@@ -9711,4 +9711,247 @@ public function testWriteWithUsageOfInformationSchemaTables(): void {
97119711 $ result
97129712 );
97139713 }
9714+
9715+ public function testNonEmptyColumnMeta (): void {
9716+ $ this ->assertQuery ( 'CREATE TABLE t (id INT) ' );
9717+
9718+ // SELECT
9719+ $ this ->assertQuery ( 'SELECT * FROM t ' );
9720+ $ this ->assertSame ( 1 , $ this ->engine ->get_last_column_count () );
9721+ $ this ->assertSame ( 'id ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9722+
9723+ // SHOW COLLATION
9724+ $ this ->assertQuery ( 'SHOW COLLATION ' );
9725+ $ this ->assertSame ( 7 , $ this ->engine ->get_last_column_count () );
9726+ $ this ->assertSame ( 'Collation ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9727+ $ this ->assertSame ( 'Charset ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9728+ $ this ->assertSame ( 'Id ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9729+ $ this ->assertSame ( 'Default ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9730+ $ this ->assertSame ( 'Compiled ' , $ this ->engine ->get_last_column_meta ()[4 ]['name ' ] );
9731+ $ this ->assertSame ( 'Sortlen ' , $ this ->engine ->get_last_column_meta ()[5 ]['name ' ] );
9732+ $ this ->assertSame ( 'Pad_attribute ' , $ this ->engine ->get_last_column_meta ()[6 ]['name ' ] );
9733+
9734+ // SHOW DATABASES
9735+ $ this ->assertQuery ( 'SHOW DATABASES ' );
9736+ $ this ->assertSame ( 1 , $ this ->engine ->get_last_column_count () );
9737+ $ this ->assertSame ( 'Database ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9738+
9739+ // SHOW CREATE TABLE
9740+ $ this ->assertQuery ( 'SHOW CREATE TABLE t ' );
9741+ $ this ->assertSame ( 2 , $ this ->engine ->get_last_column_count () );
9742+ $ this ->assertSame ( 'Table ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9743+ $ this ->assertSame ( 'Create Table ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9744+
9745+ // SHOW TABLE STATUS
9746+ $ this ->assertQuery ( 'SHOW TABLE STATUS ' );
9747+ $ this ->assertSame ( 18 , $ this ->engine ->get_last_column_count () );
9748+ $ this ->assertSame ( 'Name ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9749+ $ this ->assertSame ( 'Engine ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9750+ $ this ->assertSame ( 'Version ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9751+ $ this ->assertSame ( 'Row_format ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9752+ $ this ->assertSame ( 'Rows ' , $ this ->engine ->get_last_column_meta ()[4 ]['name ' ] );
9753+ $ this ->assertSame ( 'Avg_row_length ' , $ this ->engine ->get_last_column_meta ()[5 ]['name ' ] );
9754+ $ this ->assertSame ( 'Data_length ' , $ this ->engine ->get_last_column_meta ()[6 ]['name ' ] );
9755+ $ this ->assertSame ( 'Max_data_length ' , $ this ->engine ->get_last_column_meta ()[7 ]['name ' ] );
9756+ $ this ->assertSame ( 'Index_length ' , $ this ->engine ->get_last_column_meta ()[8 ]['name ' ] );
9757+ $ this ->assertSame ( 'Data_free ' , $ this ->engine ->get_last_column_meta ()[9 ]['name ' ] );
9758+ $ this ->assertSame ( 'Auto_increment ' , $ this ->engine ->get_last_column_meta ()[10 ]['name ' ] );
9759+ $ this ->assertSame ( 'Create_time ' , $ this ->engine ->get_last_column_meta ()[11 ]['name ' ] );
9760+ $ this ->assertSame ( 'Update_time ' , $ this ->engine ->get_last_column_meta ()[12 ]['name ' ] );
9761+ $ this ->assertSame ( 'Check_time ' , $ this ->engine ->get_last_column_meta ()[13 ]['name ' ] );
9762+ $ this ->assertSame ( 'Collation ' , $ this ->engine ->get_last_column_meta ()[14 ]['name ' ] );
9763+ $ this ->assertSame ( 'Checksum ' , $ this ->engine ->get_last_column_meta ()[15 ]['name ' ] );
9764+ $ this ->assertSame ( 'Create_options ' , $ this ->engine ->get_last_column_meta ()[16 ]['name ' ] );
9765+ $ this ->assertSame ( 'Comment ' , $ this ->engine ->get_last_column_meta ()[17 ]['name ' ] );
9766+
9767+ // SHOW TABLES
9768+ $ this ->assertQuery ( 'SHOW TABLES ' );
9769+ $ this ->assertSame ( 1 , $ this ->engine ->get_last_column_count () );
9770+ $ this ->assertSame ( 'Tables_in_wp ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9771+
9772+ // SHOW FULL TABLES
9773+ $ this ->assertQuery ( 'SHOW FULL TABLES ' );
9774+ $ this ->assertSame ( 2 , $ this ->engine ->get_last_column_count () );
9775+ $ this ->assertSame ( 'Tables_in_wp ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9776+ $ this ->assertSame ( 'Table_type ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9777+
9778+ // SHOW COLUMNS
9779+ $ this ->assertQuery ( 'SHOW COLUMNS FROM t ' );
9780+ $ this ->assertSame ( 6 , $ this ->engine ->get_last_column_count () );
9781+ $ this ->assertSame ( 'Field ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9782+ $ this ->assertSame ( 'Type ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9783+ $ this ->assertSame ( 'Null ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9784+ $ this ->assertSame ( 'Key ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9785+ $ this ->assertSame ( 'Default ' , $ this ->engine ->get_last_column_meta ()[4 ]['name ' ] );
9786+ $ this ->assertSame ( 'Extra ' , $ this ->engine ->get_last_column_meta ()[5 ]['name ' ] );
9787+
9788+ // SHOW INDEX
9789+ $ this ->assertQuery ( 'SHOW INDEX FROM t ' );
9790+ $ this ->assertSame ( 15 , $ this ->engine ->get_last_column_count () );
9791+ $ this ->assertSame ( 'Table ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9792+ $ this ->assertSame ( 'Non_unique ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9793+ $ this ->assertSame ( 'Key_name ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9794+ $ this ->assertSame ( 'Seq_in_index ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9795+ $ this ->assertSame ( 'Column_name ' , $ this ->engine ->get_last_column_meta ()[4 ]['name ' ] );
9796+ $ this ->assertSame ( 'Collation ' , $ this ->engine ->get_last_column_meta ()[5 ]['name ' ] );
9797+ $ this ->assertSame ( 'Cardinality ' , $ this ->engine ->get_last_column_meta ()[6 ]['name ' ] );
9798+ $ this ->assertSame ( 'Sub_part ' , $ this ->engine ->get_last_column_meta ()[7 ]['name ' ] );
9799+ $ this ->assertSame ( 'Packed ' , $ this ->engine ->get_last_column_meta ()[8 ]['name ' ] );
9800+ $ this ->assertSame ( 'Null ' , $ this ->engine ->get_last_column_meta ()[9 ]['name ' ] );
9801+ $ this ->assertSame ( 'Index_type ' , $ this ->engine ->get_last_column_meta ()[10 ]['name ' ] );
9802+ $ this ->assertSame ( 'Comment ' , $ this ->engine ->get_last_column_meta ()[11 ]['name ' ] );
9803+ $ this ->assertSame ( 'Index_comment ' , $ this ->engine ->get_last_column_meta ()[12 ]['name ' ] );
9804+ $ this ->assertSame ( 'Visible ' , $ this ->engine ->get_last_column_meta ()[13 ]['name ' ] );
9805+ $ this ->assertSame ( 'Expression ' , $ this ->engine ->get_last_column_meta ()[14 ]['name ' ] );
9806+
9807+ // SHOW GRANTS
9808+ $ this ->assertQuery ( 'SHOW GRANTS ' );
9809+ $ this ->assertSame ( 1 , $ this ->engine ->get_last_column_count () );
9810+ $ this ->assertSame ( 'Grants for root@localhost ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9811+
9812+ // SHOW VARIABLES
9813+ $ this ->assertQuery ( 'SHOW VARIABLES ' );
9814+ $ this ->assertSame ( 2 , $ this ->engine ->get_last_column_count () );
9815+ $ this ->assertSame ( 'Variable_name ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9816+ $ this ->assertSame ( 'Value ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9817+
9818+ // DESCRIBE/EXPLAIN
9819+ $ this ->assertQuery ( 'DESCRIBE t ' );
9820+ $ this ->assertSame ( 6 , $ this ->engine ->get_last_column_count () );
9821+ $ this ->assertSame ( 'Field ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9822+ $ this ->assertSame ( 'Type ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9823+ $ this ->assertSame ( 'Null ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9824+ $ this ->assertSame ( 'Key ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9825+ $ this ->assertSame ( 'Default ' , $ this ->engine ->get_last_column_meta ()[4 ]['name ' ] );
9826+ $ this ->assertSame ( 'Extra ' , $ this ->engine ->get_last_column_meta ()[5 ]['name ' ] );
9827+
9828+ // ANALYZE TABLE
9829+ $ this ->assertQuery ( 'ANALYZE TABLE t ' );
9830+ $ this ->assertSame ( 4 , $ this ->engine ->get_last_column_count () );
9831+ $ this ->assertSame ( 'Table ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9832+ $ this ->assertSame ( 'Op ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9833+ $ this ->assertSame ( 'Msg_type ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9834+ $ this ->assertSame ( 'Msg_text ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9835+
9836+ // CHECK TABLE
9837+ $ this ->assertQuery ( 'CHECK TABLE t ' );
9838+ $ this ->assertSame ( 4 , $ this ->engine ->get_last_column_count () );
9839+ $ this ->assertSame ( 'Table ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9840+ $ this ->assertSame ( 'Op ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9841+ $ this ->assertSame ( 'Msg_type ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9842+ $ this ->assertSame ( 'Msg_text ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9843+
9844+ // OPTIMIZE TABLE
9845+ $ this ->assertQuery ( 'OPTIMIZE TABLE t ' );
9846+ $ this ->assertSame ( 4 , $ this ->engine ->get_last_column_count () );
9847+ $ this ->assertSame ( 'Table ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9848+ $ this ->assertSame ( 'Op ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9849+ $ this ->assertSame ( 'Msg_type ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9850+ $ this ->assertSame ( 'Msg_text ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9851+
9852+ // REPAIR TABLE
9853+ $ this ->assertQuery ( 'REPAIR TABLE t ' );
9854+ $ this ->assertSame ( 4 , $ this ->engine ->get_last_column_count () );
9855+ $ this ->assertSame ( 'Table ' , $ this ->engine ->get_last_column_meta ()[0 ]['name ' ] );
9856+ $ this ->assertSame ( 'Op ' , $ this ->engine ->get_last_column_meta ()[1 ]['name ' ] );
9857+ $ this ->assertSame ( 'Msg_type ' , $ this ->engine ->get_last_column_meta ()[2 ]['name ' ] );
9858+ $ this ->assertSame ( 'Msg_text ' , $ this ->engine ->get_last_column_meta ()[3 ]['name ' ] );
9859+ }
9860+
9861+ public function testEmptyColumnMeta (): void {
9862+ // CREATE TABLE
9863+ $ this ->assertQuery ( 'CREATE TABLE t (id INT) ' );
9864+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9865+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9866+
9867+ // INSERT
9868+ $ this ->assertQuery ( 'INSERT INTO t (id) VALUES (1) ' );
9869+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9870+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9871+
9872+ // REPLACE
9873+ $ this ->assertQuery ( 'UPDATE t SET id = 1 ' );
9874+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9875+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9876+
9877+ // DELETE
9878+ $ this ->assertQuery ( 'DELETE FROM t ' );
9879+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9880+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9881+
9882+ // TRUNCATE TABLE
9883+ $ this ->assertQuery ( 'TRUNCATE TABLE t ' );
9884+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9885+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9886+
9887+ // START TRANSACTION
9888+ $ this ->assertQuery ( 'START TRANSACTION ' );
9889+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9890+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9891+
9892+ // COMMIT
9893+ $ this ->assertQuery ( 'COMMIT ' );
9894+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9895+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9896+
9897+ // ROLLBACK
9898+ $ this ->assertQuery ( 'ROLLBACK ' );
9899+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9900+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9901+
9902+ // SAVEPOINT
9903+ $ this ->assertQuery ( 'SAVEPOINT s1 ' );
9904+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9905+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9906+
9907+ // ROLLBACK TO SAVEPOINT
9908+ $ this ->assertQuery ( 'ROLLBACK TO SAVEPOINT s1 ' );
9909+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9910+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9911+
9912+ // RELEASE SAVEPOINT
9913+ $ this ->assertQuery ( 'RELEASE SAVEPOINT s1 ' );
9914+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9915+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9916+
9917+ // LOCK TABLE
9918+ $ this ->assertQuery ( 'LOCK TABLES t READ ' );
9919+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9920+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9921+
9922+ // UNLOCK TABLE
9923+ $ this ->assertQuery ( 'UNLOCK TABLES ' );
9924+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9925+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9926+
9927+ // ALTER TABLE
9928+ $ this ->assertQuery ( 'ALTER TABLE t ADD COLUMN name VARCHAR(255) ' );
9929+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9930+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9931+
9932+ // CREATE INDEX
9933+ $ this ->assertQuery ( 'CREATE INDEX idx_name ON t (name) ' );
9934+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9935+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9936+
9937+ // DROP INDEX
9938+ $ this ->assertQuery ( 'DROP INDEX idx_name ON t ' );
9939+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9940+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9941+
9942+ // DROP TABLE
9943+ $ this ->assertQuery ( 'DROP TABLE t ' );
9944+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9945+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9946+
9947+ // USE
9948+ $ this ->assertQuery ( 'USE wp ' );
9949+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9950+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9951+
9952+ // SET
9953+ $ this ->assertQuery ( 'SET @my_var = 1 ' );
9954+ $ this ->assertSame ( 0 , $ this ->engine ->get_last_column_count () );
9955+ $ this ->assertSame ( array (), $ this ->engine ->get_last_column_meta () );
9956+ }
97149957}
0 commit comments