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

Broken exception handling with BEGIN END. [CORE1956] #2394

Closed
firebird-automations opened this issue Jun 23, 2008 · 6 comments
Closed

Broken exception handling with BEGIN END. [CORE1956] #2394

firebird-automations opened this issue Jun 23, 2008 · 6 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: prenosil (prenosil)

Is related to CORE1953

Exception raised inside simple BEGIN END block caught by WHEN handler does not undo previous actions.
Example script:

CREATE EXCEPTION EX 'Test';
CREATE TABLE TEST(A INTEGER);
INSERT INTO TEST(A) VALUES(1000);
COMMIT;

SELECT * FROM TEST;
A

   1000

EXECUTE BLOCK AS
DECLARE VARIABLE I INTEGER;
BEGIN
UPDATE TEST SET A=A+10;
I = ''; .... this will cause conversion error
WHEN ANY DO BEGIN END
END;

SELECT * FROM TEST;
A

   1000    \.\.\. and the Update is correctly undone

Now simply add BEGIN END around command causing exception:

EXECUTE BLOCK AS
DECLARE VARIABLE I INTEGER;
BEGIN
UPDATE TEST SET A=A+10;
BEGIN I = ''; END
WHEN ANY DO BEGIN END
END;

SELECT * FROM TEST;
A

   1010    \.\.\. and the Update is not undone
@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Ivan, it's actually the same thing as your prior ticket refers to. Upon exception (of any kind), the current savepoint is undone and the execution is passed to a WHEN handler. BEGIN/END block creates a savepoint around the assignment operator. An EXCEPTION statement is encapsulated within its own savepoint. Try two subsequent updates with an error in the second one and you'll see that only the second one will be undone, because every UPDATE is encapsulated within a savepoint as well.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Link: This issue is related to CORE1953 [ CORE1953 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

assignee: Dmitry Yemanov [ dimitr ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

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

resolution: Duplicate [ 3 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

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

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

QA Status: No test

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

No branches or pull requests

2 participants