diff --git a/go/sqltypes/result.go b/go/sqltypes/result.go index b2818f4fb13..b3cc0fd5573 100644 --- a/go/sqltypes/result.go +++ b/go/sqltypes/result.go @@ -335,7 +335,7 @@ func (result *Result) AppendResult(src *Result) { result.InsertID = src.InsertID result.InsertIDChanged = true } - if result.Fields == nil { + if len(result.Fields) == 0 { result.Fields = src.Fields } result.Rows = append(result.Rows, src.Rows...) diff --git a/go/vt/vttablet/tabletserver/query_executor.go b/go/vt/vttablet/tabletserver/query_executor.go index 21423dd28b9..e4a165960fd 100644 --- a/go/vt/vttablet/tabletserver/query_executor.go +++ b/go/vt/vttablet/tabletserver/query_executor.go @@ -1179,7 +1179,7 @@ func (qre *QueryExecutor) resetLastInsertIDIfNeeded(ctx context.Context, conn *c } func (qre *QueryExecutor) fetchLastInsertID(ctx context.Context, conn *connpool.Conn, exec *sqltypes.Result) error { - if exec.InsertID != 0 || !qre.options.GetFetchLastInsertId() { + if exec.InsertIDUpdated() || !qre.options.GetFetchLastInsertId() { return nil } @@ -1221,7 +1221,7 @@ func (qre *QueryExecutor) execStreamSQL(conn *connpool.PooledConn, isTransaction lastInsertIDSet := false cb := func(result *sqltypes.Result) error { - if result != nil && result.InsertID != 0 { + if result != nil && result.InsertIDUpdated() { lastInsertIDSet = true } return callback(result)