Skip to content

[4.2-dev] build: upgrade to Go 1.27.1 - #33538

Open
XuPeng-SH wants to merge 11 commits into
matrixorigin:4.2-devfrom
XuPeng-SH:codex/4.2-go-1.27.1
Open

XuPeng-SH wants to merge 11 commits into
matrixorigin:4.2-devfrom
XuPeng-SH:codex/4.2-go-1.27.1

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Nov 30, 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:

Related to #33000

Merge prerequisites

  • Land the standalone 4.2 compression change under Go 1.26.4. It pins the released COMPRESS() bytes and adds the opt-in COMPRESS_V2() and UNCOMPRESS_V2() functions. Tracking issue #33557
  • Land the standalone Unicode 15.0 compatibility change under Go 1.26.4. It preserves released SQL identifier resolution, expression and tokenizer semantics, and covers the remaining planner and connector paths. Tracking issue #33559

Rebase the Go 1.27.1 upgrade on both merged changes and rerun the shutdown-upgrade checks.

What this PR does / why we need it:

Align 4.2-dev with main on the official Go 1.27.1 toolchain. Port the existing amd64 SIMD kernels to the revised Go API, use the main version of Sonic and its loader, and select the compiler consistently across the existing build and test entry points.

Go 1.27 upgrades the Unicode data and the DEFLATE encoder. A shutdown upgrade of the original candidate changed generated keys, folded distinct table and column names together, and changed ENUM input resolution. Keep the 4.2 release's Unicode 15.0 rules for case conversion, matching, identifier and type resolution, and full-text tokenization and lookup. The parser, catalog, DML binder, and storage readers share the same name mapping. Keep the raw DEFLATE bytes emitted by 4.2.9 for COMPRESS. The pinned implementations and their conformance corpus come from the official Go 1.26.4 distribution. The SQL decoder uses the current standard library. See the source and regeneration notes.

Add COMPRESS_V2(value) for applications that want the faster encoder. The function binds once to level 6 of the existing klauspost/compress v1.18.7 dependency and reuses its writer across a vector. Stored expressions persist distinct IDs for the two writers. UNCOMPRESS_V2(value) returns a binary BLOB and reads a complete V1 or V2 stream, including multi-block data. It validates the declared length, the 64 MiB decoded BLOB limit, and the end of the stream. Existing COMPRESS and UNCOMPRESS keep their released semantics in every database.

For REMAP documents of the wrong JSON type, report the expected JSON shape using a MatrixOne error. Retain the invalid-input error class and cover both arrays and scalars.

Validation

  • The Unicode mappings and fold cycles agree with Go 1.26.4 across the complete rune range. A separate comparison matched regex results across the selected corpus and kept the full compressed stream identical in 48 cases.
  • The pinned package conformance suites passed under Go 1.27.1 in normal and race modes. The CI coverage parser measured 87.8% changed-code coverage for the pinned packages locally.
  • Focused frontend, parser, type, planner, function, storage, and full-text tests passed. Incremental static analysis reported zero issues.
  • The generated-column, REMAP error, COMPRESS, and stored-procedure BVTs passed 433 statements with two existing skips, including exact V2 bytes and binary round trips. Incremental static analysis on the additional changes reported zero issues.
  • A real shutdown upgrade on Darwin/arm64 used the v4.2.9 release source built with Go 1.26.4 and this revision built with Go 1.27.1. The old instance flushed its data and stopped. The upgraded instance reopened the same data directory and matched every comparison, including existing full-text postings, distinct identifiers, ENUM/SET values, and exact COMPRESS bytes. New writes and column renaming succeeded, and all four generated unique indexes continued to reject duplicates.

Compatibility and workload measurements

Go 1.26.4 returns two distinct values for session variables and prepared statements named Ɤ and ɤ. The first compatibility revision returned the second value for both names, and a stored procedure with both parameter names failed to bind. The session, procedure interpreter, and binder now share the 4.2 name mapping. The same rule covers SQL column identities in the MongoDB and Iceberg read and write paths. Before this change, a component-level projection of the two columns returned a duplicate mapping error in MongoDB and positions [0,0] in an Iceberg replacement batch. The release and this revision both produce the requested order [1,0]. The full connector package tests and the focused planner, compiler, executor, and frontend tests passed.

