summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authorSergey Glukhov <Sergey.Glukhov@sun.com>2009-07-03 13:35:00 +0500
committerSergey Glukhov <Sergey.Glukhov@sun.com>2009-07-03 13:35:00 +0500
commit2dd709468194c3b5399c4dc614037c0557e17e14 (patch)
treee5b5bc87cb55817b0a3c7e4c2852960ad46ea937 /sql/sql_insert.cc
parent15b23550d452e1e4725b417e0c7942518729a222 (diff)
downloadmariadb-git-2dd709468194c3b5399c4dc614037c0557e17e14.tar.gz
Bug#45806 crash when replacing into a view with a join!
The crash happend because for views which are joins we have table_list->table == 0 and table_list->table->'any method' call leads to crash. The fix is to perform table_list->table->file->extra() method for all tables belonging to view. mysql-test/r/view.result: test result mysql-test/t/view.test: test case sql/sql_insert.cc: added prepare_for_positional_update() function which updates extra info about primary key for tables belonging to view.
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc32
1 files changed, 29 insertions, 3 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 28b8bcd320d..83f3b181091 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1149,6 +1149,33 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
/*
+ Get extra info for tables we insert into
+
+ @param table table(TABLE object) we insert into,
+ might be NULL in case of view
+ @param table(TABLE_LIST object) or view we insert into
+*/
+
+static void prepare_for_positional_update(TABLE *table, TABLE_LIST *tables)
+{
+ if (table)
+ {
+ if(table->reginfo.lock_type != TL_WRITE_DELAYED)
+ table->file->extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY);
+ return;
+ }
+
+ DBUG_ASSERT(tables->view);
+ List_iterator<TABLE_LIST> it(*tables->view_tables);
+ TABLE_LIST *tbl;
+ while ((tbl= it++))
+ prepare_for_positional_update(tbl->table, tbl);
+
+ return;
+}
+
+
+/*
Prepare items in INSERT statement
SYNOPSIS
@@ -1298,9 +1325,8 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
Only call extra() handler method if we are not performing a DELAYED
operation. It will instead be executed by delayed insert thread.
*/
- if ((duplic == DUP_UPDATE || duplic == DUP_REPLACE) &&
- (table->reginfo.lock_type != TL_WRITE_DELAYED))
- table->file->extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY);
+ if (duplic == DUP_UPDATE || duplic == DUP_REPLACE)
+ prepare_for_positional_update(table, table_list);
DBUG_RETURN(FALSE);
}