Skip to content

feat: backport MySQL type compatibility features to 3.0-dev (#24184) - #24198

Closed
ck89119 wants to merge 17 commits into
matrixorigin:3.0-devfrom
ck89119:issue-24184-3.0-dev
Closed

ck89119 wants to merge 17 commits into
matrixorigin:3.0-devfrom
ck89119:issue-24184-3.0-dev

Conversation

@ck89119

@ck89119 ck89119 commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #24184

What this PR does / why we need it:

Backports 8 MySQL type compatibility features from main to 3.0-dev:

  1. YEAR type (cdd430d0d5) — YEAR column type, storage, wire protocol, cast, aggregate
  2. SET type (7b53ff1215) — SET column type, storage, wire protocol, cast, planner
  3. Decimal scientific notation (c01918106b) — parse 1e2, 1.5e-3 as DECIMAL literals
  4. TEXT→CHAR/VARCHAR cast (54d9635908) — allow casting TEXT to CHAR/VARCHAR
  5. Decimal comparison precision (37a2eda6a6) — fix comparison scale alignment and DIV range validation
  6. DECIMAL(M,D) up to 65 digits / Decimal256 (688b68b618) — support DECIMAL(65,30) via 256-bit decimal type
  7. Float/exp() overflow alignment (5a25a14008) — align overflow behavior with MySQL for EXP() and arithmetic
  8. Geometry/spatial typing (d23b1258e5) — GEOMETRY/POINT/etc. column types, SRID attribute, ST_* spatial functions, spatial index support

Key 3.0-dev adaptation changes

  • Removed GeneratedCol and attr_has_generated references (main-only fields not present in 3.0-dev catalog)
  • Replaced catalog.Async constant with string literal "async" (not backported in 3.0-dev)
  • Added IsIndexAsync helper to catalog package for async fulltext index detection
  • Fixed T_decimal256 missing case in vector.setupFromData (caused panic on Decimal256 queries)
  • Restored truncating integer division for Decimal64/128 in decimalIntegerDiv (regression from Decimal256 backport)
  • Fixed information_schema.COLUMNS view to use placeholder for GENERATION_EXPRESSION (no generated column support in 3.0-dev)
  • Adapted test API calls for 3.0-dev (MakeVarcharVector, MakeVarlenaVector signatures differ)
  • Removed main-only test functions (TestOrd, TestBuildWithInsert, RewriteCountNotNullColToStarcount, etc.)

Verification

  • make ✅
  • make static-check ✅ (no new errors introduced)
  • Unit tests: pkg/sql/plan/..., pkg/sql/plan/function/... ✅
  • BVT: test/distributed/cases/function/func_geometry.test — 756/756 (100%) ✅

flypiggy and others added 9 commits April 24, 2026 12:17
- [ ] API-change
- [ ] BUG
- [ ] Improvement
- [ ] Documentation
- [x] Feature
- [ ] Test and CI
- [ ] Code Refactoring

issue matrixorigin#23310

This PR supports the year type in the MatrixOne database.

(cherry picked from commit cdd430d)
- add MySQL SET value parsing and normalization on top of uint64 bitmaps
- preserve SET metadata across planner casts, DDL/DML, SHOW CREATE TABLE, DESC, information_schema, CTAS, and LOAD DATA
- validate ALTER TABLE ... MODIFY COLUMN when the SET member list changes
- allow table-defined secondary indexes on SET columns
- preserve enum/set definition-order sorting for SELECT DISTINCT ... ORDER BY ...
- add planner regression coverage and SET BVT coverage for secondary-index and DISTINCT ordering cases

Validation:
- go test ./pkg/container/types -run 'Test(NormalizeSetValues|ParseSet|ParseSetIndex|NormalizeSetValuesMaxMembers)'
- env GOCACHE=/tmp/matrixone-go-cache go test ./pkg/sql/plan -run 'Test_isSameColumnType|TestQueryBuilder_bindOrderByEnum|TestQueryBuilder_bindOrderByEnumDistinct'
- env GOCACHE=/tmp/matrixone-go-cache go test ./pkg/sql/colexec/external -run TestDummyDoesNotExist
- SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk CPLUS_INCLUDE_PATH=/usr/local/var/homebrew/tmp/.cellar/llvm@21/21.1.8/include/c++/v1 env GOCACHE=/tmp/matrixone-go-cache make build
- cd /Users/moukeyu/mo-tester && ./run.sh -m genrs -p /Users/moukeyu/matrixone-23912/test/distributed/cases/dtype/set.sql
- cd /Users/moukeyu/mo-tester && ./run.sh -p /Users/moukeyu/matrixone-23912/test/distributed/cases/dtype/set.sql -g
- [SUMMARY] COST : 0s, TOTAL :56, SUCCESS : 56, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%

Approved by: @LeftHandCold, @ouyuanning, @heni02, @aunjgr, @XuPeng-SH

(cherry picked from commit 7b53ff1)
…atrixorigin#23440)

Selective backport of 37a2eda from main:
- Fix Decimal128 high-bit handling in hasTrailingZeros()
- Add integer range validation in checkNoNeedCast()
- Fix float precision limits for IEEE 754 safe ranges
- Add early detection for decimal comparisons always false/true
- Skip constant folding for division/modulo by zero
- Smart type selection for decimal literals

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…rixorigin#23916)

Selective backport of 688b68b from main:
- Parser routes DECIMAL(M) with M>38 to T_decimal256
- Decimal256 parse/format, arithmetic, cast, compare, aggregate support
- Wired through frontend output (constructByte), planner, and type system
- Sort, ZoneMap, vector infrastructure for decimal256
- Excluded: parquet export (tracked in matrixorigin#24188), old aggexec files

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
matrixorigin#23524 backport)

- Add overflow detection for float32/float64 arithmetic operations
- Align exp() to return error on overflow instead of infinity
- Backport from main commit 5a25a14 to 3.0-dev

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Backport commit d23b125 from main to 3.0-dev:
- Add geometry/spatial types (GEOMETRY, POINT, LINESTRING, POLYGON, etc.)
- Add ST_* spatial functions (ST_AsText, ST_GeomFromText, ST_X, ST_Y, etc.)
- Add SRID attribute support for geometry columns
- Add geometry type handling in planner, parser, frontend, and catalog
- Add async fulltext index detection via IsIndexAsync in catalog
- Fix Decimal256 vector setupFromData missing T_decimal256 case
- Fix decimalIntegerDiv truncation regression from Decimal256 backport
- Adapt tests for 3.0-dev API differences

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- Fix information_schema.COLUMNS view: GENERATION_EXPRESSION uses
  placeholder cast('') since attr_has_generated doesn't exist in 3.0-dev
- Remove explain plan tests incompatible with mo-tester 4-space separator
- Regenerate func_geometry.result from 3.0-dev mo-service

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ ck89119
❌ robll-v1
You have signed the CLA already but the status is still pending? Let us recheck it.

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants