[executor] LOAD DATA LOCAL can ignore declared defaults for missing fields
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
### 1. Minimal reproduce step (Required)
**Environment**
TiDB 13282a8bd0; real TiKV; default strict mode and MDL ON; LOAD DATA LOCAL; no injection
**Steps**
Create tables with id INT PRIMARY KEY and trailing columns INT NOT NULL DEFAULT 100, VARCHAR NOT NULL DEFAULT fallback, DATE NOT NULL DEFAULT 2000-01-01, and TIMESTAMP NOT NULL DEFAULT 2000-01-01 01:02:03. Load a local CSV containing only lines 1 and 2, then inspect warnings and all persisted values.
### 2. What did you expect to see? (Required)
Nonrestrictive LOAD DATA assigns each missing field its declared column default. DEFAULT CURRENT_TIMESTAMP remains current, nullable columns remain NULL, and no-default columns use their documented implicit values and warnings.
### 3. What did you see instead? (Required)
Every statement succeeds. Fixed INT and VARCHAR defaults become 0 and empty string; fixed temporal defaults become the load date or timestamp. Warning 1261 identifies a short row but does not report that the declared default was ignored. ADMIN CHECK remains green.
### 4. What is your TiDB version? (Required)
TiDB 13282a8bd0; real TiKV; default strict mode and MDL ON; LOAD DATA LOCAL; no injection
Likely root cause and fix direction
**Likely root cause**
parserData2TableData pads each missing mapped field with CurrentTime for NOT NULL temporal columns or NULL for other columns. InsertValues.getRow then marks every padded datum hasValue=true, so fillRow skips getColDefaultValue. Nonrestrictive bad-NULL handling converts supplied NULL to implicit zero or empty values.
**Fix direction**
Preserve source-field absence until schema admission, or resolve each missing non-generated field through InsertValues.getColDefaultValue before building the padded row. Remove the unconditional temporal CurrentTime shortcut. Cover fixed, dynamic, nullable, and no-default cells across temporal and non-temporal types.
Contributor guide
Research direction
Start with the LOAD DATA LOCAL path at parserData2TableData, then trace InsertValues.getRow, fillRow, and getColDefaultValue to follow how absent fields enter schema admission. Reproduce the stated fixed, dynamic, nullable, and no-default cases, then verify declared defaults, implicit values, and warnings for each case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 64/100