Bug #73177 Implement something like WHENEVER SQLERROR command in SQL*Plus
Submitted: 2 Jul 2014 17:31 Modified: 9 Jul 2014 12:22
Reporter: Valeriy Kravchuk Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S4 (Feature request)
Version:5.7+ OS:Any
Assigned to: CPU Architecture:Any
Tags: MySQL, SQL*Plus, whenever sqlerror

[2 Jul 2014 17:31] Valeriy Kravchuk
Description:
It seems in mysql command line client one can either stop processing script at error or just ignore errors and continue when --force option is used. Sometimes more flexible behavior is needed for scripts (including those ported from SQL*Plus), and the only partial workaround would be to code stored procedure with error handlers.

The following command (taken from Oracle SQL*Plus) may be useful to have in mysql:

WHENEVER SQLERROR {EXIT [SUCCESS | FAILURE | WARNING | n | @user_variable ] [COMMIT | ROLLBACK] | CONTINUE [COMMIT | ROLLBACK | NONE]}

How to repeat:
Try to create a script for mysql command line client that should continue no matter what happens in one part and then stop immediately on error in another part, or set some useful exit code depending on where error happened. 

Suggested fix:
Please, implement something like this for mysql command line client:

http://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12052.htm

including some way to exit with specific exit code.
[2 Jul 2014 17:56] Pura Vida
For an interactive session like this:

mysql ...
source <SQL file>

there is no way to control whether to continue or abort upon SQL error. This is first level of enhancement or bug report. The next level is to control section of the SQL statements, as requested by previous comment.

Thanks.
[9 Jul 2014 12:22] MySQL Verification Team
Hello Valeriy,

Thank you for the feature request!

Thanks,
Umesh