Skip to content

Commit acb0c9e

Browse files
committed
MDEV-23518 Syntax error in ond SP results in misleading message on SHOW CREATE PROCEDURE
Add info to the error message how to get details about error which happened.
1 parent bd64c2e commit acb0c9e

File tree

9 files changed

+164
-17
lines changed

9 files changed

+164
-17
lines changed

mysql-test/main/errors.result

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,38 @@ ERROR 22003: BIGINT value is out of range in '-73 * -2465717823867977728'
196196
SELECT UPDATEXML(-73 * -2465717823867977728,@@global.long_query_time,null);
197197
ERROR 22003: BIGINT value is out of range in '-73 * -2465717823867977728'
198198
# End of 10.3 tests
199+
#
200+
# MDEV-23518: Syntax error in ond SP results in misleading
201+
# message on SHOW CREATE PROCEDURE
202+
#
203+
CREATE PROCEDURE P1 ()
204+
BEGIN NOT ATOMIC
205+
IF (SELECT 2) THEN
206+
SELECT 4;
207+
END IF ;
208+
END;
209+
$$
210+
select name,db,body from mysql.proc where name = "P1";
211+
name db body
212+
P1 test BEGIN NOT ATOMIC
213+
IF (SELECT 2) THEN
214+
SELECT 4;
215+
END IF ;
216+
END
217+
update mysql.proc set body_utf8="BEGIN NOT ATOMIC
218+
IF (SELECT 2) OR foo = 3 THEN
219+
SELECT 4;
220+
END IF ;
221+
END", body="BEGIN NOT ATOMIC
222+
IF (SELECT 2) OR foo = 3 THEN
223+
SELECT 4;
224+
END IF ;
225+
END"where name = "P1";
226+
show create procedure P1;
227+
ERROR HY000: Failed to load routine test.P1 (internal code -6). For more details, run SHOW WARNINGS
228+
show warnings;
229+
Level Code Message
230+
Error 1327 Undeclared variable: foo
231+
Error 1457 Failed to load routine test.P1 (internal code -6). For more details, run SHOW WARNINGS
232+
drop procedure P1;
233+
# End of 10.4 tests

mysql-test/main/errors.test

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,39 @@ SELECT UPDATEXML(-73 * -2465717823867977728,@@global.auto_increment_increment,nu
246246
SELECT UPDATEXML(-73 * -2465717823867977728,@@global.long_query_time,null);
247247

248248
-- echo # End of 10.3 tests
249+
250+
--echo #
251+
--echo # MDEV-23518: Syntax error in ond SP results in misleading
252+
--echo # message on SHOW CREATE PROCEDURE
253+
--echo #
254+
255+
DELIMITER $$;
256+
257+
CREATE PROCEDURE P1 ()
258+
BEGIN NOT ATOMIC
259+
IF (SELECT 2) THEN
260+
SELECT 4;
261+
END IF ;
262+
END;
263+
$$
264+
265+
DELIMITER ;$$
266+
267+
select name,db,body from mysql.proc where name = "P1";
268+
update mysql.proc set body_utf8="BEGIN NOT ATOMIC
269+
IF (SELECT 2) OR foo = 3 THEN
270+
SELECT 4;
271+
END IF ;
272+
END", body="BEGIN NOT ATOMIC
273+
IF (SELECT 2) OR foo = 3 THEN
274+
SELECT 4;
275+
END IF ;
276+
END"where name = "P1";
277+
278+
--error ER_SP_PROC_TABLE_CORRUPT
279+
show create procedure P1;
280+
show warnings;
281+
282+
drop procedure P1;
283+
284+
-- echo # End of 10.4 tests

mysql-test/main/sp-destruct.result

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,49 @@ values
7171
'alksj wpsj sa ^#!@ '
7272
);
7373
select bug14233_1();
74-
ERROR HY000: Failed to load routine test.bug14233_1. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
74+
ERROR HY000: Failed to load routine test.bug14233_1 (internal code -6). For more details, run SHOW WARNINGS
75+
show warnings;
76+
Level Code Message
77+
Warning 1601 Creation context of stored routine `test`.`bug14233_1` is invalid
78+
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
79+
Error 1457 Failed to load routine test.bug14233_1 (internal code -6). For more details, run SHOW WARNINGS
7580
create view v1 as select bug14233_1();
76-
ERROR HY000: Failed to load routine test.bug14233_1. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
81+
ERROR HY000: Failed to load routine test.bug14233_1 (internal code -6). For more details, run SHOW WARNINGS
82+
show warnings;
83+
Level Code Message
84+
Warning 1601 Creation context of stored routine `test`.`bug14233_1` is invalid
85+
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
86+
Error 1457 Failed to load routine test.bug14233_1 (internal code -6). For more details, run SHOW WARNINGS
7787
select bug14233_2();
78-
ERROR HY000: Failed to load routine test.bug14233_2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
88+
ERROR HY000: Failed to load routine test.bug14233_2 (internal code -6). For more details, run SHOW WARNINGS
89+
show warnings;
90+
Level Code Message
91+
Warning 1601 Creation context of stored routine `test`.`bug14233_2` is invalid
92+
Error 1320 No RETURN found in FUNCTION test.bug14233_2
93+
Error 1457 Failed to load routine test.bug14233_2 (internal code -6). For more details, run SHOW WARNINGS
7994
create view v1 as select bug14233_2();
80-
ERROR HY000: Failed to load routine test.bug14233_2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
95+
ERROR HY000: Failed to load routine test.bug14233_2 (internal code -6). For more details, run SHOW WARNINGS
96+
show warnings;
97+
Level Code Message
98+
Warning 1601 Creation context of stored routine `test`.`bug14233_2` is invalid
99+
Error 1320 No RETURN found in FUNCTION test.bug14233_2
100+
Error 1457 Failed to load routine test.bug14233_2 (internal code -6). For more details, run SHOW WARNINGS
81101
call bug14233_3();
82-
ERROR HY000: Failed to load routine test.bug14233_3. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
102+
ERROR HY000: Failed to load routine test.bug14233_3 (internal code -6). For more details, run SHOW WARNINGS
103+
show warnings;
104+
Level Code Message
105+
Warning 1601 Creation context of stored routine `test`.`bug14233_3` is invalid
106+
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
107+
Error 1457 Failed to load routine test.bug14233_3 (internal code -6). For more details, run SHOW WARNINGS
83108
drop trigger t1_ai;
84109
create trigger t1_ai after insert on t1 for each row call bug14233_3();
85110
insert into t1 values (0);
86-
ERROR HY000: Failed to load routine test.bug14233_3. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
111+
ERROR HY000: Failed to load routine test.bug14233_3 (internal code -6). For more details, run SHOW WARNINGS
112+
show warnings;
113+
Level Code Message
114+
Warning 1601 Creation context of stored routine `test`.`bug14233_3` is invalid
115+
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
116+
Error 1457 Failed to load routine test.bug14233_3 (internal code -6). For more details, run SHOW WARNINGS
87117
drop trigger t1_ai;
88118
drop table t1;
89119
drop function bug14233_1;

mysql-test/main/sp-destruct.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,26 @@ values
128128

129129
--error ER_SP_PROC_TABLE_CORRUPT
130130
select bug14233_1();
131+
show warnings;
131132
--error ER_SP_PROC_TABLE_CORRUPT
132133
create view v1 as select bug14233_1();
134+
show warnings;
133135

134136
--error ER_SP_PROC_TABLE_CORRUPT
135137
select bug14233_2();
138+
show warnings;
136139
--error ER_SP_PROC_TABLE_CORRUPT
137140
create view v1 as select bug14233_2();
141+
show warnings;
138142

139143
--error ER_SP_PROC_TABLE_CORRUPT
140144
call bug14233_3();
145+
show warnings;
141146
drop trigger t1_ai;
142147
create trigger t1_ai after insert on t1 for each row call bug14233_3();
143148
--error ER_SP_PROC_TABLE_CORRUPT
144149
insert into t1 values (0);
150+
show warnings;
145151

146152
# Clean-up
147153
drop trigger t1_ai;

mysql-test/main/sp.result

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5306,8 +5306,12 @@ drop database if exists това_е_дълго_име_за_база_данни_
53065306
create database това_е_дълго_име_за_база_данни_нали|
53075307
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')|
53085308
call това_е_дълго_име_за_база_данни_нали.това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго()|
5309-
ERROR HY000: Failed to load routine това_е_дълго_име_за_база_данни_нали.това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
5309+
ERROR HY000: Failed to load routine това_е_дълго_име_за_база_данни_нали.това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго (internal code -6). For more details, run SHOW WARNINGS
53105310
drop database това_е_дълго_име_за_база_данни_нали|
5311+
show warnings|
5312+
Level Code Message
5313+
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
5314+
Error 1457 Failed to load routine това_е_дълго_име_за_база_данни_нали.това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго (internal code -6). For more details, run SHOW WARNINGS
53115315
CREATE TABLE t3 (
53125316
Member_ID varchar(15) NOT NULL,
53135317
PRIMARY KEY (Member_ID)

mysql-test/main/sp.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6315,7 +6315,7 @@ INSERT INTO mysql.proc VALUES ('това_е_дълго_име_за_база_да
63156315
--error ER_SP_PROC_TABLE_CORRUPT
63166316
call това_е_дълго_име_за_база_данни_нали.това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго()|
63176317
drop database това_е_дълго_име_за_база_данни_нали|
6318-
6318+
show warnings|
63196319

63206320
#
63216321
# BUG#21493: Crash on the second call of a procedure containing

mysql-test/suite/compat/oracle/r/sp-package.result

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,11 @@ RETURN f2();
249249
END;
250250
END;
251251
$$
252-
ERROR HY000: Failed to load routine test.test2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
252+
ERROR HY000: Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS
253+
show warnings;
254+
Level Code Message
255+
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
256+
Error 1457 Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS
253257
DROP PACKAGE test2;
254258
#
255259
# Broken CREATE PACKAGE at a package function call time
@@ -271,11 +275,23 @@ UPDATE mysql.proc SET `body`='garbage'
271275
WHERE db='test' AND name='test2' AND type='PACKAGE';
272276
# sp-cache-invalidate
273277
SELECT test2.f1();
274-
ERROR HY000: Failed to load routine test.test2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
278+
ERROR HY000: Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS
279+
show warnings;
280+
Level Code Message
281+
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
282+
Error 1457 Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS
275283
SELECT test2.f1();
276-
ERROR HY000: Failed to load routine test.test2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
284+
ERROR HY000: Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS
285+
show warnings;
286+
Level Code Message
287+
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
288+
Error 1457 Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS
277289
SELECT test2.f1();
278-
ERROR HY000: Failed to load routine test.test2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
290+
ERROR HY000: Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS
291+
show warnings;
292+
Level Code Message
293+
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
294+
Error 1457 Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS
279295
DROP PACKAGE test2;
280296
#
281297
# Broken CREATE PACKAGE at a package procedure call time
@@ -297,11 +313,23 @@ UPDATE mysql.proc SET `body`='garbage'
297313
WHERE db='test' AND name='test2' AND type='PACKAGE';
298314
# sp-cache-invalidate
299315
CALL test2.p1();
300-
ERROR HY000: Failed to load routine test.test2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
316+
ERROR HY000: Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS
317+
show warnings;
318+
Level Code Message
319+
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
320+
Error 1457 Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS
301321
CALL test2.p1();
302-
ERROR HY000: Failed to load routine test.test2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
322+
ERROR HY000: Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS
323+
show warnings;
324+
Level Code Message
325+
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
326+
Error 1457 Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS
303327
CALL test2.p1();
304-
ERROR HY000: Failed to load routine test.test2. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
328+
ERROR HY000: Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS
329+
show warnings;
330+
Level Code Message
331+
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
332+
Error 1457 Failed to load routine test.test2 (internal code -6). For more details, run SHOW WARNINGS
305333
DROP PACKAGE test2;
306334
#
307335
# Bad routine names

mysql-test/suite/compat/oracle/t/sp-package.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ CREATE PACKAGE BODY test2 AS
335335
END;
336336
$$
337337
DELIMITER ;$$
338+
show warnings;
338339

339340
DROP PACKAGE test2;
340341

@@ -367,10 +368,13 @@ UPDATE mysql.proc SET `body`='garbage'
367368
--source sp-cache-invalidate.inc
368369
--error ER_SP_PROC_TABLE_CORRUPT
369370
SELECT test2.f1();
371+
show warnings;
370372
--error ER_SP_PROC_TABLE_CORRUPT
371373
SELECT test2.f1();
374+
show warnings;
372375
--error ER_SP_PROC_TABLE_CORRUPT
373376
SELECT test2.f1();
377+
show warnings;
374378

375379
DROP PACKAGE test2;
376380

@@ -403,10 +407,13 @@ UPDATE mysql.proc SET `body`='garbage'
403407
--source sp-cache-invalidate.inc
404408
--error ER_SP_PROC_TABLE_CORRUPT
405409
CALL test2.p1();
410+
show warnings;
406411
--error ER_SP_PROC_TABLE_CORRUPT
407412
CALL test2.p1();
413+
show warnings;
408414
--error ER_SP_PROC_TABLE_CORRUPT
409415
CALL test2.p1();
416+
show warnings;
410417

411418
DROP PACKAGE test2;
412419

sql/share/errmsg-utf8.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5722,8 +5722,9 @@ ER_SP_RECURSION_LIMIT
57225722
eng "Recursive limit %d (as set by the max_sp_recursion_depth variable) was exceeded for routine %.192s"
57235723
ger "Rekursionsgrenze %d (durch Variable max_sp_recursion_depth gegeben) wurde für Routine %.192s überschritten"
57245724
ER_SP_PROC_TABLE_CORRUPT
5725-
eng "Failed to load routine %-.192s. The table mysql.proc is missing, corrupt, or contains bad data (internal code %d)"
5726-
ger "Routine %-.192s konnte nicht geladen werden. Die Tabelle mysql.proc fehlt, ist beschädigt, oder enthält fehlerhaften Daten (interner Code: %d)"
5725+
eng "Failed to load routine %-.192s (internal code %d). For more details, run SHOW WARNINGS"
5726+
ger "Fehler beim Laden der Routine %-.192s (interner Code %d). Weitere Informationen finden Sie unter SHOW WARNINGS"
5727+
ukr "Невдала спроба завантажити процедуру %-.192s (внутрішний код %d). Для отримання детальної інформації використовуйте SHOW WARNINGS"
57275728
ER_SP_WRONG_NAME 42000
57285729
eng "Incorrect routine name '%-.192s'"
57295730
ger "Ungültiger Routinenname '%-.192s'"

0 commit comments

Comments
 (0)