Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
41d238b1
提交
41d238b1
authored
6 年前
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add TypeInfo and use it in Column
上级
734f8029
隐藏空白字符变更
内嵌
并排
正在显示
27 个修改的文件
包含
230 行增加
和
140 行删除
+230
-140
Parser.java
h2/src/main/org/h2/command/Parser.java
+13
-10
Analyze.java
h2/src/main/org/h2/command/ddl/Analyze.java
+1
-1
CreateTable.java
h2/src/main/org/h2/command/ddl/CreateTable.java
+1
-1
ExpressionColumn.java
h2/src/main/org/h2/expression/ExpressionColumn.java
+6
-6
Parameter.java
h2/src/main/org/h2/expression/Parameter.java
+4
-4
AggregateDataEnvelope.java
...in/org/h2/expression/aggregate/AggregateDataEnvelope.java
+1
-1
CompareLike.java
h2/src/main/org/h2/expression/condition/CompareLike.java
+1
-1
Comparison.java
h2/src/main/org/h2/expression/condition/Comparison.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
-5
TableFunction.java
h2/src/main/org/h2/expression/function/TableFunction.java
+2
-2
BaseIndex.java
h2/src/main/org/h2/index/BaseIndex.java
+1
-1
HashIndex.java
h2/src/main/org/h2/index/HashIndex.java
+1
-1
LinkedCursor.java
h2/src/main/org/h2/index/LinkedCursor.java
+1
-1
LinkedIndex.java
h2/src/main/org/h2/index/LinkedIndex.java
+4
-2
NonUniqueHashIndex.java
h2/src/main/org/h2/index/NonUniqueHashIndex.java
+1
-1
SpatialTreeIndex.java
h2/src/main/org/h2/index/SpatialTreeIndex.java
+1
-1
MVSecondaryIndex.java
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
+3
-1
MVSpatialIndex.java
h2/src/main/org/h2/mvstore/db/MVSpatialIndex.java
+1
-1
MVTable.java
h2/src/main/org/h2/mvstore/db/MVTable.java
+1
-1
Column.java
h2/src/main/org/h2/table/Column.java
+33
-90
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+2
-2
RegularTable.java
h2/src/main/org/h2/table/RegularTable.java
+1
-1
Table.java
h2/src/main/org/h2/table/Table.java
+1
-1
TableBase.java
h2/src/main/org/h2/table/TableBase.java
+1
-1
TableView.java
h2/src/main/org/h2/table/TableView.java
+2
-2
TypeInfo.java
h2/src/main/org/h2/value/TypeInfo.java
+138
-0
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
41d238b1
...
@@ -226,6 +226,7 @@ import org.h2.value.DataType;
...
@@ -226,6 +226,7 @@ import org.h2.value.DataType;
import
org.h2.value.ExtTypeInfo
;
import
org.h2.value.ExtTypeInfo
;
import
org.h2.value.ExtTypeInfoEnum
;
import
org.h2.value.ExtTypeInfoEnum
;
import
org.h2.value.ExtTypeInfoGeometry
;
import
org.h2.value.ExtTypeInfoGeometry
;
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
;
...
@@ -5355,13 +5356,14 @@ public class Parser {
...
@@ -5355,13 +5356,14 @@ public class Parser {
Domain
domain
=
database
.
findDomain
(
original
);
Domain
domain
=
database
.
findDomain
(
original
);
if
(
domain
!=
null
)
{
if
(
domain
!=
null
)
{
templateColumn
=
domain
.
getColumn
();
templateColumn
=
domain
.
getColumn
();
dataType
=
DataType
.
getDataType
(
templateColumn
.
getType
());
TypeInfo
type
=
templateColumn
.
getType
();
dataType
=
DataType
.
getDataType
(
type
.
getValueType
());
comment
=
templateColumn
.
getComment
();
comment
=
templateColumn
.
getComment
();
original
=
forTable
?
domain
.
getSQL
()
:
templateColumn
.
getOriginalSQL
();
original
=
forTable
?
domain
.
getSQL
()
:
templateColumn
.
getOriginalSQL
();
precision
=
t
emplateColumn
.
getPrecision
();
precision
=
t
ype
.
getPrecision
();
displaySize
=
t
emplateColumn
.
getDisplaySize
();
displaySize
=
t
ype
.
getDisplaySize
();
scale
=
t
emplateColumn
.
getScale
();
scale
=
t
ype
.
getScale
();
extTypeInfo
=
t
emplateColumn
.
getExtTypeInfo
();
extTypeInfo
=
t
ype
.
getExtTypeInfo
();
}
else
{
}
else
{
Mode
mode
=
database
.
getMode
();
Mode
mode
=
database
.
getMode
();
dataType
=
DataType
.
getTypeByName
(
original
,
mode
);
dataType
=
DataType
.
getTypeByName
(
original
,
mode
);
...
@@ -5863,10 +5865,11 @@ public class Parser {
...
@@ -5863,10 +5865,11 @@ public class Parser {
.
get
(
ErrorCode
.
COLUMN_COUNT_DOES_NOT_MATCH
);
.
get
(
ErrorCode
.
COLUMN_COUNT_DOES_NOT_MATCH
);
}
}
Column
c
=
columns
.
get
(
i
);
Column
c
=
columns
.
get
(
i
);
type
=
Value
.
getHigherOrder
(
c
.
getType
(),
type
);
TypeInfo
t
=
c
.
getType
();
prec
=
Math
.
max
(
c
.
getPrecision
(),
prec
);
type
=
Value
.
getHigherOrder
(
t
.
getValueType
(),
type
);
scale
=
Math
.
max
(
c
.
getScale
(),
scale
);
prec
=
Math
.
max
(
t
.
getPrecision
(),
prec
);
displaySize
=
Math
.
max
(
c
.
getDisplaySize
(),
displaySize
);
scale
=
Math
.
max
(
t
.
getScale
(),
scale
);
displaySize
=
Math
.
max
(
t
.
getDisplaySize
(),
displaySize
);
column
=
new
Column
(
columnName
,
type
,
prec
,
scale
,
displaySize
);
column
=
new
Column
(
columnName
,
type
,
prec
,
scale
,
displaySize
);
columns
.
set
(
i
,
column
);
columns
.
set
(
i
,
column
);
row
.
add
(
expr
);
row
.
add
(
expr
);
...
@@ -5883,7 +5886,7 @@ public class Parser {
...
@@ -5883,7 +5886,7 @@ public class Parser {
}
}
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
Column
c
=
columns
.
get
(
i
);
Column
c
=
columns
.
get
(
i
);
if
(
c
.
getType
()
==
Value
.
UNKNOWN
)
{
if
(
c
.
getType
()
.
getValueType
()
==
Value
.
UNKNOWN
)
{
c
=
new
Column
(
c
.
getName
(),
Value
.
STRING
,
0
,
0
,
0
);
c
=
new
Column
(
c
.
getName
(),
Value
.
STRING
,
0
,
0
,
0
);
columns
.
set
(
i
,
c
);
columns
.
set
(
i
,
c
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/Analyze.java
浏览文件 @
41d238b1
...
@@ -105,7 +105,7 @@ public class Analyze extends DefineCommand {
...
@@ -105,7 +105,7 @@ public class Analyze extends DefineCommand {
StatementBuilder
buff
=
new
StatementBuilder
(
"SELECT "
);
StatementBuilder
buff
=
new
StatementBuilder
(
"SELECT "
);
for
(
Column
col
:
columns
)
{
for
(
Column
col
:
columns
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
if
(
DataType
.
isLargeObject
(
col
.
getType
()))
{
if
(
DataType
.
isLargeObject
(
col
.
getType
()
.
getValueType
()
))
{
// can not index LOB columns, so calculating
// can not index LOB columns, so calculating
// the selectivity is not required
// the selectivity is not required
buff
.
append
(
"MAX(NULL)"
);
buff
.
append
(
"MAX(NULL)"
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/CreateTable.java
浏览文件 @
41d238b1
...
@@ -202,7 +202,7 @@ public class CreateTable extends CommandWithColumns {
...
@@ -202,7 +202,7 @@ public class CreateTable extends CommandWithColumns {
int
t
=
dt
.
type
;
int
t
=
dt
.
type
;
if
(
DataType
.
isExtInfoType
(
t
))
{
if
(
DataType
.
isExtInfoType
(
t
))
{
if
(
expr
instanceof
ExpressionColumn
)
{
if
(
expr
instanceof
ExpressionColumn
)
{
extTypeInfo
=
((
ExpressionColumn
)
expr
).
getColumn
().
getExtTypeInfo
();
extTypeInfo
=
((
ExpressionColumn
)
expr
).
getColumn
().
get
Type
().
get
ExtTypeInfo
();
}
else
if
(
t
==
Value
.
ENUM
)
{
}
else
if
(
t
==
Value
.
ENUM
)
{
/*
/*
* Only columns of tables may be enumerated.
* Only columns of tables may be enumerated.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
41d238b1
...
@@ -216,7 +216,7 @@ public class ExpressionColumn extends Expression {
...
@@ -216,7 +216,7 @@ public class ExpressionColumn extends Expression {
}
}
}
}
if
(
value
!=
ValueNull
.
INSTANCE
)
{
if
(
value
!=
ValueNull
.
INSTANCE
)
{
ExtTypeInfo
extTypeInfo
=
column
.
getExtTypeInfo
();
ExtTypeInfo
extTypeInfo
=
column
.
get
Type
().
get
ExtTypeInfo
();
if
(
extTypeInfo
!=
null
)
{
if
(
extTypeInfo
!=
null
)
{
return
extTypeInfo
.
cast
(
value
);
return
extTypeInfo
.
cast
(
value
);
}
}
...
@@ -226,7 +226,7 @@ public class ExpressionColumn extends Expression {
...
@@ -226,7 +226,7 @@ public class ExpressionColumn extends Expression {
@Override
@Override
public
int
getType
()
{
public
int
getType
()
{
return
column
==
null
?
Value
.
UNKNOWN
:
column
.
getType
();
return
column
==
null
?
Value
.
UNKNOWN
:
column
.
getType
()
.
getValueType
()
;
}
}
@Override
@Override
...
@@ -239,17 +239,17 @@ public class ExpressionColumn extends Expression {
...
@@ -239,17 +239,17 @@ public class ExpressionColumn extends Expression {
@Override
@Override
public
int
getScale
()
{
public
int
getScale
()
{
return
column
.
getScale
();
return
column
.
get
Type
().
get
Scale
();
}
}
@Override
@Override
public
long
getPrecision
()
{
public
long
getPrecision
()
{
return
column
.
getPrecision
();
return
column
.
get
Type
().
get
Precision
();
}
}
@Override
@Override
public
int
getDisplaySize
()
{
public
int
getDisplaySize
()
{
return
column
.
getDisplaySize
();
return
column
.
get
Type
().
get
DisplaySize
();
}
}
public
String
getOriginalColumnName
()
{
public
String
getOriginalColumnName
()
{
...
@@ -360,7 +360,7 @@ public class ExpressionColumn extends Expression {
...
@@ -360,7 +360,7 @@ public class ExpressionColumn extends Expression {
@Override
@Override
public
void
createIndexConditions
(
Session
session
,
TableFilter
filter
)
{
public
void
createIndexConditions
(
Session
session
,
TableFilter
filter
)
{
TableFilter
tf
=
getTableFilter
();
TableFilter
tf
=
getTableFilter
();
if
(
filter
==
tf
&&
column
.
getType
()
==
Value
.
BOOLEAN
)
{
if
(
filter
==
tf
&&
column
.
getType
()
.
getValueType
()
==
Value
.
BOOLEAN
)
{
IndexCondition
cond
=
IndexCondition
.
get
(
IndexCondition
cond
=
IndexCondition
.
get
(
Comparison
.
EQUAL
,
this
,
ValueExpression
.
get
(
Comparison
.
EQUAL
,
this
,
ValueExpression
.
get
(
ValueBoolean
.
TRUE
));
ValueBoolean
.
TRUE
));
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Parameter.java
浏览文件 @
41d238b1
...
@@ -66,7 +66,7 @@ public class Parameter extends Expression implements ParameterInterface {
...
@@ -66,7 +66,7 @@ public class Parameter extends Expression implements ParameterInterface {
return
value
.
getType
();
return
value
.
getType
();
}
}
if
(
column
!=
null
)
{
if
(
column
!=
null
)
{
return
column
.
getType
();
return
column
.
getType
()
.
getValueType
()
;
}
}
return
Value
.
UNKNOWN
;
return
Value
.
UNKNOWN
;
}
}
...
@@ -114,7 +114,7 @@ public class Parameter extends Expression implements ParameterInterface {
...
@@ -114,7 +114,7 @@ public class Parameter extends Expression implements ParameterInterface {
return
value
.
getScale
();
return
value
.
getScale
();
}
}
if
(
column
!=
null
)
{
if
(
column
!=
null
)
{
return
column
.
getScale
();
return
column
.
get
Type
().
get
Scale
();
}
}
return
0
;
return
0
;
}
}
...
@@ -125,7 +125,7 @@ public class Parameter extends Expression implements ParameterInterface {
...
@@ -125,7 +125,7 @@ public class Parameter extends Expression implements ParameterInterface {
return
value
.
getPrecision
();
return
value
.
getPrecision
();
}
}
if
(
column
!=
null
)
{
if
(
column
!=
null
)
{
return
column
.
getPrecision
();
return
column
.
get
Type
().
get
Precision
();
}
}
return
0
;
return
0
;
}
}
...
@@ -136,7 +136,7 @@ public class Parameter extends Expression implements ParameterInterface {
...
@@ -136,7 +136,7 @@ public class Parameter extends Expression implements ParameterInterface {
return
value
.
getDisplaySize
();
return
value
.
getDisplaySize
();
}
}
if
(
column
!=
null
)
{
if
(
column
!=
null
)
{
return
column
.
getDisplaySize
();
return
column
.
get
Type
().
get
DisplaySize
();
}
}
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/aggregate/AggregateDataEnvelope.java
浏览文件 @
41d238b1
...
@@ -38,7 +38,7 @@ class AggregateDataEnvelope extends AggregateData {
...
@@ -38,7 +38,7 @@ class AggregateDataEnvelope extends AggregateData {
if
(
on
instanceof
ExpressionColumn
)
{
if
(
on
instanceof
ExpressionColumn
)
{
ExpressionColumn
col
=
(
ExpressionColumn
)
on
;
ExpressionColumn
col
=
(
ExpressionColumn
)
on
;
Column
column
=
col
.
getColumn
();
Column
column
=
col
.
getColumn
();
if
(
column
.
getType
()
==
Value
.
GEOMETRY
)
{
if
(
column
.
getType
()
.
getValueType
()
==
Value
.
GEOMETRY
)
{
TableFilter
filter
=
col
.
getTableFilter
();
TableFilter
filter
=
col
.
getTableFilter
();
if
(
filter
!=
null
)
{
if
(
filter
!=
null
)
{
ArrayList
<
Index
>
indexes
=
filter
.
getTable
().
getIndexes
();
ArrayList
<
Index
>
indexes
=
filter
.
getTable
().
getIndexes
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/condition/CompareLike.java
浏览文件 @
41d238b1
...
@@ -206,7 +206,7 @@ public class CompareLike extends Condition {
...
@@ -206,7 +206,7 @@ public class CompareLike extends Condition {
// can't use an index
// can't use an index
return
;
return
;
}
}
if
(!
DataType
.
isStringType
(
l
.
getColumn
().
getType
()))
{
if
(!
DataType
.
isStringType
(
l
.
getColumn
().
getType
()
.
getValueType
()
))
{
// column is not a varchar - can't use the index
// column is not a varchar - can't use the index
return
;
return
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/condition/Comparison.java
浏览文件 @
41d238b1
...
@@ -235,7 +235,7 @@ public class Comparison extends Condition {
...
@@ -235,7 +235,7 @@ public class Comparison extends Condition {
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
.
getPrecision
()),
session
.
getDatabase
().
getMode
(),
column
,
column
.
getExtTypeInfo
()));
session
.
getDatabase
().
getMode
(),
column
,
column
.
get
Type
().
get
ExtTypeInfo
()));
}
}
}
else
if
(
right
instanceof
Parameter
)
{
}
else
if
(
right
instanceof
Parameter
)
{
((
Parameter
)
right
).
setColumn
(
((
Parameter
)
right
).
setColumn
(
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/condition/ConditionInConstantSet.java
浏览文件 @
41d238b1
...
@@ -57,7 +57,7 @@ public class ConditionInConstantSet extends Condition {
...
@@ -57,7 +57,7 @@ public class ConditionInConstantSet extends Condition {
type
=
left
.
getType
();
type
=
left
.
getType
();
Mode
mode
=
database
.
getMode
();
Mode
mode
=
database
.
getMode
();
if
(
type
==
Value
.
ENUM
)
{
if
(
type
==
Value
.
ENUM
)
{
extTypeInfo
=
((
ExpressionColumn
)
left
).
getColumn
().
getExtTypeInfo
();
extTypeInfo
=
((
ExpressionColumn
)
left
).
getColumn
().
get
Type
().
get
ExtTypeInfo
();
for
(
Expression
expression
:
valueList
)
{
for
(
Expression
expression
:
valueList
)
{
add
(
extTypeInfo
.
cast
(
expression
.
getValue
(
session
)));
add
(
extTypeInfo
.
cast
(
expression
.
getValue
(
session
)));
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/function/Function.java
浏览文件 @
41d238b1
...
@@ -62,6 +62,7 @@ import org.h2.util.StringUtils;
...
@@ -62,6 +62,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
;
import
org.h2.value.ValueArray
;
import
org.h2.value.ValueArray
;
import
org.h2.value.ValueBoolean
;
import
org.h2.value.ValueBoolean
;
...
@@ -2293,11 +2294,12 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2293,11 +2294,12 @@ public class Function extends Expression implements FunctionCall {
}
}
public
void
setDataType
(
Column
col
)
{
public
void
setDataType
(
Column
col
)
{
dataType
=
col
.
getType
();
TypeInfo
type
=
col
.
getType
();
precision
=
col
.
getPrecision
();
dataType
=
type
.
getValueType
();
displaySize
=
col
.
getDisplaySize
();
precision
=
type
.
getPrecision
();
scale
=
col
.
getScale
();
displaySize
=
type
.
getDisplaySize
();
extTypeInfo
=
col
.
getExtTypeInfo
();
scale
=
type
.
getScale
();
extTypeInfo
=
type
.
getExtTypeInfo
();
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/function/TableFunction.java
浏览文件 @
41d238b1
...
@@ -125,8 +125,8 @@ public class TableFunction extends Function {
...
@@ -125,8 +125,8 @@ public class TableFunction extends Function {
Column
c
=
columns
[
j
];
Column
c
=
columns
[
j
];
v
=
l
[
row
];
v
=
l
[
row
];
if
(!
unnest
)
{
if
(!
unnest
)
{
v
=
c
.
convert
(
v
).
convertPrecision
(
c
.
getPrecision
(),
false
)
v
=
c
.
convert
(
v
).
convertPrecision
(
c
.
get
Type
().
get
Precision
(),
false
)
.
convertScale
(
true
,
c
.
getScale
());
.
convertScale
(
true
,
c
.
get
Type
().
get
Scale
());
}
}
}
}
r
[
j
]
=
v
;
r
[
j
]
=
v
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/BaseIndex.java
浏览文件 @
41d238b1
...
@@ -73,7 +73,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
...
@@ -73,7 +73,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
*/
*/
protected
static
void
checkIndexColumnTypes
(
IndexColumn
[]
columns
)
{
protected
static
void
checkIndexColumnTypes
(
IndexColumn
[]
columns
)
{
for
(
IndexColumn
c
:
columns
)
{
for
(
IndexColumn
c
:
columns
)
{
if
(
DataType
.
isLargeObject
(
c
.
column
.
getType
()))
{
if
(
DataType
.
isLargeObject
(
c
.
column
.
getType
()
.
getValueType
()
))
{
throw
DbException
.
getUnsupportedException
(
throw
DbException
.
getUnsupportedException
(
"Index on BLOB or CLOB column: "
+
c
.
column
.
getCreateSQL
());
"Index on BLOB or CLOB column: "
+
c
.
column
.
getCreateSQL
());
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/HashIndex.java
浏览文件 @
41d238b1
...
@@ -77,7 +77,7 @@ public class HashIndex extends BaseIndex {
...
@@ -77,7 +77,7 @@ public class HashIndex extends BaseIndex {
* case we need to convert, otherwise the ValueHashMap will not find the
* case we need to convert, otherwise the ValueHashMap will not find the
* result.
* result.
*/
*/
v
=
v
.
convertTo
(
tableData
.
getColumn
(
indexColumn
).
getType
(),
database
.
getMode
());
v
=
v
.
convertTo
(
tableData
.
getColumn
(
indexColumn
).
getType
()
.
getValueType
()
,
database
.
getMode
());
Row
result
;
Row
result
;
Long
pos
=
rows
.
get
(
v
);
Long
pos
=
rows
.
get
(
v
);
if
(
pos
==
null
)
{
if
(
pos
==
null
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/LinkedCursor.java
浏览文件 @
41d238b1
...
@@ -64,7 +64,7 @@ public class LinkedCursor implements Cursor {
...
@@ -64,7 +64,7 @@ public class LinkedCursor implements Cursor {
current
=
tableLink
.
getTemplateRow
();
current
=
tableLink
.
getTemplateRow
();
for
(
int
i
=
0
;
i
<
current
.
getColumnCount
();
i
++)
{
for
(
int
i
=
0
;
i
<
current
.
getColumnCount
();
i
++)
{
Column
col
=
tableLink
.
getColumn
(
i
);
Column
col
=
tableLink
.
getColumn
(
i
);
Value
v
=
DataType
.
readValue
(
session
,
rs
,
i
+
1
,
col
.
getType
());
Value
v
=
DataType
.
readValue
(
session
,
rs
,
i
+
1
,
col
.
getType
()
.
getValueType
()
);
current
.
setValue
(
i
,
v
);
current
.
setValue
(
i
,
v
);
}
}
return
true
;
return
true
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/LinkedIndex.java
浏览文件 @
41d238b1
...
@@ -22,6 +22,7 @@ import org.h2.table.TableFilter;
...
@@ -22,6 +22,7 @@ import org.h2.table.TableFilter;
import
org.h2.table.TableLink
;
import
org.h2.table.TableLink
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.Utils
;
import
org.h2.util.Utils
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueNull
;
...
@@ -131,12 +132,13 @@ public class LinkedIndex extends BaseIndex {
...
@@ -131,12 +132,13 @@ public class LinkedIndex extends BaseIndex {
}
}
private
void
addParameter
(
StatementBuilder
buff
,
Column
col
)
{
private
void
addParameter
(
StatementBuilder
buff
,
Column
col
)
{
if
(
col
.
getType
()
==
Value
.
STRING_FIXED
&&
link
.
isOracle
())
{
TypeInfo
type
=
col
.
getType
();
if
(
type
.
getValueType
()
==
Value
.
STRING_FIXED
&&
link
.
isOracle
())
{
// workaround for Oracle
// workaround for Oracle
// create table test(id int primary key, name char(15));
// create table test(id int primary key, name char(15));
// insert into test values(1, 'Hello')
// insert into test values(1, 'Hello')
// select * from test where name = ? -- where ? = "Hello" > no rows
// select * from test where name = ? -- where ? = "Hello" > no rows
buff
.
append
(
"CAST(? AS CHAR("
).
append
(
col
.
getPrecision
()).
append
(
"))"
);
buff
.
append
(
"CAST(? AS CHAR("
).
append
(
type
.
getPrecision
()).
append
(
"))"
);
}
else
{
}
else
{
buff
.
append
(
'?'
);
buff
.
append
(
'?'
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/NonUniqueHashIndex.java
浏览文件 @
41d238b1
...
@@ -101,7 +101,7 @@ public class NonUniqueHashIndex extends BaseIndex {
...
@@ -101,7 +101,7 @@ public class NonUniqueHashIndex extends BaseIndex {
* case we need to convert, otherwise the ValueHashMap will not find the
* case we need to convert, otherwise the ValueHashMap will not find the
* result.
* result.
*/
*/
v
=
v
.
convertTo
(
tableData
.
getColumn
(
indexColumn
).
getType
(),
database
.
getMode
());
v
=
v
.
convertTo
(
tableData
.
getColumn
(
indexColumn
).
getType
()
.
getValueType
()
,
database
.
getMode
());
ArrayList
<
Long
>
positions
=
rows
.
get
(
v
);
ArrayList
<
Long
>
positions
=
rows
.
get
(
v
);
return
new
NonUniqueHashCursor
(
session
,
tableData
,
positions
);
return
new
NonUniqueHashCursor
(
session
,
tableData
,
positions
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/SpatialTreeIndex.java
浏览文件 @
41d238b1
...
@@ -87,7 +87,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
...
@@ -87,7 +87,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
}
}
this
.
needRebuild
=
create
;
this
.
needRebuild
=
create
;
if
(!
database
.
isStarting
())
{
if
(!
database
.
isStarting
())
{
if
(
columns
[
0
].
column
.
getType
()
!=
Value
.
GEOMETRY
)
{
if
(
columns
[
0
].
column
.
getType
()
.
getValueType
()
!=
Value
.
GEOMETRY
)
{
throw
DbException
.
getUnsupportedException
(
throw
DbException
.
getUnsupportedException
(
"spatial index on non-geometry column, "
+
"spatial index on non-geometry column, "
+
columns
[
0
].
column
.
getCreateSQL
());
columns
[
0
].
column
.
getCreateSQL
());
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
浏览文件 @
41d238b1
...
@@ -30,6 +30,7 @@ import org.h2.table.Column;
...
@@ -30,6 +30,7 @@ import org.h2.table.Column;
import
org.h2.table.IndexColumn
;
import
org.h2.table.IndexColumn
;
import
org.h2.table.TableFilter
;
import
org.h2.table.TableFilter
;
import
org.h2.value.CompareMode
;
import
org.h2.value.CompareMode
;
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.ValueLong
;
import
org.h2.value.ValueLong
;
...
@@ -288,7 +289,8 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
...
@@ -288,7 +289,8 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
int
idx
=
c
.
getColumnId
();
int
idx
=
c
.
getColumnId
();
Value
v
=
r
.
getValue
(
idx
);
Value
v
=
r
.
getValue
(
idx
);
if
(
v
!=
null
)
{
if
(
v
!=
null
)
{
array
[
i
]
=
v
.
convertTo
(
c
.
getType
(),
-
1
,
database
.
getMode
(),
null
,
c
.
getExtTypeInfo
());
TypeInfo
type
=
c
.
getType
();
array
[
i
]
=
v
.
convertTo
(
type
.
getValueType
(),
-
1
,
database
.
getMode
(),
null
,
type
.
getExtTypeInfo
());
}
}
}
}
array
[
keyColumns
-
1
]
=
key
!=
null
?
key
:
ValueLong
.
get
(
r
.
getKey
());
array
[
keyColumns
-
1
]
=
key
!=
null
?
key
:
ValueLong
.
get
(
r
.
getKey
());
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/db/MVSpatialIndex.java
浏览文件 @
41d238b1
...
@@ -88,7 +88,7 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
...
@@ -88,7 +88,7 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
throw
DbException
.
getUnsupportedException
(
throw
DbException
.
getUnsupportedException
(
"Nulls last is not supported"
);
"Nulls last is not supported"
);
}
}
if
(
col
.
column
.
getType
()
!=
Value
.
GEOMETRY
)
{
if
(
col
.
column
.
getType
()
.
getValueType
()
!=
Value
.
GEOMETRY
)
{
throw
DbException
.
getUnsupportedException
(
throw
DbException
.
getUnsupportedException
(
"Spatial index on non-geometry column, "
"Spatial index on non-geometry column, "
+
col
.
column
.
getCreateSQL
());
+
col
.
column
.
getCreateSQL
());
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/db/MVTable.java
浏览文件 @
41d238b1
...
@@ -136,7 +136,7 @@ public class MVTable extends TableBase {
...
@@ -136,7 +136,7 @@ public class MVTable extends TableBase {
this
.
isHidden
=
data
.
isHidden
;
this
.
isHidden
=
data
.
isHidden
;
boolean
b
=
false
;
boolean
b
=
false
;
for
(
Column
col
:
getColumns
())
{
for
(
Column
col
:
getColumns
())
{
if
(
DataType
.
isLargeObject
(
col
.
getType
()))
{
if
(
DataType
.
isLargeObject
(
col
.
getType
()
.
getValueType
()
))
{
b
=
true
;
b
=
true
;
break
;
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/Column.java
浏览文件 @
41d238b1
...
@@ -28,6 +28,7 @@ import org.h2.util.MathUtils;
...
@@ -28,6 +28,7 @@ import org.h2.util.MathUtils;
import
org.h2.util.StringUtils
;
import
org.h2.util.StringUtils
;
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
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueLong
;
import
org.h2.value.ValueLong
;
...
@@ -64,11 +65,7 @@ public class Column {
...
@@ -64,11 +65,7 @@ public class Column {
public
static
final
int
NULLABLE_UNKNOWN
=
public
static
final
int
NULLABLE_UNKNOWN
=
ResultSetMetaData
.
columnNullableUnknown
;
ResultSetMetaData
.
columnNullableUnknown
;
private
final
int
type
;
private
final
TypeInfo
type
;
private
long
precision
;
private
int
scale
;
private
ExtTypeInfo
extTypeInfo
;
private
int
displaySize
;
private
Table
table
;
private
Table
table
;
private
String
name
;
private
String
name
;
private
int
columnId
;
private
int
columnId
;
...
@@ -90,28 +87,28 @@ public class Column {
...
@@ -90,28 +87,28 @@ public class Column {
private
boolean
visible
=
true
;
private
boolean
visible
=
true
;
private
Domain
domain
;
private
Domain
domain
;
public
Column
(
String
name
,
int
t
ype
)
{
public
Column
(
String
name
,
int
valueT
ype
)
{
this
(
name
,
t
ype
,
-
1
,
-
1
,
-
1
,
null
);
this
(
name
,
valueT
ype
,
-
1
,
-
1
,
-
1
,
null
);
}
}
public
Column
(
String
name
,
int
type
,
long
precision
,
int
scale
,
public
Column
(
String
name
,
int
valueType
,
long
precision
,
int
scale
,
int
displaySize
)
{
int
displaySize
)
{
this
(
name
,
valueType
,
precision
,
scale
,
displaySize
,
null
);
this
(
name
,
type
,
precision
,
scale
,
displaySize
,
null
);
}
}
public
Column
(
String
name
,
int
t
ype
,
long
precision
,
int
scale
,
int
displaySize
,
ExtTypeInfo
extTypeInfo
)
{
public
Column
(
String
name
,
int
valueT
ype
,
long
precision
,
int
scale
,
int
displaySize
,
ExtTypeInfo
extTypeInfo
)
{
this
.
name
=
name
;
this
.
name
=
name
;
this
.
type
=
type
;
if
(
precision
==
-
1
&&
scale
==
-
1
&&
displaySize
==
-
1
&&
valueType
!=
Value
.
UNKNOWN
)
{
if
(
precision
==
-
1
&&
scale
==
-
1
&&
displaySize
==
-
1
&&
type
!=
Value
.
UNKNOWN
)
{
DataType
dt
=
DataType
.
getDataType
(
valueType
);
DataType
dt
=
DataType
.
getDataType
(
type
);
precision
=
dt
.
defaultPrecision
;
precision
=
dt
.
defaultPrecision
;
scale
=
dt
.
defaultScale
;
scale
=
dt
.
defaultScale
;
displaySize
=
dt
.
defaultDisplaySize
;
displaySize
=
dt
.
defaultDisplaySize
;
}
}
this
.
precision
=
precision
;
this
.
type
=
new
TypeInfo
(
valueType
,
precision
,
scale
,
displaySize
,
extTypeInfo
);
this
.
scale
=
scale
;
}
this
.
displaySize
=
displaySize
;
this
.
extTypeInfo
=
extTypeInfo
;
public
Column
(
String
name
,
TypeInfo
type
)
{
this
.
name
=
name
;
this
.
type
=
type
;
}
}
@Override
@Override
...
@@ -141,7 +138,7 @@ public class Column {
...
@@ -141,7 +138,7 @@ public class Column {
}
}
public
Column
getClone
()
{
public
Column
getClone
()
{
Column
newColumn
=
new
Column
(
name
,
type
,
precision
,
scale
,
displaySize
,
extTypeInfo
);
Column
newColumn
=
new
Column
(
name
,
type
);
newColumn
.
copy
(
this
);
newColumn
.
copy
(
this
);
return
newColumn
;
return
newColumn
;
}
}
...
@@ -167,7 +164,8 @@ public class Column {
...
@@ -167,7 +164,8 @@ public class Column {
*/
*/
public
Value
convert
(
Value
v
,
Mode
mode
)
{
public
Value
convert
(
Value
v
,
Mode
mode
)
{
try
{
try
{
return
v
.
convertTo
(
type
,
MathUtils
.
convertLongToInt
(
precision
),
mode
,
this
,
extTypeInfo
);
return
v
.
convertTo
(
type
.
getValueType
(),
MathUtils
.
convertLongToInt
(
type
.
getPrecision
()),
mode
,
this
,
type
.
getExtTypeInfo
());
}
catch
(
DbException
e
)
{
}
catch
(
DbException
e
)
{
if
(
e
.
getErrorCode
()
==
ErrorCode
.
DATA_CONVERSION_ERROR_1
)
{
if
(
e
.
getErrorCode
()
==
ErrorCode
.
DATA_CONVERSION_ERROR_1
)
{
String
target
=
(
table
==
null
?
""
:
table
.
getName
()
+
": "
)
+
String
target
=
(
table
==
null
?
""
:
table
.
getName
()
+
": "
)
+
...
@@ -271,30 +269,14 @@ public class Column {
...
@@ -271,30 +269,14 @@ public class Column {
return
name
;
return
name
;
}
}
public
int
getType
()
{
public
TypeInfo
getType
()
{
return
type
;
return
type
;
}
}
public
long
getPrecision
()
{
return
precision
;
}
public
int
getDisplaySize
()
{
return
displaySize
;
}
public
int
getScale
()
{
return
scale
;
}
public
void
setNullable
(
boolean
b
)
{
public
void
setNullable
(
boolean
b
)
{
nullable
=
b
;
nullable
=
b
;
}
}
public
ExtTypeInfo
getExtTypeInfo
()
{
return
extTypeInfo
;
}
public
boolean
getVisible
()
{
public
boolean
getVisible
()
{
return
visible
;
return
visible
;
}
}
...
@@ -350,9 +332,10 @@ public class Column {
...
@@ -350,9 +332,10 @@ public class Column {
}
}
if
(
value
==
ValueNull
.
INSTANCE
&&
!
nullable
)
{
if
(
value
==
ValueNull
.
INSTANCE
&&
!
nullable
)
{
if
(
mode
.
convertInsertNullToZero
)
{
if
(
mode
.
convertInsertNullToZero
)
{
DataType
dt
=
DataType
.
getDataType
(
type
);
int
t
=
type
.
getValueType
();
DataType
dt
=
DataType
.
getDataType
(
t
);
if
(
dt
.
decimal
)
{
if
(
dt
.
decimal
)
{
value
=
ValueInt
.
get
(
0
).
convertTo
(
t
ype
);
value
=
ValueInt
.
get
(
0
).
convertTo
(
t
);
}
else
if
(
dt
.
type
==
Value
.
TIMESTAMP
)
{
}
else
if
(
dt
.
type
==
Value
.
TIMESTAMP
)
{
value
=
session
.
getCurrentCommandStart
().
convertTo
(
Value
.
TIMESTAMP
);
value
=
session
.
getCurrentCommandStart
().
convertTo
(
Value
.
TIMESTAMP
);
}
else
if
(
dt
.
type
==
Value
.
TIMESTAMP_TZ
)
{
}
else
if
(
dt
.
type
==
Value
.
TIMESTAMP_TZ
)
{
...
@@ -362,7 +345,7 @@ public class Column {
...
@@ -362,7 +345,7 @@ public class Column {
}
else
if
(
dt
.
type
==
Value
.
DATE
)
{
}
else
if
(
dt
.
type
==
Value
.
DATE
)
{
value
=
session
.
getCurrentCommandStart
().
convertTo
(
Value
.
DATE
);
value
=
session
.
getCurrentCommandStart
().
convertTo
(
Value
.
DATE
);
}
else
{
}
else
{
value
=
ValueString
.
get
(
""
).
convertTo
(
t
ype
);
value
=
ValueString
.
get
(
""
).
convertTo
(
t
);
}
}
}
else
{
}
else
{
throw
DbException
.
get
(
ErrorCode
.
NULL_NOT_ALLOWED
,
name
);
throw
DbException
.
get
(
ErrorCode
.
NULL_NOT_ALLOWED
,
name
);
...
@@ -382,7 +365,8 @@ public class Column {
...
@@ -382,7 +365,8 @@ public class Column {
checkConstraint
.
getSQL
());
checkConstraint
.
getSQL
());
}
}
}
}
value
=
value
.
convertScale
(
mode
.
convertOnlyToSmallerScale
,
scale
);
value
=
value
.
convertScale
(
mode
.
convertOnlyToSmallerScale
,
type
.
getScale
());
long
precision
=
type
.
getPrecision
();
if
(
precision
>
0
)
{
if
(
precision
>
0
)
{
if
(!
value
.
checkPrecision
(
precision
))
{
if
(!
value
.
checkPrecision
(
precision
))
{
String
s
=
value
.
getTraceSQL
();
String
s
=
value
.
getTraceSQL
();
...
@@ -393,8 +377,8 @@ public class Column {
...
@@ -393,8 +377,8 @@ public class Column {
getCreateSQL
(),
s
+
" ("
+
value
.
getPrecision
()
+
")"
);
getCreateSQL
(),
s
+
" ("
+
value
.
getPrecision
()
+
")"
);
}
}
}
}
if
(
value
!=
ValueNull
.
INSTANCE
&&
DataType
.
isExtInfoType
(
type
)
&&
extTypeInfo
!=
null
)
{
if
(
value
!=
ValueNull
.
INSTANCE
&&
DataType
.
isExtInfoType
(
type
.
getValueType
())
&&
type
.
getExtTypeInfo
()
!=
null
)
{
value
=
extTypeInfo
.
cast
(
value
);
value
=
type
.
getExtTypeInfo
()
.
cast
(
value
);
}
}
updateSequenceIfRequired
(
session
,
value
);
updateSequenceIfRequired
(
session
,
value
);
return
value
;
return
value
;
...
@@ -493,44 +477,7 @@ public class Column {
...
@@ -493,44 +477,7 @@ public class Column {
if
(
originalSQL
!=
null
)
{
if
(
originalSQL
!=
null
)
{
buff
.
append
(
originalSQL
);
buff
.
append
(
originalSQL
);
}
else
{
}
else
{
DataType
dataType
=
DataType
.
getDataType
(
type
);
type
.
getSQL
(
buff
);
if
(
type
==
Value
.
TIMESTAMP_TZ
)
{
buff
.
append
(
"TIMESTAMP"
);
}
else
{
buff
.
append
(
dataType
.
name
);
}
switch
(
type
)
{
case
Value
.
DECIMAL
:
buff
.
append
(
'('
).
append
(
precision
).
append
(
", "
).
append
(
scale
).
append
(
')'
);
break
;
case
Value
.
GEOMETRY
:
if
(
extTypeInfo
==
null
)
{
break
;
}
//$FALL-THROUGH$
case
Value
.
ENUM
:
buff
.
append
(
extTypeInfo
.
getCreateSQL
());
break
;
case
Value
.
BYTES
:
case
Value
.
STRING
:
case
Value
.
STRING_IGNORECASE
:
case
Value
.
STRING_FIXED
:
if
(
precision
<
Integer
.
MAX_VALUE
)
{
buff
.
append
(
'('
).
append
(
precision
).
append
(
')'
);
}
break
;
case
Value
.
TIME
:
case
Value
.
TIMESTAMP
:
case
Value
.
TIMESTAMP_TZ
:
if
(
scale
!=
dataType
.
defaultScale
)
{
buff
.
append
(
'('
).
append
(
scale
).
append
(
')'
);
}
if
(
type
==
Value
.
TIMESTAMP_TZ
)
{
buff
.
append
(
" WITH TIME ZONE"
);
}
break
;
default
:
}
}
}
if
(!
visible
)
{
if
(!
visible
)
{
...
@@ -729,11 +676,11 @@ public class Column {
...
@@ -729,11 +676,11 @@ public class Column {
}
}
int
getPrecisionAsInt
()
{
int
getPrecisionAsInt
()
{
return
MathUtils
.
convertLongToInt
(
precision
);
return
MathUtils
.
convertLongToInt
(
type
.
getPrecision
()
);
}
}
DataType
getDataType
()
{
DataType
getDataType
()
{
return
DataType
.
getDataType
(
type
);
return
DataType
.
getDataType
(
type
.
getValueType
()
);
}
}
/**
/**
...
@@ -803,10 +750,10 @@ public class Column {
...
@@ -803,10 +750,10 @@ public class Column {
if
(
type
!=
newColumn
.
type
)
{
if
(
type
!=
newColumn
.
type
)
{
return
false
;
return
false
;
}
}
if
(
precision
>
newColumn
.
precision
)
{
if
(
type
.
getPrecision
()
>
newColumn
.
type
.
getPrecision
()
)
{
return
false
;
return
false
;
}
}
if
(
scale
!=
newColumn
.
scale
)
{
if
(
type
.
getScale
()
!=
newColumn
.
type
.
getScale
()
)
{
return
false
;
return
false
;
}
}
if
(
nullable
&&
!
newColumn
.
nullable
)
{
if
(
nullable
&&
!
newColumn
.
nullable
)
{
...
@@ -836,7 +783,7 @@ public class Column {
...
@@ -836,7 +783,7 @@ public class Column {
if
(
onUpdateExpression
!=
null
||
newColumn
.
onUpdateExpression
!=
null
)
{
if
(
onUpdateExpression
!=
null
||
newColumn
.
onUpdateExpression
!=
null
)
{
return
false
;
return
false
;
}
}
if
(!
Objects
.
equals
(
extTypeInfo
,
newColumn
.
extTypeInfo
))
{
if
(!
Objects
.
equals
(
type
.
getExtTypeInfo
(),
newColumn
.
type
.
getExtTypeInfo
()
))
{
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
@@ -850,11 +797,7 @@ public class Column {
...
@@ -850,11 +797,7 @@ public class Column {
public
void
copy
(
Column
source
)
{
public
void
copy
(
Column
source
)
{
checkConstraint
=
source
.
checkConstraint
;
checkConstraint
=
source
.
checkConstraint
;
checkConstraintSQL
=
source
.
checkConstraintSQL
;
checkConstraintSQL
=
source
.
checkConstraintSQL
;
displaySize
=
source
.
displaySize
;
name
=
source
.
name
;
name
=
source
.
name
;
precision
=
source
.
precision
;
extTypeInfo
=
source
.
extTypeInfo
;
scale
=
source
.
scale
;
// table is not set
// table is not set
// columnId is not set
// columnId is not set
nullable
=
source
.
nullable
;
nullable
=
source
.
nullable
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
41d238b1
...
@@ -849,7 +849,7 @@ public class MetaTable extends Table {
...
@@ -849,7 +849,7 @@ public class MetaTable extends Table {
Domain
domain
=
c
.
getDomain
();
Domain
domain
=
c
.
getDomain
();
DataType
dataType
=
c
.
getDataType
();
DataType
dataType
=
c
.
getDataType
();
ValueInt
precision
=
ValueInt
.
get
(
c
.
getPrecisionAsInt
());
ValueInt
precision
=
ValueInt
.
get
(
c
.
getPrecisionAsInt
());
ValueInt
scale
=
ValueInt
.
get
(
c
.
getScale
());
ValueInt
scale
=
ValueInt
.
get
(
c
.
get
Type
().
get
Scale
());
Sequence
sequence
=
c
.
getSequence
();
Sequence
sequence
=
c
.
getSequence
();
boolean
hasDateTimePrecision
;
boolean
hasDateTimePrecision
;
int
type
=
dataType
.
type
;
int
type
=
dataType
.
type
;
...
@@ -1792,7 +1792,7 @@ public class MetaTable extends Table {
...
@@ -1792,7 +1792,7 @@ public class MetaTable extends Table {
// PRECISION
// PRECISION
ValueInt
.
get
(
col
.
getPrecisionAsInt
()),
ValueInt
.
get
(
col
.
getPrecisionAsInt
()),
// SCALE
// SCALE
ValueInt
.
get
(
col
.
getScale
()),
ValueInt
.
get
(
col
.
get
Type
().
get
Scale
()),
// TYPE_NAME
// TYPE_NAME
col
.
getDataType
().
name
,
col
.
getDataType
().
name
,
// SELECTIVITY INT
// SELECTIVITY INT
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/RegularTable.java
浏览文件 @
41d238b1
...
@@ -78,7 +78,7 @@ public class RegularTable extends TableBase {
...
@@ -78,7 +78,7 @@ public class RegularTable extends TableBase {
this
.
isHidden
=
data
.
isHidden
;
this
.
isHidden
=
data
.
isHidden
;
boolean
b
=
false
;
boolean
b
=
false
;
for
(
Column
col
:
getColumns
())
{
for
(
Column
col
:
getColumns
())
{
if
(
DataType
.
isLargeObject
(
col
.
getType
()))
{
if
(
DataType
.
isLargeObject
(
col
.
getType
()
.
getValueType
()
))
{
b
=
true
;
b
=
true
;
break
;
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/Table.java
浏览文件 @
41d238b1
...
@@ -454,7 +454,7 @@ public abstract class Table extends SchemaObjectBase {
...
@@ -454,7 +454,7 @@ public abstract class Table extends SchemaObjectBase {
}
}
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
Column
col
=
columns
[
i
];
Column
col
=
columns
[
i
];
int
dataType
=
col
.
getType
();
int
dataType
=
col
.
getType
()
.
getValueType
()
;
if
(
dataType
==
Value
.
UNKNOWN
)
{
if
(
dataType
==
Value
.
UNKNOWN
)
{
throw
DbException
.
get
(
throw
DbException
.
get
(
ErrorCode
.
UNKNOWN_DATA_TYPE_1
,
col
.
getSQL
());
ErrorCode
.
UNKNOWN_DATA_TYPE_1
,
col
.
getSQL
());
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableBase.java
浏览文件 @
41d238b1
...
@@ -51,7 +51,7 @@ public abstract class TableBase extends Table {
...
@@ -51,7 +51,7 @@ public abstract class TableBase extends Table {
if
(
first
.
sortType
!=
SortOrder
.
ASCENDING
)
{
if
(
first
.
sortType
!=
SortOrder
.
ASCENDING
)
{
return
SearchRow
.
ROWID_INDEX
;
return
SearchRow
.
ROWID_INDEX
;
}
}
switch
(
first
.
column
.
getType
())
{
switch
(
first
.
column
.
getType
()
.
getValueType
()
)
{
case
Value
.
BYTE
:
case
Value
.
BYTE
:
case
Value
.
SHORT
:
case
Value
.
SHORT
:
case
Value
.
INT
:
case
Value
.
INT
:
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableView.java
浏览文件 @
41d238b1
...
@@ -184,7 +184,7 @@ public class TableView extends Table {
...
@@ -184,7 +184,7 @@ public class TableView extends Table {
int
type
=
Value
.
UNKNOWN
;
int
type
=
Value
.
UNKNOWN
;
if
(
columnTemplates
!=
null
&&
columnTemplates
.
length
>
i
)
{
if
(
columnTemplates
!=
null
&&
columnTemplates
.
length
>
i
)
{
name
=
columnTemplates
[
i
].
getName
();
name
=
columnTemplates
[
i
].
getName
();
type
=
columnTemplates
[
i
].
getType
();
type
=
columnTemplates
[
i
].
getType
()
.
getValueType
()
;
}
}
if
(
name
==
null
)
{
if
(
name
==
null
)
{
name
=
expr
.
getAlias
();
name
=
expr
.
getAlias
();
...
@@ -199,7 +199,7 @@ public class TableView extends Table {
...
@@ -199,7 +199,7 @@ public class TableView extends Table {
ExtTypeInfo
extTypeInfo
=
null
;
ExtTypeInfo
extTypeInfo
=
null
;
if
(
DataType
.
isExtInfoType
(
type
))
{
if
(
DataType
.
isExtInfoType
(
type
))
{
if
(
expr
instanceof
ExpressionColumn
)
{
if
(
expr
instanceof
ExpressionColumn
)
{
extTypeInfo
=
((
ExpressionColumn
)
expr
).
getColumn
().
getExtTypeInfo
();
extTypeInfo
=
((
ExpressionColumn
)
expr
).
getColumn
().
get
Type
().
get
ExtTypeInfo
();
}
}
}
}
Column
col
=
new
Column
(
name
,
type
,
precision
,
scale
,
displaySize
,
extTypeInfo
);
Column
col
=
new
Column
(
name
,
type
,
precision
,
scale
,
displaySize
,
extTypeInfo
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/TypeInfo.java
0 → 100644
浏览文件 @
41d238b1
/*
* Copyright 2004-2019 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
value
;
/**
* Data type with parameters.
*/
public
class
TypeInfo
{
private
final
int
valueType
;
private
final
long
precision
;
private
final
int
scale
;
private
final
int
displaySize
;
private
final
ExtTypeInfo
extTypeInfo
;
/**
* Creates new instance of data type with parameters.
*
* @param valueType
* the value type
* @param precision
* the precision
* @param scale
* the scale
* @param displaySize
* the display size in characters
* @param extTypeInfo
* the extended type information, or null
*/
public
TypeInfo
(
int
valueType
,
long
precision
,
int
scale
,
int
displaySize
,
ExtTypeInfo
extTypeInfo
)
{
this
.
valueType
=
valueType
;
this
.
precision
=
precision
;
this
.
scale
=
scale
;
this
.
displaySize
=
displaySize
;
this
.
extTypeInfo
=
extTypeInfo
;
}
/**
* Returns the value type.
*
* @return the value type
*/
public
int
getValueType
()
{
return
valueType
;
}
/**
* Returns the precision.
*
* @return the precision
*/
public
long
getPrecision
()
{
return
precision
;
}
/**
* Returns the scale.
*
* @return the scale
*/
public
int
getScale
()
{
return
scale
;
}
/**
* Returns the display size in characters.
*
* @return the display size
*/
public
int
getDisplaySize
()
{
return
displaySize
;
}
/**
* Returns the extended type information, or null.
*
* @return the extended type information, or null
*/
public
ExtTypeInfo
getExtTypeInfo
()
{
return
extTypeInfo
;
}
/**
* Appends SQL representation of this object to the specified string
* builder.
*
* @param builder
* string builder
* @return the specified string builder
*/
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
DataType
dataType
=
DataType
.
getDataType
(
valueType
);
if
(
valueType
==
Value
.
TIMESTAMP_TZ
)
{
builder
.
append
(
"TIMESTAMP"
);
}
else
{
builder
.
append
(
dataType
.
name
);
}
switch
(
valueType
)
{
case
Value
.
DECIMAL
:
builder
.
append
(
'('
).
append
(
precision
).
append
(
", "
).
append
(
scale
).
append
(
')'
);
break
;
case
Value
.
GEOMETRY
:
if
(
extTypeInfo
==
null
)
{
break
;
}
//$FALL-THROUGH$
case
Value
.
ENUM
:
builder
.
append
(
extTypeInfo
.
getCreateSQL
());
break
;
case
Value
.
BYTES
:
case
Value
.
STRING
:
case
Value
.
STRING_IGNORECASE
:
case
Value
.
STRING_FIXED
:
if
(
precision
<
Integer
.
MAX_VALUE
)
{
builder
.
append
(
'('
).
append
(
precision
).
append
(
')'
);
}
break
;
case
Value
.
TIME
:
case
Value
.
TIMESTAMP
:
case
Value
.
TIMESTAMP_TZ
:
if
(
scale
!=
dataType
.
defaultScale
)
{
builder
.
append
(
'('
).
append
(
scale
).
append
(
')'
);
}
if
(
valueType
==
Value
.
TIMESTAMP_TZ
)
{
builder
.
append
(
" WITH TIME ZONE"
);
}
}
return
builder
;
}
}
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论