Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit d39678e

Browse files
committed
Implement DROP TABLE in information schema
1 parent ebfca2c commit d39678e

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

wp-includes/sqlite-ast/class-wp-sqlite-information-schema-builder.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,41 @@ public function record_alter_table( WP_Parser_Node $node ): void {
505505
}
506506
}
507507

508+
public function record_drop_table( WP_Parser_Node $node ): void {
509+
$child_node = $node->get_child_node();
510+
if ( $child_node->has_child_token( WP_MySQL_Lexer::TEMPORARY_SYMBOL ) ) {
511+
return;
512+
}
513+
514+
$table_refs = $child_node->get_child_node( 'tableRefList' )->get_child_nodes();
515+
foreach ( $table_refs as $table_ref ) {
516+
$table_name = $this->get_value( $table_ref );
517+
$this->delete_values(
518+
'_mysql_information_schema_tables',
519+
array(
520+
'table_schema' => $this->db_name,
521+
'table_name' => $table_name,
522+
)
523+
);
524+
$this->delete_values(
525+
'_mysql_information_schema_columns',
526+
array(
527+
'table_schema' => $this->db_name,
528+
'table_name' => $table_name,
529+
)
530+
);
531+
$this->delete_values(
532+
'_mysql_information_schema_statistics',
533+
array(
534+
'table_schema' => $this->db_name,
535+
'table_name' => $table_name,
536+
)
537+
);
538+
}
539+
540+
// @TODO: RESTRICT vs. CASCADE
541+
}
542+
508543
private function record_add_column( string $table_name, string $column_name, WP_Parser_Node $node ): void {
509544
$position = $this->query(
510545
'SELECT MAX(ordinal_position) FROM _mysql_information_schema_columns WHERE table_name = ?',

0 commit comments

Comments
 (0)