[MDEV-19106] [Feature] Issue#61 new built-in function to let customer manually issue an error Created: 2019-03-31  Updated: 2019-04-01  Resolved: 2019-04-01

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Fix Version/s: N/A

Type: Task Priority: Major
Reporter: Anel Husakovic Assignee: Sergei Golubchik
Resolution: Won't Do Votes: 0
Labels: None

Epic Link: AliSQL patches

 Description   

A new built-in function RAISE_ERROR('diagnostic-string') is needed to
let mysql users fail current statement with the desired
diagnostic-string error message and reserved sql error code.
 
DB2 does in its' RAISE_ERROR() function, where the function accepts
parameters of sql state and msg, and Oracle's RAISE_APPLICATION_ERROR
has similar function.
 
In our implementation, raise_error() accepts parameter of msg and
optional sql state, both are strings. NULL value input is not allowed
for either one, and only validate sql state is allowed.
 
Here are samples:
 
--error ER_SP_BAD_SQLSTATE
 
select raise_error(NULL, 'null sql state not allowed');
 
--error ER_MALFORMED_MESSAGE select raise_error('70001', NULL);
 
--error ER_SP_BAD_SQLSTATE
 
select raise_error('00001', 'invalid sql state');
 
--error ER_SP_BAD_SQLSTATE
 
select raise_error('666666', 'length of sql state exceeds 5');
 
--error ER_INTENTIONAL_ERROR
 
select raise_error('70001', 'this is a sample error msg');
 
--error ER_INTENTIONAL_ERROR
 
select raise_error('this is a sample error msg');
 
--error ER_INTENTIONAL_ERROR
select raise_error('only error message applied');

https://github.com/alibaba/AliSQL/commit/66c68db51483d6c719e13ab6a5dfdcb04ae22333



 Comments   
Comment by Sergei Golubchik [ 2019-04-01 ]

there's standard sql SIGNAL statement. It can be wrapped into a stored function, if needed.

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