Skip to content

PostgreSQL: Support ALTER MATERIALIZED VIEW - #2776

Merged
LucaCappelletti94 merged 4 commits into
mainfrom
upstream/alter-materialized-view
Nov 2, 2026
Merged

LucaCappelletti94 merged 4 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 83.02%. Comparing base (327d54b) to head (a39c563).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2776   +/-   ##
=======================================
  Coverage   83.02%   83.02%           
=======================================
  Files          42       42           
  Lines       36220    36227    +7     
  Branches    36220    36227    +7     
=======================================
+ Hits        30070    30077    +7     
  Misses       2652     2652           
  Partials     3498     3498           

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed, and added the adequate tests.

@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
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/alter-materialized-view branch from f6447ab to 11c3bf3 Compare November 1, 2026 14:46
@alamb
alamb added this pull request to the merge queue Nov 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 2, 2026
@LucaCappelletti94
LucaCappelletti94 added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit 9976fd0 Nov 2, 2026
10 checks passed
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.

4 participants