SQL COMPRESS now reuses a writer and output buffer within each vector. The writer is initialized on the first evaluated, non-NULL value. The 4.2 byte stream is preserved for every call. All 16 complete compressed streams for 256 KiB values matched the old toolchain byte for byte and decoded independently.

These single-client SQL timings used a Darwin/arm64 CN, TN, and LogService on the same machine, with identical data and native libraries. All three variants use application base 34b63d72614b. The middle column includes only the toolchain, Sonic, and SIMD port. Each variant ran twice in reverse order with fresh data. Ordinary statements and the synthetic compression workloads have 40 timed samples per variant. The file workloads have 48 per variant and use repository fixtures. The compression rows below use the default COMPRESS on each version. Numbers are end-to-end medians in milliseconds.

SQL workload Go 1.26.4 base Go 1.27.1 native This PR
Primary key lookup per statement 0.141 0.143 0.140
Aggregate over a range of 14,336 rows 0.726 0.755 0.703
Insert 64 rows 5.756 6.040 5.795
Update 64 rows 6.176 5.920 6.045
Create and drop a table 16.514 15.700 16.044
Full-text query 2.020 1.999 1.986
Case-insensitive REGEXP on 16,384 rows 8.239 7.923 7.925
Compress 256 short strings 5.101 9.335 3.234
Compress 256 strings of about 4 KiB 6.275 15.184 5.016
Compress eight repetitive 256 KiB BLOBs 3.395 2.800 3.288
Compress eight random 256 KiB BLOBs 18.902 2.199 18.732
Compress one JPEG 0.853 0.366 0.843
Compress one PNG 1.259 0.866 1.268
Compress the gzip CSV fixture 3.585 1.958 3.568
Insert the compressed gzip fixture into a BLOB column 9.035 7.043 8.739

In a separate four-client mixed read/write run, 480 samples per query type gave these native-to-PR medians. Full-text search took 7.293 and 7.324 ms, primary key reads took 0.216 and 0.238 ms, and updates took 9.932 and 10.186 ms. The samples establish local behavior only.

Why V2 is explicit

A local shutdown upgrade from v4.2.9 to unmodified Go 1.27 compression reproduced two application-visible failures with the same 40 ASCII A characters. The old encoder emits 13 bytes and the new one 51.

  • With a stored unique column k = HEX(COMPRESS(s)), a lookup by recomputing the key went from one match to zero. Reinserting the identical source with a different row ID went from duplicate error 1062 to success. Both rows had distinct compressed keys.
  • A plain VARBINARY(32) column accepted the original compressed value. On the new encoder the identical insert failed with error 20101. The previously stored value still decompressed to all 40 bytes.

On this PR, the same physical upgrade preserved lookups and duplicate rejection for the original expression. A new stored unique column using COMPRESS_V2 kept its distinct bytes and rejected duplicates after restart. Recreating each table from its SHOW CREATE TABLE output also preserved these properties. A fixture with 19 binary rows, including 17 values of 256 KiB, recovered every original via UNCOMPRESS_V2 from both encoders and via Python's raw DEFLATE reader. The existing UNCOMPRESS returned NULL for the 17 multi-block values. A logical restore of a V2 expression requires a target that supports the V2 SQL function. Upstream main at 38c68d02ca62 currently exposes only the original names. The full SQL function package, focused race tests, and incremental static analysis passed locally.

Opt-in encoder performance

These are local SQL p50 / p95 times in milliseconds, with 48 timed samples per cell. The same Darwin/arm64 host ran the stock Go 1.27.1 build and the candidate in forward and reverse order. On the candidate the two function names were randomly interleaved. The file fixtures are a 55,886-byte JPEG and a 1,228,780-byte gzipped CSV.

Workload Native Go 1.27.1 PR COMPRESS PR COMPRESS_V2
256 short strings 14.687/32.705 3.566/4.720 0.331/0.968
Eight repetitive 256 KiB BLOBs 2.779/5.014 3.632/6.143 1.933/3.442
Eight random 256 KiB BLOBs 2.215/3.750 19.533/23.319 1.982/3.770
JPEG 0.392/1.926 1.013/1.373 0.467/1.050
Gzipped CSV 2.047/8.031 4.041/5.817 1.935/2.867
INSERT SELECT on gzipped CSV 7.781/11.505 9.829/14.434 7.388/9.780

