Skip to content

Refuse a PostgreSQL DO block instead of modelling it as though it had not run - #294

Merged
LucaCappelletti94 merged 2 commits into
mainfrom
upstream/do-blocks
Nov 5, 2026
Merged

LucaCappelletti94 merged 2 commits into
mainfrom
upstream/do-blocks

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

Since sqlparser #2618 parses PostgreSQL's DO, a document holding a DO block no longer fails to parse. The statement fell into the catch-all arm of apply_statements, so ParserDB accepted the document and modelled it as if the block had never run. A block that creates a role, or runs CREATE TABLE through EXECUTE, left the model without that role or table and raised no error, and any comparison against a live catalog read the gap as drift.

What a DO block creates usually depends on the database it runs in, through IF NOT EXISTS checks on pg_roles, EXCEPTION WHEN duplicate_object handlers or dynamic EXECUTE. The model cannot know that state, so apply_statements now refuses every DO block with Error::UnsupportedDoBlock, which carries the statement as written. Blocks that only touch data are refused as well, which keeps the rule simple and matches what callers saw before sqlparser parsed DO.

Both lock files move to sqlparser ebb8b04a, the first revision with Statement::Do.

@LucaCappelletti94 LucaCappelletti94 added the bug Something isn't working label Nov 5, 2026
@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@LucaCappelletti94
LucaCappelletti94 merged commit 6b8fbf3 into main Nov 5, 2026
20 of 21 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant