@@ -1333,6 +1333,7 @@ private function execute_drop_table_statement( WP_Parser_Node $node ): void {
1333
1333
$ this ->execute_sqlite_query ( $ query );
1334
1334
}
1335
1335
$ this ->results = $ this ->last_exec_returned ;
1336
+ $ this ->information_schema_builder ->record_drop_table ( $ node );
1336
1337
}
1337
1338
1338
1339
private function execute_show_statement ( WP_Parser_Node $ node ): void {
@@ -1379,6 +1380,9 @@ private function execute_show_statement( WP_Parser_Node $node ): void {
1379
1380
)
1380
1381
);
1381
1382
return ;
1383
+ case WP_MySQL_Lexer::TABLE_SYMBOL :
1384
+ $ this ->execute_show_table_status_statement ( $ node );
1385
+ break ;
1382
1386
default :
1383
1387
// @TODO
1384
1388
}
@@ -1413,6 +1417,75 @@ private function execute_show_index_statement( string $table_name ): void {
1413
1417
$ this ->set_results_from_fetched_data ( $ index_info );
1414
1418
}
1415
1419
1420
+ private function execute_show_table_status_statement ( WP_Parser_Node $ node ): void {
1421
+ // @TODO: Handle FROM/IN db_name.
1422
+
1423
+ // LIKE and WHERE clauses.
1424
+ $ like_or_where = $ node ->get_child_node ( 'likeOrWhere ' );
1425
+ if ( null !== $ like_or_where ) {
1426
+ $ like_clause = $ like_or_where ->get_child_node ( 'likeClause ' );
1427
+ $ where_clause = $ like_or_where ->get_child_node ( 'whereClause ' );
1428
+
1429
+ if ( null !== $ like_clause ) {
1430
+ $ like_value = $ this ->translate (
1431
+ $ like_clause ->get_child_node ( 'textStringLiteral ' )
1432
+ );
1433
+ }
1434
+
1435
+ if ( null !== $ where_clause ) {
1436
+ $ where_value = $ this ->translate (
1437
+ $ where_clause ->get_child_node ( 'expr ' )
1438
+ );
1439
+ }
1440
+ }
1441
+
1442
+ // Fetch table information.
1443
+ $ table_info = $ this ->execute_sqlite_query (
1444
+ sprintf (
1445
+ "
1446
+ SELECT *
1447
+ FROM _mysql_information_schema_tables
1448
+ WHERE table_type = 'BASE TABLE'
1449
+ %s
1450
+ %s
1451
+ " ,
1452
+ isset ( $ like_value ) ? "AND table_name LIKE {$ like_value } ESCAPE ' \\' " : '' ,
1453
+ isset ( $ where_value ) ? "AND {$ where_value }" : ''
1454
+ )
1455
+ )->fetchAll ( PDO ::FETCH_ASSOC );
1456
+
1457
+ if ( false === $ table_info ) {
1458
+ $ this ->set_results_from_fetched_data ( array () );
1459
+ }
1460
+
1461
+ // Format the results.
1462
+ $ tables = array ();
1463
+ foreach ( $ table_info as $ value ) {
1464
+ $ tables [] = (object ) array (
1465
+ 'Name ' => $ value ['TABLE_NAME ' ],
1466
+ 'Engine ' => $ value ['ENGINE ' ],
1467
+ 'Version ' => $ value ['VERSION ' ],
1468
+ 'Row_format ' => $ value ['ROW_FORMAT ' ],
1469
+ 'Rows ' => $ value ['TABLE_ROWS ' ],
1470
+ 'Avg_row_length ' => $ value ['AVG_ROW_LENGTH ' ],
1471
+ 'Data_length ' => $ value ['DATA_LENGTH ' ],
1472
+ 'Max_data_length ' => $ value ['MAX_DATA_LENGTH ' ],
1473
+ 'Index_length ' => $ value ['INDEX_LENGTH ' ],
1474
+ 'Data_free ' => $ value ['DATA_FREE ' ],
1475
+ 'Auto_increment ' => $ value ['AUTO_INCREMENT ' ],
1476
+ 'Create_time ' => $ value ['CREATE_TIME ' ],
1477
+ 'Update_time ' => $ value ['UPDATE_TIME ' ],
1478
+ 'Check_time ' => $ value ['CHECK_TIME ' ],
1479
+ 'Collation ' => $ value ['TABLE_COLLATION ' ],
1480
+ 'Checksum ' => $ value ['CHECKSUM ' ],
1481
+ 'Create_options ' => $ value ['CREATE_OPTIONS ' ],
1482
+ 'Comment ' => $ value ['TABLE_COMMENT ' ],
1483
+ );
1484
+ }
1485
+
1486
+ $ this ->set_results_from_fetched_data ( $ tables );
1487
+ }
1488
+
1416
1489
private function execute_describe_statement ( WP_Parser_Node $ node ): void {
1417
1490
$ table_name = $ this ->unquote_sqlite_identifier (
1418
1491
$ this ->translate ( $ node ->get_child_node ( 'tableRef ' ) )
0 commit comments