Skip to content

Error on a trailing END instead of dropping the rest of the input - #2838

Merged
LucaCappelletti94 merged 1 commit into
mainfrom
pg-end-alias-truncation
Nov 7, 2026
Merged

LucaCappelletti94 merged 1 commit into
mainfrom
pg-end-alias-truncation

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

Parser::parse_statements stopped at a bare END wherever it expected a statement delimiter and returned without an error, so everything after it was silently dropped. In most dialects, PostgreSQL included, SELECT 1 END; DROP TABLE users came back as a single SELECT 1. PostgreSQL accepts SELECT 1 END with END as a column alias and runs both statements, so a (pretty daft) tool checking the parsed statements never sees the DROP.

The arm dates from when CREATE PROCEDURE bodies were parsed through a nested parse_statements call. Every BEGIN ... END body is now parsed by parse_statement_list or parse_conditional_statements, which consume their own END, so the arm only fired on top-level input. I removed it, and such input now fails with Expected: end of statement, found: END.

Accepting END as a bare alias in PostgreSQL is #2491, which I will re-review now.

@LucaCappelletti94 LucaCappelletti94 added bug Something isn't working fuzzer A bug found by the fuzzer labels Nov 7, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.16%. Comparing base (65972d7) to head (fa4912e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2838   +/-   ##
=======================================
  Coverage   83.16%   83.16%           
=======================================
  Files          42       42           
  Lines       36420    36417    -3     
  Branches    36420    36417    -3     
=======================================
- Hits        30287    30286    -1     
+ Misses       2636     2635    -1     
+ Partials     3497     3496    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@s5dsn-eqee s5dsn-eqee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@LucaCappelletti94

Copy link
Copy Markdown
Contributor Author

Thank you for the PR @s5dsn-eqee, I will be merging it now.

cc @alamb

@LucaCappelletti94
LucaCappelletti94 added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit bf99997 Nov 7, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fuzzer A bug found by the fuzzer PostgreSQL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants