Skip to content

Commit

Permalink
MDEV-23518 Syntax error in ond SP results in misleading message on SH…
Browse files Browse the repository at this point in the history
…OW CREATE PROCEDURE

Add info to the error message how to get details about error which happened.
  • Loading branch information
sanja-byelkin committed Oct 3, 2020
1 parent bd64c2e commit acb0c9e
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 17 deletions.
35 changes: 35 additions & 0 deletions mysql-test/main/errors.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
36 changes: 36 additions & 0 deletions mysql-test/main/errors.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
42 changes: 36 additions & 6 deletions mysql-test/main/sp-destruct.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions mysql-test/main/sp-destruct.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion mysql-test/main/sp.result
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/sp.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 35 additions & 7 deletions mysql-test/suite/compat/oracle/r/sp-package.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions mysql-test/suite/compat/oracle/t/sp-package.test
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ CREATE PACKAGE BODY test2 AS
END;
$$
DELIMITER ;$$
show warnings;

DROP PACKAGE test2;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
5 changes: 3 additions & 2 deletions sql/share/errmsg-utf8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down

0 comments on commit acb0c9e

Please sign in to comment.