Skip to content

PostgreSQL: Support ALTER MATERIALIZED VIEW - #2776

Open
LucaCappelletti94 wants to merge 2 commits into
upstream/postgres-alter-viewfrom
upstream/alter-materialized-view
Open

LucaCappelletti94 wants to merge 2 commits into
upstream/postgres-alter-viewfrom
upstream/alter-materialized-view

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

ALTER MATERIALIZED VIEW did not parse. After ALTER the parser expected an object keyword and stopped at MATERIALIZED, so a PostgreSQL schema that hands a materialized view to its owner, renames it or sets a storage parameter on it could not be read.

The statement reuses the AlterView node from #2730 with a materialized flag, since the two share their operations. OWNER TO, RENAME TO, RENAME COLUMN, SET SCHEMA, SET (...) and RESET (...) parse and round-trip through Display, and AS and ALTER COLUMN stay refused after MATERIALIZED.

@LucaCappelletti94 LucaCappelletti94 added enhancement New feature or request PostgreSQL labels Oct 30, 2026
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/alter-materialized-view branch from 4f339b0 to e241480 Compare October 30, 2026 09:32
@codecov-commenter

codecov-commenter commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.81%. Comparing base (acdcf55) to head (6bac6ca).

Additional details and impacted files
@@                      Coverage Diff                      @@
##           upstream/postgres-alter-view    #2776   +/-   ##
=============================================================
  Coverage                         82.80%   82.81%           
=============================================================
  Files                                42       42           
  Lines                             35848    35859   +11     
  Branches                          35848    35859   +11     
=============================================================
+ Hits                              29685    29696   +11     
  Misses                             2653     2653           
  Partials                           3510     3510           

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

@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/alter-materialized-view branch from e241480 to 39b7beb Compare October 30, 2026 10:56
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/alter-materialized-view branch from 39b7beb to e6a8210 Compare October 30, 2026 15:05
Comment thread src/parser/mod.rs
old_column_name,
new_column_name: self.parse_identifier()?,
}
} else if materialized {

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.

PG 16 does accept ALTER MATERIALIZED VIEW m ALTER COLUMN c SET STATISTICS 100 / SET (n_distinct = 10) / SET STORAGE PLAIN; only SET/DROP DEFAULT is refused. This branch will have to be undone once AlterColumn grows those variants, so it may be simpler to drop it now and let AS/default-related forms fall through as they do for plain views.

@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/alter-materialized-view branch 2 times, most recently from 62b3fcd to 3b652c6 Compare October 30, 2026 18:11
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/alter-materialized-view branch from 3b652c6 to 0d725d4 Compare October 30, 2026 22:29
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/alter-materialized-view branch from 0d725d4 to c81c8ac Compare October 31, 2026 07:55
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/alter-materialized-view branch from c81c8ac to d10da44 Compare October 31, 2026 08:32
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/alter-materialized-view branch from d10da44 to 888f8c1 Compare October 31, 2026 08:46
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/alter-materialized-view branch from 888f8c1 to 6bac6ca Compare October 31, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PostgreSQL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants