@@ -1713,7 +1713,7 @@ private function execute_show_table_status_statement( WP_Parser_Node $node ): vo
17131713 // LIKE and WHERE clauses.
17141714 $ like_or_where = $ node ->get_first_child_node ( 'likeOrWhere ' );
17151715 if ( null !== $ like_or_where ) {
1716- $ condition = $ this ->translate_show_like_or_where_condition ( $ like_or_where );
1716+ $ condition = $ this ->translate_show_like_or_where_condition ( $ like_or_where, ' table_name ' );
17171717 }
17181718
17191719 // Fetch table information.
@@ -1782,7 +1782,7 @@ private function execute_show_tables_statement( WP_Parser_Node $node ): void {
17821782 // LIKE and WHERE clauses.
17831783 $ like_or_where = $ node ->get_first_child_node ( 'likeOrWhere ' );
17841784 if ( null !== $ like_or_where ) {
1785- $ condition = $ this ->translate_show_like_or_where_condition ( $ like_or_where );
1785+ $ condition = $ this ->translate_show_like_or_where_condition ( $ like_or_where, ' table_name ' );
17861786 }
17871787
17881788 // Fetch table information.
@@ -1867,7 +1867,7 @@ private function execute_show_columns_statement( WP_Parser_Node $node ): void {
18671867 // LIKE and WHERE clauses.
18681868 $ like_or_where = $ node ->get_first_child_node ( 'likeOrWhere ' );
18691869 if ( null !== $ like_or_where ) {
1870- $ condition = $ this ->translate_show_like_or_where_condition ( $ like_or_where );
1870+ $ condition = $ this ->translate_show_like_or_where_condition ( $ like_or_where, ' column_name ' );
18711871 }
18721872
18731873 // Fetch column information.
@@ -3003,16 +3003,21 @@ private function recreate_table_from_information_schema(
30033003 * Translate a MySQL SHOW LIKE ... or SHOW WHERE ... condition to SQLite.
30043004 *
30053005 * @param WP_Parser_Node $like_or_where The "likeOrWhere" AST node.
3006+ * @param string $like_column The column name to use in the LIKE clause ("table_name", "column_name", etc.).
30063007 * @return string The translated value.
30073008 * @throws WP_SQLite_Driver_Exception When the translation fails.
30083009 */
3009- private function translate_show_like_or_where_condition ( WP_Parser_Node $ like_or_where ): string {
3010+ private function translate_show_like_or_where_condition ( WP_Parser_Node $ like_or_where, string $ like_column ): string {
30103011 $ like_clause = $ like_or_where ->get_first_child_node ( 'likeClause ' );
30113012 if ( null !== $ like_clause ) {
30123013 $ value = $ this ->translate (
30133014 $ like_clause ->get_first_child_node ( 'textStringLiteral ' )
30143015 );
3015- return sprintf ( "AND table_name LIKE %s ESCAPE ' \\' " , $ value );
3016+ return sprintf (
3017+ "AND %s LIKE %s ESCAPE ' \\' " ,
3018+ $ this ->quote_sqlite_identifier ( $ like_column ),
3019+ $ value
3020+ );
30163021 }
30173022
30183023 $ where_clause = $ like_or_where ->get_first_child_node ( 'whereClause ' );
0 commit comments