summaryrefslogtreecommitdiff
path: root/sql/sql_derived.cc
diff options
context:
space:
mode:
authorunknown <sanja@askmonty.org>2014-06-02 15:36:06 +0300
committerunknown <sanja@askmonty.org>2014-06-02 15:36:06 +0300
commit0fbe91b45bd2181e4c39b7550081b468ba179457 (patch)
treeb027e1c58c13a43a9783e4f04590c8daa6d57e56 /sql/sql_derived.cc
parent285160dee270abbbfef9b7c1fb72ec4040c42262 (diff)
downloadmariadb-git-0fbe91b45bd2181e4c39b7550081b468ba179457.tar.gz
MDEV-6251: SIGSEGV in query optimizer (in set_check_materialized with MERGE view)
mysql_derived_merge() made correctly working with views.
Diffstat (limited to 'sql/sql_derived.cc')
-rw-r--r--sql/sql_derived.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 5bc6c64c0b4..8e3d182c7b1 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -391,17 +391,13 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
if (parent_lex->get_free_table_map(&map, &tablenr))
{
/* There is no enough table bits, fall back to materialization. */
- derived->change_refs_to_fields();
- derived->set_materialized_derived();
- goto exit_merge;
+ goto unconditional_materialization;
}
if (dt_select->leaf_tables.elements + tablenr > MAX_TABLES)
{
/* There is no enough table bits, fall back to materialization. */
- derived->change_refs_to_fields();
- derived->set_materialized_derived();
- goto exit_merge;
+ goto unconditional_materialization;
}
if (dt_select->options & OPTION_SCHEMA_TABLE)
@@ -472,6 +468,15 @@ exit_merge:
if (arena)
thd->restore_active_arena(arena, &backup);
DBUG_RETURN(res);
+
+unconditional_materialization:
+ derived->change_refs_to_fields();
+ derived->set_materialized_derived();
+ if (!derived->table || !derived->table->created)
+ res= mysql_derived_create(thd, lex, derived);
+ if (!res)
+ res= mysql_derived_fill(thd, lex, derived);
+ goto exit_merge;
}