-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
122321: plpgsql: fix exception handling for nested blocks r=DrewKimball a=DrewKimball #### plpgsql: prevent inlining for block-exit continuation This commit prevents inlining for the continuation that transitions out of a PL/pgSQL block with an exception handler. This is necessary to ensure that the statements following the nested block are considered part of the parent block, not the nested block. Otherwise, an error thrown after the nested block might still be caught by the nested block's exception handler, which is incorrect behavior. #### plpgsql: keep track of the subroutine that begins a PL/pgSQL block This commit adds logic to keep track of the PL/pgSQL sub-routine that logically transitions into a PL/pgSQL block with an exception handler. This is necessary to ensure that the state shared between sub-routines within the same block is correctly initialized. Previously, the block state was only initialized once, but this is incorrect for loops, which need to re-initialize the state on each iteration. #### plpgsql: roll back all cursors within a block that handles an exception This commit fixes handling for cursors opened within the scope of a block with an exception handler that has nested blocks or nested routine calls. Previously, if a PL/pgSQL block caught an exception, only the cursors opened directly by that block would be rolled back. Any cursors opened by a nested block or routine call would remain open. Now, the block state tracks the timestamp when the block's execution began. Once an exception is caught, all cursors with a timestamp later than the block's start are rolled back. Fixes #122278 Fixes #121078 Release note: None Co-authored-by: Drew Kimball <[email protected]>
- Loading branch information
Showing
10 changed files
with
270 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.