You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Compatibility]: SPACE rejects result lengths above 65,535 that MySQL returns #30186
MatrixOne local runtime: commit 2ce4e58af6f03b943ee288ffad81012766cf830a
MySQL: 8.0.46
Client: mysql CLI over the MySQL protocol
Current local origin/main: 944b721d1b3705cdb51d1e26f1a04611a08c8401; the relevant func_unary.go and list_builtIn.go files are unchanged between the runtime build and this main commit.
Behavior
MySQL returns strings longer than 65,535 characters from SPACE(); MatrixOne rejects the same input with error 20301.
Query
MatrixOne
MySQL 8.0.46
SELECT LENGTH(SPACE(65535))
65535
65535
SELECT LENGTH(SPACE(65536))
error: the space count is greater than max allowed value 65535
65536
SELECT LENGTH(SPACE(100000))
same error
100000
SELECT LENGTH(SPACE(n)) FROM (SELECT 65536 AS n) q
same error
65536
SQL PREPARE / EXECUTE with 65536
same error
65536
This is specific to SPACE() in the tested range: REPEAT('x',100000), LPAD('a',100000,'x'), and RPAD('a',100000,'x') return length 100000 in both engines.
Reproduction
SELECT LENGTH(SPACE(65535));
SELECT LENGTH(SPACE(65536));
SELECT LENGTH(SPACE(100000));
SELECT LENGTH(SPACE(n)) FROM (SELECT65536AS n) q;
PREPARE p FROM'SELECT LENGTH(SPACE(?))';
SET @n =65536;
EXECUTE p USING @n;
DEALLOCATE PREPARE p;
Cause and expected behavior
The current implementation sets the maximum to types.MaxVarcharLen (65,535) and rejects larger counts in FillSpaceNumber in pkg/sql/plan/function/func_unary.go. The compatibility contract and existing issue search did not identify this as a documented exception. MySQL returns the requested space string for these values (within the server's packet limits), so MatrixOne's hard function-level cap is observable on literal, column-driven, and SQL prepared execution paths.
Expected: for counts above 65,535 that are otherwise within MatrixOne's supported string/result limits, SPACE(n) should return the requested number of spaces as MySQL does, or the limit should be documented as an explicit compatibility exception.
Regression and extended verification for #30186 (2026-10-16)
Verification Environment
MatrixOne origin/main: b24d1b311555e0b6f3d56eb37f9a2e9617e9a5b7 — fix(window): support temporal interval frame parameters and string parsing (#30310). The clean source worktree at this commit produced Docker image sha256:995ad135dbc97c2c14619c0b5d1b4f7967628430eb46776eab0cc31a46eacbc5; the running Log, TN, both CNs, and Proxy used that same image. The image's embedded git_version field was empty because the isolated worktree's .git pointer was outside the Docker build context, so source commit, image ID, and container image IDs were checked directly.
Local topology: 2 CN / 1 TN / 1 Log service / 1 Proxy. All MySQL endpoints were reachable: Proxy 127.0.0.1:6851 (container port 6009), CN1 127.0.0.1:16851 (container port 16001), and CN2 127.0.0.1:16852 (container port 16002). The original SQL was actually executed through all three endpoints, not merely health-checked. MOTR used the Proxy.
MySQL 8.0.46 was run locally as the compatibility control. Direct checks used PyMySQL over the MySQL text protocol and SQL PREPARE/EXECUTE; the MOTR protocol case used Go's MySQL driver with actual binary COM_STMT_PREPARE/COM_STMT_EXECUTE and parameter interpolation disabled.
What Was Covered
OK — Original literals: LENGTH(SPACE(65535)), LENGTH(SPACE(65536)), and LENGTH(SPACE(100000)) returned 65535, 65536, and 100000 on Proxy, CN1, CN2, and MySQL 8.0.46. SPACE(100000) was also fetched and checked as an actual 100000-character all-space value, not only through LENGTH.
OK — Column-driven SPACE(n) and SQL-prepared EXECUTE ... USING @n at 65536 and 100000 passed. A native binary prepared statement was reused at both lengths; its complete payload and LONGTEXT result metadata passed, including reuse after an expected oversized error.
OK — Boundary and unhappy paths: 65535/65536 cross the former cap; 1048576 passed on all three MatrixOne endpoints and MySQL; SPACE(67108865) returned MatrixOne error 20301 for the new 67108864-byte cap, and the same connections remained usable. SPACE(-1), SPACE(0), SPACE(NULL), fractional SPACE(1.5), and REPEAT/LPAD/RPAD controls retained their expected behavior.
Not covered — The exact 67108864-byte successful result, exhaustive counts below the new cap, a full BVT/TKE run, long-running memory/spill behavior, and engine-internal parallel execution. MOTR -j 2 was case scheduling only.
Findings
Fixed on the tested main: the reported 65536-character and 100000-character SPACE calls no longer return the old 20301 rejection. The result is usable over both text and binary-prepared MySQL protocol paths.
Associated fix: MatrixOne PR #30207, merged as 9b315bf06dcb79d16835fecc558b238db6f3dfe6 (fix(function): support large SPACE results (#30207)). It removes the incorrect 65535-character VARCHAR cap for generated SPACE results, declares LONGTEXT result metadata, and retains a finite 64 MiB limit.
Large-data regression: no large row-count workload is needed. This bug depends on result byte length, so the relevant size boundary was tested with minimal deterministic inputs (65535 versus 65536, 100000, 1048576, and rejection at 67108865). The exact maximum-size successful allocation and sustained memory/spill behavior remain outside this focused regression.
MOTR / BVT Coverage
MOTR branch test/issue-30186-space-large-result was created from MOTR origin/main4fd475a39876cdbd8aec5a025b9826a74a1cc48b. Independent commit 21e0e1642eee329d83c2dfe5e2cb0e4a1536c9a0 (test: add MOTR regression for #30186) adds a SQL .test/.result pair and a configurable Go binary-protocol case. No MatrixOne service source was changed.
Final MOTR recording and replay both passed: 2/2 cases, 14/14 checks, 0 failed/skipped. The daily cherry-pick 5cd0da48b36c334efa4517306cc5c4bb7374598c was separately replayed with the same result on the daily MOTR PR #246 branch. The SQL and protocol cases have no shared persistent fixture, so -j 2 case scheduling is safe; it does not prove engine parallelism.
PR fix(function): support large SPACE results #30207 reports a focused func_string_space BVT pass (70/70) on its fix tree. I did not rerun mo-tester or the full BVT suite on this latest main; the direct three-endpoint checks and MOTR runs above are this verification's evidence.
Final Conclusion
Fixed on MatrixOne mainb24d1b311555e0b6f3d56eb37f9a2e9617e9a5b7 for the reported MySQL compatibility boundary. Original, prepared, actual-payload, metadata, negative-limit, and control cases passed. A large row-count regression is unnecessary; focused result-size boundary coverage was completed.
Activity
fix(function): support large SPACE results (#30207)
slyunnn commentedon Oct 16, 2026
Regression and extended verification for #30186 (2026-10-16)
Verification Environment
origin/main:b24d1b311555e0b6f3d56eb37f9a2e9617e9a5b7—fix(window): support temporal interval frame parameters and string parsing (#30310). The clean source worktree at this commit produced Docker imagesha256:995ad135dbc97c2c14619c0b5d1b4f7967628430eb46776eab0cc31a46eacbc5; the running Log, TN, both CNs, and Proxy used that same image. The image's embeddedgit_versionfield was empty because the isolated worktree's.gitpointer was outside the Docker build context, so source commit, image ID, and container image IDs were checked directly.2CN /1TN /1Log service /1Proxy. All MySQL endpoints were reachable: Proxy127.0.0.1:6851(container port6009), CN1127.0.0.1:16851(container port16001), and CN2127.0.0.1:16852(container port16002). The original SQL was actually executed through all three endpoints, not merely health-checked. MOTR used the Proxy.8.0.46was run locally as the compatibility control. Direct checks used PyMySQL over the MySQL text protocol and SQLPREPARE/EXECUTE; the MOTR protocol case used Go's MySQL driver with actual binaryCOM_STMT_PREPARE/COM_STMT_EXECUTEand parameter interpolation disabled.What Was Covered
LENGTH(SPACE(65535)),LENGTH(SPACE(65536)), andLENGTH(SPACE(100000))returned65535,65536, and100000on Proxy, CN1, CN2, and MySQL8.0.46.SPACE(100000)was also fetched and checked as an actual100000-character all-space value, not only throughLENGTH.SPACE(n)and SQL-preparedEXECUTE ... USING @nat65536and100000passed. A native binary prepared statement was reused at both lengths; its complete payload andLONGTEXTresult metadata passed, including reuse after an expected oversized error.65535/65536cross the former cap;1048576passed on all three MatrixOne endpoints and MySQL;SPACE(67108865)returned MatrixOne error20301for the new67108864-byte cap, and the same connections remained usable.SPACE(-1),SPACE(0),SPACE(NULL), fractionalSPACE(1.5), andREPEAT/LPAD/RPADcontrols retained their expected behavior.67108864-byte successful result, exhaustive counts below the new cap, a full BVT/TKE run, long-running memory/spill behavior, and engine-internal parallel execution. MOTR-j 2was case scheduling only.Findings
main: the reported65536-character and100000-characterSPACEcalls no longer return the old20301rejection. The result is usable over both text and binary-prepared MySQL protocol paths.9b315bf06dcb79d16835fecc558b238db6f3dfe6(fix(function): support large SPACE results (#30207)). It removes the incorrect65535-characterVARCHARcap for generatedSPACEresults, declaresLONGTEXTresult metadata, and retains a finite64 MiBlimit.65535versus65536,100000,1048576, and rejection at67108865). The exact maximum-size successful allocation and sustained memory/spill behavior remain outside this focused regression.MOTR / BVT Coverage
test/issue-30186-space-large-resultwas created from MOTRorigin/main4fd475a39876cdbd8aec5a025b9826a74a1cc48b. Independent commit21e0e1642eee329d83c2dfe5e2cb0e4a1536c9a0(test: add MOTR regression for #30186) adds a SQL.test/.resultpair and a configurable Go binary-protocol case. No MatrixOne service source was changed.2/2cases,14/14checks,0failed/skipped. The daily cherry-pick5cd0da48b36c334efa4517306cc5c4bb7374598cwas separately replayed with the same result on the daily MOTR PR #246 branch. The SQL and protocol cases have no shared persistent fixture, so-j 2case scheduling is safe; it does not prove engine parallelism.func_string_spaceBVT pass (70/70) on its fix tree. I did not rerun mo-tester or the full BVT suite on this latestmain; the direct three-endpoint checks and MOTR runs above are this verification's evidence.Final Conclusion
Fixed on MatrixOne
mainb24d1b311555e0b6f3d56eb37f9a2e9617e9a5b7for the reported MySQL compatibility boundary. Original, prepared, actual-payload, metadata, negative-limit, and control cases passed. A large row-count regression is unnecessary; focused result-size boundary coverage was completed.