From 2999492c3278528ceb9f37bd6cfca5ca5295ef9a Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Thu, 20 Dec 2018 11:22:13 +0100 Subject: [PATCH] MDEV-16036: Debug assertion failed in resignal on create temporary table Reising condition on NOTW controlled by OPTION_SQL_NOTES. --- mysql-test/main/sp.result | 35 +++++++++++++++++++++++++++++++++++ mysql-test/main/sp.test | 34 ++++++++++++++++++++++++++++++++++ sql/sql_signal.cc | 10 ++++++---- 3 files changed, 75 insertions(+), 4 deletions(-) diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result index 64668e0c8ec..b7a2f865c1d 100644 --- a/mysql-test/main/sp.result +++ b/mysql-test/main/sp.result @@ -8731,3 +8731,38 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; DROP FUNCTION f1; +# +# MDEV-16036: Debug assertion failed in resignal on create +# temporary table +# +set @save_sql_mode= @@sql_mode; +set sql_mode='ORACLE'; +CREATE or replace procedure p4() +AS +CONTINUE HANDLER FOR SQLWARNING +BEGIN +NULL; +END; +EXIT HANDLER FOR OTHERS -- SQLEXCEPTION +BEGIN +GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE, @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT; +SELECT @sqlstate, @errno, @text; +SHOW WARNINGS; +RESIGNAL; -- cause DBG_ASSERT failed +END; +BEGIN +CREATE TEMPORARY TABLE IF NOT EXISTS t1(origine VARCHAR2(10) NOT NULL); +END +/ +call p4(); +call p4(); +@sqlstate @errno @text +42S01 1050 Table 't1' already exists +Level Code Message +Note 1050 Table 't1' already exists +Warnings: +Note 1050 Table 't1' already exists +drop procedure p4; +drop table t1; +set @@sql_mode=@save_sql_mode; +# End of 10.3 tests diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test index 72e6ad6bcba..98b85983687 100644 --- a/mysql-test/main/sp.test +++ b/mysql-test/main/sp.test @@ -10252,3 +10252,37 @@ CREATE TABLE t1 AS SELECT f1() AS c1, COALESCE(f1()) AS c2, CONCAT(f1()) AS c3; SHOW CREATE TABLE t1; DROP TABLE t1; DROP FUNCTION f1; + +--echo # +--echo # MDEV-16036: Debug assertion failed in resignal on create +--echo # temporary table +--echo # + +set @save_sql_mode= @@sql_mode; +set sql_mode='ORACLE'; +delimiter /; +CREATE or replace procedure p4() +AS + CONTINUE HANDLER FOR SQLWARNING + BEGIN + NULL; + END; + EXIT HANDLER FOR OTHERS -- SQLEXCEPTION + BEGIN + GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE, @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT; + SELECT @sqlstate, @errno, @text; + SHOW WARNINGS; + RESIGNAL; -- cause DBG_ASSERT failed + END; +BEGIN + CREATE TEMPORARY TABLE IF NOT EXISTS t1(origine VARCHAR2(10) NOT NULL); +END +/ +delimiter ;/ +call p4(); +call p4(); +drop procedure p4; +drop table t1; +set @@sql_mode=@save_sql_mode; + +--echo # End of 10.3 tests diff --git a/sql/sql_signal.cc b/sql/sql_signal.cc index a92d40f6bb3..1317308ceb9 100644 --- a/sql/sql_signal.cc +++ b/sql/sql_signal.cc @@ -343,13 +343,15 @@ bool Sql_cmd_common_signal::raise_condition(THD *thd, Sql_condition *cond) if (eval_signal_informations(thd, cond)) DBUG_RETURN(result); - /* SIGNAL should not signal WARN_LEVEL_NOTE */ - DBUG_ASSERT((cond->m_level == Sql_condition::WARN_LEVEL_WARN) || - (cond->m_level == Sql_condition::WARN_LEVEL_ERROR)); + /* SIGNAL should not signal WARN_LEVEL_NOTE, but RESIGNAL can */ + DBUG_ASSERT(cond->m_level == Sql_condition::WARN_LEVEL_ERROR || + cond->m_level != Sql_condition::WARN_LEVEL_NOTE || + sql_command_code() == SQLCOM_RESIGNAL); (void) thd->raise_condition(cond); - if (cond->m_level == Sql_condition::WARN_LEVEL_WARN) + if (cond->m_level == Sql_condition::WARN_LEVEL_WARN || + cond->m_level == Sql_condition::WARN_LEVEL_NOTE) { my_ok(thd); result= FALSE;