Issue found by SQLSmith on git commit hash aef7b using seed 480464966.
To Reproduce
create table all_types as select * exclude(small_enum, medium_enum, large_enum) from test_all_types() limit 0;
SELECT NULL FROM (SELECT ref_0.date_array AS c0, ref_0."bigint" AS c1, ref_0.time_tz AS c2, 95 AS c3, CAST("nullif"(ref_0."double", ref_0."double") AS DOUBLE) AS c4, ref_0.double_array AS c5 FROM main.all_types AS ref_0 WHERE (EXISTS(SELECT (SELECT "bigint" FROM main.all_types LIMIT 1 OFFSET 2) AS c0, subq_0.c1 AS c1, ref_1."union" AS c2, 53 AS c3, ref_1.uint AS c4, ref_0.timestamp_tz AS c5, 53 AS c6, ref_1.array_of_structs AS c7, subq_0.c1 AS c8, ref_0.uhugeint AS c9 FROM main.all_types AS ref_1 , (SELECT ref_1.fixed_int_array AS c0, ref_1."time" AS c1 FROM main.all_types AS ref_2 WHERE (ref_0."varchar" !~~* ref_2."varchar") LIMIT 106) AS subq_0 WHERE EXISTS(SELECT 65 AS c0, subq_0.c1 AS c1, ref_0.hugeint AS c2, ref_3."float" AS c3, (SELECT struct_of_fixed_array FROM main.all_types LIMIT 1 OFFSET 6) AS c4, ref_0."map" AS c5, (SELECT date_array FROM main.all_types LIMIT 1 OFFSET 1) AS c6, subq_1.c2 AS c7, subq_0.c0 AS c8 FROM main.all_types AS ref_3 , (SELECT ref_0.blob AS c0, ref_3."float" AS c1, ref_1.usmallint AS c2, ref_4.nested_int_array AS c3, ref_0.dec38_10 AS c4, subq_0.c1 AS c5, ref_1."bit" AS c6 FROM main.all_types AS ref_4 WHERE (CAST(NULL AS VARCHAR) ~~* ref_0."varchar")) AS subq_1 WHERE EXISTS(SELECT 14 AS c0, ref_0.timestamp_s AS c1, ref_0.list_of_fixed_int_array AS c2, subq_0.c1 AS c3, subq_1.c0 AS c4, ref_5.bool AS c5, ref_1.usmallint AS c6 FROM main.all_types AS ref_5 WHERE (ref_1."varchar" ^@ (SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 3)) LIMIT 149) LIMIT 70) LIMIT 37) OR (ref_0."varchar" ~~ ref_0."varchar"))) AS subq_2 WHERE (CASE WHEN ((NULL !~~ (SELECT NULL))) THEN ((SELECT NULL)) ELSE (SELECT NULL) END AND (((SELECT "varchar" FROM main.all_types) ~~~ CASE WHEN (((CAST(NULL AS VARCHAR) ~~* (SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 6)) AND EXISTS(SELECT (SELECT "time" FROM main.all_types LIMIT 1 OFFSET 5) AS c0, ref_6."double" AS c1 FROM main.all_types AS ref_6 WHERE EXISTS(SELECT ref_6.struct_of_fixed_array AS c0, ref_6.tinyint AS c1, ref_7.timestamp_ms AS c2, ref_6."int" AS c3, subq_2.c2 AS c4 FROM main.all_types AS ref_7 WHERE (1 AND 0)) LIMIT 105))) THEN (CASE WHEN (((CAST(NULL AS VARCHAR) ~~* (SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 90)) OR (subq_2.c3 IS NULL))) THEN ((SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 2)) ELSE (SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 2) END) ELSE CASE WHEN (((CAST(NULL AS VARCHAR) ~~* (SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 90)) OR (subq_2.c3 IS NULL))) THEN ((SELECT "varchar" FROM main.all_types LIMIT 1 OFFSET 2)) ELSE (SELECT NULL FROM main.all_types LIMIT 1 OFFSET 2) END END) OR ((SELECT "timestamp" FROM main.all_types LIMIT 1 OFFSET 1) IS NOT NULL)))
Error Message
ABORT THROWN BY INTERNAL EXCEPTION: Failed to bind column reference "c0" [119.5] (bindings: {#[213.0], #[210.0]})
Issue found by SQLSmith on git commit hash aef7b using seed 480464966.
To Reproduce
Error Message