summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-01-11 19:12:21 +0100
committerSergei Golubchik <serg@mariadb.org>2017-01-11 20:24:40 +0100
commit0d1d0d77f2a72d9cb6de0489dceb37644caf9037 (patch)
tree98b7c0fa65468555ffab1441c8b10c999aff15db
parentab93a4d4df7206833fa4a8eb0aa47b8ba185da60 (diff)
downloadmariadb-git-0d1d0d77f2a72d9cb6de0489dceb37644caf9037.tar.gz
MDEV-11706 Assertion `is_stat_field || !table || (!table->write_set || bitmap_is_set(table->write_set, field_index) || (table->vcol_set && bitmap_is_set(table->vcol_set, field_index)))' failed in Field_time::store_TIME_with_warning
vcols and triggers. Revert 094f4cf77890c5a747a57cf2bed149b0b6933507, backport the correct fix (Table_triggers_list::mark_fields_used() not marking vcols) from 10.2.
-rw-r--r--mysql-test/suite/vcol/inc/vcol_trigger_sp.inc9
-rw-r--r--mysql-test/suite/vcol/r/vcol_trigger_sp_innodb.result8
-rw-r--r--mysql-test/suite/vcol/r/vcol_trigger_sp_myisam.result8
-rw-r--r--sql/sql_base.cc16
-rw-r--r--sql/sql_delete.cc5
-rw-r--r--sql/sql_trigger.cc3
-rw-r--r--sql/sql_update.cc13
-rw-r--r--sql/table.cc13
-rw-r--r--sql/table.h3
9 files changed, 39 insertions, 39 deletions
diff --git a/mysql-test/suite/vcol/inc/vcol_trigger_sp.inc b/mysql-test/suite/vcol/inc/vcol_trigger_sp.inc
index eb7e6ad32b9..b9a6ba28a5f 100644
--- a/mysql-test/suite/vcol/inc/vcol_trigger_sp.inc
+++ b/mysql-test/suite/vcol/inc/vcol_trigger_sp.inc
@@ -110,7 +110,7 @@ drop table t1,t2;
drop procedure p1;
--echo #
---echo # Bug mdev-3845: values of virtual columns are not computed for triggers
+--echo # MDEV-3845 values of virtual columns are not computed for triggers
--echo #
CREATE TABLE t1 (
@@ -149,3 +149,10 @@ DROP TRIGGER t1_ins_aft;
DROP TRIGGER t1_del_bef;
DROP TABLE t1,t2;
+#
+# MDEV-11706 Assertion `is_stat_field || !table || (!table->write_set || bitmap_is_set(table->write_set, field_index) || (table->vcol_set && bitmap_is_set(table->vcol_set, field_index)))' failed in Field_time::store_TIME_with_warning
+#
+create table t1 (i int, t time not null, vt time(4) as (t) virtual);
+create trigger trg before update on t1 for each row set @a = 1;
+insert ignore into t1 (i) values (1);
+drop table t1;
diff --git a/mysql-test/suite/vcol/r/vcol_trigger_sp_innodb.result b/mysql-test/suite/vcol/r/vcol_trigger_sp_innodb.result
index 1d78bbf50e4..034a67a9bb0 100644
--- a/mysql-test/suite/vcol/r/vcol_trigger_sp_innodb.result
+++ b/mysql-test/suite/vcol/r/vcol_trigger_sp_innodb.result
@@ -86,7 +86,7 @@ a b c
drop table t1,t2;
drop procedure p1;
#
-# Bug mdev-3845: values of virtual columns are not computed for triggers
+# MDEV-3845 values of virtual columns are not computed for triggers
#
CREATE TABLE t1 (
a INTEGER UNSIGNED NULL DEFAULT NULL,
@@ -125,3 +125,9 @@ c
DROP TRIGGER t1_ins_aft;
DROP TRIGGER t1_del_bef;
DROP TABLE t1,t2;
+create table t1 (i int, t time not null, vt time(4) as (t) virtual);
+create trigger trg before update on t1 for each row set @a = 1;
+insert ignore into t1 (i) values (1);
+Warnings:
+Warning 1364 Field 't' doesn't have a default value
+drop table t1;
diff --git a/mysql-test/suite/vcol/r/vcol_trigger_sp_myisam.result b/mysql-test/suite/vcol/r/vcol_trigger_sp_myisam.result
index 77efa8fe6b9..07d011ac64c 100644
--- a/mysql-test/suite/vcol/r/vcol_trigger_sp_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_trigger_sp_myisam.result
@@ -86,7 +86,7 @@ a b c
drop table t1,t2;
drop procedure p1;
#
-# Bug mdev-3845: values of virtual columns are not computed for triggers
+# MDEV-3845 values of virtual columns are not computed for triggers
#
CREATE TABLE t1 (
a INTEGER UNSIGNED NULL DEFAULT NULL,
@@ -125,3 +125,9 @@ c
DROP TRIGGER t1_ins_aft;
DROP TRIGGER t1_del_bef;
DROP TABLE t1,t2;
+create table t1 (i int, t time not null, vt time(4) as (t) virtual);
+create trigger trg before update on t1 for each row set @a = 1;
+insert ignore into t1 (i) values (1);
+Warnings:
+Warning 1364 Field 't' doesn't have a default value
+drop table t1;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index d281758fc18..7f84f35c825 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -9033,9 +9033,7 @@ fill_record(THD * thd, List<Item> &fields, List<Item> &values,
/* Update virtual fields*/
thd->abort_on_warning= FALSE;
if (vcol_table && vcol_table->vfield &&
- update_virtual_fields(thd, vcol_table,
- vcol_table->triggers ? VCOL_UPDATE_ALL :
- VCOL_UPDATE_FOR_WRITE))
+ update_virtual_fields(thd, vcol_table, VCOL_UPDATE_FOR_WRITE))
goto err;
thd->abort_on_warning= save_abort_on_warning;
thd->no_errors= save_no_errors;
@@ -9099,9 +9097,7 @@ fill_record_n_invoke_before_triggers(THD *thd, List<Item> &fields,
if (item_field && item_field->field &&
(table= item_field->field->table) &&
table->vfield)
- result= update_virtual_fields(thd, table,
- table->triggers ? VCOL_UPDATE_ALL :
- VCOL_UPDATE_FOR_WRITE);
+ result= update_virtual_fields(thd, table, VCOL_UPDATE_FOR_WRITE);
}
}
return result;
@@ -9186,9 +9182,7 @@ fill_record(THD *thd, Field **ptr, List<Item> &values, bool ignore_errors,
/* Update virtual fields*/
thd->abort_on_warning= FALSE;
if (table->vfield &&
- update_virtual_fields(thd, table,
- table->triggers ? VCOL_UPDATE_ALL :
- VCOL_UPDATE_FOR_WRITE))
+ update_virtual_fields(thd, table, VCOL_UPDATE_FOR_WRITE))
goto err;
thd->abort_on_warning= abort_on_warning_saved;
DBUG_RETURN(thd->is_error());
@@ -9241,9 +9235,7 @@ fill_record_n_invoke_before_triggers(THD *thd, Field **ptr,
{
TABLE *table= (*ptr)->table;
if (table->vfield)
- result= update_virtual_fields(thd, table,
- table->triggers ? VCOL_UPDATE_ALL :
- VCOL_UPDATE_FOR_WRITE);
+ result= update_virtual_fields(thd, table, VCOL_UPDATE_FOR_WRITE);
}
return result;
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 5b233cde7c7..8aca415a9d0 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -328,9 +328,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
! thd->is_error())
{
if (table->vfield)
- update_virtual_fields(thd, table,
- table->triggers ? VCOL_UPDATE_ALL :
- VCOL_UPDATE_FOR_READ);
+ update_virtual_fields(thd, table, VCOL_UPDATE_FOR_READ);
thd->examined_row_count++;
// thd->is_error() is tested to disallow delete row on error
if (!select || select->skip_record(thd) > 0)
@@ -1073,4 +1071,3 @@ bool multi_delete::send_eof()
}
return 0;
}
-
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index b6915b708fa..4d7338b2e1d 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -2246,6 +2246,9 @@ void Table_triggers_list::mark_fields_used(trg_event_type event)
bitmap_set_bit(trigger_table->read_set, trg_field->field_idx);
if (trg_field->get_settable_routine_parameter())
bitmap_set_bit(trigger_table->write_set, trg_field->field_idx);
+ if (trigger_table->field[trg_field->field_idx]->vcol_info)
+ trigger_table->mark_virtual_col(trigger_table->
+ field[trg_field->field_idx]);
}
}
}
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index f134e0ba266..060952a589d 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -569,9 +569,7 @@ int mysql_update(THD *thd,
while (!(error=info.read_record(&info)) && !thd->killed)
{
if (table->vfield)
- update_virtual_fields(thd, table,
- table->triggers ? VCOL_UPDATE_ALL :
- VCOL_UPDATE_FOR_READ);
+ update_virtual_fields(thd, table, VCOL_UPDATE_FOR_READ);
thd->examined_row_count++;
if (!select || (error= select->skip_record(thd)) > 0)
{
@@ -695,9 +693,7 @@ int mysql_update(THD *thd,
while (!(error=info.read_record(&info)) && !thd->killed)
{
if (table->vfield)
- update_virtual_fields(thd, table,
- table->triggers ? VCOL_UPDATE_ALL :
- VCOL_UPDATE_FOR_READ);
+ update_virtual_fields(thd, table, VCOL_UPDATE_FOR_READ);
thd->examined_row_count++;
if (!select || select->skip_record(thd) > 0)
{
@@ -2235,10 +2231,7 @@ int multi_update::do_updates()
{
int error;
if (table->vfield &&
- update_virtual_fields(thd, table,
- (table->triggers ?
- VCOL_UPDATE_ALL :
- VCOL_UPDATE_FOR_WRITE)))
+ update_virtual_fields(thd, table, VCOL_UPDATE_FOR_WRITE))
goto err2;
if ((error= cur_table->view_check_option(thd, ignore)) !=
VIEW_CHECK_OK)
diff --git a/sql/table.cc b/sql/table.cc
index db18214165e..1330560b6b6 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -6557,11 +6557,9 @@ bool is_simple_order(ORDER *order)
@details
The function computes the values of the virtual columns of the table and
stores them in the table record buffer.
- If vcol_update_mode is set to VCOL_UPDATE_ALL then all virtual column are
- computed. Otherwise, only fields from vcol_set are computed: all of them,
- if vcol_update_mode is set to VCOL_UPDATE_FOR_WRITE, and, only those with
- the stored_in_db flag set to false, if vcol_update_mode is equal to
- VCOL_UPDATE_FOR_READ.
+ Only fields from vcol_set are computed: all of them, if vcol_update_mode is
+ set to VCOL_UPDATE_FOR_WRITE, and, only those with the stored_in_db flag
+ set to false, if vcol_update_mode is equal to VCOL_UPDATE_FOR_READ.
@retval
0 Success
@@ -6583,9 +6581,8 @@ int update_virtual_fields(THD *thd, TABLE *table,
{
vfield= (*vfield_ptr);
DBUG_ASSERT(vfield->vcol_info && vfield->vcol_info->expr_item);
- if ((bitmap_is_set(table->vcol_set, vfield->field_index) &&
- (vcol_update_mode == VCOL_UPDATE_FOR_WRITE || !vfield->stored_in_db)) ||
- vcol_update_mode == VCOL_UPDATE_ALL)
+ if (bitmap_is_set(table->vcol_set, vfield->field_index) &&
+ (vcol_update_mode == VCOL_UPDATE_FOR_WRITE || !vfield->stored_in_db))
{
/* Compute the actual value of the virtual fields */
error= vfield->vcol_info->expr_item->save_in_field(vfield, 0);
diff --git a/sql/table.h b/sql/table.h
index 17fdd4aba15..dde01a85d77 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -302,8 +302,7 @@ enum release_type { RELEASE_NORMAL, RELEASE_WAIT_FOR_DROP };
enum enum_vcol_update_mode
{
VCOL_UPDATE_FOR_READ= 0,
- VCOL_UPDATE_FOR_WRITE,
- VCOL_UPDATE_ALL
+ VCOL_UPDATE_FOR_WRITE
};
typedef struct st_filesort_info