diff --git a/go/vt/proto/query/query_extra.go b/go/vt/proto/query/query_extra.go new file mode 100644 index 00000000000..21cdb8c1efc --- /dev/null +++ b/go/vt/proto/query/query_extra.go @@ -0,0 +1,24 @@ +/* +Copyright 2024 The Vitess Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package query + +func (x *ExecuteOptions) ShouldFetchLastInsertID() bool { + if x == nil { + return false + } + return x.FetchLastInsertId +} diff --git a/go/vt/vttablet/tabletserver/query_executor.go b/go/vt/vttablet/tabletserver/query_executor.go index 1acbe2beed4..deadbdac4b1 100644 --- a/go/vt/vttablet/tabletserver/query_executor.go +++ b/go/vt/vttablet/tabletserver/query_executor.go @@ -1125,7 +1125,7 @@ func (qre *QueryExecutor) execDBConn(conn *connpool.Conn, sql string, wantfields if err != nil { return nil, err } - if qre.options.FetchLastInsertId { + if qre.options.ShouldFetchLastInsertID() { err := qre.fetchLastInsertID(ctx, conn, exec) if err != nil { return nil, err @@ -1151,7 +1151,7 @@ func (qre *QueryExecutor) execStatefulConn(conn *StatefulConnection, sql string, if err != nil { return nil, err } - if qre.options.FetchLastInsertId { + if qre.options.ShouldFetchLastInsertID() { err = qre.fetchLastInsertID(ctx, conn.UnderlyingDBConn().Conn, exec) if err != nil { return nil, err