Skip to content

Commit 1416186

Browse files
committed
Drop UPDATE rewrite patch — caused PHPUnit to hang
The rewrite of sync_column_key_info's row-value UPDATE into two correlated subqueries produced valid SQL but triggered a Turso query planner pathological case: PHPUnit hung indefinitely somewhere after test 504/667. Keep only temporary_table_exists and wp_die polyfill.
1 parent 325615a commit 1416186

1 file changed

Lines changed: 7 additions & 70 deletions

File tree

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

Lines changed: 7 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -458,77 +458,14 @@ jobs:
458458
assert old in src, 'temporary_table_exists body not found'
459459
src = src.replace(old, new, 1)
460460
461-
# 2. Turso's UPDATE statement doesn't accept row-value assignment from
462-
# a subquery (`SET (a, b) = (SELECT ...)`). Rewrite the single query
463-
# in sync_column_key_info as two correlated subqueries, one per
464-
# target column.
465-
old = (
466-
"\t\t$this->connection->query(\n"
467-
"\t\t\t'\n"
468-
"\t\t\t\tUPDATE ' . $this->connection->quote_identifier( $columns_table_name ) . \" AS c\n"
469-
"\t\t\t\tSET (column_key, is_nullable) = (\n"
470-
"\t\t\t\t\tSELECT\n"
471-
"\t\t\t\t\t\tCASE\n"
472-
"\t\t\t\t\t\t\tWHEN MAX(s.index_name = 'PRIMARY') THEN 'PRI'\n"
473-
"\t\t\t\t\t\t\tWHEN MAX(s.non_unique = 0 AND s.seq_in_index = 1) THEN 'UNI'\n"
474-
"\t\t\t\t\t\t\tWHEN MAX(s.seq_in_index = 1) THEN 'MUL'\n"
475-
"\t\t\t\t\t\t\tELSE ''\n"
476-
"\t\t\t\t\t\tEND,\n"
477-
"\t\t\t\t\t\tCASE\n"
478-
"\t\t\t\t\t\t\tWHEN MAX(s.index_name = 'PRIMARY') THEN 'NO'\n"
479-
"\t\t\t\t\t\t\tELSE c.is_nullable\n"
480-
"\t\t\t\t\t\tEND\n"
481-
"\t\t\t\t\tFROM \" . $this->connection->quote_identifier( $statistics_table_name ) . ' AS s\n"
482-
"\t\t\t\t\tWHERE s.table_schema = c.table_schema\n"
483-
"\t\t\t\t\tAND s.table_name = c.table_name\n"
484-
"\t\t\t\t\tAND s.column_name = c.column_name\n"
485-
"\t\t\t\t)\n"
486-
"\t\t\t WHERE c.table_schema = ?\n"
487-
"\t\t\t AND c.table_name = ?\n"
488-
"\t\t\t',\n"
489-
"\t\t\tarray( self::SAVED_DATABASE_NAME, $table_name )\n"
490-
"\t\t);"
491-
)
492-
assert old in src, 'sync_column_key_info UPDATE not found'
493-
new = "\n".join([
494-
"\t\t$columns_table = $this->connection->quote_identifier( $columns_table_name );",
495-
"\t\t$statistics_table = $this->connection->quote_identifier( $statistics_table_name );",
496-
"\t\t$this->connection->query(",
497-
"\t\t\t\"",
498-
"\t\t\t\tUPDATE $columns_table AS c",
499-
"\t\t\t\tSET column_key = (",
500-
"\t\t\t\t\tSELECT",
501-
"\t\t\t\t\t\tCASE",
502-
"\t\t\t\t\t\t\tWHEN MAX(s.index_name = 'PRIMARY') THEN 'PRI'",
503-
"\t\t\t\t\t\t\tWHEN MAX(s.non_unique = 0 AND s.seq_in_index = 1) THEN 'UNI'",
504-
"\t\t\t\t\t\t\tWHEN MAX(s.seq_in_index = 1) THEN 'MUL'",
505-
"\t\t\t\t\t\t\tELSE ''",
506-
"\t\t\t\t\t\tEND",
507-
"\t\t\t\t\tFROM $statistics_table AS s",
508-
"\t\t\t\t\tWHERE s.table_schema = c.table_schema",
509-
"\t\t\t\t\tAND s.table_name = c.table_name",
510-
"\t\t\t\t\tAND s.column_name = c.column_name",
511-
"\t\t\t\t),",
512-
"\t\t\t\tis_nullable = (",
513-
"\t\t\t\t\tSELECT",
514-
"\t\t\t\t\t\tCASE",
515-
"\t\t\t\t\t\t\tWHEN MAX(s.index_name = 'PRIMARY') THEN 'NO'",
516-
"\t\t\t\t\t\t\tELSE c.is_nullable",
517-
"\t\t\t\t\t\tEND",
518-
"\t\t\t\t\tFROM $statistics_table AS s",
519-
"\t\t\t\t\tWHERE s.table_schema = c.table_schema",
520-
"\t\t\t\t\tAND s.table_name = c.table_name",
521-
"\t\t\t\t\tAND s.column_name = c.column_name",
522-
"\t\t\t\t)",
523-
"\t\t\t\tWHERE c.table_schema = ?",
524-
"\t\t\t\tAND c.table_name = ?",
525-
"\t\t\t\",",
526-
"\t\t\tarray( self::SAVED_DATABASE_NAME, $table_name )",
527-
"\t\t);",
528-
])
529-
src = src.replace(old, new, 1)
461+
# (Earlier attempt also rewrote sync_column_key_info's UPDATE to
462+
# work around Turso's lack of row-value assignment from a subquery,
463+
# but the rewrite caused PHPUnit to hang indefinitely on a specific
464+
# test around position 504/667 — likely a pathological case in
465+
# Turso's query planner. Dropped for now; the 40 affected tests
466+
# remain errors.)
530467
open(path, 'w').write(src)
531-
print('patched information-schema-builder.php')
468+
print('patched information-schema-builder.php (temporary_table_exists only)')
532469
533470
# 3. wp_die polyfill: 21 tests hit an error path in the driver that
534471
# calls wp_die(). Real WordPress provides it; the unit-test bootstrap

0 commit comments

Comments
 (0)