mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
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().
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user