Repository navigation
Description
Description
MatrixOne LOAD DATA uses a comma as the default field separator, while MySQL 8.0 uses a tab (\t). For a migration from MySQL this breaks the most common form of the statement — LOAD DATA ... INTO TABLE t with no FIELDS clause — in both directions:
- A tab-separated data file (the format MySQL's default semantics expect) cannot be loaded by MatrixOne.
- A comma-separated data file (which MySQL's default treats as one field per row) is silently split into several columns by MatrixOne.
The same mismatch silently replaces an explicit FIELDS TERMINATED BY '' (MySQL: fixed-row, non-delimited format) with the comma default, because the option is only honored when non-empty.
Environment
- Commit ID: 95341b4
- Branch Name: main (detached HEAD)
- Other Environment Information:
- Hardware: Apple Silicon (darwin/arm64), 10 cores, macOS
- Server: standalone
mo-service -launchbuilt withmake build, launch configs copied frometc/launchinto.loom-test/launch20200/with all ports offset by 20200 (frontend 26201), data dir.loom-test/mo-data20200 - Client: Homebrew
[email protected]CLI (8.0.x):mysql -h 127.0.0.1 -P 26201 -udump -p111 --local-infile=1 -f -N - Comparison server: Homebrew
[email protected](mysqld 8.0.46) started in the workspace via--initialize-insecureon port 23506 withlocal_infile=ON; same client.
Steps to Reproduce
- Create a tab-separated file (tabs between
x,y,z):
printf 'x\ty\tz\np\tq\tr\n' > /tmp/tab3.csv
printf 'x,y,z\np,q,r\n' > /tmp/comma3.csv
od -c /tmp/tab3.csv
# 0000000 x \t y \t z \n p \t q \t r \n- On MatrixOne (fresh standalone instance,
make build):
create database fr4; use fr4;
set sql_mode='STRICT_TRANS_TABLES';
create table t3(a char(5), b char(5), c char(5));
-- (a) Server-side INFILE, no FIELDS clause
load data infile '/tmp/tab3.csv' into table t3;
-- (b) LOCAL INFILE, no FIELDS clause
truncate table t3;
load data local infile '/tmp/tab3.csv' into table t3;
select concat('[',coalesce(a,'N'),']','[',coalesce(b,'N'),']','[',coalesce(c,'N'),']') from t3;
-- (c) LOCAL INFILE, explicit empty terminator
truncate table t3;
load data local infile '/tmp/tab3.csv' into table t3 fields terminated by '';
select concat('[',coalesce(a,'N'),']','[',coalesce(b,'N'),']','[',coalesce(c,'N'),']') from t3;
-- (d) comma-separated file, no FIELDS clause
truncate table t3;
load data local infile '/tmp/comma3.csv' into table t3;
select concat('[',coalesce(a,'N'),']','[',coalesce(b,'N'),']','[',coalesce(c,'N'),']') from t3;- Run steps (a)–(d) identically on MySQL 8.0.46 to compare.
Actual Behavior (MatrixOne)
- (a)
load data infile '/tmp/tab3.csv' into table t3;fails the whole import:
ERROR 20301 (HY000): invalid input: the data of row 1 contained is not equal to input columns
The row is parsed as a single field, so 1 field vs 3 columns is rejected; no rows are loaded.
- (b)
load data local infile(same clause) silently loads each whole line into columnaand leavesb,cNULL — no error, no warning:
===MO_tabfile_LOCAL_default
[x\ty\tz][N][N]
[p\tq\tr][N][N]
- (c)
fields terminated by ''behaves exactly like the default (silent fallback to,) — same[x\ty\tz][N][N]result locally, same ERROR 20301 for server-side INFILE. - (d) The comma file loads as 3 fields per row:
[x][y][z],[p][q][r].
Expected Behavior (MySQL 8.0.46 reference, actually run)
- (a)+(b) The same tab file with no FIELDS clause loads 3 fields per row in both strict and default mode:
MY_tabfile_default [x][y][z]
MY_tabfile_default [p][q][r]
- (c)
fields terminated by ''is accepted (fixed-row format, not an error), loadingafrom the leading bytes per the fixed-row rules. - (d) The comma file is NOT split: each line is one field,
a='x,y,z'(truncated per mode),b/cleft NULL withWarning 1261 Row 1 doesn't contain data for all columns:
MY_commafile_default [x,y,z][N][N]
MY_commafile_default [p,q,r][N][N]
Warning 1261 Row 1 doesn't contain data for all columns
MySQL 8.0 docs (https://dev.mysql.com/doc/refman/8.0/en/load-data.html) define the default as FIELDS TERMINATED BY '\t'. MatrixOne's default of , therefore diverges from the reference engine on the default clause in both directions, and additionally hides the explicit empty terminator.
Root cause / code locations
pkg/sql/parsers/tree/update.go:538—DefaultFieldsTerminated = ","is the constant used whenever noFIELDS TERMINATED BYis given. MySQL's default is a tab.pkg/sql/colexec/external/types.go:492—CSVConfigForLoadseeds the reader config from this constant; it is the authoritative LOAD-clause mapping for both server INFILE and LOCAL INFILE.pkg/sql/colexec/external/types.go:500—if terminated != nil && terminated.Value != ""silently drops an explicitFIELDS TERMINATED BY ''instead of honoring it (MySQL fixes the field/row layout to non-delimited reading for''). The same non-empty-only guard exists in the parallel-reader configuration inpkg/sql/plan/build_load.go(newReaderWithParam, ~L134–190).
Additional information
- Two independent manifestations, one root cause: server-side INFILE aborts the import with ERROR 20301 (loud), LOCAL INFILE inserts whole lines into the first column with NULL-padded trailing columns and no signal at all (silent data misplacement — the dangerous one, because the load "succeeds").
- A workaround exists (
FIELDS TERMINATED BY '\t'explicitly, which loads correctly in MatrixOne — verified[x][y][z]/[p][q][r]), hence severity s1 rather than s0. - Recommended fix: change
tree.DefaultFieldsTerminatedto"\t"to match MySQL, and treat an explicitFIELDS TERMINATED BY ''as the fixed-row configuration instead of silently falling back to the default. Changing the default separator alters the interpretation of previously-loaded comma files, so a compatibility/announcement note is advised; however matching the documented reference-engine default is the correct long-term behavior, and existing scripts that rely on comma can be made explicit withFIELDS TERMINATED BY ','which already works. - The LOCAL-vs-server inconsistency (one errors, the other silently misplaces data for the identical file and clause) suggests the two ingestion paths differ in column-count validation; that inconsistency is itself worth normalizing, but the separator default remains the single root cause addressed here.
- Related but distinct existing issues cover blank-line skipping and ENCLOSED BY ''/line-terminator semantics on CSV readers ([Bug]: CSV readers lose records or ignore enclosure and line-terminator semantics #30329); none of them covers the field-separator default, and I found no issue or PR mentioning the comma-vs-tab default mismatch.
Full reproduction, exactly as Loom ran it
# 1. data files (run in any scratch dir; use an absolute path in the SQL below)
printf 'x\ty\tz\np\tq\tr\n' > /tmp/tab3.csv
printf 'x,y,z\np,q,r\n' > /tmp/comma3.csv
# 2. MatrixOne standalone (built with `make build`, launch configs from etc/launch with port offset 20200, frontend on 26201):
mysql -h 127.0.0.1 -P 26201 -udump -p111 --local-infile=1 -f -N <<'SQL'
drop database if exists fr4; create database fr4; use fr4;
set sql_mode='STRICT_TRANS_TABLES';
create table t3(a char(5), b char(5), c char(5));
load data infile '/tmp/tab3.csv' into table t3;
-- expect: ERROR 20301 (HY000): invalid input: the data of row 1 contained is not equal to input columns
truncate t3;
load data local infile '/tmp/tab3.csv' into table t3;
select concat('[',coalesce(a,'N'),']','[',coalesce(b,'N'),']','[',coalesce(c,'N'),']') from t3;
-- expect (actual MO): [x\ty\tz][N][N] / [p\tq\tr][N][N] (MySQL 8.0: [x][y][z] / [p][q][r])
truncate t3;
load data local infile '/tmp/tab3.csv' into table t3 fields terminated by '';
select concat('[',coalesce(a,'N'),']','[',coalesce(b,'N'),']','[',coalesce(c,'N'),']') from t3;
-- expect (actual MO): identical comma-default fallback: [x\ty\tz][N][N] / [p\tq\tr][N][N]
truncate t3;
load data local infile '/tmp/comma3.csv' into table t3;
select concat('[',coalesce(a,'N'),']','[',coalesce(b,'N'),']','[',coalesce(c,'N'),']') from t3;
-- expect (actual MO, 3 fields split): [x][y][z] / [p][q][r] (MySQL 8.0: one field + Warning 1261)
SQL
# 3. MySQL 8.0.46 reference (Homebrew [email protected], --initialize-insecure, local_infile=ON):
mysql -h 127.0.0.1 -P 23506 -uroot --local-infile=1 -N <<'SQL'
drop database if exists fr; create database fr; use fr;
create table t3(a char(5), b char(5), c char(5));
load data local infile '/tmp/tab3.csv' into table t3;
select 'MY_tabfile_default', concat('[',coalesce(a,'N'),']','[',coalesce(b,'N'),']','[',coalesce(c,'N'),']') from t3;
-- expect: [x][y][z] / [p][q][r] (3 fields, tab default)
set sql_mode='';
truncate t3;
load data local infile '/tmp/comma3.csv' into table t3;
show warnings;
select 'MY_commafile_default', concat('[',coalesce(a,'N'),']','[',coalesce(b,'N'),']','[',coalesce(c,'N'),']') from t3;
-- expect: [x,y,z][N][N] / [p,q,r][N][N] + Warning 1261 Row 1 doesn't contain data for all columns
SQLFound by Loom bug hunt (module: custom-de41a00730; tests: unit, white-box, end-to-end, concurrency; severity: S1)
Activity
XuPeng-SH commentedon Oct 31, 2026
已并入 #31232(LOAD入口参数完整性与字节保真)。本项的完整复现、版本、证据和独立验收要求已保留在主 issue,后续统一在主项跟踪,唯一负责人为 @iamlinjunhong。
本次关闭仅为问题整理/合并,不代表缺陷已修复、测试通过或所有来源具有同一根因;各独立验收仍须完成。