@@ -9809,4 +9809,248 @@ public function testWriteWithUsageOfInformationSchemaTables(): void {
98099809 $ result
98109810 );
98119811 }
9812+
9813+ public function testNonEmptyColumnMeta (): void {
9814+ $ this ->assertQuery ( 'CREATE TABLE t (id INT PRIMARY KEY) ' );
9815+ $ this ->assertQuery ( 'INSERT INTO t VALUES (1) ' );
9816+
9817+ // SELECT
9818+ $ this ->assertQuery ( 'SELECT * FROM t ' );
9819+ $ this ->assertSame ( 1 , $ this ->engine ->get_last_column_count () );
9820+ $ this ->assertSame ( 'id ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9821+
9822+ // SHOW COLLATION
9823+ $ this ->assertQuery ( 'SHOW COLLATION ' );
9824+ $ this ->assertSame ( 7 , $ this ->engine ->get_last_column_count () );
9825+ $ this ->assertSame ( 'Collation ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9826+ $ this ->assertSame ( 'Charset ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9827+ $ this ->assertSame ( 'Id ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9828+ $ this ->assertSame ( 'Default ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9829+ $ this ->assertSame ( 'Compiled ' , $ this ->engine ->get_last_column_meta ()[4 ]['name ' ] );
9830+ $ this ->assertSame ( 'Sortlen ' , $ this ->engine ->get_last_column_meta ()[5 ]['name ' ] );
9831+ $ this ->assertSame ( 'Pad_attribute ' , $ this ->engine ->get_last_column_meta ()[6 ]['name ' ] );
9832+
9833+ // SHOW DATABASES
9834+ $ this ->assertQuery ( 'SHOW DATABASES ' );
9835+ $ this ->assertSame ( 1 , $ this ->engine ->get_last_column_count () );
9836+ $ this ->assertSame ( 'Database ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9837+
9838+ // SHOW CREATE TABLE
9839+ $ this ->assertQuery ( 'SHOW CREATE TABLE t ' );
9840+ $ this ->assertSame ( 2 , $ this ->engine ->get_last_column_count () );
9841+ $ this ->assertSame ( 'Table ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9842+ $ this ->assertSame ( 'Create Table ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9843+
9844+ // SHOW TABLE STATUS
9845+ $ this ->assertQuery ( 'SHOW TABLE STATUS ' );
9846+ $ this ->assertSame ( 18 , $ this ->engine ->get_last_column_count () );
9847+ $ this ->assertSame ( 'Name ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9848+ $ this ->assertSame ( 'Engine ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9849+ $ this ->assertSame ( 'Version ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9850+ $ this ->assertSame ( 'Row_format ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9851+ $ this ->assertSame ( 'Rows ' , $ this ->engine ->get_last_column_meta ()[4 ]['name ' ] );
9852+ $ this ->assertSame ( 'Avg_row_length ' , $ this ->engine ->get_last_column_meta ()[5 ]['name ' ] );
9853+ $ this ->assertSame ( 'Data_length ' , $ this ->engine ->get_last_column_meta ()[6 ]['name ' ] );
9854+ $ this ->assertSame ( 'Max_data_length ' , $ this ->engine ->get_last_column_meta ()[7 ]['name ' ] );
9855+ $ this ->assertSame ( 'Index_length ' , $ this ->engine ->get_last_column_meta ()[8 ]['name ' ] );
9856+ $ this ->assertSame ( 'Data_free ' , $ this ->engine ->get_last_column_meta ()[9 ]['name ' ] );
9857+ $ this ->assertSame ( 'Auto_increment ' , $ this ->engine ->get_last_column_meta ()[10 ]['name ' ] );
9858+ $ this ->assertSame ( 'Create_time ' , $ this ->engine ->get_last_column_meta ()[11 ]['name ' ] );
9859+ $ this ->assertSame ( 'Update_time ' , $ this ->engine ->get_last_column_meta ()[12 ]['name ' ] );
9860+ $ this ->assertSame ( 'Check_time ' , $ this ->engine ->get_last_column_meta ()[13 ]['name ' ] );
9861+ $ this ->assertSame ( 'Collation ' , $ this ->engine ->get_last_column_meta ()[14 ]['name ' ] );
9862+ $ this ->assertSame ( 'Checksum ' , $ this ->engine ->get_last_column_meta ()[15 ]['name ' ] );
9863+ $ this ->assertSame ( 'Create_options ' , $ this ->engine ->get_last_column_meta ()[16 ]['name ' ] );
9864+ $ this ->assertSame ( 'Comment ' , $ this ->engine ->get_last_column_meta ()[17 ]['name ' ] );
9865+
9866+ // SHOW TABLES
9867+ $ this ->assertQuery ( 'SHOW TABLES ' );
9868+ $ this ->assertSame ( 1 , $ this ->engine ->get_last_column_count () );
9869+ $ this ->assertSame ( 'Tables_in_wp ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9870+
9871+ // SHOW FULL TABLES
9872+ $ this ->assertQuery ( 'SHOW FULL TABLES ' );
9873+ $ this ->assertSame ( 2 , $ this ->engine ->get_last_column_count () );
9874+ $ this ->assertSame ( 'Tables_in_wp ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9875+ $ this ->assertSame ( 'Table_type ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9876+
9877+ // SHOW COLUMNS
9878+ $ this ->assertQuery ( 'SHOW COLUMNS FROM t ' );
9879+ $ this ->assertSame ( 6 , $ this ->engine ->get_last_column_count () );
9880+ $ this ->assertSame ( 'Field ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9881+ $ this ->assertSame ( 'Type ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9882+ $ this ->assertSame ( 'Null ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9883+ $ this ->assertSame ( 'Key ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9884+ $ this ->assertSame ( 'Default ' , $ this ->engine ->get_last_column_meta ()[4 ]['name ' ] );
9885+ $ this ->assertSame ( 'Extra ' , $ this ->engine ->get_last_column_meta ()[5 ]['name ' ] );
9886+
9887+ // SHOW INDEX
9888+ $ this ->assertQuery ( 'SHOW INDEX FROM t ' );
9889+ $ this ->assertSame ( 15 , $ this ->engine ->get_last_column_count () );
9890+ $ this ->assertSame ( 'Table ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9891+ $ this ->assertSame ( 'Non_unique ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9892+ $ this ->assertSame ( 'Key_name ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9893+ $ this ->assertSame ( 'Seq_in_index ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9894+ $ this ->assertSame ( 'Column_name ' , $ this ->engine ->get_last_column_meta ()[4 ]['name ' ] );
9895+ $ this ->assertSame ( 'Collation ' , $ this ->engine ->get_last_column_meta ()[5 ]['name ' ] );
9896+ $ this ->assertSame ( 'Cardinality ' , $ this ->engine ->get_last_column_meta ()[6 ]['name ' ] );
9897+ $ this ->assertSame ( 'Sub_part ' , $ this ->engine ->get_last_column_meta ()[7 ]['name ' ] );
9898+ $ this ->assertSame ( 'Packed ' , $ this ->engine ->get_last_column_meta ()[8 ]['name ' ] );
9899+ $ this ->assertSame ( 'Null ' , $ this ->engine ->get_last_column_meta ()[9 ]['name ' ] );
9900+ $ this ->assertSame ( 'Index_type ' , $ this ->engine ->get_last_column_meta ()[10 ]['name ' ] );
9901+ $ this ->assertSame ( 'Comment ' , $ this ->engine ->get_last_column_meta ()[11 ]['name ' ] );
9902+ $ this ->assertSame ( 'Index_comment ' , $ this ->engine ->get_last_column_meta ()[12 ]['name ' ] );
9903+ $ this ->assertSame ( 'Visible ' , $ this ->engine ->get_last_column_meta ()[13 ]['name ' ] );
9904+ $ this ->assertSame ( 'Expression ' , $ this ->engine ->get_last_column_meta ()[14 ]['name ' ] );
9905+
9906+ // SHOW GRANTS
9907+ $ this ->assertQuery ( 'SHOW GRANTS ' );
9908+ $ this ->assertSame ( 1 , $ this ->engine ->get_last_column_count () );
9909+ $ this ->assertSame ( 'Grants for root@localhost ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9910+
9911+ // SHOW VARIABLES
9912+ $ this ->assertQuery ( 'SHOW VARIABLES ' );
9913+ $ this ->assertSame ( 2 , $ this ->engine ->get_last_column_count () );
9914+ $ this ->assertSame ( 'Variable_name ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9915+ $ this ->assertSame ( 'Value ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9916+
9917+ // DESCRIBE/EXPLAIN
9918+ $ this ->assertQuery ( 'DESCRIBE t ' );
9919+ $ this ->assertSame ( 6 , $ this ->engine ->get_last_column_count () );
9920+ $ this ->assertSame ( 'Field ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9921+ $ this ->assertSame ( 'Type ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9922+ $ this ->assertSame ( 'Null ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9923+ $ this ->assertSame ( 'Key ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9924+ $ this ->assertSame ( 'Default ' , $ this ->engine ->get_last_column_meta ()[4 ]['name ' ] );
9925+ $ this ->assertSame ( 'Extra ' , $ this ->engine ->get_last_column_meta ()[5 ]['name ' ] );
9926+
9927+ // ANALYZE TABLE
9928+ $ this ->assertQuery ( 'ANALYZE TABLE t ' );
9929+ $ this ->assertSame ( 4 , $ this ->engine ->get_last_column_count () );
9930+ $ this ->assertSame ( 'Table ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9931+ $ this ->assertSame ( 'Op ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9932+ $ this ->assertSame ( 'Msg_type ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9933+ $ this ->assertSame ( 'Msg_text ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9934+
9935+ // CHECK TABLE
9936+ $ this ->assertQuery ( 'CHECK TABLE t ' );
9937+ $ this ->assertSame ( 4 , $ this ->engine ->get_last_column_count () );
9938+ $ this ->assertSame ( 'Table ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9939+ $ this ->assertSame ( 'Op ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9940+ $ this ->assertSame ( 'Msg_type ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9941+ $ this ->assertSame ( 'Msg_text ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9942+
9943+ // OPTIMIZE TABLE
9944+ $ this ->assertQuery ( 'OPTIMIZE TABLE t ' );
9945+ $ this ->assertSame ( 4 , $ this ->engine ->get_last_column_count () );
9946+ $ this ->assertSame ( 'Table ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9947+ $ this ->assertSame ( 'Op ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9948+ $ this ->assertSame ( 'Msg_type ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9949+ $ this ->assertSame ( 'Msg_text ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9950+
9951+ // REPAIR TABLE
9952+ $ this ->assertQuery ( 'REPAIR TABLE t ' );
9953+ $ this ->assertSame ( 4 , $ this ->engine ->get_last_column_count () );
9954+ $ this ->assertSame ( 'Table ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9955+ $ this ->assertSame ( 'Op ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9956+ $ this ->assertSame ( 'Msg_type ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9957+ $ this ->assertSame ( 'Msg_text ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9958+ }
9959+
9960+ public function testEmptyColumnMeta (): void {
9961+ // CREATE TABLE
9962+ $ this ->assertQuery ( 'CREATE TABLE t (id INT) ' );
9963+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9964+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9965+
9966+ // INSERT
9967+ $ this ->assertQuery ( 'INSERT INTO t (id) VALUES (1) ' );
9968+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9969+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9970+
9971+ // REPLACE
9972+ $ this ->assertQuery ( 'UPDATE t SET id = 1 ' );
9973+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9974+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9975+
9976+ // DELETE
9977+ $ this ->assertQuery ( 'DELETE FROM t ' );
9978+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9979+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9980+
9981+ // TRUNCATE TABLE
9982+ $ this ->assertQuery ( 'TRUNCATE TABLE t ' );
9983+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9984+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9985+
9986+ // START TRANSACTION
9987+ $ this ->assertQuery ( 'START TRANSACTION ' );
9988+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9989+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9990+
9991+ // COMMIT
9992+ $ this ->assertQuery ( 'COMMIT ' );
9993+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9994+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9995+
9996+ // ROLLBACK
9997+ $ this ->assertQuery ( 'ROLLBACK ' );
9998+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9999+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
10000+
10001+ // SAVEPOINT
10002+ $ this ->assertQuery ( 'SAVEPOINT s1 ' );
10003+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
10004+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
10005+
10006+ // ROLLBACK TO SAVEPOINT
10007+ $ this ->assertQuery ( 'ROLLBACK TO SAVEPOINT s1 ' );
10008+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
10009+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
10010+
10011+ // RELEASE SAVEPOINT
10012+ $ this ->assertQuery ( 'RELEASE SAVEPOINT s1 ' );
10013+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
10014+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
10015+
10016+ // LOCK TABLE
10017+ $ this ->assertQuery ( 'LOCK TABLES t READ ' );
10018+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
10019+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
10020+
10021+ // UNLOCK TABLE
10022+ $ this ->assertQuery ( 'UNLOCK TABLES ' );
10023+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
10024+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
10025+
10026+ // ALTER TABLE
10027+ $ this ->assertQuery ( 'ALTER TABLE t ADD COLUMN name VARCHAR(255) ' );
10028+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
10029+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
10030+
10031+ // CREATE INDEX
10032+ $ this ->assertQuery ( 'CREATE INDEX idx_name ON t (name) ' );
10033+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
10034+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
10035+
10036+ // DROP INDEX
10037+ $ this ->assertQuery ( 'DROP INDEX idx_name ON t ' );
10038+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
10039+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
10040+
10041+ // DROP TABLE
10042+ $ this ->assertQuery ( 'DROP TABLE t ' );
10043+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
10044+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
10045+
10046+ // USE
10047+ $ this ->assertQuery ( 'USE wp ' );
10048+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
10049+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
10050+
10051+ // SET
10052+ $ this ->assertQuery ( 'SET @my_var = 1 ' );
10053+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
10054+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
10055+ }
981210056}
0 commit comments