Skip to content

Commit

Permalink
bugfix: protect against nil exceptions
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <andres@planetscale.com>
  • Loading branch information
systay committed Dec 18, 2024
1 parent 1e7fbe3 commit 3abdf60
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions go/vt/vtgate/scatter_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,13 @@ func (stc *ScatterConn) ExecuteMultiShard(
opts = session.Session.Options
}

// TODO reset this?
opts.FetchLastInsertId = fetchLastInsertID
if fetchLastInsertID {
if opts == nil {
opts = &querypb.ExecuteOptions{FetchLastInsertId: fetchLastInsertID}
} else {
opts.FetchLastInsertId = fetchLastInsertID
}
}

if autocommit {
// As this is auto-commit, the transactionID is supposed to be zero.
Expand Down Expand Up @@ -410,7 +415,11 @@ func (stc *ScatterConn) StreamExecuteMulti(
}

if fetchLastInsertID {
opts.FetchLastInsertId = true
if opts == nil {
opts = &querypb.ExecuteOptions{FetchLastInsertId: fetchLastInsertID}
} else {
opts.FetchLastInsertId = fetchLastInsertID
}
}

if autocommit {
Expand Down

0 comments on commit 3abdf60

Please sign in to comment.