Repository navigation
Description
Parent issue
#32278 (D24, category A). Coordinate the V2 contract with the standalone 4.2-dev work in #33557. The Go 1.27.1 toolchain upgrade is tracked in #33538.
Detail of subtask
The next major release cut from main must carry forward the SQL compression functions and persisted expressions shipped in 4.2.x. Port COMPRESS_V2() and UNCOMPRESS_V2() with the same encoded bytes and stable function/overload identities finalized in #33557. main already reads the legacy raw DEFLATE format, and since #27965 its default COMPRESS() writes MySQL-compatible zlib. Both branches currently use function ID 387 for COMPRESS(). The change in encoder can therefore affect existing 4.2-generated expressions when they are evaluated after an upgrade. Main implementation
Reproduction
Reproduced on local Darwin/arm64 builds of the v4.2.9 release source (6c05e42f9f660a207077b050b8ec285ccf3f8103) and main (38c68d02ca62521e61da7783863ae7bd21ee055a). The test flushed the table, stopped the 4.2 process and reopened the same data directory on main.
CREATE TABLE keys_v1 (
id INT PRIMARY KEY,
s VARCHAR(100),
k VARCHAR(160) GENERATED ALWAYS AS (HEX(COMPRESS(s))) STORED,
UNIQUE KEY uk(k)
);
INSERT INTO keys_v1(id, s) VALUES (1, REPEAT('A', 40));
SELECT LENGTH(COMPRESS(REPEAT('A', 40))),
(SELECT COUNT(*) FROM keys_v1 WHERE k = HEX(COMPRESS(REPEAT('A', 40))));
INSERT INTO keys_v1(id, s) VALUES (2, REPEAT('A', 40));The SELECT returned (13, 1) on v4.2.9 and (57, 0) on main. The second INSERT failed with duplicate-key error 1062 on v4.2.9 and succeeded after the upgrade. The table then contained two rows with identical source text and two different keys. UNCOMPRESS(UNHEX(k)) still recovered all 40 bytes from the original row.
Acceptance
- On
main, expose both V2 SQL functions with the same bytes, return types, and persistent identities as the released 4.2 functions. Check the IDs for collisions before either release ships. Reuse the existing SQL binder, catalog and decoder responsibilities and keep encoder selection out of the per-row path. - Define and verify the release contract for previously persisted V1 expressions, including STORED and VIRTUAL columns, uniqueness, and lookups that recompute compressed keys. Keep
main's MySQL-compatible zlib behavior for new ordinary calls. If a 4.2 predicate or definition requires an explicit migration, specify the supported migration and verify the result against the original data. - Upgrade from the latest official 4.2.x artifact at release time. Flush and reopen the same data directory, verify old and new writes and recomputation, then restart. Cover V1 and V2 values, generated columns with unique indexes, and logical dump/restore of their expressions. Verify decoded bytes, key lookups and duplicate rejection.
- Verify representative SQL CPU and allocation costs for existing
mainzlib calls and for V2. Preserve the existingmainzlib and legacy raw DEFLATE decoding coverage.
Cross-branch function numbering
Allocate each public SQL function that can appear in persisted expressions once across 4.2-dev and main. The same function ID and argument overload IDs must denote the same SQL types and semantics on both branches. Check both registries before allocating an ID and reserve released assignments for the same function for as long as supported artifacts can carry them.
PR #33551 already uses 638 for IVF_EXACT_PK_IN on 4.2-dev. The earlier Go-upgrade draft in #33538 used that number for COMPRESS_V2(). Coordinate COMPRESS_V2() as 639 and UNCOMPRESS_V2() as 640 in #33557 and the main port. For both V2 functions, use argument overload IDs 0 for VARCHAR, 1 for CHAR, 2 for TEXT, and 3 for BLOB. Preserve the released overload order when porting the functions and verify collisions again against the branch tips before release.
Activity
[4.2-dev] fix(sql): preserve COMPRESS bytes and add opt-in V2 (#33563)
fix(sql): preserve 4.2 compression function IDs across ENUM upgrade
fix(sql): preserve 4.2 compression function IDs across ENUM upgrade
docs(skills): strengthen upgrade compatibility checks (#33712)