@@ -3273,31 +3273,7 @@ private function execute_show_statement( WP_Parser_Node $node ): void {
32733273 $ this ->execute_show_tables_statement ( $ node );
32743274 return ;
32753275 case WP_MySQL_Lexer::VARIABLES_SYMBOL :
3276- $ this ->last_column_meta = array (
3277- array (
3278- 'native_type ' => 'STRING ' ,
3279- 'pdo_type ' => PDO ::PARAM_STR ,
3280- 'flags ' => array ( 'not_null ' ),
3281- 'table ' => 'session_variables ' ,
3282- 'name ' => 'Variable_name ' ,
3283- 'len ' => 256 ,
3284- 'precision ' => 0 ,
3285- ),
3286- array (
3287- 'native_type ' => 'STRING ' ,
3288- 'pdo_type ' => PDO ::PARAM_STR ,
3289- 'flags ' => array (),
3290- 'table ' => 'session_variables ' ,
3291- 'name ' => 'Value ' ,
3292- 'len ' => 4096 ,
3293- 'precision ' => 0 ,
3294- ),
3295- );
3296- $ this ->last_result_statement = $ this ->create_result_statement_from_data (
3297- array_column ( $ this ->last_column_meta , 'name ' ),
3298- array ()
3299- );
3300- $ this ->found_rows = 0 ;
3276+ $ this ->execute_show_variables_statement ( $ node );
33013277 return ;
33023278 }
33033279
@@ -3310,6 +3286,39 @@ private function execute_show_statement( WP_Parser_Node $node ): void {
33103286 );
33113287 }
33123288
3289+ /**
3290+ * Translate and execute a MySQL SHOW VARIABLES statement in SQLite.
3291+ *
3292+ * @param WP_Parser_Node $node The "showStatement" AST node.
3293+ */
3294+ private function execute_show_variables_statement ( WP_Parser_Node $ node ): void {
3295+ $ like_or_where = $ node ->get_first_child_node ( 'likeOrWhere ' );
3296+ if ( null !== $ like_or_where ) {
3297+ $ condition = $ this ->translate_show_like_or_where_condition ( $ like_or_where , 'Variable_name ' );
3298+ }
3299+
3300+ $ query = sprintf (
3301+ "SELECT column1 AS `Variable_name`, column2 AS `Value`
3302+ FROM (
3303+ VALUES
3304+ ('version', ?),
3305+ ('version_comment', ?)
3306+ )
3307+ WHERE TRUE %s
3308+ ORDER BY column1 " ,
3309+ $ condition ?? ''
3310+ );
3311+ $ params = array (
3312+ $ this ->get_mysql_server_version_string (),
3313+ $ this ->get_mysql_server_version_comment (),
3314+ );
3315+
3316+ $ stmt = $ this ->execute_sqlite_query ( $ query , $ params );
3317+ $ this ->store_last_column_meta_from_statement ( $ stmt );
3318+ $ this ->last_result_statement = $ stmt ;
3319+ $ this ->found_rows = array ( $ query , $ params );
3320+ }
3321+
33133322 /**
33143323 * Translate and execute a MySQL SHOW COLLATION statement in SQLite.
33153324 *
0 commit comments