Repository navigation
Description
Description
INSERT IGNORE suppresses some error classes but not NOT NULL violations. A single NULL in a NOT NULL column aborts the whole statement with a hard error, so a multi-row batch that MySQL would load partially (skipping the bad rows with warnings) inserts nothing here.
MySQL documents ER_BAD_NULL_ERROR (1048) among the errors that IGNORE downgrades to a warning:
mysql> insert ignore into ig(u,nn,c) values(2,null,1);
Query OK, 0 rows affected, 1 warning
Warning (Code 1048): Column 'nn' cannot be null
MatrixOne:
mysql> insert ignore into ig(u,nn,c) values(2,null,1);
ERROR 3819 (HY000): constraint violation: Column 'nn' cannot be null
Multi-row, one bad row kills the batch:
insert ignore into ig(u,nn,c) values(10,10,1),(11,null,1),(12,12,1);
-- ERROR 3819 (HY000): constraint violation: Column 'nn' cannot be nullMySQL: rows 10 and 12 are inserted, row 11 is skipped with a warning.
What does work (so this is a gap, not a missing feature)
Measured on the same build, same table:
INSERT IGNORE case |
MO result | MySQL |
|---|---|---|
| duplicate unique key | warning 1062, row skipped ✅ |
same |
FK violation (1452) |
row skipped, no error ✅ | same |
CHECK (c>0) violation |
row skipped ✅ | warning + skip |
'12abc' into int |
coerced to 12, row inserted ✅ |
warning + insert |
NULL into NOT NULL |
ERROR 3819, statement aborts ❌ | warning 1048, row skipped |
out-of-range tinyint (300) |
ERROR 1690 ❌ | warning + clamp |
So the ignore machinery is wired up (duplicate/FK/coercion paths honour it) — the NOT NULL check simply bypasses it.
White-box pointers
pkg/sql/colexec/constraint_util.go:108—BatchDataNotNullCheck(vecs, attrs, tableDef, ctx)returnsmoerr.NewConstraintViolation(... "Column '%s' cannot be null")unconditionally; it takes no duplicate-handling / IGNORE mode.pkg/sql/colexec/insert/insert.go:235—checkExternalNotNullhas the same shape for external tables.- The error is reported as 3819 (check-constraint violation) rather than 1048 (
ER_BAD_NULL_ERROR), so even the error class hides the fact that this is a NOT NULL, not a CHECK, failure.
Impact
Bulk-load scripts and sync jobs commonly use INSERT IGNORE precisely to tolerate a few bad rows. Here one NULL turns a partially-successful batch into a total failure, and the operation must be re-run row by row.
Expected behaviour
Under IGNORE, a NULL in a NOT NULL column should skip the row and publish warning 1048 (ER_BAD_NULL_ERROR); the statement should succeed and report the skipped count, matching the duplicate/FK behaviour that already works.
Versions
MatrixOne main @ 3ad9adbb4c (2026-10-22), macOS arm64, local mo-service -launch.
Related
- [Compatibility]: INSERT IGNORE with ON DUPLICATE KEY UPDATE is rejected #28159 —
INSERT IGNOREcombined withON DUPLICATE KEY UPDATEis rejected (different defect, same statement family). - [Bug]: INSERT IGNORE maps AUTO_INCREMENT gaps to accepted rows differently from MySQL #28238 —
INSERT IGNOREAUTO_INCREMENT gap behaviour. - [Bug]: DML assignment casts must honor bounds and SQL-mode adjustment semantics #27340 — DML assignment casts must honour bounds and SQL-mode adjustment (covers the out-of-range row in the table above).
Activity
Ariznawlll commentedon Oct 26, 2026
Confirming, plus one detail that raises the severity: a single bad row aborts the entire multi-row batch, so
INSERT IGNOREcannot be used as a bulk-load dirty-data filter at all.ERROR 3819 (HY000): constraint violation: Column 'a' cannot be null— 0 rows insertedSELECT COUNT(*), GROUP_CONCAT(a) FROM ig2→3, 1,0,2(the NULL row is coerced to0under non-strict, or skipped under strict — either way the other two rows are kept)Because the whole statement rolls back, the common ETL pattern "
INSERT IGNOREa 10k-row staging batch, let bad rows drop on the floor" fails completely: one malformed row and you lose the other 9,999 good rows. On MySQL the same statement loads the good rows.This is a distinct consequence from the error-code mismatch (3819 vs warning 1048): it's not just the wrong code, it's all-or-nothing batch semantics instead of per-row skip.
Also note the same pattern applies to other IGNORE-covered violations (type truncation, out-of-range) per the related issues — the batch-level abort makes them all unusable for bulk loads.
gouhongshen commentedon Nov 6, 2026
PR #32299 is trying to fix this issue.
Merge origin/main (2746f81) into agent/issue-30906-main-cfb4a77c
fix: make INSERT IGNORE tolerate NOT NULL violations (#32299)
gouhongshen commentedon Nov 6, 2026
PR #32299 has merged and is awaiting manual validation. The issue remains open.
XuPeng-SH commentedon Nov 6, 2026
转 QA 验证:#32299 已合入 main
证据及未测范围:
保留边界:
建议 QA:
按流程移除研发负责人,改派唯一 Ariznawlll。
slyunnn commentedon Nov 11, 2026
Regression and extended verification for #30906 (2026-11-11)
Verification Environment
45917e803f2915f6f0838b2b2fe9f591fc5b6018,fix(plan): fold contradictory same-column predicates to near-zero estimates (#32502).git_version()=45917e803fthrough Proxy6001, CN116001and CN216002. All three endpoints executed the issue checks.2 CN / 1 TN / 1 Log service / Proxy, macOS arm64, Go1.27.1.database/sql+go-sql-driver/mysql,interpolateParams=false, supplied native prepared-statement evidence forMIN/MAXparameter changes and physical-index role changes.What Was Covered
399/399SQL statements passed per endpoint. Original single/multi-row batches retain valid rows, fill offendingNULLcells with implicit type defaults and report1048.BINARYpadding, strict controls,INSERTSELECT/LOAD, unique/CHECK/FKinteractions, default expressions and primary-key boundaries.LOAD ... IGNOREimported17,000rows per endpoint. All rows were compared against an independent expected list. Exactly4adjusted cells produced4warnings1048, and their nullable siblings remainedNULL.INSERT IGNOREis rejected before assignment even for entirely valid data. Ordinary externalINSERTand externalLOADIGNOREwork. This separate general admission defect is tracked as [Bug]: writable external tables reject valid INSERT IGNORE VALUES and SELECT with 20313 #32512.Findings
fix: make INSERT IGNORE tolerate NOT NULL violations, merge647eaf9dd36d4b8521114e5dedb9d99d4c148c68is included in the frozen main. PR #32299NULLbehavior underIGNOREis implicit-default filling. The independent externalINSERTIGNOREadmission defect also rejects non-NULLVALUESandSELECT, so its error precedes the repaired assignment boundary. Related to #32512MOTR / BVT Coverage
9cases with-j 5 --repeat 2through each endpoint,54/54executions total. The new cases use separate databases, roles and connections, with no global-variable changes. This is runner concurrency.199test/subtest passes across7packages with selected tests. The independent forced-two-CN aggregate fixture also passed.Final Conclusion
Fixed for the original issue contract on the verified build and paths.
Large-data regression — A batch boundary check is required. The
17,000-row external load crosses reader batches and checks all stored rows; larger arbitrary data is unnecessary.