Issue Bug Resolved

#110422An index over a column that does not exist destroys a SQLite database

Stefan Bürk 08/11/26, 01:22 updated 09/02/26, 09:40

Description

An ext_tables.sql definition that indexes a column the table does not declare – a typo, or a column removed while the index over it stayed – is accepted by TYPO3 and handed to the platform.

MySQL and PostgreSQL reject such an index themselves, which keeps the damage to a failed statement. SQLite accepts it, because a quoted identifier that matches no column is read as a string literal:

CREATE INDEX i1 ON t ("nonexistent")   -- accepted, indexes the string constant
CREATE INDEX i2 ON t (nonexistent) -- rejected, "no such column"

TYPO3 quotes index columns, so it always produces the accepting form. The resulting index covers no column at all, pragma_index_info reports NULL for it, and introspection then throws:

Doctrine\DBAL\Schema\Metadata\IndexColumnMetadataRow::__construct():
Argument #7 ($columnName) must be of type string, null given

From that point on the database cannot be introspected at all: the schema analysis of the install tool and of the command line both die, and there is no way back through TYPO3. Recovery requires a manual DROP INDEX on the indexes whose pragma_index_info column name is NULL.

Fix

Check the columns of every index against the table before anything is applied and report an invalid definition, naming table, index and column. The check has to run once all definitions for that table are merged – extensions add an index to a table owned by another extension in a statement of their own, which does not repeat the columns the index covers, so checking a single statement would not do.

Patch

Gerrit 95187, topic database-analyzer.

Releases: main, 14.3, 13.4

Reviews 3