diff --git a/mysql-test/main/errors.result b/mysql-test/main/errors.result index 78695b07b8e51..4419386549394 100644 --- a/mysql-test/main/errors.result +++ b/mysql-test/main/errors.result @@ -196,3 +196,38 @@ ERROR 22003: BIGINT value is out of range in '-73 * -2465717823867977728' SELECT UPDATEXML(-73 * -2465717823867977728,@@global.long_query_time,null); ERROR 22003: BIGINT value is out of range in '-73 * -2465717823867977728' # End of 10.3 tests +# +# MDEV-23518: Syntax error in ond SP results in misleading +# message on SHOW CREATE PROCEDURE +# +CREATE PROCEDURE P1 () +BEGIN NOT ATOMIC +IF (SELECT 2) THEN +SELECT 4; +END IF ; +END; +$$ +select name,db,body from mysql.proc where name = "P1"; +name db body +P1 test BEGIN NOT ATOMIC +IF (SELECT 2) THEN +SELECT 4; +END IF ; +END +update mysql.proc set body_utf8="BEGIN NOT ATOMIC +IF (SELECT 2) OR foo = 3 THEN +SELECT 4; +END IF ; +END", body="BEGIN NOT ATOMIC +IF (SELECT 2) OR foo = 3 THEN +SELECT 4; +END IF ; +END"where name = "P1"; +show create procedure P1; +ERROR HY000: Failed to load routine test.P1 (internal code -6). For more details, run SHOW WARNINGS +show warnings; +Level Code Message +Error 1327 Undeclared variable: foo +Error 1457 Failed to load routine test.P1 (internal code -6). For more details, run SHOW WARNINGS +drop procedure P1; +# End of 10.4 tests diff --git a/mysql-test/main/errors.test b/mysql-test/main/errors.test index f3aedc8e491e9..a4b95d48e5d04 100644 --- a/mysql-test/main/errors.test +++ b/mysql-test/main/errors.test @@ -246,3 +246,39 @@ SELECT UPDATEXML(-73 * -2465717823867977728,@@global.auto_increment_increment,nu SELECT UPDATEXML(-73 * -2465717823867977728,@@global.long_query_time,null); -- echo # End of 10.3 tests + +--echo # +--echo # MDEV-23518: Syntax error in ond SP results in misleading +--echo # message on SHOW CREATE PROCEDURE +--echo # + +DELIMITER $$; + +CREATE PROCEDURE P1 () +BEGIN NOT ATOMIC + IF (SELECT 2) THEN + SELECT 4; + END IF ; +END; +$$ + +DELIMITER ;$$ + +select name,db,body from mysql.proc where name = "P1"; +update mysql.proc set body_utf8="BEGIN NOT ATOMIC +IF (SELECT 2) OR foo = 3 THEN +SELECT 4; +END IF ; +END", body="BEGIN NOT ATOMIC +IF (SELECT 2) OR foo = 3 THEN +SELECT 4; +END IF ; +END"where name = "P1"; + +--error ER_SP_PROC_TABLE_CORRUPT +show create procedure P1; +show warnings; + +drop procedure P1; + +-- echo # End of 10.4 tests diff --git a/mysql-test/main/sp-destruct.result b/mysql-test/main/sp-destruct.result index 10cfcafdb3b2b..b5e01f8beeb2d 100644 --- a/mysql-test/main/sp-destruct.result +++ b/mysql-test/main/sp-destruct.result @@ -71,19 +71,49 @@ values 'alksj wpsj sa ^#!@ ' ); select bug14233_1(); -ERROR HY000: Failed to load routine test.bug14233_1. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6) +ERROR HY000: Failed to load routine test.bug14233_1 (internal code -6). For more details, run SHOW WARNINGS +show warnings; +Level Code Message +Warning 1601 Creation context of stored routine `test`.`bug14233_1` is invalid +Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'select count(*) from mysql.user' at line 3 +Error 1457 Failed to load routine test.bug14233_1 (internal code -6). For more details, run SHOW WARNINGS create view v1 as select bug14233_1(); -ERROR HY000: Failed to load routine test.bug14233_1. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6) +ERROR HY000: Failed to load routine test.bug14233_1 (internal code -6). For more details, run SHOW WARNINGS +show warnings; +Level Code Message +Warning 1601 Creation context of stored routine `test`.`bug14233_1` is invalid +Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'select count(*) from mysql.user' at line 3 +Error 1457 Failed to load routine test.bug14233_1 (internal code -6). For more details, run SHOW WARNINGS select bug14233_2(); -ERROR HY000: Failed to load routine test.bug14233_2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6) +ERROR HY000: Failed to load routine test.bug14233_2 (internal code -6). For more details, run SHOW WARNINGS +show warnings; +Level Code Message +Warning 1601 Creation context of stored routine `test`.`bug14233_2` is invalid +Error 1320 No RETURN found in FUNCTION test.bug14233_2 +Error 1457 Failed to load routine test.bug14233_2 (internal code -6). For more details, run SHOW WARNINGS create view v1 as select bug14233_2(); -ERROR HY000: Failed to load routine test.bug14233_2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6) +ERROR HY000: Failed to load routine test.bug14233_2 (internal code -6). For more details, run SHOW WARNINGS +show warnings; +Level Code Message +Warning 1601 Creation context of stored routine `test`.`bug14233_2` is invalid +Error 1320 No RETURN found in FUNCTION test.bug14233_2 +Error 1457 Failed to load routine test.bug14233_2 (internal code -6). For more details, run SHOW WARNINGS call bug14233_3(); -ERROR HY000: Failed to load routine test.bug14233_3. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6) +ERROR HY000: Failed to load routine test.bug14233_3 (internal code -6). For more details, run SHOW WARNINGS +show warnings; +Level Code Message +Warning 1601 Creation context of stored routine `test`.`bug14233_3` is invalid +Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'wpsj sa ^#!@ ' at line 3 +Error 1457 Failed to load routine test.bug14233_3 (internal code -6). For more details, run SHOW WARNINGS drop trigger t1_ai; create trigger t1_ai after insert on t1 for each row call bug14233_3(); insert into t1 values (0); -ERROR HY000: Failed to load routine test.bug14233_3. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6) +ERROR HY000: Failed to load routine test.bug14233_3 (internal code -6). For more details, run SHOW WARNINGS +show warnings; +Level Code Message +Warning 1601 Creation context of stored routine `test`.`bug14233_3` is invalid +Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'wpsj sa ^#!@ ' at line 3 +Error 1457 Failed to load routine test.bug14233_3 (internal code -6). For more details, run SHOW WARNINGS drop trigger t1_ai; drop table t1; drop function bug14233_1; diff --git a/mysql-test/main/sp-destruct.test b/mysql-test/main/sp-destruct.test index 12299fa230bcd..4bdfed70545de 100644 --- a/mysql-test/main/sp-destruct.test +++ b/mysql-test/main/sp-destruct.test @@ -128,20 +128,26 @@ values --error ER_SP_PROC_TABLE_CORRUPT select bug14233_1(); +show warnings; --error ER_SP_PROC_TABLE_CORRUPT create view v1 as select bug14233_1(); +show warnings; --error ER_SP_PROC_TABLE_CORRUPT select bug14233_2(); +show warnings; --error ER_SP_PROC_TABLE_CORRUPT create view v1 as select bug14233_2(); +show warnings; --error ER_SP_PROC_TABLE_CORRUPT call bug14233_3(); +show warnings; drop trigger t1_ai; create trigger t1_ai after insert on t1 for each row call bug14233_3(); --error ER_SP_PROC_TABLE_CORRUPT insert into t1 values (0); +show warnings; # Clean-up drop trigger t1_ai; diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result index d40516da88e2c..6bde488642abf 100644 --- a/mysql-test/main/sp.result +++ b/mysql-test/main/sp.result @@ -5306,8 +5306,12 @@ drop database if exists това_е_дълго_име_за_база_данни_ create database това_е_дълго_име_за_база_данни_нали| INSERT INTO mysql.proc VALUES ('това_е_дълго_име_за_база_данни_нали','това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго','PROCEDURE','това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго','SQL','CONTAINS_SQL','NO','DEFINER','','','bad_body','root@localhost',now(), now(),'','', 'utf8', 'utf8_general_ci', 'utf8_general_ci', 'n/a', 'NONE')| call това_е_дълго_име_за_база_данни_нали.това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго()| -ERROR HY000: Failed to load routine това_е_дълго_име_за_база_данни_нали.това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6) +ERROR HY000: Failed to load routine това_е_дълго_име_за_база_данни_нали.това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго (internal code -6). For more details, run SHOW WARNINGS drop database това_е_дълго_име_за_база_данни_нали| +show warnings| +Level Code Message +Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 2 +Error 1457 Failed to load routine това_е_дълго_име_за_база_данни_нали.това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго (internal code -6). For more details, run SHOW WARNINGS CREATE TABLE t3 ( Member_ID varchar(15) NOT NULL, PRIMARY KEY (Member_ID) diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test index bddd07bdb6cdf..c6c00ca8d9106 100644 --- a/mysql-test/main/sp.test +++ b/mysql-test/main/sp.test @@ -6315,7 +6315,7 @@ INSERT INTO mysql.proc VALUES ('това_е_дълго_име_за_база_да --error ER_SP_PROC_TABLE_CORRUPT call това_е_дълго_име_за_база_данни_нали.това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго()| drop database това_е_дълго_име_за_база_данни_нали| - +show warnings| # # BUG#21493: Crash on the second call of a procedure containing diff --git a/mysql-test/suite/compat/oracle/r/sp-package.result b/mysql-test/suite/compat/oracle/r/sp-package.result index 4f0f05b19393a..e7ab4eaa4a2ed 100644 --- a/mysql-test/suite/compat/oracle/r/sp-package.result +++ b/mysql-test/suite/compat/oracle/r/sp-package.result @@ -249,7 +249,11 @@ RETURN f2(); END; END; $$ -ERROR HY000: Failed to load routine test.test2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6) +ERROR HY000: Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS +show warnings; +Level Code Message +Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'garbage' at line 1 +Error 1457 Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS DROP PACKAGE test2; # # Broken CREATE PACKAGE at a package function call time @@ -271,11 +275,23 @@ UPDATE mysql.proc SET `body`='garbage' WHERE db='test' AND name='test2' AND type='PACKAGE'; # sp-cache-invalidate SELECT test2.f1(); -ERROR HY000: Failed to load routine test.test2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6) +ERROR HY000: Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS +show warnings; +Level Code Message +Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'garbage' at line 1 +Error 1457 Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS SELECT test2.f1(); -ERROR HY000: Failed to load routine test.test2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6) +ERROR HY000: Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS +show warnings; +Level Code Message +Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'garbage' at line 1 +Error 1457 Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS SELECT test2.f1(); -ERROR HY000: Failed to load routine test.test2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6) +ERROR HY000: Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS +show warnings; +Level Code Message +Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'garbage' at line 1 +Error 1457 Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS DROP PACKAGE test2; # # Broken CREATE PACKAGE at a package procedure call time @@ -297,11 +313,23 @@ UPDATE mysql.proc SET `body`='garbage' WHERE db='test' AND name='test2' AND type='PACKAGE'; # sp-cache-invalidate CALL test2.p1(); -ERROR HY000: Failed to load routine test.test2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6) +ERROR HY000: Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS +show warnings; +Level Code Message +Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'garbage' at line 1 +Error 1457 Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS CALL test2.p1(); -ERROR HY000: Failed to load routine test.test2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6) +ERROR HY000: Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS +show warnings; +Level Code Message +Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'garbage' at line 1 +Error 1457 Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS CALL test2.p1(); -ERROR HY000: Failed to load routine test.test2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6) +ERROR HY000: Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS +show warnings; +Level Code Message +Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'garbage' at line 1 +Error 1457 Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS DROP PACKAGE test2; # # Bad routine names diff --git a/mysql-test/suite/compat/oracle/t/sp-package.test b/mysql-test/suite/compat/oracle/t/sp-package.test index 5eac398798294..96420c18820be 100644 --- a/mysql-test/suite/compat/oracle/t/sp-package.test +++ b/mysql-test/suite/compat/oracle/t/sp-package.test @@ -335,6 +335,7 @@ CREATE PACKAGE BODY test2 AS END; $$ DELIMITER ;$$ +show warnings; DROP PACKAGE test2; @@ -367,10 +368,13 @@ UPDATE mysql.proc SET `body`='garbage' --source sp-cache-invalidate.inc --error ER_SP_PROC_TABLE_CORRUPT SELECT test2.f1(); +show warnings; --error ER_SP_PROC_TABLE_CORRUPT SELECT test2.f1(); +show warnings; --error ER_SP_PROC_TABLE_CORRUPT SELECT test2.f1(); +show warnings; DROP PACKAGE test2; @@ -403,10 +407,13 @@ UPDATE mysql.proc SET `body`='garbage' --source sp-cache-invalidate.inc --error ER_SP_PROC_TABLE_CORRUPT CALL test2.p1(); +show warnings; --error ER_SP_PROC_TABLE_CORRUPT CALL test2.p1(); +show warnings; --error ER_SP_PROC_TABLE_CORRUPT CALL test2.p1(); +show warnings; DROP PACKAGE test2; diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 6f366e18b2f9c..e526363029b5d 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -5722,8 +5722,9 @@ ER_SP_RECURSION_LIMIT eng "Recursive limit %d (as set by the max_sp_recursion_depth variable) was exceeded for routine %.192s" ger "Rekursionsgrenze %d (durch Variable max_sp_recursion_depth gegeben) wurde für Routine %.192s überschritten" ER_SP_PROC_TABLE_CORRUPT - eng "Failed to load routine %-.192s. The table mysql.proc is missing, corrupt, or contains bad data (internal code %d)" - ger "Routine %-.192s konnte nicht geladen werden. Die Tabelle mysql.proc fehlt, ist beschädigt, oder enthält fehlerhaften Daten (interner Code: %d)" + eng "Failed to load routine %-.192s (internal code %d). For more details, run SHOW WARNINGS" + ger "Fehler beim Laden der Routine %-.192s (interner Code %d). Weitere Informationen finden Sie unter SHOW WARNINGS" + ukr "Невдала спроба завантажити процедуру %-.192s (внутрішний код %d). Для отримання детальної інформації використовуйте SHOW WARNINGS" ER_SP_WRONG_NAME 42000 eng "Incorrect routine name '%-.192s'" ger "Ungültiger Routinenname '%-.192s'"