All 18 file and BLOB outputs in this run matched the native Go 1.27.1 bytes. A separate encoder corpus also matched across arm64 and amd64. V2 output is defined by its pinned encoder and level.

Single-row and batch inserts of article text

A single client compressed 2,000 uncompressed Chinese and English Wikipedia excerpts on the same Go 1.27.1 server. Each pair used the same input for both encoders. A second run used a fresh database and reversed the starting order. Each cell reports the end-to-end p50 / p95 in milliseconds across 128 timed statements. English fixture · Chinese fixture

SQL workload COMPRESS COMPRESS_V2 Median time saved
Compress and insert one article excerpt 5.333 / 8.682 5.254 / 8.492 1.5%
Compress and insert 256 excerpts with INSERT ... SELECT 16.187 / 23.838 11.042 / 15.589 31.8%
Compress 256 excerpts and sum their encoded lengths 9.533 / 10.861 4.561 / 6.621 52.2%

The 2,000 excerpts occupied 2,236,712 bytes before compression. V1 produced 1,341,213 bytes and V2 produced 1,343,526 bytes (+0.17%). Both round-tripped all 2,000 values. These measurements support explicit V2 for batch compression. Single-row writes showed little change.

Port the amd64 vector kernels to the Go 1.27 experimental SIMD API and select the Go 1.27.1 compiler for source and CI image builds. Raise the nested Iceberg module minimum and use the same Sonic and golangci-lint versions as main.
@XuPeng-SH
XuPeng-SH requested a review from fengttt as a code owner November 30, 2026 17:17
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify

mergify Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions

@XuPeng-SH

XuPeng-SH commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: 34a7934d7cc56ee33a372a5ded065a1915a914dd

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 34a7934d7cc56ee33a372a5ded065a1915a914dd

Assessment: approve

The Go upgrade ports the existing SIMD kernels in place and retains their dispatch and scalar fallbacks. No actionable defects were found.

Model: gpt-6.1-terra / max

Session: 01a22aff-bb68-7e31-ae71-ee4ab48ad9d0 · slot 0 · generation 45

Validation:

  • Isolation preflight and native-artifact provenance checks passed.

  • On Linux/amd64 with Go 1.27.1, the metric package passed in SIMD and scalar modes, including selected AVX-512 and AVX2 comparisons. Forced AVX2 and debug fallback checks also passed.

  • The selected IVF parser and vector-index metadata JSON tests passed. The Iceberg adapter suite passed in default and iceberggo-tagged modes.

  • BuildKit --check passed for the BVT and development Dockerfiles and for the release and cached-build Dockerfiles targeting linux/arm64.

Limitations:

  • BuildKit checks did not build the full images. Darwin/arm64 validation was author-reported and not independently rerun.

  • The debug fallback check ran on AVX-512-capable hardware, so it does not independently prove execution on a CPU without AVX-512.

  • End-to-end CS Coverage toolchain reuse remains unverified: the PR reports that its preflight selected the Shanghai path because of a separate stale fixture. Full PR CI was pending.

@XuPeng-SH
XuPeng-SH marked this pull request as draft November 30, 2026 17:55
@XuPeng-SH
XuPeng-SH marked this pull request as ready for review November 30, 2026 18:14
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH

XuPeng-SH commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: 9fc9a4c1e25a234b7923a056d389c00027b5632a

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 9fc9a4c1e25a234b7923a056d389c00027b5632a

Assessment: request_changes

The pinned Unicode and DEFLATE implementations reuse the released behavior, and the reported compression timings are comparable to the Go 1.26 baseline on the measured workloads. Four correctness gaps remain: COMPRESS can return a malformed NULL vector, and three consumers still use the new runtime’s Unicode case rules. The earlier SIMD approval covered the initial head and does not close these later changes.

Model: gpt-6.1-terra / max

