From cef95ab7b000f125e085d52240b3ee5d8fcdfd21 Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Tue, 2 Apr 2024 11:35:15 +0200 Subject: [PATCH] evalengine: Ensure to pass down the precision (#15611) Signed-off-by: Dirkjan Bussink --- go/vt/vtgate/evalengine/compiler_test.go | 4 ++++ go/vt/vtgate/evalengine/fn_time.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/go/vt/vtgate/evalengine/compiler_test.go b/go/vt/vtgate/evalengine/compiler_test.go index f101bf61c64..435e6491828 100644 --- a/go/vt/vtgate/evalengine/compiler_test.go +++ b/go/vt/vtgate/evalengine/compiler_test.go @@ -631,6 +631,10 @@ func TestCompilerSingle(t *testing.T) { expression: `REPLACE('www.mysql.com', '', 'Ww')`, result: `VARCHAR("www.mysql.com")`, }, + { + expression: `1 * unix_timestamp(utc_timestamp(1))`, + result: `DECIMAL(1698134400.1)`, + }, } tz, _ := time.LoadLocation("Europe/Madrid") diff --git a/go/vt/vtgate/evalengine/fn_time.go b/go/vt/vtgate/evalengine/fn_time.go index ad8ea68c6a2..1a0b6ede18e 100644 --- a/go/vt/vtgate/evalengine/fn_time.go +++ b/go/vt/vtgate/evalengine/fn_time.go @@ -222,7 +222,7 @@ func (call *builtinNow) compile(c *compiler) (ctype, error) { t = sqltypes.Datetime c.asm.Fn_Now(call.prec, call.utc) } - return ctype{Type: t, Col: collationBinary}, nil + return ctype{Type: t, Col: collationBinary, Size: int32(call.prec)}, nil } func (call *builtinNow) constant() bool { @@ -239,7 +239,7 @@ func (call *builtinSysdate) eval(env *ExpressionEnv) (eval, error) { func (call *builtinSysdate) compile(c *compiler) (ctype, error) { c.asm.Fn_Sysdate(call.prec) - return ctype{Type: sqltypes.Datetime, Col: collationBinary}, nil + return ctype{Type: sqltypes.Datetime, Col: collationBinary, Size: int32(call.prec)}, nil } func (call *builtinSysdate) constant() bool {