-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: correctly handle parsing errors #112200
Conversation
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.
Nice work! Only one very minor test suggestion.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @DrewKimball and @mgartner)
pkg/sql/plpgsql/parser/testdata/stmt_assign
line 68 at r3 (raw file):
DECLARE BEGIN a := 1, (2, 3, 4, 5);
nit: have one of these tests return 3+ columns.
00ffa21
to
10baf35
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.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @mgartner)
pkg/sql/plpgsql/parser/testdata/stmt_assign
line 68 at r3 (raw file):
Previously, rharding6373 (Rachael Harding) wrote…
nit: have one of these tests return 3+ columns.
Done.
TFTR! |
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 2 of 3 files at r1, 7 of 7 files at r4, 2 of 2 files at r5, 7 of 7 files at r6, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @DrewKimball)
This patch ensures that PLpgSQL parsing errors are correctly propagated in all cases. Previously, there were a few cases (like variable declaration type parsing) where an error didn't halt parsing. The contract for `GetTypeFromValidSQLSyntax` is also clarified, since it is ok to call with an invalid type name as long as the error is properly handled. Informs cockroachdb#105254 Release note: None
Previously, the PLpgSQL parser could panic when the user supplied more than one expression in a location where only one was expected, for example, in a return statement. This was because the PLpgSQL parser delegated to the SQL parser's `ParseExpr` function, which expects exactly one input expression. This commit returns a syntax error instead of the panic by switching to use `ParseExprs`, which can handle multiple input expressions. Informs cockroachdb#109342 Release note: None
…ression This patch fixes error messages in the PLpgSQL parser for the case when the parenthesis nesting is invalid, and for the case when no expression (or statement) is supplied. Previously, invalid parentheses would cause a panic without an error code, and a missing expression had the incorrect message, since it wasn't checked until the SQL parser attempted to read an empty string. Now, both cases are checked immediately by the PLpgSQL parser and the correct error is propagated. Fixes cockroachdb#109342 Release note: None
10baf35
to
6e331e6
Compare
bors r+ |
Build succeeded: |
plpgsql: correctly handle parsing errors
This patch ensures that PLpgSQL parsing errors are correctly propagated
in all cases. Previously, there were a few cases (like variable declaration
type parsing) where an error didn't halt parsing. The contract for
GetTypeFromValidSQLSyntax
is also clarified, since it is ok to call withan invalid type name as long as the error is properly handled.
Informs #105254
Release note: None
plpgsql: handle multiple expressions when one expression is expected
Previously, the PLpgSQL parser could panic when the user supplied more
than one expression in a location where only one was expected, for example,
in a return statement. This was because the PLpgSQL parser delegated to
the SQL parser's
ParseExpr
function, which expects exactly one inputexpression. This commit returns a syntax error instead of the panic by
switching to use
ParseExprs
, which can handle multiple input expressions.Informs #109342
Release note: None
plpgsql: return correct error for invalid parantheses and missing expression
This patch fixes error messages in the PLpgSQL parser for the case when
the parenthesis nesting is invalid, and for the case when no expression
(or statement) is supplied. Previously, invalid parentheses would cause
a panic without an error code, and a missing expression had the incorrect
message, since it wasn't checked until the SQL parser attempted to read
an empty string. Now, both cases are checked immediately by the PLpgSQL
parser and the correct error is propagated.
Fixes #109342
Release note: None