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
{{ message }}
Repository navigation
SHOW CREATE TABLE drops index prefix lengths and DESC from primary keys #501
SHOW CREATE TABLE loses index prefix lengths and descending order in the PRIMARY KEY clause. A table created with PRIMARY KEY (session_id(100)) on a MEDIUMTEXT column is reported as PRIMARY KEY (session_id), and PRIMARY KEY (a DESC, b) comes back as PRIMARY KEY (a, b).
The information schema records the data correctly (SUB_PART = 100, COLLATION = 'D' in _wp_sqlite_mysql_information_schema_statistics); only the PRIMARY KEY branch of the statement reconstruction drops it, while the branch handling all other index types preserves both.
Impact
Any consumer that rebuilds a schema from SHOW CREATE TABLE produces DDL that MySQL rejects: ERROR 1170 (42000): BLOB/TEXT column used in key specification without a key length. This is how the bug surfaces in WordPress Studio's push feature (wp sqlite export relays the statement as is), reported in Automattic/studio#4739.
Reproduction
CREATETABLEt (session_id MEDIUMTEXT NOT NULL, PRIMARY KEY (session_id(100)));
SHOW CREATE TABLE t;
-- reports: PRIMARY KEY (`session_id`)-- expected, as in MySQL 8: PRIMARY KEY (`session_id`(100))
Verified against a real MySQL 8 server: its SHOW CREATE TABLE emits PRIMARY KEY (session_id(100)) for the same table, and re-importing the driver's current output fails there with ERROR 1170.
Activity
Preserve index prefix lengths and order in SHOW CREATE TABLE primary …