mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixed bug #21231: wrong results for a simple query with a
a non-correlated single-row subquery over information schema. The function get_all_tables filling all information schema tables reset lex->sql_command to SQLCOM_SHOW_FIELDS. After this the function could evaluate partial conditions related to some columns. If these conditions contained a subquery over information schema it led to a wrong evaluation and a wrong result set. This bug was already fixed in 5.1. This patch follows the way how it was done in 5.1 where the value of lex->sql_command is set to SQLCOM_SHOW_FIELDS in get_all_tables only for the calls of the function open_normal_and_derived_tables and is restored after these calls. mysql-test/r/information_schema.result: Added a test case for bug #21231. mysql-test/t/information_schema.test: Added a test case for bug #21231.
This commit is contained in:
@ -2116,12 +2116,6 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
LINT_INIT(end);
|
||||
LINT_INIT(len);
|
||||
|
||||
/*
|
||||
Let us set fake sql_command so views won't try to merge
|
||||
themselves into main statement.
|
||||
*/
|
||||
lex->sql_command= SQLCOM_SHOW_FIELDS;
|
||||
|
||||
lex->reset_n_backup_query_tables_list(&query_tables_list_backup);
|
||||
|
||||
/*
|
||||
@ -2144,8 +2138,16 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
I_S tables will be done.
|
||||
*/
|
||||
thd->temporary_tables= open_tables_state_backup.temporary_tables;
|
||||
/*
|
||||
Let us set fake sql_command so views won't try to merge
|
||||
themselves into main statement. If we don't do this,
|
||||
SELECT * from information_schema.xxxx will cause problems.
|
||||
SQLCOM_SHOW_FIELDS is used because it satisfies 'only_view_structure()'
|
||||
*/
|
||||
lex->sql_command= SQLCOM_SHOW_FIELDS;
|
||||
res= open_normal_and_derived_tables(thd, show_table_list,
|
||||
MYSQL_LOCK_IGNORE_FLUSH);
|
||||
lex->sql_command= save_sql_command;
|
||||
/*
|
||||
get_all_tables() returns 1 on failure and 0 on success thus
|
||||
return only these and not the result code of ::process_table()
|
||||
@ -2267,8 +2269,10 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
TABLE_LIST *show_table_list= (TABLE_LIST*) sel.table_list.first;
|
||||
lex->all_selects_list= &sel;
|
||||
lex->derived_tables= 0;
|
||||
lex->sql_command= SQLCOM_SHOW_FIELDS;
|
||||
res= open_normal_and_derived_tables(thd, show_table_list,
|
||||
MYSQL_LOCK_IGNORE_FLUSH);
|
||||
lex->sql_command= save_sql_command;
|
||||
/*
|
||||
We should use show_table_list->alias instead of
|
||||
show_table_list->table_name because table_name
|
||||
|
Reference in New Issue
Block a user