Unverified 提交 9ca1abcd authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #925 from katzyn/datetime2

Fix time overflow in DATEADD
......@@ -1942,9 +1942,9 @@ public class Function extends Expression implements FunctionCall {
forceTimestamp = true;
}
timeNanos += count;
if (timeNanos > DateTimeUtils.NANOS_PER_DAY || timeNanos < 0) {
if (timeNanos >= DateTimeUtils.NANOS_PER_DAY || timeNanos < 0) {
long d;
if (timeNanos > DateTimeUtils.NANOS_PER_DAY) {
if (timeNanos >= DateTimeUtils.NANOS_PER_DAY) {
d = timeNanos / DateTimeUtils.NANOS_PER_DAY;
} else {
d = (timeNanos - DateTimeUtils.NANOS_PER_DAY + 1) / DateTimeUtils.NANOS_PER_DAY;
......
......@@ -161,3 +161,9 @@ SELECT TIMESTAMPADD('TIMEZONE_MINUTE', -45, TIMESTAMP WITH TIME ZONE '2010-01-01
> ---------------------------
> 2010-01-01 10:00:00.0+06:45
> rows: 1
SELECT DATEADD(HOUR, 1, TIME '23:00:00') AS T;
> T
> --------
> 00:00:00
> rows: 1
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论