Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7b7afcc4
提交
7b7afcc4
authored
12月 31, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
DatabaseMetaData.getPrimaryKeys: The column PK_NAME now contains the constraint name.
上级
0717e820
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
41 行增加
和
12 行删除
+41
-12
ViewIndex.java
h2/src/main/org/h2/index/ViewIndex.java
+6
-3
JdbcDatabaseMetaData.java
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
+1
-1
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+15
-4
TestView.java
h2/src/test/org/h2/test/db/TestView.java
+15
-0
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+4
-4
没有找到文件。
h2/src/main/org/h2/index/ViewIndex.java
浏览文件 @
7b7afcc4
...
...
@@ -156,10 +156,13 @@ public class ViewIndex extends BaseIndex {
for
(
int
i
=
0
;
originalParameters
!=
null
&&
i
<
originalParameters
.
size
();
i
++)
{
Parameter
orig
=
(
Parameter
)
originalParameters
.
get
(
i
);
int
idx
=
orig
.
getIndex
();
// the parameter may have been optimized away
if
(
idx
<
paramList
.
size
())
{
Parameter
param
=
(
Parameter
)
paramList
.
get
(
idx
);
Value
value
=
orig
.
getValue
(
session
);
param
.
setValue
(
value
);
}
}
int
len
;
if
(
first
!=
null
)
{
len
=
first
.
getColumnCount
();
...
...
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
浏览文件 @
7b7afcc4
...
...
@@ -358,7 +358,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"TABLE_NAME, "
+
"COLUMN_NAME, "
+
"ORDINAL_POSITION KEY_SEQ, "
+
"I
NDEX_NAME
PK_NAME "
+
"I
FNULL(CONSTRAINT_NAME, INDEX_NAME)
PK_NAME "
+
"FROM INFORMATION_SCHEMA.INDEXES "
+
"WHERE TABLE_CATALOG LIKE ? "
+
"AND TABLE_SCHEMA LIKE ? "
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
7b7afcc4
...
...
@@ -187,7 +187,8 @@ public class MetaTable extends Table {
"REMARKS"
,
"SQL"
,
"ID INT"
,
"SORT_TYPE INT"
"SORT_TYPE INT"
,
"CONSTRAINT_NAME"
});
indexColumnName
=
"TABLE_NAME"
;
break
;
...
...
@@ -726,12 +727,20 @@ public class MetaTable extends Table {
if
(!
checkIndex
(
session
,
tableName
,
indexFrom
,
indexTo
))
{
continue
;
}
ObjectArray
idx
=
table
.
getIndexes
();
for
(
int
j
=
0
;
idx
!=
null
&&
j
<
idx
.
size
();
j
++)
{
Index
index
=
(
Index
)
idx
.
get
(
j
);
ObjectArray
indexes
=
table
.
getIndexes
();
ObjectArray
constraints
=
table
.
getConstraints
();
for
(
int
j
=
0
;
indexes
!=
null
&&
j
<
indexes
.
size
();
j
++)
{
Index
index
=
(
Index
)
indexes
.
get
(
j
);
if
(
index
.
getCreateSQL
()
==
null
)
{
continue
;
}
String
constraintName
=
null
;
for
(
int
k
=
0
;
constraints
!=
null
&&
k
<
constraints
.
size
();
k
++)
{
Constraint
constraint
=
(
Constraint
)
constraints
.
get
(
k
);
if
(
constraint
.
getUniqueIndex
()
==
index
)
{
constraintName
=
constraint
.
getName
();
}
}
IndexColumn
[]
cols
=
index
.
getIndexColumns
();
for
(
int
k
=
0
;
k
<
cols
.
length
;
k
++)
{
IndexColumn
idxCol
=
cols
[
k
];
...
...
@@ -775,6 +784,8 @@ public class MetaTable extends Table {
""
+
index
.
getId
(),
// SORT_TYPE
""
+
idxCol
.
sortType
,
// CONSTRAINT_NAME
constraintName
});
}
}
...
...
h2/src/test/org/h2/test/db/TestView.java
浏览文件 @
7b7afcc4
...
...
@@ -7,6 +7,7 @@
package
org
.
h2
.
test
.
db
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
...
...
@@ -28,11 +29,25 @@ public class TestView extends TestBase {
}
public
void
test
()
throws
SQLException
{
testInSelect
();
testUnionReconnect
();
testManyViews
();
deleteDb
(
"view"
);
}
private
void
testInSelect
()
throws
SQLException
{
deleteDb
(
"view"
);
Connection
conn
=
getConnection
(
"view"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int primary key) as select 1"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"select * from test t where t.id in (select t2.id from test t2 where t2.id in (?, ?))"
);
prep
.
setInt
(
1
,
1
);
prep
.
setInt
(
2
,
2
);
prep
.
execute
();
conn
.
close
();
}
private
void
testUnionReconnect
()
throws
SQLException
{
if
(
config
.
memory
)
{
return
;
...
...
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
7b7afcc4
...
...
@@ -704,7 +704,7 @@ public class TestMetaData extends TestBase {
"PK_NAME"
},
new
int
[]
{
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
SMALLINT
,
Types
.
VARCHAR
},
null
,
null
);
assertResultSetOrdered
(
rs
,
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TEST"
,
"ID"
,
"1"
,
"
PRIMARY_KEY
_2"
},
});
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"TEST"
,
"ID"
,
"1"
,
"
CONSTRAINT
_2"
},
});
trace
(
"getTables - using a wildcard"
);
stat
.
executeUpdate
(
"CREATE TABLE T_2(B INT,A VARCHAR(6),C INT,PRIMARY KEY(C,A,B))"
);
stat
.
executeUpdate
(
"CREATE TABLE TX2(B INT,A VARCHAR(6),C INT,PRIMARY KEY(C,A,B))"
);
...
...
@@ -758,9 +758,9 @@ public class TestMetaData extends TestBase {
trace
(
"getPrimaryKeys"
);
rs
=
meta
.
getPrimaryKeys
(
null
,
null
,
"T_2"
);
assertResultSetOrdered
(
rs
,
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"A"
,
"2"
,
"
PRIMARY_KEY
_1"
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"B"
,
"3"
,
"
PRIMARY_KEY
_1"
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"C"
,
"1"
,
"
PRIMARY_KEY
_1"
},
});
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"A"
,
"2"
,
"
CONSTRAINT
_1"
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"B"
,
"3"
,
"
CONSTRAINT
_1"
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"C"
,
"1"
,
"
CONSTRAINT
_1"
},
});
stat
.
executeUpdate
(
"DROP TABLE TX2"
);
stat
.
executeUpdate
(
"DROP TABLE T_2"
);
stat
.
executeUpdate
(
"CREATE TABLE PARENT(ID INT PRIMARY KEY)"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论