Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7205f150
提交
7205f150
authored
16 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Renaming tables that have foreign keys with cascade didn't work correctly.
上级
075899ac
master
noel-pr1
plus33-master
pr/267
stumc-Issue#576
version-1.1.x
version-1.4.198
version-1.4.197
version-1.4.196
version-1.4.195
version-1.4.194
version-1.4.193
version-1.4.192
version-1.4.191
version-1.4.190
version-1.4.188
version-1.4.187
version-1.4.186
version-1.4.185
version-1.4.184
version-1.4.183
version-1.4.182
version-1.4.181
version-1.4.178
version-1.4.177
version-1.3
version-1.2
version-1.1
version-1.0
无相关合并请求
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
62 行增加
和
5 行删除
+62
-5
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
Constraint.java
h2/src/main/org/h2/constraint/Constraint.java
+6
-0
ConstraintCheck.java
h2/src/main/org/h2/constraint/ConstraintCheck.java
+4
-0
ConstraintReferential.java
h2/src/main/org/h2/constraint/ConstraintReferential.java
+23
-4
ConstraintUnique.java
h2/src/main/org/h2/constraint/ConstraintUnique.java
+4
-0
Table.java
h2/src/main/org/h2/table/Table.java
+8
-0
testSimple.in.txt
h2/src/test/org/h2/test/testSimple.in.txt
+15
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
7205f150
...
...
@@ -18,7 +18,8 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
The auto-reconnect feature didn't work when using the auto-server mode. Fixed.
<ul><li>
Renaming tables that have foreign keys with cascade didn't work correctly.
</li><li>
The auto-reconnect feature didn't work when using the auto-server mode. Fixed.
</li><li>
Fulltext search: new method FT_DROP_INDEX.
</li><li>
The optimization to group using an index didn't work in some cases in version 1.1
(see also system property h2.optimizeGroupSorted).
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/constraint/Constraint.java
浏览文件 @
7205f150
...
...
@@ -118,6 +118,12 @@ public abstract class Constraint extends SchemaObjectBase implements Comparable
*/
public
abstract
void
checkExistingData
(
Session
session
)
throws
SQLException
;
/**
* This method is called after a related table has changed
* (the table was renamed, or columns have been renamed).
*/
public
abstract
void
rebuild
()
throws
SQLException
;
/**
* Get the unique index used to enforce this constraint, or null if no index
* is used.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/constraint/ConstraintCheck.java
浏览文件 @
7205f150
...
...
@@ -143,4 +143,8 @@ public class ConstraintCheck extends Constraint {
return
null
;
}
public
void
rebuild
()
throws
SQLException
{
// nothing to do
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/constraint/ConstraintReferential.java
浏览文件 @
7205f150
...
...
@@ -484,15 +484,22 @@ public class ConstraintReferential extends Constraint {
* @param action the action
*/
public
void
setDeleteAction
(
int
action
)
throws
SQLException
{
if
(
action
==
deleteAction
)
{
if
(
action
==
deleteAction
&&
deleteSQL
==
null
)
{
return
;
}
if
(
deleteAction
!=
RESTRICT
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
CONSTRAINT_ALREADY_EXISTS_1
,
"ON DELETE"
);
}
this
.
deleteAction
=
action
;
buildDeleteSQL
();
}
private
void
buildDeleteSQL
()
{
if
(
deleteAction
==
RESTRICT
)
{
return
;
}
StringBuffer
buff
=
new
StringBuffer
();
if
(
a
ction
==
CASCADE
)
{
if
(
deleteA
ction
==
CASCADE
)
{
buff
.
append
(
"DELETE FROM "
);
buff
.
append
(
table
.
getSQL
());
}
else
{
...
...
@@ -520,18 +527,30 @@ public class ConstraintReferential extends Constraint {
* @param action the action
*/
public
void
setUpdateAction
(
int
action
)
throws
SQLException
{
if
(
action
==
updateAction
)
{
if
(
action
==
updateAction
&&
updateSQL
==
null
)
{
return
;
}
if
(
updateAction
!=
RESTRICT
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
CONSTRAINT_ALREADY_EXISTS_1
,
"ON UPDATE"
);
}
this
.
updateAction
=
action
;
buildUpdateSQL
();
}
private
void
buildUpdateSQL
()
{
if
(
updateAction
==
RESTRICT
)
{
return
;
}
StringBuffer
buff
=
new
StringBuffer
();
appendUpdate
(
buff
);
appendWhere
(
buff
);
updateSQL
=
buff
.
toString
();
}
public
void
rebuild
()
throws
SQLException
{
buildUpdateSQL
();
buildDeleteSQL
();
}
private
Prepared
prepare
(
Session
session
,
String
sql
,
int
action
)
throws
SQLException
{
Prepared
command
=
session
.
prepare
(
sql
);
...
...
@@ -555,7 +574,7 @@ public class ConstraintReferential extends Constraint {
}
return
command
;
}
private
void
appendUpdate
(
StringBuffer
buff
)
{
buff
.
append
(
"UPDATE "
);
buff
.
append
(
table
.
getSQL
());
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/constraint/ConstraintUnique.java
浏览文件 @
7205f150
...
...
@@ -148,4 +148,8 @@ public class ConstraintUnique extends Constraint {
return
index
;
}
public
void
rebuild
()
throws
SQLException
{
// nothing to do
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/Table.java
浏览文件 @
7205f150
...
...
@@ -97,6 +97,14 @@ public abstract class Table extends SchemaObjectBase {
initSchemaObjectBase
(
schema
,
id
,
name
,
Trace
.
TABLE
);
this
.
persistent
=
persistent
;
}
public
void
rename
(
String
newName
)
throws
SQLException
{
super
.
rename
(
newName
);
for
(
int
i
=
0
;
constraints
!=
null
&&
i
<
constraints
.
size
();
i
++)
{
Constraint
constraint
=
(
Constraint
)
constraints
.
get
(
i
);
constraint
.
rebuild
();
}
}
/**
* Lock the table for the given session.
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/testSimple.in.txt
浏览文件 @
7205f150
create table master(id int primary key);
create table detail(id int primary key, x bigint, foreign key(x) references master(id) on delete cascade);
alter table detail alter column x bigint;
insert into master values(0);
insert into detail values(0,0);
delete from master;
drop table master, detail;
drop all objects;
create table test(id int, parent int references test(id) on delete cascade);
insert into test values(0, 0);
alter table test rename to test2;
delete from test2;
drop table test2;
SELECT X FROM dual GROUP BY X HAVING X=AVG(X);
> 1;
create view test_view(id,) as select * from dual;
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论