You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add CI probe for Turso correlated-subquery-in-derived-table bug
Reproduce testInformationSchemaTablesFilterByAutoIncrement's bug
shape minimally and try several workarounds:
- baseline: correlated subq, no derived-table wrap (sanity check)
- derived-table wrap + WHERE on alias (the failing shape)
- same + length() trick to force outer ref into inner WHERE
- same + outer col added to inner SELECT via zero-arith
- same + outer col concatenated into a separate alias
- JOIN form (same shape as my failed translate_table_ref attempt)
Probe is informational; if any variant returns the correct rows we
have a candidate fix that doesn't need to touch translate_table_ref's
overall shape.
$pdo->exec('CREATE TABLE outer_t (id INT, name TEXT)');
1024
+
$pdo->exec('CREATE TABLE inner_t (parent_name TEXT, value INT)');
1025
+
$pdo->exec("INSERT INTO outer_t VALUES (1,'a'), (2,'b'), (3,'c')");
1026
+
$pdo->exec("INSERT INTO inner_t VALUES ('a',10), ('b',20), ('c',30)");
1027
+
1028
+
$cases = [
1029
+
'baseline: correlated subq, no derived-table wrap' =>
1030
+
"SELECT id, (SELECT value FROM inner_t WHERE parent_name = outer_t.name) AS v FROM outer_t WHERE (SELECT value FROM inner_t WHERE parent_name = outer_t.name) > 15",
1031
+
'derived-table wrap + WHERE on alias' =>
1032
+
"SELECT id FROM (SELECT id, name, (SELECT value FROM inner_t WHERE parent_name = outer_t.name) AS v FROM outer_t) WHERE v > 15",
1033
+
'derived-table + WHERE on alias + outer col aliased in inner WHERE (length trick)' =>
1034
+
"SELECT id FROM (SELECT id, name, (SELECT value FROM inner_t WHERE parent_name = outer_t.name AND length(outer_t.name) > 0) AS v FROM outer_t) WHERE v > 15",
1035
+
'derived-table + WHERE on alias + outer col added in inner SELECT (zero arith)' =>
1036
+
"SELECT id FROM (SELECT id, name, (SELECT value + (length(outer_t.name) - length(outer_t.name)) FROM inner_t WHERE parent_name = outer_t.name) AS v FROM outer_t) WHERE v > 15",
1037
+
'derived-table + WHERE on alias + outer col combined into expression' =>
1038
+
"SELECT id FROM (SELECT id, name, (SELECT value || '|' || outer_t.name FROM inner_t WHERE parent_name = outer_t.name) AS combined, (SELECT value FROM inner_t WHERE parent_name = outer_t.name) AS v FROM outer_t) WHERE v > 15",
1039
+
'derived-table + WHERE on alias + recreate as JOIN form' =>
1040
+
"SELECT id FROM (SELECT outer_t.id, outer_t.name, inner_t.value AS v FROM outer_t LEFT JOIN inner_t ON inner_t.parent_name = outer_t.name) WHERE v > 15",
0 commit comments