Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a79c5d9f
提交
a79c5d9f
authored
11月 04, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improved error message when casting a value failed.
上级
2a199167
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
33 行增加
和
20 行删除
+33
-20
Insert.java
h2/src/main/org/h2/command/dml/Insert.java
+2
-2
Merge.java
h2/src/main/org/h2/command/dml/Merge.java
+2
-2
Update.java
h2/src/main/org/h2/command/dml/Update.java
+1
-1
ConstraintReferential.java
h2/src/main/org/h2/constraint/ConstraintReferential.java
+3
-4
TableFunction.java
h2/src/main/org/h2/expression/TableFunction.java
+1
-1
IndexCondition.java
h2/src/main/org/h2/index/IndexCondition.java
+1
-2
IndexCursor.java
h2/src/main/org/h2/index/IndexCursor.java
+4
-5
Column.java
h2/src/main/org/h2/table/Column.java
+17
-0
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+1
-1
Table.java
h2/src/main/org/h2/table/Table.java
+1
-2
没有找到文件。
h2/src/main/org/h2/command/dml/Insert.java
浏览文件 @
a79c5d9f
...
@@ -105,7 +105,7 @@ public class Insert extends Prepared {
...
@@ -105,7 +105,7 @@ public class Insert extends Prepared {
// e can be null (DEFAULT)
// e can be null (DEFAULT)
e
=
e
.
optimize
(
session
);
e
=
e
.
optimize
(
session
);
try
{
try
{
Value
v
=
e
.
getValue
(
session
).
convertTo
(
c
.
getType
(
));
Value
v
=
c
.
convert
(
e
.
getValue
(
session
));
newRow
.
setValue
(
index
,
v
);
newRow
.
setValue
(
index
,
v
);
}
catch
(
SQLException
ex
)
{
}
catch
(
SQLException
ex
)
{
throw
setRow
(
ex
,
x
,
getSQL
(
expr
));
throw
setRow
(
ex
,
x
,
getSQL
(
expr
));
...
@@ -136,7 +136,7 @@ public class Insert extends Prepared {
...
@@ -136,7 +136,7 @@ public class Insert extends Prepared {
Column
c
=
columns
[
j
];
Column
c
=
columns
[
j
];
int
index
=
c
.
getColumnId
();
int
index
=
c
.
getColumnId
();
try
{
try
{
Value
v
=
r
[
j
].
convertTo
(
c
.
getType
()
);
Value
v
=
c
.
convert
(
r
[
j
]
);
newRow
.
setValue
(
index
,
v
);
newRow
.
setValue
(
index
,
v
);
}
catch
(
SQLException
ex
)
{
}
catch
(
SQLException
ex
)
{
throw
setRow
(
ex
,
count
,
getSQL
(
r
));
throw
setRow
(
ex
,
count
,
getSQL
(
r
));
...
...
h2/src/main/org/h2/command/dml/Merge.java
浏览文件 @
a79c5d9f
...
@@ -116,7 +116,7 @@ public class Merge extends Prepared {
...
@@ -116,7 +116,7 @@ public class Merge extends Prepared {
if
(
e
!=
null
)
{
if
(
e
!=
null
)
{
// e can be null (DEFAULT)
// e can be null (DEFAULT)
try
{
try
{
Value
v
=
e
.
getValue
(
session
).
convertTo
(
c
.
getType
(
));
Value
v
=
c
.
convert
(
e
.
getValue
(
session
));
newRow
.
setValue
(
index
,
v
);
newRow
.
setValue
(
index
,
v
);
}
catch
(
SQLException
ex
)
{
}
catch
(
SQLException
ex
)
{
throw
setRow
(
ex
,
count
,
getSQL
(
expr
));
throw
setRow
(
ex
,
count
,
getSQL
(
expr
));
...
@@ -140,7 +140,7 @@ public class Merge extends Prepared {
...
@@ -140,7 +140,7 @@ public class Merge extends Prepared {
Column
c
=
columns
[
j
];
Column
c
=
columns
[
j
];
int
index
=
c
.
getColumnId
();
int
index
=
c
.
getColumnId
();
try
{
try
{
Value
v
=
r
[
j
].
convertTo
(
c
.
getType
()
);
Value
v
=
c
.
convert
(
r
[
j
]
);
newRow
.
setValue
(
index
,
v
);
newRow
.
setValue
(
index
,
v
);
}
catch
(
SQLException
ex
)
{
}
catch
(
SQLException
ex
)
{
throw
setRow
(
ex
,
count
,
getSQL
(
r
));
throw
setRow
(
ex
,
count
,
getSQL
(
r
));
...
...
h2/src/main/org/h2/command/dml/Update.java
浏览文件 @
a79c5d9f
...
@@ -99,7 +99,7 @@ public class Update extends Prepared {
...
@@ -99,7 +99,7 @@ public class Update extends Prepared {
newValue
=
table
.
getDefaultValue
(
session
,
column
);
newValue
=
table
.
getDefaultValue
(
session
,
column
);
}
else
{
}
else
{
Column
column
=
table
.
getColumn
(
i
);
Column
column
=
table
.
getColumn
(
i
);
newValue
=
newExpr
.
getValue
(
session
).
convertTo
(
column
.
getType
(
));
newValue
=
column
.
convert
(
newExpr
.
getValue
(
session
));
}
}
newRow
.
setValue
(
i
,
newValue
);
newRow
.
setValue
(
i
,
newValue
);
}
}
...
...
h2/src/main/org/h2/constraint/ConstraintReferential.java
浏览文件 @
a79c5d9f
...
@@ -321,7 +321,7 @@ public class ConstraintReferential extends Constraint {
...
@@ -321,7 +321,7 @@ public class ConstraintReferential extends Constraint {
Value
v
=
newRow
.
getValue
(
idx
);
Value
v
=
newRow
.
getValue
(
idx
);
Column
refCol
=
refColumns
[
i
].
column
;
Column
refCol
=
refColumns
[
i
].
column
;
int
refIdx
=
refCol
.
getColumnId
();
int
refIdx
=
refCol
.
getColumnId
();
check
.
setValue
(
refIdx
,
v
.
convertTo
(
refCol
.
getType
()
));
check
.
setValue
(
refIdx
,
refCol
.
convert
(
v
));
}
}
if
(!
found
(
session
,
refIndex
,
check
,
null
))
{
if
(!
found
(
session
,
refIndex
,
check
,
null
))
{
throw
Message
.
getSQLException
(
ErrorCode
.
REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
,
throw
Message
.
getSQLException
(
ErrorCode
.
REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
,
...
@@ -367,9 +367,8 @@ public class ConstraintReferential extends Constraint {
...
@@ -367,9 +367,8 @@ public class ConstraintReferential extends Constraint {
Column
refCol
=
refColumns
[
i
].
column
;
Column
refCol
=
refColumns
[
i
].
column
;
int
refIdx
=
refCol
.
getColumnId
();
int
refIdx
=
refCol
.
getColumnId
();
Column
col
=
columns
[
i
].
column
;
Column
col
=
columns
[
i
].
column
;
int
idx
=
col
.
getColumnId
();
Value
v
=
col
.
convert
(
oldRow
.
getValue
(
refIdx
));
Value
v
=
oldRow
.
getValue
(
refIdx
).
convertTo
(
col
.
getType
());
check
.
setValue
(
col
.
getColumnId
(),
v
);
check
.
setValue
(
idx
,
v
);
}
}
// exclude the row only for self-referencing constraints
// exclude the row only for self-referencing constraints
Row
excluding
=
(
refTable
==
table
)
?
oldRow
:
null
;
Row
excluding
=
(
refTable
==
table
)
?
oldRow
:
null
;
...
...
h2/src/main/org/h2/expression/TableFunction.java
浏览文件 @
a79c5d9f
...
@@ -110,7 +110,7 @@ public class TableFunction extends Function {
...
@@ -110,7 +110,7 @@ public class TableFunction extends Function {
}
else
{
}
else
{
Column
c
=
columnList
[
j
];
Column
c
=
columnList
[
j
];
v
=
l
[
row
];
v
=
l
[
row
];
v
=
v
.
convertTo
(
c
.
getType
()
);
v
=
c
.
convert
(
v
);
v
=
v
.
convertPrecision
(
c
.
getPrecision
());
v
=
v
.
convertPrecision
(
c
.
getPrecision
());
v
=
v
.
convertScale
(
true
,
c
.
getScale
());
v
=
v
.
convertScale
(
true
,
c
.
getScale
());
}
}
...
...
h2/src/main/org/h2/index/IndexCondition.java
浏览文件 @
a79c5d9f
...
@@ -128,10 +128,9 @@ public class IndexCondition {
...
@@ -128,10 +128,9 @@ public class IndexCondition {
*/
*/
public
Value
[]
getCurrentValueList
(
Session
session
)
throws
SQLException
{
public
Value
[]
getCurrentValueList
(
Session
session
)
throws
SQLException
{
HashSet
<
Value
>
valueSet
=
new
HashSet
<
Value
>();
HashSet
<
Value
>
valueSet
=
new
HashSet
<
Value
>();
int
dataType
=
column
.
getType
();
for
(
Expression
e
:
expressionList
)
{
for
(
Expression
e
:
expressionList
)
{
Value
v
=
e
.
getValue
(
session
);
Value
v
=
e
.
getValue
(
session
);
v
=
v
.
convertTo
(
dataType
);
v
=
column
.
convert
(
v
);
valueSet
.
add
(
v
);
valueSet
.
add
(
v
);
}
}
Value
[]
array
=
new
Value
[
valueSet
.
size
()];
Value
[]
array
=
new
Value
[
valueSet
.
size
()];
...
...
h2/src/main/org/h2/index/IndexCursor.java
浏览文件 @
a79c5d9f
...
@@ -75,8 +75,6 @@ public class IndexCursor implements Cursor {
...
@@ -75,8 +75,6 @@ public class IndexCursor implements Cursor {
break
;
break
;
}
}
Column
column
=
condition
.
getColumn
();
Column
column
=
condition
.
getColumn
();
int
type
=
column
.
getType
();
int
id
=
column
.
getColumnId
();
if
(
condition
.
getCompareType
()
==
Comparison
.
IN_LIST
)
{
if
(
condition
.
getCompareType
()
==
Comparison
.
IN_LIST
)
{
this
.
inColumn
=
column
;
this
.
inColumn
=
column
;
inList
=
condition
.
getCurrentValueList
(
session
);
inList
=
condition
.
getCurrentValueList
(
session
);
...
@@ -87,9 +85,10 @@ public class IndexCursor implements Cursor {
...
@@ -87,9 +85,10 @@ public class IndexCursor implements Cursor {
inResult
=
condition
.
getCurrentResult
(
session
);
inResult
=
condition
.
getCurrentResult
(
session
);
return
;
return
;
}
else
{
}
else
{
Value
v
=
co
ndition
.
getCurrentValue
(
session
).
convertTo
(
type
);
Value
v
=
co
lumn
.
convert
(
condition
.
getCurrentValue
(
session
)
);
boolean
isStart
=
condition
.
isStart
();
boolean
isStart
=
condition
.
isStart
();
boolean
isEnd
=
condition
.
isEnd
();
boolean
isEnd
=
condition
.
isEnd
();
int
id
=
column
.
getColumnId
();
IndexColumn
idxCol
=
indexColumns
[
id
];
IndexColumn
idxCol
=
indexColumns
[
id
];
if
(
idxCol
!=
null
&&
(
idxCol
.
sortType
&
SortOrder
.
DESCENDING
)
!=
0
)
{
if
(
idxCol
!=
null
&&
(
idxCol
.
sortType
&
SortOrder
.
DESCENDING
)
!=
0
)
{
// if the index column is sorted the other way, we swap end and start
// if the index column is sorted the other way, we swap end and start
...
@@ -179,7 +178,7 @@ public class IndexCursor implements Cursor {
...
@@ -179,7 +178,7 @@ public class IndexCursor implements Cursor {
}
else
if
(
inResult
!=
null
)
{
}
else
if
(
inResult
!=
null
)
{
while
(
inResult
.
next
())
{
while
(
inResult
.
next
())
{
Value
v
=
inResult
.
currentRow
()[
0
];
Value
v
=
inResult
.
currentRow
()[
0
];
v
=
v
.
convertTo
(
inColumn
.
getType
()
);
v
=
inColumn
.
convert
(
v
);
if
(
inResultTested
.
add
(
v
))
{
if
(
inResultTested
.
add
(
v
))
{
find
(
v
);
find
(
v
);
break
;
break
;
...
@@ -189,7 +188,7 @@ public class IndexCursor implements Cursor {
...
@@ -189,7 +188,7 @@ public class IndexCursor implements Cursor {
}
}
private
void
find
(
Value
v
)
throws
SQLException
{
private
void
find
(
Value
v
)
throws
SQLException
{
v
=
v
.
convertTo
(
inColumn
.
getType
()
);
v
=
inColumn
.
convert
(
v
);
int
id
=
inColumn
.
getColumnId
();
int
id
=
inColumn
.
getColumnId
();
if
(
start
==
null
)
{
if
(
start
==
null
)
{
start
=
table
.
getTemplateRow
();
start
=
table
.
getTemplateRow
();
...
...
h2/src/main/org/h2/table/Column.java
浏览文件 @
a79c5d9f
...
@@ -137,6 +137,23 @@ public class Column {
...
@@ -137,6 +137,23 @@ public class Column {
return
newColumn
;
return
newColumn
;
}
}
/**
* Convert a value to this column's type.
*
* @param v the value
* @return the value
*/
public
Value
convert
(
Value
v
)
throws
SQLException
{
try
{
return
v
.
convertTo
(
type
);
}
catch
(
SQLException
e
)
{
if
(
e
.
getErrorCode
()
==
ErrorCode
.
DATA_CONVERSION_ERROR_1
)
{
e
=
Message
.
getSQLException
(
ErrorCode
.
DATA_CONVERSION_ERROR_1
,
v
.
getSQL
()
+
" ("
+
getCreateSQL
()
+
")"
);
}
throw
e
;
}
}
boolean
getComputed
()
{
boolean
getComputed
()
{
return
isComputed
;
return
isComputed
;
}
}
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
a79c5d9f
...
@@ -1686,7 +1686,7 @@ public class MetaTable extends Table {
...
@@ -1686,7 +1686,7 @@ public class MetaTable extends Table {
String
s
=
strings
[
i
];
String
s
=
strings
[
i
];
Value
v
=
(
s
==
null
)
?
(
Value
)
ValueNull
.
INSTANCE
:
ValueString
.
get
(
s
);
Value
v
=
(
s
==
null
)
?
(
Value
)
ValueNull
.
INSTANCE
:
ValueString
.
get
(
s
);
Column
col
=
columns
[
i
];
Column
col
=
columns
[
i
];
v
=
v
.
convertTo
(
col
.
getType
()
);
v
=
col
.
convert
(
v
);
values
[
i
]
=
v
;
values
[
i
]
=
v
;
}
}
Row
row
=
new
Row
(
values
,
0
);
Row
row
=
new
Row
(
values
,
0
);
...
...
h2/src/main/org/h2/table/Table.java
浏览文件 @
a79c5d9f
...
@@ -961,8 +961,7 @@ public abstract class Table extends SchemaObjectBase {
...
@@ -961,8 +961,7 @@ public abstract class Table extends SchemaObjectBase {
}
else
{
}
else
{
v
=
defaultExpr
.
getValue
(
session
);
v
=
defaultExpr
.
getValue
(
session
);
}
}
int
type
=
column
.
getType
();
return
column
.
convert
(
v
);
return
v
.
convertTo
(
type
);
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论