Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
066f681b
提交
066f681b
authored
15 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support for Java 6 DatabaseMetaData.getTables, getColumns, getProcedures, and getProcedureColumns.
上级
54441b1b
无相关合并请求
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
81 行增加
和
37 行删除
+81
-37
changelog.html
h2/src/docsrc/html/changelog.html
+3
-2
JdbcDatabaseMetaData.java
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
+42
-10
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+15
-10
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+21
-15
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
066f681b
...
...
@@ -18,8 +18,9 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
Issue 101: Rollback of a large transaction could fail.
</li><li>
Various improvements in the page store mechanism (still experimental).
<ul><li>
Support for Java 6 DatabaseMetaData.getTables, getColumns, getProcedures, and getProcedureColumns.
</li><li>
Issue 101: Rollback of a large transaction could fail.
</li><li>
Various bugfixes and improvements in the page store mechanism (still experimental).
</li><li>
The functions LENGTH, OCTET_LENGTH, and BIT_LENGTH now return BIGINT.
</li><li>
Data types CLOB and BLOB: the maximum precision was Integer.MAX_VALUE, it is now Long.MAX_VALUE.
</li><li>
Multi-threaded kernel: creating and dropping temporary database objects
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
浏览文件 @
066f681b
...
...
@@ -106,7 +106,12 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* <li>3 TABLE_NAME (String) table name </li>
* <li>4 TABLE_TYPE (String) table type </li>
* <li>5 REMARKS (String) comment </li>
* <li>6 SQL (String) the create table statement or NULL for systems tables
* <li>6 TYPE_CAT (String) always null </li>
* <li>7 TYPE_SCHEM (String) always null </li>
* <li>8 TYPE_NAME (String) always null </li>
* <li>9 SELF_REFERENCING_COL_NAME (String) always null </li>
* <li>10 REF_GENERATION (String) always null </li>
* <li>11 SQL (String) the create table statement or NULL for systems tables
* </li>
* </ul>
*
...
...
@@ -143,6 +148,11 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"TABLE_NAME, "
+
"TABLE_TYPE, "
+
"REMARKS, "
+
"TYPE_NAME TYPE_CAT, "
+
"TYPE_NAME TYPE_SCHEM, "
+
"TYPE_NAME, "
+
"TYPE_NAME SELF_REFERENCING_COL_NAME, "
+
"TYPE_NAME REF_GENERATION, "
+
"SQL "
+
"FROM INFORMATION_SCHEMA.TABLES "
+
"WHERE TABLE_CATALOG LIKE ? "
...
...
@@ -177,8 +187,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* <li>8 BUFFER_LENGTH (int) unused </li>
* <li>9 DECIMAL_DIGITS (int) scale (0 for INTEGER and VARCHAR) </li>
* <li>10 NUM_PREC_RADIX (int) radix (always 10) </li>
* <li>11 NULLABLE (int) nullable or not. columnNoNulls or columnNullable
* </li>
* <li>11 NULLABLE (int) columnNoNulls or columnNullable</li>
* <li>12 REMARKS (String) comment (always empty) </li>
* <li>13 COLUMN_DEF (String) default value </li>
* <li>14 SQL_DATA_TYPE (int) unused </li>
...
...
@@ -186,6 +195,11 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* <li>16 CHAR_OCTET_LENGTH (int) unused </li>
* <li>17 ORDINAL_POSITION (int) the column index (1,2,...) </li>
* <li>18 IS_NULLABLE (String) "NO" or "YES" </li>
* <li>19 SCOPE_CATLOG (String) always null </li>
* <li>20 SCOPE_SCHEMA (String) always null </li>
* <li>21 SCOPE_TABLE (String) always null </li>
* <li>22 SOURCE_DATA_TYPE (short) null </li>
* <li>23 IS_AUTOINCREMENT (String) "NO" or "YES" </li>
* </ul>
*
* @param catalogPattern null (to get all objects) or the catalog name
...
...
@@ -227,7 +241,12 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"ZERO() SQL_DATETIME_SUB, "
+
"CHARACTER_OCTET_LENGTH CHAR_OCTET_LENGTH, "
+
"ORDINAL_POSITION, "
+
"IS_NULLABLE IS_NULLABLE "
+
"IS_NULLABLE IS_NULLABLE, "
+
"CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_CATLOG, "
+
"CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_SCHEMA, "
+
"CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_TABLE, "
+
"SOURCE_DATA_TYPE, "
+
"CASE WHEN SEQUENCE_NAME IS NULL THEN 'NO' ELSE 'YES' END IS_AUTOINCREMENT "
+
"FROM INFORMATION_SCHEMA.COLUMNS "
+
"WHERE TABLE_CATALOG LIKE ? "
+
"AND TABLE_SCHEMA LIKE ? "
...
...
@@ -505,6 +524,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* <li>7 REMARKS (String) description </li>
* <li>8 PROCEDURE_TYPE (short) if this procedure returns a result
* (procedureNoResult or procedureReturnsResult) </li>
* <li>9 SPECIFIC_NAME (String) name </li>
* </ul>
*
* @param catalogPattern null or the catalog name
...
...
@@ -531,7 +551,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"ZERO() NUM_OUTPUT_PARAMS, "
+
"ZERO() NUM_RESULT_SETS, "
+
"REMARKS, "
+
"RETURNS_RESULT PROCEDURE_TYPE "
+
"RETURNS_RESULT PROCEDURE_TYPE, "
+
"ALIAS_NAME SPECIFIC_NAME "
+
"FROM INFORMATION_SCHEMA.FUNCTION_ALIASES "
+
"WHERE ALIAS_CATALOG LIKE ? "
+
"AND ALIAS_SCHEMA LIKE ? "
...
...
@@ -566,8 +587,14 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* <li>11 RADIX (int) always 10 </li>
* <li>12 NULLABLE (short) nullable </li>
* <li>13 REMARKS (String) description </li>
* <li>14 NUM_INPUT_PARAMS (int) the parameter count </li>
* <li>15 POS (int) the parameter index </li>
* <li>14 COLUMN_DEF (String) always null </li>
* <li>15 SQL_DATA_TYPE (int) for future use, always 0 </li>
* <li>16 SQL_DATETIME_SUB (int) for future use, always 0 </li>
* <li>17 CHAR_OCTET_LENGTH (int) always null </li>
* <li>18 ORDINAL_POSITION (int) the parameter index
* starting from 1 (0 is the return value) </li>
* <li>19 IS_NULLABLE (String) always "YES" </li>
* <li>20 SPECIFIC_NAME (String) name </li>
* </ul>
*
* @param catalogPattern null or the catalog name
...
...
@@ -603,14 +630,19 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"RADIX, "
+
"NULLABLE, "
+
"REMARKS, "
+
"COLUMN_COUNT NUM_INPUT_PARAMS, "
+
"POS "
+
"COLUMN_DEFAULT COLUMN_DEF, "
+
"0 SQL_DATA_TYPE, "
+
"0 SQL_DATETIME_SUB, "
+
"0 CHAR_OCTET_LENGTH, "
+
"POS ORDINAL_POSITION, "
+
"'YES' IS_NULLABLE, "
+
"ALIAS_NAME SPECIFIC_NAME "
+
"FROM INFORMATION_SCHEMA.FUNCTION_COLUMNS "
+
"WHERE ALIAS_CATALOG LIKE ? "
+
"AND ALIAS_SCHEMA LIKE ? "
+
"AND ALIAS_NAME LIKE ? "
+
"AND COLUMN_NAME LIKE ? "
+
"ORDER BY PROCEDURE_SCHEM, PROCEDURE_NAME,
NUM_INPUT_PARAMS, POS
"
);
+
"ORDER BY PROCEDURE_SCHEM, PROCEDURE_NAME,
ORDINAL_POSITION
"
);
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
2
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
3
,
getPattern
(
procedureNamePattern
));
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
066f681b
...
...
@@ -71,10 +71,6 @@ public class MetaTable extends Table {
*/
public
static
final
long
ROW_COUNT_APPROXIMATION
=
1000
;
// TODO INFORMATION_SCHEMA.tables: select table_name
// from INFORMATION_SCHEMA.tables where TABLE_TYPE = 'BASE TABLE'
// (currently 'TABLE'; like HSQLDB)
private
static
final
int
TABLES
=
0
;
private
static
final
int
COLUMNS
=
1
;
private
static
final
int
INDEXES
=
2
;
...
...
@@ -135,7 +131,8 @@ public class MetaTable extends Table {
"SQL"
,
"REMARKS"
,
"LAST_MODIFICATION BIGINT"
,
"ID INT"
"ID INT"
,
"TYPE_NAME"
});
indexColumnName
=
"TABLE_NAME"
;
break
;
...
...
@@ -164,7 +161,8 @@ public class MetaTable extends Table {
"SELECTIVITY INT"
,
"CHECK_CONSTRAINT"
,
"SEQUENCE_NAME"
,
"REMARKS"
"REMARKS"
,
"SOURCE_DATA_TYPE SMALLINT"
});
indexColumnName
=
"TABLE_NAME"
;
break
;
...
...
@@ -315,7 +313,8 @@ public class MetaTable extends Table {
"RADIX SMALLINT"
,
"NULLABLE SMALLINT"
,
"COLUMN_TYPE SMALLINT"
,
"REMARKS"
"REMARKS"
,
"COLUMN_DEFAULT"
});
break
;
case
SCHEMATA:
...
...
@@ -650,7 +649,9 @@ public class MetaTable extends Table {
// LAST_MODIFICATION
""
+
table
.
getMaxDataModificationId
(),
// ID
""
+
table
.
getId
()
""
+
table
.
getId
(),
// TYPE_NAME
null
});
}
break
;
...
...
@@ -710,7 +711,9 @@ public class MetaTable extends Table {
// SEQUENCE_NAME
sequence
==
null
?
null
:
sequence
.
getName
(),
// REMARKS
replaceNullWithEmpty
(
c
.
getComment
())
replaceNullWithEmpty
(
c
.
getComment
()),
// SOURCE_DATA_TYPE
null
});
}
}
...
...
@@ -1141,7 +1144,9 @@ public class MetaTable extends Table {
// COLUMN_TYPE
""
+
DatabaseMetaData
.
procedureColumnIn
,
// REMARKS
""
""
,
// COLUMN_DEFAULT
null
});
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
066f681b
...
...
@@ -302,19 +302,23 @@ public class TestMetaData extends TestBase {
stat
.
execute
(
"CREATE ALIAS PROP FOR \"java.lang.System.getProperty(java.lang.String)\""
);
stat
.
execute
(
"CREATE ALIAS EXIT FOR \"java.lang.System.exit\""
);
rs
=
meta
.
getProcedures
(
null
,
null
,
"EX%"
);
assertResultSetMeta
(
rs
,
8
,
new
String
[]
{
"PROCEDURE_CAT"
,
"PROCEDURE_SCHEM"
,
"PROCEDURE_NAME"
,
"NUM_INPUT_PARAMS"
,
"NUM_OUTPUT_PARAMS"
,
"NUM_RESULT_SETS"
,
"REMARKS"
,
"PROCEDURE_TYPE"
},
new
int
[]
{
assertResultSetMeta
(
rs
,
9
,
new
String
[]
{
"PROCEDURE_CAT"
,
"PROCEDURE_SCHEM"
,
"PROCEDURE_NAME"
,
"NUM_INPUT_PARAMS"
,
"NUM_OUTPUT_PARAMS"
,
"NUM_RESULT_SETS"
,
"REMARKS"
,
"PROCEDURE_TYPE"
,
"SPECIFIC_NAME"
},
new
int
[]
{
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
VARCHAR
,
Types
.
SMALLINT
},
null
,
null
);
Types
.
VARCHAR
,
Types
.
SMALLINT
,
Types
.
VARCHAR
},
null
,
null
);
assertResultSetOrdered
(
rs
,
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"EXIT"
,
"1"
,
"0"
,
"0"
,
""
,
""
+
DatabaseMetaData
.
procedureNoResult
}
,
});
""
+
DatabaseMetaData
.
procedureNoResult
}
});
rs
=
meta
.
getProcedureColumns
(
null
,
null
,
null
,
null
);
assertResultSetMeta
(
rs
,
15
,
assertResultSetMeta
(
rs
,
20
,
new
String
[]
{
"PROCEDURE_CAT"
,
"PROCEDURE_SCHEM"
,
"PROCEDURE_NAME"
,
"COLUMN_NAME"
,
"COLUMN_TYPE"
,
"DATA_TYPE"
,
"TYPE_NAME"
,
"PRECISION"
,
"LENGTH"
,
"SCALE"
,
"RADIX"
,
"NULLABLE"
,
"REMARKS"
,
"NUM_INPUT_PARAMS"
,
"POS"
},
"DATA_TYPE"
,
"TYPE_NAME"
,
"PRECISION"
,
"LENGTH"
,
"SCALE"
,
"RADIX"
,
"NULLABLE"
,
"REMARKS"
,
"COLUMN_DEF"
,
"SQL_DATA_TYPE"
,
"SQL_DATETIME_SUB"
,
"CHAR_OCTET_LENGTH"
,
"ORDINAL_POSITION"
,
"IS_NULLABLE"
,
"SPECIFIC_NAME"
},
new
int
[]
{
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
SMALLINT
,
Types
.
INTEGER
,
Types
.
VARCHAR
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
SMALLINT
,
Types
.
SMALLINT
,
Types
.
SMALLINT
,
Types
.
VARCHAR
,
Types
.
INTEGER
,
Types
.
INTEGE
R
},
null
,
null
);
Types
.
VARCHAR
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
SMALLINT
,
Types
.
SMALLINT
,
Types
.
SMALLINT
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
VARCHAR
,
Types
.
VARCHA
R
},
null
,
null
);
assertResultSetOrdered
(
rs
,
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"EXIT"
,
"P1"
,
""
+
DatabaseMetaData
.
procedureColumnIn
,
""
+
Types
.
INTEGER
,
"INTEGER"
,
"10"
,
"10"
,
"0"
,
"10"
,
""
+
DatabaseMetaData
.
procedureNoNulls
},
...
...
@@ -633,9 +637,10 @@ public class TestMetaData extends TestBase {
trace
(
"getTables"
);
rs
=
meta
.
getTables
(
null
,
Constants
.
SCHEMA_MAIN
,
null
,
new
String
[]
{
"TABLE"
});
assertResultSetMeta
(
rs
,
6
,
new
String
[]
{
"TABLE_CAT"
,
"TABLE_SCHEM"
,
"TABLE_NAME"
,
"TABLE_TYPE"
,
"REMARKS"
,
"SQL"
},
new
int
[]
{
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
},
null
,
null
);
assertResultSetMeta
(
rs
,
11
,
new
String
[]
{
"TABLE_CAT"
,
"TABLE_SCHEM"
,
"TABLE_NAME"
,
"TABLE_TYPE"
,
"REMARKS"
,
"TYPE_CAT"
,
"TYPE_SCHEM"
,
"TYPE_NAME"
,
"SELF_REFERENCING_COL_NAME"
,
"REF_GENERATION"
,
"SQL"
},
new
int
[]
{
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
},
null
,
null
);
if
(
rs
.
next
())
{
fail
(
"Database is not empty after dropping all tables"
);
}
...
...
@@ -645,13 +650,14 @@ public class TestMetaData extends TestBase {
assertResultSetOrdered
(
rs
,
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TEST"
,
"TABLE"
,
""
}
});
trace
(
"getColumns"
);
rs
=
meta
.
getColumns
(
null
,
null
,
"TEST"
,
null
);
assertResultSetMeta
(
rs
,
18
,
new
String
[]
{
"TABLE_CAT"
,
"TABLE_SCHEM"
,
"TABLE_NAME"
,
"COLUMN_NAME"
,
"DATA_TYPE"
,
assertResultSetMeta
(
rs
,
23
,
new
String
[]
{
"TABLE_CAT"
,
"TABLE_SCHEM"
,
"TABLE_NAME"
,
"COLUMN_NAME"
,
"DATA_TYPE"
,
"TYPE_NAME"
,
"COLUMN_SIZE"
,
"BUFFER_LENGTH"
,
"DECIMAL_DIGITS"
,
"NUM_PREC_RADIX"
,
"NULLABLE"
,
"REMARKS"
,
"COLUMN_DEF"
,
"SQL_DATA_TYPE"
,
"SQL_DATETIME_SUB"
,
"CHAR_OCTET_LENGTH"
,
"ORDINAL_POSITION"
,
"IS_NULLABLE"
},
new
int
[]
{
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
"IS_NULLABLE"
,
"SCOPE_CATLOG"
,
"SCOPE_SCHEMA"
,
"SCOPE_TABLE"
,
"SOURCE_DATA_TYPE"
,
"IS_AUTOINCREMENT"
},
new
int
[]
{
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
INTEGER
,
Types
.
VARCHAR
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
VARCHAR
},
null
,
null
);
Types
.
INTEGER
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
INTEGER
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
SMALLINT
,
Types
.
VARCHAR
},
null
,
null
);
assertResultSetOrdered
(
rs
,
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TEST"
,
"ID"
,
""
+
Types
.
INTEGER
,
"INTEGER"
,
"10"
,
"10"
,
"0"
,
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论