[MDEV-12913] SP stack trace Created: 2017-05-24  Updated: 2017-05-29  Resolved: 2017-05-29

Status: Closed
Project: MariaDB Server
Component/s: Stored routines
Fix Version/s: 10.3.1

Type: Task Priority: Major
Reporter: Vicențiu Ciorbaru Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: contribution

Sub-Tasks:
Key
Summary
Type
Status
Assignee
MDEV-13763 Document SP stack trace at SHOW WARNI... Technical task Closed Ian Gilfillan  
Sprint: 10.3.1-1

 Description   

PR:396 implements stored routine error stack trace.

Example

This script creates two procedures. p2 calls p1, and p1 opens a cursor using a non-existing table:

DELIMITER $$
CREATE OR REPLACE PROCEDURE p1()
BEGIN
  DECLARE c CURSOR FOR SELECT * FROM not_existing;
  OPEN c;
  CLOSE c;
END;
$$
CREATE OR REPLACE PROCEDURE p2()
BEGIN
  CALL p1;
END;
$$
DELIMITER ;
CALL p2;

ERROR 1146 (42S02): Table 'test.not_existing' doesn't exist

The script returns an error, as expected.

Now it's possible to get additional diagnostics:

SHOW WARNINGS;

+-------+------+-----------------------------------------+
| Level | Code | Message                                 |
+-------+------+-----------------------------------------+
| Error | 1146 | Table 'test.not_existing' doesn't exist |
| Note  | 4070 | At line 4 in test.p1                    |
| Note  | 4070 | At line 3 in test.p2                    |
+-------+------+-----------------------------------------+

It displays stack trace, showing where the error actually happened:

  • Line 4 in test.p1 is the OPEN command which actually raised the error
  • Line 3 in test.p2 is the CALL statement, calling p1 from p2.


 Comments   
Comment by Alexander Barkov [ 2017-05-29 ]

Pushed to bb-10.2-compatibility

Generated at Thu Feb 08 08:01:28 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.