Session: 01a22aff-bb68-7e31-ae71-ee4ab48ad9d0 · slot 0 · generation 45

  • P2 pkg/sql/plan/function/func_unary.go:6025: COMPRESS receives a constant-NULL column vector, such as the null-extended side of a left join whose build side is empty.
    Impact: The result has length zero for a nonempty batch. An INSERT from that join fails with a three-row versus zero-row batch error, and a MINUS query drops the expected NULL result.
    Evidence: opUnaryBytesToBytesWithNullOnError marks the NULL bitmap but does not set the varlena result length in its constant-NULL branch. The current-head SQL probe reproduces both failures in review-join-write.log; restoring the earlier per-row COMPRESS implementation in a control overlay makes both pass. Preserve the result row count for NULL and ignored rows, with regression coverage for the join cases.

  • P2 go.mod:4: A full-text query uses columns named Ɤ and ɤ, which are distinct under the released Unicode rules.
    Impact: Fulltext2 can return a different included column’s value or select the index for the wrong MATCH column, producing incorrect query results.
    Evidence: Go 1.27 folds these names together. pkg/sql/plan/apply_indices_fulltext.go:964, :979, and :1153 still use strings.ToLower for covered-column mapping, and :1349 uses strings.EqualFold for index matching. The current-head SQL probe returns 11 instead of the requested column’s 99 and selects the wrong MATCH index. Use the release-compatible case helpers throughout these full-text planner paths.

  • P2 go.mod:4: An existing Parquet file contains both Ɤ and ɤ as column names and is read through an external table.
    Impact: A query fails with an ambiguous-column error even when it requests an exact column name; the same names were distinct under Go 1.26.4.
    Evidence: pkg/sql/colexec/external/parquet.go:268 and :282 still build and query their folded-name map with strings.ToLower. The current-head public-SQL probe creates a Parquet file with these two fields and reproduces the error. Use the 4.2-compatible mapping for both map construction and lookup.

  • P2 go.mod:4: mo_table_col_min or mo_table_col_max is called for ɤ in a table that also has a distinct Ɤ column.
    Impact: The function can return the other column’s statistics, giving callers an incorrect minimum or maximum.
    Evidence: pkg/sql/plan/function/func_mo.go:864 still selects the first column using strings.EqualFold. After flushing rows (1,99) and (2,100), the current-head probe returns 1 rather than 99 for mo_table_col_min on ɤ. Use the release-compatible equality rule for this lookup.

Validation:

  • Isolation preflight and native-input provenance passed; receipts are checks/1796068797950148470-3.json and checks/1796068803561152350-3.json.

  • Go 1.26.4 and Go 1.27.1 controls confirmed the case-folding difference; logs are case-go126-head.log and case-go127-head.log, with receipts checks/1796069925912639505-3.json and checks/1796069934061413403-3.json.

  • The current-head public-SQL Unicode probe reproduced the full-text, statistics, and Parquet failures; review-final-unicode.log and checks/1796070182295058307-3.json record the failing run. Its ILIKE, generated-key, and ordinary compression controls passed.

  • The current-head compression join probe failed as described in review-join-write.log, receipt checks/1796069839196149732-3.json. A control overlay restoring the earlier COMPRESS implementation passed the same executor and SQL probes; review-compress-control.log and checks/1796070083691372980-3.json.

  • Focused Iceberg MERGE planner probes passed within the mixed-result run recorded in review-tests-auto.log. The checkout remained unchanged.

Limitations:

  • The v4.2.9 shutdown upgrade, broader BVT results, and workload timings are author-reported; they were not independently rerun.

  • The local checkout does not contain a v4.2.9 tag, so its exact release source and any later applicable hotfixes could not be independently verified from the available snapshot.

  • The earlier published SIMD assessment applies to its earlier head; the full CI suite was not rerun.

@XuPeng-SH

XuPeng-SH commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · superseded

Commit: 30e84debc6a50dad0d846577dcc997fb895c242f

linked issue or PR description changed before publication

@XuPeng-SH

XuPeng-SH commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · superseded

Commit: 30e84debc6a50dad0d846577dcc997fb895c242f

linked issue or PR description changed before publication

@XuPeng-SH

XuPeng-SH commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: 30e84debc6a50dad0d846577dcc997fb895c242f

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 30e84debc6a50dad0d846577dcc997fb895c242f

Assessment: request_changes

The four previously reported SQL regressions remain open on this unchanged head, and MongoDB SHOW CREATE can also change column mappings. The new target branch additionally assigns the same function ID as COMPRESS_V2, creating an integration conflict. The pinned compatibility fork and distinct encoder identities are reasonable approaches to preserving released behavior, but their integration needs correction. The author’s proposed standalone compression split is not yet present in the frozen target.

Model: gpt-6.1-terra / max

