Repository navigation
fix prepared DECIMAL comparison coercion - #26849
Conversation
|
Verification evidence from base Reproduction before the production fix: GOTMPDIR=/home/xupeng/.cache/codex-26847-gotmp.rE053s \
.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=120s \
-run '^TestPreparedDecimal(BinaryComparisonsDeriveParamType|ComparisonPlannerReplacementAndReuse)$' \
./pkg/sql/planFailed as expected: DECIMAL64/128 Fresh verification after the fix: GOTMPDIR=/home/xupeng/.cache/codex-26847-gotmp.rE053s \
.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=120s \
-run '^(TestPreparedDecimalBinaryComparisonsDeriveParamType|TestDecimalStringComparisonsKeepMySQLCoercion|TestPreparedDecimalComparisonPlannerReplacementAndReuse)$' \
./pkg/sql/plan
GOTMPDIR=/home/xupeng/.cache/codex-26847-gotmp.rE053s \
.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=120s ./pkg/sql/planBoth passed. The focused matrix covers DECIMAL64/128, Readonly package gates passed: GOTMPDIR=/home/xupeng/.cache/codex-26847-gotmp.rE053s GOWORK=off \
CGO_CFLAGS="'-I/home/xupeng/github/matrixone-issue-26847-codex/cgo' '-I/home/xupeng/github/matrixone-issue-26847-codex/thirdparties/install/include'" \
CGO_LDFLAGS="'-L/home/xupeng/github/matrixone-issue-26847-codex/thirdparties/install/lib'" \
go list -mod=readonly ./pkg/sql/plan
GOTMPDIR=/home/xupeng/.cache/codex-26847-gotmp.rE053s GOWORK=off \
CGO_CFLAGS="'-I/home/xupeng/github/matrixone-issue-26847-codex/cgo' '-I/home/xupeng/github/matrixone-issue-26847-codex/thirdparties/install/include'" \
CGO_LDFLAGS="'-L/home/xupeng/github/matrixone-issue-26847-codex/thirdparties/install/lib'" \
go build -mod=readonly ./pkg/sql/plan
GOTMPDIR=/home/xupeng/.cache/codex-26847-gotmp.rE053s GOWORK=off \
CGO_CFLAGS="'-I/home/xupeng/github/matrixone-issue-26847-codex/cgo' '-I/home/xupeng/github/matrixone-issue-26847-codex/thirdparties/install/include'" \
CGO_LDFLAGS="'-L/home/xupeng/github/matrixone-issue-26847-codex/thirdparties/install/lib'" \
go vet -mod=readonly ./pkg/sql/planCandidate build passed: TMPDIR=/home/xupeng/.cache/codex-26847-gotmp.rE053s \
GOCACHE=/home/xupeng/.cache/codex-26847-gocache.tl7yBB \
GOTMPDIR=/home/xupeng/.cache/codex-26847-gotmp.rE053s make buildBlack-box replay used only the locally built candidate on ./run.sh \
-p /home/xupeng/github/matrixone-issue-26847-codex/test/distributed/cases/prepare/prepare_decimal_comparison.sql \
-m run -r 100 -gResult: 43/43 successful, 0 failed, 0 ignored, 0 abnormal. Self-review: ACCEPT. No resource ownership, waits, goroutines, generation state, or unbounded growth were introduced; unhappy-path Q1-Q3 are not applicable. |
|
Independent 10.222.1.55 candidate acceptance (single node, 6 GB cache) passed. |
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review: ACCEPT — no blocking findings.
Reviewed exact head afeb5500a28ad1ddae77abc7cfa841d99df0c3ec against base 0676200da47052659cf46ad9e22d67ab9654e393. The change restores the intended invariant at the narrowest shared boundary: only a direct prepared parameter paired with a DECIMAL peer is typed as that peer before generic overload coercion. Both operand orders and all binary comparison operators are covered; genuine string literals/columns and parameters explicitly wrapped as strings keep MySQL string/numeric coercion. The additional bind-time work is two direct type checks per comparison and one existing cast node only on the matched prepared-DECIMAL path, with no new per-row state, allocation, synchronization, or lifecycle ownership.
I also checked the nearby paths not exercised by the new helper itself: public PREPARE plans for DECIMAL BETWEEN ? AND ? and IN (?, ?) already derive DECIMAL through their existing contextual binders; tuple/ANY/ALL comparisons eventually bind through the same binary comparison boundary. Independent review probes for DECIMAL256, the != alias, and an explicit-string-param negative control all passed.
Fresh local gates at the exact head:
- focused prepared DECIMAL planner tests: PASS
- full
./pkg/sql/plan: PASS go build -mod=readonly ./pkg/sql/plan: PASSgo vet -mod=readonly ./pkg/sql/plan: PASSgit diff --check: PASS
No correctness, performance, unhappy-path, resource-lifecycle, or test-oracle blockers found. GitHub does not allow XuPeng-SH to Approve a PR authored by XuPeng-SH, so this is recorded as an ACCEPT comment rather than an APPROVED review state.
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26847 Fixes matrixorigin#26845 ## What this PR does / why we need it: A direct prepared parameter is initially represented as TEXT. In binary comparisons with DECIMAL, the generic string/numeric cast matrix therefore selected DOUBLE for both operands, losing precision above 2^53 and making distinct DECIMAL values compare equal. Derive a direct parameter marker's type from its DECIMAL peer before generic overload coercion. This covers null-safe and ordinary binary comparisons in both operand orders while leaving genuine string literal/column coercion unchanged. Regression coverage includes DECIMAL64/128, NULL and non-NULL values above 2^53 with fractional digits, operand order, all ordinary comparisons, prepared-plan replacement/reuse, and real-string controls. ## Verification - Focused planner regressions: pass - Full `./pkg/sql/plan` package: pass - `go list`, `go build`, and `go vet` for `./pkg/sql/plan`: pass - `make build`: pass - Candidate `mo-tester` replay: 43/43 statements pass with issue-skip handling enabled Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26847 Fixes matrixorigin#26845 ## What this PR does / why we need it: A direct prepared parameter is initially represented as TEXT. In binary comparisons with DECIMAL, the generic string/numeric cast matrix therefore selected DOUBLE for both operands, losing precision above 2^53 and making distinct DECIMAL values compare equal. Derive a direct parameter marker's type from its DECIMAL peer before generic overload coercion. This covers null-safe and ordinary binary comparisons in both operand orders while leaving genuine string literal/column coercion unchanged. Regression coverage includes DECIMAL64/128, NULL and non-NULL values above 2^53 with fractional digits, operand order, all ordinary comparisons, prepared-plan replacement/reuse, and real-string controls. ## Verification - Focused planner regressions: pass - Full `./pkg/sql/plan` package: pass - `go list`, `go build`, and `go vet` for `./pkg/sql/plan`: pass - `make build`: pass - Candidate `mo-tester` replay: 43/43 statements pass with issue-skip handling enabled Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26847 Fixes matrixorigin#26845 ## What this PR does / why we need it: A direct prepared parameter is initially represented as TEXT. In binary comparisons with DECIMAL, the generic string/numeric cast matrix therefore selected DOUBLE for both operands, losing precision above 2^53 and making distinct DECIMAL values compare equal. Derive a direct parameter marker's type from its DECIMAL peer before generic overload coercion. This covers null-safe and ordinary binary comparisons in both operand orders while leaving genuine string literal/column coercion unchanged. Regression coverage includes DECIMAL64/128, NULL and non-NULL values above 2^53 with fractional digits, operand order, all ordinary comparisons, prepared-plan replacement/reuse, and real-string controls. ## Verification - Focused planner regressions: pass - Full `./pkg/sql/plan` package: pass - `go list`, `go build`, and `go vet` for `./pkg/sql/plan`: pass - `make build`: pass - Candidate `mo-tester` replay: 43/43 statements pass with issue-skip handling enabled Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #26847
Fixes #26845
What this PR does / why we need it:
A direct prepared parameter is initially represented as TEXT. In binary comparisons with DECIMAL, the generic string/numeric cast matrix therefore selected DOUBLE for both operands, losing precision above 2^53 and making distinct DECIMAL values compare equal.
Derive a direct parameter marker's type from its DECIMAL peer before generic overload coercion. This covers null-safe and ordinary binary comparisons in both operand orders while leaving genuine string literal/column coercion unchanged.
Regression coverage includes DECIMAL64/128, NULL and non-NULL values above 2^53 with fractional digits, operand order, all ordinary comparisons, prepared-plan replacement/reuse, and real-string controls.
Verification
./pkg/sql/planpackage: passgo list,go build, andgo vetfor./pkg/sql/plan: passmake build: passmo-testerreplay: 43/43 statements pass with issue-skip handling enabled