Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e8934d75
提交
e8934d75
authored
3月 19, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use UNION in getTables() only if required
上级
77401651
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
48 行增加
和
40 行删除
+48
-40
JdbcDatabaseMetaData.java
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
+48
-40
没有找到文件。
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
浏览文件 @
e8934d75
...
@@ -144,34 +144,25 @@ public class JdbcDatabaseMetaData extends TraceObject implements
...
@@ -144,34 +144,25 @@ public class JdbcDatabaseMetaData extends TraceObject implements
}
}
checkClosed
();
checkClosed
();
int
typesLength
=
types
!=
null
?
types
.
length
:
0
;
int
typesLength
=
types
!=
null
?
types
.
length
:
0
;
boolean
includeSynonyms
=
types
==
null
||
Arrays
.
asList
(
types
).
contains
(
"SYNONYM"
);
String
tableSelect
=
"SELECT "
// (1024 - 16) is enough for the most cases
+
"TABLE_CATALOG TABLE_CAT, "
StringBuilder
select
=
new
StringBuilder
(
1008
);
+
"TABLE_SCHEMA TABLE_SCHEM, "
if
(
includeSynonyms
)
{
select
.
append
(
"SELECT "
+
"TABLE_CAT, "
+
"TABLE_SCHEM, "
+
"TABLE_NAME, "
+
"TABLE_NAME, "
+
"TABLE_TYPE, "
+
"TABLE_TYPE, "
+
"REMARKS, "
+
"REMARKS, "
+
"TYPE_NAME
TYPE_CAT, "
+
"
TYPE_CAT, "
+
"TYPE_NAME
TYPE_SCHEM, "
+
"
TYPE_SCHEM, "
+
"TYPE_NAME, "
+
"TYPE_NAME, "
+
"TYPE_NAME
SELF_REFERENCING_COL_NAME, "
+
"
SELF_REFERENCING_COL_NAME, "
+
"TYPE_NAME
REF_GENERATION, "
+
"
REF_GENERATION, "
+
"SQL "
+
"SQL "
+
"FROM INFORMATION_SCHEMA.TABLES "
+
"FROM ("
+
"WHERE TABLE_CATALOG LIKE ?1 ESCAPE ?4 "
+
"SELECT "
+
"AND TABLE_SCHEMA LIKE ?2 ESCAPE ?4 "
+
"AND TABLE_NAME LIKE ?3 ESCAPE ?4"
;
if
(
typesLength
>
0
)
{
StatementBuilder
buff
=
new
StatementBuilder
(
tableSelect
).
append
(
" AND TABLE_TYPE IN("
);
for
(
int
i
=
0
;
i
<
typesLength
;
i
++)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
'?'
).
append
(
i
+
5
);
}
tableSelect
=
buff
.
append
(
')'
).
toString
();
}
boolean
includeSynonyms
=
types
==
null
||
Arrays
.
asList
(
types
).
contains
(
"SYNONYM"
);
String
synonymSelect
=
"SELECT "
+
"SYNONYM_CATALOG TABLE_CAT, "
+
"SYNONYM_CATALOG TABLE_CAT, "
+
"SYNONYM_SCHEMA TABLE_SCHEM, "
+
"SYNONYM_SCHEMA TABLE_SCHEM, "
+
"SYNONYM_NAME as TABLE_NAME, "
+
"SYNONYM_NAME as TABLE_NAME, "
...
@@ -187,22 +178,39 @@ public class JdbcDatabaseMetaData extends TraceObject implements
...
@@ -187,22 +178,39 @@ public class JdbcDatabaseMetaData extends TraceObject implements
+
"WHERE SYNONYM_CATALOG LIKE ?1 ESCAPE ?4 "
+
"WHERE SYNONYM_CATALOG LIKE ?1 ESCAPE ?4 "
+
"AND SYNONYM_SCHEMA LIKE ?2 ESCAPE ?4 "
+
"AND SYNONYM_SCHEMA LIKE ?2 ESCAPE ?4 "
+
"AND SYNONYM_NAME LIKE ?3 ESCAPE ?4 "
+
"AND SYNONYM_NAME LIKE ?3 ESCAPE ?4 "
+
"AND ("
+
includeSynonyms
+
") "
;
+
"UNION "
)
;
}
PreparedStatement
prep
=
conn
.
prepareAutoCloseStatement
(
"SELECT "
select
.
append
(
"SELECT "
+
"TABLE_CAT, "
+
"TABLE_CAT
ALOG TABLE_CAT
, "
+
"TABLE_SCHEM, "
+
"TABLE_SCHEM
A TABLE_SCHEM
, "
+
"TABLE_NAME, "
+
"TABLE_NAME, "
+
"TABLE_TYPE, "
+
"TABLE_TYPE, "
+
"REMARKS, "
+
"REMARKS, "
+
"TYPE_CAT, "
+
"TYPE_
NAME TYPE_
CAT, "
+
"TYPE_SCHEM, "
+
"TYPE_
NAME TYPE_
SCHEM, "
+
"TYPE_NAME, "
+
"TYPE_NAME, "
+
"SELF_REFERENCING_COL_NAME, "
+
"
TYPE_NAME
SELF_REFERENCING_COL_NAME, "
+
"REF_GENERATION, "
+
"
TYPE_NAME
REF_GENERATION, "
+
"SQL "
+
"SQL "
+
"FROM ("
+
synonymSelect
+
" UNION "
+
tableSelect
+
") "
+
"FROM INFORMATION_SCHEMA.TABLES "
+
"ORDER BY TABLE_TYPE, TABLE_SCHEM, TABLE_NAME"
);
+
"WHERE TABLE_CATALOG LIKE ?1 ESCAPE ?4 "
+
"AND TABLE_SCHEMA LIKE ?2 ESCAPE ?4 "
+
"AND TABLE_NAME LIKE ?3 ESCAPE ?4"
);
if
(
typesLength
>
0
)
{
select
.
append
(
" AND TABLE_TYPE IN("
);
for
(
int
i
=
0
;
i
<
typesLength
;
i
++)
{
if
(
i
>
0
)
{
select
.
append
(
", "
);
}
select
.
append
(
'?'
).
append
(
i
+
5
);
}
select
.
append
(
')'
);
}
if
(
includeSynonyms
)
{
select
.
append
(
')'
);
}
PreparedStatement
prep
=
conn
.
prepareAutoCloseStatement
(
select
.
append
(
" ORDER BY TABLE_TYPE, TABLE_SCHEM, TABLE_NAME"
).
toString
());
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
2
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
2
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
3
,
getPattern
(
tableNamePattern
));
prep
.
setString
(
3
,
getPattern
(
tableNamePattern
));
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论