Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7e0f68c9
Unverified
提交
7e0f68c9
authored
9月 28, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
9月 28, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1477 from katzyn/ddl
Throw COLUMN_IS_REFERENCED_1 instead of VIEW_IS_INVALID_2 from DROP COLUMN
上级
8f3a8e36
76db4d99
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
28 行增加
和
4 行删除
+28
-4
changelog.html
h2/src/docsrc/html/changelog.html
+2
-0
AlterTableAlterColumn.java
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
+6
-2
TestViewAlterTable.java
h2/src/test/org/h2/test/db/TestViewAlterTable.java
+2
-2
alterTableDropColumn.sql
h2/src/test/org/h2/test/scripts/ddl/alterTableDropColumn.sql
+18
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
7e0f68c9
...
@@ -21,6 +21,8 @@ Change Log
...
@@ -21,6 +21,8 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul>
<ul>
<li>
Issue #1475: Dropping column used by a view produces misleading error message
</li>
<li>
Issue #1473: TestScript needs better detection of sorted result
<li>
Issue #1473: TestScript needs better detection of sorted result
</li>
</li>
<li>
PR #1471: issue 1350: TestCrashAPI: PageStore.freeListPagesPerList
<li>
PR #1471: issue 1350: TestCrashAPI: PageStore.freeListPagesPerList
...
...
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
浏览文件 @
7e0f68c9
...
@@ -297,7 +297,7 @@ public class AlterTableAlterColumn extends CommandWithColumns {
...
@@ -297,7 +297,7 @@ public class AlterTableAlterColumn extends CommandWithColumns {
checkViews
(
table
,
newTable
);
checkViews
(
table
,
newTable
);
}
catch
(
DbException
e
)
{
}
catch
(
DbException
e
)
{
execute
(
"DROP TABLE "
+
newTable
.
getName
(),
true
);
execute
(
"DROP TABLE "
+
newTable
.
getName
(),
true
);
throw
DbException
.
get
(
ErrorCode
.
VIEW_IS_INVALID_2
,
e
,
getSQL
(),
e
.
getMessage
())
;
throw
e
;
}
}
String
tableName
=
table
.
getName
();
String
tableName
=
table
.
getName
();
ArrayList
<
TableView
>
dependentViews
=
new
ArrayList
<>(
table
.
getDependentViews
());
ArrayList
<
TableView
>
dependentViews
=
new
ArrayList
<>(
table
.
getDependentViews
());
...
@@ -547,7 +547,11 @@ public class AlterTableAlterColumn extends CommandWithColumns {
...
@@ -547,7 +547,11 @@ public class AlterTableAlterColumn extends CommandWithColumns {
// check if the query is still valid
// check if the query is still valid
// do not execute, not even with limit 1, because that could
// do not execute, not even with limit 1, because that could
// have side effects or take a very long time
// have side effects or take a very long time
session
.
prepare
(
sql
);
try
{
session
.
prepare
(
sql
);
}
catch
(
DbException
e
)
{
throw
DbException
.
get
(
ErrorCode
.
COLUMN_IS_REFERENCED_1
,
e
,
view
.
getSQL
());
}
checkViewsAreValid
(
view
);
checkViewsAreValid
(
view
);
}
}
}
}
...
...
h2/src/test/org/h2/test/db/TestViewAlterTable.java
浏览文件 @
7e0f68c9
...
@@ -73,7 +73,7 @@ public class TestViewAlterTable extends TestDb {
...
@@ -73,7 +73,7 @@ public class TestViewAlterTable extends TestDb {
stat
.
execute
(
"create table test(id identity, name varchar) "
+
stat
.
execute
(
"create table test(id identity, name varchar) "
+
"as select x, 'Hello'"
);
"as select x, 'Hello'"
);
stat
.
execute
(
"create view test_view as select * from test"
);
stat
.
execute
(
"create view test_view as select * from test"
);
assertThrows
(
ErrorCode
.
VIEW_IS_INVALID_2
,
stat
).
assertThrows
(
ErrorCode
.
COLUMN_IS_REFERENCED_1
,
stat
).
execute
(
"alter table test drop name"
);
execute
(
"alter table test drop name"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test_view"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from test_view"
);
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
...
@@ -83,7 +83,7 @@ public class TestViewAlterTable extends TestDb {
...
@@ -83,7 +83,7 @@ public class TestViewAlterTable extends TestDb {
// nested
// nested
createTestData
();
createTestData
();
// should throw exception because V1 uses column A
// should throw exception because V1 uses column A
assertThrows
(
ErrorCode
.
VIEW_IS_INVALID_2
,
stat
).
assertThrows
(
ErrorCode
.
COLUMN_IS_REFERENCED_1
,
stat
).
execute
(
"alter table test drop column a"
);
execute
(
"alter table test drop column a"
);
stat
.
execute
(
"drop table test cascade"
);
stat
.
execute
(
"drop table test cascade"
);
}
}
...
...
h2/src/test/org/h2/test/scripts/ddl/alterTableDropColumn.sql
浏览文件 @
7e0f68c9
...
@@ -78,3 +78,21 @@ SELECT * FROM TEST;
...
@@ -78,3 +78,21 @@ SELECT * FROM TEST;
DROP
TABLE
TEST
;
DROP
TABLE
TEST
;
>
ok
>
ok
CREATE
TABLE
T1
(
ID
INT
PRIMARY
KEY
,
C
INT
);
>
ok
CREATE
VIEW
V1
AS
SELECT
C
FROM
T1
;
>
ok
ALTER
TABLE
T1
DROP
COLUMN
C
;
>
exception
COLUMN_IS_REFERENCED_1
DROP
VIEW
V1
;
>
ok
ALTER
TABLE
T1
DROP
COLUMN
C
;
>
ok
DROP
TABLE
T1
;
>
ok
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论