Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3df87142
提交
3df87142
authored
13 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The SCRIPT statements now supports filtering by schema and table.
上级
fc6c1aa6
master
noel-pr1
plus33-master
pr/267
stumc-Issue#576
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
无相关合并请求
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
54 行增加
和
22 行删除
+54
-22
ScriptCommand.java
h2/src/main/org/h2/command/dml/ScriptCommand.java
+13
-1
TestRunscript.java
h2/src/test/org/h2/test/db/TestRunscript.java
+41
-21
没有找到文件。
h2/src/main/org/h2/command/dml/ScriptCommand.java
浏览文件 @
3df87142
...
@@ -616,7 +616,19 @@ public class ScriptCommand extends ScriptBase {
...
@@ -616,7 +616,19 @@ public class ScriptCommand extends ScriptBase {
}
}
private
boolean
excludeSchema
(
Schema
schema
)
{
private
boolean
excludeSchema
(
Schema
schema
)
{
return
schemaNames
!=
null
&&
!
schemaNames
.
contains
(
schema
.
getName
());
if
(
schemaNames
!=
null
&&
!
schemaNames
.
contains
(
schema
.
getName
()))
{
return
true
;
}
if
(
tables
!=
null
)
{
// if filtering on specific tables, only include those schemas
for
(
Table
table
:
schema
.
getAllTablesAndViews
())
{
if
(
tables
.
contains
(
table
))
{
return
false
;
}
}
return
true
;
}
return
false
;
}
}
private
boolean
excludeTable
(
Table
table
)
{
private
boolean
excludeTable
(
Table
table
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestRunscript.java
浏览文件 @
3df87142
...
@@ -89,13 +89,15 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -89,13 +89,15 @@ public class TestRunscript extends TestBase implements Trigger {
stat
.
execute
(
"script schema include_schema1"
);
stat
.
execute
(
"script schema include_schema1"
);
rs
=
stat
.
getResultSet
();
rs
=
stat
.
getResultSet
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
assertTrue
(
"The schema 'exclude_schema1' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"exclude_schema1"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The schema 'exclude_schema1' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"exclude_schema1"
.
toUpperCase
())
==
-
1
);
}
}
rs
.
close
();
rs
.
close
();
stat
.
execute
(
"create schema include_schema2"
);
stat
.
execute
(
"create schema include_schema2"
);
stat
.
execute
(
"script schema include_schema1, include_schema2"
);
stat
.
execute
(
"script schema include_schema1, include_schema2"
);
rs
=
stat
.
getResultSet
();
rs
=
stat
.
getResultSet
();
assertResultRowCount
(
3
,
rs
);
// User and one row pr schema = 3
// user and one row per schema = 3
assertResultRowCount
(
3
,
rs
);
rs
.
close
();
rs
.
close
();
conn
.
close
();
conn
.
close
();
}
}
...
@@ -116,22 +118,29 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -116,22 +118,29 @@ public class TestRunscript extends TestBase implements Trigger {
stat
.
execute
(
"script table a.test1"
);
stat
.
execute
(
"script table a.test1"
);
rs
=
stat
.
getResultSet
();
rs
=
stat
.
getResultSet
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
assertTrue
(
"The table 'a.test2' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"a.test2"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The table 'a.test2' should not be present in the script"
,
assertTrue
(
"The table 'b.test1' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"b.test1"
.
toUpperCase
())
==
-
1
);
rs
.
getString
(
1
).
indexOf
(
"a.test2"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The table 'b.test2' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"b.test2"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The table 'b.test1' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"b.test1"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The table 'b.test2' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"b.test2"
.
toUpperCase
())
==
-
1
);
}
}
rs
.
close
();
rs
.
close
();
stat
.
execute
(
"set schema b"
);
stat
.
execute
(
"set schema b"
);
stat
.
execute
(
"script table test1"
);
stat
.
execute
(
"script table test1"
);
rs
=
stat
.
getResultSet
();
rs
=
stat
.
getResultSet
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
assertTrue
(
"The table 'a.test1' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"a.test1"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The table 'a.test1' should not be present in the script"
,
assertTrue
(
"The table 'a.test2' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"a.test2"
.
toUpperCase
())
==
-
1
);
rs
.
getString
(
1
).
indexOf
(
"a.test1"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The table 'b.test2' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"b.test2"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The table 'a.test2' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"a.test2"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The table 'b.test2' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"b.test2"
.
toUpperCase
())
==
-
1
);
}
}
stat
.
execute
(
"script table
(a.test1, test2)
"
);
stat
.
execute
(
"script table
a.test1, test2
"
);
rs
=
stat
.
getResultSet
();
rs
=
stat
.
getResultSet
();
assertResultRowCount
(
7
,
rs
);
//User, Schemas 'a' & 'b' and 2 rows pr table = 7
// user, schemas 'a' & 'b' and 2 rows per table = 7
assertResultRowCount
(
7
,
rs
);
rs
.
close
();
rs
.
close
();
conn
.
close
();
conn
.
close
();
}
}
...
@@ -150,7 +159,8 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -150,7 +159,8 @@ public class TestRunscript extends TestBase implements Trigger {
stat
.
execute
(
"script schema b"
);
stat
.
execute
(
"script schema b"
);
rs
=
stat
.
getResultSet
();
rs
=
stat
.
getResultSet
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
assertTrue
(
"The function alias 'int_decode' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"int_decode"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The function alias 'int_decode' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"int_decode"
.
toUpperCase
())
==
-
1
);
}
}
rs
.
close
();
rs
.
close
();
conn
.
close
();
conn
.
close
();
...
@@ -170,7 +180,8 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -170,7 +180,8 @@ public class TestRunscript extends TestBase implements Trigger {
stat
.
execute
(
"script schema b"
);
stat
.
execute
(
"script schema b"
);
rs
=
stat
.
getResultSet
();
rs
=
stat
.
getResultSet
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
assertTrue
(
"The constant 'default_email' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"default_email"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The constant 'default_email' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"default_email"
.
toUpperCase
())
==
-
1
);
}
}
rs
.
close
();
rs
.
close
();
conn
.
close
();
conn
.
close
();
...
@@ -189,7 +200,8 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -189,7 +200,8 @@ public class TestRunscript extends TestBase implements Trigger {
stat
.
execute
(
"script schema b"
);
stat
.
execute
(
"script schema b"
);
rs
=
stat
.
getResultSet
();
rs
=
stat
.
getResultSet
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
assertTrue
(
"The sequence 'seq_id' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"seq_id"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The sequence 'seq_id' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"seq_id"
.
toUpperCase
())
==
-
1
);
}
}
rs
.
close
();
rs
.
close
();
conn
.
close
();
conn
.
close
();
...
@@ -209,14 +221,16 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -209,14 +221,16 @@ public class TestRunscript extends TestBase implements Trigger {
stat
.
execute
(
"script schema b"
);
stat
.
execute
(
"script schema b"
);
rs
=
stat
.
getResultSet
();
rs
=
stat
.
getResultSet
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
assertTrue
(
"The sequence 'unique_constraint' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"unique_constraint"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The sequence 'unique_constraint' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"unique_constraint"
.
toUpperCase
())
==
-
1
);
}
}
rs
.
close
();
rs
.
close
();
stat
.
execute
(
"create table a.test2(x varchar, y int)"
);
stat
.
execute
(
"create table a.test2(x varchar, y int)"
);
stat
.
execute
(
"script table a.test2"
);
stat
.
execute
(
"script table a.test2"
);
rs
=
stat
.
getResultSet
();
rs
=
stat
.
getResultSet
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
assertTrue
(
"The sequence 'unique_constraint' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"unique_constraint"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The sequence 'unique_constraint' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"unique_constraint"
.
toUpperCase
())
==
-
1
);
}
}
rs
.
close
();
rs
.
close
();
conn
.
close
();
conn
.
close
();
...
@@ -232,18 +246,21 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -232,18 +246,21 @@ public class TestRunscript extends TestBase implements Trigger {
stat
.
execute
(
"create schema b"
);
stat
.
execute
(
"create schema b"
);
stat
.
execute
(
"create schema c"
);
stat
.
execute
(
"create schema c"
);
stat
.
execute
(
"create table a.test1(x varchar, y int)"
);
stat
.
execute
(
"create table a.test1(x varchar, y int)"
);
stat
.
execute
(
"create trigger trigger_insert before insert on a.test1 for each row call \"org.h2.test.db.TestRunscript\""
);
stat
.
execute
(
"create trigger trigger_insert before insert on a.test1 "
+
"for each row call \"org.h2.test.db.TestRunscript\""
);
stat
.
execute
(
"script schema b"
);
stat
.
execute
(
"script schema b"
);
rs
=
stat
.
getResultSet
();
rs
=
stat
.
getResultSet
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
assertTrue
(
"The trigger 'trigger_insert' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"trigger_insert"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The trigger 'trigger_insert' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"trigger_insert"
.
toUpperCase
())
==
-
1
);
}
}
rs
.
close
();
rs
.
close
();
stat
.
execute
(
"create table a.test2(x varchar, y int)"
);
stat
.
execute
(
"create table a.test2(x varchar, y int)"
);
stat
.
execute
(
"script table a.test2"
);
stat
.
execute
(
"script table a.test2"
);
rs
=
stat
.
getResultSet
();
rs
=
stat
.
getResultSet
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
assertTrue
(
"The trigger 'trigger_insert' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"trigger_insert"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The trigger 'trigger_insert' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"trigger_insert"
.
toUpperCase
())
==
-
1
);
}
}
rs
.
close
();
rs
.
close
();
conn
.
close
();
conn
.
close
();
...
@@ -267,7 +284,8 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -267,7 +284,8 @@ public class TestRunscript extends TestBase implements Trigger {
stat
.
execute
(
"script schema b"
);
stat
.
execute
(
"script schema b"
);
rs
=
stat
.
getResultSet
();
rs
=
stat
.
getResultSet
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
assertTrue
(
"The grant to 'USER_A1' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"to USER_A1"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The grant to 'USER_A1' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"to USER_A1"
.
toUpperCase
())
==
-
1
);
}
}
rs
.
close
();
rs
.
close
();
stat
.
execute
(
"create user USER_A2 password 'test'"
);
stat
.
execute
(
"create user USER_A2 password 'test'"
);
...
@@ -276,8 +294,10 @@ public class TestRunscript extends TestBase implements Trigger {
...
@@ -276,8 +294,10 @@ public class TestRunscript extends TestBase implements Trigger {
stat
.
execute
(
"script table a.test2"
);
stat
.
execute
(
"script table a.test2"
);
rs
=
stat
.
getResultSet
();
rs
=
stat
.
getResultSet
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
assertTrue
(
"The grant to 'USER_A1' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"to USER_A1"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The grant to 'USER_A1' should not be present in the script"
,
assertTrue
(
"The grant to 'USER_B1' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"to USER_B1"
.
toUpperCase
())
==
-
1
);
rs
.
getString
(
1
).
indexOf
(
"to USER_A1"
.
toUpperCase
())
==
-
1
);
assertTrue
(
"The grant to 'USER_B1' should not be present in the script"
,
rs
.
getString
(
1
).
indexOf
(
"to USER_B1"
.
toUpperCase
())
==
-
1
);
}
}
rs
.
close
();
rs
.
close
();
conn
.
close
();
conn
.
close
();
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论