Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
0a211f76
提交
0a211f76
authored
10月 09, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
After re-connecting to a database, the database event listener (if set) is informed.
上级
7664a84f
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
78 行增加
和
9 行删除
+78
-9
ConnectionInfo.java
h2/src/main/org/h2/engine/ConnectionInfo.java
+9
-2
Database.java
h2/src/main/org/h2/engine/Database.java
+3
-7
Mode.java
h2/src/main/org/h2/engine/Mode.java
+16
-0
TestCompatibility.java
h2/src/test/org/h2/test/db/TestCompatibility.java
+41
-0
TestPgServer.java
h2/src/test/org/h2/test/server/TestPgServer.java
+9
-0
没有找到文件。
h2/src/main/org/h2/engine/ConnectionInfo.java
浏览文件 @
0a211f76
...
@@ -207,6 +207,13 @@ public class ConnectionInfo implements Cloneable {
...
@@ -207,6 +207,13 @@ public class ConnectionInfo implements Cloneable {
}
}
}
}
/**
* Removes the database event listener object.
*/
void
removeDatabaseEventListenerObject
()
{
prop
.
remove
(
"DATABASE_EVENT_LISTENER_OBJECT"
);
}
/**
/**
* Return the database event listener object set as a Java object. If the
* Return the database event listener object set as a Java object. If the
* event listener is not set or set as a string (the class name), then this
* event listener is not set or set as a string (the class name), then this
...
@@ -214,8 +221,8 @@ public class ConnectionInfo implements Cloneable {
...
@@ -214,8 +221,8 @@ public class ConnectionInfo implements Cloneable {
*
*
* @return the database event listener object or null
* @return the database event listener object or null
*/
*/
DatabaseEventListener
remove
DatabaseEventListenerObject
()
throws
SQLException
{
DatabaseEventListener
get
DatabaseEventListenerObject
()
throws
SQLException
{
Object
p
=
prop
.
remove
(
"DATABASE_EVENT_LISTENER_OBJECT"
);
Object
p
=
prop
.
get
(
"DATABASE_EVENT_LISTENER_OBJECT"
);
if
(
p
==
null
)
{
if
(
p
==
null
)
{
return
null
;
return
null
;
}
}
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
0a211f76
...
@@ -181,16 +181,12 @@ public class Database implements DataHandler {
...
@@ -181,16 +181,12 @@ public class Database implements DataHandler {
this
.
fileLockMethod
=
FileLock
.
getFileLockMethod
(
lockMethodName
);
this
.
fileLockMethod
=
FileLock
.
getFileLockMethod
(
lockMethodName
);
this
.
textStorage
=
ci
.
getTextStorage
();
this
.
textStorage
=
ci
.
getTextStorage
();
this
.
databaseURL
=
ci
.
getURL
();
this
.
databaseURL
=
ci
.
getURL
();
this
.
eventListener
=
ci
.
removeDatabaseEventListenerObject
();
this
.
eventListener
=
ci
.
getDatabaseEventListenerObject
();
ci
.
removeDatabaseEventListenerObject
();
if
(
eventListener
==
null
)
{
if
(
eventListener
==
null
)
{
String
listener
=
ci
.
removeProperty
(
"DATABASE_EVENT_LISTENER"
,
null
);
String
listener
=
ci
.
removeProperty
(
"DATABASE_EVENT_LISTENER"
,
null
);
if
(
listener
!=
null
)
{
if
(
listener
!=
null
)
{
if
(
listener
.
startsWith
(
"'"
))
{
listener
=
StringUtils
.
trim
(
listener
,
true
,
true
,
"'"
);
listener
=
listener
.
substring
(
1
);
}
if
(
listener
.
endsWith
(
"'"
))
{
listener
=
listener
.
substring
(
0
,
listener
.
length
()
-
1
);
}
setEventListenerClass
(
listener
);
setEventListenerClass
(
listener
);
}
}
}
}
...
...
h2/src/main/org/h2/engine/Mode.java
浏览文件 @
0a211f76
...
@@ -8,6 +8,7 @@ package org.h2.engine;
...
@@ -8,6 +8,7 @@ package org.h2.engine;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
org.h2.constant.SysProperties
;
import
org.h2.util.StringUtils
;
import
org.h2.util.StringUtils
;
/**
/**
...
@@ -93,16 +94,26 @@ public class Mode {
...
@@ -93,16 +94,26 @@ public class Mode {
*/
*/
public
boolean
supportOffsetFetch
;
public
boolean
supportOffsetFetch
;
/**
* When enabled, aliased columns (as in SELECT ID AS I FROM TEST) return the
* alias (I in this case) in ResultSetMetaData.getColumnName() and 'null' in
* getTableName(). If disabled, the real column name (ID in this case) and
* table name is returned.
*/
public
boolean
aliasColumnName
;
private
String
name
;
private
String
name
;
static
{
static
{
Mode
mode
=
new
Mode
(
REGULAR
);
Mode
mode
=
new
Mode
(
REGULAR
);
mode
.
aliasColumnName
=
SysProperties
.
ALIAS_COLUMN_NAME
;
add
(
mode
);
add
(
mode
);
mode
=
new
Mode
(
"PostgreSQL"
);
mode
=
new
Mode
(
"PostgreSQL"
);
mode
.
nullConcatIsNull
=
true
;
mode
.
nullConcatIsNull
=
true
;
mode
.
roundWhenConvertToLong
=
true
;
mode
.
roundWhenConvertToLong
=
true
;
mode
.
systemColumns
=
true
;
mode
.
systemColumns
=
true
;
mode
.
aliasColumnName
=
true
;
add
(
mode
);
add
(
mode
);
mode
=
new
Mode
(
"MySQL"
);
mode
=
new
Mode
(
"MySQL"
);
...
@@ -116,23 +127,28 @@ public class Mode {
...
@@ -116,23 +127,28 @@ public class Mode {
mode
.
nullConcatIsNull
=
true
;
mode
.
nullConcatIsNull
=
true
;
mode
.
convertOnlyToSmallerScale
=
true
;
mode
.
convertOnlyToSmallerScale
=
true
;
mode
.
uniqueIndexSingleNull
=
true
;
mode
.
uniqueIndexSingleNull
=
true
;
mode
.
aliasColumnName
=
true
;
add
(
mode
);
add
(
mode
);
mode
=
new
Mode
(
"MSSQLServer"
);
mode
=
new
Mode
(
"MSSQLServer"
);
mode
.
squareBracketQuotedNames
=
true
;
mode
.
squareBracketQuotedNames
=
true
;
mode
.
uniqueIndexSingleNull
=
true
;
mode
.
uniqueIndexSingleNull
=
true
;
mode
.
aliasColumnName
=
true
;
add
(
mode
);
add
(
mode
);
mode
=
new
Mode
(
"Derby"
);
mode
=
new
Mode
(
"Derby"
);
mode
.
uniqueIndexSingleNull
=
true
;
mode
.
uniqueIndexSingleNull
=
true
;
mode
.
aliasColumnName
=
true
;
add
(
mode
);
add
(
mode
);
mode
=
new
Mode
(
"Oracle"
);
mode
=
new
Mode
(
"Oracle"
);
mode
.
uniqueIndexSingleNullExceptAllColumnsAreNull
=
true
;
mode
.
uniqueIndexSingleNullExceptAllColumnsAreNull
=
true
;
mode
.
aliasColumnName
=
true
;
add
(
mode
);
add
(
mode
);
mode
=
new
Mode
(
"DB2"
);
mode
=
new
Mode
(
"DB2"
);
mode
.
supportOffsetFetch
=
true
;
mode
.
supportOffsetFetch
=
true
;
mode
.
aliasColumnName
=
true
;
add
(
mode
);
add
(
mode
);
}
}
...
...
h2/src/test/org/h2/test/db/TestCompatibility.java
浏览文件 @
0a211f76
...
@@ -8,9 +8,12 @@ package org.h2.test.db;
...
@@ -8,9 +8,12 @@ package org.h2.test.db;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
org.h2.engine.Constants
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
/**
/**
...
@@ -20,10 +23,20 @@ public class TestCompatibility extends TestBase {
...
@@ -20,10 +23,20 @@ public class TestCompatibility extends TestBase {
private
Connection
conn
;
private
Connection
conn
;
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
[]
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
public
void
test
()
throws
SQLException
{
public
void
test
()
throws
SQLException
{
deleteDb
(
"compatibility"
);
deleteDb
(
"compatibility"
);
conn
=
getConnection
(
"compatibility"
);
conn
=
getConnection
(
"compatibility"
);
testColumnAlias
();
testUniqueIndexSingleNull
();
testUniqueIndexSingleNull
();
testUniqueIndexOracle
();
testUniqueIndexOracle
();
testHsqlDb
();
testHsqlDb
();
...
@@ -33,6 +46,34 @@ public class TestCompatibility extends TestBase {
...
@@ -33,6 +46,34 @@ public class TestCompatibility extends TestBase {
}
}
private
void
testColumnAlias
()
throws
SQLException
{
Statement
stat
=
conn
.
createStatement
();
String
[]
modes
=
new
String
[]
{
"PostgreSQL"
,
"MySQL"
,
"HSQLDB"
,
"MSSQLServer"
,
"Derby"
,
"Oracle"
,
"Regular"
};
String
columnAlias
;
if
(
Constants
.
VERSION_MINOR
==
0
)
{
columnAlias
=
"MySQL"
;
}
else
{
columnAlias
=
"MySQL,Regular"
;
}
stat
.
execute
(
"CREATE TABLE TEST(ID INT)"
);
for
(
int
i
=
0
;
i
<
modes
.
length
;
i
++)
{
String
mode
=
modes
[
i
];
stat
.
execute
(
"SET MODE "
+
mode
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT ID I FROM TEST"
);
ResultSetMetaData
meta
=
rs
.
getMetaData
();
String
columnName
=
meta
.
getColumnName
(
1
);
String
tableName
=
meta
.
getTableName
(
1
);
if
(
"ID"
.
equals
(
columnName
)
&&
"TEST"
.
equals
(
tableName
))
{
assertTrue
(
mode
+
" mode should not support columnAlias"
,
columnAlias
.
indexOf
(
mode
)
>=
0
);
}
else
if
(
"I"
.
equals
(
columnName
)
&&
tableName
==
null
)
{
assertTrue
(
mode
+
" mode should support columnAlias"
,
columnAlias
.
indexOf
(
mode
)
<
0
);
}
else
{
fail
();
}
}
stat
.
execute
(
"DROP TABLE TEST"
);
}
private
void
testUniqueIndexSingleNull
()
throws
SQLException
{
private
void
testUniqueIndexSingleNull
()
throws
SQLException
{
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
String
[]
modes
=
new
String
[]
{
"PostgreSQL"
,
"MySQL"
,
"HSQLDB"
,
"MSSQLServer"
,
"Derby"
,
"Oracle"
,
"Regular"
};
String
[]
modes
=
new
String
[]
{
"PostgreSQL"
,
"MySQL"
,
"HSQLDB"
,
"MSSQLServer"
,
"Derby"
,
"Oracle"
,
"Regular"
};
...
...
h2/src/test/org/h2/test/server/TestPgServer.java
浏览文件 @
0a211f76
...
@@ -23,6 +23,15 @@ import org.h2.tools.Server;
...
@@ -23,6 +23,15 @@ import org.h2.tools.Server;
*/
*/
public
class
TestPgServer
extends
TestBase
{
public
class
TestPgServer
extends
TestBase
{
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
[]
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
public
void
test
()
throws
SQLException
{
public
void
test
()
throws
SQLException
{
deleteDb
(
"test"
);
deleteDb
(
"test"
);
Server
server
=
Server
.
createPgServer
(
new
String
[]{
"-baseDir"
,
baseDir
,
"-pgPort"
,
"5535"
});
Server
server
=
Server
.
createPgServer
(
new
String
[]{
"-baseDir"
,
baseDir
,
"-pgPort"
,
"5535"
});
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论