Details
-
Bug
-
Status: Closed (View Workflow)
-
Blocker
-
Resolution: Fixed
-
10.2.13, 10.3.5
-
Windows x64 and CENTOS 7.4
-
10.2.14
Description
https://mariadb.com/kb/en/library/mariadb-10213-call-procedure-param-last_insert_id/
Before the update MariaDB 10.2.13 I was able to call a procedure inside the other passing as argument LAST_INSERT_ID (), now of the error in MariaDB, after the update I have to assign the LAST_INSERT_ID () in a variable before calling the procedure
Before MariaDB 10.2.13
in procedure1
CALL procedure2 (LAST_INSERT_ID ());
|
After MariaDB 10.2.13
in procedure1
SET id = LAST_INSERT_ID (); |
CALL procedure2 (id);
|
Run CALL procedure1 ();
SET FOREIGN_KEY_CHECKS=0; |
-- ----------------------------
|
-- Table structure for `table`
|
-- ----------------------------
|
DROP TABLE IF EXISTS `table`; |
CREATE TABLE `table` ( |
`id` int(11) NOT NULL AUTO_INCREMENT, |
`name` varchar(20) DEFAULT NULL, |
PRIMARY KEY (`id`) |
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; |
-- ----------------------------
|
-- Procedure definition for `procedure1`
|
-- ----------------------------
|
DROP PROCEDURE IF EXISTS `procedure1`; |
DELIMITER ;;
|
CREATE DEFINER=`root`@`localhost` PROCEDURE `procedure1`() |
MAIN:BEGIN |
DECLARE id INT(11) DEFAULT NULL; |
|
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION |
BEGIN |
GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE, @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
|
SELECT @text AS message; |
ROLLBACK; |
END; |
|
START TRANSACTION; |
|
INSERT INTO `table` (name) VALUES ('Elvis'); |
|
SET id = LAST_INSERT_ID(); |
|
CALL procedure2(LAST_INSERT_ID());
|
|
SELECT 'Add' AS message; |
|
COMMIT; |
END
|
;;
|
DELIMITER ;
|
-- ----------------------------
|
-- Procedure definition for `procedure2`
|
-- ----------------------------
|
DROP PROCEDURE IF EXISTS `procedure2`; |
DELIMITER ;;
|
CREATE DEFINER=`root`@`localhost` PROCEDURE `procedure2`(IN id int(11)) |
BEGIN
|
#Routine body goes here...
|
|
END
|
;;
|
DELIMITER ;
|
Attachments
Issue Links
- duplicates
-
MDEV-15545 crash 11 during evaluating an expression
-
- Closed
-
- relates to
-
MDEV-15449 Signal 11 using LAST_INSERT_ID() as parameter in stored procedure
-
- Closed
-
-
MDEV-15870 Using aggregate and window function in unexpected places can crash the server
-
- Closed
-
This actually causes a server crash. I reproduced using the test case in the description:
Server version: 10.2.13-MariaDB-10.2.13+maria~trusty-log
key_buffer_size=16384
read_buffer_size=131072
max_used_connections=2
max_threads=802
thread_count=8
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 1762270 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
Thread pointer: 0x7fa9700024d8
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0x7fa9ba739e70 thread_stack 0x40000
addr2line: 'mysqld': No such file
mysqld(my_print_stacktrace+0x2e)[0x5593b77d627e]
mysqld(handle_fatal_signal+0x355)[0x5593b725b295]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x10330)[0x7fa9d6d6a330]
addr2line: 'mysqld': No such file
mysqld(_ZN24Item_func_last_insert_id10fix_fieldsEP3THDPP4Item+0x37)[0x5593b72c32a7]
mysqld(_Z20sp_prepare_func_itemP3THDPP4Item+0x3f)[0x5593b738b7ef]
mysqld(_Z12sp_eval_exprP3THDP5FieldPP4Item+0x3c)[0x5593b738b8bc]
mysqld(_ZN11sp_rcontext12set_variableEP3THDP5FieldPP4Item+0x17)[0x5593b7394357]
mysqld(_ZN7sp_head17execute_procedureEP3THDP4ListI4ItemE+0xe3)[0x5593b738de73]
mysqld(_Z21mysql_execute_commandP3THD+0x6b88)[0x5593b70cd2e8]
mysqld(_ZN13sp_instr_stmt9exec_coreEP3THDPj+0x15)[0x5593b7389b25]
mysqld(_ZN13sp_lex_keeper23reset_lex_and_exec_coreEP3THDPjbP8sp_instr+0x9d)[0x5593b738fdcd]
mysqld(_ZN13sp_instr_stmt7executeEP3THDPj+0x205)[0x5593b73903a5]
mysqld(_ZN7sp_head7executeEP3THDb+0x7b0)[0x5593b738cb50]
mysqld(_ZN7sp_head17execute_procedureEP3THDP4ListI4ItemE+0x5ef)[0x5593b738e37f]
mysqld(_Z21mysql_execute_commandP3THD+0x6b88)[0x5593b70cd2e8]
mysqld(_Z11mysql_parseP3THDPcjP12Parser_statebb+0x351)[0x5593b70cffa1]
mysqld(_Z16dispatch_command19enum_server_commandP3THDPcjbb+0x2b9d)[0x5593b70d3c6d]
mysqld(_Z10do_commandP3THD+0x149)[0x5593b70d46f9]
mysqld(_Z24do_handle_one_connectionP7CONNECT+0x1aa)[0x5593b719b35a]
mysqld(handle_one_connection+0x3d)[0x5593b719b47d]
nptl/pthread_create.c:312(start_thread)[0x7fa9d6d62184]
x86_64/clone.S:113(clone)[0x7fa9d648503d]
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7fa9700602b0): is an invalid pointer
Connection ID (thread ID): 11
Status: NOT_KILLED
Optimizer switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,
firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache
=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
We think the query pointer is invalid, but we will try to print it anyway.
Query: CALL procedure2(LAST_INSERT_ID())
Anything else I can provide?