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
plpgsql: allow nested blocks in a block with an exception handler #120045
Conversation
The first two commits are #120043. |
6db366d
to
fe06932
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r3, 5 of 5 files at r4, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @mgartner)
There was some leftover logic for building the branches of a routine's exception handler after some refactoring in cockroachdb#110998. This didn't affect correctness, but added unnecessary overhead. This commit removes the extra work. Epic: None Release note: None
This commit removes the restriction on nesting PL/pgSQL blocks within a block that has an exception handler. This is accomplished by tracking the number of variables that are in scope for each block, and using that information to determine which arguments to supply to the exception handler for a block. This relies on the invariant that the variables of a parent block always form a prefix of the variables of a child block. Fixes cockroachdb#118551 Release note (sql change): PL/pgSQL blocks can now be nested in a block that has an exception handler.
fe06932
to
dc19dfc
Compare
The tests exposed a bug - subsequent branches of an exception handler were considered even if an earlier branch matched and returned its own exception. I fixed that by breaking out of the exception branch-checking loop before attempting to handle the error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 14 of 14 files at r5, 14 of 14 files at r6, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @mgartner)
TFTR! bors r+ |
Build succeeded: |
execbuilder,plpgsql: don't build redundant exception handler
There was some leftover logic for building the branches of a routine's
exception handler after some refactoring in #110998. This didn't affect
correctness, but added unnecessary overhead. This commit removes the
extra work.
plpgsql: allow nested blocks in a block with an exception handler
This commit removes the restriction on nesting PL/pgSQL blocks within
a block that has an exception handler. This is accomplished by tracking
the number of variables that are in scope for each block, and using that
information to determine which arguments to supply to the exception
handler for a block. This relies on the invariant that the variables of
a parent block always form a prefix of the variables of a child block.
Fixes #118551
Release note (sql change): PL/pgSQL blocks can now be nested in a block
that has an exception handler.