[MDEV-15754] Server crashes in fill_record_n_invoke_before_triggers upon insert into table with TIMESTAMP INVISIBLE Created: 2018-04-02  Updated: 2018-04-19  Resolved: 2018-04-19

Status: Closed
Project: MariaDB Server
Component/s: Server, Triggers
Affects Version/s: 10.3
Fix Version/s: 10.3.7

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Sachin Setiya (Inactive)
Resolution: Fixed Votes: 0
Labels: 10.3-ga


 Description   

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;

10.3 69efa1343a0a047

#3  <signal handler called>
#4  0x0000556623cb06b8 in fill_record (thd=0x7fc5b0000b00, table=0x7fc5b00753f0, ptr=0x7fc5b0076a68, values=..., ignore_errors=true, use_value=false) at /data/src/10.3/sql/sql_base.cc:8457
#5  0x0000556623cb0927 in fill_record_n_invoke_before_triggers (thd=0x7fc5b0000b00, table=0x7fc5b00753f0, ptr=0x7fc5b0076a58, values=..., ignore_errors=true, event=TRG_EVENT_INSERT) at /data/src/10.3/sql/sql_base.cc:8510
#6  0x0000556623cfa8e6 in select_insert::store_values (this=0x7fc5b0016ed8, values=...) at /data/src/10.3/sql/sql_insert.cc:3904
#7  0x0000556623cfa58e in select_insert::send_data (this=0x7fc5b0016ed8, values=...) at /data/src/10.3/sql/sql_insert.cc:3837
#8  0x0000556623da4694 in end_send (join=0x7fc5b0016f80, join_tab=0x0, end_of_records=false) at /data/src/10.3/sql/sql_select.cc:20407
#9  0x0000556623da0bb0 in do_select (join=0x7fc5b0016f80, procedure=0x0) at /data/src/10.3/sql/sql_select.cc:18735
#10 0x0000556623d79e78 in JOIN::exec_inner (this=0x7fc5b0016f80) at /data/src/10.3/sql/sql_select.cc:3989
#11 0x0000556623d79310 in JOIN::exec (this=0x7fc5b0016f80) at /data/src/10.3/sql/sql_select.cc:3783
#12 0x0000556623d7a551 in mysql_select (thd=0x7fc5b0000b00, tables=0x7fc5b00155f0, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=3489925888, result=0x7fc5b0016ed8, unit=0x7fc5b0004948, select_lex=0x7fc5b00050c0) at /data/src/10.3/sql/sql_select.cc:4188
#13 0x0000556623d6c7f5 in handle_select (thd=0x7fc5b0000b00, lex=0x7fc5b0004880, result=0x7fc5b0016ed8, setup_tables_done_option=1073741824) at /data/src/10.3/sql/sql_select.cc:382
#14 0x0000556623d3130f in mysql_execute_command (thd=0x7fc5b0000b00) at /data/src/10.3/sql/sql_parse.cc:4833
#15 0x0000556623d3b39c in mysql_parse (thd=0x7fc5b0000b00, rawbuf=0x7fc5b0014d58 "INSERT INTO t1 SELECT * FROM t1", length=31, parser_state=0x7fc5cc74c5d0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:8013
#16 0x0000556623d28a4f in dispatch_command (command=COM_QUERY, thd=0x7fc5b0000b00, packet=0x7fc5b008fe31 "INSERT INTO t1 SELECT * FROM t1", packet_length=31, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1842
#17 0x0000556623d2748e in do_command (thd=0x7fc5b0000b00) at /data/src/10.3/sql/sql_parse.cc:1387
#18 0x0000556623e8bde5 in do_handle_one_connection (connect=0x556627b61220) at /data/src/10.3/sql/sql_connect.cc:1402
#19 0x0000556623e8bb72 in handle_one_connection (arg=0x556627b61220) at /data/src/10.3/sql/sql_connect.cc:1308
#20 0x0000556624312c2b in pfs_spawn_thread (arg=0x556627c236c0) at /data/src/10.3/storage/perfschema/pfs.cc:1862
#21 0x00007fc5d3a7b494 in start_thread (arg=0x7fc5cc74d700) at pthread_create.c:333
#22 0x00007fc5d1e6193f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Reproducible with at least MyISAM, InnoDB, Aria.



 Comments   
Comment by Sachin Setiya (Inactive) [ 2018-04-16 ]

Patch

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)

Comment by Sachin Setiya (Inactive) [ 2018-04-16 ]

Although If there is one issue with this solution , It changes t1(timestamp) values (with invisible and without invisible).
With Invisible (patch applied )

main.invisible_field                     [ fail ]
        Test ended at 2018-04-16 16:09:39
 
CURRENT_TEST: main.invisible_field
--- /home/sachin/10.3/server/mysql-test/main/invisible_field.result     2018-04-16 13:30:06.648254214 +0530
+++ /home/sachin/10.3/server/mysql-test/main/invisible_field.reject     2018-04-16 16:09:39.730991158 +0530
@@ -551,3 +551,12 @@
 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;
+select c,t from t1;
+c      t
+foo    2000-01-01 00:00:00
+foo    2018-04-16 16:09:39
+DROP TABLE t1;
 
mysqltest: Result length mismatch
 
 - saving '/home/sachin/10.3/build/mysql-test/var/log/main.invisible_field/' to '/home/sachin/10.3/build/mysql-test/var/log/main.invisible_field/'
--------------------------------------------------------------------------
The servers were restarted 0 times
Spent 0.000 of 9 seconds executing testcases

Without invisible (Patch applied)

main.invisible_field                     [ fail ]
        Test ended at 2018-04-16 16:10:24
 
CURRENT_TEST: main.invisible_field
--- /home/sachin/10.3/server/mysql-test/main/invisible_field.result     2018-04-16 13:30:06.648254214 +0530
+++ /home/sachin/10.3/server/mysql-test/main/invisible_field.reject     2018-04-16 16:10:23.970286538 +0530
@@ -551,3 +551,12 @@
 b      c       a       d
 2      3       1       4
 drop table t1, t2;
+CREATE TABLE t1 (c CHAR(3), t TIMESTAMP );
+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;
+select c,t from t1;
+c      t
+foo    2000-01-01 00:00:00
+foo    2000-01-01 00:00:00
+DROP TABLE t1;
 
mysqltest: Result length mismatch
 
 - saving '/home/sachin/10.3/build/mysql-test/var/log/main.invisible_field/' to '/home/sachin/10.3/build/mysql-test/var/log/main.invisible_field/'
--------------------------------------------------------------------------
The servers were restarted 0 times
Spent 0.000 of 5 seconds executing testcases.

Comment by Sachin Setiya (Inactive) [ 2018-04-16 ]

I am not sure why it fails , but seems like timestamp field is updated .. But why ?

Comment by Sachin Setiya (Inactive) [ 2018-04-16 ]

Ohh okay, got it nothing to worry , because in first case where timestamp is invisible it will get default values , but when it is not invisible it will copy old value

Comment by Sachin Setiya (Inactive) [ 2018-04-16 ]

http://lists.askmonty.org/pipermail/commits/2018-April/012398.html

Generated at Thu Feb 08 08:23:46 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.