Skip to content

Commit

Permalink
fix: sequence query in vttablet to execute without raw packets
Browse files Browse the repository at this point in the history
Signed-off-by: Harshit Gangal <[email protected]>
  • Loading branch information
harshit-gangal committed Nov 14, 2024
1 parent fdf1224 commit 1a92368
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions go/vt/vttablet/tabletserver/query_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ func (qre *QueryExecutor) execNextval() (*sqltypes.Result, error) {
if t.SequenceInfo.NextVal == 0 || t.SequenceInfo.NextVal+inc > t.SequenceInfo.LastVal {
_, err := qre.execAsTransaction(func(conn *StatefulConnection) (*sqltypes.Result, error) {
query := fmt.Sprintf("select next_id, cache from %s where id = 0 for update", sqlparser.String(tableName))
qr, err := qre.execStatefulConn(conn, query, false)
qr, err := qre.execStatefulConnWithOpt(conn, query, mysql.ExecuteOptions{MaxRows: int(qre.tsv.qe.maxResultSize.Load())})
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1133,6 +1133,15 @@ func (qre *QueryExecutor) execDBConn(conn *connpool.Conn, sql string, wantfields
}

func (qre *QueryExecutor) execStatefulConn(conn *StatefulConnection, sql string, wantfields bool) (*sqltypes.Result, error) {
opt := mysql.ExecuteOptions{
MaxRows: int(qre.tsv.qe.maxResultSize.Load()),
WantFields: wantfields,
RawPackets: qre.options.RawMysqlPackets,
}
return qre.execStatefulConnWithOpt(conn, sql, opt)
}

func (qre *QueryExecutor) execStatefulConnWithOpt(conn *StatefulConnection, sql string, opt mysql.ExecuteOptions) (*sqltypes.Result, error) {
span, ctx := trace.NewSpan(qre.ctx, "QueryExecutor.execStatefulConn")
defer span.Finish()

Expand All @@ -1145,11 +1154,6 @@ func (qre *QueryExecutor) execStatefulConn(conn *StatefulConnection, sql string,
}
defer qre.tsv.statefulql.Remove(qd)

opt := mysql.ExecuteOptions{
MaxRows: int(qre.tsv.qe.maxResultSize.Load()),
WantFields: wantfields,
RawPackets: qre.options.RawMysqlPackets,
}
return conn.ExecOpt(ctx, sql, opt)
}

Expand Down

0 comments on commit 1a92368

Please sign in to comment.