Session: 01a22b07-00b6-7e32-b0a1-3099d0b867c7 · slot 1 · generation 39

  • P2 pkg/sql/plan/function/function_id.go:827: Integrating this head with target d497cc1 while retaining both new function registrations.
    Impact: COMPRESS_V2 and the target’s IVF_EXACT_PK_IN both use ID 638. The three-way merge conflicts in the ID registry and its test; retaining both IDs would make the later IVF registration overwrite the compression registration.
    Evidence: The target’s function_id.go assigns IVF_EXACT_PK_IN=638, and function.go indexes both builtin groups into the same array. merge-tree.txt and audit-target-registry.log record the conflict and registration order. Allocate distinct identities when landing the compression split and rebasing, preserving any identities already required by supported persisted data.

  • P2 pkg/sql/plan/function/func_unary.go:6043: COMPRESS receives a constant-NULL vector, such as the null-extended side of a left join with no matching rows.
    Impact: The result has length zero for a nonempty batch. INSERT ... SELECT fails with a batch-length error, and MINUS can omit the expected NULL row. COMPRESS_V2 and malformed constant UNCOMPRESS_V2 input reach the same helper.
    Evidence: The helper marks NULL bits without appending result rows. The retained same-head SQL and vector probes reproduce the failures, while a target-base COMPRESS control returns three NULL rows. Preserve the requested result length for NULL, invalid and ignored rows; see reused/review-regressions.log, reused/v2-null.log and reused/compress-base-control.log.

  • P2 go.mod:4: A fulltext2 query uses distinct columns named Ɤ and ɤ in a covered projection or MATCH index selection.
    Impact: The query can return another column’s value or search the wrong index. The same-head SQL probe returns 11 instead of 99 and selects the wrong MATCH index.
    Evidence: Go 1.27 folds these names together, while the released Unicode rules keep them distinct. pkg/sql/plan/apply_indices_fulltext.go still uses runtime case operations for matching, as does the included-column mapping in pkg/sql/colexec/table_function/fulltext2_search.go. Apply the release-compatible mapping throughout these paths; the new target’s prefilter changes do not replace those lookups.

  • P2 go.mod:4: An existing Parquet file contains both Ɤ and ɤ as distinct field names and an external table reads them.
    Impact: The read fails with an ambiguous-column error even when the query requests the exact field names.
    Evidence: pkg/sql/colexec/external/parquet.go builds and queries its folded-name map with Go 1.27 strings.ToLower. The retained public SQL probe reproduces the ambiguity. Use the release-compatible mapping for both map construction and lookup.

  • P2 go.mod:4: mo_table_col_min or mo_table_col_max is called for ɤ in a table that also contains a distinct Ɤ column.
    Impact: The function can return the other column’s statistics. After flushing rows (1,99) and (2,100), the probe returns 1 instead of 99 for the minimum of ɤ.
    Evidence: pkg/sql/plan/function/func_mo.go:864 still selects the first matching column using Go 1.27 strings.EqualFold. Use the release-compatible equality rule; see reused/review-regressions.log.

  • P2 go.mod:4: SHOW CREATE TABLE renders a MongoDB external table with distinct Ɤ and ɤ columns mapped to different MongoDB paths.
    Impact: The rendered DDL assigns the second path to both columns. Restoring that DDL changes the source field used for the first column.
    Evidence: pkg/sql/plan/build_show_util.go:121 and :266 use runtime strings.ToLower while the MongoDB planner preserves these names separately. The retained DDL planner probe reproduces the wrong output; ASCII and compatibility-mapping controls pass. Use the release-compatible mapping for both construction and lookup.

Validation:

  • Current isolation preflight passed. An audit verified the identical head and patch, copied prior receipts and logs, and relevant unchanged target-base control inputs; receipt checks/1796094536966254587-3.json.

  • Reused exact-head evidence includes the failing public SQL and NULL-vector probes, passing target-base COMPRESS control, MongoDB DDL and control probes, V2 functional checks, and the sqlcompat suites. Their original receipts and logs are retained under reused/.

  • The retained generated-source comparison verified 99 files against the pinned Go 1.26.4 generator output. Earlier SIMD and build-check evidence applies to unchanged inputs.

  • A current source audit confirmed the target registry collision and three-way merge conflicts; receipt checks/1796094611603839530-3.json. No merged-binary failure is claimed.

  • The first evidence-audit attempt failed because its command-substring assertion omitted the test selector’s regex grouping; the corrected audit passed.

