This repository was archived by the owner on Sep 11, 2026. It is now read-only.
Repository navigation
Commit dfd509c
Avoid a row-value UPDATE when syncing column key info
sync_column_key_info() assigned COLUMN_KEY and IS_NULLABLE together as a row
value fed by a correlated aggregate subquery. On SQLite that is safe: an
aggregate with no GROUP BY always yields exactly one row, so the CASE ELSE
branches always supply a value.
Turso does not always yield that row. When the row being updated sorts before a
row that does have a matching statistics entry, the subquery produces no row,
both columns are set to NULL, and the NOT NULL constraint on IS_NULLABLE fails:
NOT NULL constraint failed: _wp_sqlite_mysql_information_schema_columns.IS_NULLABLE
Reproduced against Turso 0.8.0-pre.7 with no PHP involved: two rows in a STRICT
table, only the later one indexed, and the same UPDATE. Whether it fails depends
purely on the sort order of the stored COLUMN_NAME values. WordPress hits it on
9 of the 12 core tables, because wp_users.comment_id-style columns sort before
the indexed primary key column -- so CREATE TABLE fails and wp_install() cannot
complete.
Assign the two columns separately and wrap each subquery in COALESCE(), falling
back to the values the ELSE branches would have produced for a column with no
index entries. Verified to produce identical results to the row-value form on
real SQLite, and to fix the failure on Turso.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 22ad5d8 commit dfd509c
2 files changed
Lines changed: 50 additions & 27 deletions
File tree
- packages/mysql-on-sqlite
- src/sqlite
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1954 | 1954 | | |
1955 | 1955 | | |
1956 | 1956 | | |
1957 | | - | |
1958 | | - | |
1959 | | - | |
1960 | | - | |
1961 | | - | |
1962 | | - | |
1963 | | - | |
1964 | | - | |
1965 | | - | |
1966 | | - | |
1967 | | - | |
1968 | | - | |
1969 | | - | |
1970 | | - | |
1971 | | - | |
1972 | | - | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
1973 | 1974 | | |
1974 | 1975 | | |
1975 | | - | |
1976 | | - | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
1977 | 2000 | | |
1978 | 2001 | | |
1979 | | - | |
| 2002 | + | |
1980 | 2003 | | |
1981 | 2004 | | |
1982 | 2005 | | |
| |||
0 commit comments