Skip to content

Commit

Permalink
handle lastInsertID correctly when streaming
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <[email protected]>
  • Loading branch information
systay committed Dec 20, 2024
1 parent b9d4b7a commit 53e3fcc
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions go/vt/vtgate/executorcontext/vcursor_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,15 +675,20 @@ func (vc *VCursorImpl) ExecutePrimitiveStandalone(ctx context.Context, primitive

func (vc *VCursorImpl) wrapCallback(callback func(*sqltypes.Result) error, primitive engine.Primitive) func(*sqltypes.Result) error {
if vc.interOpStats == nil {
return callback
return func(r *sqltypes.Result) error {
if r.InsertIDChanged {
vc.SafeSession.LastInsertId = r.InsertID
}
return callback(r)
}
}

return func(result *sqltypes.Result) error {
if result.InsertIDChanged {
vc.SafeSession.LastInsertId = result.InsertID
return func(r *sqltypes.Result) error {
if r.InsertIDChanged {
vc.SafeSession.LastInsertId = r.InsertID
}
vc.logOpTraffic(primitive, result)
return callback(result)
vc.logOpTraffic(primitive, r)
return callback(r)
}
}

Expand Down

0 comments on commit 53e3fcc

Please sign in to comment.