235 materialised view recreation did not restore its indexes - #236
Merged
nettrash merged 1 commit intoJul 28, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #235 where indexes defined on materialized views were not captured in dumps and therefore were not restored after a drop+recreate of the materialized view. It extends the dump format to include per-materialized-view index metadata, updates the comparer to recreate or reconcile those indexes appropriately (including production-mode concurrent builds), and adds regression fixtures/tests.
Changes:
- Add
View.indexes: Vec<TableIndex>(excluded fromView::hash) and emit matview indexes on CREATE or via separate production-mode concurrent steps. - Extend dump collection to query and attach indexes for materialized views (including index comments).
- Add regression schemas/docs/tests for matview index recreation and in-place reconciliation; bump version + changelog entry.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| data/test/schema_b.sql | Adds regression schema objects for matview index recreation/reconciliation scenarios. |
| data/test/schema_a.sql | Adds paired FROM-side regression schema objects and detailed scenario commentary. |
| data/test/README.md | Documents the new regression case and expected behaviors (default vs production output). |
| CHANGELOG | Adds v1.0.26 entry describing the fix and compatibility implications for older dumps. |
| app/src/dump/view.rs | Adds matview index support to View (serialization + script emission + index alter planning). |
| app/src/dump/view_tests.rs | Adds unit tests covering matview script emission, hashing behavior, and index alter planning. |
| app/src/dump/core.rs | Fetches and attaches materialized-view indexes during dump generation. |
| app/src/dump/core_tests.rs | Adds query-shape tests for the new matview index query (relkind filter, join keys, extension exclusion). |
| app/src/comparer/core.rs | Emits matview indexes on create; reconciles indexes for unchanged matviews; production-mode splitting support. |
| app/src/comparer/core_tests.rs | Adds end-to-end comparer regression tests for recreate/reconcile and production-mode behavior. |
| app/Cargo.toml | Bumps crate version to 1.0.26. |
| app/Cargo.lock | Updates locked version to 1.0.26. |
Comments suppressed due to low confidence (1)
app/src/comparer/core.rs:4390
- In production mode with
use_drop=false, index redefinitions (drop+create) for unchanged materialized views will still enqueue CREATE INDEX in the post-commit section even though the DROP is commented out. That makes the generated script fail due to the existing index name. Before emitting the plan in the production branch, filterplan.createto remove any CREATE whose index name also appears inplan.dropwhenuse_drop=false(keep pure additions and comment-only changes).
let owner_changed = from_view.owner != to_view.owner;
let plan = from_view.index_alter_plan(to_view);
let has_index_changes = !plan.create.is_empty()
|| !plan.drop.is_empty()
|| !plan.comment_changes.is_empty();
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
nettrash
deleted the
235-materialised-view-recreation-didnt-restore-indexes
branch
July 28, 2026 17:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Closes #235