Lightning: Unexpected Behavior When Mixing Different Types of INSERT Statements
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
The source schema is like this:
CREATE TABLE test_tbl (
id bigint PRIMARY KEY AUTO_INCREMENT,
c char(40) NOT NULL DEFAULT '');
The input data is a SQL file. Instead using the same kind of INSERT statements, I use different formats for the INSERT statements:
INSERT INTO test_tbl (id, c) VALUES
(1, 'normal_pk_01');
INSERT INTO test_tbl (c) VALUES
('empty_pk_02');
INSERT INTO test_tbl (c) VALUES
('empty_pk_03');
INSERT INTO test_tbl (id, c) VALUES
(4, 'normal_pk_04');
Try to import the data using the 'tidb' backend and 'local' backend.
### 2. What did you expect to see? (Required)
The importing should succeed, no matter what kind of backend in this situation. Because I can run these SQL statements in sequence without any problems.
The expected table data should be:
1, "normal_pk_01"
2, "empty_pk_02"
3, "empty_pk_03"
4, "normal_pk_04"
### 3. What did you see instead (Required)
For 'tidb' backend, I got the following error:
tidb lightning encountered error: [Lightning:Restore:ErrEncodeKV]encode kv error in file testdb.test_tbl.sql:0 at offset 110: column count mismatch, expected 2, got 1
For 'local' backend:
1. The import partially succeeded, and failed on doing checksum.
2. The data was incorrect:
0, ""
1, "normal_pk_01"
4, "normal_pk_04"
### 4. What is your TiDB version? (Required)
Latest master build
Contributor guide
Assessment
This issue has not been assessed yet.