Skip to content

Commit

Permalink
evalengine: Ensure to pass down the precision (#15611)
Browse files Browse the repository at this point in the history
Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
  • Loading branch information
dbussink authored Apr 2, 2024
1 parent 9ad73c1 commit cef95ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions go/vt/vtgate/evalengine/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtgate/evalengine/fn_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit cef95ab

Please sign in to comment.