Repository navigation
Description
Consolidated tracking scope
Unify the LOAD DATA conversion contract while preserving the separate server-side IGNORE and LOCAL CSV reproductions linked below. The linked reports are retained as separate reproductions where they exercise different code paths. Closing a linked issue is an administrative consolidation only; no fix is claimed here.
Acceptance criteria
- Server-side LOAD DATA INFILE ... IGNORE continues with warnings and applies representable clamping/truncation for invalid, out-of-range, and over-width values.
- For LOCAL loads, a missing integer field follows the established zero-value behavior; an explicitly empty INT becomes 0 and an empty DATE becomes 0000-00-00 under the tested default mode.
- For non-strict LOCAL loads, an over-maximum integer is clamped to the representable endpoint instead of aborting.
- Keep strict non-IGNORE controls: they must continue to reject invalid input. Do not fold the separate CHAR(0)/VARCHAR(0) defect into this issue.
Included reports
- #30492 — original report and discussion remain on that issue.
- #30493 — original report and discussion remain on that issue.
- #30494 — original report and discussion remain on that issue.
Original canonical report (preserved verbatim)
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
HEAD (detached in Loom task workspace)
Commit ID
429c27761be90c3c865685700cc208e194e61be6
Other Environment Information
- Hardware parameters: Apple Silicon, darwin/arm64, macOS 15.5
- OS type: macOS 15.5 (24F74), Go 1.26 arm64
- Others: standalone
mo-servicebuilt withmake buildfrom the commit above and launched with./mo-service -launch .loom-test/launch/launch.toml(copy ofetc/launchwith every port shifted by +20400; frontend listens on 26401; session userdump/111, defaultsql_mode). MySQL reference is Homebrew[email protected]8.0.46 (mysqld --no-defaults,--secure-file-privpointed at the same workspace.loom-testdirectory) so the identical CSV files are readable by both servers; both servers load the same absolute file paths on the same host.
Actual Behavior
For server-side LOAD DATA INFILE ... IGNORE with the default strict session, MatrixOne neither adjusts data-interpretation errors nor continues the load:
- Out-of-range / invalid integer, date, year, decimal values abort the whole statement (statement is atomic, so zero rows are loaded):
mysql> load data infile '<path>/rep_tinyint.csv' ignore into table ti
-> fields terminated by ',' lines terminated by '\n' ignore 1 lines;
ERROR 20101 (HY000): internal error: the input value '128' is not int8 type for column 1
mysql> select count(*) from ti; -- 0
mysql> load data infile '<path>/rep_dates.csv' ignore into table td ... ;
ERROR 20101 (HY000): internal error: the input value '2026-02-31' is not Date type for column 1
A YEAR value 2156 fails the same way (the input value '2156' is not Year type), and a DECIMAL(10,2) overflow value 9999999999 999999999 fails with invalid Decimal64 type — all with IGNORE present, and identically with sql_mode='' instead of IGNORE.
- Over-width strings are stored beyond the declared column width, silently — no truncation, no error, no warning:
mysql> load data infile '<path>/rep_overwidth.csv' ignore into table tv
-> fields terminated by ',' enclosed by '"' lines terminated by '\n' ignore 1 lines;
-- Query OK, 3 rows affected
mysql> select id, s, char_length(s) from tv;
1 hello 5
2 hello world! 12
3 ééééééé 7 -- 7 characters stored in VARCHAR(5)
mysql> show warnings;
-- Empty set
The same silent over-width storage happens for LOAD DATA LOCAL INFILE in a default strict session and for server-side loads under sql_mode=''. Without IGNORE in a strict session, MatrixOne does reject the over-width file (Data too long for column 's' at row 2), which matches MySQL, showing the guard exists but is switched off under every "tolerant" combination while the adjusting logic is not applied.
Expected Behavior
Per the MySQL 8.0 manual (15.2.9 LOAD DATA Statement, "Duplicate-Key and Error Handling"): "When IGNORE—or LOCAL without REPLACE—is specified, data interpretation errors become warnings and the load operation continues, even if the SQL mode is restrictive." MySQL 8.0.46 was run against the exact same files, tables and statements:
-- tinyint: all 4 rows loaded, values clamped to the nearest representable value
Query OK, 4 rows affected, 3 warnings
2 127
3 127 -- from 128
4 127 -- from 300
5 -128 -- from -300
-- dates: all 4 rows loaded as the zero date, 4 warnings (1264/1265)
Query OK, 4 rows affected, 4 warnings
1 0000-00-00
2 0000-00-00
3 0000-00-00
4 0000-00-00
-- over-width varchar(5): all 3 rows loaded, truncated to the column width, warnings reported
Query OK, 3 rows affected, 2 warnings
Warning 1265 Data truncated for column 's' at row 2
Warning 1265 Data truncated for column 's' at row 3
1 hello 5
2 hello 5 -- from "hello world!"
3 ééééé 5 -- from 7 é characters
-- control, no IGNORE in strict session: MySQL also rejects with
ERROR 1406 (22001): Data too long for column 's' at row 2
Also verified on MySQL: YEAR 2156 → 0000 with a warning, DECIMAL(10,2) overflow → clamped to 99999999.99 with a warning, and LOAD DATA LOCAL INFILE (with no IGNORE, strict session) behaves exactly like IGNORE — clamps/zero-fills/truncates with warnings, loads every row.
So with IGNORE (or LOCAL, or a non-strict session) MatrixOne should apply the MySQL adjust-and-continue semantics: truncate over-width strings to the column width, clamp out-of-range numerics to the nearest representable value, rewrite invalid numerics/temporals to the zero value, record warnings, and load all rows. In a strict session without IGNORE/LOCAL the current error behavior is correct and should not change.
Steps to Reproduce
Create the three input files (any directory readable by both servers; below $D):
printf '%s\n' 'id,v' '2,127' '3,128' '4,300' '5,-300' > $D/rep_tinyint.csv
printf '%s\n' 'id,d' '1,2026-02-31' '2,2026-13-01' '3,0000-00-00' '4,2020-2-30' > $D/rep_dates.csv
printf '%s\n' 'id,s' '1,hello' '2,"hello world!"' '3,ééééééé' > $D/rep_overwidth.csvRun on MatrixOne (standalone mo-service, default session sql_mode):
drop database if exists rep;
create database rep;
use rep;
create table ti(id int primary key, v tinyint);
load data infile '$D/rep_tinyint.csv' ignore into table ti
fields terminated by ',' lines terminated by '\n' ignore 1 lines;
select count(*) from ti; -- ERROR 20101 ... not int8 type; count = 0
mysql --force continues:
create table td(id int primary key, d date);
load data infile '$D/rep_dates.csv' ignore into table td
fields terminated by ',' lines terminated by '\n' ignore 1 lines;
select count(*) from td; -- ERROR 20101 ... not Date type; count = 0
create table tv(id int, s varchar(5));
load data infile '$D/rep_overwidth.csv' ignore into table tv
fields terminated by ',' enclosed by '"' lines terminated by '\n' ignore 1 lines;
select id, s, char_length(s) from tv; -- rows stored with char_length 5 / 12 / 7
show warnings; -- Empty set
-- control: same file, no IGNORE (strict) -> still rejected, like MySQL
create table tv2(id int, s varchar(5));
load data infile '$D/rep_overwidth.csv' into table tv2
fields terminated by ',' enclosed by '"' lines terminated by '\n' ignore 1 lines;
-- ERROR 20101 ... Data too long for column 's' at row 2Run the same DDL and LOAD statements on MySQL 8.0.46 (server-side INFILE with secure_file_priv including $D; or use LOAD DATA LOCAL INFILE, which MySQL defines to behave the same as IGNORE): each load completes with all rows adjusted as shown in Expected Behavior.
Additional information
Root cause. The MySQL-compatible value-adjustment machinery exists, but it is gated to a single execution combination. shouldApplyLoadDataNonStrictAdjustments (pkg/sql/colexec/external/external.go:1492-1498) requires param.Extern.Local && Format == CSV && !param.StrictSqlMode. It gates every adjustment step in getColData: the invalid-numeric prefix rewrite (loadDataNonStrictNumericPrefix, applied at external.go:1939-1944), the invalid-temporal zero-value fallback (normalizeLoadDataNonStrictTemporalValue, external.go:1506-1544, applied at external.go:1945-1946), and the over-width string truncation (truncateLoadDataStringValue, applied at external.go:1947-1948).
The IGNORE modifier, however, is implemented by flipping the strict decision off globally: effectiveExternalStrictMode (pkg/sql/compile/compile.go:2556-2562) returns !StatementIgnore, so with IGNORE the decoder is non-strict while being a server-side (non-LOCAL) load. The result is an inconsistent middle state, twice over:
- the strict over-width rejection
checkLineStrict(external.go:1400-1405, used atexternal.go:1956-1959) is honest toIGNORE— it stops rejecting — but the compensating truncation step is not invoked, so the over-width value is stored verbatim beyond the column width (VARCHAR(5)keeps 12/7 characters); - invalid/out-of-range numeric and temporal conversions go through the plain
strconv/types parse branches (e.g.external.go:1995-2015for TINYINT returnsthe input value '128' is not int8 type), which always return hard errors (aborting the whole multi-row statement) because the rewrite/zero-fill/clamp steps are the only tolerant paths and they are LOCAL-only. There is no out-of-range clamping anywhere in the load decoder, not even for the LOCAL non-strict path (cf. [Bug]: non-strict LOCAL LOAD aborts on integer over-max text instead of clamping #30494).
The same asymmetry shows under sql_mode='' on the server path, and for LOAD DATA LOCAL INFILE in a strict default session (LOCAL is tolerated by checkLineStrict but the adjustments need !StrictSqlMode): over-width strings get stored while invalid ints/dates/decimals still abort.
Observed behavior matrix (MatrixOne @ 429c277 vs MySQL 8.0.46, identical files/DDL):
| Configuration | tinyint 128 / date 2026-02-31 / year 2156 / decimal overflow | over-width VARCHAR(5) |
|---|---|---|
server INFILE, strict, plain (no IGNORE) |
error, abort (MO≈MySQL) | Data too long error (MO≈MySQL) |
server INFILE + IGNORE |
ERROR 20101, statement aborts, 0 rows (MySQL: clamps/zeroes, rows loaded, warnings) | stored, char_length 12/7, no warning (MySQL: truncated to 5 + warnings) |
server INFILE, sql_mode='' |
ERROR 20101, abort (MySQL: adjusted, rows loaded) | stored 12/7 (MySQL: truncated) |
| LOCAL INFILE, default strict session | ERROR 20101, abort (MySQL=IGNORE: adjusted, rows loaded) | stored 12/7 (MySQL: truncated) |
LOCAL INFILE, sql_mode='' |
adjusted text ('abc'→0 per #25366) but range values still abort (see #30494) | truncated to 5 (the only adjusted combination) |
Impact. Users who add IGNORE (the documented way to make dirty files loadable) get two opposite failure modes at once: dirty files are not made loadable (a single bad field aborts everything and no partial data is committed, unlike MySQL which loads every row), while simultaneously over-width strings are committed, silently violating the declared column width with no warning — schema-violating data that MySQL would never store in any mode.
Related issues (checked, not duplicates).
- [Bug]: LOAD DATA non-strict invalid conversions abort instead of loading adjusted rows #25366 fixed the LOCAL non-strict CSV adjustment path (PR fix(load): adjust non-strict LOAD DATA values #25459) — that fix is exactly the Local-gated machinery above; the server-side
INFILEtolerant paths were never covered, and addingIGNOREdoes not route into it. - [Bug]: non-strict LOCAL LOAD aborts on integer over-max text instead of clamping #30494 (open) covers the missing range clamping inside the LOCAL non-strict adjusted path (INT32 over-max); this report is the non-LOCAL mirror: on
LOAD DATA INFILE,IGNOREhas no data-interpretation effect at all, and no adjustment code runs, so even plain invalid-text cases that [Bug]: LOAD DATA non-strict invalid conversions abort instead of loading adjusted rows #25366 fixed for LOCAL abort here. The two fixes overlap in the clamping half but have different gates. - [Bug]: LOAD DATA LOCAL fills missing default-backed integer fields with NULL #30492/[Bug]: LOAD DATA LOCAL turns explicit empty INT and DATE fields into NULL #30493 (open) are the empty-field/missing-field manifestations of the same Local/non-strict conflation for the NULL-vs-zero decision, not the conversion-abort or over-width storage reported here.
- [Bug]: LOAD DATA IGNORE/REPLACE do not handle duplicate primary or unique keys #25470 (open) is IGNORE/REPLACE duplicate-key handling; [Bug]: LOAD DATA IGNORE persists rows that violate CHECK constraints #30345 (open) is CHECK constraints under IGNORE; [Bug]: LOAD DATA persists nonempty values in CHAR(0) and VARCHAR(0) columns #30460/[Bug]: LOAD DATA stores nonempty values in CHAR(0) and VARCHAR(0) columns #30457 (open) is the zero-width column guard bypass (
col.Typ.Width > 0in the strict check); none of these concerns value adjustments. - [Feature Request]: LOAD DATA INFILE with CSV file supports ignoring error rows #23937 (closed feature request) and the unmerged PR feat: support LOAD DATA INFILE with IGNORE to skip error rows #24031 confirm the roadmap intent that IGNORE should tolerate bad records ("type conversion errors are still fail-fast" was explicitly listed as out of that PR's scope); MySQL 8.0 remains the reference for what IGNORE must do to values.
Recommendation. Introduce a single "tolerant load" predicate (statement IGNORE ∨ LOCAL ∨ non-strict session, CSV only) used by both the strictness decision and the adjustment steps: truncate strings to the column width, rewrite invalid numerics/temporals to zero values, clamp out-of-range numerics/years to the nearest representable value, count one warning per adjusted cell, and keep the current hard failure for strictly-mode server loads without IGNORE/LOCAL. That preserves all existing strict behavior and the already-shipped LOCAL non-strict adjustments (no back-compat risk for payloads that currently error), while fixing both reported symptom classes. The clamping half is required in any case for #30494; sharing the predicate avoids a third divergent gate.
Full reproduction, exactly as Loom ran it
#!/bin/bash
# Same files and statements against both servers (run as-is on the same host).
# $D must be readable by both servers (MySQL run with --secure-file-priv=<dir containing $D>).
D=/Users/linjunhong/.loom/workspaces/hunt/w3/.loom-test/loaddata
MY=/opt/homebrew/opt/mysql@8.0/bin/mysql
printf '%s\n' 'id,v' '2,127' '3,128' '4,300' '5,-300' > $D/rep_tinyint.csv
printf '%s\n' 'id,d' '1,2026-02-31' '2,2026-13-01' '3,0000-00-00' '4,2020-2-30' > $D/rep_dates.csv
printf '%s\n' 'id,s' '1,hello' '2,"hello world!"' '3,ééééééé' > $D/rep_overwidth.csv
# ---------- MatrixOne (standalone mo-service, frontend 26401, user dump/111) ----------
MOPT="$MY -h127.0.0.1 -P26401 -udump -p111 --default-character-set=utf8mb4 --force"
$MY $MOPT -e "drop database if exists rep; create database rep;"
echo '=== MO 1: tinyint clamp under IGNORE (default strict session)'
$MY $MOPT -e "use rep; create table ti(id int primary key, v tinyint);
load data infile '$D/rep_tinyint.csv' ignore into table ti fields terminated by ',' lines terminated by '\\n' ignore 1 lines;
select 'rows', count(*) from ti;"
# -> ERROR 20101 (HY000): internal error: the input value '128' is not int8 type for column 1 ; rows = 0
echo '=== MO 2: invalid dates under IGNORE'
$MY $MOPT -e "use rep; create table td(id int primary key, d date);
load data infile '$D/rep_dates.csv' ignore into table td fields terminated by ',' lines terminated by '\\n' ignore 1 lines;
select 'rows', count(*) from td;"
# -> ERROR 20101 (HY000): internal error: the input value '2026-02-31' is not Date type for column 1 ; rows = 0
echo '=== MO 3: over-width varchar(5) under IGNORE'
$MY $MOPT -e "use rep; create table tv(id int, s varchar(5));
load data infile '$D/rep_overwidth.csv' ignore into table tv fields terminated by ',' enclosed by '\"' lines terminated by '\\n' ignore 1 lines;
select id, s, char_length(s) from tv; show warnings;"
# -> Query OK, 3 rows affected; char_length = 5 / 12 / 7; show warnings: Empty set
echo '=== MO control: over-width, server-side, strict, no IGNORE'
$MY $MOPT -e "use rep; create table tv2(id int, s varchar(5));
load data infile '$D/rep_overwidth.csv' into table tv2 fields terminated by ',' enclosed by '\"' lines terminated by '\\n' ignore 1 lines;"
# -> ERROR 20101 (HY000): internal error: Data too long for column 's' at row 2 (agrees with MySQL erroring)
# ---------- MySQL 8.0.46 reference (mysqld on 23706, --secure-file-priv=$D's parent) ----------
MOY="$MY -uroot -h127.0.0.1 -P23706 --force"
$MY $MOY -e "drop database if exists rep; create database rep;"
echo '=== MySQL 1'
$MY $MOY -e "use rep; create table ti(id int primary key, v tinyint);
load data infile '$D/rep_tinyint.csv' ignore into table ti fields terminated by ',' lines terminated by '\\n' ignore 1 lines;
select * from ti;"
# -> Query OK, 4 rows affected, 3 warnings ; values 127 / 127 / 127 / -128
echo '=== MySQL 2'
$MY $MOY -e "use rep; create table td(id int primary key, d date);
load data infile '$D/rep_dates.csv' ignore into table td fields terminated by ',' lines terminated by '\\n' ignore 1 lines;
show warnings; select * from td;"
# -> Query OK, 4 rows affected, 4 warnings (1264/1265) ; four rows 0000-00-00
echo '=== MySQL 3'
$MY $MOY -e "use rep; create table tv(id int, s varchar(5));
load data infile '$D/rep_overwidth.csv' ignore into table tv fields terminated by ',' enclosed by '\"' lines terminated by '\\n' ignore 1 lines;
show warnings; select id, s, char_length(s) from tv;"
# -> Query OK, 3 rows affected, 2 warnings (1265 row 2 / row 3) ; char_length 5 / 5 / 5
echo '=== MySQL control'
$MY $MOY -e "use rep; create table tv2(id int, s varchar(5));
load data infile '$D/rep_overwidth.csv' into table tv2 fields terminated by ',' enclosed by '\"' lines terminated by '\\n' ignore 1 lines;"
# -> ERROR 1406 (22001): Data too long for column 's' at row 2Found by Loom bug hunt (module: custom-a9872c7d6e; tests: unit, white-box, end-to-end)
Activity
[-][Bug]: LOAD DATA IGNORE aborts on out-of-range/invalid values and stores over-width strings unadjusted[/-][+][Bug]: LOAD DATA must apply mode-aware conversion and missing/empty-field semantics consistently[/+]