summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2010-07-15 16:51:05 -0700
committerIgor Babaev <igor@askmonty.org>2010-07-15 16:51:05 -0700
commit40901007434a30882e1f51171551ff287fbe540c (patch)
tree533145fe7464b9126586448d784c3fd9893807ca /sql/sql_insert.cc
parent683154d1fa6249a8bfcde4bb9227570c452ea802 (diff)
downloadmariadb-git-40901007434a30882e1f51171551ff287fbe540c.tar.gz
Fixed bug #603186.
There were two problems that caused wrong results reported with this bug. 1. In some cases stored(persistent) virtual columns were not marked in the write_set and in the vcol_set bitmaps. 2. If the list of fields in an insert command was empty then the values of the stored virtual columns were set to default. To fix the first problem the function st_table::mark_virtual_columns_for_write was modified. Now the function has a parameter that says whether the virtual columns are to be marked for insert or for update. To fix the second problem a special handling of empty insert lists is added in the function fill_record().
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 54234eb8ab4..4ce13374d03 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -273,7 +273,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
}
/* Mark virtual columns used in the insert statement */
if (table->vfield)
- table->mark_virtual_columns_for_write();
+ table->mark_virtual_columns_for_write(TRUE);
// For the values we need select_priv
#ifndef NO_EMBEDDED_ACCESS_CHECKS
table->grant.want_privilege= (SELECT_ACL & ~table->grant.privilege);
@@ -1267,7 +1267,6 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
if (mysql_prepare_insert_check_table(thd, table_list, fields, select_insert))
DBUG_RETURN(TRUE);
-
/* Prepare the fields in the statement. */
if (values)
{
@@ -1320,6 +1319,18 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
if (!table)
table= table_list->table;
+ if (!fields.elements && table->vfield)
+ {
+ for (Field **vfield_ptr= table->vfield; *vfield_ptr; vfield_ptr++)
+ {
+ if ((*vfield_ptr)->stored_in_db)
+ {
+ thd->lex->unit.insert_table_with_stored_vcol= table;
+ break;
+ }
+ }
+ }
+
if (!select_insert)
{
Item *fake_conds= 0;