Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
Other Environment Information
- Hardware parameters: Apple silicon (arm64), 10 cores
- OS type: macOS 15.7
- Others: standalone
mo-servicebuilt from the workspace, MySQL port 26201; Go 1.27.1
Actual Behavior
LOAD DATA from a CSV file stores abc (3 characters) into a CHAR(0) / VARCHAR(0) column:
- Under
sql_mode='STRICT_TRANS_TABLES', the load succeeds instead of failing withData too long. - Under
sql_mode='', the load stores all characters instead of truncating to the empty string.
The equivalent INSERT follows the declared width: strict INSERT fails, and non-strict INSERT stores the empty string.
Expected Behavior
- Zero is a declared CHAR/VARCHAR capacity, as already established for the Parquet path by fix(sql): enforce zero-width parquet text columns #29988.
- Strict server CSV LOAD should reject a nonempty value with
Data too long for column .... - Non-strict and LOCAL CSV LOAD should truncate the value to the empty string.
Steps to Reproduce
CREATE TABLE zc (id INT PRIMARY KEY, v CHAR(0));
-- file with content: 1,abc
SET sql_mode = 'STRICT_TRANS_TABLES';
LOAD DATA INFILE '/path/zerow.csv' INTO TABLE zc
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
SELECT id, HEX(v), CHAR_LENGTH(v) FROM zc;
SET sql_mode = '';
TRUNCATE zc;
LOAD DATA INFILE '/path/zerow.csv' INTO TABLE zc
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
SELECT id, HEX(v), CHAR_LENGTH(v) FROM zc;Expected strict result: statement fails. Expected non-strict result: HEX(v)='', CHAR_LENGTH(v)=0.
Additional information
The CSV text conversion has the same boundary that PR #29988 fixed for Parquet: zero is treated as “unbounded” instead of as a declared capacity.
pkg/sql/colexec/external/external.gotruncateLoadDataStringValuereturns the value unchanged whenwidth <= 0.- The strict CHAR/VARCHAR check a few lines later requires
col.Typ.Width > 0, soCHAR(0)never reachesData too long.
A direct unit regression now reproduces the failure:go test ./pkg/sql/colexec/external -run TestLoomCSVZeroWidthText -count=1
All strict/non-strict/LOCAL cases in that test persist abc; positive-width behavior is unchanged. The new test is pkg/sql/colexec/external/loom_test_zero_width_text_test.go (workspace only).
Found by Loom bug hunt (module: custom-a9872c7d6e; tests: unit, white-box, end-to-end)
Activity
XuPeng-SH commentedon Oct 22, 2026
This report is now tracked together with #30457. The canonical issue retains explicit acceptance cases for the behavior described here. This is an administrative duplicate/consolidation closure only; the underlying defect is not claimed fixed. The original description and discussion remain available on this issue.