Issue Details (XML | Word | Printable)

Key: CORE-3410
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Dmitry Yemanov
Reporter: Vladimir Arkhipov
Votes: 2
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Request synchronization error with SUSPEND inside two exceptions handling blocks (specific and common)

Created: 24/Mar/11 01:10 PM   Updated: 15/Nov/13 03:33 PM
Component/s: None
Affects Version/s: 2.1.0, 2.0.4, 2.1.1, 2.0.5, 2.1.2, 2.1.3, 1.5.6, 3.0 Initial, 2.0.6, 2.5.0, 2.1.4, 2.5.1, 3.0 Alpha 1
Fix Version/s: None


 Description  « Hide
The following simple procedure works fine and returns 'Error3'.

create or alter procedure TEST
returns
(
  error_text varchar(1024)
)
as
begin
  in autonomous transaction do
  begin
    exception error 'Error1';

    when exception error do
    begin
      error_text = 'Error2';
      exception;
    end
  end

  when exception error do
  begin
    error_text = 'Error3';
    suspend;
  end
end

But if I add extra handling "when any do" to the end of procedure, then request synchronization error occurs.

create or alter procedure TEST
returns
(
  error_text varchar(1024)
)
as
begin
  in autonomous transaction do
  begin
    exception error 'Error1';

    when exception error do
    begin
      error_text = 'Error2';
      exception;
    end
  end

  when exception error do
  begin
    error_text = 'Error3';
    suspend;
  end

  when any do
  begin
    error_text = 'Error4';
    suspend;
  end
end

May be usage of exception handling in autonomous transaction block is wrong in principle?!
But in some cases it is needed for rollback all autonomous actions and receive information about state from transactional context variables, for example.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Dmitry Yemanov added a comment - 01/Apr/11 01:36 PM
I see the same request sync error even if the IN AUTONOMOUS TRANSACTION line is commented out, so it seems the problem lies elsewhere. Can you confirm that?

Vladimir Arkhipov added a comment - 01/Apr/11 02:20 PM
Yes, I confirm it. When I select from the following procedure, then request synchronization error occurs:

create or alter procedure TEST
returns
(
  ERROR_TEXT varchar(1024)
)
as
begin
  exception error 'Error1';

  when exception error do
  begin
    error_text = 'Error3';
    suspend;
  end

  when any do
  begin
    error_text = 'Error4';
    suspend;
  end
end

See the following example. I only replace first line "exception error ..." to "exception error2 ..." (new exception). No errors!

create or alter procedure TEST
returns
(
  ERROR_TEXT varchar(1024)
)
as
begin
  exception error2 'Error1';

  when exception error do
  begin
    error_text = 'Error3';
    suspend;
  end

  when any do
  begin
    error_text = 'Error4';
    suspend;
  end
end

Dmitry Yemanov added a comment - 01/Apr/11 02:54 PM
With exception "error" both exception handlers work, while in your last example (exception "error2") only the last one (when any) handles the exception. This fact somehow triggers the error.

Vannus added a comment - 13/Jan/13 07:29 PM
Dmitry, I also get the problem when not using IN AUTONOMOUS TRANSACTION.