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 {
boolean
canBeNumber
=
!
readIf
(
EQUAL
);
SelectOrderBy
order
=
new
SelectOrderBy
();
Expression
expr
=
readExpression
();
if
(
canBeNumber
&&
expr
instanceof
ValueExpression
&&
expr
.
getValueType
()
==
Value
.
INT
)
{
if
(
canBeNumber
&&
expr
instanceof
ValueExpression
&&
expr
.
getType
().
getValueType
()
==
Value
.
INT
)
{
order
.
columnIndexExpr
=
expr
;
}
else
if
(
expr
instanceof
Parameter
)
{
recompileAlways
=
true
;
...
...
@@ -3837,14 +3836,14 @@ public class Parser {
read
();
if
(
currentTokenType
==
VALUE
)
{
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
)
{
// convert Integer.MIN_VALUE to type 'int'
// (Integer.MAX_VALUE+1 is of type 'long')
r
=
ValueExpression
.
get
(
ValueInt
.
get
(
Integer
.
MIN_VALUE
));
}
else
if
(
r
.
getValueType
()
==
Value
.
DECIMAL
&&
r
.
getValue
(
session
).
getBigDecimal
()
.
compareTo
(
Value
.
MIN_LONG_DECIMAL
)
==
0
)
{
}
else
if
(
rType
==
Value
.
DECIMAL
&&
r
.
getValue
(
session
).
getBigDecimal
().
compareTo
(
Value
.
MIN_LONG_DECIMAL
)
==
0
)
{
// convert Long.MIN_VALUE to type 'long'
// (Long.MAX_VALUE+1 is of type 'decimal')
r
=
ValueExpression
.
get
(
ValueLong
.
MIN
);
...
...
h2/src/main/org/h2/command/dml/Call.java
浏览文件 @
f2b73153
...
...
@@ -76,7 +76,7 @@ public class Call extends Prepared {
public
void
prepare
()
{
expression
=
expression
.
optimize
(
session
);
expressions
=
new
Expression
[]
{
expression
};
isResultSet
=
expression
.
getValueType
()
==
Value
.
RESULT_SET
;
isResultSet
=
expression
.
get
Type
().
get
ValueType
()
==
Value
.
RESULT_SET
;
if
(
isResultSet
)
{
prepareAlways
=
true
;
}
...
...
h2/src/main/org/h2/command/dml/SelectUnion.java
浏览文件 @
f2b73153
...
...
@@ -122,7 +122,7 @@ public class SelectUnion extends Query {
Mode
mode
=
session
.
getDatabase
().
getMode
();
for
(
int
i
=
0
;
i
<
columnCount
;
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
;
}
...
...
h2/src/main/org/h2/expression/Alias.java
浏览文件 @
f2b73153
...
...
@@ -42,11 +42,6 @@ public class Alias extends Expression {
return
expr
.
getType
();
}
@Override
public
int
getValueType
()
{
return
expr
.
getValueType
();
}
@Override
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
expr
.
mapColumns
(
resolver
,
level
,
state
);
...
...
h2/src/main/org/h2/expression/BinaryOperation.java
浏览文件 @
f2b73153
...
...
@@ -60,7 +60,6 @@ public class BinaryOperation extends Expression {
private
OpType
opType
;
private
Expression
left
,
right
;
private
TypeInfo
type
;
private
int
dataType
;
private
boolean
convertRight
=
true
;
public
BinaryOperation
(
OpType
opType
,
Expression
left
,
Expression
right
)
{
...
...
@@ -100,6 +99,7 @@ public class BinaryOperation extends Expression {
@Override
public
Value
getValue
(
Session
session
)
{
Mode
mode
=
session
.
getDatabase
().
getMode
();
int
dataType
=
type
.
getValueType
();
Value
l
=
left
.
getValue
(
session
).
convertTo
(
dataType
,
mode
);
Value
r
=
right
.
getValue
(
session
);
if
(
convertRight
)
{
...
...
@@ -166,15 +166,14 @@ public class BinaryOperation extends Expression {
switch
(
opType
)
{
case
CONCAT:
type
=
TypeInfo
.
TYPE_STRING_DEFAULT
;
dataType
=
Value
.
STRING
;
break
;
case
PLUS:
case
MINUS:
case
MULTIPLY:
case
DIVIDE:
case
MODULUS:
int
l
=
left
.
getValueType
();
int
r
=
right
.
getValueType
();
int
l
=
left
.
get
Type
().
get
ValueType
();
int
r
=
right
.
get
Type
().
get
ValueType
();
if
((
l
==
Value
.
NULL
&&
r
==
Value
.
NULL
)
||
(
l
==
Value
.
UNKNOWN
&&
r
==
Value
.
UNKNOWN
))
{
// (? + ?) - use decimal by default (the most safe data type) or
...
...
@@ -182,18 +181,16 @@ public class BinaryOperation extends Expression {
if
(
opType
==
OpType
.
PLUS
&&
session
.
getDatabase
().
getMode
().
allowPlusForStringConcat
)
{
type
=
TypeInfo
.
TYPE_STRING_DEFAULT
;
dataType
=
Value
.
STRING
;
opType
=
OpType
.
CONCAT
;
}
else
{
type
=
TypeInfo
.
TYPE_DECIMAL_DEFAULT
;
dataType
=
Value
.
DECIMAL
;
}
}
else
if
(
DataType
.
isIntervalType
(
l
)
||
DataType
.
isIntervalType
(
r
))
{
return
optimizeInterval
(
session
,
l
,
r
);
}
else
if
(
DataType
.
isDateTimeType
(
l
)
||
DataType
.
isDateTimeType
(
r
))
{
return
optimizeDateTime
(
session
,
l
,
r
);
}
else
{
dataType
=
Value
.
getHigherOrder
(
l
,
r
);
int
dataType
=
Value
.
getHigherOrder
(
l
,
r
);
if
(
dataType
==
Value
.
ENUM
)
{
type
=
TypeInfo
.
TYPE_INT
;
dataType
=
Value
.
INT
;
...
...
@@ -317,12 +314,10 @@ public class BinaryOperation extends Expression {
}
case
Value
.
TIME
:
if
(
r
==
Value
.
TIME
||
r
==
Value
.
TIMESTAMP_TZ
)
{
dataType
=
r
;
type
=
TypeInfo
.
getTypeInfo
(
r
);
return
this
;
}
else
{
// DATE, TIMESTAMP
type
=
TypeInfo
.
TYPE_TIMESTAMP
;
dataType
=
Value
.
TIMESTAMP
;
return
this
;
}
}
...
...
@@ -361,7 +356,6 @@ public class BinaryOperation extends Expression {
}
case
Value
.
TIME
:
type
=
TypeInfo
.
TYPE_TIMESTAMP
;
dataType
=
Value
.
TIMESTAMP
;
return
this
;
case
Value
.
DATE
:
case
Value
.
TIMESTAMP
:
...
...
@@ -379,13 +373,11 @@ public class BinaryOperation extends Expression {
case
MULTIPLY:
if
(
l
==
Value
.
TIME
)
{
type
=
TypeInfo
.
TYPE_TIME
;
dataType
=
Value
.
TIME
;
convertRight
=
false
;
return
this
;
}
else
if
(
r
==
Value
.
TIME
)
{
swap
();
type
=
TypeInfo
.
TYPE_TIME
;
dataType
=
Value
.
TIME
;
convertRight
=
false
;
return
this
;
}
...
...
@@ -393,7 +385,6 @@ public class BinaryOperation extends Expression {
case
DIVIDE:
if
(
l
==
Value
.
TIME
)
{
type
=
TypeInfo
.
TYPE_TIME
;
dataType
=
Value
.
TIME
;
convertRight
=
false
;
return
this
;
}
...
...
@@ -425,11 +416,6 @@ public class BinaryOperation extends Expression {
return
type
;
}
@Override
public
int
getValueType
()
{
return
dataType
;
}
@Override
public
void
updateAggregate
(
Session
session
,
int
stage
)
{
left
.
updateAggregate
(
session
,
stage
);
...
...
h2/src/main/org/h2/expression/Expression.java
浏览文件 @
f2b73153
...
...
@@ -92,14 +92,6 @@ public abstract class Expression {
*/
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.
*
...
...
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
f2b73153
...
...
@@ -230,11 +230,6 @@ public class ExpressionColumn extends Expression {
return
column
==
null
?
TypeInfo
.
TYPE_UNKNOWN
:
column
.
getType
();
}
@Override
public
int
getValueType
()
{
return
column
==
null
?
Value
.
UNKNOWN
:
column
.
getType
().
getValueType
();
}
@Override
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 {
return
isArray
?
TypeInfo
.
TYPE_ARRAY
:
TypeInfo
.
TYPE_ROW
;
}
@Override
public
int
getValueType
()
{
return
isArray
?
Value
.
ARRAY
:
Value
.
ROW
;
}
@Override
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
for
(
Expression
e
:
list
)
{
...
...
h2/src/main/org/h2/expression/IntervalOperation.java
浏览文件 @
f2b73153
...
...
@@ -79,7 +79,6 @@ public class IntervalOperation extends Expression {
private
final
IntervalOpType
opType
;
private
Expression
left
,
right
;
private
TypeInfo
type
;
private
int
dataType
;
private
static
BigInteger
nanosFromValue
(
Value
v
)
{
long
[]
a
=
dateAndTimeFromValue
(
v
);
...
...
@@ -91,30 +90,25 @@ public class IntervalOperation extends Expression {
this
.
opType
=
opType
;
this
.
left
=
left
;
this
.
right
=
right
;
int
l
=
left
.
get
ValueType
(),
r
=
right
.
getValueType
();
int
l
=
left
.
get
Type
().
getValueType
(),
r
=
right
.
getType
()
.
getValueType
();
switch
(
opType
)
{
case
INTERVAL_PLUS_INTERVAL:
case
INTERVAL_MINUS_INTERVAL:
dataType
=
Value
.
getHigherOrder
(
l
,
r
);
type
=
TypeInfo
.
getTypeInfo
(
dataType
);
type
=
TypeInfo
.
getTypeInfo
(
Value
.
getHigherOrder
(
l
,
r
));
break
;
case
DATETIME_PLUS_INTERVAL:
case
DATETIME_MINUS_INTERVAL:
case
INTERVAL_MULTIPLY_NUMERIC:
case
INTERVAL_DIVIDE_NUMERIC:
type
=
left
.
getType
();
dataType
=
l
;
break
;
case
DATETIME_MINUS_DATETIME:
if
(
l
==
Value
.
TIME
&&
r
==
Value
.
TIME
)
{
type
=
TypeInfo
.
TYPE_INTERVAL_HOUR_TO_SECOND
;
dataType
=
Value
.
INTERVAL_HOUR_TO_SECOND
;
}
else
if
(
l
==
Value
.
DATE
&&
r
==
Value
.
DATE
)
{
type
=
TypeInfo
.
TYPE_INTERVAL_DAY
;
dataType
=
Value
.
INTERVAL_DAY
;
}
else
{
type
=
TypeInfo
.
TYPE_INTERVAL_DAY_TO_SECOND
;
dataType
=
Value
.
INTERVAL_DAY_TO_SECOND
;
}
}
}
...
...
@@ -288,11 +282,6 @@ public class IntervalOperation extends Expression {
return
type
;
}
@Override
public
int
getValueType
()
{
return
dataType
;
}
@Override
public
void
updateAggregate
(
Session
session
,
int
stage
)
{
left
.
updateAggregate
(
session
,
stage
);
...
...
h2/src/main/org/h2/expression/Rownum.java
浏览文件 @
f2b73153
...
...
@@ -38,11 +38,6 @@ public class Rownum extends Expression {
return
TypeInfo
.
TYPE_LONG
;
}
@Override
public
int
getValueType
()
{
return
Value
.
LONG
;
}
@Override
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
// nothing to do
...
...
h2/src/main/org/h2/expression/SequenceValue.java
浏览文件 @
f2b73153
...
...
@@ -37,11 +37,6 @@ public class SequenceValue extends Expression {
return
TypeInfo
.
TYPE_LONG
;
}
@Override
public
int
getValueType
()
{
return
Value
.
LONG
;
}
@Override
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
// nothing to do
...
...
h2/src/main/org/h2/expression/Subquery.java
浏览文件 @
f2b73153
...
...
@@ -58,11 +58,6 @@ public class Subquery extends Expression {
return
getExpression
().
getType
();
}
@Override
public
int
getValueType
()
{
return
getExpression
().
getValueType
();
}
@Override
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
query
.
mapColumns
(
resolver
,
level
+
1
);
...
...
h2/src/main/org/h2/expression/UnaryOperation.java
浏览文件 @
f2b73153
...
...
@@ -68,11 +68,6 @@ public class UnaryOperation extends Expression {
return
type
;
}
@Override
public
int
getValueType
()
{
return
type
.
getValueType
();
}
@Override
public
void
updateAggregate
(
Session
session
,
int
stage
)
{
arg
.
updateAggregate
(
session
,
stage
);
...
...
h2/src/main/org/h2/expression/ValueExpression.java
浏览文件 @
f2b73153
...
...
@@ -80,11 +80,6 @@ public class ValueExpression extends Expression {
return
value
.
getType
();
}
@Override
public
int
getValueType
()
{
return
value
.
getValueType
();
}
@Override
public
void
createIndexConditions
(
Session
session
,
TableFilter
filter
)
{
if
(
value
.
getValueType
()
==
Value
.
BOOLEAN
)
{
...
...
@@ -168,7 +163,7 @@ public class ValueExpression extends Expression {
@Override
public
Expression
[]
getExpressionColumns
(
Session
session
)
{
if
(
getValueType
()
==
Value
.
ARRAY
)
{
if
(
get
Type
().
get
ValueType
()
==
Value
.
ARRAY
)
{
return
getExpressionColumns
(
session
,
(
ValueArray
)
getValue
(
session
));
}
return
super
.
getExpressionColumns
(
session
);
...
...
h2/src/main/org/h2/expression/Variable.java
浏览文件 @
f2b73153
...
...
@@ -42,11 +42,6 @@ public class Variable extends Expression {
return
lastValue
.
getType
();
}
@Override
public
int
getValueType
()
{
return
lastValue
.
getValueType
();
}
@Override
public
Value
getValue
(
Session
session
)
{
lastValue
=
session
.
getVariable
(
name
);
...
...
h2/src/main/org/h2/expression/Wildcard.java
浏览文件 @
f2b73153
...
...
@@ -72,11 +72,6 @@ public class Wildcard extends Expression {
throw
DbException
.
throwInternalError
(
toString
());
}
@Override
public
int
getValueType
()
{
throw
DbException
.
throwInternalError
(
toString
());
}
@Override
public
void
mapColumns
(
ColumnResolver
resolver
,
int
level
,
int
state
)
{
if
(
exceptColumns
!=
null
)
{
...
...
h2/src/main/org/h2/expression/aggregate/Aggregate.java
浏览文件 @
f2b73153
...
...
@@ -164,7 +164,6 @@ public class Aggregate extends AbstractAggregate {
private
ArrayList
<
SelectOrderBy
>
orderByList
;
private
SortOrder
orderBySort
;
private
TypeInfo
type
;
private
int
dataType
;
/**
* Create a new aggregate object.
...
...
@@ -304,7 +303,7 @@ public class Aggregate extends AbstractAggregate {
v
=
updateCollecting
(
session
,
v
,
remembered
);
}
}
data
.
add
(
session
.
getDatabase
(),
dataType
,
v
);
data
.
add
(
session
.
getDatabase
(),
type
.
getValueType
()
,
v
);
}
@Override
...
...
@@ -410,7 +409,7 @@ public class Aggregate extends AbstractAggregate {
return
v
;
}
case
MEDIAN:
return
AggregateMedian
.
medianFromIndex
(
session
,
on
,
dataType
);
return
AggregateMedian
.
medianFromIndex
(
session
,
on
,
type
.
getValueType
()
);
case
ENVELOPE:
return
((
MVSpatialIndex
)
AggregateDataEnvelope
.
getGeometryColumnIndex
(
on
)).
getBounds
(
session
);
default
:
...
...
@@ -443,6 +442,7 @@ public class Aggregate extends AbstractAggregate {
}
AggregateDataDefault
d
=
new
AggregateDataDefault
(
aggregateType
);
Database
db
=
session
.
getDatabase
();
int
dataType
=
type
.
getValueType
();
for
(
Value
v
:
c
)
{
d
.
add
(
db
,
dataType
,
v
);
}
...
...
@@ -473,14 +473,14 @@ public class Aggregate extends AbstractAggregate {
if
(
array
==
null
)
{
return
ValueNull
.
INSTANCE
;
}
return
AggregateMedian
.
median
(
session
.
getDatabase
(),
array
,
dataType
);
return
AggregateMedian
.
median
(
session
.
getDatabase
(),
array
,
type
.
getValueType
()
);
}
case
MODE:
return
getMode
(
session
,
data
);
default
:
// Avoid compiler warning
}
return
data
.
getValue
(
session
.
getDatabase
(),
dataType
);
return
data
.
getValue
(
session
.
getDatabase
(),
type
.
getValueType
()
);
}
private
Value
getGroupConcat
(
Session
session
,
AggregateData
data
)
{
...
...
@@ -573,7 +573,7 @@ public class Aggregate extends AbstractAggregate {
}
}
}
return
v
.
convertTo
(
dataType
);
return
v
.
convertTo
(
type
.
getValueType
()
);
}
@Override
...
...
@@ -581,11 +581,6 @@ public class Aggregate extends AbstractAggregate {
return
type
;
}
@Override
public
int
getValueType
()
{
return
dataType
;
}
@Override
public
void
mapColumnsAnalysis
(
ColumnResolver
resolver
,
int
level
,
int
innerState
)
{
if
(
on
!=
null
)
{
...
...
@@ -608,7 +603,6 @@ public class Aggregate extends AbstractAggregate {
if
(
on
!=
null
)
{
on
=
on
.
optimize
(
session
);
type
=
on
.
getType
();
dataType
=
on
.
getValueType
();
}
if
(
orderByList
!=
null
)
{
for
(
SelectOrderBy
o
:
orderByList
)
{
...
...
@@ -622,35 +616,31 @@ public class Aggregate extends AbstractAggregate {
switch
(
aggregateType
)
{
case
GROUP_CONCAT:
type
=
TypeInfo
.
TYPE_STRING_DEFAULT
;
dataType
=
Value
.
STRING
;
break
;
case
COUNT_ALL:
case
COUNT:
type
=
TypeInfo
.
TYPE_LONG
;
dataType
=
Value
.
LONG
;
break
;
case
SELECTIVITY:
type
=
TypeInfo
.
TYPE_INT
;
dataType
=
Value
.
INT
;
break
;
case
HISTOGRAM:
type
=
TypeInfo
.
TYPE_ARRAY
;
dataType
=
Value
.
ARRAY
;
break
;
case
SUM:
case
SUM:
{
int
dataType
=
type
.
getValueType
();
if
(
dataType
==
Value
.
BOOLEAN
)
{
// example: sum(id > 3) (count the rows)
type
=
TypeInfo
.
TYPE_LONG
;
dataType
=
Value
.
LONG
;
}
else
if
(!
DataType
.
supportsAdd
(
dataType
))
{
throw
DbException
.
get
(
ErrorCode
.
SUM_OR_AVG_ON_WRONG_DATATYPE_1
,
getSQL
());
}
else
{
dataType
=
DataType
.
getAddProofType
(
dataType
);
type
=
TypeInfo
.
getTypeInfo
(
dataType
);
type
=
TypeInfo
.
getTypeInfo
(
DataType
.
getAddProofType
(
dataType
));
}
break
;
}
case
AVG:
if
(!
DataType
.
supportsAdd
(
dataType
))
{
if
(!
DataType
.
supportsAdd
(
type
.
getValueType
()
))
{
throw
DbException
.
get
(
ErrorCode
.
SUM_OR_AVG_ON_WRONG_DATATYPE_1
,
getSQL
());
}
break
;
...
...
@@ -664,26 +654,22 @@ public class Aggregate extends AbstractAggregate {
case
VAR_POP:
case
VAR_SAMP:
type
=
TypeInfo
.
TYPE_DOUBLE
;
dataType
=
Value
.
DOUBLE
;
break
;
case
EVERY:
case
ANY:
type
=
TypeInfo
.
TYPE_BOOLEAN
;
dataType
=
Value
.
BOOLEAN
;
break
;
case
BIT_AND:
case
BIT_OR:
if
(!
DataType
.
supportsAdd
(
dataType
))
{
if
(!
DataType
.
supportsAdd
(
type
.
getValueType
()
))
{
throw
DbException
.
get
(
ErrorCode
.
SUM_OR_AVG_ON_WRONG_DATATYPE_1
,
getSQL
());
}
break
;
case
ARRAY_AGG:
type
=
TypeInfo
.
TYPE_ARRAY
;
dataType
=
Value
.
ARRAY
;
break
;
case
ENVELOPE:
type
=
TypeInfo
.
TYPE_GEOMETRY
;
dataType
=
Value
.
GEOMETRY
;
break
;
default
:
DbException
.
throwInternalError
(
"type="
+
aggregateType
);
...
...
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
浏览文件 @
f2b73153
...
...
@@ -67,11 +67,6 @@ public class JavaAggregate extends AbstractAggregate {
return
type
;
}
@Override
public
int
getValueType
()
{
return
dataType
;
}
@Override
public
boolean
isEverything
(
ExpressionVisitor
visitor
)
{
if
(!
super
.
isEverything
(
visitor
))
{
...
...
@@ -114,7 +109,7 @@ public class JavaAggregate extends AbstractAggregate {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Expression
expr
=
args
[
i
];
args
[
i
]
=
expr
.
optimize
(
session
);
int
type
=
expr
.
getValueType
();
int
type
=
expr
.
get
Type
().
get
ValueType
();
argTypes
[
i
]
=
type
;
}
try
{
...
...
h2/src/main/org/h2/expression/analysis/WindowFunction.java
浏览文件 @
f2b73153
...
...
@@ -287,7 +287,7 @@ public class WindowFunction extends DataAnalysisOperation {
int
rowIdColumn
)
{
int
size
=
ordered
.
size
();
int
numExpressions
=
getNumExpressions
();
int
dataType
=
args
[
0
].
getValueType
();
int
dataType
=
args
[
0
].
get
Type
().
get
ValueType
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Value
[]
row
=
ordered
.
get
(
i
);
int
rowId
=
row
[
rowIdColumn
].
getInt
();
...
...
@@ -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
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
String
name
=
type
.
getSQL
();
...
...
h2/src/main/org/h2/expression/condition/CompareLike.java
浏览文件 @
f2b73153
...
...
@@ -100,7 +100,7 @@ public class CompareLike extends Condition {
public
Expression
optimize
(
Session
session
)
{
left
=
left
.
optimize
(
session
);
right
=
right
.
optimize
(
session
);
if
(
left
.
getValueType
()
==
Value
.
STRING_IGNORECASE
)
{
if
(
left
.
get
Type
().
get
ValueType
()
==
Value
.
STRING_IGNORECASE
)
{
ignoreCase
=
true
;
}
if
(
left
.
isValueSet
())
{
...
...
h2/src/main/org/h2/expression/condition/Comparison.java
浏览文件 @
f2b73153
...
...
@@ -206,7 +206,7 @@ public class Comparison extends Condition {
if
(
right
!=
null
)
{
right
=
right
.
optimize
(
session
);
// 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
);
}
if
(
right
instanceof
ExpressionColumn
)
{
...
...
@@ -225,7 +225,7 @@ public class Comparison extends Condition {
return
ValueExpression
.
getNull
();
}
}
int
colType
=
left
.
getValueType
();
int
colType
=
left
.
get
Type
().
get
ValueType
();
int
constType
=
r
.
getValueType
();
int
resType
=
Value
.
getHigherOrder
(
colType
,
constType
);
// If not, the column values will need to be promoted
...
...
@@ -516,12 +516,14 @@ public class Comparison extends Condition {
}
if
(
addIndex
)
{
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
(
IndexCondition
.
get
(
compareType
,
l
,
right
));
}
}
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
);
filter
.
addIndexCondition
(
IndexCondition
.
get
(
compareRev
,
r
,
left
));
...
...
h2/src/main/org/h2/expression/condition/Condition.java
浏览文件 @
f2b73153
...
...
@@ -7,7 +7,6 @@ package org.h2.expression.condition;
import
org.h2.expression.Expression
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
/**
* Represents a condition returning a boolean value, or NULL.
...
...
@@ -19,9 +18,4 @@ abstract class Condition extends Expression {
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 {
return
new
Comparison
(
session
,
Comparison
.
EQUAL
,
left
,
values
.
get
(
0
)).
optimize
(
session
);
}
if
(
allValuesConstant
&&
!
allValuesNull
)
{
int
leftType
=
left
.
getValueType
();
int
leftType
=
left
.
get
Type
().
get
ValueType
();
if
(
leftType
==
Value
.
UNKNOWN
)
{
return
this
;
}
...
...
h2/src/main/org/h2/expression/condition/ConditionInConstantSet.java
浏览文件 @
f2b73153
...
...
@@ -54,7 +54,7 @@ public class ConditionInConstantSet extends Condition {
this
.
valueList
=
valueList
;
Database
database
=
session
.
getDatabase
();
this
.
valueSet
=
new
TreeSet
<>(
database
.
getCompareMode
());
type
=
left
.
getValueType
();
type
=
left
.
get
Type
().
get
ValueType
();
Mode
mode
=
database
.
getMode
();
if
(
type
==
Value
.
ENUM
)
{
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 {
s
=
ValueTimestamp
.
MAXIMUM_SCALE
;
if
(
p0
.
isConstant
())
{
Expression
p2
=
args
[
2
];
switch
(
p2
.
getValueType
())
{
switch
(
p2
.
get
Type
().
get
ValueType
())
{
case
Value
.
TIME
:
t
=
Value
.
TIME
;
p
=
d
=
ValueTime
.
DEFAULT_PRECISION
;
...
...
@@ -2374,7 +2374,7 @@ public class Function extends Expression implements FunctionCall {
}
case
DATE_TRUNC:
{
Expression
p1
=
args
[
1
];
t
=
p1
.
getValueType
();
t
=
p1
.
get
Type
().
get
ValueType
();
if
(
t
==
Value
.
TIMESTAMP_TZ
)
{
p
=
d
=
ValueTimestampTimeZone
.
DEFAULT_PRECISION
;
}
else
{
...
...
@@ -2466,18 +2466,18 @@ public class Function extends Expression implements FunctionCall {
break
;
}
case
NVL2:
{
switch
(
args
[
1
].
getValueType
())
{
TypeInfo
t1
=
args
[
1
].
getType
(),
t2
=
args
[
2
].
getType
();
switch
(
t1
.
getValueType
())
{
case
Value
.
STRING
:
case
Value
.
CLOB
:
case
Value
.
STRING_FIXED
:
case
Value
.
STRING_IGNORECASE
:
t
=
args
[
1
]
.
getValueType
();
t
=
t1
.
getValueType
();
break
;
default
:
t
=
Value
.
getHigherOrder
(
args
[
1
].
getValueType
(),
args
[
2
]
.
getValueType
());
t
=
Value
.
getHigherOrder
(
t1
.
getValueType
(),
t2
.
getValueType
());
break
;
}
TypeInfo
t1
=
args
[
1
].
getType
(),
t2
=
args
[
2
].
getType
();
p
=
Math
.
max
(
t1
.
getPrecision
(),
t2
.
getPrecision
());
d
=
Math
.
max
(
t1
.
getDisplaySize
(),
t2
.
getDisplaySize
());
s
=
Math
.
max
(
t1
.
getScale
(),
t2
.
getScale
());
...
...
@@ -2498,7 +2498,7 @@ public class Function extends Expression implements FunctionCall {
}
break
;
case
TRUNCATE:
switch
(
p0
.
getValueType
())
{
switch
(
p0
.
get
Type
().
get
ValueType
())
{
case
Value
.
STRING
:
case
Value
.
DATE
:
case
Value
.
TIMESTAMP
:
...
...
h2/src/main/org/h2/result/ResultTempTable.java
浏览文件 @
f2b73153
...
...
@@ -24,6 +24,7 @@ import org.h2.table.IndexColumn;
import
org.h2.table.Table
;
import
org.h2.util.TempFileDeleter
;
import
org.h2.value.DataType
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
import
org.h2.value.ValueNull
;
...
...
@@ -117,9 +118,9 @@ public class ResultTempTable implements ResultExternal {
CreateTableData
data
=
new
CreateTableData
();
boolean
containsLob
=
false
;
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
);
if
(
DataType
.
isLargeObject
(
type
))
{
if
(
DataType
.
isLargeObject
(
type
.
getValueType
()
))
{
containsLob
=
true
;
}
data
.
columns
.
add
(
col
);
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
f2b73153
...
...
@@ -1762,7 +1762,7 @@ public class MetaTable extends Table {
// CONSTANT_NAME
identifier
(
constant
.
getName
()),
// DATA_TYPE
ValueInt
.
get
(
DataType
.
convertTypeToSQLType
(
expr
.
getValueType
())),
ValueInt
.
get
(
DataType
.
convertTypeToSQLType
(
expr
.
get
Type
().
get
ValueType
())),
// REMARKS
replaceNullWithEmpty
(
constant
.
getComment
()),
// SQL
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
f2b73153
...
...
@@ -192,7 +192,7 @@ public class TableView extends Table {
}
name
=
columnNamer
.
getColumnName
(
expr
,
i
,
name
);
if
(
valueType
==
Value
.
UNKNOWN
)
{
valueType
=
expr
.
getValueType
();
valueType
=
expr
.
get
Type
().
get
ValueType
();
}
TypeInfo
type
=
expr
.
getType
();
long
precision
=
type
.
getPrecision
();
...
...
@@ -819,8 +819,7 @@ public class TableView extends Table {
// (if found) otherwise use column name derived from column
// expression
String
columnName
=
columnNamer
.
getColumnName
(
columnExp
,
i
,
cols
);
columnTemplateList
.
add
(
new
Column
(
columnName
,
columnExp
.
getValueType
()));
columnTemplateList
.
add
(
new
Column
(
columnName
,
columnExp
.
getType
()));
}
return
columnTemplateList
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论