summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/trigger_null-8605.result5
-rw-r--r--mysql-test/t/trigger_null-8605.test3
-rw-r--r--sql/sql_base.cc3
3 files changed, 6 insertions, 5 deletions
diff --git a/mysql-test/r/trigger_null-8605.result b/mysql-test/r/trigger_null-8605.result
index e024bc6b7d2..b187fc19554 100644
--- a/mysql-test/r/trigger_null-8605.result
+++ b/mysql-test/r/trigger_null-8605.result
@@ -318,9 +318,8 @@ id
delete from t1;
create trigger t1_bi before insert on t1 for each row begin end;
insert t1 values (0);
-select * from t1;
-id
-0
+insert t1 (id) values (0);
+ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
drop table t1;
create table t1 (a int not null, b int);
create trigger trgi before update on t1 for each row do 1;
diff --git a/mysql-test/t/trigger_null-8605.test b/mysql-test/t/trigger_null-8605.test
index 4b51ccd5606..748768a1849 100644
--- a/mysql-test/t/trigger_null-8605.test
+++ b/mysql-test/t/trigger_null-8605.test
@@ -336,7 +336,8 @@ select * from t1;
delete from t1;
create trigger t1_bi before insert on t1 for each row begin end;
insert t1 values (0);
-select * from t1;
+--error ER_DUP_ENTRY
+insert t1 (id) values (0);
drop table t1;
#
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index e808fbafb50..8c1c32e28f6 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -8728,7 +8728,8 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
value=v++;
Field *rfield= field->field;
TABLE* table= rfield->table;
- if (rfield == table->next_number_field)
+ if (table->next_number_field &&
+ rfield->field_index == table->next_number_field->field_index)
table->auto_increment_field_not_null= TRUE;
if (rfield->vcol_info &&
value->type() != Item::DEFAULT_VALUE_ITEM &&