Skip to content

PostgreSQL: Parse namespaced options in ALTER VIEW SET and RESET - #2785

Open
LucaCappelletti94 wants to merge 2 commits into
mainfrom
upstream/alter-view-namespaced-options
Open

LucaCappelletti94 wants to merge 2 commits into
mainfrom
upstream/alter-view-namespaced-options

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

ALTER VIEW v SET (toast.autovacuum_enabled = false) and ALTER VIEW v RESET (toast.autovacuum_enabled) fail with Expected: ), found: ., while the same option already parses in CREATE VIEW v WITH (...) and in ALTER TABLE t SET (...) and RESET (...).

TLDR of the PR: Ident becomes ObjectName, plus appropriate tests.

@LucaCappelletti94 LucaCappelletti94 added enhancement New feature or request api change fuzzer A bug found by the fuzzer PostgreSQL labels Oct 31, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.83%. Comparing base (45fe354) to head (c535549).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2785   +/-   ##
=======================================
  Coverage   82.83%   82.83%           
=======================================
  Files          42       42           
  Lines       35900    35901    +1     
  Branches    35900    35901    +1     
=======================================
+ Hits        29739    29740    +1     
  Misses       2654     2654           
  Partials     3507     3507           

☔ 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.

@slopgobblercobbler slopgobblercobbler left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Audited the namespaced view option parsing in src/ast/ddl.rs and src/parser/mod.rs:

  • AST alignment and parity:
    • Transitioning AlterViewOperation::ResetOptions.options from Vec<Ident> to Vec<ObjectName> resolves a long-standing AST inconsistency with AlterTableOperation::ResetOptions, which already models storage parameters via Vec<ObjectName>.
    • Single-part options (security_invoker) and multi-part options (toast.autovacuum_enabled) are now unified under ObjectName.
  • Parsing logic and lookahead:
    • In parse_alter_view:
      • SET uses parse_period_separated to construct ObjectName keys, properly handling both key-value pairs (toast.autovacuum_vacuum_threshold = 50) and standalone flags (toast.vacuum_truncate).
      • RESET parses comma-separated object names via p.parse_object_name(false).
    • Negative syntax checks correctly catch trailing period tokens (SET (toast. = 1) and RESET (toast.)), rejecting with clean expected-identifier diagnostics.
  • Span derivation and Display roundtrip:
    • Updated Spanned implementation in src/ast/spans.rs to call i.span() on ObjectName, maintaining accurate source spans.
    • Roundtrip formatting through display_comma_separated(options) cleanly emits period-separated names.
  • Test and fuzz coverage:
    • Unit tests in sqlparser_common.rs verify roundtrip equivalence and AST structure across both SET and RESET variants.
    • Addition of fuzz/fuzz_seeds/postgres_2785_alter_view_namespaced_options.sql ensures fuzzer coverage.

Solid cleanup that aligns view options with table options and supports standard PostgreSQL toast parameters.

@LucaCappelletti94

Copy link
Copy Markdown
Contributor Author

@slopgobblercobbler don't post generated summaries on this pull request, issues or other interactions with humans in the Apache org. A review is welcome when it points at a concrete problem or asks a question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api change enhancement New feature or request fuzzer A bug found by the fuzzer PostgreSQL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants