Skip to content

Preserve SQLite view and trigger dependencies during rebuilds - #220

Merged
jogibear9988 merged 1 commit into
masterfrom
codex/214-sqlite-view-rebuild
Nov 22, 2026
Merged

jogibear9988 merged 1 commit into
masterfrom
codex/214-sqlite-view-rebuild

Conversation

@jogibear9988

@jogibear9988 jogibear9988 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

SQLite reconstruction must preserve executable views and triggers while the original table is briefly absent. Rebuilds now preserve their definitions through copy/rename, replay TEMP triggers with their original target schema, and roll back failures using a savepoint, including within an outer transaction.

Every view and INSERT/UPDATE/DELETE trigger program that prepared before reconstruction must still prepare afterward. EXPLAIN compiles trigger programs without executing their writes or bodies, covering external triggers that depend on the rebuilt table through views, UPDATE OF columns, implicit rowid aliases, and INSTEAD OF triggers on views. Pre-existing invalid programs remain untouched. Literal table names in unrelated triggers no longer cause false dependency matches.

For schema-changing rebuilds, SQLite's compiled table/index b-tree bindings identify the dependent views and trigger programs, including indirect dependencies, covering indexes and attached databases. Only those dependencies are also validated with double-quoted string fallback disabled. This prevents removed quoted columns becoming literals while allowing unrelated legacy views to retain their behavior. The original DQS_DML setting is restored on success and failure. Dependent objects must use single quotes for string literals; Microsoft.Data.Sqlite and System.Data.SQLite expose the required setting, and other drivers must already disable DQS_DML.

Validation: 16 existing preservation cases plus 29 binding/program cases on each SQLite ADO.NET driver. The latter cover direct/transitive/TEMP/attached views and triggers, generated columns, all trigger events, rowid aliases, unrelated literals, valid surviving dependencies, pre-existing invalid triggers, outer rollback and setting restoration. Local combined DTO/feature branches build and pass 927 unit tests and 177 focused SQLite tests. GitHub Actions rechecks all database suites on every updated PR.

The guard/audit exports inherited from #215/#216 also validate SQLite watched columns against queued/renamed definitions or supplied existing-table metadata, and explicitly reject unverified exports.

Stacked on #219, with #222 rebased on this PR. This reconstruction path is specific to SQLite; native rename/drop remains responsible for supported dependency rewrites.

Closes #214.

@jogibear9988 jogibear9988 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reviewed the current head. The actionable findings are inline.

@jogibear9988
jogibear9988 force-pushed the codex/214-sqlite-view-rebuild branch from c2fd8a9 to 10990a5 Compare November 22, 2026 08:39

@jogibear9988 jogibear9988 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Follow-up review of the current head. One actionable finding is inline.

@jogibear9988
jogibear9988 force-pushed the codex/214-sqlite-view-rebuild branch from 10990a5 to 72221b4 Compare November 22, 2026 10:19
@jogibear9988
jogibear9988 force-pushed the codex/214-sqlite-view-rebuild branch from 72221b4 to d7a30d5 Compare November 22, 2026 10:27
@jogibear9988
jogibear9988 force-pushed the codex/214-sqlite-view-rebuild branch from d7a30d5 to 2382e4b Compare November 22, 2026 10:33

@jogibear9988 jogibear9988 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Follow-up review of the current head. New findings are inline.

@jogibear9988
jogibear9988 force-pushed the codex/214-sqlite-view-rebuild branch from 2382e4b to d3b3443 Compare November 22, 2026 11:14
@jogibear9988
jogibear9988 force-pushed the codex/214-sqlite-view-rebuild branch from d3b3443 to e05f6ed Compare November 22, 2026 11:22
@jogibear9988
jogibear9988 force-pushed the codex/214-sqlite-view-rebuild branch from e05f6ed to 9875b30 Compare November 22, 2026 11:30

@jogibear9988 jogibear9988 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

One new SQLite rebuild regression is inline.

@jogibear9988
jogibear9988 force-pushed the codex/214-sqlite-view-rebuild branch from 9875b30 to 62eee9b Compare November 22, 2026 13:44

@jogibear9988 jogibear9988 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

One compatibility regression in the new strict view validation is inline.

@jogibear9988
jogibear9988 force-pushed the codex/214-sqlite-view-rebuild branch from 62eee9b to 78722da Compare November 22, 2026 14:37
@jogibear9988
jogibear9988 force-pushed the codex/214-sqlite-view-rebuild branch 4 times, most recently from ed806aa to cdc27cf Compare November 22, 2026 15:37
@jogibear9988
jogibear9988 force-pushed the codex/214-sqlite-view-rebuild branch from cdc27cf to 39a94af Compare November 22, 2026 15:37
Base automatically changed from codex/213-projected-data-migrations to master November 22, 2026 15:37
@jogibear9988
jogibear9988 force-pushed the codex/214-sqlite-view-rebuild branch from 39a94af to 51decce Compare November 22, 2026 15:37
@jogibear9988
jogibear9988 merged commit 2c02fe0 into master Nov 22, 2026
13 checks passed
@jogibear9988
jogibear9988 deleted the codex/214-sqlite-view-rebuild branch November 22, 2026 15:43
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.

SQLite table rebuild fails when a view references the table

1 participant