summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_base.cc1
-rw-r--r--sql/sql_class.h12
-rw-r--r--sql/sql_derived.cc8
-rw-r--r--sql/sql_prepare.cc2
4 files changed, 16 insertions, 7 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 0b17032da8f..4e5b32ce1e5 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -5187,7 +5187,6 @@ bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags,
uint counter;
MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint();
DBUG_ENTER("open_normal_and_derived_tables");
- DBUG_ASSERT(!thd->fill_derived_tables());
if (open_tables(thd, &tables, &counter, flags, &prelocking_strategy) ||
mysql_handle_derived(thd->lex, dt_phases))
goto end;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 5ab93de7957..de2dab3cc14 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -3636,9 +3636,17 @@ public:
{
return server_status & SERVER_STATUS_IN_TRANS;
}
- inline bool fill_derived_tables()
+ inline bool fill_derived_table(TABLE_LIST *tl)
{
- return !stmt_arena->is_stmt_prepare() && !lex->only_view_structure();
+ /*
+ Do not fill derived table when
+ 1. running a PREPARE command
+ 2. this is a SHOW command and the table is a temp.table representing
+ the I_S table.
+ */
+ return !stmt_arena->is_stmt_prepare() && // (1)
+ !(lex->only_view_structure() && tl? tl->schema_table_reformed:false); // (2)
+
}
inline bool fill_information_schema_tables()
{
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 50b0178c6c9..33cb6a50710 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -85,14 +85,16 @@ mysql_handle_derived(LEX *lex, uint phases)
break;
if (!(phases & phase_flag))
continue;
- if (phase_flag >= DT_CREATE && !thd->fill_derived_tables())
- break;
for (SELECT_LEX *sl= lex->all_selects_list;
sl && !res;
sl= sl->next_select_in_list())
{
TABLE_LIST *cursor= sl->get_table_list();
+
+ if (phase_flag >= DT_CREATE && !thd->fill_derived_table(cursor))
+ break;
+
sl->changed_elements|= TOUCHED_SEL_DERIVED;
/*
DT_MERGE_FOR_INSERT is not needed for views/derived tables inside
@@ -193,7 +195,7 @@ mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases)
if (phase_flag != DT_PREPARE &&
!(allowed_phases & phase_flag))
continue;
- if (phase_flag >= DT_CREATE && !thd->fill_derived_tables())
+ if (phase_flag >= DT_CREATE && !thd->fill_derived_table(derived))
break;
if ((res= (*processors[phase])(lex->thd, lex, derived)))
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 9775e99afdd..357c1334ee2 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1452,7 +1452,7 @@ static int mysql_test_update(Prepared_statement *stmt,
}
/*
- thd->fill_derived_tables() is false here for sure (because it is
+ thd->fill_derived_table(table_list) is false here for sure (because it is
preparation of PS, so we even do not check it).
*/
if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))