From 53e3fcc721738c32b8a78d9a23219fe51fe25e18 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Fri, 20 Dec 2024 08:34:06 +0100 Subject: [PATCH] handle lastInsertID correctly when streaming Signed-off-by: Andres Taylor --- go/vt/vtgate/executorcontext/vcursor_impl.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/go/vt/vtgate/executorcontext/vcursor_impl.go b/go/vt/vtgate/executorcontext/vcursor_impl.go index e51056a3367..dcd27633c38 100644 --- a/go/vt/vtgate/executorcontext/vcursor_impl.go +++ b/go/vt/vtgate/executorcontext/vcursor_impl.go @@ -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) } }