Repository navigation
fix(sql): retain DECIMAL access for prepared integer consumers - #29920
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? |
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed head 55957c5 against f42af4d. No blocking finding.
The admission proof is appropriately narrow: native DECIMAL columns, exact integer peers, and injective integer cast chains. All peers must fit before guards are published, executable parameters/casts remain intact, and a failed proof retains the fallback/value dependency. The declared-precision probes protect reuse without replacing the admitted cache entry on a wide binding. The tests cover these boundaries and safe/wide/NULL recovery.
The optional InputBlocks JSON field preserves actual remote scan work without inventing legacy counts. Producer/receiver, duplicate terminal delivery, and local/remote aggregation tests cover the changed diagnostic contract.
Validation: reused the reported owning-package/cache/race and real SQL/BVT evidence, plus passing current-head CI. I did not rerun a local service or benchmark. Remaining TEXT/DOUBLE cases and the disclosed small-query guard overhead are explicitly outside the claim.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of 55957c53053f03c3bb00ff5d813aeadb2d6e72a5 against f42af4dfcba210fd91b6f1fc5d7b5a72704502ee: no blocking finding.
The design extends the existing prepared consumer admission and diagnostic/cache ownership. It replaces the old direct-comparison branch with one admission for comparison/list/range peers. The native DECIMAL column is retained only when every integer peer fits; explicit cast chains must be injective over their source domain and remain executable. Guard publication is atomic, prior value dependencies survive, and wide/NULL/type-changing bindings cannot overwrite the admitted safe plan. TEXT/DOUBLE residual cases stay outside this proof; this PR correctly does not close #29661.
The InputBlocks change repairs the existing terminal-analysis serialization boundary with an optional field, reusing producer, receiver and node aggregation. Missing legacy data remains zero; duplicate terminal delivery remains idempotent. No new statistics estimator, cache, storage field or protocol state machine is introduced.
All eight files reviewed: production 2 files +136/-37, Go tests 4 +381/-1, SQL/results 2 +109/-0, no documentation files. The test increment checks real cache identity and failure/recovery, executable parameter retention, narrowing/float controls, remote serialization/aggregation and actual SQL rows/access paths. The BVT reuses the persisted fixture and makes selective scan/index assertions rather than relying only on plan shape.
Fresh local Darwin arm64 / Go 1.27.1 race checks passed: planner prepared-DECIMAL tests (2.995s), frontend prepared-DECIMAL and existing signed-narrowing cache checks (3.029s), real remote-terminal scan-work test (4.152s) and physical-plan JSON round trip (1.615s). Inspected current-head successful CI 38154370996 and its actual pessimistic BVT artifact: the extended DECIMAL script passed 274/274, with zero ignored/abnormal results. There are no unresolved review threads.
Performance is a real tradeoff: existing per-EXECUTE diagnostic probes protect the newly admitted cases, so small queries incur work. The author's disclosed shared-host measurements report +15–37 microseconds (5.3–14%) for two-row cases, while selective persisted IN/index cases improve substantially. I did not rerun those benchmarks and do not interpret them as a production guarantee or zero TP regression. The code preserves cache reuse and does not add unconditional replanning; the bounded guard cost buys the claimed access-path correctness.
Merge Queue Status
This pull request spent 1 minute 55 seconds in the queue, with no time running CI. ReasonPull request #29920 has been merged manually at 6812abb HintYou were too fast! Waiting for any of
All conditions
Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
Part of #29661; follow-up to #29667. Does not close #29661.
What this PR does / why we need it:
Two independent boundaries prevent meaningful prepared-DECIMAL pruning coverage:
OperatorStats.InputBlockshasjson:"-". Remote terminal analysis preserves input rows but drops the actual block count, so aggregation can reportRows=32768, Blocks=0. That diagnostic failure blocks the nightly fixture before its prepared comparisons are exercised; it is not proof that a storage scan read zero blocks.This patch shares the existing exact-domain admission across SELECT comparisons, IN/NOT IN and BETWEEN. It admits only a native DECIMAL column and integer literals/parameters, including injective integer cast chains. All peers must fit before any conversion guard is published. Original executable parameter/cast expressions, wide-value fallback, earlier value dependencies, and existing cache ownership are retained. A declared-precision conversion guard protects subsequent EXECUTEs; an unsafe binding cannot replace the reusable safe plan.
The diagnostic fix is one optional JSON field. Real remote-terminal producer/consumer tests cover round-trip, idempotent terminal delivery, mixed local/remote aggregation, and legacy missing-field inputs. Missing data stays zero; counts are never invented from row counts. No storage format, RPC protocol version, reader implementation, global type-coercion policy, or DML behavior changes.
Validation scope
Base: freshly verified Main
f42af4dfcba210fd91b6f1fc5d7b5a72704502ee.Actual SQL is tested on server 50 in task-owned single-CN instances (4 CPU / 8 GiB), using identical persisted data and independent fixed-row expected results, with both binary Prepared Statements and SQL EXECUTE. Existing user services and nightly clusters are untouched.
The existing DECIMAL BVT is extended in place, reusing its dataset and normal result comparison. On the unmodified base the original 239 statements pass; the final extended 274-statement case has exactly four new scan/index assertion failures and 270 passes. No existing expectation is weakened.
Local candidate results:
runmode, 2.830s / 2.839s. Explicit before/after database checks are zero. No generated-result acceptance.pkg/sql/plantests pass; focused frontend real-cache tests pass, including safe cache identity, wide/NULL fallback and recovery, plus existing signed-narrowing/assignment/float controls.pkg/vm/process,pkg/sql/models,pkg/sql/compiletests pass. The real remote-terminal regression test fails on the base (rows preserved, expected four blocks become zero) and passes after the optional-field change.go vetpasses for the five affected packages; formatting and whitespace checks pass. Pinnedgolangci-lint v2.14.0, repository config, all five packages,--new-from-rev=f42af4df...: exit 0, zero reported issues (1m 2.787s). The initially selected host Go launcher could not recognize SIMD inside lint's package loader; fixing only PATH/GOROOT to the verified Go 1.27.1 toolchain resolved it. SIMD/v3 and native provenance checks were retained.Bounded actual-query timing (median of five 200-operation batches per protocol/scenario; 8,000 correctness-checked operations per binary): persisted IN takes 43.3% / 45.2% of base time (binary / SQL EXECUTE); indexed SIGNED takes 53.1% / 55.5%. On two-row tables, the added guarded paths cost 15–37 microseconds per execution (5.3–14.0%) in this shared-host sample. This cost is disclosed, not called zero regression or a production guarantee. The existing cache is retained, rather than replacing the access-path issue with repeated planning or a new cache mechanism.
Both isolated test services have been stopped; test databases were removed. All evidence is retained under
/tmp/mo-29661-completion-20261011.O28F1pon server 50.Explicit remaining limits