Skip to content

Support DML through simple updatable SQL views#4279

Draft
arnaud-lacurie wants to merge 2 commits into
FoundationDB:mainfrom
arnaud-lacurie:view-dml
Draft

Support DML through simple updatable SQL views#4279
arnaud-lacurie wants to merge 2 commits into
FoundationDB:mainfrom
arnaud-lacurie:view-dml

Conversation

@arnaud-lacurie

Copy link
Copy Markdown
Collaborator

Summary

SQL views that are backed by a single base table are now valid targets for INSERT, UPDATE, and DELETE statements.

A view is considered updatable when its definition is a plain single-table SELECT — no joins, no aggregates, no DISTINCT, no partial column projection, and no views-on-views. Any view that does not meet these criteria raises VIEW_NOT_UPDATABLE.

Architecture

At planning time, when the DML visitor encounters a view name as the target of an INSERT/UPDATE/DELETE, it:

  1. Compiles the view's stored definition and inspects the resulting logical plan to decide whether it is updatable (ViewUpdatabilityAnalyzer).
  2. Rewrites the statement to target the view's base table directly.
  3. For UPDATE and DELETE, automatically injects the view's own WHERE predicate alongside any user-supplied predicate, so that the view's filtering semantics are preserved. A predicate alias translation step is required because the view's predicates were compiled against the view's own quantifier, not the DML's freshly-created base-table access.
  4. For INSERT, the row is written to the base table as-is. WITH CHECK OPTION is not yet supported.

@arnaud-lacurie arnaud-lacurie added the enhancement New feature or request label Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant