Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
68dbdcd5
提交
68dbdcd5
authored
2月 01, 2012
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Some DatabaseMetaData methods didn't work when using ALLOW_LITERALS NONE.
上级
024e80c3
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
146 行增加
和
73 行删除
+146
-73
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
JdbcDatabaseMetaData.java
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
+109
-72
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+35
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
68dbdcd5
...
@@ -18,7 +18,8 @@ Change Log
...
@@ -18,7 +18,8 @@ Change Log
<h1>
Change Log
</h1>
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
Trying to convert a VARCHAR to UUID will now fail if the text contains
<ul><li>
Some DatabaseMetaData methods didn't work when using ALLOW_LITERALS NONE.
</li><li>
Trying to convert a VARCHAR to UUID will now fail if the text contains
a character that is not a hex digit, '-', or not a whitespace.
a character that is not a hex digit, '-', or not a whitespace.
</li><li>
TriggerAdapter: in "before" triggers, values can be changed using the ResultSet.updateX methods.
</li><li>
TriggerAdapter: in "before" triggers, values can be changed using the ResultSet.updateX methods.
</li><li>
Creating a table with column data type NULL now works (even if not very useful).
</li><li>
Creating a table with column data type NULL now works (even if not very useful).
...
...
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
浏览文件 @
68dbdcd5
...
@@ -157,16 +157,19 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
...
@@ -157,16 +157,19 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"TYPE_NAME REF_GENERATION, "
+
"TYPE_NAME REF_GENERATION, "
+
"SQL "
+
"SQL "
+
"FROM INFORMATION_SCHEMA.TABLES "
+
"FROM INFORMATION_SCHEMA.TABLES "
+
"WHERE TABLE_CATALOG LIKE ? ESCAPE
'\\'
"
+
"WHERE TABLE_CATALOG LIKE ? ESCAPE
?
"
+
"AND TABLE_SCHEMA LIKE ? ESCAPE
'\\'
"
+
"AND TABLE_SCHEMA LIKE ? ESCAPE
?
"
+
"AND TABLE_NAME LIKE ? ESCAPE
'\\'
"
+
"AND TABLE_NAME LIKE ? ESCAPE
?
"
+
"AND ("
+
tableType
+
") "
+
"AND ("
+
tableType
+
") "
+
"ORDER BY TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME"
);
+
"ORDER BY TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME"
);
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
2
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
2
,
"\\"
);
prep
.
setString
(
3
,
getPattern
(
tableNamePattern
));
prep
.
setString
(
3
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
4
,
"\\"
);
prep
.
setString
(
5
,
getPattern
(
tableNamePattern
));
prep
.
setString
(
6
,
"\\"
);
for
(
int
i
=
0
;
types
!=
null
&&
i
<
types
.
length
;
i
++)
{
for
(
int
i
=
0
;
types
!=
null
&&
i
<
types
.
length
;
i
++)
{
prep
.
setString
(
4
+
i
,
types
[
i
]);
prep
.
setString
(
7
+
i
,
types
[
i
]);
}
}
return
prep
.
executeQuery
();
return
prep
.
executeQuery
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -251,18 +254,24 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
...
@@ -251,18 +254,24 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_SCHEMA, "
+
"CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_SCHEMA, "
+
"CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_TABLE, "
+
"CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_TABLE, "
+
"SOURCE_DATA_TYPE, "
+
"SOURCE_DATA_TYPE, "
+
"CASE WHEN SEQUENCE_NAME IS NULL THEN
'NO' ELSE 'YES'
END IS_AUTOINCREMENT, "
+
"CASE WHEN SEQUENCE_NAME IS NULL THEN
CAST(? AS VARCHAR) ELSE CAST(? AS VARCHAR)
END IS_AUTOINCREMENT, "
+
"CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_CATLOG "
+
"CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_CATLOG "
+
"FROM INFORMATION_SCHEMA.COLUMNS "
+
"FROM INFORMATION_SCHEMA.COLUMNS "
+
"WHERE TABLE_CATALOG LIKE ? ESCAPE
'\\'
"
+
"WHERE TABLE_CATALOG LIKE ? ESCAPE
?
"
+
"AND TABLE_SCHEMA LIKE ? ESCAPE
'\\'
"
+
"AND TABLE_SCHEMA LIKE ? ESCAPE
?
"
+
"AND TABLE_NAME LIKE ? ESCAPE
'\\'
"
+
"AND TABLE_NAME LIKE ? ESCAPE
?
"
+
"AND COLUMN_NAME LIKE ? ESCAPE
'\\'
"
+
"AND COLUMN_NAME LIKE ? ESCAPE
?
"
+
"ORDER BY TABLE_SCHEM, TABLE_NAME, ORDINAL_POSITION"
);
+
"ORDER BY TABLE_SCHEM, TABLE_NAME, ORDINAL_POSITION"
);
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
1
,
"NO"
);
prep
.
setString
(
2
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
2
,
"YES"
);
prep
.
setString
(
3
,
getPattern
(
tableNamePattern
));
prep
.
setString
(
3
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
4
,
getPattern
(
columnNamePattern
));
prep
.
setString
(
4
,
"\\"
);
prep
.
setString
(
5
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
6
,
"\\"
);
prep
.
setString
(
7
,
getPattern
(
tableNamePattern
));
prep
.
setString
(
8
,
"\\"
);
prep
.
setString
(
9
,
getPattern
(
columnNamePattern
));
prep
.
setString
(
10
,
"\\"
);
return
prep
.
executeQuery
();
return
prep
.
executeQuery
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -334,14 +343,16 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
...
@@ -334,14 +343,16 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"FILTER_CONDITION, "
+
"FILTER_CONDITION, "
+
"SORT_TYPE "
+
"SORT_TYPE "
+
"FROM INFORMATION_SCHEMA.INDEXES "
+
"FROM INFORMATION_SCHEMA.INDEXES "
+
"WHERE TABLE_CATALOG LIKE ? ESCAPE
'\\'
"
+
"WHERE TABLE_CATALOG LIKE ? ESCAPE
?
"
+
"AND TABLE_SCHEMA LIKE ? ESCAPE
'\\'
"
+
"AND TABLE_SCHEMA LIKE ? ESCAPE
?
"
+
"AND ("
+
uniqueCondition
+
") "
+
"AND ("
+
uniqueCondition
+
") "
+
"AND TABLE_NAME = ? "
+
"AND TABLE_NAME = ? "
+
"ORDER BY NON_UNIQUE, TYPE, TABLE_SCHEM, INDEX_NAME, ORDINAL_POSITION"
);
+
"ORDER BY NON_UNIQUE, TYPE, TABLE_SCHEM, INDEX_NAME, ORDINAL_POSITION"
);
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
2
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
2
,
"\\"
);
prep
.
setString
(
3
,
tableName
);
prep
.
setString
(
3
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
4
,
"\\"
);
prep
.
setString
(
5
,
tableName
);
return
prep
.
executeQuery
();
return
prep
.
executeQuery
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -385,14 +396,16 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
...
@@ -385,14 +396,16 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"ORDINAL_POSITION KEY_SEQ, "
+
"ORDINAL_POSITION KEY_SEQ, "
+
"IFNULL(CONSTRAINT_NAME, INDEX_NAME) PK_NAME "
+
"IFNULL(CONSTRAINT_NAME, INDEX_NAME) PK_NAME "
+
"FROM INFORMATION_SCHEMA.INDEXES "
+
"FROM INFORMATION_SCHEMA.INDEXES "
+
"WHERE TABLE_CATALOG LIKE ? ESCAPE
'\\'
"
+
"WHERE TABLE_CATALOG LIKE ? ESCAPE
?
"
+
"AND TABLE_SCHEMA LIKE ? ESCAPE
'\\'
"
+
"AND TABLE_SCHEMA LIKE ? ESCAPE
?
"
+
"AND TABLE_NAME = ? "
+
"AND TABLE_NAME = ? "
+
"AND PRIMARY_KEY = TRUE "
+
"AND PRIMARY_KEY = TRUE "
+
"ORDER BY COLUMN_NAME"
);
+
"ORDER BY COLUMN_NAME"
);
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
2
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
2
,
"\\"
);
prep
.
setString
(
3
,
tableName
);
prep
.
setString
(
3
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
4
,
"\\"
);
prep
.
setString
(
5
,
tableName
);
return
prep
.
executeQuery
();
return
prep
.
executeQuery
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -562,13 +575,16 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
...
@@ -562,13 +575,16 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"RETURNS_RESULT PROCEDURE_TYPE, "
+
"RETURNS_RESULT PROCEDURE_TYPE, "
+
"ALIAS_NAME SPECIFIC_NAME "
+
"ALIAS_NAME SPECIFIC_NAME "
+
"FROM INFORMATION_SCHEMA.FUNCTION_ALIASES "
+
"FROM INFORMATION_SCHEMA.FUNCTION_ALIASES "
+
"WHERE ALIAS_CATALOG LIKE ? ESCAPE
'\\'
"
+
"WHERE ALIAS_CATALOG LIKE ? ESCAPE
?
"
+
"AND ALIAS_SCHEMA LIKE ? ESCAPE
'\\'
"
+
"AND ALIAS_SCHEMA LIKE ? ESCAPE
?
"
+
"AND ALIAS_NAME LIKE ? ESCAPE
'\\'
"
+
"AND ALIAS_NAME LIKE ? ESCAPE
?
"
+
"ORDER BY PROCEDURE_SCHEM, PROCEDURE_NAME, NUM_INPUT_PARAMS"
);
+
"ORDER BY PROCEDURE_SCHEM, PROCEDURE_NAME, NUM_INPUT_PARAMS"
);
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
2
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
2
,
"\\"
);
prep
.
setString
(
3
,
getPattern
(
procedureNamePattern
));
prep
.
setString
(
3
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
4
,
"\\"
);
prep
.
setString
(
5
,
getPattern
(
procedureNamePattern
));
prep
.
setString
(
6
,
"\\"
);
return
prep
.
executeQuery
();
return
prep
.
executeQuery
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -643,22 +659,27 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
...
@@ -643,22 +659,27 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"NULLABLE, "
+
"NULLABLE, "
+
"REMARKS, "
+
"REMARKS, "
+
"COLUMN_DEFAULT COLUMN_DEF, "
+
"COLUMN_DEFAULT COLUMN_DEF, "
+
"
0
SQL_DATA_TYPE, "
+
"
ZERO()
SQL_DATA_TYPE, "
+
"
0
SQL_DATETIME_SUB, "
+
"
ZERO()
SQL_DATETIME_SUB, "
+
"
0
CHAR_OCTET_LENGTH, "
+
"
ZERO()
CHAR_OCTET_LENGTH, "
+
"POS ORDINAL_POSITION, "
+
"POS ORDINAL_POSITION, "
+
"
'YES'
IS_NULLABLE, "
+
"
?
IS_NULLABLE, "
+
"ALIAS_NAME SPECIFIC_NAME "
+
"ALIAS_NAME SPECIFIC_NAME "
+
"FROM INFORMATION_SCHEMA.FUNCTION_COLUMNS "
+
"FROM INFORMATION_SCHEMA.FUNCTION_COLUMNS "
+
"WHERE ALIAS_CATALOG LIKE ? ESCAPE
'\\'
"
+
"WHERE ALIAS_CATALOG LIKE ? ESCAPE
?
"
+
"AND ALIAS_SCHEMA LIKE ? ESCAPE
'\\'
"
+
"AND ALIAS_SCHEMA LIKE ? ESCAPE
?
"
+
"AND ALIAS_NAME LIKE ? ESCAPE
'\\'
"
+
"AND ALIAS_NAME LIKE ? ESCAPE
?
"
+
"AND COLUMN_NAME LIKE ? ESCAPE
'\\'
"
+
"AND COLUMN_NAME LIKE ? ESCAPE
?
"
+
"ORDER BY PROCEDURE_SCHEM, PROCEDURE_NAME, ORDINAL_POSITION"
);
+
"ORDER BY PROCEDURE_SCHEM, PROCEDURE_NAME, ORDINAL_POSITION"
);
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
1
,
"YES"
);
prep
.
setString
(
2
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
2
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
3
,
getPattern
(
procedureNamePattern
));
prep
.
setString
(
3
,
"\\"
);
prep
.
setString
(
4
,
getPattern
(
columnNamePattern
));
prep
.
setString
(
4
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
5
,
"\\"
);
prep
.
setString
(
6
,
getPattern
(
procedureNamePattern
));
prep
.
setString
(
7
,
"\\"
);
prep
.
setString
(
8
,
getPattern
(
columnNamePattern
));
prep
.
setString
(
9
,
"\\"
);
return
prep
.
executeQuery
();
return
prep
.
executeQuery
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -792,15 +813,18 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
...
@@ -792,15 +813,18 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"PRIVILEGE_TYPE PRIVILEGE, "
+
"PRIVILEGE_TYPE PRIVILEGE, "
+
"IS_GRANTABLE "
+
"IS_GRANTABLE "
+
"FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES "
+
"FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES "
+
"WHERE TABLE_CATALOG LIKE ? ESCAPE
'\\'
"
+
"WHERE TABLE_CATALOG LIKE ? ESCAPE
?
"
+
"AND TABLE_SCHEMA LIKE ? ESCAPE
'\\'
"
+
"AND TABLE_SCHEMA LIKE ? ESCAPE
?
"
+
"AND TABLE_NAME = ? "
+
"AND TABLE_NAME = ? "
+
"AND COLUMN_NAME LIKE ? ESCAPE
'\\'
"
+
"AND COLUMN_NAME LIKE ? ESCAPE
?
"
+
"ORDER BY COLUMN_NAME, PRIVILEGE"
);
+
"ORDER BY COLUMN_NAME, PRIVILEGE"
);
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
2
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
2
,
"\\"
);
prep
.
setString
(
3
,
table
);
prep
.
setString
(
3
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
4
,
getPattern
(
columnNamePattern
));
prep
.
setString
(
4
,
"\\"
);
prep
.
setString
(
5
,
table
);
prep
.
setString
(
6
,
getPattern
(
columnNamePattern
));
prep
.
setString
(
7
,
"\\"
);
return
prep
.
executeQuery
();
return
prep
.
executeQuery
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -850,13 +874,16 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
...
@@ -850,13 +874,16 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"PRIVILEGE_TYPE PRIVILEGE, "
+
"PRIVILEGE_TYPE PRIVILEGE, "
+
"IS_GRANTABLE "
+
"IS_GRANTABLE "
+
"FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES "
+
"FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES "
+
"WHERE TABLE_CATALOG LIKE ? ESCAPE
'\\'
"
+
"WHERE TABLE_CATALOG LIKE ? ESCAPE
?
"
+
"AND TABLE_SCHEMA LIKE ? ESCAPE
'\\'
"
+
"AND TABLE_SCHEMA LIKE ? ESCAPE
?
"
+
"AND TABLE_NAME LIKE ? ESCAPE
'\\'
"
+
"AND TABLE_NAME LIKE ? ESCAPE
?
"
+
"ORDER BY TABLE_SCHEM, TABLE_NAME, PRIVILEGE"
);
+
"ORDER BY TABLE_SCHEM, TABLE_NAME, PRIVILEGE"
);
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
2
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
2
,
"\\"
);
prep
.
setString
(
3
,
getPattern
(
tableNamePattern
));
prep
.
setString
(
3
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
4
,
"\\"
);
prep
.
setString
(
5
,
getPattern
(
tableNamePattern
));
prep
.
setString
(
6
,
"\\"
);
return
prep
.
executeQuery
();
return
prep
.
executeQuery
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -912,8 +939,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
...
@@ -912,8 +939,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
" INFORMATION_SCHEMA.COLUMNS C "
+
" INFORMATION_SCHEMA.COLUMNS C "
+
"WHERE C.TABLE_NAME = I.TABLE_NAME "
+
"WHERE C.TABLE_NAME = I.TABLE_NAME "
+
"AND C.COLUMN_NAME = I.COLUMN_NAME "
+
"AND C.COLUMN_NAME = I.COLUMN_NAME "
+
"AND C.TABLE_CATALOG LIKE ? ESCAPE
'\\'
"
+
"AND C.TABLE_CATALOG LIKE ? ESCAPE
?
"
+
"AND C.TABLE_SCHEMA LIKE ? ESCAPE
'\\'
"
+
"AND C.TABLE_SCHEMA LIKE ? ESCAPE
?
"
+
"AND C.TABLE_NAME = ? "
+
"AND C.TABLE_NAME = ? "
+
"AND I.PRIMARY_KEY = TRUE "
+
"AND I.PRIMARY_KEY = TRUE "
+
"ORDER BY SCOPE"
);
+
"ORDER BY SCOPE"
);
...
@@ -922,8 +949,10 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
...
@@ -922,8 +949,10 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
// PSEUDO_COLUMN
// PSEUDO_COLUMN
prep
.
setInt
(
2
,
DatabaseMetaData
.
bestRowNotPseudo
);
prep
.
setInt
(
2
,
DatabaseMetaData
.
bestRowNotPseudo
);
prep
.
setString
(
3
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
3
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
4
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
4
,
"\\"
);
prep
.
setString
(
5
,
tableName
);
prep
.
setString
(
5
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
6
,
"\\"
);
prep
.
setString
(
7
,
tableName
);
return
prep
.
executeQuery
();
return
prep
.
executeQuery
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -1035,13 +1064,15 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
...
@@ -1035,13 +1064,15 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"PK_NAME, "
+
"PK_NAME, "
+
"DEFERRABILITY "
+
"DEFERRABILITY "
+
"FROM INFORMATION_SCHEMA.CROSS_REFERENCES "
+
"FROM INFORMATION_SCHEMA.CROSS_REFERENCES "
+
"WHERE FKTABLE_CATALOG LIKE ? ESCAPE
'\\'
"
+
"WHERE FKTABLE_CATALOG LIKE ? ESCAPE
?
"
+
"AND FKTABLE_SCHEMA LIKE ? ESCAPE
'\\'
"
+
"AND FKTABLE_SCHEMA LIKE ? ESCAPE
?
"
+
"AND FKTABLE_NAME = ? "
+
"AND FKTABLE_NAME = ? "
+
"ORDER BY PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME, FK_NAME, KEY_SEQ"
);
+
"ORDER BY PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME, FK_NAME, KEY_SEQ"
);
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
2
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
2
,
"\\"
);
prep
.
setString
(
3
,
tableName
);
prep
.
setString
(
3
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
4
,
"\\"
);
prep
.
setString
(
5
,
tableName
);
return
prep
.
executeQuery
();
return
prep
.
executeQuery
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -1105,13 +1136,15 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
...
@@ -1105,13 +1136,15 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"PK_NAME, "
+
"PK_NAME, "
+
"DEFERRABILITY "
+
"DEFERRABILITY "
+
"FROM INFORMATION_SCHEMA.CROSS_REFERENCES "
+
"FROM INFORMATION_SCHEMA.CROSS_REFERENCES "
+
"WHERE PKTABLE_CATALOG LIKE ? ESCAPE
'\\'
"
+
"WHERE PKTABLE_CATALOG LIKE ? ESCAPE
?
"
+
"AND PKTABLE_SCHEMA LIKE ? ESCAPE
'\\'
"
+
"AND PKTABLE_SCHEMA LIKE ? ESCAPE
?
"
+
"AND PKTABLE_NAME = ? "
+
"AND PKTABLE_NAME = ? "
+
"ORDER BY FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, FK_NAME, KEY_SEQ"
);
+
"ORDER BY FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, FK_NAME, KEY_SEQ"
);
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
2
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
2
,
"\\"
);
prep
.
setString
(
3
,
tableName
);
prep
.
setString
(
3
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
4
,
"\\"
);
prep
.
setString
(
5
,
tableName
);
return
prep
.
executeQuery
();
return
prep
.
executeQuery
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -1185,19 +1218,23 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
...
@@ -1185,19 +1218,23 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"PK_NAME, "
+
"PK_NAME, "
+
"DEFERRABILITY "
+
"DEFERRABILITY "
+
"FROM INFORMATION_SCHEMA.CROSS_REFERENCES "
+
"FROM INFORMATION_SCHEMA.CROSS_REFERENCES "
+
"WHERE PKTABLE_CATALOG LIKE ? ESCAPE
'\\'
"
+
"WHERE PKTABLE_CATALOG LIKE ? ESCAPE
?
"
+
"AND PKTABLE_SCHEMA LIKE ? ESCAPE
'\\'
"
+
"AND PKTABLE_SCHEMA LIKE ? ESCAPE
?
"
+
"AND PKTABLE_NAME = ? "
+
"AND PKTABLE_NAME = ? "
+
"AND FKTABLE_CATALOG LIKE ? ESCAPE
'\\'
"
+
"AND FKTABLE_CATALOG LIKE ? ESCAPE
?
"
+
"AND FKTABLE_SCHEMA LIKE ? ESCAPE
'\\'
"
+
"AND FKTABLE_SCHEMA LIKE ? ESCAPE
?
"
+
"AND FKTABLE_NAME = ? "
+
"AND FKTABLE_NAME = ? "
+
"ORDER BY FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, FK_NAME, KEY_SEQ"
);
+
"ORDER BY FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, FK_NAME, KEY_SEQ"
);
prep
.
setString
(
1
,
getCatalogPattern
(
primaryCatalogPattern
));
prep
.
setString
(
1
,
getCatalogPattern
(
primaryCatalogPattern
));
prep
.
setString
(
2
,
getSchemaPattern
(
primarySchemaPattern
));
prep
.
setString
(
2
,
"\\"
);
prep
.
setString
(
3
,
primaryTable
);
prep
.
setString
(
3
,
getSchemaPattern
(
primarySchemaPattern
));
prep
.
setString
(
4
,
getCatalogPattern
(
foreignCatalogPattern
));
prep
.
setString
(
4
,
"\\"
);
prep
.
setString
(
5
,
getSchemaPattern
(
foreignSchemaPattern
));
prep
.
setString
(
5
,
primaryTable
);
prep
.
setString
(
6
,
foreignTable
);
prep
.
setString
(
6
,
getCatalogPattern
(
foreignCatalogPattern
));
prep
.
setString
(
7
,
"\\"
);
prep
.
setString
(
8
,
getSchemaPattern
(
foreignSchemaPattern
));
prep
.
setString
(
9
,
"\\"
);
prep
.
setString
(
10
,
foreignTable
);
return
prep
.
executeQuery
();
return
prep
.
executeQuery
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
...
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
68dbdcd5
...
@@ -207,6 +207,8 @@ public class TestMetaData extends TestBase {
...
@@ -207,6 +207,8 @@ public class TestMetaData extends TestBase {
// meta.getSuperTypes()
// meta.getSuperTypes()
// meta.getTypeInfo()
// meta.getTypeInfo()
testAllowLiteralsNone
();
conn
.
close
();
conn
.
close
();
deleteDb
(
"metaData"
);
deleteDb
(
"metaData"
);
...
@@ -894,4 +896,37 @@ public class TestMetaData extends TestBase {
...
@@ -894,4 +896,37 @@ public class TestMetaData extends TestBase {
}
}
private
void
testAllowLiteralsNone
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"metaData"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"SET ALLOW_LITERALS NONE"
);
DatabaseMetaData
meta
=
conn
.
getMetaData
();
// meta.getAttributes(null, null, null, null);
meta
.
getBestRowIdentifier
(
null
,
null
,
null
,
0
,
false
);
meta
.
getCatalogs
();
// meta.getClientInfoProperties();
meta
.
getColumnPrivileges
(
null
,
null
,
null
,
null
);
meta
.
getColumns
(
null
,
null
,
null
,
null
);
meta
.
getCrossReference
(
null
,
null
,
null
,
null
,
null
,
null
);
meta
.
getExportedKeys
(
null
,
null
,
null
);
// meta.getFunctionColumns(null, null, null, null);
// meta.getFunctions(null, null, null);
meta
.
getImportedKeys
(
null
,
null
,
null
);
meta
.
getIndexInfo
(
null
,
null
,
null
,
false
,
false
);
meta
.
getPrimaryKeys
(
null
,
null
,
null
);
meta
.
getProcedureColumns
(
null
,
null
,
null
,
null
);
meta
.
getProcedures
(
null
,
null
,
null
);
meta
.
getSchemas
();
// meta.getSchemas(null, null);
meta
.
getSuperTables
(
null
,
null
,
null
);
// meta.getSuperTypes(null, null, null);
meta
.
getTablePrivileges
(
null
,
null
,
null
);
meta
.
getTables
(
null
,
null
,
null
,
null
);
meta
.
getTableTypes
();
meta
.
getTypeInfo
();
meta
.
getUDTs
(
null
,
null
,
null
,
null
);
meta
.
getVersionColumns
(
null
,
null
,
null
);
conn
.
close
();
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论