Skip to content

Commit 6ce20fb

Browse files
committed
MDEV-9428 NO_AUTO_VALUE_ON_ZERO is ignored when a trigger before insert is defined
fix the *other* fill_record() too, arrgh!
1 parent 9c38308 commit 6ce20fb

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

mysql-test/r/trigger_null-8605.result

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,8 @@ id
318318
delete from t1;
319319
create trigger t1_bi before insert on t1 for each row begin end;
320320
insert t1 values (0);
321-
select * from t1;
322-
id
323-
0
321+
insert t1 (id) values (0);
322+
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
324323
drop table t1;
325324
create table t1 (a int not null, b int);
326325
create trigger trgi before update on t1 for each row do 1;

mysql-test/t/trigger_null-8605.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ select * from t1;
336336
delete from t1;
337337
create trigger t1_bi before insert on t1 for each row begin end;
338338
insert t1 values (0);
339-
select * from t1;
339+
--error ER_DUP_ENTRY
340+
insert t1 (id) values (0);
340341
drop table t1;
341342

342343
#

sql/sql_base.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8728,7 +8728,8 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
87288728
value=v++;
87298729
Field *rfield= field->field;
87308730
TABLE* table= rfield->table;
8731-
if (rfield == table->next_number_field)
8731+
if (table->next_number_field &&
8732+
rfield->field_index == table->next_number_field->field_index)
87328733
table->auto_increment_field_not_null= TRUE;
87338734
if (rfield->vcol_info &&
87348735
value->type() != Item::DEFAULT_VALUE_ITEM &&

0 commit comments

Comments
 (0)