Repository navigation
fix(plan): reject explicit writes to hidden storage columns - #31321
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 7a3ed3c896aa697d9d145bc7cb3141127d55c3c3
Assessment: request_changes
The hidden-column boundary is sound and functional validation passes. One measured performance regression remains in legacy LOAD binding. Both frozen discussion items are informational; their dispositions are saved.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1
- P2
pkg/sql/plan/build_load.go:89: LOAD supplies an explicit column list for a wide table routed through the legacy planner, such as a self-referencing foreign-key table with foreign-key checks enabled.
Impact: Calling FindColumn for every target makes binding quadratic in schema width. At the supported 4,096-column limit, the projection helper slowed from a median 1.84 ms to 42.55 ms, approximately 23×. Build a lookup from the filtered Cols once, preserving hidden-column rejection without repeated scans.
Evidence: wide-route.log proves current-head CREATE TABLE and BuildPlan accept the 4,096-column self-FK LOAD and select the legacy route. load-projection-benchmark.log compares the actual current helper with the merge-base helper over three 100-iteration samples; allocation counts are unchanged. Probe sources, input hashes and command/exit receipts are retained and indexed in validation-audit.json.
Validation:
-
Artifacts and receipt reconciliation: /home/xupeng/.local/state/mo-bot/jobs/69f2add6a9444a9c9433d4ee/attempt-1/validation-audit.json. Source remains clean at the frozen head.
-
Focused planner tests: 20 top-level tests passed. Complete pkg/sql/plan passed; go vet and formatting checks passed.
-
The exact SQL fixture passed normal mo-tester comparison twice, 36/36 statements each, on one isolated instance. Separate teardown queries confirmed no residual database after either run.
-
Six regression cases failed as intended with four affected production owners restored to their merge-base versions: hidden targets were accepted without errors.
-
Native prerequisites were rebuilt through make cgo from matching exported inputs. Initial prerequisite and fixture-path setup failures were diagnosed and recovered; neither was counted as a product failure.
-
discussion-assessment.json accounts for both nonempty discussion items exactly once.
Limitations:
-
Performance measurements isolate the binding helper, not end-to-end LOAD throughput.
-
Validation used Linux/amd64 CPU and one-CN SQL execution; no full CI or race-suite pass is claimed.
-
Linked issue bodies were absent from frozen evidence; review used the explicit PR behavioral contract.
7a3ed3c to
70980eb
Compare
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 70980ebd2cf77d42adef0dca362842667949738b
Assessment: approve
Reviewed all 12 changed files and affected callers. Existing binders correctly own hidden-target rejection; the narrow COPY exception preserves engine-owned row identity. The prior quadratic LOAD finding is resolved, independently confirmed by source review and measurements. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1
Validation:
-
Receipts, source fingerprints and logs reconciled in /home/xupeng/.local/state/mo-bot/jobs/482edae31e77724ab608868c/attempt-1/validation-audit.json. Source remains unchanged.
-
23 focused planner tests, the complete planner suite and five affected SQL integration tests passed.
-
The exact 54-statement SQL fixture passed normal mo-tester comparison twice; independent teardown queries found zero residual databases.
-
Formatting, diff checks, go vet and configured incremental static analysis passed. Pinned molint reported five diagnostics in files byte-identical to the merge base.
-
Native reuse verified 194 matching inputs and 57 matching outputs. Initial prerequisite lookup failure was recovered before successful tests.
-
At 4,096 columns, median helper time was 1.696 ms versus 39.659 ms previously and 1.567 ms at merge base. Additional allocation was approximately 218 KB and 17 allocations: an accepted, bounded planning-time cost.
-
discussion-assessment.json accounts for all four discussion items and resolves the prior P2 using current source and execution evidence.
Limitations:
-
Validation used Linux/amd64 and one-CN execution; no independent race-suite, macOS or full CI pass is claimed.
-
Benchmarks isolate binding rather than end-to-end LOAD throughput; narrow-table timing samples are noisy.
-
Linked issue bodies were absent from frozen evidence; review used the explicit PR contract. Historical-row repair and hidden-column reads are outside this change.
70980eb to
7d2e41d
Compare
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 7d2e41dc7f0b45d08d9edbca8bd70194907286b7
Assessment: approve
Reviewed all 14 changed files and affected callers. Existing binders correctly own hidden-target rejection; the narrow ALTER COPY exception preserves engine-owned identity without adding execution-time checks. LOAD SET preserves diagnostic priority and rebind safety. The prior quadratic LOAD finding is resolved. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Commands, source fingerprints, exit receipts and logs reconciled in /home/xupeng/.local/state/mo-bot/jobs/7af35b8e51100a43c2825b66/attempt-1/validation-audit.json. Source remains unchanged.
-
Complete pkg/sql/plan suite passed, including all 13 test functions in the affected test files. Six regression cases failed as expected with the affected production owners restored to their base versions.
-
Exact public SQL fixtures passed normal mo-tester comparison twice each: hidden_write_targets 54/54 and load_data_set_null 49/49. Independent teardown queries found no residual fixture objects.
-
Formatting, diff checks, go vet and incremental static analysis passed. Pinned molint reported five diagnostics in files verified byte-identical to base.
-
Native prerequisites qualified through 200 matching inputs, seven output hashes and the repository-owner build receipt. An initial BVT harness configuration failure was diagnosed and recovered before successful validation.
-
Qualified retained helper measurements resolve the earlier performance concern: at 4096 columns, median binding time was 1.696 ms versus 39.659 ms previously and 1.567 ms at base. Approximately 218 KB and 17 additional allocations are accepted bounded planning costs.
-
discussion-assessment.json accounts for all six discussion entries and independently reconciles both prior reviews.
Limitations:
-
Validation used Linux/amd64 and one-CN execution. Frozen CI remained incomplete; no independent race-suite, macOS or full CI pass is claimed.
-
Performance evidence covers the unchanged binding helper, not end-to-end LOAD throughput; narrow-table timing samples are noisy.
-
Linked issue bodies were absent from frozen evidence; review used the explicit PR contract. Historical-row repair and hidden-column reads remain outside scope.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #31270
Related to #26993
What this PR does / why we need it:
Explicit INSERT, REPLACE, UPDATE and LOAD targets could write hidden storage columns and commit composite keys inconsistent with declared values. Reject those targets in the existing modern and legacy binding paths, including ODKU fallback and LOAD SET, before consuming the statement AST.
Preserve internal ALTER COPY using the existing statement-scoped authority, restricted to the destination's actual fake primary key. This keeps row identities required by cloned indexes and tombstones. LOAD SET first validates the entire expression list using the existing diagnostics, then rejects missing or hidden targets, including consumed assignments; this preserves the previous error priority and retry safety.
Legacy LOAD lookups use the actual filtered columns instead of stale catalog offsets or repeated schema scans. All changes run at bind time; there are no new per-row checks, storage formats or migrations. Existing inconsistent rows are not rewritten.
Validation
533e957961(includes fix(load): restore large CSV rows and preserve LOCAL upload errors #31300). Fullpkg/sql/plantests passed normally and under race; configured incremental SCA and vet passed for the complete affected Go package.load_data_set_nullBVT passed 49/49 statements twice against a clean local instance, including the original CI failure and two error-priority controls. Hidden-write and ALTER COPY BVT passed 54/54 twice. Both cases were run in normal comparison mode with independent cleanup checks.Local validation used Go 1.27.1 on macOS arm64. Remote CI for the updated head is pending.