Repository navigation
PostgreSQL: Add support for DO statement - #2618
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DOblocks likeDO $$BEGIN RAISE NOTICE 'hi'; END$$currently fail with "Expected: an SQL statement, found: DO".This adds
Statement::Do(DoStatement)for PostgreSQL'sDOstatement, gated behind a newDialect::supports_do_statement()that is enabled for PostgreSQL.DoStatementkeeps the items ofdostmt_opt_listin source order as aVec<DoOption>, so every accepted form prints back as written. An item is a code block orLANGUAGEfollowed by an identifier or a string literal, and the missing code and duplicate checks are left to the server, matching PostgreSQL's grammar.Code blocks may be single-quoted, dollar-quoted,
E''orU&''.LANGUAGE N'...'is read as the languagencharand a code block, because PostgreSQL's scanner splits it that way.Tests in
tests/sqlparser_common.rsandtests/sqlparser_postgres.rscover the accepted forms, the round trip, the error cases and dialects without support. Five seeds underfuzz/fuzz_seeds/cover the same syntax for the fuzzer.The implementation and tests were drafted with an AI coding assistant (Grok 4.7 effort: xHigh), and I reviewed the diff, ran the test suite and the fuzzer, and stand by the change.
Fixes #2609