[MDEV-23518] Syntax error in ond SP results in misleading message on SHOW CREATE PROCEDURE Created: 2020-08-20  Updated: 2021-04-19  Resolved: 2020-10-05

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.4, 10.5
Fix Version/s: 10.4.16, 10.5.7

Type: Bug Priority: Critical
Reporter: Oleksandr Byelkin Assignee: Oleksandr Byelkin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-21997 Server crashes in LEX::create_item_id... Closed

 Description   

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";
 
show create procedure P1;
 
drop procedure P1;

mysqltest: At line 25: query 'show create procedure P1' failed: 1457: Failed to load routine test.P1. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)



 Comments   
Comment by Oleksandr Byelkin [ 2020-08-20 ]

instead of checking parser error on opening procedure, we shoud check sqlstate "42000".

use mysql_errno_to_sqlstate probably to convert

Comment by Oleksandr Byelkin [ 2020-08-20 ]

the test case is repetable on 10.4 + due to syntax error (probably it is possible to find other errors in earlier versions)

Comment by Oleksandr Byelkin [ 2020-08-20 ]

it is unrelated to real parsing error, so just an error text shoud be changed to show posibility of parsing error of old SP:

Something like "Failed to load routine %-.192s. The table mysql.proc is missing, corrupt, or contains bad data or stored procedure text from old version has an sytax error (internal code %d)"

Comment by Oleksandr Byelkin [ 2020-08-28 ]

ommit 6f211b1f01b51e8d335fe90b227536fdfc034591 (HEAD > bb-10.4MDEV-23518, origin/bb-10.4-MDEV-23518)
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date: Fri Aug 28 16:05:38 2020 +0200

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.

Generated at Thu Feb 08 09:23:00 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.