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
Tighter probe + force temp_store=MEMORY under Turso
Two changes in one CI iteration to maximize use of the build:
- Tighten the correlated-subquery probe: the minimal repro passed
every workaround variant on Turso, so the bug isn't fundamental.
Replace it with a probe that mirrors the *exact* shape the driver
emits — info_schema-style _ist/_isc/sqlseq tables, the multi-table
LEFT JOIN inside the correlated subquery, and COALESCE — then run
the failing-test query patterns (`AI > 3`, `AI IS NULL`, plain
SELECT) and print the actual rows so we can see what Turso returns.
- Patch the SQLite connection's __construct to issue
`PRAGMA temp_store = MEMORY` after journal_mode setup. Turso's
default disk-backed temp pager has a state-dependent
`short read on page N` bug (mid-suite, doesn't reproduce in fresh
PDO). Forcing temp_store=MEMORY routes temp tables through MemoryIO,
which is the same code path the probe exercises and which works.
This is the candidate fix for testCreateTemporaryTable +
testTemporaryTableHasPriorityOverStandardTable.
$pdo->exec("INSERT INTO sqlseq VALUES ('low',1), ('high',5)");
1030
+
1031
+
// Driver's actual correlated subquery shape:
1032
+
$corr = "(SELECT COALESCE(s.seq + 1, 1)
1033
+
FROM _isc AS c
1034
+
LEFT JOIN sqlseq AS s ON s.name = c.table_name
1035
+
WHERE c.extra = 'auto_increment'
1036
+
AND c.table_schema = t.table_schema
1037
+
AND c.table_name = t.table_name)";
1038
+
1039
+
$derived = "(SELECT table_name AS NAME, $corr AS AI FROM _ist AS t)";
1027
1040
1028
1041
$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",
1042
+
'inline correlated subq value' =>
1043
+
"SELECT table_name, $corr AS AI FROM _ist AS t",
1044
+
'derived-table + WHERE AI > 3 (the bug)' =>
1045
+
"SELECT NAME FROM $derived WHERE AI > 3",
1046
+
'derived-table + WHERE AI IS NULL' =>
1047
+
"SELECT NAME FROM $derived WHERE AI IS NULL",
1048
+
'derived-table + plain SELECT' =>
1049
+
"SELECT NAME, AI FROM $derived",
1050
+
'derived-table + WHERE on AI with length(t.name) > 0 forced' =>
1051
+
("SELECT NAME FROM (SELECT table_name AS NAME, "
1052
+
. "(SELECT COALESCE(s.seq + 1, 1) FROM _isc AS c "
1053
+
. "LEFT JOIN sqlseq AS s ON s.name = c.table_name "
1054
+
. "WHERE c.extra='auto_increment' "
1055
+
. "AND c.table_schema = t.table_schema "
1056
+
. "AND c.table_name = t.table_name "
1057
+
. "AND length(t.table_name) > 0) AS AI FROM _ist AS t) WHERE AI > 3"),
0 commit comments