[MDEV-16311] Server crash when using a NAME_CONST() with a CURSOR Created: 2018-05-28  Updated: 2018-06-13  Resolved: 2018-06-13

Status: Closed
Project: MariaDB Server
Component/s: Stored routines
Affects Version/s: 10.2, 10.3, 10.4
Fix Version/s: 10.2.16, 10.3.8, 10.4.0

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None


 Description   

This script makes the server crash in a debug build:

SET sql_mode=STRICT_ALL_TABLES;
CREATE OR REPLACE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10);
DELIMITER $$
BEGIN NOT ATOMIC
  DECLARE a INT;
  DECLARE c CURSOR FOR SELECT NAME_CONST('x','y') FROM t1;
  OPEN c;
  FETCH c INTO a;
  CLOSE c;
END;
$$
DELIMITER ;

If I change sql_mode to empty, it works fine:

SET sql_mode='';
CREATE OR REPLACE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10);
DELIMITER $$
BEGIN NOT ATOMIC
  DECLARE a INT;
  DECLARE c CURSOR FOR SELECT NAME_CONST('x','y') FROM t1;
  OPEN c;
  FETCH c INTO a;
  CLOSE c;
END;
$$
DELIMITER ;



 Comments   
Comment by Elena Stepanova [ 2018-05-28 ]

10.2 b8fdd56a4d6

mysqld: /data/src/10.2/sql/sql_error.cc:380: void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*): Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed.
180528 14:29:37 [ERROR] mysqld got signal 6 ;
 
#7  0x00007fc81c38dee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x000055d960bdf387 in Diagnostics_area::set_ok_status (this=0x7fc79c005c90, affected_rows=0, last_insert_id=0, message=0x0) at /data/src/10.2/sql/sql_error.cc:380
#9  0x000055d960b91853 in my_ok (thd=0x7fc79c000b00, affected_rows=0, id=0, message=0x0) at /data/src/10.2/sql/sql_class.h:4477
#10 0x000055d960c0a6b6 in do_execute_sp (thd=0x7fc79c000b00, sp=0x7fc79c0572f8) at /data/src/10.2/sql/sql_parse.cc:2920
#11 0x000055d960c139fd in mysql_execute_command (thd=0x7fc79c000b00) at /data/src/10.2/sql/sql_parse.cc:5835
#12 0x000055d960c19e0f in mysql_parse (thd=0x7fc79c000b00, rawbuf=0x7fc79c010f78 "BEGIN NOT ATOMIC\n  DECLARE a INT;\n  DECLARE c CURSOR FOR SELECT NAME_CONST('x','y') FROM t1;\n  OPEN c;\n  FETCH c INTO a;\n  CLOSE c;\nEND", length=135, parser_state=0x7fc80c2c0250, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:8002
#13 0x000055d960c078b8 in dispatch_command (command=COM_QUERY, thd=0x7fc79c000b00, packet=0x7fc79c0191a1 "BEGIN NOT ATOMIC\n  DECLARE a INT;\n  DECLARE c CURSOR FOR SELECT NAME_CONST('x','y') FROM t1;\n  OPEN c;\n  FETCH c INTO a;\n  CLOSE c;\nEND;", packet_length=136, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1821
#14 0x000055d960c0621b in do_command (thd=0x7fc79c000b00) at /data/src/10.2/sql/sql_parse.cc:1375
#15 0x000055d960d55930 in do_handle_one_connection (connect=0x55d9650327c0) at /data/src/10.2/sql/sql_connect.cc:1335
#16 0x000055d960d556bd in handle_one_connection (arg=0x55d9650327c0) at /data/src/10.2/sql/sql_connect.cc:1241
#17 0x00007fc81e064494 in start_thread (arg=0x7fc80c2c1700) at pthread_create.c:333
#18 0x00007fc81c44a93f in clone () from /lib/x86_64-linux-gnu/libc.so.6

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