Limitations:

  • The assigned checkout did not contain a v4.2.9 tag or release binary. The author-reported shutdown upgrade, full BVT runs and workload measurements were not independently verified.

  • No new Go tests were run in this attempt; matching tests from the preceding same-head review were reused after auditing their inputs, receipts and logs.

  • The proposed standalone compression change and subsequent rebase are not present in the frozen target, so their eventual implementation and merged execution remain to be reviewed.

XuPeng-SH added a commit that referenced this pull request Dec 1, 2026
## What type of PR is this?

- [x] BUG
- [x] Improvement
- [x] Feature

## Which issue(s) this PR fixes:

issue #33557

## What this PR does / why we need it:

Go 1.27.1 changes the raw DEFLATE bytes produced for the same input. A
shutdown upgrade changed the output of `COMPRESS(REPEAT('A', 40))` from
13 to 51 bytes, so an existing generated unique key could be missed.
This change freezes the released 4.2 encoder, preserves the framing and
existing SQL identity of `COMPRESS()`, and reuses the writer within each
vector.

Add explicit `COMPRESS_V2()` using the existing klauspost/compress
v1.18.7 dependency at level 6 and `UNCOMPRESS_V2()` to decode complete
V1 and V2 streams into a BLOB. The V2 decoder verifies the declared
length and stream end, with a 64 MiB decoded-size limit.

The shared byte-function template preserves the input row count for
constant NULL, constant evaluation errors, and empty selections. Skipped
rows carry only NULL, and reused flat NULL results clear previous
descriptors before serialization.

| Function | Persistent ID |
| --- | ---: |
| `COMPRESS_V2()` | 639 |
| `UNCOMPRESS_V2()` | 640 |

Both V2 functions register overloads in the order VARCHAR, CHAR, TEXT,
BLOB. The IDs were checked against `4.2-dev` and `main` and are recorded
in #33558. ID 638 belongs to `IVF_EXACT_PK_IN`. The original
`UNCOMPRESS()` repair is tracked in #33555.

## Validation

- Go 1.26.4 function-package race tests and Go 1.27.1 compression and
function-ID race tests passed. The compression SQL BVT passed 73 cases
on each toolchain with 2 existing skips.
- The private writer matched all 697 reference frames from Go 1.26.4,
including inputs that cross the window and hash-offset limits. The CI
coverage parser reported 83.23% changed-block coverage on the local
race-test profile.
- Reopened a data directory written by the official v4.2.9 binary. V1
generated unique keys matched and rejected duplicate inserts with error
1062. Stored expressions using both V2 functions survived the toolchain
change, writes, restart, and logical restore.
- Local incremental static analysis, Go vet, molint, error constructor
checks, and source license checks passed.
- The 256-row article-text SQL p50 was 19.41 ms on the Go 1.26.4 base,
9.72 ms for pinned V1, and 4.96 ms for V2. Single-row SQL was 0.530 ms
on the base and 0.532 ms for pinned V1. The batch sizes were 89,977
bytes for both V1 builds and 89,322 bytes for V2. The Go 1.27.1
derivative preserved the exact V1 and V2 frames.

- The NULL-result follow-up in `4832b41066` preserves both rows in the
reported `LEFT JOIN`/`INSERT` and the expected NULL row in `MINUS`.
Vector and function race tests passed on Go 1.26.4, with focused race
tests on Go 1.27.1. The compression BVT passed twice on local macOS
arm64 with 80 passes and 2 existing skips per run. Pinned molint and
incremental lint passed for the affected packages. [Review
finding](#33563 (review))

Merge this standalone change ahead of the toolchain upgrade in #33538.
XuPeng-SH added a commit that referenced this pull request Dec 1, 2026
…33564)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes #33559

## What this PR does / why we need it:

4.2.9 used Unicode 15.0. The Unicode 17.0 tables in Go 1.27.1 can
collapse released identifiers such as `Ɤ` and `ɤ`, changing which
columns, generated keys and full-text postings a query finds. Land this
standalone compatibility fix on `4.2-dev` with Go 1.26.4 before #33538.

