Commit c8d51129 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-8796 Delete with sub query with information_schema.TABLES deletes too many rows

make_cond_for_info_schema() does preserve outer fields
parent 504802f3
...@@ -6,15 +6,15 @@ select variable_name from information_schema.session_variables where variable_na ...@@ -6,15 +6,15 @@ select variable_name from information_schema.session_variables where variable_na
(select variable_name from information_schema.session_variables where variable_name = 'basedir'); (select variable_name from information_schema.session_variables where variable_name = 'basedir');
variable_name variable_name
BASEDIR BASEDIR
create table t1 (a char); create table t1 (x int);
insert t1 values ('a'),('t'),('z'); create table t2 (x int);
flush status; create table t3 (x int);
select a, exists (select 1 from information_schema.columns where table_schema=concat('tes',a)) from t1; create table t4 AS select table_name from information_schema.TABLES where table_schema = database() and table_type = 'BASE TABLE' ;
a exists (select 1 from information_schema.columns where table_schema=concat('tes',a)) delete from t4 where table_name not in (select table_name from information_schema.TABLES where table_schema = database() and table_type = 'BASE TABLE');
a 0 select * from t4;
t 1 table_name
z 0 t1
show status like 'created_tmp_tables'; t2
Variable_name Value t3
Created_tmp_tables 38 t4
drop table t1; drop table t1, t2, t3, t4;
...@@ -8,15 +8,12 @@ select variable_name from information_schema.session_variables where variable_na ...@@ -8,15 +8,12 @@ select variable_name from information_schema.session_variables where variable_na
(select variable_name from information_schema.session_variables where variable_name = 'basedir'); (select variable_name from information_schema.session_variables where variable_name = 'basedir');
# #
# information_schema tables inside subqueries, they should not be re-populated # MDEV-8796 Delete with sub query with information_schema.TABLES deletes too many rows
# (i_s.columns needs to scan i_s itself, creating a tmp table for every i_s
# table. if it's re-populated, it'll do that multiple times)
# #
create table t1 (a char); create table t1 (x int);
insert t1 values ('a'),('t'),('z'); create table t2 (x int);
flush status; create table t3 (x int);
select a, exists (select 1 from information_schema.columns where table_schema=concat('tes',a)) from t1; create table t4 AS select table_name from information_schema.TABLES where table_schema = database() and table_type = 'BASE TABLE' ;
# fix the result in ps-protocol delete from t4 where table_name not in (select table_name from information_schema.TABLES where table_schema = database() and table_type = 'BASE TABLE');
--replace_result 39 38 select * from t4;
show status like 'created_tmp_tables'; drop table t1, t2, t3, t4;
drop table t1;
...@@ -7730,13 +7730,14 @@ bool get_schema_tables_result(JOIN *join, ...@@ -7730,13 +7730,14 @@ bool get_schema_tables_result(JOIN *join,
TABLE_LIST *table_list= tab->table->pos_in_table_list; TABLE_LIST *table_list= tab->table->pos_in_table_list;
if (table_list->schema_table && thd->fill_information_schema_tables()) if (table_list->schema_table && thd->fill_information_schema_tables())
{ {
#if MYSQL_VERSION_ID > 100105 /*
#error I_S tables only need to be re-populated if make_cond_for_info_schema() will preserve outer fields I_S tables only need to be re-populated if make_cond_for_info_schema()
bool is_subselect= (&lex->unit != lex->current_select->master_unit() && preserves outer fields
lex->current_select->master_unit()->item); */
#else bool is_subselect= &lex->unit != lex->current_select->master_unit() &&
#define is_subselect false lex->current_select->master_unit()->item &&
#endif tab->select_cond &&
tab->select_cond->used_tables() & OUTER_REF_TABLE_BIT;
/* A value of 0 indicates a dummy implementation */ /* A value of 0 indicates a dummy implementation */
if (table_list->schema_table->fill_table == 0) if (table_list->schema_table->fill_table == 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment