Skip to content

PostgreSQL: Support ALTER MATERIALIZED VIEW - #2776

Open
LucaCappelletti94 wants to merge 3 commits into
mainfrom
upstream/alter-materialized-view
Open

LucaCappelletti94 wants to merge 3 commits into
mainfrom
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.84%. Comparing base (45fe354) to head (f6447ab).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2776   +/-   ##
=======================================
  Coverage   82.83%   82.84%           
=======================================
  Files          42       42           
  Lines       35900    35907    +7     
  Branches    35900    35907    +7     
=======================================
+ Hits        29739    29746    +7     
  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.

@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 Outdated
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
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/alter-materialized-view branch from 6bac6ca to 145e5cd Compare October 31, 2026 12:39
Base automatically changed from upstream/postgres-alter-view to main October 31, 2026 13:16
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/alter-materialized-view branch from cf5f8f5 to f6447ab Compare October 31, 2026 13:29
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