Skip to content

235 materialised view recreation did not restore its indexes - #236

Merged
nettrash merged 1 commit into
v1.0.26from
235-materialised-view-recreation-didnt-restore-indexes
Jul 28, 2026
Merged

235 materialised view recreation did not restore its indexes#236
nettrash merged 1 commit into
v1.0.26from
235-materialised-view-recreation-didnt-restore-indexes

Conversation

@nettrash

Copy link
Copy Markdown
Owner

Closes #235

@nettrash nettrash added this to the v1.0.26 milestone Jul 28, 2026
@nettrash nettrash self-assigned this Jul 28, 2026
Copilot AI review requested due to automatic review settings July 28, 2026 16:56

Copilot AI left a comment

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.

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 from View::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, filter plan.create to remove any CREATE whose index name also appears in plan.drop when use_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.

Comment thread app/src/comparer/core.rs
@nettrash
nettrash merged commit 2f1ec9a into v1.0.26 Jul 28, 2026
17 checks passed
@nettrash
nettrash deleted the 235-materialised-view-recreation-didnt-restore-indexes branch July 28, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants