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