Skip to content

Commit

Permalink
Add check for IsZero datetime in Fn_LAST_DAY
Browse files Browse the repository at this point in the history
Signed-off-by: Noble Mittal <[email protected]>
  • Loading branch information
beingnoble03 committed Jan 26, 2024
1 parent 2ea4596 commit c24efc8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 3 additions & 2 deletions go/vt/vtgate/evalengine/compiler_asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3784,11 +3784,12 @@ func (asm *assembler) Fn_LAST_DAY() {
return 1
}
arg := env.vm.stack[env.vm.sp-1].(*evalTemporal)
d := lastDay(env.currentTimezone(), arg.dt)
if d.IsZero() {
if arg.dt.IsZero() {
env.vm.stack[env.vm.sp-1] = nil
return 1
}

Check warning on line 3790 in go/vt/vtgate/evalengine/compiler_asm.go

View check run for this annotation

Codecov / codecov/patch

go/vt/vtgate/evalengine/compiler_asm.go#L3788-L3790

Added lines #L3788 - L3790 were not covered by tests

d := lastDay(env.currentTimezone(), arg.dt)
env.vm.stack[env.vm.sp-1] = env.vm.arena.newEvalDate(d)
return 1
}, "FN LAST_DAY DATETIME(SP-1)")
Expand Down
4 changes: 0 additions & 4 deletions go/vt/vtgate/evalengine/fn_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -1228,10 +1228,6 @@ func (b *builtinLastDay) eval(env *ExpressionEnv) (eval, error) {
}

d := lastDay(env.currentTimezone(), dt.dt)
if d.IsZero() {
return nil, nil
}

return newEvalDate(d, env.sqlmode.AllowZeroDate()), nil
}

Expand Down

0 comments on commit c24efc8

Please sign in to comment.