Skip to content

Commit

Permalink
MDEV-9629 Disappearing PRI from Key column after creating a trigger
Browse files Browse the repository at this point in the history
when creating shadow nullable fields, preserve all
original field flags (because we swap flags
back and forth in not_null_fields_have_null_values())
  • Loading branch information
vuvova committed Mar 19, 2016
1 parent b24a04c commit 2390325
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mysql-test/r/trigger_null-8605.result
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,17 @@ create trigger tr1 before update on t1 for each row do 1;
create trigger tr2 after update on t2 for each row update t1 set a=new.f2;
update t2 set f2=1 where f1=1;
drop table t1, t2;
create table t1 (a int not null, primary key (a));
insert into t1 (a) values (1);
show columns from t1;
Field Type Null Key Default Extra
a int(11) NO PRI NULL
create trigger t1bu before update on t1 for each row begin end;
show columns from t1;
Field Type Null Key Default Extra
a int(11) NO PRI NULL
insert into t1 (a) values (3);
show columns from t1;
Field Type Null Key Default Extra
a int(11) NO PRI NULL
drop table t1;
12 changes: 12 additions & 0 deletions mysql-test/t/trigger_null-8605.test
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,15 @@ create trigger tr1 before update on t1 for each row do 1;
create trigger tr2 after update on t2 for each row update t1 set a=new.f2;
update t2 set f2=1 where f1=1;
drop table t1, t2;

#
# MDEV-9629 Disappearing PRI from Key column after creating a trigger
#
create table t1 (a int not null, primary key (a));
insert into t1 (a) values (1);
show columns from t1;
create trigger t1bu before update on t1 for each row begin end;
show columns from t1;
insert into t1 (a) values (3);
show columns from t1;
drop table t1;
1 change: 1 addition & 0 deletions sql/sql_trigger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ bool Table_triggers_list::prepare_record_accessors(TABLE *table)
table == (*fld)->table)))
return 1;

f->flags= (*fld)->flags;
f->null_ptr= null_ptr;
f->null_bit= null_bit;
if (null_bit == 128)
Expand Down

0 comments on commit 2390325

Please sign in to comment.