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
...
...
@@ -206,6 +206,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
...
...
@@ -214,8 +221,8 @@ public class ConnectionInfo implements Cloneable {
*
* @return the database event listener object or null
*/
DatabaseEventListener
remove
DatabaseEventListenerObject
()
throws
SQLException
{
Object
p
=
prop
.
remove
(
"DATABASE_EVENT_LISTENER_OBJECT"
);
DatabaseEventListener
get
DatabaseEventListenerObject
()
throws
SQLException
{
Object
p
=
prop
.
get
(
"DATABASE_EVENT_LISTENER_OBJECT"
);
if
(
p
==
null
)
{
return
null
;
}
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
0a211f76
...
...
@@ -181,16 +181,12 @@ public class Database implements DataHandler {
this
.
fileLockMethod
=
FileLock
.
getFileLockMethod
(
lockMethodName
);
this
.
textStorage
=
ci
.
getTextStorage
();
this
.
databaseURL
=
ci
.
getURL
();
this
.
eventListener
=
ci
.
removeDatabaseEventListenerObject
();
this
.
eventListener
=
ci
.
getDatabaseEventListenerObject
();
ci
.
removeDatabaseEventListenerObject
();
if
(
eventListener
==
null
)
{
String
listener
=
ci
.
removeProperty
(
"DATABASE_EVENT_LISTENER"
,
null
);
if
(
listener
!=
null
)
{
if
(
listener
.
startsWith
(
"'"
))
{
listener
=
listener
.
substring
(
1
);
}
if
(
listener
.
endsWith
(
"'"
))
{
listener
=
listener
.
substring
(
0
,
listener
.
length
()
-
1
);
}
listener
=
StringUtils
.
trim
(
listener
,
true
,
true
,
"'"
);
setEventListenerClass
(
listener
);
}
}
...
...
h2/src/main/org/h2/engine/Mode.java
浏览文件 @
0a211f76
...
...
@@ -8,6 +8,7 @@ package org.h2.engine;
import
java.util.HashMap
;
import
org.h2.constant.SysProperties
;
import
org.h2.util.StringUtils
;
/**
...
...
@@ -93,16 +94,26 @@ public class Mode {
*/
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
;
static
{
Mode
mode
=
new
Mode
(
REGULAR
);
mode
.
aliasColumnName
=
SysProperties
.
ALIAS_COLUMN_NAME
;
add
(
mode
);
mode
=
new
Mode
(
"PostgreSQL"
);
mode
.
nullConcatIsNull
=
true
;
mode
.
roundWhenConvertToLong
=
true
;
mode
.
systemColumns
=
true
;
mode
.
aliasColumnName
=
true
;
add
(
mode
);
mode
=
new
Mode
(
"MySQL"
);
...
...
@@ -116,23 +127,28 @@ public class Mode {
mode
.
nullConcatIsNull
=
true
;
mode
.
convertOnlyToSmallerScale
=
true
;
mode
.
uniqueIndexSingleNull
=
true
;
mode
.
aliasColumnName
=
true
;
add
(
mode
);
mode
=
new
Mode
(
"MSSQLServer"
);
mode
.
squareBracketQuotedNames
=
true
;
mode
.
uniqueIndexSingleNull
=
true
;
mode
.
aliasColumnName
=
true
;
add
(
mode
);
mode
=
new
Mode
(
"Derby"
);
mode
.
uniqueIndexSingleNull
=
true
;
mode
.
aliasColumnName
=
true
;
add
(
mode
);
mode
=
new
Mode
(
"Oracle"
);
mode
.
uniqueIndexSingleNullExceptAllColumnsAreNull
=
true
;
mode
.
aliasColumnName
=
true
;
add
(
mode
);
mode
=
new
Mode
(
"DB2"
);
mode
.
supportOffsetFetch
=
true
;
mode
.
aliasColumnName
=
true
;
add
(
mode
);
}
...
...
h2/src/test/org/h2/test/db/TestCompatibility.java
浏览文件 @
0a211f76
...
...
@@ -8,9 +8,12 @@ package org.h2.test.db;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
org.h2.engine.Constants
;
import
org.h2.test.TestBase
;
/**
...
...
@@ -19,11 +22,21 @@ import org.h2.test.TestBase;
public
class
TestCompatibility
extends
TestBase
{
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
{
deleteDb
(
"compatibility"
);
conn
=
getConnection
(
"compatibility"
);
testColumnAlias
();
testUniqueIndexSingleNull
();
testUniqueIndexOracle
();
testHsqlDb
();
...
...
@@ -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
{
Statement
stat
=
conn
.
createStatement
();
String
[]
modes
=
new
String
[]
{
"PostgreSQL"
,
"MySQL"
,
"HSQLDB"
,
"MSSQLServer"
,
"Derby"
,
"Oracle"
,
"Regular"
};
...
...
h2/src/test/org/h2/test/server/TestPgServer.java
浏览文件 @
0a211f76
...
...
@@ -22,6 +22,15 @@ import org.h2.tools.Server;
* Tests the PostgreSQL server protocol compliant implementation.
*/
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
{
deleteDb
(
"test"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论