[Commits] 5e94fe1: MDEV-15754 Server crashes in fill_record_n_invoke_before_triggers upon ...
revision-id: 5e94fe189d6325028613b2c830082e07ff303acb (mariadb-10.3.5-156-g5e94fe1) parent(s): f0e4f94c230326a2f2e608e4119530d775c37b21 author: Sachin Setiya committer: Sachin Setiya timestamp: 2018-04-16 16:27:11 +0530 message: 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. --- mysql-test/main/invisible_field.result | 5 +++++ mysql-test/main/invisible_field.test | 8 ++++++++ sql/sql_trigger.cc | 1 + 3 files changed, 14 insertions(+) diff --git a/mysql-test/main/invisible_field.result b/mysql-test/main/invisible_field.result index c331f3f..5cea77f 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 884abb1..cfe89d7 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 4c1e2a5..d523779 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)
participants (1)
-
sachin