From 0abfff46641d15c9b431ff563512ca2ada6ac045 Mon Sep 17 00:00:00 2001 From: disksing Date: Tue, 24 Nov 2015 10:14:15 +0800 Subject: [PATCH] *: address comments --- stmt/stmts/insert.go | 10 +++++----- table/table.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/stmt/stmts/insert.go b/stmt/stmts/insert.go index dcf3e830c6..ff83f31ec3 100644 --- a/stmt/stmts/insert.go +++ b/stmt/stmts/insert.go @@ -199,17 +199,17 @@ func (s *InsertIntoStmt) Exec(ctx context.Context) (_ rset.Recordset, err error) } for i, row := range rows { - // Notes: incompatible with mysql - // MySQL will set last insert id to the first row, as follows: - // `t(id int AUTO_INCREMENT, c1 int, PRIMARY KEY (id))` - // `insert t (c1) values(1),(2),(3);` - // Last insert id will be 1, not 3. if len(s.OnDuplicate) == 0 { txn.SetOption(kv.PresumeKeyNotExists, nil) } h, err := t.AddRecord(ctx, row, recordIDs[i]) txn.DelOption(kv.PresumeKeyNotExists) if err == nil { + // Notes: incompatible with mysql + // MySQL will set last insert id to the first row, as follows: + // `t(id int AUTO_INCREMENT, c1 int, PRIMARY KEY (id))` + // `insert t (c1) values(1),(2),(3);` + // Last insert id will be 1, not 3. variable.GetSessionVars(ctx).SetLastInsertID(uint64(recordIDs[i])) continue } diff --git a/table/table.go b/table/table.go index 932f6bd193..a5044c9e96 100644 --- a/table/table.go +++ b/table/table.go @@ -77,7 +77,7 @@ type Table interface { // Truncate truncates the table. Truncate(ctx context.Context) (err error) - // AddRecord inserts a row into the table. + // AddRecord inserts a row into the table. Is h is 0, it will alloc an unique id inside. AddRecord(ctx context.Context, r []interface{}, h int64) (recordID int64, err error) // UpdateRecord updates a row in the table.