Skip to content

Commit 472d4c4

Browse files
committed
Revert length() perturbation of AUTO_INCREMENT correlated subquery
The probe-validated `length(<alias>.table_name) > 0` perturbation didn't fix testInformationSchemaTablesFilterByAutoIncrement under Turso mid-suite (CI run 24933743168 still failed the test). The state-dependent Turso bug isn't a missing outer-row reference; it's something else in Turso's mid-suite optimizer. Drop the patch to keep the workflow's translate_table_ref output identical to upstream, and update the workflow note.
1 parent 78066d7 commit 472d4c4

1 file changed

Lines changed: 10 additions & 59 deletions

File tree

.github/workflows/phpunit-tests-turso.yml

Lines changed: 10 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,65 +1906,16 @@ jobs:
19061906
# driver-side workaround found that doesn't break a
19071907
# currently-passing test.
19081908

1909-
# 21. testInformationSchemaTablesFilterByAutoIncrement fails on
1910-
# Turso mid-suite because the WHERE filter on the AUTO_INCREMENT
1911-
# alias of a correlated subquery in a derived-table SELECT
1912-
# list returns 0 rows. CI probe of the exact same query
1913-
# shape on a fresh PDO returns the correct rows, so the bug
1914-
# is state-dependent.
1915-
#
1916-
# The probe also showed that adding `AND length(<alias>.table_name) > 0`
1917-
# to the correlated subquery's WHERE clause works (forces a
1918-
# fresh outer-column reference at each evaluation). Apply
1919-
# that perturbation here. This change keeps the overall
1920-
# translate_table_ref shape identical except for one extra
1921-
# redundant predicate in the WHERE — which we hope doesn't
1922-
# trigger Turso's testReconstructTable pager fragility the
1923-
# way restructuring to a JOIN form did.
1924-
path = 'src/sqlite/class-wp-pdo-mysql-on-sqlite.php'
1925-
src = open(path).read()
1926-
old_corr = (
1927-
"\t\t\t\t\t$auto_increment_subquery = sprintf(\n"
1928-
"\t\t\t\t\t\t\"(\n"
1929-
"\t\t\t\t\t\t\tSELECT COALESCE(s.seq + 1, 1)\n"
1930-
"\t\t\t\t\t\t\tFROM %s AS c\n"
1931-
"\t\t\t\t\t\t\t%s\n"
1932-
"\t\t\t\t\t\t\tWHERE c.extra = 'auto_increment'\n"
1933-
"\t\t\t\t\t\t\tAND c.table_schema = %s.table_schema\n"
1934-
"\t\t\t\t\t\t\tAND c.table_name = %s.table_name\n"
1935-
"\t\t\t\t\t\t)\",\n"
1936-
"\t\t\t\t\t\t$this->quote_sqlite_identifier( $columns_table ),\n"
1937-
"\t\t\t\t\t\t$has_sequence_table\n"
1938-
"\t\t\t\t\t\t\t? 'LEFT JOIN main.sqlite_sequence AS s ON s.name = c.table_name'\n"
1939-
"\t\t\t\t\t\t\t: 'LEFT JOIN (SELECT 0 AS seq) AS s',\n"
1940-
"\t\t\t\t\t\t$this->quote_sqlite_identifier( $table_name ),\n"
1941-
"\t\t\t\t\t\t$this->quote_sqlite_identifier( $table_name )\n"
1942-
"\t\t\t\t\t);\n"
1943-
)
1944-
new_corr = (
1945-
"\t\t\t\t\t$auto_increment_subquery = sprintf(\n"
1946-
"\t\t\t\t\t\t\"(\n"
1947-
"\t\t\t\t\t\t\tSELECT COALESCE(s.seq + 1, 1)\n"
1948-
"\t\t\t\t\t\t\tFROM %s AS c\n"
1949-
"\t\t\t\t\t\t\t%s\n"
1950-
"\t\t\t\t\t\t\tWHERE c.extra = 'auto_increment'\n"
1951-
"\t\t\t\t\t\t\tAND c.table_schema = %s.table_schema\n"
1952-
"\t\t\t\t\t\t\tAND c.table_name = %s.table_name\n"
1953-
"\t\t\t\t\t\t\tAND length(%s.table_name) > 0\n"
1954-
"\t\t\t\t\t\t)\",\n"
1955-
"\t\t\t\t\t\t$this->quote_sqlite_identifier( $columns_table ),\n"
1956-
"\t\t\t\t\t\t$has_sequence_table\n"
1957-
"\t\t\t\t\t\t\t? 'LEFT JOIN main.sqlite_sequence AS s ON s.name = c.table_name'\n"
1958-
"\t\t\t\t\t\t\t: 'LEFT JOIN (SELECT 0 AS seq) AS s',\n"
1959-
"\t\t\t\t\t\t$this->quote_sqlite_identifier( $table_name ),\n"
1960-
"\t\t\t\t\t\t$this->quote_sqlite_identifier( $table_name ),\n"
1961-
"\t\t\t\t\t\t$this->quote_sqlite_identifier( $table_name )\n"
1962-
"\t\t\t\t\t);\n"
1963-
)
1964-
assert old_corr in src, 'translate_table_ref AUTO_INCREMENT correlated subquery not found'
1965-
src = src.replace(old_corr, new_corr, 1)
1966-
open(path, 'w').write(src)
1967-
print('patched translate_table_ref AUTO_INCREMENT correlated subquery with length() perturbation')
1909+
# 21. NOTE: testInformationSchemaTablesFilterByAutoIncrement fails
1910+
# on Turso mid-suite because the WHERE filter on the
1911+
# AUTO_INCREMENT alias of a correlated subquery in a
1912+
# derived-table SELECT list returns 0 rows. CI probe of the
1913+
# same shape on a fresh PDO works (mirrors testReconstructTable's
1914+
# state-dependent failure). Adding `AND length(<alias>.table_name) > 0`
1915+
# to the correlated subquery's WHERE didn't help — the
1916+
# mid-suite Turso state corrupts a different code path than
1917+
# a missing outer-row reference. Restructuring to a JOIN
1918+
# form crashes testReconstructTable. Test stays failing.
19681919
PY
19691920

19701921
- name: Run PHPUnit tests against Turso DB

0 commit comments

Comments
 (0)