1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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.
This commit is contained in:
Igor Babaev
2011-06-09 00:13:00 -07:00
parent db0c340601
commit 7f345153f9
4 changed files with 43 additions and 11 deletions

View File

@ -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