提交 f213481a authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix time overflow in DATEADD

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