Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7efe8087
提交
7efe8087
authored
3月 07, 2012
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
In error messages about referential constraint violation, the values are now included.
上级
86e275b4
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
23 行增加
和
6 行删除
+23
-6
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
ConstraintReferential.java
h2/src/main/org/h2/constraint/ConstraintReferential.java
+21
-5
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
7efe8087
...
...
@@ -18,7 +18,8 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
SCRIPT and RUNSCRIPT: the password can now be set using a prepared statement.
<ul><li>
In error messages about referential constraint violation, the values are now included.
</li><li>
SCRIPT and RUNSCRIPT: the password can now be set using a prepared statement.
Previously, it was required to be a literal in the SQL statement.
</li><li>
MySQL compatibility: SUBSTR with a negative start index now works like MySQL.
</li><li>
When enabling autocommit, the transaction is now committed (as required by the JDBC API).
...
...
h2/src/main/org/h2/constraint/ConstraintReferential.java
浏览文件 @
7efe8087
...
...
@@ -167,9 +167,11 @@ public class ConstraintReferential extends Constraint {
* Get a short description of the constraint. This includes the constraint
* name (if set), and the constraint expression.
*
* @param searchIndex the index, or null
* @param check the row, or null
* @return the description
*/
private
String
getShortDescription
()
{
private
String
getShortDescription
(
Index
searchIndex
,
SearchRow
check
)
{
StatementBuilder
buff
=
new
StatementBuilder
(
getName
());
buff
.
append
(
": "
).
append
(
table
.
getSQL
()).
append
(
" FOREIGN KEY("
);
for
(
IndexColumn
c
:
columns
)
{
...
...
@@ -182,7 +184,21 @@ public class ConstraintReferential extends Constraint {
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
r
.
getSQL
());
}
return
buff
.
append
(
')'
).
toString
();
buff
.
append
(
')'
);
if
(
searchIndex
!=
null
&&
check
!=
null
)
{
buff
.
append
(
" ("
);
buff
.
resetCount
();
Column
[]
cols
=
searchIndex
.
getColumns
();
int
len
=
Math
.
min
(
columns
.
length
,
cols
.
length
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
idx
=
cols
[
i
].
getColumnId
();
Value
c
=
check
.
getValue
(
idx
);
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
c
==
null
?
""
:
c
.
toString
());
}
buff
.
append
(
')'
);
}
return
buff
.
toString
();
}
public
String
getCreateSQLWithoutIndexes
()
{
...
...
@@ -343,7 +359,7 @@ public class ConstraintReferential extends Constraint {
}
if
(!
existsRow
(
session
,
refIndex
,
check
,
null
))
{
throw
DbException
.
get
(
ErrorCode
.
REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
,
getShortDescription
());
getShortDescription
(
refIndex
,
check
));
}
}
...
...
@@ -396,7 +412,7 @@ public class ConstraintReferential extends Constraint {
Row
excluding
=
(
refTable
==
table
)
?
oldRow
:
null
;
if
(
existsRow
(
session
,
index
,
check
,
excluding
))
{
throw
DbException
.
get
(
ErrorCode
.
REFERENTIAL_INTEGRITY_VIOLATED_CHILD_EXISTS_1
,
getShortDescription
());
getShortDescription
(
index
,
check
));
}
}
...
...
@@ -638,7 +654,7 @@ public class ConstraintReferential extends Constraint {
ResultInterface
r
=
session
.
prepare
(
sql
).
query
(
1
);
if
(
r
.
next
())
{
throw
DbException
.
get
(
ErrorCode
.
REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1
,
getShortDescription
());
getShortDescription
(
null
,
null
));
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论