Commit 3046f14
authored
fix: align explicit CAST overflow behavior with MySQL (#25898)
Explicit SQL `CAST` and `CONVERT` expressions previously reused the ordinary internal cast overload, whose strict overflow errors differ from MySQL's explicit-cast behavior.
This change:
- routes only MySQL `SIGNED`, `UNSIGNED`, and `DECIMAL` cast targets through a dedicated overload, keeping MatrixOne extension integer targets and planner-inserted casts unchanged;
- applies MySQL-compatible signed/unsigned overflow handling across string, integer, float, Decimal64, Decimal128, and Decimal256 sources;
- clamps explicit decimal casts across Decimal64, Decimal128, and Decimal256 target precisions;
- preserves errors for invalid numeric strings;
- adds planner/function unit tests, column-vector coverage, extension-target regression tests, and BVT coverage for the reported cases and boundaries.
User impact: overflow cases such as large integer strings, negative-to-unsigned casts, and oversized decimals now produce MySQL-compatible values without changing existing strict semantics for implicit casts or MatrixOne extension integer targets.
Validation:
- `go test ./pkg/sql/plan/function ./pkg/sql/plan`
- `go test -race ./pkg/sql/plan/function ./pkg/sql/plan`
- `go vet ./pkg/sql/plan/function ./pkg/sql/plan`
- `make build`
- `func_cast.test` BVT: 226/226 passed
- `boundary_comprehensive.sql` BVT: 241/241 passed
- changed helper coverage: 75.0%-100%
- `git diff --check`
Approved by: @XuPeng-SH, @heni021 parent b3fe1ba commit 3046f14
17 files changed
Lines changed: 1648 additions & 63 deletions
File tree
- pkg/sql/plan
- function
- test/distributed/cases
- dml/select
- dtype
- function
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
159 | 163 | | |
160 | 164 | | |
161 | 165 | | |
| |||
281 | 285 | | |
282 | 286 | | |
283 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
284 | 306 | | |
285 | 307 | | |
286 | 308 | | |
| |||
3000 | 3022 | | |
3001 | 3023 | | |
3002 | 3024 | | |
| 3025 | + | |
| 3026 | + | |
| 3027 | + | |
| 3028 | + | |
| 3029 | + | |
| 3030 | + | |
| 3031 | + | |
| 3032 | + | |
| 3033 | + | |
| 3034 | + | |
3003 | 3035 | | |
3004 | 3036 | | |
3005 | 3037 | | |
3006 | 3038 | | |
3007 | 3039 | | |
3008 | | - | |
| 3040 | + | |
3009 | 3041 | | |
3010 | 3042 | | |
3011 | 3043 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
0 commit comments