Below is the list of changes that have just been committed into a local
5.1 repository of malff. When malff does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2008-05-05 15:07:36-06:00, malff@stripped. +4 -0
Bug#36510 (Stored Procedures: mysql_error_code 0 should be illegal)
This fix is a follow up on Bug 8759.
DECLARE HANDLER can catch exceptions using several syntaxes:
- by SQLSTATE (SQL Standard)
- by error number (MySQL)
Catching succesful completion by error number, aka catching error 0,
is illegal, and is now prevented.
Also, the SQL standard defines the completion condition as a class of
SQLSTATE, so that any state of class '00' and any subclass is a completion
condition. Such completion conditions (for example, '00123') can not be
caught by an exception handler in SQL.
mysql-test/r/sp-error.result@stripped, 2008-05-05 15:07:28-06:00, malff@stripped. +23 -0
Bug#36510 (Stored Procedures: mysql_error_code 0 should be illegal)
mysql-test/t/sp-error.test@stripped, 2008-05-05 15:07:29-06:00, malff@stripped. +36 -0
Bug#36510 (Stored Procedures: mysql_error_code 0 should be illegal)
sql/sp_pcontext.cc@stripped, 2008-05-05 15:07:29-06:00, malff@stripped. +2 -1
Bug#36510 (Stored Procedures: mysql_error_code 0 should be illegal)
sql/sql_yacc.yy@stripped, 2008-05-05 15:07:29-06:00, malff@stripped. +5 -0
Bug#36510 (Stored Procedures: mysql_error_code 0 should be illegal)
diff -Nrup a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
--- a/mysql-test/r/sp-error.result 2008-03-31 19:45:47 -06:00
+++ b/mysql-test/r/sp-error.result 2008-05-05 15:07:28 -06:00
@@ -1650,3 +1650,26 @@ begin
declare continue handler for sqlstate '00000' set @x=0;
end$$
ERROR 42000: Bad SQLSTATE: '00000'
+drop procedure if exists proc_36510;
+create procedure proc_36510()
+begin
+declare should_be_illegal condition for sqlstate '00123';
+declare continue handler for should_be_illegal set @x=0;
+end$$
+ERROR 42000: Bad SQLSTATE: '00123'
+create procedure proc_36510()
+begin
+declare continue handler for sqlstate '00123' set @x=0;
+end$$
+ERROR 42000: Bad SQLSTATE: '00123'
+create procedure proc_36510()
+begin
+declare should_be_illegal condition for 0;
+declare continue handler for should_be_illegal set @x=0;
+end$$
+ERROR HY000: Incorrect CONDITION value: '0'
+create procedure proc_36510()
+begin
+declare continue handler for 0 set @x=0;
+end$$
+ERROR HY000: Incorrect CONDITION value: '0'
diff -Nrup a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
--- a/mysql-test/t/sp-error.test 2008-03-21 12:07:59 -06:00
+++ b/mysql-test/t/sp-error.test 2008-05-05 15:07:29 -06:00
@@ -2411,6 +2411,42 @@ end$$
delimiter ;$$
+#
+# Bug#36510 (Stored Procedures: mysql_error_code 0 should be illegal)
+#
+
+--disable_warnings
+drop procedure if exists proc_36510;
+--enable_warnings
+
+delimiter $$;
+
+--error ER_SP_BAD_SQLSTATE
+create procedure proc_36510()
+begin
+ declare should_be_illegal condition for sqlstate '00123';
+ declare continue handler for should_be_illegal set @x=0;
+end$$
+
+--error ER_SP_BAD_SQLSTATE
+create procedure proc_36510()
+begin
+ declare continue handler for sqlstate '00123' set @x=0;
+end$$
+
+--error ER_WRONG_VALUE
+create procedure proc_36510()
+begin
+ declare should_be_illegal condition for 0;
+ declare continue handler for should_be_illegal set @x=0;
+end$$
+
+--error ER_WRONG_VALUE
+create procedure proc_36510()
+begin
+ declare continue handler for 0 set @x=0;
+end$$
+delimiter ;$$
#
# BUG#NNNN: New bug synopsis
diff -Nrup a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc
--- a/sql/sp_pcontext.cc 2008-03-21 12:07:59 -06:00
+++ b/sql/sp_pcontext.cc 2008-05-05 15:07:29 -06:00
@@ -51,7 +51,8 @@ sp_cond_check(LEX_STRING *sqlstate)
(c < 'A' || 'Z' < c))
return FALSE;
}
- if (strcmp(sqlstate->str, "00000") == 0)
+ /* SQLSTATE class '00' : completion condition */
+ if (strncmp(sqlstate->str, "00", 2) == 0)
return FALSE;
return TRUE;
}
diff -Nrup a/sql/sql_yacc.yy b/sql/sql_yacc.yy
--- a/sql/sql_yacc.yy 2008-04-19 08:07:42 -06:00
+++ b/sql/sql_yacc.yy 2008-05-05 15:07:29 -06:00
@@ -2455,6 +2455,11 @@ sp_hcond_element:
sp_cond:
ulong_num
{ /* mysql errno */
+ if ($1 == 0)
+ {
+ my_error(ER_WRONG_VALUE, MYF(0), "CONDITION", "0");
+ MYSQL_YYABORT;
+ }
$$= (sp_cond_type_t *)YYTHD->alloc(sizeof(sp_cond_type_t));
$$->type= sp_cond_type_t::number;
$$->mysqlerr= $1;
| Thread |
|---|
| • bk commit into 5.1 tree (malff:1.2582) BUG#36510 | marc.alff | 5 May |