diff --git a/go/sqltypes/result.go b/go/sqltypes/result.go index f5f1c151b63..3c56c8b7eea 100644 --- a/go/sqltypes/result.go +++ b/go/sqltypes/result.go @@ -330,17 +330,14 @@ func (result *Result) StripMetadata(incl querypb.ExecuteOptions_IncludedFields) // to another result.Note currently it doesn't handle cases like // if two results have different fields.We will enhance this function. func (result *Result) AppendResult(src *Result) { - if src.RowsAffected == 0 && len(src.Rows) == 0 && len(src.Fields) == 0 { - return - } - if result.Fields == nil { - result.Fields = src.Fields - } result.RowsAffected += src.RowsAffected if src.InsertID != 0 || src.InsertIDChanged { result.InsertID = src.InsertID } result.InsertIDChanged = result.InsertIDChanged || src.InsertIDChanged + if result.Fields == nil { + result.Fields = src.Fields + } result.Rows = append(result.Rows, src.Rows...) } diff --git a/go/test/endtoend/utils/cmp.go b/go/test/endtoend/utils/cmp.go index 7d94c181abd..bf4eb5e14c1 100644 --- a/go/test/endtoend/utils/cmp.go +++ b/go/test/endtoend/utils/cmp.go @@ -313,3 +313,10 @@ func (mcmp *MySQLCompare) ExecAllowError(query string) (*sqltypes.Result, error) } return vtQr, vtErr } + +func (mcmp *MySQLCompare) VExplain(query string) { + mcmp.t.Helper() + vtQr, vtErr := mcmp.VtConn.ExecuteFetch("vexplain plan "+query, 1, true) + require.NoError(mcmp.t, vtErr, "[Vitess Error] for query: "+query) + fmt.Printf("Vitess VExplain Plan: \n%v\n", vtQr.Rows[0][0].ToString()) +} diff --git a/go/test/endtoend/vtgate/queries/misc/misc_test.go b/go/test/endtoend/vtgate/queries/misc/misc_test.go index b3ee47df3b6..05b96c33604 100644 --- a/go/test/endtoend/vtgate/queries/misc/misc_test.go +++ b/go/test/endtoend/vtgate/queries/misc/misc_test.go @@ -144,6 +144,9 @@ func TestSetAndGetLastInsertID(t *testing.T) { mcmp.Run(name, func(mcmp *utils.MySQLCompare) { mcmp.Exec(query) mcmp.Exec("select last_insert_id()") + if mcmp.AsT().Failed() { + mcmp.VExplain(query) + } }) } // we need this value to be not zero, and then we keep changing it so different queries don't interact with each other diff --git a/go/vt/vttablet/tabletserver/query_executor.go b/go/vt/vttablet/tabletserver/query_executor.go index 4c6da0315d1..2253d22ec6e 100644 --- a/go/vt/vttablet/tabletserver/query_executor.go +++ b/go/vt/vttablet/tabletserver/query_executor.go @@ -1206,9 +1206,9 @@ func (qre *QueryExecutor) execStreamSQL(conn *connpool.PooledConn, isTransaction callBackClosingSpan := func(result *sqltypes.Result) error { defer span.Finish() - if err := qre.fetchLastInsertID(ctx, conn.Conn, result); err != nil { - return err - } + // if err := qre.fetchLastInsertID(ctx, conn.Conn, result); err != nil { + // return err + // } return callback(result) } @@ -1222,9 +1222,9 @@ func (qre *QueryExecutor) execStreamSQL(conn *connpool.PooledConn, isTransaction // This change will ensure that long-running streaming stateful queries get gracefully shutdown during ServingTypeChange // once their grace period is over. qd := NewQueryDetail(qre.logStats.Ctx, conn.Conn) - if err := qre.resetLastInsertIDIfNeeded(ctx, conn.Conn); err != nil { - return err - } + // if err := qre.resetLastInsertIDIfNeeded(ctx, conn.Conn); err != nil { + // return err + // } if isTransaction { err := qre.tsv.statefulql.Add(qd)