Skip to content

Commit

Permalink
bugfix: actually use the jump
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <[email protected]>
  • Loading branch information
systay committed Dec 19, 2024
1 parent ec1f432 commit 6fcd9e1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions go/vt/vtgate/evalengine/compiler_asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
2 changes: 1 addition & 1 deletion go/vt/vtgate/evalengine/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions go/vt/vtgate/evalengine/fn_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 6fcd9e1

Please sign in to comment.