Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f2b73153
提交
f2b73153
authored
1月 17, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove Expression.getValueType()
上级
e2dea134
隐藏空白字符变更
内嵌
并排
正在显示
28 个修改的文件
包含
50 行增加
和
180 行删除
+50
-180
Parser.java
h2/src/main/org/h2/command/Parser.java
+5
-6
Call.java
h2/src/main/org/h2/command/dml/Call.java
+1
-1
SelectUnion.java
h2/src/main/org/h2/command/dml/SelectUnion.java
+1
-1
Alias.java
h2/src/main/org/h2/expression/Alias.java
+0
-5
BinaryOperation.java
h2/src/main/org/h2/expression/BinaryOperation.java
+4
-18
Expression.java
h2/src/main/org/h2/expression/Expression.java
+0
-8
ExpressionColumn.java
h2/src/main/org/h2/expression/ExpressionColumn.java
+0
-5
ExpressionList.java
h2/src/main/org/h2/expression/ExpressionList.java
+0
-5
IntervalOperation.java
h2/src/main/org/h2/expression/IntervalOperation.java
+2
-13
Rownum.java
h2/src/main/org/h2/expression/Rownum.java
+0
-5
SequenceValue.java
h2/src/main/org/h2/expression/SequenceValue.java
+0
-5
Subquery.java
h2/src/main/org/h2/expression/Subquery.java
+0
-5
UnaryOperation.java
h2/src/main/org/h2/expression/UnaryOperation.java
+0
-5
ValueExpression.java
h2/src/main/org/h2/expression/ValueExpression.java
+1
-6
Variable.java
h2/src/main/org/h2/expression/Variable.java
+0
-5
Wildcard.java
h2/src/main/org/h2/expression/Wildcard.java
+0
-5
Aggregate.java
h2/src/main/org/h2/expression/aggregate/Aggregate.java
+12
-26
JavaAggregate.java
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
+1
-6
WindowFunction.java
h2/src/main/org/h2/expression/analysis/WindowFunction.java
+1
-24
CompareLike.java
h2/src/main/org/h2/expression/condition/CompareLike.java
+1
-1
Comparison.java
h2/src/main/org/h2/expression/condition/Comparison.java
+6
-4
Condition.java
h2/src/main/org/h2/expression/condition/Condition.java
+0
-6
ConditionIn.java
h2/src/main/org/h2/expression/condition/ConditionIn.java
+1
-1
ConditionInConstantSet.java
...n/org/h2/expression/condition/ConditionInConstantSet.java
+1
-1
Function.java
h2/src/main/org/h2/expression/function/Function.java
+7
-7
ResultTempTable.java
h2/src/main/org/h2/result/ResultTempTable.java
+3
-2
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+1
-1
TableView.java
h2/src/main/org/h2/table/TableView.java
+2
-3
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
f2b73153
...
@@ -2439,8 +2439,7 @@ public class Parser {
...
@@ -2439,8 +2439,7 @@ public class Parser {
boolean
canBeNumber
=
!
readIf
(
EQUAL
);
boolean
canBeNumber
=
!
readIf
(
EQUAL
);
SelectOrderBy
order
=
new
SelectOrderBy
();
SelectOrderBy
order
=
new
SelectOrderBy
();
Expression
expr
=
readExpression
();
Expression
expr
=
readExpression
();
if
(
canBeNumber
&&
expr
instanceof
ValueExpression
&&
if
(
canBeNumber
&&
expr
instanceof
ValueExpression
&&
expr
.
getType
().
getValueType
()
==
Value
.
INT
)
{
expr
.
getValueType
()
==
Value
.
INT
)
{
order
.
columnIndexExpr
=
expr
;
order
.
columnIndexExpr
=
expr
;
}
else
if
(
expr
instanceof
Parameter
)
{
}
else
if
(
expr
instanceof
Parameter
)
{
recompileAlways
=
true
;
recompileAlways
=
true
;
...
@@ -3837,14 +3836,14 @@ public class Parser {
...
@@ -3837,14 +3836,14 @@ public class Parser {
read
();
read
();
if
(
currentTokenType
==
VALUE
)
{
if
(
currentTokenType
==
VALUE
)
{
r
=
ValueExpression
.
get
(
currentValue
.
negate
());
r
=
ValueExpression
.
get
(
currentValue
.
negate
());
if
(
r
.
getValueType
()
==
Value
.
LONG
&&
int
rType
=
r
.
getType
().
getValueType
();
if
(
rType
==
Value
.
LONG
&&
r
.
getValue
(
session
).
getLong
()
==
Integer
.
MIN_VALUE
)
{
r
.
getValue
(
session
).
getLong
()
==
Integer
.
MIN_VALUE
)
{
// convert Integer.MIN_VALUE to type 'int'
// convert Integer.MIN_VALUE to type 'int'
// (Integer.MAX_VALUE+1 is of type 'long')
// (Integer.MAX_VALUE+1 is of type 'long')
r
=
ValueExpression
.
get
(
ValueInt
.
get
(
Integer
.
MIN_VALUE
));
r
=
ValueExpression
.
get
(
ValueInt
.
get
(
Integer
.
MIN_VALUE
));
}
else
if
(
r
.
getValueType
()
==
Value
.
DECIMAL
&&
}
else
if
(
rType
==
Value
.
DECIMAL
&&
r
.
getValue
(
session
).
getBigDecimal
()
r
.
getValue
(
session
).
getBigDecimal
().
compareTo
(
Value
.
MIN_LONG_DECIMAL
)
==
0
)
{
.
compareTo
(
Value
.
MIN_LONG_DECIMAL
)
==
0
)
{
// convert Long.MIN_VALUE to type 'long'
// convert Long.MIN_VALUE to type 'long'
// (Long.MAX_VALUE+1 is of type 'decimal')
// (Long.MAX_VALUE+1 is of type 'decimal')
r
=
ValueExpression
.
get
(
ValueLong
.
MIN
);
r
=
ValueExpression
.
get
(
ValueLong
.
MIN
);
...
...
h2/src/main/org/h2/command/dml/Call.java
浏览文件 @
f2b73153
...
@@ -76,7 +76,7 @@ public class Call extends Prepared {
...
@@ -76,7 +76,7 @@ public class Call extends Prepared {
public
void
prepare
()
{
public
void
prepare
()
{
expression
=
expression
.
optimize
(
session
);
expression
=
expression
.
optimize
(
session
);
expressions
=
new
Expression
[]
{
expression
};
expressions
=
new
Expression
[]
{
expression
};
isResultSet
=
expression
.
getValueType
()
==
Value
.
RESULT_SET
;
isResultSet
=
expression
.
get
Type
().
get
ValueType
()
==
Value
.
RESULT_SET
;
if
(
isResultSet
)
{
if
(
isResultSet
)
{
prepareAlways
=
true
;
prepareAlways
=
true
;
}
}
...
...
h2/src/main/org/h2/command/dml/SelectUnion.java
浏览文件 @
f2b73153
...
@@ -122,7 +122,7 @@ public class SelectUnion extends Query {
...
@@ -122,7 +122,7 @@ public class SelectUnion extends Query {
Mode
mode
=
session
.
getDatabase
().
getMode
();
Mode
mode
=
session
.
getDatabase
().
getMode
();
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
Expression
e
=
expressions
.
get
(
i
);
Expression
e
=
expressions
.
get
(
i
);
newValues
[
i
]
=
values
[
i
].
convertTo
(
e
.
getValueType
(),
mode
);
newValues
[
i
]
=
values
[
i
].
convertTo
(
e
.
get
Type
().
get
ValueType
(),
mode
);
}
}
return
newValues
;
return
newValues
;
}
}
...
...
h2/src/main/org/h2/expression/Alias.java
浏览文件 @
f2b73153
...
@@ -42,11 +42,6 @@ public class Alias extends Expression {
...
@@ -42,11 +42,6 @@ public class Alias extends Expression {
return
expr
.
getType
();
return
expr
.
getType
();
}
}
@Override
public
int
getValueType
()
{
return
expr
.
getValueType
();
}
@Override
@Override
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
expr
.
mapColumns
(
resolver
,
level
,
state
);
expr
.
mapColumns
(
resolver
,
level
,
state
);
...
...
h2/src/main/org/h2/expression/BinaryOperation.java
浏览文件 @
f2b73153
...
@@ -60,7 +60,6 @@ public class BinaryOperation extends Expression {
...
@@ -60,7 +60,6 @@ public class BinaryOperation extends Expression {
private
OpType
opType
;
private
OpType
opType
;
private
Expression
left
,
right
;
private
Expression
left
,
right
;
private
TypeInfo
type
;
private
TypeInfo
type
;
private
int
dataType
;
private
boolean
convertRight
=
true
;
private
boolean
convertRight
=
true
;
public
BinaryOperation
(
OpType
opType
,
Expression
left
,
Expression
right
)
{
public
BinaryOperation
(
OpType
opType
,
Expression
left
,
Expression
right
)
{
...
@@ -100,6 +99,7 @@ public class BinaryOperation extends Expression {
...
@@ -100,6 +99,7 @@ public class BinaryOperation extends Expression {
@Override
@Override
public
Value
getValue
(
Session
session
)
{
public
Value
getValue
(
Session
session
)
{
Mode
mode
=
session
.
getDatabase
().
getMode
();
Mode
mode
=
session
.
getDatabase
().
getMode
();
int
dataType
=
type
.
getValueType
();
Value
l
=
left
.
getValue
(
session
).
convertTo
(
dataType
,
mode
);
Value
l
=
left
.
getValue
(
session
).
convertTo
(
dataType
,
mode
);
Value
r
=
right
.
getValue
(
session
);
Value
r
=
right
.
getValue
(
session
);
if
(
convertRight
)
{
if
(
convertRight
)
{
...
@@ -166,15 +166,14 @@ public class BinaryOperation extends Expression {
...
@@ -166,15 +166,14 @@ public class BinaryOperation extends Expression {
switch
(
opType
)
{
switch
(
opType
)
{
case
CONCAT:
case
CONCAT:
type
=
TypeInfo
.
TYPE_STRING_DEFAULT
;
type
=
TypeInfo
.
TYPE_STRING_DEFAULT
;
dataType
=
Value
.
STRING
;
break
;
break
;
case
PLUS:
case
PLUS:
case
MINUS:
case
MINUS:
case
MULTIPLY:
case
MULTIPLY:
case
DIVIDE:
case
DIVIDE:
case
MODULUS:
case
MODULUS:
int
l
=
left
.
getValueType
();
int
l
=
left
.
get
Type
().
get
ValueType
();
int
r
=
right
.
getValueType
();
int
r
=
right
.
get
Type
().
get
ValueType
();
if
((
l
==
Value
.
NULL
&&
r
==
Value
.
NULL
)
||
if
((
l
==
Value
.
NULL
&&
r
==
Value
.
NULL
)
||
(
l
==
Value
.
UNKNOWN
&&
r
==
Value
.
UNKNOWN
))
{
(
l
==
Value
.
UNKNOWN
&&
r
==
Value
.
UNKNOWN
))
{
// (? + ?) - use decimal by default (the most safe data type) or
// (? + ?) - use decimal by default (the most safe data type) or
...
@@ -182,18 +181,16 @@ public class BinaryOperation extends Expression {
...
@@ -182,18 +181,16 @@ public class BinaryOperation extends Expression {
if
(
opType
==
OpType
.
PLUS
&&
session
.
getDatabase
().
if
(
opType
==
OpType
.
PLUS
&&
session
.
getDatabase
().
getMode
().
allowPlusForStringConcat
)
{
getMode
().
allowPlusForStringConcat
)
{
type
=
TypeInfo
.
TYPE_STRING_DEFAULT
;
type
=
TypeInfo
.
TYPE_STRING_DEFAULT
;
dataType
=
Value
.
STRING
;
opType
=
OpType
.
CONCAT
;
opType
=
OpType
.
CONCAT
;
}
else
{
}
else
{
type
=
TypeInfo
.
TYPE_DECIMAL_DEFAULT
;
type
=
TypeInfo
.
TYPE_DECIMAL_DEFAULT
;
dataType
=
Value
.
DECIMAL
;
}
}
}
else
if
(
DataType
.
isIntervalType
(
l
)
||
DataType
.
isIntervalType
(
r
))
{
}
else
if
(
DataType
.
isIntervalType
(
l
)
||
DataType
.
isIntervalType
(
r
))
{
return
optimizeInterval
(
session
,
l
,
r
);
return
optimizeInterval
(
session
,
l
,
r
);
}
else
if
(
DataType
.
isDateTimeType
(
l
)
||
DataType
.
isDateTimeType
(
r
))
{
}
else
if
(
DataType
.
isDateTimeType
(
l
)
||
DataType
.
isDateTimeType
(
r
))
{
return
optimizeDateTime
(
session
,
l
,
r
);
return
optimizeDateTime
(
session
,
l
,
r
);
}
else
{
}
else
{
dataType
=
Value
.
getHigherOrder
(
l
,
r
);
int
dataType
=
Value
.
getHigherOrder
(
l
,
r
);
if
(
dataType
==
Value
.
ENUM
)
{
if
(
dataType
==
Value
.
ENUM
)
{
type
=
TypeInfo
.
TYPE_INT
;
type
=
TypeInfo
.
TYPE_INT
;
dataType
=
Value
.
INT
;
dataType
=
Value
.
INT
;
...
@@ -317,12 +314,10 @@ public class BinaryOperation extends Expression {
...
@@ -317,12 +314,10 @@ public class BinaryOperation extends Expression {
}
}
case
Value
.
TIME
:
case
Value
.
TIME
:
if
(
r
==
Value
.
TIME
||
r
==
Value
.
TIMESTAMP_TZ
)
{
if
(
r
==
Value
.
TIME
||
r
==
Value
.
TIMESTAMP_TZ
)
{
dataType
=
r
;
type
=
TypeInfo
.
getTypeInfo
(
r
);
type
=
TypeInfo
.
getTypeInfo
(
r
);
return
this
;
return
this
;
}
else
{
// DATE, TIMESTAMP
}
else
{
// DATE, TIMESTAMP
type
=
TypeInfo
.
TYPE_TIMESTAMP
;
type
=
TypeInfo
.
TYPE_TIMESTAMP
;
dataType
=
Value
.
TIMESTAMP
;
return
this
;
return
this
;
}
}
}
}
...
@@ -361,7 +356,6 @@ public class BinaryOperation extends Expression {
...
@@ -361,7 +356,6 @@ public class BinaryOperation extends Expression {
}
}
case
Value
.
TIME
:
case
Value
.
TIME
:
type
=
TypeInfo
.
TYPE_TIMESTAMP
;
type
=
TypeInfo
.
TYPE_TIMESTAMP
;
dataType
=
Value
.
TIMESTAMP
;
return
this
;
return
this
;
case
Value
.
DATE
:
case
Value
.
DATE
:
case
Value
.
TIMESTAMP
:
case
Value
.
TIMESTAMP
:
...
@@ -379,13 +373,11 @@ public class BinaryOperation extends Expression {
...
@@ -379,13 +373,11 @@ public class BinaryOperation extends Expression {
case
MULTIPLY:
case
MULTIPLY:
if
(
l
==
Value
.
TIME
)
{
if
(
l
==
Value
.
TIME
)
{
type
=
TypeInfo
.
TYPE_TIME
;
type
=
TypeInfo
.
TYPE_TIME
;
dataType
=
Value
.
TIME
;
convertRight
=
false
;
convertRight
=
false
;
return
this
;
return
this
;
}
else
if
(
r
==
Value
.
TIME
)
{
}
else
if
(
r
==
Value
.
TIME
)
{
swap
();
swap
();
type
=
TypeInfo
.
TYPE_TIME
;
type
=
TypeInfo
.
TYPE_TIME
;
dataType
=
Value
.
TIME
;
convertRight
=
false
;
convertRight
=
false
;
return
this
;
return
this
;
}
}
...
@@ -393,7 +385,6 @@ public class BinaryOperation extends Expression {
...
@@ -393,7 +385,6 @@ public class BinaryOperation extends Expression {
case
DIVIDE:
case
DIVIDE:
if
(
l
==
Value
.
TIME
)
{
if
(
l
==
Value
.
TIME
)
{
type
=
TypeInfo
.
TYPE_TIME
;
type
=
TypeInfo
.
TYPE_TIME
;
dataType
=
Value
.
TIME
;
convertRight
=
false
;
convertRight
=
false
;
return
this
;
return
this
;
}
}
...
@@ -425,11 +416,6 @@ public class BinaryOperation extends Expression {
...
@@ -425,11 +416,6 @@ public class BinaryOperation extends Expression {
return
type
;
return
type
;
}
}
@Override
public
int
getValueType
()
{
return
dataType
;
}
@Override
@Override
public
void
updateAggregate
(
Session
session
,
int
stage
)
{
public
void
updateAggregate
(
Session
session
,
int
stage
)
{
left
.
updateAggregate
(
session
,
stage
);
left
.
updateAggregate
(
session
,
stage
);
...
...
h2/src/main/org/h2/expression/Expression.java
浏览文件 @
f2b73153
...
@@ -92,14 +92,6 @@ public abstract class Expression {
...
@@ -92,14 +92,6 @@ public abstract class Expression {
*/
*/
public
abstract
TypeInfo
getType
();
public
abstract
TypeInfo
getType
();
/**
* Return the value type. The value type may not be known before the
* optimization phase.
*
* @return the value type
*/
public
abstract
int
getValueType
();
/**
/**
* Map the columns of the resolver to expression columns.
* Map the columns of the resolver to expression columns.
*
*
...
...
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
f2b73153
...
@@ -230,11 +230,6 @@ public class ExpressionColumn extends Expression {
...
@@ -230,11 +230,6 @@ public class ExpressionColumn extends Expression {
return
column
==
null
?
TypeInfo
.
TYPE_UNKNOWN
:
column
.
getType
();
return
column
==
null
?
TypeInfo
.
TYPE_UNKNOWN
:
column
.
getType
();
}
}
@Override
public
int
getValueType
()
{
return
column
==
null
?
Value
.
UNKNOWN
:
column
.
getType
().
getValueType
();
}
@Override
@Override
public
void
setEvaluatable
(
TableFilter
tableFilter
,
boolean
b
)
{
public
void
setEvaluatable
(
TableFilter
tableFilter
,
boolean
b
)
{
}
}
...
...
h2/src/main/org/h2/expression/ExpressionList.java
浏览文件 @
f2b73153
...
@@ -42,11 +42,6 @@ public class ExpressionList extends Expression {
...
@@ -42,11 +42,6 @@ public class ExpressionList extends Expression {
return
isArray
?
TypeInfo
.
TYPE_ARRAY
:
TypeInfo
.
TYPE_ROW
;
return
isArray
?
TypeInfo
.
TYPE_ARRAY
:
TypeInfo
.
TYPE_ROW
;
}
}
@Override
public
int
getValueType
()
{
return
isArray
?
Value
.
ARRAY
:
Value
.
ROW
;
}
@Override
@Override
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
for
(
Expression
e
:
list
)
{
for
(
Expression
e
:
list
)
{
...
...
h2/src/main/org/h2/expression/IntervalOperation.java
浏览文件 @
f2b73153
...
@@ -79,7 +79,6 @@ public class IntervalOperation extends Expression {
...
@@ -79,7 +79,6 @@ public class IntervalOperation extends Expression {
private
final
IntervalOpType
opType
;
private
final
IntervalOpType
opType
;
private
Expression
left
,
right
;
private
Expression
left
,
right
;
private
TypeInfo
type
;
private
TypeInfo
type
;
private
int
dataType
;
private
static
BigInteger
nanosFromValue
(
Value
v
)
{
private
static
BigInteger
nanosFromValue
(
Value
v
)
{
long
[]
a
=
dateAndTimeFromValue
(
v
);
long
[]
a
=
dateAndTimeFromValue
(
v
);
...
@@ -91,30 +90,25 @@ public class IntervalOperation extends Expression {
...
@@ -91,30 +90,25 @@ public class IntervalOperation extends Expression {
this
.
opType
=
opType
;
this
.
opType
=
opType
;
this
.
left
=
left
;
this
.
left
=
left
;
this
.
right
=
right
;
this
.
right
=
right
;
int
l
=
left
.
get
ValueType
(),
r
=
right
.
getValueType
();
int
l
=
left
.
get
Type
().
getValueType
(),
r
=
right
.
getType
()
.
getValueType
();
switch
(
opType
)
{
switch
(
opType
)
{
case
INTERVAL_PLUS_INTERVAL:
case
INTERVAL_PLUS_INTERVAL:
case
INTERVAL_MINUS_INTERVAL:
case
INTERVAL_MINUS_INTERVAL:
dataType
=
Value
.
getHigherOrder
(
l
,
r
);
type
=
TypeInfo
.
getTypeInfo
(
Value
.
getHigherOrder
(
l
,
r
));
type
=
TypeInfo
.
getTypeInfo
(
dataType
);
break
;
break
;
case
DATETIME_PLUS_INTERVAL:
case
DATETIME_PLUS_INTERVAL:
case
DATETIME_MINUS_INTERVAL:
case
DATETIME_MINUS_INTERVAL:
case
INTERVAL_MULTIPLY_NUMERIC:
case
INTERVAL_MULTIPLY_NUMERIC:
case
INTERVAL_DIVIDE_NUMERIC:
case
INTERVAL_DIVIDE_NUMERIC:
type
=
left
.
getType
();
type
=
left
.
getType
();
dataType
=
l
;
break
;
break
;
case
DATETIME_MINUS_DATETIME:
case
DATETIME_MINUS_DATETIME:
if
(
l
==
Value
.
TIME
&&
r
==
Value
.
TIME
)
{
if
(
l
==
Value
.
TIME
&&
r
==
Value
.
TIME
)
{
type
=
TypeInfo
.
TYPE_INTERVAL_HOUR_TO_SECOND
;
type
=
TypeInfo
.
TYPE_INTERVAL_HOUR_TO_SECOND
;
dataType
=
Value
.
INTERVAL_HOUR_TO_SECOND
;
}
else
if
(
l
==
Value
.
DATE
&&
r
==
Value
.
DATE
)
{
}
else
if
(
l
==
Value
.
DATE
&&
r
==
Value
.
DATE
)
{
type
=
TypeInfo
.
TYPE_INTERVAL_DAY
;
type
=
TypeInfo
.
TYPE_INTERVAL_DAY
;
dataType
=
Value
.
INTERVAL_DAY
;
}
else
{
}
else
{
type
=
TypeInfo
.
TYPE_INTERVAL_DAY_TO_SECOND
;
type
=
TypeInfo
.
TYPE_INTERVAL_DAY_TO_SECOND
;
dataType
=
Value
.
INTERVAL_DAY_TO_SECOND
;
}
}
}
}
}
}
...
@@ -288,11 +282,6 @@ public class IntervalOperation extends Expression {
...
@@ -288,11 +282,6 @@ public class IntervalOperation extends Expression {
return
type
;
return
type
;
}
}
@Override
public
int
getValueType
()
{
return
dataType
;
}
@Override
@Override
public
void
updateAggregate
(
Session
session
,
int
stage
)
{
public
void
updateAggregate
(
Session
session
,
int
stage
)
{
left
.
updateAggregate
(
session
,
stage
);
left
.
updateAggregate
(
session
,
stage
);
...
...
h2/src/main/org/h2/expression/Rownum.java
浏览文件 @
f2b73153
...
@@ -38,11 +38,6 @@ public class Rownum extends Expression {
...
@@ -38,11 +38,6 @@ public class Rownum extends Expression {
return
TypeInfo
.
TYPE_LONG
;
return
TypeInfo
.
TYPE_LONG
;
}
}
@Override
public
int
getValueType
()
{
return
Value
.
LONG
;
}
@Override
@Override
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
// nothing to do
// nothing to do
...
...
h2/src/main/org/h2/expression/SequenceValue.java
浏览文件 @
f2b73153
...
@@ -37,11 +37,6 @@ public class SequenceValue extends Expression {
...
@@ -37,11 +37,6 @@ public class SequenceValue extends Expression {
return
TypeInfo
.
TYPE_LONG
;
return
TypeInfo
.
TYPE_LONG
;
}
}
@Override
public
int
getValueType
()
{
return
Value
.
LONG
;
}
@Override
@Override
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
// nothing to do
// nothing to do
...
...
h2/src/main/org/h2/expression/Subquery.java
浏览文件 @
f2b73153
...
@@ -58,11 +58,6 @@ public class Subquery extends Expression {
...
@@ -58,11 +58,6 @@ public class Subquery extends Expression {
return
getExpression
().
getType
();
return
getExpression
().
getType
();
}
}
@Override
public
int
getValueType
()
{
return
getExpression
().
getValueType
();
}
@Override
@Override
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
query
.
mapColumns
(
resolver
,
level
+
1
);
query
.
mapColumns
(
resolver
,
level
+
1
);
...
...
h2/src/main/org/h2/expression/UnaryOperation.java
浏览文件 @
f2b73153
...
@@ -68,11 +68,6 @@ public class UnaryOperation extends Expression {
...
@@ -68,11 +68,6 @@ public class UnaryOperation extends Expression {
return
type
;
return
type
;
}
}
@Override
public
int
getValueType
()
{
return
type
.
getValueType
();
}
@Override
@Override
public
void
updateAggregate
(
Session
session
,
int
stage
)
{
public
void
updateAggregate
(
Session
session
,
int
stage
)
{
arg
.
updateAggregate
(
session
,
stage
);
arg
.
updateAggregate
(
session
,
stage
);
...
...
h2/src/main/org/h2/expression/ValueExpression.java
浏览文件 @
f2b73153
...
@@ -80,11 +80,6 @@ public class ValueExpression extends Expression {
...
@@ -80,11 +80,6 @@ public class ValueExpression extends Expression {
return
value
.
getType
();
return
value
.
getType
();
}
}
@Override
public
int
getValueType
()
{
return
value
.
getValueType
();
}
@Override
@Override
public
void
createIndexConditions
(
Session
session
,
TableFilter
filter
)
{
public
void
createIndexConditions
(
Session
session
,
TableFilter
filter
)
{
if
(
value
.
getValueType
()
==
Value
.
BOOLEAN
)
{
if
(
value
.
getValueType
()
==
Value
.
BOOLEAN
)
{
...
@@ -168,7 +163,7 @@ public class ValueExpression extends Expression {
...
@@ -168,7 +163,7 @@ public class ValueExpression extends Expression {
@Override
@Override
public
Expression
[]
getExpressionColumns
(
Session
session
)
{
public
Expression
[]
getExpressionColumns
(
Session
session
)
{
if
(
getValueType
()
==
Value
.
ARRAY
)
{
if
(
get
Type
().
get
ValueType
()
==
Value
.
ARRAY
)
{
return
getExpressionColumns
(
session
,
(
ValueArray
)
getValue
(
session
));
return
getExpressionColumns
(
session
,
(
ValueArray
)
getValue
(
session
));
}
}
return
super
.
getExpressionColumns
(
session
);
return
super
.
getExpressionColumns
(
session
);
...
...
h2/src/main/org/h2/expression/Variable.java
浏览文件 @
f2b73153
...
@@ -42,11 +42,6 @@ public class Variable extends Expression {
...
@@ -42,11 +42,6 @@ public class Variable extends Expression {
return
lastValue
.
getType
();
return
lastValue
.
getType
();
}
}
@Override
public
int
getValueType
()
{
return
lastValue
.
getValueType
();
}
@Override
@Override
public
Value
getValue
(
Session
session
)
{
public
Value
getValue
(
Session
session
)
{
lastValue
=
session
.
getVariable
(
name
);
lastValue
=
session
.
getVariable
(
name
);
...
...
h2/src/main/org/h2/expression/Wildcard.java
浏览文件 @
f2b73153
...
@@ -72,11 +72,6 @@ public class Wildcard extends Expression {
...
@@ -72,11 +72,6 @@ public class Wildcard extends Expression {
throw
DbException
.
throwInternalError
(
toString
());
throw
DbException
.
throwInternalError
(
toString
());
}
}
@Override
public
int
getValueType
()
{
throw
DbException
.
throwInternalError
(
toString
());
}
@Override
@Override
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
if
(
exceptColumns
!=
null
)
{
if
(
exceptColumns
!=
null
)
{
...
...
h2/src/main/org/h2/expression/aggregate/Aggregate.java
浏览文件 @
f2b73153
...
@@ -164,7 +164,6 @@ public class Aggregate extends AbstractAggregate {
...
@@ -164,7 +164,6 @@ public class Aggregate extends AbstractAggregate {
private
ArrayList
<
SelectOrderBy
>
orderByList
;
private
ArrayList
<
SelectOrderBy
>
orderByList
;
private
SortOrder
orderBySort
;
private
SortOrder
orderBySort
;
private
TypeInfo
type
;
private
TypeInfo
type
;
private
int
dataType
;
/**
/**
* Create a new aggregate object.
* Create a new aggregate object.
...
@@ -304,7 +303,7 @@ public class Aggregate extends AbstractAggregate {
...
@@ -304,7 +303,7 @@ public class Aggregate extends AbstractAggregate {
v
=
updateCollecting
(
session
,
v
,
remembered
);
v
=
updateCollecting
(
session
,
v
,
remembered
);
}
}
}
}
data
.
add
(
session
.
getDatabase
(),
dataType
,
v
);
data
.
add
(
session
.
getDatabase
(),
type
.
getValueType
()
,
v
);
}
}
@Override
@Override
...
@@ -410,7 +409,7 @@ public class Aggregate extends AbstractAggregate {
...
@@ -410,7 +409,7 @@ public class Aggregate extends AbstractAggregate {
return
v
;
return
v
;
}
}
case
MEDIAN:
case
MEDIAN:
return
AggregateMedian
.
medianFromIndex
(
session
,
on
,
dataType
);
return
AggregateMedian
.
medianFromIndex
(
session
,
on
,
type
.
getValueType
()
);
case
ENVELOPE:
case
ENVELOPE:
return
((
MVSpatialIndex
)
AggregateDataEnvelope
.
getGeometryColumnIndex
(
on
)).
getBounds
(
session
);
return
((
MVSpatialIndex
)
AggregateDataEnvelope
.
getGeometryColumnIndex
(
on
)).
getBounds
(
session
);
default
:
default
:
...
@@ -443,6 +442,7 @@ public class Aggregate extends AbstractAggregate {
...
@@ -443,6 +442,7 @@ public class Aggregate extends AbstractAggregate {
}
}
AggregateDataDefault
d
=
new
AggregateDataDefault
(
aggregateType
);
AggregateDataDefault
d
=
new
AggregateDataDefault
(
aggregateType
);
Database
db
=
session
.
getDatabase
();
Database
db
=
session
.
getDatabase
();
int
dataType
=
type
.
getValueType
();
for
(
Value
v
:
c
)
{
for
(
Value
v
:
c
)
{
d
.
add
(
db
,
dataType
,
v
);
d
.
add
(
db
,
dataType
,
v
);
}
}
...
@@ -473,14 +473,14 @@ public class Aggregate extends AbstractAggregate {
...
@@ -473,14 +473,14 @@ public class Aggregate extends AbstractAggregate {
if
(
array
==
null
)
{
if
(
array
==
null
)
{
return
ValueNull
.
INSTANCE
;
return
ValueNull
.
INSTANCE
;
}
}
return
AggregateMedian
.
median
(
session
.
getDatabase
(),
array
,
dataType
);
return
AggregateMedian
.
median
(
session
.
getDatabase
(),
array
,
type
.
getValueType
()
);
}
}
case
MODE:
case
MODE:
return
getMode
(
session
,
data
);
return
getMode
(
session
,
data
);
default
:
default
:
// Avoid compiler warning
// Avoid compiler warning
}
}
return
data
.
getValue
(
session
.
getDatabase
(),
dataType
);
return
data
.
getValue
(
session
.
getDatabase
(),
type
.
getValueType
()
);
}
}
private
Value
getGroupConcat
(
Session
session
,
AggregateData
data
)
{
private
Value
getGroupConcat
(
Session
session
,
AggregateData
data
)
{
...
@@ -573,7 +573,7 @@ public class Aggregate extends AbstractAggregate {
...
@@ -573,7 +573,7 @@ public class Aggregate extends AbstractAggregate {
}
}
}
}
}
}
return
v
.
convertTo
(
dataType
);
return
v
.
convertTo
(
type
.
getValueType
()
);
}
}
@Override
@Override
...
@@ -581,11 +581,6 @@ public class Aggregate extends AbstractAggregate {
...
@@ -581,11 +581,6 @@ public class Aggregate extends AbstractAggregate {
return
type
;
return
type
;
}
}
@Override
public
int
getValueType
()
{
return
dataType
;
}
@Override
@Override
public
void
mapColumnsAnalysis
(
ColumnResolver
resolver
,
int
level
,
int
innerState
)
{
public
void
mapColumnsAnalysis
(
ColumnResolver
resolver
,
int
level
,
int
innerState
)
{
if
(
on
!=
null
)
{
if
(
on
!=
null
)
{
...
@@ -608,7 +603,6 @@ public class Aggregate extends AbstractAggregate {
...
@@ -608,7 +603,6 @@ public class Aggregate extends AbstractAggregate {
if
(
on
!=
null
)
{
if
(
on
!=
null
)
{
on
=
on
.
optimize
(
session
);
on
=
on
.
optimize
(
session
);
type
=
on
.
getType
();
type
=
on
.
getType
();
dataType
=
on
.
getValueType
();
}
}
if
(
orderByList
!=
null
)
{
if
(
orderByList
!=
null
)
{
for
(
SelectOrderBy
o
:
orderByList
)
{
for
(
SelectOrderBy
o
:
orderByList
)
{
...
@@ -622,35 +616,31 @@ public class Aggregate extends AbstractAggregate {
...
@@ -622,35 +616,31 @@ public class Aggregate extends AbstractAggregate {
switch
(
aggregateType
)
{
switch
(
aggregateType
)
{
case
GROUP_CONCAT:
case
GROUP_CONCAT:
type
=
TypeInfo
.
TYPE_STRING_DEFAULT
;
type
=
TypeInfo
.
TYPE_STRING_DEFAULT
;
dataType
=
Value
.
STRING
;
break
;
break
;
case
COUNT_ALL:
case
COUNT_ALL:
case
COUNT:
case
COUNT:
type
=
TypeInfo
.
TYPE_LONG
;
type
=
TypeInfo
.
TYPE_LONG
;
dataType
=
Value
.
LONG
;
break
;
break
;
case
SELECTIVITY:
case
SELECTIVITY:
type
=
TypeInfo
.
TYPE_INT
;
type
=
TypeInfo
.
TYPE_INT
;
dataType
=
Value
.
INT
;
break
;
break
;
case
HISTOGRAM:
case
HISTOGRAM:
type
=
TypeInfo
.
TYPE_ARRAY
;
type
=
TypeInfo
.
TYPE_ARRAY
;
dataType
=
Value
.
ARRAY
;
break
;
break
;
case
SUM:
case
SUM:
{
int
dataType
=
type
.
getValueType
();
if
(
dataType
==
Value
.
BOOLEAN
)
{
if
(
dataType
==
Value
.
BOOLEAN
)
{
// example: sum(id > 3) (count the rows)
// example: sum(id > 3) (count the rows)
type
=
TypeInfo
.
TYPE_LONG
;
type
=
TypeInfo
.
TYPE_LONG
;
dataType
=
Value
.
LONG
;
}
else
if
(!
DataType
.
supportsAdd
(
dataType
))
{
}
else
if
(!
DataType
.
supportsAdd
(
dataType
))
{
throw
DbException
.
get
(
ErrorCode
.
SUM_OR_AVG_ON_WRONG_DATATYPE_1
,
getSQL
());
throw
DbException
.
get
(
ErrorCode
.
SUM_OR_AVG_ON_WRONG_DATATYPE_1
,
getSQL
());
}
else
{
}
else
{
dataType
=
DataType
.
getAddProofType
(
dataType
);
type
=
TypeInfo
.
getTypeInfo
(
DataType
.
getAddProofType
(
dataType
));
type
=
TypeInfo
.
getTypeInfo
(
dataType
);
}
}
break
;
break
;
}
case
AVG:
case
AVG:
if
(!
DataType
.
supportsAdd
(
dataType
))
{
if
(!
DataType
.
supportsAdd
(
type
.
getValueType
()
))
{
throw
DbException
.
get
(
ErrorCode
.
SUM_OR_AVG_ON_WRONG_DATATYPE_1
,
getSQL
());
throw
DbException
.
get
(
ErrorCode
.
SUM_OR_AVG_ON_WRONG_DATATYPE_1
,
getSQL
());
}
}
break
;
break
;
...
@@ -664,26 +654,22 @@ public class Aggregate extends AbstractAggregate {
...
@@ -664,26 +654,22 @@ public class Aggregate extends AbstractAggregate {
case
VAR_POP:
case
VAR_POP:
case
VAR_SAMP:
case
VAR_SAMP:
type
=
TypeInfo
.
TYPE_DOUBLE
;
type
=
TypeInfo
.
TYPE_DOUBLE
;
dataType
=
Value
.
DOUBLE
;
break
;
break
;
case
EVERY:
case
EVERY:
case
ANY:
case
ANY:
type
=
TypeInfo
.
TYPE_BOOLEAN
;
type
=
TypeInfo
.
TYPE_BOOLEAN
;
dataType
=
Value
.
BOOLEAN
;
break
;
break
;
case
BIT_AND:
case
BIT_AND:
case
BIT_OR:
case
BIT_OR:
if
(!
DataType
.
supportsAdd
(
dataType
))
{
if
(!
DataType
.
supportsAdd
(
type
.
getValueType
()
))
{
throw
DbException
.
get
(
ErrorCode
.
SUM_OR_AVG_ON_WRONG_DATATYPE_1
,
getSQL
());
throw
DbException
.
get
(
ErrorCode
.
SUM_OR_AVG_ON_WRONG_DATATYPE_1
,
getSQL
());
}
}
break
;
break
;
case
ARRAY_AGG:
case
ARRAY_AGG:
type
=
TypeInfo
.
TYPE_ARRAY
;
type
=
TypeInfo
.
TYPE_ARRAY
;
dataType
=
Value
.
ARRAY
;
break
;
break
;
case
ENVELOPE:
case
ENVELOPE:
type
=
TypeInfo
.
TYPE_GEOMETRY
;
type
=
TypeInfo
.
TYPE_GEOMETRY
;
dataType
=
Value
.
GEOMETRY
;
break
;
break
;
default
:
default
:
DbException
.
throwInternalError
(
"type="
+
aggregateType
);
DbException
.
throwInternalError
(
"type="
+
aggregateType
);
...
...
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
浏览文件 @
f2b73153
...
@@ -67,11 +67,6 @@ public class JavaAggregate extends AbstractAggregate {
...
@@ -67,11 +67,6 @@ public class JavaAggregate extends AbstractAggregate {
return
type
;
return
type
;
}
}
@Override
public
int
getValueType
()
{
return
dataType
;
}
@Override
@Override
public
boolean
isEverything
(
ExpressionVisitor
visitor
)
{
public
boolean
isEverything
(
ExpressionVisitor
visitor
)
{
if
(!
super
.
isEverything
(
visitor
))
{
if
(!
super
.
isEverything
(
visitor
))
{
...
@@ -114,7 +109,7 @@ public class JavaAggregate extends AbstractAggregate {
...
@@ -114,7 +109,7 @@ public class JavaAggregate extends AbstractAggregate {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Expression
expr
=
args
[
i
];
Expression
expr
=
args
[
i
];
args
[
i
]
=
expr
.
optimize
(
session
);
args
[
i
]
=
expr
.
optimize
(
session
);
int
type
=
expr
.
getValueType
();
int
type
=
expr
.
get
Type
().
get
ValueType
();
argTypes
[
i
]
=
type
;
argTypes
[
i
]
=
type
;
}
}
try
{
try
{
...
...
h2/src/main/org/h2/expression/analysis/WindowFunction.java
浏览文件 @
f2b73153
...
@@ -287,7 +287,7 @@ public class WindowFunction extends DataAnalysisOperation {
...
@@ -287,7 +287,7 @@ public class WindowFunction extends DataAnalysisOperation {
int
rowIdColumn
)
{
int
rowIdColumn
)
{
int
size
=
ordered
.
size
();
int
size
=
ordered
.
size
();
int
numExpressions
=
getNumExpressions
();
int
numExpressions
=
getNumExpressions
();
int
dataType
=
args
[
0
].
getValueType
();
int
dataType
=
args
[
0
].
get
Type
().
get
ValueType
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Value
[]
row
=
ordered
.
get
(
i
);
Value
[]
row
=
ordered
.
get
(
i
);
int
rowId
=
row
[
rowIdColumn
].
getInt
();
int
rowId
=
row
[
rowIdColumn
].
getInt
();
...
@@ -498,29 +498,6 @@ public class WindowFunction extends DataAnalysisOperation {
...
@@ -498,29 +498,6 @@ public class WindowFunction extends DataAnalysisOperation {
}
}
}
}
@Override
public
int
getValueType
()
{
switch
(
type
)
{
case
ROW_NUMBER:
case
RANK:
case
DENSE_RANK:
case
NTILE:
return
Value
.
LONG
;
case
PERCENT_RANK:
case
CUME_DIST:
case
RATIO_TO_REPORT:
return
Value
.
DOUBLE
;
case
LEAD:
case
LAG:
case
FIRST_VALUE:
case
LAST_VALUE:
case
NTH_VALUE:
return
args
[
0
].
getValueType
();
default
:
throw
DbException
.
throwInternalError
(
"type="
+
type
);
}
}
@Override
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
String
name
=
type
.
getSQL
();
String
name
=
type
.
getSQL
();
...
...
h2/src/main/org/h2/expression/condition/CompareLike.java
浏览文件 @
f2b73153
...
@@ -100,7 +100,7 @@ public class CompareLike extends Condition {
...
@@ -100,7 +100,7 @@ public class CompareLike extends Condition {
public
Expression
optimize
(
Session
session
)
{
public
Expression
optimize
(
Session
session
)
{
left
=
left
.
optimize
(
session
);
left
=
left
.
optimize
(
session
);
right
=
right
.
optimize
(
session
);
right
=
right
.
optimize
(
session
);
if
(
left
.
getValueType
()
==
Value
.
STRING_IGNORECASE
)
{
if
(
left
.
get
Type
().
get
ValueType
()
==
Value
.
STRING_IGNORECASE
)
{
ignoreCase
=
true
;
ignoreCase
=
true
;
}
}
if
(
left
.
isValueSet
())
{
if
(
left
.
isValueSet
())
{
...
...
h2/src/main/org/h2/expression/condition/Comparison.java
浏览文件 @
f2b73153
...
@@ -206,7 +206,7 @@ public class Comparison extends Condition {
...
@@ -206,7 +206,7 @@ public class Comparison extends Condition {
if
(
right
!=
null
)
{
if
(
right
!=
null
)
{
right
=
right
.
optimize
(
session
);
right
=
right
.
optimize
(
session
);
// TODO check row values too
// TODO check row values too
if
(
right
.
get
ValueType
()
==
Value
.
ARRAY
&&
left
.
getValueType
()
!=
Value
.
ARRAY
)
{
if
(
right
.
get
Type
().
getValueType
()
==
Value
.
ARRAY
&&
left
.
getType
()
.
getValueType
()
!=
Value
.
ARRAY
)
{
throw
DbException
.
get
(
ErrorCode
.
COMPARING_ARRAY_TO_SCALAR
);
throw
DbException
.
get
(
ErrorCode
.
COMPARING_ARRAY_TO_SCALAR
);
}
}
if
(
right
instanceof
ExpressionColumn
)
{
if
(
right
instanceof
ExpressionColumn
)
{
...
@@ -225,7 +225,7 @@ public class Comparison extends Condition {
...
@@ -225,7 +225,7 @@ public class Comparison extends Condition {
return
ValueExpression
.
getNull
();
return
ValueExpression
.
getNull
();
}
}
}
}
int
colType
=
left
.
getValueType
();
int
colType
=
left
.
get
Type
().
get
ValueType
();
int
constType
=
r
.
getValueType
();
int
constType
=
r
.
getValueType
();
int
resType
=
Value
.
getHigherOrder
(
colType
,
constType
);
int
resType
=
Value
.
getHigherOrder
(
colType
,
constType
);
// If not, the column values will need to be promoted
// If not, the column values will need to be promoted
...
@@ -516,12 +516,14 @@ public class Comparison extends Condition {
...
@@ -516,12 +516,14 @@ public class Comparison extends Condition {
}
}
if
(
addIndex
)
{
if
(
addIndex
)
{
if
(
l
!=
null
)
{
if
(
l
!=
null
)
{
if
(
l
.
getValueType
()
==
right
.
getValueType
()
||
right
.
getValueType
()
!=
Value
.
STRING_IGNORECASE
)
{
int
rType
=
right
.
getType
().
getValueType
();
if
(
l
.
getType
().
getValueType
()
==
rType
||
rType
!=
Value
.
STRING_IGNORECASE
)
{
filter
.
addIndexCondition
(
filter
.
addIndexCondition
(
IndexCondition
.
get
(
compareType
,
l
,
right
));
IndexCondition
.
get
(
compareType
,
l
,
right
));
}
}
}
else
if
(
r
!=
null
)
{
}
else
if
(
r
!=
null
)
{
if
(
r
.
getValueType
()
==
left
.
getValueType
()
||
left
.
getValueType
()
!=
Value
.
STRING_IGNORECASE
)
{
int
lType
=
left
.
getType
().
getValueType
();
if
(
r
.
getType
().
getValueType
()
==
lType
||
lType
!=
Value
.
STRING_IGNORECASE
)
{
int
compareRev
=
getReversedCompareType
(
compareType
);
int
compareRev
=
getReversedCompareType
(
compareType
);
filter
.
addIndexCondition
(
filter
.
addIndexCondition
(
IndexCondition
.
get
(
compareRev
,
r
,
left
));
IndexCondition
.
get
(
compareRev
,
r
,
left
));
...
...
h2/src/main/org/h2/expression/condition/Condition.java
浏览文件 @
f2b73153
...
@@ -7,7 +7,6 @@ package org.h2.expression.condition;
...
@@ -7,7 +7,6 @@ package org.h2.expression.condition;
import
org.h2.expression.Expression
;
import
org.h2.expression.Expression
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
/**
/**
* Represents a condition returning a boolean value, or NULL.
* Represents a condition returning a boolean value, or NULL.
...
@@ -19,9 +18,4 @@ abstract class Condition extends Expression {
...
@@ -19,9 +18,4 @@ abstract class Condition extends Expression {
return
TypeInfo
.
TYPE_BOOLEAN
;
return
TypeInfo
.
TYPE_BOOLEAN
;
}
}
@Override
public
int
getValueType
()
{
return
Value
.
BOOLEAN
;
}
}
}
h2/src/main/org/h2/expression/condition/ConditionIn.java
浏览文件 @
f2b73153
...
@@ -150,7 +150,7 @@ public class ConditionIn extends Condition {
...
@@ -150,7 +150,7 @@ public class ConditionIn extends Condition {
return
new
Comparison
(
session
,
Comparison
.
EQUAL
,
left
,
values
.
get
(
0
)).
optimize
(
session
);
return
new
Comparison
(
session
,
Comparison
.
EQUAL
,
left
,
values
.
get
(
0
)).
optimize
(
session
);
}
}
if
(
allValuesConstant
&&
!
allValuesNull
)
{
if
(
allValuesConstant
&&
!
allValuesNull
)
{
int
leftType
=
left
.
getValueType
();
int
leftType
=
left
.
get
Type
().
get
ValueType
();
if
(
leftType
==
Value
.
UNKNOWN
)
{
if
(
leftType
==
Value
.
UNKNOWN
)
{
return
this
;
return
this
;
}
}
...
...
h2/src/main/org/h2/expression/condition/ConditionInConstantSet.java
浏览文件 @
f2b73153
...
@@ -54,7 +54,7 @@ public class ConditionInConstantSet extends Condition {
...
@@ -54,7 +54,7 @@ public class ConditionInConstantSet extends Condition {
this
.
valueList
=
valueList
;
this
.
valueList
=
valueList
;
Database
database
=
session
.
getDatabase
();
Database
database
=
session
.
getDatabase
();
this
.
valueSet
=
new
TreeSet
<>(
database
.
getCompareMode
());
this
.
valueSet
=
new
TreeSet
<>(
database
.
getCompareMode
());
type
=
left
.
getValueType
();
type
=
left
.
get
Type
().
get
ValueType
();
Mode
mode
=
database
.
getMode
();
Mode
mode
=
database
.
getMode
();
if
(
type
==
Value
.
ENUM
)
{
if
(
type
==
Value
.
ENUM
)
{
extTypeInfo
=
((
ExpressionColumn
)
left
).
getColumn
().
getType
().
getExtTypeInfo
();
extTypeInfo
=
((
ExpressionColumn
)
left
).
getColumn
().
getType
().
getExtTypeInfo
();
...
...
h2/src/main/org/h2/expression/function/Function.java
浏览文件 @
f2b73153
...
@@ -2327,7 +2327,7 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2327,7 +2327,7 @@ public class Function extends Expression implements FunctionCall {
s
=
ValueTimestamp
.
MAXIMUM_SCALE
;
s
=
ValueTimestamp
.
MAXIMUM_SCALE
;
if
(
p0
.
isConstant
())
{
if
(
p0
.
isConstant
())
{
Expression
p2
=
args
[
2
];
Expression
p2
=
args
[
2
];
switch
(
p2
.
getValueType
())
{
switch
(
p2
.
get
Type
().
get
ValueType
())
{
case
Value
.
TIME
:
case
Value
.
TIME
:
t
=
Value
.
TIME
;
t
=
Value
.
TIME
;
p
=
d
=
ValueTime
.
DEFAULT_PRECISION
;
p
=
d
=
ValueTime
.
DEFAULT_PRECISION
;
...
@@ -2374,7 +2374,7 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2374,7 +2374,7 @@ public class Function extends Expression implements FunctionCall {
}
}
case
DATE_TRUNC:
{
case
DATE_TRUNC:
{
Expression
p1
=
args
[
1
];
Expression
p1
=
args
[
1
];
t
=
p1
.
getValueType
();
t
=
p1
.
get
Type
().
get
ValueType
();
if
(
t
==
Value
.
TIMESTAMP_TZ
)
{
if
(
t
==
Value
.
TIMESTAMP_TZ
)
{
p
=
d
=
ValueTimestampTimeZone
.
DEFAULT_PRECISION
;
p
=
d
=
ValueTimestampTimeZone
.
DEFAULT_PRECISION
;
}
else
{
}
else
{
...
@@ -2466,18 +2466,18 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2466,18 +2466,18 @@ public class Function extends Expression implements FunctionCall {
break
;
break
;
}
}
case
NVL2:
{
case
NVL2:
{
switch
(
args
[
1
].
getValueType
())
{
TypeInfo
t1
=
args
[
1
].
getType
(),
t2
=
args
[
2
].
getType
();
switch
(
t1
.
getValueType
())
{
case
Value
.
STRING
:
case
Value
.
STRING
:
case
Value
.
CLOB
:
case
Value
.
CLOB
:
case
Value
.
STRING_FIXED
:
case
Value
.
STRING_FIXED
:
case
Value
.
STRING_IGNORECASE
:
case
Value
.
STRING_IGNORECASE
:
t
=
args
[
1
]
.
getValueType
();
t
=
t1
.
getValueType
();
break
;
break
;
default
:
default
:
t
=
Value
.
getHigherOrder
(
args
[
1
].
getValueType
(),
args
[
2
]
.
getValueType
());
t
=
Value
.
getHigherOrder
(
t1
.
getValueType
(),
t2
.
getValueType
());
break
;
break
;
}
}
TypeInfo
t1
=
args
[
1
].
getType
(),
t2
=
args
[
2
].
getType
();
p
=
Math
.
max
(
t1
.
getPrecision
(),
t2
.
getPrecision
());
p
=
Math
.
max
(
t1
.
getPrecision
(),
t2
.
getPrecision
());
d
=
Math
.
max
(
t1
.
getDisplaySize
(),
t2
.
getDisplaySize
());
d
=
Math
.
max
(
t1
.
getDisplaySize
(),
t2
.
getDisplaySize
());
s
=
Math
.
max
(
t1
.
getScale
(),
t2
.
getScale
());
s
=
Math
.
max
(
t1
.
getScale
(),
t2
.
getScale
());
...
@@ -2498,7 +2498,7 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2498,7 +2498,7 @@ public class Function extends Expression implements FunctionCall {
}
}
break
;
break
;
case
TRUNCATE:
case
TRUNCATE:
switch
(
p0
.
getValueType
())
{
switch
(
p0
.
get
Type
().
get
ValueType
())
{
case
Value
.
STRING
:
case
Value
.
STRING
:
case
Value
.
DATE
:
case
Value
.
DATE
:
case
Value
.
TIMESTAMP
:
case
Value
.
TIMESTAMP
:
...
...
h2/src/main/org/h2/result/ResultTempTable.java
浏览文件 @
f2b73153
...
@@ -24,6 +24,7 @@ import org.h2.table.IndexColumn;
...
@@ -24,6 +24,7 @@ import org.h2.table.IndexColumn;
import
org.h2.table.Table
;
import
org.h2.table.Table
;
import
org.h2.util.TempFileDeleter
;
import
org.h2.util.TempFileDeleter
;
import
org.h2.value.DataType
;
import
org.h2.value.DataType
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueNull
;
...
@@ -117,9 +118,9 @@ public class ResultTempTable implements ResultExternal {
...
@@ -117,9 +118,9 @@ public class ResultTempTable implements ResultExternal {
CreateTableData
data
=
new
CreateTableData
();
CreateTableData
data
=
new
CreateTableData
();
boolean
containsLob
=
false
;
boolean
containsLob
=
false
;
for
(
int
i
=
0
;
i
<
expressions
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
expressions
.
length
;
i
++)
{
int
type
=
expressions
[
i
].
getValue
Type
();
TypeInfo
type
=
expressions
[
i
].
get
Type
();
Column
col
=
new
Column
(
COLUMN_NAME
+
i
,
type
);
Column
col
=
new
Column
(
COLUMN_NAME
+
i
,
type
);
if
(
DataType
.
isLargeObject
(
type
))
{
if
(
DataType
.
isLargeObject
(
type
.
getValueType
()
))
{
containsLob
=
true
;
containsLob
=
true
;
}
}
data
.
columns
.
add
(
col
);
data
.
columns
.
add
(
col
);
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
f2b73153
...
@@ -1762,7 +1762,7 @@ public class MetaTable extends Table {
...
@@ -1762,7 +1762,7 @@ public class MetaTable extends Table {
// CONSTANT_NAME
// CONSTANT_NAME
identifier
(
constant
.
getName
()),
identifier
(
constant
.
getName
()),
// DATA_TYPE
// DATA_TYPE
ValueInt
.
get
(
DataType
.
convertTypeToSQLType
(
expr
.
getValueType
())),
ValueInt
.
get
(
DataType
.
convertTypeToSQLType
(
expr
.
get
Type
().
get
ValueType
())),
// REMARKS
// REMARKS
replaceNullWithEmpty
(
constant
.
getComment
()),
replaceNullWithEmpty
(
constant
.
getComment
()),
// SQL
// SQL
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
f2b73153
...
@@ -192,7 +192,7 @@ public class TableView extends Table {
...
@@ -192,7 +192,7 @@ public class TableView extends Table {
}
}
name
=
columnNamer
.
getColumnName
(
expr
,
i
,
name
);
name
=
columnNamer
.
getColumnName
(
expr
,
i
,
name
);
if
(
valueType
==
Value
.
UNKNOWN
)
{
if
(
valueType
==
Value
.
UNKNOWN
)
{
valueType
=
expr
.
getValueType
();
valueType
=
expr
.
get
Type
().
get
ValueType
();
}
}
TypeInfo
type
=
expr
.
getType
();
TypeInfo
type
=
expr
.
getType
();
long
precision
=
type
.
getPrecision
();
long
precision
=
type
.
getPrecision
();
...
@@ -819,8 +819,7 @@ public class TableView extends Table {
...
@@ -819,8 +819,7 @@ public class TableView extends Table {
// (if found) otherwise use column name derived from column
// (if found) otherwise use column name derived from column
// expression
// expression
String
columnName
=
columnNamer
.
getColumnName
(
columnExp
,
i
,
cols
);
String
columnName
=
columnNamer
.
getColumnName
(
columnExp
,
i
,
cols
);
columnTemplateList
.
add
(
new
Column
(
columnName
,
columnTemplateList
.
add
(
new
Column
(
columnName
,
columnExp
.
getType
()));
columnExp
.
getValueType
()));
}
}
return
columnTemplateList
;
return
columnTemplateList
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论