diff options
author | Sachin Setiya <sachinsetia1001@gmail.com> | 2018-04-16 16:27:11 +0530 |
---|---|---|
committer | Sachin Setiya <sachinsetia1001@gmail.com> | 2018-04-19 12:29:23 +0530 |
commit | dde0ba5aaaf653af3079939536a8dd0f90abbb41 (patch) | |
tree | f69a221d148de1cd5f905f4ec5c8aa906639a00e | |
parent | fa68b88b5d415ebec84602b449bddeed761be04f (diff) | |
download | mariadb-git-dde0ba5aaaf653af3079939536a8dd0f90abbb41.tar.gz |
MDEV-15754 Server crashes in fill_record_n_invoke_before_triggers upon ...
insert into table with TIMESTAMP INVISIBLE
Problem:- The segfault occurs because value is null but since timestamp field
is VISIBLE it expects a value , and it tries to call value->save_in_field(..
Timestamp field should not be visible this is the problem.
Solution:- While we clone field for record0_field we don't honor the field
_visibility , this patch changes that.
-rw-r--r-- | mysql-test/main/invisible_field.result | 5 | ||||
-rw-r--r-- | mysql-test/main/invisible_field.test | 8 | ||||
-rw-r--r-- | sql/sql_trigger.cc | 1 |
3 files changed, 14 insertions, 0 deletions
diff --git a/mysql-test/main/invisible_field.result b/mysql-test/main/invisible_field.result index c331f3fca88..5cea77f5b0c 100644 --- a/mysql-test/main/invisible_field.result +++ b/mysql-test/main/invisible_field.result @@ -551,3 +551,8 @@ select * from t1 natural join t2; b c a d 2 3 1 4 drop table t1, t2; +CREATE TABLE t1 (c CHAR(3), t TIMESTAMP invisible); +INSERT INTO t1 (c,t) VALUES ('foo','2000-01-01 00:00:00'); +CREATE TRIGGER tr BEFORE INSERT ON t1 FOR EACH ROW SET @a= 1; +INSERT INTO t1 SELECT * FROM t1; +DROP TABLE t1; diff --git a/mysql-test/main/invisible_field.test b/mysql-test/main/invisible_field.test index 884abb1238d..cfe89d77230 100644 --- a/mysql-test/main/invisible_field.test +++ b/mysql-test/main/invisible_field.test @@ -238,3 +238,11 @@ insert t2 (a,b,d) values (1,2,4), (10, 30, 40); select * from t1 join t2 using (a); select * from t1 natural join t2; drop table t1, t2; +## Triggers MDEV-15754 +CREATE TABLE t1 (c CHAR(3), t TIMESTAMP invisible); +INSERT INTO t1 (c,t) VALUES ('foo','2000-01-01 00:00:00'); + +CREATE TRIGGER tr BEFORE INSERT ON t1 FOR EACH ROW SET @a= 1; +INSERT INTO t1 SELECT * FROM t1; +# Cleanup +DROP TABLE t1; diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 4c1e2a51fbf..d523779cda7 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1240,6 +1240,7 @@ bool Table_triggers_list::prepare_record_accessors(TABLE *table) return 1; f->flags= (*fld)->flags; + f->invisible= (*fld)->invisible; f->null_ptr= null_ptr; f->null_bit= null_bit; if (null_bit == 128) |