Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f70ff5e2
提交
f70ff5e2
authored
6 年前
作者:
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 {
do
{
Expression
expr
=
readExpression
();
expr
=
expr
.
optimize
(
session
);
int
type
=
expr
.
getValueType
();
TypeInfo
type
=
expr
.
getType
();
int
valueType
=
type
.
getValueType
();
long
prec
;
int
scale
,
displaySize
;
Column
column
;
String
columnName
=
"C"
+
(
i
+
1
);
if
(
rows
.
isEmpty
())
{
if
(
t
ype
==
Value
.
UNKNOWN
)
{
t
ype
=
Value
.
STRING
;
if
(
valueT
ype
==
Value
.
UNKNOWN
)
{
valueT
ype
=
Value
.
STRING
;
}
DataType
dt
=
DataType
.
getDataType
(
t
ype
);
DataType
dt
=
DataType
.
getDataType
(
valueT
ype
);
prec
=
dt
.
defaultPrecision
;
scale
=
dt
.
defaultScale
;
displaySize
=
dt
.
defaultDisplaySize
;
column
=
new
Column
(
columnName
,
type
,
prec
,
scale
,
displaySize
);
column
=
new
Column
(
columnName
,
valueType
,
prec
,
scale
,
displaySize
);
columns
.
add
(
column
);
}
prec
=
expr
.
getPrecision
();
scale
=
expr
.
getScale
();
displaySize
=
expr
.
getDisplaySize
();
prec
=
type
.
getPrecision
();
scale
=
type
.
getScale
();
displaySize
=
type
.
getDisplaySize
();
if
(
i
>=
columns
.
size
())
{
throw
DbException
.
get
(
ErrorCode
.
COLUMN_COUNT_DOES_NOT_MATCH
);
}
Column
c
=
columns
.
get
(
i
);
TypeInfo
t
=
c
.
getType
();
type
=
Value
.
getHigherOrder
(
t
.
getValueType
(),
t
ype
);
valueType
=
Value
.
getHigherOrder
(
t
.
getValueType
(),
valueT
ype
);
prec
=
Math
.
max
(
t
.
getPrecision
(),
prec
);
scale
=
Math
.
max
(
t
.
getScale
(),
scale
);
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
);
row
.
add
(
expr
);
i
++;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/CreateTable.java
浏览文件 @
f70ff5e2
...
...
@@ -24,6 +24,7 @@ import org.h2.table.Table;
import
org.h2.util.ColumnNamer
;
import
org.h2.value.DataType
;
import
org.h2.value.ExtTypeInfo
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
/**
...
...
@@ -180,17 +181,18 @@ public class CreateTable extends CommandWithColumns {
ColumnNamer
columnNamer
=
new
ColumnNamer
(
session
);
for
(
int
i
=
0
;
i
<
columnCount
;
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
());
long
precision
=
expr
.
getPrecision
();
int
displaySize
=
expr
.
getDisplaySize
();
DataType
dt
=
DataType
.
getDataType
(
t
ype
);
long
precision
=
type
.
getPrecision
();
int
displaySize
=
type
.
getDisplaySize
();
DataType
dt
=
DataType
.
getDataType
(
valueT
ype
);
if
(
precision
>
0
&&
(
dt
.
defaultPrecision
==
0
||
(
dt
.
defaultPrecision
>
precision
&&
dt
.
defaultPrecision
<
Byte
.
MAX_VALUE
)))
{
// dont' set precision to MAX_VALUE if this is the default
precision
=
dt
.
defaultPrecision
;
}
int
scale
=
expr
.
getScale
();
int
scale
=
type
.
getScale
();
if
(
scale
>
0
&&
(
dt
.
defaultScale
==
0
||
(
dt
.
defaultScale
>
scale
&&
dt
.
defaultScale
<
precision
)))
{
scale
=
dt
.
defaultScale
;
...
...
@@ -211,7 +213,7 @@ public class CreateTable extends CommandWithColumns {
"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
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/SelectUnion.java
浏览文件 @
f70ff5e2
...
...
@@ -27,6 +27,7 @@ import org.h2.table.ColumnResolver;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.ColumnNamer
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueNull
;
...
...
@@ -328,10 +329,11 @@ public class SelectUnion extends Query {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Expression
l
=
le
.
get
(
i
);
Expression
r
=
re
.
get
(
i
);
int
type
=
Value
.
getHigherOrder
(
l
.
getValueType
(),
r
.
getValueType
());
long
prec
=
Math
.
max
(
l
.
getPrecision
(),
r
.
getPrecision
());
int
scale
=
Math
.
max
(
l
.
getScale
(),
r
.
getScale
());
int
displaySize
=
Math
.
max
(
l
.
getDisplaySize
(),
r
.
getDisplaySize
());
TypeInfo
lType
=
l
.
getType
(),
rType
=
r
.
getType
();
int
type
=
Value
.
getHigherOrder
(
lType
.
getValueType
(),
rType
.
getValueType
());
long
prec
=
Math
.
max
(
lType
.
getPrecision
(),
rType
.
getPrecision
());
int
scale
=
Math
.
max
(
lType
.
getScale
(),
rType
.
getScale
());
int
displaySize
=
Math
.
max
(
lType
.
getDisplaySize
(),
rType
.
getDisplaySize
());
String
columnName
=
columnNamer
.
getColumnName
(
l
,
i
,
l
.
getAlias
());
Column
col
=
new
Column
(
columnName
,
type
,
prec
,
scale
,
displaySize
);
Expression
e
=
new
ExpressionColumn
(
session
.
getDatabase
(),
col
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Alias.java
浏览文件 @
f70ff5e2
...
...
@@ -63,21 +63,6 @@ public class Alias extends Expression {
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
public
boolean
isAutoIncrement
()
{
return
expr
.
isAutoIncrement
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/BinaryOperation.java
浏览文件 @
f70ff5e2
...
...
@@ -12,7 +12,6 @@ import org.h2.expression.function.Function;
import
org.h2.message.DbException
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.TableFilter
;
import
org.h2.util.MathUtils
;
import
org.h2.value.DataType
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
...
...
@@ -431,32 +430,6 @@ public class BinaryOperation extends Expression {
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
public
void
updateAggregate
(
Session
session
,
int
stage
)
{
left
.
updateAggregate
(
session
,
stage
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Expression.java
浏览文件 @
f70ff5e2
...
...
@@ -127,27 +127,6 @@ public abstract class Expression {
*/
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.
* This may not always be the original SQL statement,
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
f70ff5e2
...
...
@@ -243,21 +243,6 @@ public class ExpressionColumn extends Expression {
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
()
{
return
columnName
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/ExpressionList.java
浏览文件 @
f70ff5e2
...
...
@@ -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
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
builder
.
append
(
isArray
?
"ARRAY ["
:
"ROW ("
);
...
...
@@ -130,9 +115,7 @@ public class ExpressionList extends Expression {
ExpressionColumn
[]
expr
=
new
ExpressionColumn
[
list
.
length
];
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
Expression
e
=
list
[
i
];
Column
col
=
new
Column
(
"C"
+
(
i
+
1
),
e
.
getValueType
(),
e
.
getPrecision
(),
e
.
getScale
(),
e
.
getDisplaySize
());
Column
col
=
new
Column
(
"C"
+
(
i
+
1
),
e
.
getType
());
expr
[
i
]
=
new
ExpressionColumn
(
session
.
getDatabase
(),
col
);
}
return
expr
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/IntervalOperation.java
浏览文件 @
f70ff5e2
...
...
@@ -293,21 +293,6 @@ public class IntervalOperation extends Expression {
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
public
void
updateAggregate
(
Session
session
,
int
stage
)
{
left
.
updateAggregate
(
session
,
stage
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Parameter.java
浏览文件 @
f70ff5e2
...
...
@@ -142,17 +142,6 @@ public class Parameter extends Expression implements ParameterInterface {
return
0
;
}
@Override
public
int
getDisplaySize
()
{
if
(
value
!=
null
)
{
return
value
.
getType
().
getDisplaySize
();
}
if
(
column
!=
null
)
{
return
column
.
getType
().
getDisplaySize
();
}
return
0
;
}
@Override
public
void
updateAggregate
(
Session
session
,
int
stage
)
{
// nothing to do
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Rownum.java
浏览文件 @
f70ff5e2
...
...
@@ -58,21 +58,6 @@ public class Rownum extends Expression {
// 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
public
String
getSQL
()
{
return
"ROWNUM()"
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/SequenceValue.java
浏览文件 @
f70ff5e2
...
...
@@ -57,21 +57,6 @@ public class SequenceValue extends Expression {
// 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
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
builder
.
append
(
"(NEXT VALUE FOR "
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Subquery.java
浏览文件 @
f70ff5e2
...
...
@@ -79,21 +79,6 @@ public class Subquery extends Expression {
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
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
'('
).
append
(
query
.
getPlanSQL
()).
append
(
')'
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/UnaryOperation.java
浏览文件 @
f70ff5e2
...
...
@@ -73,21 +73,6 @@ public class UnaryOperation extends Expression {
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
public
void
updateAggregate
(
Session
session
,
int
stage
)
{
arg
.
updateAggregate
(
session
,
stage
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/ValueExpression.java
浏览文件 @
f70ff5e2
...
...
@@ -126,21 +126,6 @@ public class ValueExpression extends Expression {
// 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
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
if
(
this
==
DEFAULT
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Variable.java
浏览文件 @
f70ff5e2
...
...
@@ -31,27 +31,12 @@ public class Variable extends Expression {
return
0
;
}
@Override
public
int
getDisplaySize
()
{
return
lastValue
.
getType
().
getDisplaySize
();
}
@Override
public
long
getPrecision
()
{
return
lastValue
.
getType
().
getPrecision
();
}
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
builder
.
append
(
'@'
);
return
Parser
.
quoteIdentifier
(
builder
,
name
);
}
@Override
public
int
getScale
()
{
return
lastValue
.
getType
().
getScale
();
}
@Override
public
TypeInfo
getType
()
{
return
lastValue
.
getType
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Wildcard.java
浏览文件 @
f70ff5e2
...
...
@@ -96,21 +96,6 @@ public class Wildcard extends Expression {
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
public
String
getTableAlias
()
{
return
table
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/aggregate/Aggregate.java
浏览文件 @
f70ff5e2
...
...
@@ -39,8 +39,6 @@ import org.h2.value.TypeInfo;
import
org.h2.value.Value
;
import
org.h2.value.ValueArray
;
import
org.h2.value.ValueBoolean
;
import
org.h2.value.ValueDouble
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueLong
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueString
;
...
...
@@ -166,9 +164,7 @@ public class Aggregate extends AbstractAggregate {
private
ArrayList
<
SelectOrderBy
>
orderByList
;
private
SortOrder
orderBySort
;
private
TypeInfo
type
;
private
int
dataType
,
scale
;
private
long
precision
;
private
int
displaySize
;
private
int
dataType
;
/**
* Create a new aggregate object.
...
...
@@ -613,9 +609,6 @@ public class Aggregate extends AbstractAggregate {
on
=
on
.
optimize
(
session
);
type
=
on
.
getType
();
dataType
=
on
.
getValueType
();
scale
=
on
.
getScale
();
precision
=
on
.
getPrecision
();
displaySize
=
on
.
getDisplaySize
();
}
if
(
orderByList
!=
null
)
{
for
(
SelectOrderBy
o
:
orderByList
)
{
...
...
@@ -630,29 +623,19 @@ public class Aggregate extends AbstractAggregate {
case
GROUP_CONCAT:
type
=
TypeInfo
.
TYPE_STRING_DEFAULT
;
dataType
=
Value
.
STRING
;
scale
=
0
;
precision
=
displaySize
=
Integer
.
MAX_VALUE
;
break
;
case
COUNT_ALL:
case
COUNT:
type
=
TypeInfo
.
TYPE_LONG
;
dataType
=
Value
.
LONG
;
scale
=
0
;
precision
=
ValueLong
.
PRECISION
;
displaySize
=
ValueLong
.
DISPLAY_SIZE
;
break
;
case
SELECTIVITY:
type
=
TypeInfo
.
TYPE_INT
;
dataType
=
Value
.
INT
;
scale
=
0
;
precision
=
ValueInt
.
PRECISION
;
displaySize
=
ValueInt
.
DISPLAY_SIZE
;
break
;
case
HISTOGRAM:
type
=
TypeInfo
.
TYPE_ARRAY
;
dataType
=
Value
.
ARRAY
;
scale
=
0
;
precision
=
displaySize
=
Integer
.
MAX_VALUE
;
break
;
case
SUM:
if
(
dataType
==
Value
.
BOOLEAN
)
{
...
...
@@ -682,17 +665,11 @@ public class Aggregate extends AbstractAggregate {
case
VAR_SAMP:
type
=
TypeInfo
.
TYPE_DOUBLE
;
dataType
=
Value
.
DOUBLE
;
precision
=
ValueDouble
.
PRECISION
;
displaySize
=
ValueDouble
.
DISPLAY_SIZE
;
scale
=
0
;
break
;
case
EVERY:
case
ANY:
type
=
TypeInfo
.
TYPE_BOOLEAN
;
dataType
=
Value
.
BOOLEAN
;
precision
=
ValueBoolean
.
PRECISION
;
displaySize
=
ValueBoolean
.
DISPLAY_SIZE
;
scale
=
0
;
break
;
case
BIT_AND:
case
BIT_OR:
...
...
@@ -703,14 +680,10 @@ public class Aggregate extends AbstractAggregate {
case
ARRAY_AGG:
type
=
TypeInfo
.
TYPE_ARRAY
;
dataType
=
Value
.
ARRAY
;
scale
=
0
;
precision
=
displaySize
=
Integer
.
MAX_VALUE
;
break
;
case
ENVELOPE:
type
=
TypeInfo
.
TYPE_GEOMETRY
;
dataType
=
Value
.
GEOMETRY
;
scale
=
0
;
precision
=
displaySize
=
Integer
.
MAX_VALUE
;
break
;
default
:
DbException
.
throwInternalError
(
"type="
+
aggregateType
);
...
...
@@ -734,21 +707,6 @@ public class Aggregate extends AbstractAggregate {
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
)
{
builder
.
append
(
"GROUP_CONCAT("
);
if
(
distinct
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
浏览文件 @
f70ff5e2
...
...
@@ -54,21 +54,6 @@ public class JavaAggregate extends AbstractAggregate {
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
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
Parser
.
quoteIdentifier
(
builder
,
userAggregate
.
getName
()).
append
(
'('
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/analysis/WindowFunction.java
浏览文件 @
f70ff5e2
...
...
@@ -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
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
String
name
=
type
.
getSQL
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/condition/Comparison.java
浏览文件 @
f70ff5e2
...
...
@@ -234,7 +234,7 @@ public class Comparison extends Condition {
if
(
constType
!=
resType
)
{
Column
column
=
((
ExpressionColumn
)
left
).
getColumn
();
right
=
ValueExpression
.
get
(
r
.
convertTo
(
resType
,
MathUtils
.
convertLongToInt
(
left
.
getPrecision
()),
MathUtils
.
convertLongToInt
(
left
.
get
Type
().
get
Precision
()),
session
.
getDatabase
().
getMode
(),
column
,
column
.
getType
().
getExtTypeInfo
()));
}
}
else
if
(
right
instanceof
Parameter
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/condition/Condition.java
浏览文件 @
f70ff5e2
...
...
@@ -8,7 +8,6 @@ package org.h2.expression.condition;
import
org.h2.expression.Expression
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
import
org.h2.value.ValueBoolean
;
/**
* Represents a condition returning a boolean value, or NULL.
...
...
@@ -25,19 +24,4 @@ abstract class Condition extends Expression {
return
Value
.
BOOLEAN
;
}
@Override
public
int
getScale
()
{
return
0
;
}
@Override
public
long
getPrecision
()
{
return
ValueBoolean
.
PRECISION
;
}
@Override
public
int
getDisplaySize
()
{
return
ValueBoolean
.
DISPLAY_SIZE
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/function/Function.java
浏览文件 @
f70ff5e2
差异被折叠。
点击展开。
h2/src/main/org/h2/expression/function/JavaFunction.java
浏览文件 @
f70ff5e2
...
...
@@ -14,7 +14,6 @@ import org.h2.expression.ExpressionVisitor;
import
org.h2.expression.ValueExpression
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.TableFilter
;
import
org.h2.value.DataType
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
import
org.h2.value.ValueArray
;
...
...
@@ -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
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
// TODO always append the schema once FUNCTIONS_IN_SCHEMA is enabled
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/LazyResult.java
浏览文件 @
f70ff5e2
...
...
@@ -145,17 +145,17 @@ public abstract class LazyResult implements ResultInterface {
@Override
public
long
getColumnPrecision
(
int
i
)
{
return
expressions
[
i
].
getPrecision
();
return
expressions
[
i
].
get
Type
().
get
Precision
();
}
@Override
public
int
getColumnScale
(
int
i
)
{
return
expressions
[
i
].
getScale
();
return
expressions
[
i
].
get
Type
().
get
Scale
();
}
@Override
public
int
getDisplaySize
(
int
i
)
{
return
expressions
[
i
].
getDisplaySize
();
return
expressions
[
i
].
get
Type
().
get
DisplaySize
();
}
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/LocalResultImpl.java
浏览文件 @
f70ff5e2
...
...
@@ -529,7 +529,7 @@ public class LocalResultImpl implements LocalResult {
@Override
public
int
getDisplaySize
(
int
i
)
{
return
expressions
[
i
].
getDisplaySize
();
return
expressions
[
i
].
get
Type
().
get
DisplaySize
();
}
@Override
...
...
@@ -544,7 +544,7 @@ public class LocalResultImpl implements LocalResult {
@Override
public
long
getColumnPrecision
(
int
i
)
{
return
expressions
[
i
].
getPrecision
();
return
expressions
[
i
].
get
Type
().
get
Precision
();
}
@Override
...
...
@@ -559,7 +559,7 @@ public class LocalResultImpl implements LocalResult {
@Override
public
int
getColumnScale
(
int
i
)
{
return
expressions
[
i
].
getScale
();
return
expressions
[
i
].
get
Type
().
get
Scale
();
}
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableView.java
浏览文件 @
f70ff5e2
...
...
@@ -40,6 +40,7 @@ import org.h2.util.StringUtils;
import
org.h2.util.Utils
;
import
org.h2.value.DataType
;
import
org.h2.value.ExtTypeInfo
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
/**
...
...
@@ -181,28 +182,29 @@ public class TableView extends Table {
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
Expression
expr
=
expressions
.
get
(
i
);
String
name
=
null
;
int
t
ype
=
Value
.
UNKNOWN
;
int
valueT
ype
=
Value
.
UNKNOWN
;
if
(
columnTemplates
!=
null
&&
columnTemplates
.
length
>
i
)
{
name
=
columnTemplates
[
i
].
getName
();
t
ype
=
columnTemplates
[
i
].
getType
().
getValueType
();
valueT
ype
=
columnTemplates
[
i
].
getType
().
getValueType
();
}
if
(
name
==
null
)
{
name
=
expr
.
getAlias
();
}
name
=
columnNamer
.
getColumnName
(
expr
,
i
,
name
);
if
(
t
ype
==
Value
.
UNKNOWN
)
{
t
ype
=
expr
.
getValueType
();
if
(
valueT
ype
==
Value
.
UNKNOWN
)
{
valueT
ype
=
expr
.
getValueType
();
}
long
precision
=
expr
.
getPrecision
();
int
scale
=
expr
.
getScale
();
int
displaySize
=
expr
.
getDisplaySize
();
TypeInfo
type
=
expr
.
getType
();
long
precision
=
type
.
getPrecision
();
int
scale
=
type
.
getScale
();
int
displaySize
=
type
.
getDisplaySize
();
ExtTypeInfo
extTypeInfo
=
null
;
if
(
DataType
.
isExtInfoType
(
t
ype
))
{
if
(
DataType
.
isExtInfoType
(
valueT
ype
))
{
if
(
expr
instanceof
ExpressionColumn
)
{
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
);
// Fetch check constraint from view column source
ExpressionColumn
fromColumn
=
null
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ExtTypeInfoEnum.java
浏览文件 @
f70ff5e2
...
...
@@ -18,6 +18,8 @@ public final class ExtTypeInfoEnum extends ExtTypeInfo {
private
final
String
[]
enumerators
,
cleaned
;
private
TypeInfo
type
;
/**
* Returns enumerators for the two specified values for a binary operation.
*
...
...
@@ -92,6 +94,21 @@ public final class ExtTypeInfoEnum extends ExtTypeInfo {
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
public
Value
cast
(
Value
value
)
{
switch
(
value
.
getValueType
())
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueEnum.java
浏览文件 @
f70ff5e2
...
...
@@ -19,7 +19,7 @@ public class ValueEnum extends ValueEnumBase {
@Override
public
TypeInfo
getType
()
{
return
new
TypeInfo
(
ENUM
,
PRECISION
,
0
,
DISPLAY_SIZE
,
enumerators
);
return
enumerators
.
getType
(
);
}
public
ExtTypeInfoEnum
getEnumerators
()
{
...
...
This diff is collapsed.
Click to expand it.
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_
>
------------- ------------ ---------- ----------- ---------------- -------------- ------------- ----------- -------------- ----------- --------- ------------------------ ---------------------- ----------------- ----------------------- ------------- ------------------ ------------- ------------------ ------------------ -------------- --------- -------- ----------- ----------- ---------------- ------------- ------- ---------------- -------------- ---------------- ----------
>
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
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
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
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
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
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
10
10
10
10
0
null
null
null
Unicode
OFF
INTEGER
1
FALSE
50
null
null
INTEGER
null
TRUE
>
rows
(
ordered
):
5
DROP
VIEW
V
;
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论