summaryrefslogtreecommitdiff
path: root/sql/sql_derived.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2011-06-09 00:13:00 -0700
committerIgor Babaev <igor@askmonty.org>2011-06-09 00:13:00 -0700
commit7f345153f91c5395e5ab4ce5906fcabbb6d06f51 (patch)
tree00d8d3897c98f18bad884c69195cef98e8739105 /sql/sql_derived.cc
parentdb0c3406011d9a6d6fdb98c1c1f7925d243bd1f9 (diff)
downloadmariadb-git-7f345153f91c5395e5ab4ce5906fcabbb6d06f51.tar.gz
Fixed LP bug #794038.
INSERT/UPDATE/DELETE statement that used a temptable view v1 could lead to a crash if v1 was defined as a select from a mergeable view v2 that selected rows from a temptable view v3. When INSERT/UPDATE/DELETE uses a view that is not updatable then field translation for the view should be created before the prepare phase.
Diffstat (limited to 'sql/sql_derived.cc')
-rw-r--r--sql/sql_derived.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index ca56f0fa0a6..9bfa49c5f2d 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -467,6 +467,12 @@ bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived)
if (derived->merged_for_insert)
return FALSE;
+ /* It's a target view for an INSERT, create field translation only. */
+ if (!derived->updatable || derived->is_materialized_derived())
+ {
+ bool res= derived->create_field_translation(thd);
+ return res;
+ }
if (!derived->is_multitable())
{
TABLE_LIST *tl=((TABLE_LIST*)dt_select->table_list.first);
@@ -603,16 +609,9 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
bool res= FALSE;
// Skip already prepared views/DT
- if (!unit || unit->prepared)
+ if (!unit || unit->prepared || derived->merged_for_insert)
DBUG_RETURN(FALSE);
- /* It's a target view for an INSERT, create field translation only. */
- if (derived->merged_for_insert)
- {
- res= derived->create_field_translation(thd);
- DBUG_RETURN(res);
- }
-
Query_arena *arena= thd->stmt_arena, backup;
if (arena->is_conventional())
arena= 0; // For easier test