Repository navigation
fix(sql): preserve UUID NULL and mixed character semantics - #29800
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? |
|
Commit review: |
|
Commit review: 审查结论:未发现阻塞问题。类型归并复用现有公共职责;LEAST/GREATEST 只增加 UUID 与字符类型混合的受限分支,原生 UUID 快路径和其他不支持的混合类型保持不变。生产代码净增 15 行,没有引入新的执行路径或状态管理。 验证方面,当前提交的 UT、Coverage、SCA 和多 CN BVT 均通过。我补充验证了 prepared 参数在 NULL、短文本和 200 字符中文之间切换,以及真实列上的 IF、CASE、COALESCE、GREATEST 表达式,未观察到截断。 兼容性范围仍按 PR 说明:#28382 部分处理;UUID_SHORT 延后;原生 UUID/v7、CTAS 和严格 UUID 比较语义保留。该结论是对本提交的 review,不表示所有 UUID 兼容性 issue 均已实现。 |
) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #29562. This closes cancellation and cleanup ownership gaps; it does not claim the issue's ten-minute performance target. ## What this PR does / why we need it: The [coverage failure in PR #29800](https://github.com/matrixorigin/matrixone/actions/runs/37956144015/job/113907182188) left an embedded helper, active mock test and watchdog after the harness timeout. Deterministic white-box checks demonstrated repeated TERM interrupting cleanup and a further gap: helper status 125 initially retained artifacts, but clearing its PID erased that conclusion; a later root TERM then deleted the artifacts and exited 143. Reuse the existing process-group drain owners and deadlines: - Ignore repeated TERM during cleanup; fence plan metadata/build/inventory/shard PID publication and drain its child groups under one common deadline. - Retain a monotonic failed-drain fact for each existing owner independently of PID liveness. A shared join publishes helper status 125 before clearing the PID and carries raw/captured status through TERM at that handoff. TERM during an active wait immediately enters bounded cancellation. - Check retained ownership at existing report, cleanup, fallback and admission boundaries. Root failure stops already-admitted companions before post-processing and preserves terminal125. Ordinary test failure and healthy cancellation retain their existing behavior. - Keep failed child drains terminal inside engine, prebuild, shared prebuilt execution and inventory helpers. Keep TERM ignored through exit 125 so a second TERM cannot erase the failure before the parent joins. Reuse the parent ownership flags; remove redundant helper status assignments. The common prebuilt stop drains and joins all admitted groups before checking existing watchdog failure markers. A published `.drain` remains terminal125 after a later successful sweep, report-open failure or cancellation. Normal completion rechecks immediately after watchdog join; a late marker stops other admitted groups before releasing ownership. Remove the duplicated cancellation scan and unreachable marker cleanup. - Route issues infrastructure failure through the root termination owner so it always stops heartbeat and admitted companions. Remove the obsolete companion shutdown path. Consolidate engine/plan join handling, including the duplicated overlapped/sequential plan joins. - On harness failure, reclaim Linux descendants by exact fixture CASE_DIR and rechecked process start identity. Emergency cleanup remains a failed test. Successful commands do not scan procfs; the 15-second harness timeout and three-second WaitDelay are unchanged. Regression coverage extends existing fixtures for failed join followed by TERM, re-entry/fallback rejection, engine125, overlapping/sequential plan125, light leases, prebuilt execution, raw/captured status handoffs, publication gaps, repeated TERM, forced root termination and stale identity. The real root dispatch also covers status125 with no companion, healthy light and healthy prebuild companions, plus status7 and success. FIFO barriers prove timer/companion readiness; an independent pipe reader requires natural EOF before fixture cleanup. Preserve passing and ordinary-failure controls. Update the relocated join injection anchor and make the drain-count oracle portable to BSD wc. Real helper-to-parent regressions additionally cover failed drains with held live children, TERM at the terminal handoff, retained binaries/reports, blocked admission/fallback and late root TERM. Preserve ordinary drained report-open failures and successful fallback controls. Consolidate the previous inventory failure test into this shared consumer fixture. The three TERM handoff regressions fail on pre-fix `3ac2e72`, while the drained fallback control passes. The new marker-before-cancellation regression also fails when its six-line cancellation check is removed. EXIT assertions keep a saved output descriptor to remain visible when Bash 5 exits inside a redirected function. ### Final validation Rebased onto main `a6e19ccf7761`; the base delta affects CDC only, with runner dependencies and lint configuration unchanged. - Complete `./optools`, Go1.27.1: macOS arm64/Bash3.2 normal88.645s and race88.862s; Linux arm64/Bash5 with init reaping normal33.279s and race34.567s, all passed. Linux prerequisites include libc development headers and the existing Python interpreter in PATH; initial environment failures were corrected without source changes. - Two new rows reuse the existing real helper-to-parent fixture: marker plus report-open failure, and marker published at completion with two active shards. They require retained artifacts/marker, protected helper and parent TERM125, blocked admission and all groups drained before fixture cleanup. The promoted pre-fix report-open case fails while its ordinary drained control passes. - Focused Linux race stress: shared prebuilt fixture100 repetitions passed (24.519s). Prior parent-handoff96 repetitions remain valid: its fixture and causal paths are unchanged. - Incremental SCA across the complete five-file PR: formatting, Bash syntax, diff checks, go vet and repository-pinned molint passed. Configured golangci-lint2.14 checks: zero issues. Pinned2.6 cannot read Go1.27 export data; repository configuration unchanged. - Actual gpt-6.1-sol/xhigh design and overall review approved the complete delivery. Final review evidence conditions are closed on the identical five-file diff SHA256 `760c1fc97e22119d7f68676a3e8b16b6b25455dcc448eccadaae62ea379fcbb1`. The original timeout's exact initial wait is not established. This affects UT orchestration and fixtures only; no database execution code or SQL behavior changes. Cost is constant per join/admission boundary; no new scheduler, polling loop or normal-path procfs scan. Orphan discovery remains Linux-specific. CI on the updated revision is pending; no BVT or CI completion is claimed.
## What type of PR is this? - [x] Feature - [x] Improvement ## Which issue(s) this PR fixes: Implements only the `UUID_SHORT()` item in #25107; its other functions and syntax remain separate work. Follows the native UUID contract accepted in #29800. Companion bilingual documentation: matrixorigin/matrixone-doc#374, tracking #29803. ## What this PR does / why we need it: Add volatile `UUID_SHORT()` returning `BIGINT UNSIGNED`, backed by the existing durable HAKeeper allocator. Reserve 8,192 IDs per refill for its fixed SQL namespace. This avoids inheriting the metadata allocation default of 100, which needed about 100 synchronous HAKeeper reservations to generate 10,000 SQL values. ### Design and behavior - Append the function ID and use the existing volatility, unsigned vector and MySQL protocol machinery. - All CNs/accounts use one fixed keyed namespace. Existing HAKeeper state/snapshots own durability; the managed client owns its cached range, locking, refill coordination and retries. - SQL requests `objectio.BlockMaxRows` (8,192) through existing `AllocateIDByKeyWithBatch`. This is a fixed SQL policy, independent of `AllocateIDBatch`; other consumers retain their configured reservation sizes. Scalar statements reuse the same client cache, and sparse evaluations consume IDs only for selected rows. - Lazily create one child context per evaluated vector, retaining an earlier query deadline and otherwise limiting it to 30 seconds. Release it on exit; propagate allocation failures. Empty/ignored evaluations consume no IDs. - Reject zero/overflowing reservations before durable mutation or cache publication. Preserve successful request-ID replay and the existing refill wakeup on errors. Consolidate duplicated RSM allocation branches. Successful values are unique within one preserved cluster allocation history. Gaps and out-of-order observation are allowed. Rollback, cancellation, lost replies and CN restart consume or abandon reserved IDs. A client can leave up to 8,191 unused IDs from its current successful reservation; repeated failures/restarts have no lifetime gap guarantee. A refill errors when the remaining durable range cannot fit the complete 8,192 batch, leaving the counter unchanged. Independent clusters, cloned allocator state and rewound snapshots can repeat values; this differs from MySQL's server/startup bit layout. Values are not secrets. Upgrade CNs and all HAKeeper replicas before relying on the function and reservation guards. Preserve allocator state on rollback. The existing native UUIDv7 functions retain their accepted contract. ### Performance evidence Paired local SQL measurements use the same embedded two-CN topology, queries and data, with a one-call-site old-API overlay as the baseline. Query: ```sql select count(distinct uuid_short()) from generate_series(1,10000) g; ``` | Workload | 100-ID default baseline | 8,192-ID SQL reservation | |---|---:|---:| | 10,000 IDs, cold CN client | 419.8 ms | 24.3–28.2 ms | | 10,000 IDs, warm cache | 397.4 ms | 4.8–5.5 ms | | Four UPDATEs assigning UUID_SHORT to 128 rows each | 41.2–45.7 ms | 21.9–25.5 ms | Persistent prepared scalar calls and ordinary UPDATE controls were also exercised. Cold samples include first-query/CN initialization; timings vary on this shared host. These are local diagnostic results, not a cluster throughput or SLA claim. No wall-clock threshold is added to unit tests. The optimization itself adds 4 production lines and removes 3 test lines net; the complete feature is production +58 / tests +334. ### Validation Base / merge base: `8f48d6fac04bf612be65ed1b44477ef9b32cb88f`. Final source: `cff322740e48605b5853b6e5fd776d292a4aa359`. Go 1.27.1, Linux/amd64 CPU, matching native libraries through `mo-cgo-test`, disk TMPDIR, GOMAXPROCS=4, package parallelism=2. - Full function package: normal PASS 6.500s; `-race` PASS 11.616s. - Existing/new allocation tests with `-race`: logservice PASS 1.914s, including explicit batch overriding configured batch and first three IDs sharing one RPC / fourth ID causing the second. - UUID_SHORT and native UUID public consumers with `-race`: DML PASS 11.941s. Retain two-CN, repeated/prepared expressions, rollback gaps, invalid-arity connection recovery, unsigned CTAS and text/prepared MaxUint64 controls. - Public normal QA PASS 8.958s: DEFAULT / INSERT SELECT / prepared INSERT / UPDATE, generated-column rejection, 16,386 concurrent IDs across two CNs, driver/native controls and the committed 8,193-row count/distinct boundary test in the existing fixture. - Workload controls pass, including all 128 affected rows and 128 distinct stored values after each UPDATE sequence. Error/zero/nil client, masks, parent cancellation and child-context cleanup remain covered. - Incremental SCA for the complete affected package closure: `go vet` PASS; configured golangci-lint 2.14.0 reports 0 issues; matching-Go molint has 0 new diagnostics. Its two existing unsafe-import diagnostics are byte-identical to base sources and separately recorded. - Reuse unchanged HAKeeper/logservice production owner evidence: full normal/race, snapshot/exhaustion/replay, terminal ranges, cancellation, refill competitors and fresh-client isolation. The revised client test has fresh normal/race evidence. CI will run on the updated source; no pending CI result is counted as passed. ### Reviewed design and QA Design model: `gpt-6.1-sol`, reasoning `xhigh`, session `01a12212-268c-7693-a7de-2fa7a67020aa`; design amendment SHA256 `02fa7c9b27c83e5b85f30722685c945b5fbb520339cbec2fca5659f24f4457ad`. Runtime model/effort selection was verified from the CLI session. The preserved allocator-history contract and existing owner guards follow the accepted base design; the complete approved SQL batch amendment is below. Final independent overall review: `gpt-6.1-sol` / `xhigh`, session `01a12225-0a88-7392-bd26-6540a72565f3`, **PASS for the complete PR at `cff322740e48605b5853b6e5fd776d292a4aa359`**, no unresolved material blocker. Review artifact SHA256 `c8629b1e4d00f53c8d7bfee0204d65576dee2c8b345c53e5009f89210c8eb913`. The original reservation-granularity P2 is closed; unchanged allocator evidence was checked against source hashes, and revised function/client/public tests have fresh evidence.. <details> <summary>Approved SQL reservation design amendment</summary> **Design decision: PASS for a fixed SQL reservation of 8,192 IDs through the existing `AllocateIDByKeyWithBatch` API.** Implement this on the same `feat/uuid-short` branch and PR #29805. This design supplements head `1e41c466aaa4d6f6ece9cb8ad12d507222374a99`, based on `8f48d6fac04bf612be65ed1b44477ef9b32cb88f`. This phase read source and the supplied artifacts. It made no edits, ran no tests, and performed no remote mutations. **Root cause and invariant.** The confirmed review evidence (recorded artifact) establishes that the executor’s per-row `AllocateIDByKey` call inherits the metadata allocation default of 100. Generating 10,000 IDs therefore requires approximately 100 synchronous HAKeeper reservations. The measured original → batch-10,000 overlay → original comparison was 405–428 ms → 4.9–5.8 ms → 426–428 ms, with correct results throughout. The separate counter namespace still shares HAKeeper RPC and Raft capacity. The correction must amortize reservation work across ordinary SQL batches while retaining these invariants: - Every evaluated row consumes one positive `uint64` ID; ignored rows and empty evaluations consume none. - One fixed namespace, `__mo_sql_uuid_short`, retains uniqueness within preserved allocator history. - HAKeeper owns durable range reservation; the managed client owns cache consumption, refill coordination, publication, retry, and waiting. - Errors propagate immediately. Cancellation, failed evaluation, rollback, and restart never reclaim IDs. - The executor retains its lazy, cancellable 30-second child context per evaluation and preserves unsigned results. These retain the ownership and compatibility decisions in the accepted design (recorded artifact). **Exact correction.** In [func_builtin.go](https://github.com/XuPeng-SH/matrixone/blob/1e41c466aaa4d6f6ece9cb8ad12d507222374a99/pkg/sql/plan/function/func_builtin.go#L2269), add a named SQL policy constant beside the allocation key: ```go // Reserve one normal block of IDs to amortize SQL allocation refills. const uuidShortAllocationBatchSize uint64 = objectio.BlockMaxRows ``` Replace only the allocation call: ```go id, err := client.AllocateIDByKeyWithBatch( ctx, uuidShortAllocationKey, uuidShortAllocationBatchSize, ) ``` Use `objectio.BlockMaxRows` directly: it is [8,192](https://github.com/XuPeng-SH/matrixone/blob/1e41c466aaa4d6f6ece9cb8ad12d507222374a99/pkg/objectio/const.go#L27). `options.DefaultBlockMaxRows` aliases it, and `generate_series` also emits 8,192-row batches. This makes one ordinary block the justified SQL reservation lower bound **and the fixed refill size**. Do not grow it with evaluation length. SQL owns this policy; [managedHAKeeperClient](https://github.com/XuPeng-SH/matrixone/blob/1e41c466aaa4d6f6ece9cb8ad12d507222374a99/pkg/logservice/hakeeper_client.go#L607) remains the sole mechanism owner. Its cache is keyed by namespace, so cached ranges remain usable regardless of the batch argument that originally reserved them. **Policy challenge and accepted costs.** A fixed 8,192 reservation is not a claim of universal optimality. It is the smallest direct policy aligned with the established execution unit and an explicit waste bound. Using evaluation length alone would leave scalar calls making frequent reservations. Using `max(8192, length)` would allow unusually large or sparse vectors to reserve much larger ranges. Counting selected rows first adds work without improving cache reuse across evaluations. Larger fixed multiples need evidence beyond this finding. The selected policy behaves as follows: | Situation | Accepted behavior | |---|---| | Scalar-heavy workloads | The first uncached call still needs one synchronous reservation. Later statements and evaluations sharing the client consume its existing range. A short-lived client producing one ID can abandon 8,191 cached IDs. | | Empty or wholly masked evaluation | No allocator or child context is acquired. | | Sparse evaluation | Only selected rows consume IDs. The refill size remains 8,192, independent of physical vector length. | | Large vectors or multiple expressions | Reservations follow total evaluated calls. For one cold client without errors or retries, `N` calls require `ceil(N / 8192)` refills. A 10,000-call workload requires two rather than 100. | | Concurrent calls on one client | Existing per-key locking and elected-refiller coordination remain authoritative. A vector does not receive exclusive ownership of a range. | | Multiple CNs/clients | Each existing client caches disjoint durable reservations. Startup and low utilization incur one reservation per participating cold client; no global call-order guarantee is added. | Memory remains constant per existing keyed cache entry: reserving 8,192 IDs does not materialize an 8,192-element buffer. The explicit API overrides `AllocateIDBatch` for this SQL namespace, whether that configuration is smaller or larger than 8,192. Other consumers retain their configured behavior. This is a deliberate SQL policy change and should appear in the implementation description. **Gaps, exhaustion, and compatibility.** After a successful refill consumes its first ID, at most 8,191 unused IDs remain cached per client. Restart or client replacement can abandon that remainder. Lost replies can abandon a complete 8,192-ID reservation per successful-but-unobserved proposal; retries and repeated restarts have no cumulative lifetime gap bound. Rollback and failed result publication add their existing consumed-ID gaps. Preserve full-batch, fail-closed exhaustion. When fewer than 8,192 unreserved values remain, a refill errors even for a scalar request, leaving the durable counter unchanged. Accept the resulting unused tail of at most 8,191 values. Existing cached IDs may still be consumed, and a legal range ending at `MaxUint64` remains valid. There is no smaller-batch fallback. [HAKeeper’s range guards and `NextIDByKey` persistence](https://github.com/XuPeng-SH/matrixone/blob/1e41c466aaa4d6f6ece9cb8ad12d507222374a99/pkg/hakeeper/rsm.go#L1299) remain unchanged. The existing error convention and client publication guard remain unchanged. Old and new CNs reserving different positive batch sizes remain disjoint under the guarded owner. Existing rollout requirements for those guards still apply. Rollback must retain the advanced namespace. Native UUIDv7 is outside this correction. **Minimum regression architecture.** 1. **Migrate the existing function mock.** In [uuid_short_test.go](https://github.com/XuPeng-SH/matrixone/blob/1e41c466aaa4d6f6ece9cb8ad12d507222374a99/pkg/sql/plan/function/uuid_short_test.go), implement `AllocateIDByKeyWithBatch` and give its callback the batch argument. Assert the namespace and exact named SQL batch size on every allocation. Retain the existing empty, mask, deadline, child-cancel, parent-cancel, nil-client, zero-result, injected-error, and full-`uint64` oracles. 2. **Prove refill counts through the real managed client.** Extend the existing batch-consumption suite in [hakeeper_client_test.go](https://github.com/XuPeng-SH/matrixone/blob/1e41c466aaa4d6f6ece9cb8ad12d507222374a99/pkg/logservice/hakeeper_client_test.go#L2349) with a named explicit-batch case: configure batch **1**, request batch **3** through `WithBatch`, and allocate four IDs. Assert IDs 1–3 require exactly one RPC and ID 4 causes exactly the second RPC; assert both RPC batch arguments equal 3. Reuse `sendCNAllocateIDFunc`, restore it immediately through cleanup, and keep the case serialized. This independently proves explicit configuration override and full-range consumption; the function mock proves SQL supplies 8,192. Four allocations suffice. 3. **Add one bounded public workload.** Extend [TestUUIDShortSQL](https://github.com/XuPeng-SH/matrixone/blob/1e41c466aaa4d6f6ece9cb8ad12d507222374a99/pkg/tests/dml/uuid_short_test.go) in its existing fixture with: ```sql select count(*), count(distinct uuid_short()) from generate_series(1,8193) g; ``` Assert both results are 8,193. This is one reservation quantum plus one, aggregated server-side, without a Go uniqueness loop. The client UT owns the exact refill-count oracle; the SQL assertion must not infer RPC counts or require contiguity. Retain the existing two-CN, prepared execution, rollback, connection reuse, unsigned protocol, and CTAS checks. Previous DEFAULT, INSERT SELECT, UPDATE, generated-column, and concurrent correctness probes inform coverage. Their old executions do not certify the changed executor. **Risk-to-validation map.** | Risk | Required evidence | |---|---| | Wrong API, mask side effects, cancellation or unsigned-result regression | Updated `TestUUIDShort`; fresh full function normal/race evidence. | | Explicit batch ignored or early refill | Four-ID real-client regression, normal/race. Reuse unchanged allocator concurrency and failure-path evidence. | | Public execution across the reservation boundary | Fresh `TestUUIDShortSQL` normal/race, including the aggregate above; applicable owning DML normal evidence for the final inputs. | | Reservation throughput and scalar/update behavior | Final-policy local SQL comparison and controls described below. | | Durable uniqueness, terminal range, restart, refill synchronization | Reuse the deep review’s complete HAKeeper/logservice normal/race evidence: those production owners remain unchanged. Run newly changed client tests separately. | | Static correctness | Incremental gofmt, vet, configured golangci, and molint over the final changed package closure relative to the supplied PR base. Preserve documented unchanged base diagnostics; require zero new diagnostics. | Use the established CGo setup for later validation. Relevant function and DML evidence becomes stale when their source or tests change; unchanged owner evidence does not. For performance acceptance, record a bounded paired comparison of the original head and the **final 8,192 policy** using the same 10,000-row SQL query, topology, and build mode. Record cold-client and warm-cache conditions, correctness, and ordinary UUID controls. Include repeated scalar SELECT/prepared calls on a persistent connection, a few separate sessions, and a modest real-table `UPDATE ... SET id = uuid_short()` with affected-row and distinct-count checks. Investigate any unexplained scalar/update regression. The diagnostic 10,000 overlay is causal evidence, not final-policy validation. Acceptance requires the deterministic API/refill oracles, fresh affected checks, zero new static findings, and a reproducible material SQL latency reduction consistent with fewer reservations. Neither 4.9–5.8 ms nor UUID control latency becomes a promised target. Ordinary tests receive no timing thresholds. **Blockers and suggestions.** No unresolved design blocker remains. PR acceptance still requires the correction and final validation above; the confirmed performance finding remains open until then. Constant naming, comment wording, and broader cluster throughput characterization are subjective suggestions, not additional blockers. Changes to allocator ownership, reservation fallback, or the selected bound require a new design decision. </details>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #28251.
Partially addresses #28382; documents the intentional native UUID/v7 contract in #28380.
Assesses the UUID_SHORT portion of #25107; it remains deferred pending an explicit distributed uniqueness contract. #27800 P0 is already delivered by #28955; its storage-format P1 remains separate.
What this PR does / why we need it:
Current main (
d2a0055ebe) reproduces UUID/untyped-NULL bind errors and branch-order-dependent UNION truncation to eight characters. Codec NULL flags propagate NULL and nonnumeric flags error. Mixed UUID/text LEAST/GREATEST is rejected.Design document
1. Scope and product contract
This PR owns the UUID SQL compatibility design and implementation.
UUID()/UUID_V7()continue to generate native 16-byte UUIDv7 values. They render as 36 canonical ASCII characters.UUID(datetime)is a deterministic timestamp boundary, not a fresh unique identifier. Native comparisons validate textual operands as UUID values. Applications requiring arbitrary character semantics use an explicit cast; version 1 is available throughUUID_V1().2. Root causes and first owners
textStringCommonTypeexcludes UUID, while the generic COALESCE fallback reconstructs cast targets with different widths. UNION selects that common target from COALESCE, allowing a short first text branch to truncate the formatted UUID. The existingformattedScalarStringTypealready owns its 36-character bound.3. Correction and integration
textStringCommonTypeto accept UUID as a cast-requiring branch, but require a real CHAR/VARCHAR/TEXT branch before selecting text. UUID/NULL-only expressions remain native.commonConditionalStringTypewith UUID's existing formatted width. Preserve TEXT-family bounds, unbounded TEXT and existing charset merge ownership.swapFlag && !null2. For strings, scan the existing decimal prefix, then use existing MySQL numeric parsing; no prefix means false. This avoids unintentionally accepting native hexadecimal/NaN/Inf extensions.4. Invariants and unhappy paths
5. Alternatives, cost and compatibility
Changing UUID() globally to VARCHAR/v1 would alter schema inference and native generator use. Formatting UUID columns for every comparison would add per-row work and compromise native index opportunities. Separate CASE/IF/UNION patches would duplicate the same result-domain calculation. Reusing the current owners avoids those costs.
Common-domain work remains bind-time O(argument count). Mixed character expressions already require formatting; no additional per-row formatting pass or retained state is introduced. Typed codec flags retain their accessors; textual parsing is O(flag length). Overall throughput improvement is not claimed.
Persistent UUID bytes, indexes, function IDs and protocol layouts remain unchanged. Existing materialized schemas retain their types; newly evaluated mixed expressions receive safe widths. During rolling upgrades, old executors retain old expression semantics until upgraded; instant cluster-wide semantic consistency is not claimed.
UUID_SHORT cannot be safely approximated with a local counter, CN hash or truncated UUID. A future cluster-scoped implementation could reuse
proc.GetHaKeeper().AllocateID(ctx), but must first define allocator failure/cancellation, restart, clone and namespace boundaries. Exact MySQL server/startup layout is a separate contract.6. Validation and delivery decisions
Typed registry tests assert complete widths/types, both branch orders, CHAR/VARCHAR/TEXT, NULL neutrality and rejected neighboring domains. Actual SQL tests assert full UUID values, prepared reuse, CTAS width, driver type, native CTAS and error recovery. Existing version tests protect generation and extraction. A shared two-CN fixture is reused; the test does not claim explicit placement on both CNs.
Existing UUID codec and LEAST/GREATEST BVT expectations are migrated to the documented contract. Their negative controls remain, and the codec roundtrip now includes existing nullable flag and nullable UUID rows. Both complete cases pass normal mo-tester comparison twice on the same test-owned two-CN fixture, with table teardown checked before repetition.
Production delta: +15 lines net. Implementation, tests and documentation were examined separately. Existing strict swap tests are migrated rather than duplicated. The official reference correction is a companion documentation PR.
Validation
Go 1.27.1, matching CPU CGo libraries built with
make cgo, controlled disk TMPDIR, GOMAXPROCS=4, package parallelism=2.pkg/sql/plan/functionnormal tests: PASS (6.032s).-race: PASS (13.005s); later test-only additions also pass targeted race (1.135s).-race: PASS (2.310s).go vetPASS; configured golangci-lint v2.14.0 zero new issues; configured molint has zero new findings. Its two unchanged unsafe-allowlist diagnostics are reproduced identically against baseline source; they are not reported as a globally clean scan.Design and independent final QA: gpt-6.1-sol / xhigh. Accepted design revision3, SHA256
f5ed07141b60f768cd175dfd9ef9cee1c484f46d3f01cf78324ec03b3eb770f8; QA receipts recorded with exact revisions.Limits
No overall throughput improvement is claimed. Type changes are bind-time; native generation/comparison/storage execution stays unchanged. Mixed text expressions already require formatting. Existing shared text ordering semantics are retained; full MySQL collation or warning parity is not claimed. UUID_SHORT is not approximated with a counter or truncated UUID.
Official UUID documentation: matrixorigin.io #723.
CI follow-up: stale codec flag and mixed UUID/text golden expectations are corrected in four BVT files (+28/-16). No production changes or additional queries/fixtures are introduced. The existing invalid-input SQL test now requires a server MySQL error and uses a nullable receiver, so unexpected SQL NULL cannot masquerade as an expected rejection. Complete function package race passes locally (18.095s), and the strengthened public
TestUUIDSemanticsregression passes race (11.375s); unchanged function-code CI SCA is reused, and local dml vet, molint and configured incremental golangci-lint pass with zero new issues after strengthening the test.Follow-up design and final overall review: gpt-6.1-sol / xhigh; final correction review APPROVE at
164a20fb33. Strengthened SQL regression normal PASS (9.579s), race PASS (11.375s). Final Compose/proxy CI is pending.