Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load data : fix load data rowCount should added first before call colsToRow(). (#11980) #11994

Merged
merged 1 commit into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix load data rowCount should added first before call colsToRow(). (#…
…11980)

fix load data rowcount should added first before call colsToRow().
  • Loading branch information
AilinKid committed Sep 3, 2019
commit abc64743354b971d7dd210cbc0739fe1faa1542f
4 changes: 3 additions & 1 deletion executor/load_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,10 @@ func (e *LoadDataInfo) InsertData(prevData, curData []byte) ([]byte, bool, error
if err != nil {
return nil, false, errors.Trace(err)
}
rows = append(rows, e.colsToRow(cols))
// rowCount will be used in fillRow(), last insert ID will be assigned according to the rowCount = 1.
// So should add first here.
e.rowCount++
rows = append(rows, e.colsToRow(cols))
if e.maxRowsInBatch != 0 && e.rowCount%e.maxRowsInBatch == 0 {
reachLimit = true
logutil.Logger(context.Background()).Info("batch limit hit when inserting rows", zap.Int("maxBatchRows", e.maxChunkSize),
Expand Down
4 changes: 2 additions & 2 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ func runTestLoadData(c *C, server *Server) {
dbt.Assert(err, IsNil)
lastID, err = rs.LastInsertId()
dbt.Assert(err, IsNil)
dbt.Assert(lastID, Equals, int64(7))
dbt.Assert(lastID, Equals, int64(6))
affectedRows, err = rs.RowsAffected()
dbt.Assert(err, IsNil)
dbt.Assert(affectedRows, Equals, int64(4))
Expand Down Expand Up @@ -466,7 +466,7 @@ func runTestLoadData(c *C, server *Server) {
dbt.Assert(err, IsNil)
lastID, err = rs.LastInsertId()
dbt.Assert(err, IsNil)
dbt.Assert(lastID, Equals, int64(11))
dbt.Assert(lastID, Equals, int64(10))
affectedRows, err = rs.RowsAffected()
dbt.Assert(err, IsNil)
dbt.Assert(affectedRows, Equals, int64(799))
Expand Down