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,9 +156,12 @@ public class ViewIndex extends BaseIndex {
...
@@ -156,9 +156,12 @@ public class ViewIndex extends BaseIndex {
for
(
int
i
=
0
;
originalParameters
!=
null
&&
i
<
originalParameters
.
size
();
i
++)
{
for
(
int
i
=
0
;
originalParameters
!=
null
&&
i
<
originalParameters
.
size
();
i
++)
{
Parameter
orig
=
(
Parameter
)
originalParameters
.
get
(
i
);
Parameter
orig
=
(
Parameter
)
originalParameters
.
get
(
i
);
int
idx
=
orig
.
getIndex
();
int
idx
=
orig
.
getIndex
();
Parameter
param
=
(
Parameter
)
paramList
.
get
(
idx
);
// the parameter may have been optimized away
Value
value
=
orig
.
getValue
(
session
);
if
(
idx
<
paramList
.
size
())
{
param
.
setValue
(
value
);
Parameter
param
=
(
Parameter
)
paramList
.
get
(
idx
);
Value
value
=
orig
.
getValue
(
session
);
param
.
setValue
(
value
);
}
}
}
int
len
;
int
len
;
if
(
first
!=
null
)
{
if
(
first
!=
null
)
{
...
...
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
浏览文件 @
7b7afcc4
...
@@ -358,7 +358,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
...
@@ -358,7 +358,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+
"TABLE_NAME, "
+
"TABLE_NAME, "
+
"COLUMN_NAME, "
+
"COLUMN_NAME, "
+
"ORDINAL_POSITION KEY_SEQ, "
+
"ORDINAL_POSITION KEY_SEQ, "
+
"I
NDEX_NAME
PK_NAME "
+
"I
FNULL(CONSTRAINT_NAME, INDEX_NAME)
PK_NAME "
+
"FROM INFORMATION_SCHEMA.INDEXES "
+
"FROM INFORMATION_SCHEMA.INDEXES "
+
"WHERE TABLE_CATALOG LIKE ? "
+
"WHERE TABLE_CATALOG LIKE ? "
+
"AND TABLE_SCHEMA LIKE ? "
+
"AND TABLE_SCHEMA LIKE ? "
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
7b7afcc4
...
@@ -187,7 +187,8 @@ public class MetaTable extends Table {
...
@@ -187,7 +187,8 @@ public class MetaTable extends Table {
"REMARKS"
,
"REMARKS"
,
"SQL"
,
"SQL"
,
"ID INT"
,
"ID INT"
,
"SORT_TYPE INT"
"SORT_TYPE INT"
,
"CONSTRAINT_NAME"
});
});
indexColumnName
=
"TABLE_NAME"
;
indexColumnName
=
"TABLE_NAME"
;
break
;
break
;
...
@@ -726,12 +727,20 @@ public class MetaTable extends Table {
...
@@ -726,12 +727,20 @@ public class MetaTable extends Table {
if
(!
checkIndex
(
session
,
tableName
,
indexFrom
,
indexTo
))
{
if
(!
checkIndex
(
session
,
tableName
,
indexFrom
,
indexTo
))
{
continue
;
continue
;
}
}
ObjectArray
idx
=
table
.
getIndexes
();
ObjectArray
indexes
=
table
.
getIndexes
();
for
(
int
j
=
0
;
idx
!=
null
&&
j
<
idx
.
size
();
j
++)
{
ObjectArray
constraints
=
table
.
getConstraints
();
Index
index
=
(
Index
)
idx
.
get
(
j
);
for
(
int
j
=
0
;
indexes
!=
null
&&
j
<
indexes
.
size
();
j
++)
{
Index
index
=
(
Index
)
indexes
.
get
(
j
);
if
(
index
.
getCreateSQL
()
==
null
)
{
if
(
index
.
getCreateSQL
()
==
null
)
{
continue
;
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
();
IndexColumn
[]
cols
=
index
.
getIndexColumns
();
for
(
int
k
=
0
;
k
<
cols
.
length
;
k
++)
{
for
(
int
k
=
0
;
k
<
cols
.
length
;
k
++)
{
IndexColumn
idxCol
=
cols
[
k
];
IndexColumn
idxCol
=
cols
[
k
];
...
@@ -775,6 +784,8 @@ public class MetaTable extends Table {
...
@@ -775,6 +784,8 @@ public class MetaTable extends Table {
""
+
index
.
getId
(),
""
+
index
.
getId
(),
// SORT_TYPE
// SORT_TYPE
""
+
idxCol
.
sortType
,
""
+
idxCol
.
sortType
,
// CONSTRAINT_NAME
constraintName
});
});
}
}
}
}
...
...
h2/src/test/org/h2/test/db/TestView.java
浏览文件 @
7b7afcc4
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
package
org
.
h2
.
test
.
db
;
package
org
.
h2
.
test
.
db
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
...
@@ -28,11 +29,25 @@ public class TestView extends TestBase {
...
@@ -28,11 +29,25 @@ public class TestView extends TestBase {
}
}
public
void
test
()
throws
SQLException
{
public
void
test
()
throws
SQLException
{
testInSelect
();
testUnionReconnect
();
testUnionReconnect
();
testManyViews
();
testManyViews
();
deleteDb
(
"view"
);
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
{
private
void
testUnionReconnect
()
throws
SQLException
{
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
...
...
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
7b7afcc4
...
@@ -704,7 +704,7 @@ public class TestMetaData extends TestBase {
...
@@ -704,7 +704,7 @@ public class TestMetaData extends TestBase {
"PK_NAME"
},
new
int
[]
{
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
SMALLINT
,
"PK_NAME"
},
new
int
[]
{
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
VARCHAR
,
Types
.
SMALLINT
,
Types
.
VARCHAR
},
null
,
null
);
Types
.
VARCHAR
},
null
,
null
);
assertResultSetOrdered
(
rs
,
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"
);
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 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))"
);
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 {
...
@@ -758,9 +758,9 @@ public class TestMetaData extends TestBase {
trace
(
"getPrimaryKeys"
);
trace
(
"getPrimaryKeys"
);
rs
=
meta
.
getPrimaryKeys
(
null
,
null
,
"T_2"
);
rs
=
meta
.
getPrimaryKeys
(
null
,
null
,
"T_2"
);
assertResultSetOrdered
(
rs
,
new
String
[][]
{
assertResultSetOrdered
(
rs
,
new
String
[][]
{
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"A"
,
"2"
,
"
PRIMARY_KEY
_1"
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"A"
,
"2"
,
"
CONSTRAINT
_1"
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"B"
,
"3"
,
"
PRIMARY_KEY
_1"
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"B"
,
"3"
,
"
CONSTRAINT
_1"
},
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"C"
,
"1"
,
"
PRIMARY_KEY
_1"
},
});
{
catalog
,
Constants
.
SCHEMA_MAIN
,
"T_2"
,
"C"
,
"1"
,
"
CONSTRAINT
_1"
},
});
stat
.
executeUpdate
(
"DROP TABLE TX2"
);
stat
.
executeUpdate
(
"DROP TABLE TX2"
);
stat
.
executeUpdate
(
"DROP TABLE T_2"
);
stat
.
executeUpdate
(
"DROP TABLE T_2"
);
stat
.
executeUpdate
(
"CREATE TABLE PARENT(ID INT PRIMARY KEY)"
);
stat
.
executeUpdate
(
"CREATE TABLE PARENT(ID INT PRIMARY KEY)"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论