From 4307d1711263a5a4dd39f6c923d76766358c4821 Mon Sep 17 00:00:00 2001 From: "vitess-bot[bot]" <108069721+vitess-bot[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 12:29:03 +0200 Subject: [PATCH] [release-19.0] evalengine: Ensure to pass down the precision (#15611) (#15612) Signed-off-by: Dirkjan Bussink Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> --- 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 537fc64be3c..0c0841a848b 100644 --- a/go/vt/vtgate/evalengine/compiler_test.go +++ b/go/vt/vtgate/evalengine/compiler_test.go @@ -611,6 +611,10 @@ func TestCompilerSingle(t *testing.T) { expression: `now() + interval 654321 microsecond`, result: `DATETIME("2023-10-24 12:00:00.654321")`, }, + { + 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 fc5c045a407..bdaaaa7e1d2 100644 --- a/go/vt/vtgate/evalengine/fn_time.go +++ b/go/vt/vtgate/evalengine/fn_time.go @@ -217,7 +217,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 { @@ -234,7 +234,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 {