Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception handling with EXECUTE STATEMENT [CORE2907] #3291

Closed
firebird-automations opened this issue Mar 4, 2010 · 12 comments
Closed

Exception handling with EXECUTE STATEMENT [CORE2907] #3291

firebird-automations opened this issue Mar 4, 2010 · 12 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Van den Wouwer Danny (dannyvdw)

Is related to QA432

Unable to catch exceptions that are thrown inside a dynamic builded execute block.

Example:

SET NAMES WIN1252;

SET CLIENTLIB 'fbclient.dll';

CREATE DATABASE 'LOCALHOST/3050:C:\TESTDB.FDB'
USER 'SYSDBA'
PASSWORD 'masterkey'
PAGE_SIZE 16384
DEFAULT CHARACTER SET WIN1252;

CREATE OR ALTER EXCEPTION EX_TEST 'test';

SET TERM ^ ;
CREATE OR ALTER procedure sp_1
as
declare variable v_stmt varchar(256);
begin

v_stmt = 'execute block as '||
'begin '||
' exception ex_test; '||
'end';
execute statement v_stmt;

end
^
SET TERM ; ^

SET TERM ^ ;
CREATE OR ALTER procedure sp_2
as
begin
begin
execute procedure sp_1;

when exception ex\_test do
begin
  exit;
end

end
end
^
SET TERM ; ^

SET TERM ^ ;
CREATE OR ALTER procedure sp_3
as
begin
begin
execute procedure sp_1;
when any do
begin
exit;
end
end
end
^
SET TERM ; ^

EXECUTE PROCEDURE SP_2;
EXECUTE PROCEDURE SP_3;

COMMIT WORK;

When executing sp_2 we never reach the exception handling block, if we use the "any" keyword like in sp_3 then we can catch the exception.

We tested this on Classic Windows 32-bit version and it works like it should on v2.1.3.

Danny

Commits: fcbd948 2d74ff8

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

assignee: Vlad Khorsun [ hvlad ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

New implementation of EXECUTE STATEMENT works with exceptions in following way - when any operation (connect, start transaction, prepare, execute, fetch, etc) raised exception this exception is converted into text form and primary error code of final exception is one of the new isc_eds_XXX constants.

Text with details about original exception (error codes and associated messages) also present in the status-vector as one of arguments of primary isc_eds_XXX error.

This is necessary as client applicatin can't interpret error codes supplied by (unknown for app) external data source.

I see possibility to pass original error to the application without interception if dynamic statement was executed in current execution context.
This will preserve backward compatibility.

@firebird-automations
Copy link
Collaborator Author

Commented by: Van den Wouwer Danny (dannyvdw)

So, You will change this behaviour before final 2.5?

Otherwise we can't accuratly check which exception was thrown inside a stored procedure.

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

Yes, i going change it before RC3

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

More exact ticket description

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

summary: Exception handling => Exception handling with EXECUTE STATEMENT

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

Changes documented at doc/sql.extensions/README.execute_statement2

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.5 RC3 [ 10381 ]

Fix Version: 3.0 Alpha 1 [ 10331 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: Van den Wouwer Danny (dannyvdw)

Tested it with snapshot build 25980, it works.

thx

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue is related to QA432 [ QA432 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pmakowski

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Closed [ 6 ] => Closed [ 6 ]

QA Status: Done successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment