MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Konstantin Osipov Date:July 13 2007 9:48pm
Subject:Re: bk commit into 5.0 tree (evgen:1.2500) BUG#24989
View as plain text  
* eugene@stripped <eugene@stripped> [07/07/13 02:22]:
>  bool
> -sp_rcontext::find_handler(uint sql_errno,
> +sp_rcontext::find_handler(THD *thd, uint sql_errno,
>                            MYSQL_ERROR::enum_warning_level level)
>  {
>    if (m_hfound >= 0)
>      return 1;			// Already got one
> +  /* Don't allow fatal sub statement errors to be caught in a sub statement */
> +  if (thd->is_fatal_sub_stmt_error && thd->in_sub_stmt)
> +    return FALSE;

Hello,

Please consider the following test case:

mysql> drop table if exists t1|
Query OK, 0 rows affected (0.00 sec)

mysql> drop procedure if exists p1|
Query OK, 0 rows affected (0.00 sec)

mysql> drop function if exists f1|
Query OK, 0 rows affected (0.01 sec)

mysql> create table t1 (a int unique)|
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 (a) values (1)|
Query OK, 1 row affected (0.00 sec)

mysql> 
mysql> create procedure p1()
    ->     deterministic
    -> begin
    ->   declare continue handler for sqlexception
    ->     select 'Outer handler' as 'exception';
    -> 
    ->   select f1();
    ->   select "continued";
    -> end|
Query OK, 0 rows affected (0.00 sec)

mysql> 
mysql> 
mysql> create function f1() returns varchar(255)
    -> begin
    ->   insert into t1 values (1);
    ->   return "continued in the function";
    -> end|
Query OK, 0 rows affected (0.00 sec)

mysql> call p1|
Empty set (0.00 sec)

+---------------+
| exception     |
+---------------+
| Outer handler | 
+---------------+
1 row in set (0.00 sec)

+-----------+
| continued |
+-----------+
| continued | 
+-----------+
1 row in set (0.00 sec)

As you can see, a handler is found in the outer scope and the code
flow continues from the first statement in the outer scope that
follows the failing sub-statement.
Your code should behave the same -- it should effectively disable
all CONTINUE/EXIT handlers of sub-statements and unwind the stack
till the first top-level statement.

The sequence of the events should be the following:

- erroneous statement
- error is issued
- a handler is found
- the stack is unwound
- transaction is rolled back
- continue/exit handler is executed

I should look more how to make this happen next week.

-- 
-- Konstantin Osipov              Software Developer, Moscow, Russia
-- MySQL AB, www.mysql.com   The best DATABASE COMPANY in the GALAXY
Thread
bk commit into 5.0 tree (evgen:1.2500) BUG#24989eugene12 Jul
  • Re: bk commit into 5.0 tree (evgen:1.2500) BUG#24989Sergei Golubchik13 Jul
  • Re: bk commit into 5.0 tree (evgen:1.2500) BUG#24989Konstantin Osipov13 Jul