Skip to content

Commit

Permalink
WIP information_schema reusability for ALTER statements
Browse files Browse the repository at this point in the history
  • Loading branch information
JanJakes committed Dec 13, 2024
1 parent 385e708 commit d1dfbdb
Show file tree
Hide file tree
Showing 2 changed files with 192 additions and 193 deletions.
12 changes: 9 additions & 3 deletions tests/WP_SQLite_Driver_Translation_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,11 @@ public function testCreateTableWithPrimaryKeyAndAutoincrement(): void {
'INSERT INTO _mysql_information_schema_tables (table_schema, table_name, table_type, engine, row_format, table_collation)'
. " VALUES ('wp', 't3', 'BASE TABLE', 'InnoDB', 'DYNAMIC', 'utf8mb4_general_ci')",
'INSERT INTO _mysql_information_schema_columns (table_schema, table_name, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, datetime_precision, character_set_name, collation_name, column_type, column_key, extra, privileges, column_comment, generation_expression, srs_id)'
. " VALUES ('wp', 't3', 'id', 1, null, 'NO', 'int', null, null, 10, 0, null, null, null, 'int', 'PRI', 'auto_increment', 'select,insert,update,references', '', '', null)",
. " VALUES ('wp', 't3', 'id', 1, null, 'YES', 'int', null, null, 10, 0, null, null, null, 'int', '', 'auto_increment', 'select,insert,update,references', '', '', null)",
"SELECT column_name, data_type, is_nullable, character_maximum_length FROM _mysql_information_schema_columns WHERE table_name = 't3' AND column_name IN ('id')",
'INSERT INTO _mysql_information_schema_statistics (table_schema, table_name, non_unique, index_schema, index_name, seq_in_index, column_name, collation, cardinality, sub_part, packed, nullable, index_type, comment, index_comment, is_visible, expression)'
. " VALUES ('wp', 't3', 0, 'wp', 'PRIMARY', 1, 'id', 'A', 0, null, null, '', 'BTREE', '', '', 'YES', null)",
"UPDATE _mysql_information_schema_columns AS c SET column_key = CASE WHEN s.index_name = 'PRIMARY' THEN 'PRI' WHEN s.non_unique = 0 AND s.seq_in_index = 1 THEN 'UNI' WHEN s.seq_in_index = 1 THEN 'MUL' ELSE '' END, is_nullable = CASE WHEN s.nullable = 'YES' THEN 'YES' ELSE 'NO' END FROM _mysql_information_schema_statistics AS s WHERE c.table_name = 't3' AND c.table_name = s.table_name AND c.column_name = s.column_name",
"SELECT * FROM _mysql_information_schema_tables WHERE table_type = \"BASE TABLE\" AND table_schema = 'wp' AND table_name = 't3'",
"SELECT * FROM _mysql_information_schema_columns WHERE table_schema = 'wp' AND table_name = 't3'",
"SELECT * FROM _mysql_information_schema_statistics WHERE table_schema = 'wp' AND table_name = 't3'",
Expand Down Expand Up @@ -439,13 +441,17 @@ public function testCreateTableWithStandaloneUniqueIndexes(): void {
'INSERT INTO _mysql_information_schema_tables (table_schema, table_name, table_type, engine, row_format, table_collation)'
. " VALUES ('wp', 't', 'BASE TABLE', 'InnoDB', 'DYNAMIC', 'utf8mb4_general_ci')",
'INSERT INTO _mysql_information_schema_columns (table_schema, table_name, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, datetime_precision, character_set_name, collation_name, column_type, column_key, extra, privileges, column_comment, generation_expression, srs_id)'
. " VALUES ('wp', 't', 'id', 1, null, 'YES', 'int', null, null, 10, 0, null, null, null, 'int', 'UNI', '', 'select,insert,update,references', '', '', null)",
. " VALUES ('wp', 't', 'id', 1, null, 'YES', 'int', null, null, 10, 0, null, null, null, 'int', '', '', 'select,insert,update,references', '', '', null)",
'INSERT INTO _mysql_information_schema_columns (table_schema, table_name, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, datetime_precision, character_set_name, collation_name, column_type, column_key, extra, privileges, column_comment, generation_expression, srs_id)'
. " VALUES ('wp', 't', 'name', 2, null, 'YES', 'varchar', 100, 400, null, null, null, 'utf8mb4', 'utf8mb4_general_ci', 'varchar(100)', 'UNI', '', 'select,insert,update,references', '', '', null)",
. " VALUES ('wp', 't', 'name', 2, null, 'YES', 'varchar', 100, 400, null, null, null, 'utf8mb4', 'utf8mb4_general_ci', 'varchar(100)', '', '', 'select,insert,update,references', '', '', null)",
"SELECT column_name, data_type, is_nullable, character_maximum_length FROM _mysql_information_schema_columns WHERE table_name = 't' AND column_name IN ('id')",
'INSERT INTO _mysql_information_schema_statistics (table_schema, table_name, non_unique, index_schema, index_name, seq_in_index, column_name, collation, cardinality, sub_part, packed, nullable, index_type, comment, index_comment, is_visible, expression)'
. " VALUES ('wp', 't', 0, 'wp', 'id', 1, 'id', 'A', 0, null, null, 'YES', 'BTREE', '', '', 'YES', null)",
"UPDATE _mysql_information_schema_columns AS c SET column_key = CASE WHEN s.index_name = 'PRIMARY' THEN 'PRI' WHEN s.non_unique = 0 AND s.seq_in_index = 1 THEN 'UNI' WHEN s.seq_in_index = 1 THEN 'MUL' ELSE '' END, is_nullable = CASE WHEN s.nullable = 'YES' THEN 'YES' ELSE 'NO' END FROM _mysql_information_schema_statistics AS s WHERE c.table_name = 't' AND c.table_name = s.table_name AND c.column_name = s.column_name",
"SELECT column_name, data_type, is_nullable, character_maximum_length FROM _mysql_information_schema_columns WHERE table_name = 't' AND column_name IN ('name')",
'INSERT INTO _mysql_information_schema_statistics (table_schema, table_name, non_unique, index_schema, index_name, seq_in_index, column_name, collation, cardinality, sub_part, packed, nullable, index_type, comment, index_comment, is_visible, expression)'
. " VALUES ('wp', 't', 0, 'wp', 'name', 1, 'name', 'A', 0, null, null, 'YES', 'BTREE', '', '', 'YES', null)",
"UPDATE _mysql_information_schema_columns AS c SET column_key = CASE WHEN s.index_name = 'PRIMARY' THEN 'PRI' WHEN s.non_unique = 0 AND s.seq_in_index = 1 THEN 'UNI' WHEN s.seq_in_index = 1 THEN 'MUL' ELSE '' END, is_nullable = CASE WHEN s.nullable = 'YES' THEN 'YES' ELSE 'NO' END FROM _mysql_information_schema_statistics AS s WHERE c.table_name = 't' AND c.table_name = s.table_name AND c.column_name = s.column_name",
"SELECT * FROM _mysql_information_schema_tables WHERE table_type = \"BASE TABLE\" AND table_schema = 'wp' AND table_name = 't'",
"SELECT * FROM _mysql_information_schema_columns WHERE table_schema = 'wp' AND table_name = 't'",
"SELECT * FROM _mysql_information_schema_statistics WHERE table_schema = 'wp' AND table_name = 't'",
Expand Down
Loading

0 comments on commit d1dfbdb

Please sign in to comment.