From a1c2707313b56023ab256e1104ee30d1968d015b Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Wed, 18 Dec 2024 18:17:20 +0100 Subject: [PATCH] bugfix: actually use the jump Signed-off-by: Andres Taylor --- go/vt/vtgate/evalengine/compiler_asm.go | 6 ++++++ go/vt/vtgate/evalengine/compiler_test.go | 2 +- go/vt/vtgate/evalengine/fn_misc.go | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/go/vt/vtgate/evalengine/compiler_asm.go b/go/vt/vtgate/evalengine/compiler_asm.go index ebde418a3db..9099f8711c0 100644 --- a/go/vt/vtgate/evalengine/compiler_asm.go +++ b/go/vt/vtgate/evalengine/compiler_asm.go @@ -5153,3 +5153,9 @@ func (asm *assembler) Fn_LAST_INSERT_ID_NULL() { return 1 }, "FN LAST_INSERT_ID NULL") } + +func (asm *assembler) addJump(end *jump) { + asm.emit(func(env *ExpressionEnv) int { + return end.offset() + }, "JUMP") +} diff --git a/go/vt/vtgate/evalengine/compiler_test.go b/go/vt/vtgate/evalengine/compiler_test.go index 9fbcffdcdf6..ea3a7a603ce 100644 --- a/go/vt/vtgate/evalengine/compiler_test.go +++ b/go/vt/vtgate/evalengine/compiler_test.go @@ -966,7 +966,7 @@ func runTest(t *testing.T, expr sqlparser.Expr, cfg *evalengine.Config, tc struc vc := &testVcursor{env: vtenv.NewTestEnv()} env := evalengine.NewExpressionEnv(context.Background(), nil, vc) - _, err = env.EvaluateAST(converted) + _, err = env.Evaluate(converted) require.NoError(t, err) if tc.missing { require.Nil(t, vc.lastInsertID) diff --git a/go/vt/vtgate/evalengine/fn_misc.go b/go/vt/vtgate/evalengine/fn_misc.go index 6c017b9195c..cb17f8d6560 100644 --- a/go/vt/vtgate/evalengine/fn_misc.go +++ b/go/vt/vtgate/evalengine/fn_misc.go @@ -224,6 +224,7 @@ func (call *builtinLastInsertID) compile(c *compiler) (ctype, error) { c.compileToUint64(arg, 1) c.asm.Fn_LAST_INSERT_ID() end := c.asm.jumpFrom() + c.asm.addJump(end) c.asm.jumpDestination(setZero) c.asm.Fn_LAST_INSERT_ID_NULL()