Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f70ff5e2
提交
f70ff5e2
authored
1月 17, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove getPrecision(), getScale(), and getDisplaySize() from Expression
上级
2d71c43f
隐藏空白字符变更
内嵌
并排
正在显示
30 个修改的文件
包含
137 行增加
和
487 行删除
+137
-487
Parser.java
h2/src/main/org/h2/command/Parser.java
+11
-11
CreateTable.java
h2/src/main/org/h2/command/ddl/CreateTable.java
+8
-6
SelectUnion.java
h2/src/main/org/h2/command/dml/SelectUnion.java
+6
-4
Alias.java
h2/src/main/org/h2/expression/Alias.java
+0
-15
BinaryOperation.java
h2/src/main/org/h2/expression/BinaryOperation.java
+0
-27
Expression.java
h2/src/main/org/h2/expression/Expression.java
+0
-21
ExpressionColumn.java
h2/src/main/org/h2/expression/ExpressionColumn.java
+0
-15
ExpressionList.java
h2/src/main/org/h2/expression/ExpressionList.java
+1
-18
IntervalOperation.java
h2/src/main/org/h2/expression/IntervalOperation.java
+0
-15
Parameter.java
h2/src/main/org/h2/expression/Parameter.java
+0
-11
Rownum.java
h2/src/main/org/h2/expression/Rownum.java
+0
-15
SequenceValue.java
h2/src/main/org/h2/expression/SequenceValue.java
+0
-15
Subquery.java
h2/src/main/org/h2/expression/Subquery.java
+0
-15
UnaryOperation.java
h2/src/main/org/h2/expression/UnaryOperation.java
+0
-15
ValueExpression.java
h2/src/main/org/h2/expression/ValueExpression.java
+0
-15
Variable.java
h2/src/main/org/h2/expression/Variable.java
+0
-15
Wildcard.java
h2/src/main/org/h2/expression/Wildcard.java
+0
-15
Aggregate.java
h2/src/main/org/h2/expression/aggregate/Aggregate.java
+1
-43
JavaAggregate.java
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
+0
-15
WindowFunction.java
h2/src/main/org/h2/expression/analysis/WindowFunction.java
+0
-60
Comparison.java
h2/src/main/org/h2/expression/condition/Comparison.java
+1
-1
Condition.java
h2/src/main/org/h2/expression/condition/Condition.java
+0
-16
Function.java
h2/src/main/org/h2/expression/function/Function.java
+71
-69
JavaFunction.java
h2/src/main/org/h2/expression/function/JavaFunction.java
+0
-16
LazyResult.java
h2/src/main/org/h2/result/LazyResult.java
+3
-3
LocalResultImpl.java
h2/src/main/org/h2/result/LocalResultImpl.java
+3
-3
TableView.java
h2/src/main/org/h2/table/TableView.java
+11
-9
ExtTypeInfoEnum.java
h2/src/main/org/h2/value/ExtTypeInfoEnum.java
+17
-0
ValueEnum.java
h2/src/main/org/h2/value/ValueEnum.java
+1
-1
enum.sql
h2/src/test/org/h2/test/scripts/datatypes/enum.sql
+3
-3
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
f70ff5e2
...
@@ -5841,37 +5841,37 @@ public class Parser {
...
@@ -5841,37 +5841,37 @@ public class Parser {
do
{
do
{
Expression
expr
=
readExpression
();
Expression
expr
=
readExpression
();
expr
=
expr
.
optimize
(
session
);
expr
=
expr
.
optimize
(
session
);
int
type
=
expr
.
getValueType
();
TypeInfo
type
=
expr
.
getType
();
int
valueType
=
type
.
getValueType
();
long
prec
;
long
prec
;
int
scale
,
displaySize
;
int
scale
,
displaySize
;
Column
column
;
Column
column
;
String
columnName
=
"C"
+
(
i
+
1
);
String
columnName
=
"C"
+
(
i
+
1
);
if
(
rows
.
isEmpty
())
{
if
(
rows
.
isEmpty
())
{
if
(
t
ype
==
Value
.
UNKNOWN
)
{
if
(
valueT
ype
==
Value
.
UNKNOWN
)
{
t
ype
=
Value
.
STRING
;
valueT
ype
=
Value
.
STRING
;
}
}
DataType
dt
=
DataType
.
getDataType
(
t
ype
);
DataType
dt
=
DataType
.
getDataType
(
valueT
ype
);
prec
=
dt
.
defaultPrecision
;
prec
=
dt
.
defaultPrecision
;
scale
=
dt
.
defaultScale
;
scale
=
dt
.
defaultScale
;
displaySize
=
dt
.
defaultDisplaySize
;
displaySize
=
dt
.
defaultDisplaySize
;
column
=
new
Column
(
columnName
,
type
,
prec
,
scale
,
column
=
new
Column
(
columnName
,
valueType
,
prec
,
scale
,
displaySize
);
displaySize
);
columns
.
add
(
column
);
columns
.
add
(
column
);
}
}
prec
=
expr
.
getPrecision
();
prec
=
type
.
getPrecision
();
scale
=
expr
.
getScale
();
scale
=
type
.
getScale
();
displaySize
=
expr
.
getDisplaySize
();
displaySize
=
type
.
getDisplaySize
();
if
(
i
>=
columns
.
size
())
{
if
(
i
>=
columns
.
size
())
{
throw
DbException
throw
DbException
.
get
(
ErrorCode
.
COLUMN_COUNT_DOES_NOT_MATCH
);
.
get
(
ErrorCode
.
COLUMN_COUNT_DOES_NOT_MATCH
);
}
}
Column
c
=
columns
.
get
(
i
);
Column
c
=
columns
.
get
(
i
);
TypeInfo
t
=
c
.
getType
();
TypeInfo
t
=
c
.
getType
();
type
=
Value
.
getHigherOrder
(
t
.
getValueType
(),
t
ype
);
valueType
=
Value
.
getHigherOrder
(
t
.
getValueType
(),
valueT
ype
);
prec
=
Math
.
max
(
t
.
getPrecision
(),
prec
);
prec
=
Math
.
max
(
t
.
getPrecision
(),
prec
);
scale
=
Math
.
max
(
t
.
getScale
(),
scale
);
scale
=
Math
.
max
(
t
.
getScale
(),
scale
);
displaySize
=
Math
.
max
(
t
.
getDisplaySize
(),
displaySize
);
displaySize
=
Math
.
max
(
t
.
getDisplaySize
(),
displaySize
);
column
=
new
Column
(
columnName
,
t
ype
,
prec
,
scale
,
displaySize
);
column
=
new
Column
(
columnName
,
valueT
ype
,
prec
,
scale
,
displaySize
);
columns
.
set
(
i
,
column
);
columns
.
set
(
i
,
column
);
row
.
add
(
expr
);
row
.
add
(
expr
);
i
++;
i
++;
...
...
h2/src/main/org/h2/command/ddl/CreateTable.java
浏览文件 @
f70ff5e2
...
@@ -24,6 +24,7 @@ import org.h2.table.Table;
...
@@ -24,6 +24,7 @@ import org.h2.table.Table;
import
org.h2.util.ColumnNamer
;
import
org.h2.util.ColumnNamer
;
import
org.h2.value.DataType
;
import
org.h2.value.DataType
;
import
org.h2.value.ExtTypeInfo
;
import
org.h2.value.ExtTypeInfo
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
/**
/**
...
@@ -180,17 +181,18 @@ public class CreateTable extends CommandWithColumns {
...
@@ -180,17 +181,18 @@ public class CreateTable extends CommandWithColumns {
ColumnNamer
columnNamer
=
new
ColumnNamer
(
session
);
ColumnNamer
columnNamer
=
new
ColumnNamer
(
session
);
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
Expression
expr
=
expressions
.
get
(
i
);
Expression
expr
=
expressions
.
get
(
i
);
int
type
=
expr
.
getValueType
();
TypeInfo
type
=
expr
.
getType
();
int
valueType
=
type
.
getValueType
();
String
name
=
columnNamer
.
getColumnName
(
expr
,
i
,
expr
.
getAlias
());
String
name
=
columnNamer
.
getColumnName
(
expr
,
i
,
expr
.
getAlias
());
long
precision
=
expr
.
getPrecision
();
long
precision
=
type
.
getPrecision
();
int
displaySize
=
expr
.
getDisplaySize
();
int
displaySize
=
type
.
getDisplaySize
();
DataType
dt
=
DataType
.
getDataType
(
t
ype
);
DataType
dt
=
DataType
.
getDataType
(
valueT
ype
);
if
(
precision
>
0
&&
(
dt
.
defaultPrecision
==
0
||
if
(
precision
>
0
&&
(
dt
.
defaultPrecision
==
0
||
(
dt
.
defaultPrecision
>
precision
&&
dt
.
defaultPrecision
<
Byte
.
MAX_VALUE
)))
{
(
dt
.
defaultPrecision
>
precision
&&
dt
.
defaultPrecision
<
Byte
.
MAX_VALUE
)))
{
// dont' set precision to MAX_VALUE if this is the default
// dont' set precision to MAX_VALUE if this is the default
precision
=
dt
.
defaultPrecision
;
precision
=
dt
.
defaultPrecision
;
}
}
int
scale
=
expr
.
getScale
();
int
scale
=
type
.
getScale
();
if
(
scale
>
0
&&
(
dt
.
defaultScale
==
0
||
if
(
scale
>
0
&&
(
dt
.
defaultScale
==
0
||
(
dt
.
defaultScale
>
scale
&&
dt
.
defaultScale
<
precision
)))
{
(
dt
.
defaultScale
>
scale
&&
dt
.
defaultScale
<
precision
)))
{
scale
=
dt
.
defaultScale
;
scale
=
dt
.
defaultScale
;
...
@@ -211,7 +213,7 @@ public class CreateTable extends CommandWithColumns {
...
@@ -211,7 +213,7 @@ public class CreateTable extends CommandWithColumns {
"Unable to resolve enumerators of expression"
);
"Unable to resolve enumerators of expression"
);
}
}
}
}
Column
col
=
new
Column
(
name
,
t
ype
,
precision
,
scale
,
displaySize
,
extTypeInfo
);
Column
col
=
new
Column
(
name
,
valueT
ype
,
precision
,
scale
,
displaySize
,
extTypeInfo
);
addColumn
(
col
);
addColumn
(
col
);
}
}
}
}
...
...
h2/src/main/org/h2/command/dml/SelectUnion.java
浏览文件 @
f70ff5e2
...
@@ -27,6 +27,7 @@ import org.h2.table.ColumnResolver;
...
@@ -27,6 +27,7 @@ import org.h2.table.ColumnResolver;
import
org.h2.table.Table
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.table.TableFilter
;
import
org.h2.util.ColumnNamer
;
import
org.h2.util.ColumnNamer
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueNull
;
...
@@ -328,10 +329,11 @@ public class SelectUnion extends Query {
...
@@ -328,10 +329,11 @@ public class SelectUnion extends Query {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Expression
l
=
le
.
get
(
i
);
Expression
l
=
le
.
get
(
i
);
Expression
r
=
re
.
get
(
i
);
Expression
r
=
re
.
get
(
i
);
int
type
=
Value
.
getHigherOrder
(
l
.
getValueType
(),
r
.
getValueType
());
TypeInfo
lType
=
l
.
getType
(),
rType
=
r
.
getType
();
long
prec
=
Math
.
max
(
l
.
getPrecision
(),
r
.
getPrecision
());
int
type
=
Value
.
getHigherOrder
(
lType
.
getValueType
(),
rType
.
getValueType
());
int
scale
=
Math
.
max
(
l
.
getScale
(),
r
.
getScale
());
long
prec
=
Math
.
max
(
lType
.
getPrecision
(),
rType
.
getPrecision
());
int
displaySize
=
Math
.
max
(
l
.
getDisplaySize
(),
r
.
getDisplaySize
());
int
scale
=
Math
.
max
(
lType
.
getScale
(),
rType
.
getScale
());
int
displaySize
=
Math
.
max
(
lType
.
getDisplaySize
(),
rType
.
getDisplaySize
());
String
columnName
=
columnNamer
.
getColumnName
(
l
,
i
,
l
.
getAlias
());
String
columnName
=
columnNamer
.
getColumnName
(
l
,
i
,
l
.
getAlias
());
Column
col
=
new
Column
(
columnName
,
type
,
prec
,
scale
,
displaySize
);
Column
col
=
new
Column
(
columnName
,
type
,
prec
,
scale
,
displaySize
);
Expression
e
=
new
ExpressionColumn
(
session
.
getDatabase
(),
col
);
Expression
e
=
new
ExpressionColumn
(
session
.
getDatabase
(),
col
);
...
...
h2/src/main/org/h2/expression/Alias.java
浏览文件 @
f70ff5e2
...
@@ -63,21 +63,6 @@ public class Alias extends Expression {
...
@@ -63,21 +63,6 @@ public class Alias extends Expression {
expr
.
setEvaluatable
(
tableFilter
,
b
);
expr
.
setEvaluatable
(
tableFilter
,
b
);
}
}
@Override
public
int
getScale
()
{
return
expr
.
getScale
();
}
@Override
public
long
getPrecision
()
{
return
expr
.
getPrecision
();
}
@Override
public
int
getDisplaySize
()
{
return
expr
.
getDisplaySize
();
}
@Override
@Override
public
boolean
isAutoIncrement
()
{
public
boolean
isAutoIncrement
()
{
return
expr
.
isAutoIncrement
();
return
expr
.
isAutoIncrement
();
...
...
h2/src/main/org/h2/expression/BinaryOperation.java
浏览文件 @
f70ff5e2
...
@@ -12,7 +12,6 @@ import org.h2.expression.function.Function;
...
@@ -12,7 +12,6 @@ import org.h2.expression.function.Function;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.TableFilter
;
import
org.h2.table.TableFilter
;
import
org.h2.util.MathUtils
;
import
org.h2.value.DataType
;
import
org.h2.value.DataType
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
...
@@ -431,32 +430,6 @@ public class BinaryOperation extends Expression {
...
@@ -431,32 +430,6 @@ public class BinaryOperation extends Expression {
return
dataType
;
return
dataType
;
}
}
@Override
public
long
getPrecision
()
{
switch
(
opType
)
{
case
CONCAT:
return
left
.
getPrecision
()
+
right
.
getPrecision
();
default
:
return
Math
.
max
(
left
.
getPrecision
(),
right
.
getPrecision
());
}
}
@Override
public
int
getDisplaySize
()
{
switch
(
opType
)
{
case
CONCAT:
return
MathUtils
.
convertLongToInt
((
long
)
left
.
getDisplaySize
()
+
(
long
)
right
.
getDisplaySize
());
default
:
return
Math
.
max
(
left
.
getDisplaySize
(),
right
.
getDisplaySize
());
}
}
@Override
public
int
getScale
()
{
return
Math
.
max
(
left
.
getScale
(),
right
.
getScale
());
}
@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
浏览文件 @
f70ff5e2
...
@@ -127,27 +127,6 @@ public abstract class Expression {
...
@@ -127,27 +127,6 @@ public abstract class Expression {
*/
*/
public
abstract
void
setEvaluatable
(
TableFilter
tableFilter
,
boolean
value
);
public
abstract
void
setEvaluatable
(
TableFilter
tableFilter
,
boolean
value
);
/**
* Get the scale of this expression.
*
* @return the scale
*/
public
abstract
int
getScale
();
/**
* Get the precision of this expression.
*
* @return the precision
*/
public
abstract
long
getPrecision
();
/**
* Get the display size of this expression.
*
* @return the display size
*/
public
abstract
int
getDisplaySize
();
/**
/**
* Get the SQL statement of this expression.
* Get the SQL statement of this expression.
* This may not always be the original SQL statement,
* This may not always be the original SQL statement,
...
...
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
f70ff5e2
...
@@ -243,21 +243,6 @@ public class ExpressionColumn extends Expression {
...
@@ -243,21 +243,6 @@ public class ExpressionColumn extends Expression {
return
column
;
return
column
;
}
}
@Override
public
int
getScale
()
{
return
column
.
getType
().
getScale
();
}
@Override
public
long
getPrecision
()
{
return
column
.
getType
().
getPrecision
();
}
@Override
public
int
getDisplaySize
()
{
return
column
.
getType
().
getDisplaySize
();
}
public
String
getOriginalColumnName
()
{
public
String
getOriginalColumnName
()
{
return
columnName
;
return
columnName
;
}
}
...
...
h2/src/main/org/h2/expression/ExpressionList.java
浏览文件 @
f70ff5e2
...
@@ -77,21 +77,6 @@ public class ExpressionList extends Expression {
...
@@ -77,21 +77,6 @@ public class ExpressionList extends Expression {
}
}
}
}
@Override
public
int
getScale
()
{
return
0
;
}
@Override
public
long
getPrecision
()
{
return
Integer
.
MAX_VALUE
;
}
@Override
public
int
getDisplaySize
()
{
return
Integer
.
MAX_VALUE
;
}
@Override
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
builder
.
append
(
isArray
?
"ARRAY ["
:
"ROW ("
);
builder
.
append
(
isArray
?
"ARRAY ["
:
"ROW ("
);
...
@@ -130,9 +115,7 @@ public class ExpressionList extends Expression {
...
@@ -130,9 +115,7 @@ public class ExpressionList extends Expression {
ExpressionColumn
[]
expr
=
new
ExpressionColumn
[
list
.
length
];
ExpressionColumn
[]
expr
=
new
ExpressionColumn
[
list
.
length
];
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
Expression
e
=
list
[
i
];
Expression
e
=
list
[
i
];
Column
col
=
new
Column
(
"C"
+
(
i
+
1
),
Column
col
=
new
Column
(
"C"
+
(
i
+
1
),
e
.
getType
());
e
.
getValueType
(),
e
.
getPrecision
(),
e
.
getScale
(),
e
.
getDisplaySize
());
expr
[
i
]
=
new
ExpressionColumn
(
session
.
getDatabase
(),
col
);
expr
[
i
]
=
new
ExpressionColumn
(
session
.
getDatabase
(),
col
);
}
}
return
expr
;
return
expr
;
...
...
h2/src/main/org/h2/expression/IntervalOperation.java
浏览文件 @
f70ff5e2
...
@@ -293,21 +293,6 @@ public class IntervalOperation extends Expression {
...
@@ -293,21 +293,6 @@ public class IntervalOperation extends Expression {
return
dataType
;
return
dataType
;
}
}
@Override
public
long
getPrecision
()
{
return
Math
.
max
(
left
.
getPrecision
(),
right
.
getPrecision
());
}
@Override
public
int
getDisplaySize
()
{
return
Math
.
max
(
left
.
getDisplaySize
(),
right
.
getDisplaySize
());
}
@Override
public
int
getScale
()
{
return
Math
.
max
(
left
.
getScale
(),
right
.
getScale
());
}
@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/Parameter.java
浏览文件 @
f70ff5e2
...
@@ -142,17 +142,6 @@ public class Parameter extends Expression implements ParameterInterface {
...
@@ -142,17 +142,6 @@ public class Parameter extends Expression implements ParameterInterface {
return
0
;
return
0
;
}
}
@Override
public
int
getDisplaySize
()
{
if
(
value
!=
null
)
{
return
value
.
getType
().
getDisplaySize
();
}
if
(
column
!=
null
)
{
return
column
.
getType
().
getDisplaySize
();
}
return
0
;
}
@Override
@Override
public
void
updateAggregate
(
Session
session
,
int
stage
)
{
public
void
updateAggregate
(
Session
session
,
int
stage
)
{
// nothing to do
// nothing to do
...
...
h2/src/main/org/h2/expression/Rownum.java
浏览文件 @
f70ff5e2
...
@@ -58,21 +58,6 @@ public class Rownum extends Expression {
...
@@ -58,21 +58,6 @@ public class Rownum extends Expression {
// nothing to do
// nothing to do
}
}
@Override
public
int
getScale
()
{
return
0
;
}
@Override
public
long
getPrecision
()
{
return
ValueLong
.
PRECISION
;
}
@Override
public
int
getDisplaySize
()
{
return
ValueLong
.
DISPLAY_SIZE
;
}
@Override
@Override
public
String
getSQL
()
{
public
String
getSQL
()
{
return
"ROWNUM()"
;
return
"ROWNUM()"
;
...
...
h2/src/main/org/h2/expression/SequenceValue.java
浏览文件 @
f70ff5e2
...
@@ -57,21 +57,6 @@ public class SequenceValue extends Expression {
...
@@ -57,21 +57,6 @@ public class SequenceValue extends Expression {
// nothing to do
// nothing to do
}
}
@Override
public
int
getScale
()
{
return
0
;
}
@Override
public
long
getPrecision
()
{
return
ValueLong
.
PRECISION
;
}
@Override
public
int
getDisplaySize
()
{
return
ValueLong
.
DISPLAY_SIZE
;
}
@Override
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
builder
.
append
(
"(NEXT VALUE FOR "
);
builder
.
append
(
"(NEXT VALUE FOR "
);
...
...
h2/src/main/org/h2/expression/Subquery.java
浏览文件 @
f70ff5e2
...
@@ -79,21 +79,6 @@ public class Subquery extends Expression {
...
@@ -79,21 +79,6 @@ public class Subquery extends Expression {
query
.
setEvaluatable
(
tableFilter
,
b
);
query
.
setEvaluatable
(
tableFilter
,
b
);
}
}
@Override
public
int
getScale
()
{
return
getExpression
().
getScale
();
}
@Override
public
long
getPrecision
()
{
return
getExpression
().
getPrecision
();
}
@Override
public
int
getDisplaySize
()
{
return
getExpression
().
getDisplaySize
();
}
@Override
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
'('
).
append
(
query
.
getPlanSQL
()).
append
(
')'
);
return
builder
.
append
(
'('
).
append
(
query
.
getPlanSQL
()).
append
(
')'
);
...
...
h2/src/main/org/h2/expression/UnaryOperation.java
浏览文件 @
f70ff5e2
...
@@ -73,21 +73,6 @@ public class UnaryOperation extends Expression {
...
@@ -73,21 +73,6 @@ public class UnaryOperation extends Expression {
return
type
.
getValueType
();
return
type
.
getValueType
();
}
}
@Override
public
long
getPrecision
()
{
return
arg
.
getPrecision
();
}
@Override
public
int
getDisplaySize
()
{
return
arg
.
getDisplaySize
();
}
@Override
public
int
getScale
()
{
return
arg
.
getScale
();
}
@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
浏览文件 @
f70ff5e2
...
@@ -126,21 +126,6 @@ public class ValueExpression extends Expression {
...
@@ -126,21 +126,6 @@ public class ValueExpression extends Expression {
// nothing to do
// nothing to do
}
}
@Override
public
int
getScale
()
{
return
value
.
getType
().
getScale
();
}
@Override
public
long
getPrecision
()
{
return
value
.
getType
().
getPrecision
();
}
@Override
public
int
getDisplaySize
()
{
return
value
.
getType
().
getDisplaySize
();
}
@Override
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
if
(
this
==
DEFAULT
)
{
if
(
this
==
DEFAULT
)
{
...
...
h2/src/main/org/h2/expression/Variable.java
浏览文件 @
f70ff5e2
...
@@ -31,27 +31,12 @@ public class Variable extends Expression {
...
@@ -31,27 +31,12 @@ public class Variable extends Expression {
return
0
;
return
0
;
}
}
@Override
public
int
getDisplaySize
()
{
return
lastValue
.
getType
().
getDisplaySize
();
}
@Override
public
long
getPrecision
()
{
return
lastValue
.
getType
().
getPrecision
();
}
@Override
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
builder
.
append
(
'@'
);
builder
.
append
(
'@'
);
return
Parser
.
quoteIdentifier
(
builder
,
name
);
return
Parser
.
quoteIdentifier
(
builder
,
name
);
}
}
@Override
public
int
getScale
()
{
return
lastValue
.
getType
().
getScale
();
}
@Override
@Override
public
TypeInfo
getType
()
{
public
TypeInfo
getType
()
{
return
lastValue
.
getType
();
return
lastValue
.
getType
();
...
...
h2/src/main/org/h2/expression/Wildcard.java
浏览文件 @
f70ff5e2
...
@@ -96,21 +96,6 @@ public class Wildcard extends Expression {
...
@@ -96,21 +96,6 @@ public class Wildcard extends Expression {
DbException
.
throwInternalError
(
toString
());
DbException
.
throwInternalError
(
toString
());
}
}
@Override
public
int
getScale
()
{
throw
DbException
.
throwInternalError
(
toString
());
}
@Override
public
long
getPrecision
()
{
throw
DbException
.
throwInternalError
(
toString
());
}
@Override
public
int
getDisplaySize
()
{
throw
DbException
.
throwInternalError
(
toString
());
}
@Override
@Override
public
String
getTableAlias
()
{
public
String
getTableAlias
()
{
return
table
;
return
table
;
...
...
h2/src/main/org/h2/expression/aggregate/Aggregate.java
浏览文件 @
f70ff5e2
...
@@ -39,8 +39,6 @@ import org.h2.value.TypeInfo;
...
@@ -39,8 +39,6 @@ import org.h2.value.TypeInfo;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
import
org.h2.value.ValueArray
;
import
org.h2.value.ValueArray
;
import
org.h2.value.ValueBoolean
;
import
org.h2.value.ValueBoolean
;
import
org.h2.value.ValueDouble
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueLong
;
import
org.h2.value.ValueLong
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueString
;
import
org.h2.value.ValueString
;
...
@@ -166,9 +164,7 @@ public class Aggregate extends AbstractAggregate {
...
@@ -166,9 +164,7 @@ 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
,
scale
;
private
int
dataType
;
private
long
precision
;
private
int
displaySize
;
/**
/**
* Create a new aggregate object.
* Create a new aggregate object.
...
@@ -613,9 +609,6 @@ public class Aggregate extends AbstractAggregate {
...
@@ -613,9 +609,6 @@ public class Aggregate extends AbstractAggregate {
on
=
on
.
optimize
(
session
);
on
=
on
.
optimize
(
session
);
type
=
on
.
getType
();
type
=
on
.
getType
();
dataType
=
on
.
getValueType
();
dataType
=
on
.
getValueType
();
scale
=
on
.
getScale
();
precision
=
on
.
getPrecision
();
displaySize
=
on
.
getDisplaySize
();
}
}
if
(
orderByList
!=
null
)
{
if
(
orderByList
!=
null
)
{
for
(
SelectOrderBy
o
:
orderByList
)
{
for
(
SelectOrderBy
o
:
orderByList
)
{
...
@@ -630,29 +623,19 @@ public class Aggregate extends AbstractAggregate {
...
@@ -630,29 +623,19 @@ public class Aggregate extends AbstractAggregate {
case
GROUP_CONCAT:
case
GROUP_CONCAT:
type
=
TypeInfo
.
TYPE_STRING_DEFAULT
;
type
=
TypeInfo
.
TYPE_STRING_DEFAULT
;
dataType
=
Value
.
STRING
;
dataType
=
Value
.
STRING
;
scale
=
0
;
precision
=
displaySize
=
Integer
.
MAX_VALUE
;
break
;
break
;
case
COUNT_ALL:
case
COUNT_ALL:
case
COUNT:
case
COUNT:
type
=
TypeInfo
.
TYPE_LONG
;
type
=
TypeInfo
.
TYPE_LONG
;
dataType
=
Value
.
LONG
;
dataType
=
Value
.
LONG
;
scale
=
0
;
precision
=
ValueLong
.
PRECISION
;
displaySize
=
ValueLong
.
DISPLAY_SIZE
;
break
;
break
;
case
SELECTIVITY:
case
SELECTIVITY:
type
=
TypeInfo
.
TYPE_INT
;
type
=
TypeInfo
.
TYPE_INT
;
dataType
=
Value
.
INT
;
dataType
=
Value
.
INT
;
scale
=
0
;
precision
=
ValueInt
.
PRECISION
;
displaySize
=
ValueInt
.
DISPLAY_SIZE
;
break
;
break
;
case
HISTOGRAM:
case
HISTOGRAM:
type
=
TypeInfo
.
TYPE_ARRAY
;
type
=
TypeInfo
.
TYPE_ARRAY
;
dataType
=
Value
.
ARRAY
;
dataType
=
Value
.
ARRAY
;
scale
=
0
;
precision
=
displaySize
=
Integer
.
MAX_VALUE
;
break
;
break
;
case
SUM:
case
SUM:
if
(
dataType
==
Value
.
BOOLEAN
)
{
if
(
dataType
==
Value
.
BOOLEAN
)
{
...
@@ -682,17 +665,11 @@ public class Aggregate extends AbstractAggregate {
...
@@ -682,17 +665,11 @@ public class Aggregate extends AbstractAggregate {
case
VAR_SAMP:
case
VAR_SAMP:
type
=
TypeInfo
.
TYPE_DOUBLE
;
type
=
TypeInfo
.
TYPE_DOUBLE
;
dataType
=
Value
.
DOUBLE
;
dataType
=
Value
.
DOUBLE
;
precision
=
ValueDouble
.
PRECISION
;
displaySize
=
ValueDouble
.
DISPLAY_SIZE
;
scale
=
0
;
break
;
break
;
case
EVERY:
case
EVERY:
case
ANY:
case
ANY:
type
=
TypeInfo
.
TYPE_BOOLEAN
;
type
=
TypeInfo
.
TYPE_BOOLEAN
;
dataType
=
Value
.
BOOLEAN
;
dataType
=
Value
.
BOOLEAN
;
precision
=
ValueBoolean
.
PRECISION
;
displaySize
=
ValueBoolean
.
DISPLAY_SIZE
;
scale
=
0
;
break
;
break
;
case
BIT_AND:
case
BIT_AND:
case
BIT_OR:
case
BIT_OR:
...
@@ -703,14 +680,10 @@ public class Aggregate extends AbstractAggregate {
...
@@ -703,14 +680,10 @@ public class Aggregate extends AbstractAggregate {
case
ARRAY_AGG:
case
ARRAY_AGG:
type
=
TypeInfo
.
TYPE_ARRAY
;
type
=
TypeInfo
.
TYPE_ARRAY
;
dataType
=
Value
.
ARRAY
;
dataType
=
Value
.
ARRAY
;
scale
=
0
;
precision
=
displaySize
=
Integer
.
MAX_VALUE
;
break
;
break
;
case
ENVELOPE:
case
ENVELOPE:
type
=
TypeInfo
.
TYPE_GEOMETRY
;
type
=
TypeInfo
.
TYPE_GEOMETRY
;
dataType
=
Value
.
GEOMETRY
;
dataType
=
Value
.
GEOMETRY
;
scale
=
0
;
precision
=
displaySize
=
Integer
.
MAX_VALUE
;
break
;
break
;
default
:
default
:
DbException
.
throwInternalError
(
"type="
+
aggregateType
);
DbException
.
throwInternalError
(
"type="
+
aggregateType
);
...
@@ -734,21 +707,6 @@ public class Aggregate extends AbstractAggregate {
...
@@ -734,21 +707,6 @@ public class Aggregate extends AbstractAggregate {
super
.
setEvaluatable
(
tableFilter
,
b
);
super
.
setEvaluatable
(
tableFilter
,
b
);
}
}
@Override
public
int
getScale
()
{
return
scale
;
}
@Override
public
long
getPrecision
()
{
return
precision
;
}
@Override
public
int
getDisplaySize
()
{
return
displaySize
;
}
private
StringBuilder
getSQLGroupConcat
(
StringBuilder
builder
)
{
private
StringBuilder
getSQLGroupConcat
(
StringBuilder
builder
)
{
builder
.
append
(
"GROUP_CONCAT("
);
builder
.
append
(
"GROUP_CONCAT("
);
if
(
distinct
)
{
if
(
distinct
)
{
...
...
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
浏览文件 @
f70ff5e2
...
@@ -54,21 +54,6 @@ public class JavaAggregate extends AbstractAggregate {
...
@@ -54,21 +54,6 @@ public class JavaAggregate extends AbstractAggregate {
return
cost
;
return
cost
;
}
}
@Override
public
long
getPrecision
()
{
return
Integer
.
MAX_VALUE
;
}
@Override
public
int
getDisplaySize
()
{
return
Integer
.
MAX_VALUE
;
}
@Override
public
int
getScale
()
{
return
DataType
.
getDataType
(
dataType
).
defaultScale
;
}
@Override
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
Parser
.
quoteIdentifier
(
builder
,
userAggregate
.
getName
()).
append
(
'('
);
Parser
.
quoteIdentifier
(
builder
,
userAggregate
.
getName
()).
append
(
'('
);
...
...
h2/src/main/org/h2/expression/analysis/WindowFunction.java
浏览文件 @
f70ff5e2
...
@@ -521,66 +521,6 @@ public class WindowFunction extends DataAnalysisOperation {
...
@@ -521,66 +521,6 @@ public class WindowFunction extends DataAnalysisOperation {
}
}
}
}
@Override
public
int
getScale
()
{
switch
(
type
)
{
case
LEAD:
case
LAG:
case
FIRST_VALUE:
case
LAST_VALUE:
case
NTH_VALUE:
return
args
[
0
].
getScale
();
default
:
return
0
;
}
}
@Override
public
long
getPrecision
()
{
switch
(
type
)
{
case
ROW_NUMBER:
case
RANK:
case
DENSE_RANK:
case
NTILE:
return
ValueLong
.
PRECISION
;
case
PERCENT_RANK:
case
CUME_DIST:
case
RATIO_TO_REPORT:
return
ValueDouble
.
PRECISION
;
case
LEAD:
case
LAG:
case
FIRST_VALUE:
case
LAST_VALUE:
case
NTH_VALUE:
return
args
[
0
].
getPrecision
();
default
:
throw
DbException
.
throwInternalError
(
"type="
+
type
);
}
}
@Override
public
int
getDisplaySize
()
{
switch
(
type
)
{
case
ROW_NUMBER:
case
RANK:
case
DENSE_RANK:
case
NTILE:
return
ValueLong
.
DISPLAY_SIZE
;
case
PERCENT_RANK:
case
CUME_DIST:
case
RATIO_TO_REPORT:
return
ValueDouble
.
DISPLAY_SIZE
;
case
LEAD:
case
LAG:
case
FIRST_VALUE:
case
LAST_VALUE:
case
NTH_VALUE:
return
args
[
0
].
getDisplaySize
();
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/Comparison.java
浏览文件 @
f70ff5e2
...
@@ -234,7 +234,7 @@ public class Comparison extends Condition {
...
@@ -234,7 +234,7 @@ public class Comparison extends Condition {
if
(
constType
!=
resType
)
{
if
(
constType
!=
resType
)
{
Column
column
=
((
ExpressionColumn
)
left
).
getColumn
();
Column
column
=
((
ExpressionColumn
)
left
).
getColumn
();
right
=
ValueExpression
.
get
(
r
.
convertTo
(
resType
,
right
=
ValueExpression
.
get
(
r
.
convertTo
(
resType
,
MathUtils
.
convertLongToInt
(
left
.
getPrecision
()),
MathUtils
.
convertLongToInt
(
left
.
get
Type
().
get
Precision
()),
session
.
getDatabase
().
getMode
(),
column
,
column
.
getType
().
getExtTypeInfo
()));
session
.
getDatabase
().
getMode
(),
column
,
column
.
getType
().
getExtTypeInfo
()));
}
}
}
else
if
(
right
instanceof
Parameter
)
{
}
else
if
(
right
instanceof
Parameter
)
{
...
...
h2/src/main/org/h2/expression/condition/Condition.java
浏览文件 @
f70ff5e2
...
@@ -8,7 +8,6 @@ package org.h2.expression.condition;
...
@@ -8,7 +8,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
;
import
org.h2.value.Value
;
import
org.h2.value.ValueBoolean
;
/**
/**
* Represents a condition returning a boolean value, or NULL.
* Represents a condition returning a boolean value, or NULL.
...
@@ -25,19 +24,4 @@ abstract class Condition extends Expression {
...
@@ -25,19 +24,4 @@ abstract class Condition extends Expression {
return
Value
.
BOOLEAN
;
return
Value
.
BOOLEAN
;
}
}
@Override
public
int
getScale
()
{
return
0
;
}
@Override
public
long
getPrecision
()
{
return
ValueBoolean
.
PRECISION
;
}
@Override
public
int
getDisplaySize
()
{
return
ValueBoolean
.
DISPLAY_SIZE
;
}
}
}
h2/src/main/org/h2/expression/function/Function.java
浏览文件 @
f70ff5e2
...
@@ -901,9 +901,10 @@ public class Function extends Expression implements FunctionCall {
...
@@ -901,9 +901,10 @@ public class Function extends Expression implements FunctionCall {
case
CAST:
case
CAST:
case
CONVERT:
{
case
CONVERT:
{
Mode
mode
=
database
.
getMode
();
Mode
mode
=
database
.
getMode
();
v0
=
v0
.
convertTo
(
dataType
,
MathUtils
.
convertLongToInt
(
getPrecision
()),
mode
,
null
,
extTypeInfo
);
TypeInfo
type
=
this
.
type
;
v0
=
v0
.
convertScale
(
mode
.
convertOnlyToSmallerScale
,
getScale
());
v0
=
v0
.
convertTo
(
dataType
,
MathUtils
.
convertLongToInt
(
type
.
getPrecision
()),
mode
,
null
,
extTypeInfo
);
v0
=
v0
.
convertPrecision
(
getPrecision
(),
false
);
v0
=
v0
.
convertScale
(
mode
.
convertOnlyToSmallerScale
,
type
.
getScale
());
v0
=
v0
.
convertPrecision
(
type
.
getPrecision
(),
false
);
result
=
v0
;
result
=
v0
;
break
;
break
;
}
}
...
@@ -2394,12 +2395,13 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2394,12 +2395,13 @@ public class Function extends Expression implements FunctionCall {
d
=
0
;
d
=
0
;
for
(
Expression
e
:
args
)
{
for
(
Expression
e
:
args
)
{
if
(
e
!=
ValueExpression
.
getNull
())
{
if
(
e
!=
ValueExpression
.
getNull
())
{
int
type
=
e
.
getValueType
();
TypeInfo
type
=
e
.
getType
();
if
(
type
!=
Value
.
UNKNOWN
&&
type
!=
Value
.
NULL
)
{
int
valueType
=
type
.
getValueType
();
t
=
Value
.
getHigherOrder
(
t
,
type
);
if
(
valueType
!=
Value
.
UNKNOWN
&&
valueType
!=
Value
.
NULL
)
{
s
=
Math
.
max
(
s
,
e
.
getScale
());
t
=
Value
.
getHigherOrder
(
t
,
valueType
);
p
=
Math
.
max
(
p
,
e
.
getPrecision
());
s
=
Math
.
max
(
s
,
type
.
getScale
());
d
=
Math
.
max
(
d
,
e
.
getDisplaySize
());
p
=
Math
.
max
(
p
,
type
.
getPrecision
());
d
=
Math
.
max
(
d
,
type
.
getDisplaySize
());
}
}
}
}
}
}
...
@@ -2424,24 +2426,26 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2424,24 +2426,26 @@ public class Function extends Expression implements FunctionCall {
for
(
int
i
=
2
,
len
=
args
.
length
;
i
<
len
;
i
+=
2
)
{
for
(
int
i
=
2
,
len
=
args
.
length
;
i
<
len
;
i
+=
2
)
{
Expression
then
=
args
[
i
];
Expression
then
=
args
[
i
];
if
(
then
!=
ValueExpression
.
getNull
())
{
if
(
then
!=
ValueExpression
.
getNull
())
{
int
type
=
then
.
getValueType
();
TypeInfo
type
=
then
.
getType
();
if
(
type
!=
Value
.
UNKNOWN
&&
type
!=
Value
.
NULL
)
{
int
valueType
=
type
.
getValueType
();
t
=
Value
.
getHigherOrder
(
t
,
type
);
if
(
valueType
!=
Value
.
UNKNOWN
&&
valueType
!=
Value
.
NULL
)
{
s
=
Math
.
max
(
s
,
then
.
getScale
());
t
=
Value
.
getHigherOrder
(
t
,
valueType
);
p
=
Math
.
max
(
p
,
then
.
getPrecision
());
s
=
Math
.
max
(
s
,
type
.
getScale
());
d
=
Math
.
max
(
d
,
then
.
getDisplaySize
());
p
=
Math
.
max
(
p
,
type
.
getPrecision
());
d
=
Math
.
max
(
d
,
type
.
getDisplaySize
());
}
}
}
}
}
}
if
(
args
.
length
%
2
==
0
)
{
if
(
args
.
length
%
2
==
0
)
{
Expression
elsePart
=
args
[
args
.
length
-
1
];
Expression
elsePart
=
args
[
args
.
length
-
1
];
if
(
elsePart
!=
ValueExpression
.
getNull
())
{
if
(
elsePart
!=
ValueExpression
.
getNull
())
{
int
type
=
elsePart
.
getValueType
();
TypeInfo
type
=
elsePart
.
getType
();
if
(
type
!=
Value
.
UNKNOWN
&&
type
!=
Value
.
NULL
)
{
int
valueType
=
type
.
getValueType
();
t
=
Value
.
getHigherOrder
(
t
,
type
);
if
(
valueType
!=
Value
.
UNKNOWN
&&
valueType
!=
Value
.
NULL
)
{
s
=
Math
.
max
(
s
,
elsePart
.
getScale
());
t
=
Value
.
getHigherOrder
(
t
,
valueType
);
p
=
Math
.
max
(
p
,
elsePart
.
getPrecision
());
s
=
Math
.
max
(
s
,
type
.
getScale
());
d
=
Math
.
max
(
d
,
elsePart
.
getDisplaySize
());
p
=
Math
.
max
(
p
,
type
.
getPrecision
());
d
=
Math
.
max
(
d
,
type
.
getDisplaySize
());
}
}
}
}
}
}
...
@@ -2453,13 +2457,15 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2453,13 +2457,15 @@ public class Function extends Expression implements FunctionCall {
}
}
break
;
break
;
}
}
case
CASEWHEN:
case
CASEWHEN:
{
t
=
Value
.
getHigherOrder
(
args
[
1
].
getValueType
(),
args
[
2
].
getValueType
());
TypeInfo
t1
=
args
[
1
].
getType
(),
t2
=
args
[
2
].
getType
();
p
=
Math
.
max
(
args
[
1
].
getPrecision
(),
args
[
2
].
getPrecision
());
t
=
Value
.
getHigherOrder
(
t1
.
getValueType
(),
t2
.
getValueType
());
d
=
Math
.
max
(
args
[
1
].
getDisplaySize
(),
args
[
2
].
getDisplaySize
());
p
=
Math
.
max
(
t1
.
getPrecision
(),
t2
.
getPrecision
());
s
=
Math
.
max
(
args
[
1
].
getScale
(),
args
[
2
].
getScale
());
d
=
Math
.
max
(
t1
.
getDisplaySize
(),
t2
.
getDisplaySize
());
s
=
Math
.
max
(
t1
.
getScale
(),
t2
.
getScale
());
break
;
break
;
case
NVL2:
}
case
NVL2:
{
switch
(
args
[
1
].
getValueType
())
{
switch
(
args
[
1
].
getValueType
())
{
case
Value
.
STRING
:
case
Value
.
STRING
:
case
Value
.
CLOB
:
case
Value
.
CLOB
:
...
@@ -2471,10 +2477,12 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2471,10 +2477,12 @@ public class Function extends Expression implements FunctionCall {
t
=
Value
.
getHigherOrder
(
args
[
1
].
getValueType
(),
args
[
2
].
getValueType
());
t
=
Value
.
getHigherOrder
(
args
[
1
].
getValueType
(),
args
[
2
].
getValueType
());
break
;
break
;
}
}
p
=
Math
.
max
(
args
[
1
].
getPrecision
(),
args
[
2
].
getPrecision
());
TypeInfo
t1
=
args
[
1
].
getType
(),
t2
=
args
[
2
].
getType
();
d
=
Math
.
max
(
args
[
1
].
getDisplaySize
(),
args
[
2
].
getDisplaySize
());
p
=
Math
.
max
(
t1
.
getPrecision
(),
t2
.
getPrecision
());
s
=
Math
.
max
(
args
[
1
].
getScale
(),
args
[
2
].
getScale
());
d
=
Math
.
max
(
t1
.
getDisplaySize
(),
t2
.
getDisplaySize
());
s
=
Math
.
max
(
t1
.
getScale
(),
t2
.
getScale
());
break
;
break
;
}
case
CAST:
case
CAST:
case
CONVERT:
case
CONVERT:
case
TRUNCATE_VALUE:
case
TRUNCATE_VALUE:
...
@@ -2512,11 +2520,12 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2512,11 +2520,12 @@ public class Function extends Expression implements FunctionCall {
break
;
break
;
case
ABS:
case
ABS:
case
FLOOR:
case
FLOOR:
case
ROUND:
case
ROUND:
{
t
=
p0
.
getValueType
();
TypeInfo
type
=
p0
.
getType
();
s
=
p0
.
getScale
();
t
=
type
.
getValueType
();
p
=
p0
.
getPrecision
();
s
=
type
.
getScale
();
d
=
p0
.
getDisplaySize
();
p
=
type
.
getPrecision
();
d
=
type
.
getDisplaySize
();
if
(
t
==
Value
.
NULL
)
{
if
(
t
==
Value
.
NULL
)
{
t
=
Value
.
INT
;
t
=
Value
.
INT
;
p
=
ValueInt
.
PRECISION
;
p
=
ValueInt
.
PRECISION
;
...
@@ -2524,12 +2533,13 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2524,12 +2533,13 @@ public class Function extends Expression implements FunctionCall {
s
=
0
;
s
=
0
;
}
}
break
;
break
;
}
case
SET:
{
case
SET:
{
Expression
p1
=
args
[
1
]
;
TypeInfo
type
=
args
[
1
].
getType
()
;
t
=
p1
.
getValueType
();
t
=
type
.
getValueType
();
p
=
p1
.
getPrecision
();
p
=
type
.
getPrecision
();
s
=
p1
.
getScale
();
s
=
type
.
getScale
();
d
=
p1
.
getDisplaySize
();
d
=
type
.
getDisplaySize
();
if
(!(
p0
instanceof
Variable
))
{
if
(!(
p0
instanceof
Variable
))
{
throw
DbException
.
get
(
throw
DbException
.
get
(
ErrorCode
.
CAN_ONLY_ASSIGN_TO_VARIABLE_1
,
p0
.
getSQL
());
ErrorCode
.
CAN_ONLY_ASSIGN_TO_VARIABLE_1
,
p0
.
getSQL
());
...
@@ -2550,7 +2560,7 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2550,7 +2560,7 @@ public class Function extends Expression implements FunctionCall {
case
SUBSTRING:
case
SUBSTRING:
case
SUBSTR:
{
case
SUBSTR:
{
t
=
info
.
returnDataType
;
t
=
info
.
returnDataType
;
p
=
args
[
0
].
getPrecision
();
p
=
args
[
0
].
get
Type
().
get
Precision
();
s
=
0
;
s
=
0
;
if
(
args
[
1
].
isConstant
())
{
if
(
args
[
1
].
isConstant
())
{
// if only two arguments are used,
// if only two arguments are used,
...
@@ -2566,18 +2576,22 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2566,18 +2576,22 @@ public class Function extends Expression implements FunctionCall {
break
;
break
;
}
}
case
ENCRYPT:
case
ENCRYPT:
case
DECRYPT:
case
DECRYPT:
{
t
=
info
.
returnDataType
;
t
=
info
.
returnDataType
;
p
=
args
[
2
].
getPrecision
();
TypeInfo
type
=
args
[
2
].
getType
();
d
=
args
[
2
].
getDisplaySize
();
p
=
type
.
getPrecision
();
d
=
type
.
getDisplaySize
();
s
=
0
;
s
=
0
;
break
;
break
;
case
COMPRESS:
}
case
COMPRESS:
{
t
=
info
.
returnDataType
;
t
=
info
.
returnDataType
;
p
=
args
[
0
].
getPrecision
();
TypeInfo
type
=
args
[
0
].
getType
();
d
=
args
[
0
].
getDisplaySize
();
p
=
type
.
getPrecision
();
d
=
type
.
getDisplaySize
();
s
=
0
;
s
=
0
;
break
;
break
;
}
case
CHAR:
case
CHAR:
t
=
info
.
returnDataType
;
t
=
info
.
returnDataType
;
p
=
1
;
p
=
1
;
...
@@ -2590,8 +2604,9 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2590,8 +2604,9 @@ public class Function extends Expression implements FunctionCall {
d
=
0
;
d
=
0
;
s
=
0
;
s
=
0
;
for
(
Expression
e
:
args
)
{
for
(
Expression
e
:
args
)
{
p
+=
e
.
getPrecision
();
TypeInfo
type
=
e
.
getType
();
d
=
MathUtils
.
convertLongToInt
((
long
)
d
+
e
.
getDisplaySize
());
p
+=
type
.
getPrecision
();
d
=
MathUtils
.
convertLongToInt
((
long
)
d
+
type
.
getDisplaySize
());
if
(
p
<
0
)
{
if
(
p
<
0
)
{
p
=
Long
.
MAX_VALUE
;
p
=
Long
.
MAX_VALUE
;
}
}
...
@@ -2599,7 +2614,7 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2599,7 +2614,7 @@ public class Function extends Expression implements FunctionCall {
break
;
break
;
case
HEXTORAW:
case
HEXTORAW:
t
=
info
.
returnDataType
;
t
=
info
.
returnDataType
;
p
=
(
args
[
0
].
getPrecision
()
+
3
)
/
4
;
p
=
(
args
[
0
].
get
Type
().
get
Precision
()
+
3
)
/
4
;
d
=
MathUtils
.
convertLongToInt
(
p
);
d
=
MathUtils
.
convertLongToInt
(
p
);
s
=
0
;
s
=
0
;
break
;
break
;
...
@@ -2612,15 +2627,17 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2612,15 +2627,17 @@ public class Function extends Expression implements FunctionCall {
case
UPPER:
case
UPPER:
case
TRIM:
case
TRIM:
case
STRINGDECODE:
case
STRINGDECODE:
case
UTF8TOSTRING:
case
UTF8TOSTRING:
{
t
=
info
.
returnDataType
;
t
=
info
.
returnDataType
;
p
=
args
[
0
].
getPrecision
();
TypeInfo
type
=
args
[
0
].
getType
();
d
=
args
[
0
].
getDisplaySize
();
p
=
type
.
getPrecision
();
d
=
type
.
getDisplaySize
();
s
=
0
;
s
=
0
;
break
;
break
;
}
case
RAWTOHEX:
case
RAWTOHEX:
t
=
info
.
returnDataType
;
t
=
info
.
returnDataType
;
p
=
args
[
0
].
getPrecision
()
*
4
;
p
=
args
[
0
].
get
Type
().
get
Precision
()
*
4
;
d
=
MathUtils
.
convertLongToInt
(
p
);
d
=
MathUtils
.
convertLongToInt
(
p
);
s
=
0
;
s
=
0
;
break
;
break
;
...
@@ -2666,21 +2683,6 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2666,21 +2683,6 @@ public class Function extends Expression implements FunctionCall {
}
}
}
}
@Override
public
int
getScale
()
{
return
type
.
getScale
();
}
@Override
public
long
getPrecision
()
{
return
type
.
getPrecision
();
}
@Override
public
int
getDisplaySize
()
{
return
type
.
getDisplaySize
();
}
@Override
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
builder
.
append
(
info
.
name
);
builder
.
append
(
info
.
name
);
...
...
h2/src/main/org/h2/expression/function/JavaFunction.java
浏览文件 @
f70ff5e2
...
@@ -14,7 +14,6 @@ import org.h2.expression.ExpressionVisitor;
...
@@ -14,7 +14,6 @@ import org.h2.expression.ExpressionVisitor;
import
org.h2.expression.ValueExpression
;
import
org.h2.expression.ValueExpression
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.TableFilter
;
import
org.h2.table.TableFilter
;
import
org.h2.value.DataType
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
import
org.h2.value.ValueArray
;
import
org.h2.value.ValueArray
;
...
@@ -81,21 +80,6 @@ public class JavaFunction extends Expression implements FunctionCall {
...
@@ -81,21 +80,6 @@ public class JavaFunction extends Expression implements FunctionCall {
}
}
}
}
@Override
public
int
getScale
()
{
return
DataType
.
getDataType
(
getValueType
()).
defaultScale
;
}
@Override
public
long
getPrecision
()
{
return
Integer
.
MAX_VALUE
;
}
@Override
public
int
getDisplaySize
()
{
return
Integer
.
MAX_VALUE
;
}
@Override
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
// TODO always append the schema once FUNCTIONS_IN_SCHEMA is enabled
// TODO always append the schema once FUNCTIONS_IN_SCHEMA is enabled
...
...
h2/src/main/org/h2/result/LazyResult.java
浏览文件 @
f70ff5e2
...
@@ -145,17 +145,17 @@ public abstract class LazyResult implements ResultInterface {
...
@@ -145,17 +145,17 @@ public abstract class LazyResult implements ResultInterface {
@Override
@Override
public
long
getColumnPrecision
(
int
i
)
{
public
long
getColumnPrecision
(
int
i
)
{
return
expressions
[
i
].
getPrecision
();
return
expressions
[
i
].
get
Type
().
get
Precision
();
}
}
@Override
@Override
public
int
getColumnScale
(
int
i
)
{
public
int
getColumnScale
(
int
i
)
{
return
expressions
[
i
].
getScale
();
return
expressions
[
i
].
get
Type
().
get
Scale
();
}
}
@Override
@Override
public
int
getDisplaySize
(
int
i
)
{
public
int
getDisplaySize
(
int
i
)
{
return
expressions
[
i
].
getDisplaySize
();
return
expressions
[
i
].
get
Type
().
get
DisplaySize
();
}
}
@Override
@Override
...
...
h2/src/main/org/h2/result/LocalResultImpl.java
浏览文件 @
f70ff5e2
...
@@ -529,7 +529,7 @@ public class LocalResultImpl implements LocalResult {
...
@@ -529,7 +529,7 @@ public class LocalResultImpl implements LocalResult {
@Override
@Override
public
int
getDisplaySize
(
int
i
)
{
public
int
getDisplaySize
(
int
i
)
{
return
expressions
[
i
].
getDisplaySize
();
return
expressions
[
i
].
get
Type
().
get
DisplaySize
();
}
}
@Override
@Override
...
@@ -544,7 +544,7 @@ public class LocalResultImpl implements LocalResult {
...
@@ -544,7 +544,7 @@ public class LocalResultImpl implements LocalResult {
@Override
@Override
public
long
getColumnPrecision
(
int
i
)
{
public
long
getColumnPrecision
(
int
i
)
{
return
expressions
[
i
].
getPrecision
();
return
expressions
[
i
].
get
Type
().
get
Precision
();
}
}
@Override
@Override
...
@@ -559,7 +559,7 @@ public class LocalResultImpl implements LocalResult {
...
@@ -559,7 +559,7 @@ public class LocalResultImpl implements LocalResult {
@Override
@Override
public
int
getColumnScale
(
int
i
)
{
public
int
getColumnScale
(
int
i
)
{
return
expressions
[
i
].
getScale
();
return
expressions
[
i
].
get
Type
().
get
Scale
();
}
}
/**
/**
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
f70ff5e2
...
@@ -40,6 +40,7 @@ import org.h2.util.StringUtils;
...
@@ -40,6 +40,7 @@ import org.h2.util.StringUtils;
import
org.h2.util.Utils
;
import
org.h2.util.Utils
;
import
org.h2.value.DataType
;
import
org.h2.value.DataType
;
import
org.h2.value.ExtTypeInfo
;
import
org.h2.value.ExtTypeInfo
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
/**
/**
...
@@ -181,28 +182,29 @@ public class TableView extends Table {
...
@@ -181,28 +182,29 @@ public class TableView extends Table {
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
Expression
expr
=
expressions
.
get
(
i
);
Expression
expr
=
expressions
.
get
(
i
);
String
name
=
null
;
String
name
=
null
;
int
t
ype
=
Value
.
UNKNOWN
;
int
valueT
ype
=
Value
.
UNKNOWN
;
if
(
columnTemplates
!=
null
&&
columnTemplates
.
length
>
i
)
{
if
(
columnTemplates
!=
null
&&
columnTemplates
.
length
>
i
)
{
name
=
columnTemplates
[
i
].
getName
();
name
=
columnTemplates
[
i
].
getName
();
t
ype
=
columnTemplates
[
i
].
getType
().
getValueType
();
valueT
ype
=
columnTemplates
[
i
].
getType
().
getValueType
();
}
}
if
(
name
==
null
)
{
if
(
name
==
null
)
{
name
=
expr
.
getAlias
();
name
=
expr
.
getAlias
();
}
}
name
=
columnNamer
.
getColumnName
(
expr
,
i
,
name
);
name
=
columnNamer
.
getColumnName
(
expr
,
i
,
name
);
if
(
t
ype
==
Value
.
UNKNOWN
)
{
if
(
valueT
ype
==
Value
.
UNKNOWN
)
{
t
ype
=
expr
.
getValueType
();
valueT
ype
=
expr
.
getValueType
();
}
}
long
precision
=
expr
.
getPrecision
();
TypeInfo
type
=
expr
.
getType
();
int
scale
=
expr
.
getScale
();
long
precision
=
type
.
getPrecision
();
int
displaySize
=
expr
.
getDisplaySize
();
int
scale
=
type
.
getScale
();
int
displaySize
=
type
.
getDisplaySize
();
ExtTypeInfo
extTypeInfo
=
null
;
ExtTypeInfo
extTypeInfo
=
null
;
if
(
DataType
.
isExtInfoType
(
t
ype
))
{
if
(
DataType
.
isExtInfoType
(
valueT
ype
))
{
if
(
expr
instanceof
ExpressionColumn
)
{
if
(
expr
instanceof
ExpressionColumn
)
{
extTypeInfo
=
((
ExpressionColumn
)
expr
).
getColumn
().
getType
().
getExtTypeInfo
();
extTypeInfo
=
((
ExpressionColumn
)
expr
).
getColumn
().
getType
().
getExtTypeInfo
();
}
}
}
}
Column
col
=
new
Column
(
name
,
t
ype
,
precision
,
scale
,
displaySize
,
extTypeInfo
);
Column
col
=
new
Column
(
name
,
valueT
ype
,
precision
,
scale
,
displaySize
,
extTypeInfo
);
col
.
setTable
(
this
,
i
);
col
.
setTable
(
this
,
i
);
// Fetch check constraint from view column source
// Fetch check constraint from view column source
ExpressionColumn
fromColumn
=
null
;
ExpressionColumn
fromColumn
=
null
;
...
...
h2/src/main/org/h2/value/ExtTypeInfoEnum.java
浏览文件 @
f70ff5e2
...
@@ -18,6 +18,8 @@ public final class ExtTypeInfoEnum extends ExtTypeInfo {
...
@@ -18,6 +18,8 @@ public final class ExtTypeInfoEnum extends ExtTypeInfo {
private
final
String
[]
enumerators
,
cleaned
;
private
final
String
[]
enumerators
,
cleaned
;
private
TypeInfo
type
;
/**
/**
* Returns enumerators for the two specified values for a binary operation.
* Returns enumerators for the two specified values for a binary operation.
*
*
...
@@ -92,6 +94,21 @@ public final class ExtTypeInfoEnum extends ExtTypeInfo {
...
@@ -92,6 +94,21 @@ public final class ExtTypeInfoEnum extends ExtTypeInfo {
this
.
cleaned
=
Arrays
.
equals
(
cleaned
,
enumerators
)
?
enumerators
:
cleaned
;
this
.
cleaned
=
Arrays
.
equals
(
cleaned
,
enumerators
)
?
enumerators
:
cleaned
;
}
}
TypeInfo
getType
()
{
TypeInfo
type
=
this
.
type
;
if
(
type
==
null
)
{
int
p
=
0
;
for
(
String
s
:
enumerators
)
{
int
l
=
s
.
length
();
if
(
l
>
p
)
{
p
=
l
;
}
}
this
.
type
=
type
=
new
TypeInfo
(
Value
.
ENUM
,
p
,
0
,
p
,
this
);
}
return
type
;
}
@Override
@Override
public
Value
cast
(
Value
value
)
{
public
Value
cast
(
Value
value
)
{
switch
(
value
.
getValueType
())
{
switch
(
value
.
getValueType
())
{
...
...
h2/src/main/org/h2/value/ValueEnum.java
浏览文件 @
f70ff5e2
...
@@ -19,7 +19,7 @@ public class ValueEnum extends ValueEnumBase {
...
@@ -19,7 +19,7 @@ public class ValueEnum extends ValueEnumBase {
@Override
@Override
public
TypeInfo
getType
()
{
public
TypeInfo
getType
()
{
return
new
TypeInfo
(
ENUM
,
PRECISION
,
0
,
DISPLAY_SIZE
,
enumerators
);
return
enumerators
.
getType
(
);
}
}
public
ExtTypeInfoEnum
getEnumerators
()
{
public
ExtTypeInfoEnum
getEnumerators
()
{
...
...
h2/src/test/org/h2/test/scripts/datatypes/enum.sql
浏览文件 @
f70ff5e2
...
@@ -255,9 +255,9 @@ SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'E' ORDER BY TABLE_
...
@@ -255,9 +255,9 @@ SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'E' ORDER BY TABLE_
>
------------- ------------ ---------- ----------- ---------------- -------------- ------------- ----------- -------------- ----------- --------- ------------------------ ---------------------- ----------------- ----------------------- ------------- ------------------ ------------- ------------------ ------------------ -------------- --------- -------- ----------- ----------- ---------------- ------------- ------- ---------------- -------------- ---------------- ----------
>
------------- ------------ ---------- ----------- ---------------- -------------- ------------- ----------- -------------- ----------- --------- ------------------------ ---------------------- ----------------- ----------------------- ------------- ------------------ ------------- ------------------ ------------------ -------------- --------- -------- ----------- ----------- ---------------- ------------- ------- ---------------- -------------- ---------------- ----------
>
SCRIPT
PUBLIC
TEST
E
1
null
null
null
null
YES
1111
2147483647
2147483647
2147483647
10
0
null
null
null
Unicode
OFF
ENUM
1
FALSE
50
null
null
ENUM
(
'A'
,
'B'
)
null
TRUE
>
SCRIPT
PUBLIC
TEST
E
1
null
null
null
null
YES
1111
2147483647
2147483647
2147483647
10
0
null
null
null
Unicode
OFF
ENUM
1
FALSE
50
null
null
ENUM
(
'A'
,
'B'
)
null
TRUE
>
SCRIPT
PUBLIC
V
E
1
null
null
null
null
YES
1111
2147483647
2147483647
2147483647
10
0
null
null
null
Unicode
OFF
ENUM
1
FALSE
50
null
null
ENUM
(
'A'
,
'B'
)
null
TRUE
>
SCRIPT
PUBLIC
V
E
1
null
null
null
null
YES
1111
2147483647
2147483647
2147483647
10
0
null
null
null
Unicode
OFF
ENUM
1
FALSE
50
null
null
ENUM
(
'A'
,
'B'
)
null
TRUE
>
SCRIPT
PUBLIC
V1
E
1
null
null
null
null
YES
4
2147483647
2147483647
2147483647
10
0
null
null
null
Unicode
OFF
INTEGER
1
FALSE
50
null
null
INTEGER
null
TRUE
>
SCRIPT
PUBLIC
V1
E
1
null
null
null
null
YES
4
10
10
10
10
0
null
null
null
Unicode
OFF
INTEGER
1
FALSE
50
null
null
INTEGER
null
TRUE
>
SCRIPT
PUBLIC
V2
E
1
null
null
null
null
YES
4
2147483647
2147483647
2147483647
10
0
null
null
null
Unicode
OFF
INTEGER
1
FALSE
50
null
null
INTEGER
null
TRUE
>
SCRIPT
PUBLIC
V2
E
1
null
null
null
null
YES
4
10
10
10
10
0
null
null
null
Unicode
OFF
INTEGER
1
FALSE
50
null
null
INTEGER
null
TRUE
>
SCRIPT
PUBLIC
V3
E
1
null
null
null
null
YES
4
2147483647
2147483647
2147483647
10
0
null
null
null
Unicode
OFF
INTEGER
1
FALSE
50
null
null
INTEGER
null
TRUE
>
SCRIPT
PUBLIC
V3
E
1
null
null
null
null
YES
4
10
10
10
10
0
null
null
null
Unicode
OFF
INTEGER
1
FALSE
50
null
null
INTEGER
null
TRUE
>
rows
(
ordered
):
5
>
rows
(
ordered
):
5
DROP
VIEW
V
;
DROP
VIEW
V
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论