- Pin the SQL casing, simple folding and classification operations to
one reproducible copy of the Go 1.26.4 Unicode data. The regexp compiler
and matcher use the same data. Full-text indexing and query construction
share the release tokenizer rules.
- Apply the existing lookup semantics across catalog, publication DDL,
SQL expressions, ENUM and SET, feature quotas, and connector fields.
FULLTEXT2 uses bound column identities for MATCH and covered
projections. Catalog queries quote names with the SQL literal encoder so
lookup and deletion preserve the accepted name bytes.
- Keep the upstream license, generator and conformance corpus in the
private compatibility package. The source requires no data rewrite.
- Preserve the same SQL identity in partition pruning, generated-key
ODKU workspace reads, and checkpoint restore DDL. Scope the embedded
clone inventory deadline to each scenario.
- Use the released printability rules for JSON_QUOTE literal escaping.
On a failed explicit-transaction clone test, the enclosing rollback owns
cleanup of the shared connection.

## Validation

### JSON_QUOTE and clone cleanup follow-up

- Reopened a v4.2.9 store with a stored JSON_QUOTE expression on both Go
toolchains. Both rejected the same input with the release error and
retained the existing row. Accepted BMP and supplementary controls wrote
successfully. The full Unicode scalar corpus and all two-byte inputs
matched the Go 1.26.4 quoting oracle.
- The updated SQL BVT passed 62/62 on each toolchain. The prior Go
1.27.1 build failed the rejection and persisted-row assertions. All 13
clone scenarios passed with the race detector, and fault injection
confirmed the enclosing rollback after a child failure. Scoped static
analysis and license headers passed.

### Rebased head

- Rebased on `4.2-dev` at `fa22bd6c9f`. Built on Go 1.26.4 and 1.27.1
and ran the Unicode SQL BVT on each (58/58 statements). The earlier Go
1.27.1 build omitted a matching partition row and rejected an ODKU on a
generated unique key. Both corrected builds returned the expected row
and updated the existing workspace row.
- Exported a v4.2.9 checkpoint with both versions of `mo-tool`. The
previous Go 1.27.1 tool generated DDL with the primary key on the wrong
column. The corrected tool preserved the primary key, two unique keys
and two foreign keys. Executed its restore script, checked the restored
rows, and verified rejection of a duplicate key and violations of each
foreign key. The corrected server also reopened the release store
successfully.
- Loaded a v4.2.9 DUMP TABLE SET archive on Go 1.27.1. Verified that the
original domain loaded with the same value and the other domain rejected
the archive and stayed empty.
- All 13 clone inventory scenarios passed on Go 1.26.4 with and without
the race detector. A local delay experiment reproduced both late
deadline failures before the fix and both scenarios passed after it.
Targeted Go packages passed on both toolchains, including
partitionprune, checkpointtool, the ckp command and the Unicode
compatibility packages.
- Local race checks also passed for workspace reads and dump
fingerprints. Identifier comparison benchmarks on Go 1.27.1 used zero
allocations in each case. The same-case ASCII median was 9.4 ns for the
host comparison and 10.7 ns for the pinned comparison.
- Full local static analysis ran with the CI versions of Go and
golangci-lint and reported 0 issues. Formatting and license-header
checks passed.

### Earlier validation

- Built the reviewed source with Go 1.26.4 and 1.27.1. BVT passed
132/132 statements on 1.26.4 (Unicode SQL, REMAP errors and feature
quotas) and 48/48 Unicode statements on 1.27.1.
- Flushed and stopped the official v4.2.9 server, then opened its store
with the Go 1.27.1 build. Released rows, generated keys, full-text
results and quota keys matched. Duplicate writes and a forbidden scope
were rejected. Valid inserts and updates survived restart, and a logical
dump restored into a fresh instance with the expected results.
- Local race tests passed across 35 affected packages and direct
consumers. The Go 1.27.1 publication control reproduces the missing
ALTER on the clean base and passes with this change. The repository SCA
selected the full graph for the license configuration and reported zero
golangci-lint issues.
- On Go 1.26.4 with 8,192 rows, SQL p50 was 1.76 → 1.49 ms for ASCII
LOWER, 3.12 → 3.07 ms for mixed LOWER, 2.74 → 2.81 ms for ILIKE and 4.25
→ 4.19 ms for regex. The casing and regexp microbenchmarks and the
full-text tokenizer/query benchmarks retained their measured allocation
counts and bytes. One ASCII byte-mapping microbenchmark was about 7%
slower.

This branch had an error being deployed

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

Labels

kind/api-change kind/bug Something isn't working kind/enhancement kind/feature kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants