summaryrefslogtreecommitdiff
path: root/sql/sql_update.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-11-14 22:51:54 +0100
committerSergei Golubchik <serg@mariadb.org>2015-12-21 21:30:54 +0100
commit0686c34d22a5cbf93015012eaf77a4a977b63afb (patch)
tree3c95207d5e01a905f9e87820e6439fe6c6547653 /sql/sql_update.cc
parentad5db17e882fea36dcae6f6e61996b5f9bf28962 (diff)
downloadmariadb-git-0686c34d22a5cbf93015012eaf77a4a977b63afb.tar.gz
MDEV-8605 MariaDB not use DEFAULT value even when inserted NULL for NOT NULLABLE column
NOT NULL constraint must be checked *after* the BEFORE triggers. That is for INSERT and UPDATE statements even NOT NULL fields must be able to store a NULL temporarily at least while BEFORE INSERT/UPDATE triggers are running.
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r--sql/sql_update.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 0caae7ac821..f343a17ee11 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -455,6 +455,8 @@ int mysql_update(THD *thd,
}
init_ftfuncs(thd, select_lex, 1);
+ switch_to_nullable_trigger_fields(fields, table);
+ switch_to_nullable_trigger_fields(values, table);
table->mark_columns_needed_for_update();
table->update_const_key_parts(conds);
@@ -1766,7 +1768,6 @@ int multi_update::prepare(List<Item> &not_used_values,
}
}
-
table_count= update.elements;
update_tables= update.first;
@@ -1802,7 +1803,15 @@ int multi_update::prepare(List<Item> &not_used_values,
/* Allocate copy fields */
max_fields=0;
for (i=0 ; i < table_count ; i++)
+ {
set_if_bigger(max_fields, fields_for_table[i]->elements + leaf_table_count);
+ if (fields_for_table[i]->elements)
+ {
+ TABLE *table= ((Item_field*)(fields_for_table[i]->head()))->field->table;
+ switch_to_nullable_trigger_fields(*fields_for_table[i], table);
+ switch_to_nullable_trigger_fields(*values_for_table[i], table);
+ }
+ }
copy_field= new Copy_field[max_fields];
DBUG_RETURN(thd->is_fatal_error != 0);
}