File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -754,6 +754,9 @@ private function execute_mysql_query( WP_Parser_Node $node ): void {
754
754
$ this ->set_result_from_affected_rows ();
755
755
}
756
756
break ;
757
+ case 'truncateTableStatement ' :
758
+ $ this ->execute_truncate_table_statement ( $ node );
759
+ break ;
757
760
case 'setStatement ' :
758
761
/*
759
762
* It would be lovely to support at least SET autocommit,
@@ -1272,6 +1275,24 @@ private function execute_drop_table_statement( WP_Parser_Node $node ): void {
1272
1275
$ this ->information_schema_builder ->record_drop_table ( $ node );
1273
1276
}
1274
1277
1278
+ /**
1279
+ * Translate and execute a MySQL TRUNCATE TABLE statement in SQLite.
1280
+ *
1281
+ * @param WP_Parser_Node $node The "truncateTableStatement" AST node.
1282
+ * @throws WP_SQLite_Driver_Exception When the query execution fails.
1283
+ */
1284
+ private function execute_truncate_table_statement ( WP_Parser_Node $ node ): void {
1285
+ $ table_name = $ this ->unquote_sqlite_identifier (
1286
+ $ this ->translate ( $ node ->get_first_child_node ( 'tableRef ' ) )
1287
+ );
1288
+
1289
+ $ quoted_table_name = $ this ->quote_sqlite_identifier ( $ table_name );
1290
+
1291
+ $ this ->execute_sqlite_query ( "DELETE FROM $ quoted_table_name " );
1292
+ $ this ->execute_sqlite_query ( 'DELETE FROM sqlite_sequence WHERE name = ? ' , array ( $ table_name ) );
1293
+ $ this ->set_result_from_affected_rows ();
1294
+ }
1295
+
1275
1296
/**
1276
1297
* Translate and execute a MySQL SHOW statement in SQLite.
1277
1298
*
You can’t perform that action at this time.
0 commit comments