Repository navigation
Description
Parent Issue
Parent issue: #29433
Detail of Subtask
Phase S3. Depends on: #29437
Remove correctness dependence on stale persisted view columns from query-planning consumers, while preserving existing output-provenance and protocol contracts.
Deliverables:
- Route nested-view boundaries and CTAS metadata/default-policy decisions through the approved derived schema. Audit every view TableDef.Cols consumer rather than changing only visible type reporting.
- Preserve query result metadata, explicit names, null-extension, type/default provenance, ownership, and privileges according to the S1 contract. Do not redefine independent CTAS semantics.
- Audit ordinary plan-cache, PREPARE/EXECUTE, binary prepare/reprepare, and cursor metadata dependencies. Reuse the existing invalidation/rebuild model, but validate all required intermediate-view/base-object identities and versions.
- Treat view ALTER/DROP/recreation, source metadata-only and COPY DDL, subscription remapping, and snapshot references consistently. Do not add a separate durable invalidation system.
Acceptance criteria:
- A source DDL visible to a newly bound statement cannot leave planner/CTAS output using obsolete persisted column metadata.
- Same-view-version with changed transitive base schema invalidates or bypasses reusable derived results; same-name recreated objects cannot pass identity validation.
- Prepared/cached and uncached paths agree under equivalent visibility. Existing cursor metadata follows the approved cursor snapshot contract, not an unrelated latest-schema rule.
- Focused unit tests and public SQL tests cover nested views, expression columns, outer-join nullability, default provenance, explicit column names, and schema changes before plan reuse.
- New consumers do not silently fall back to stale columns when derivation fails; default activation is deferred to rollout.
Describe implementation you've considered
The current bindView path already parses SQL but calls markViewCTASDefaultBoundary(tableDef.Cols). Replace that dependency with authoritative derived metadata, not a second local patch. Inspect checkModify, validateCapturedPrepareSchemas, and CatalogDependencies; preserve unrelated plan-cache semantics and protocol gates.
Additional information
Current anchors: pkg/sql/plan/query_builder.go; pkg/sql/plan/output_column_provenance.go; pkg/frontend/mysql_cmd_executor.go; pkg/frontend/computation_wrapper.go. Existing tests are scenario inventory, not proof the new path has passed.
Planning baseline: b9013dc6bb058ec74935a62ac3a35f57d13c2f98. This issue records future work, not completed implementation or fresh test evidence. All production work is subject to the approved versioned design from S1. Ordinary views only; materialized-view refresh and unrelated SQL compatibility work are out of scope.
Activity
test(view): pin the S4 introspection contract and reconcile the close…