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

Add support of TIMESTAMP WITH TIME ZONE to addition and subtraction operators

上级 6b6db5e3
......@@ -216,9 +216,7 @@ public class Operation extends Expression {
} else {
dataType = Value.DECIMAL;
}
} else if (l == Value.DATE || l == Value.TIMESTAMP ||
l == Value.TIME || r == Value.DATE ||
r == Value.TIMESTAMP || r == Value.TIME) {
} else if (DataType.isDateTimeType(l) || DataType.isDateTimeType(r)) {
switch (opType) {
case PLUS:
if (r != Value.getHigherOrder(l, r)) {
......@@ -252,10 +250,10 @@ public class Operation extends Expression {
return f.optimize(session);
}
case Value.TIME:
if (r == Value.TIME) {
dataType = Value.TIME;
if (r == Value.TIME || r == Value.TIMESTAMP_TZ) {
dataType = r;
return this;
} else {
} else { // DATE, TIMESTAMP
dataType = Value.TIMESTAMP;
return this;
}
......@@ -265,6 +263,7 @@ public class Operation extends Expression {
switch (l) {
case Value.DATE:
case Value.TIMESTAMP:
case Value.TIMESTAMP_TZ:
switch (r) {
case Value.INT: {
// Oracle date subtract
......@@ -296,7 +295,8 @@ public class Operation extends Expression {
dataType = Value.TIMESTAMP;
return this;
case Value.DATE:
case Value.TIMESTAMP: {
case Value.TIMESTAMP:
case Value.TIMESTAMP_TZ: {
// Oracle date subtract
Function f = Function.getFunction(session.getDatabase(), "DATEDIFF");
f.setParameter(0, ValueExpression.get(ValueString.get("DAY")));
......
......@@ -93,3 +93,22 @@ SELECT T0 FROM TEST;
DROP TABLE TEST;
> ok
SELECT (LOCALTIMESTAMP + 1) = (CURRENT_TIMESTAMP + 1);
>> TRUE
SELECT (TIMESTAMP WITH TIME ZONE '2010-01-01 10:00:00+01' + 1) A,
(1 + TIMESTAMP WITH TIME ZONE '2010-01-01 10:00:00+01') B;
> A B
> ---------------------- ----------------------
> 2010-01-02 10:00:00+01 2010-01-02 10:00:00+01
> rows: 1
SELECT (LOCALTIMESTAMP - 1) = (CURRENT_TIMESTAMP - 1);
>> TRUE
SELECT (TIMESTAMP WITH TIME ZONE '2010-01-01 10:00:00+01' - 1) A;
> A
> ----------------------
> 2009-12-31 10:00:00+01
> rows: 1
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论