Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3bad54e3
提交
3bad54e3
authored
10月 08, 2016
作者:
Sergi Vladykin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Compilation for Java 7 fixed, cleanup + code style.
上级
7102cc38
隐藏空白字符变更
内嵌
并排
正在显示
25 个修改的文件
包含
100 行增加
和
107 行删除
+100
-107
Command.java
h2/src/main/org/h2/command/Command.java
+7
-7
CommandContainer.java
h2/src/main/org/h2/command/CommandContainer.java
+2
-2
Parser.java
h2/src/main/org/h2/command/Parser.java
+2
-1
Prepared.java
h2/src/main/org/h2/command/Prepared.java
+8
-8
QueryStatisticsData.java
h2/src/main/org/h2/engine/QueryStatisticsData.java
+17
-17
Session.java
h2/src/main/org/h2/engine/Session.java
+1
-1
SessionInterface.java
h2/src/main/org/h2/engine/SessionInterface.java
+0
-1
SpatialTreeIndex.java
h2/src/main/org/h2/index/SpatialTreeIndex.java
+1
-2
JdbcConnection.java
h2/src/main/org/h2/jdbc/JdbcConnection.java
+0
-3
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+4
-4
Value.java
h2/src/main/org/h2/value/Value.java
+1
-2
ValueTimestampTimeZone.java
h2/src/main/org/h2/value/ValueTimestampTimeZone.java
+6
-6
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+2
-0
TestCompatibilityOracle.java
h2/src/test/org/h2/test/db/TestCompatibilityOracle.java
+1
-2
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+26
-25
TestTriggersConstraints.java
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
+3
-0
UpdateTest.java
h2/src/test/org/h2/test/jaqu/UpdateTest.java
+3
-3
TestBenchmark.java
h2/src/test/org/h2/test/store/TestBenchmark.java
+0
-1
TestStreamStore.java
h2/src/test/org/h2/test/store/TestStreamStore.java
+1
-1
TestPgServer.java
h2/src/test/org/h2/test/unit/TestPgServer.java
+0
-2
TestTimeStampWithTimeZone.java
h2/src/test/org/h2/test/unit/TestTimeStampWithTimeZone.java
+12
-12
TestValue.java
h2/src/test/org/h2/test/unit/TestValue.java
+3
-4
ImmutableArray.java
h2/src/tools/org/h2/dev/util/ImmutableArray.java
+0
-1
ImmutableArray2.java
h2/src/tools/org/h2/dev/util/ImmutableArray2.java
+0
-1
ImmutableArray3.java
h2/src/tools/org/h2/dev/util/ImmutableArray3.java
+0
-1
没有找到文件。
h2/src/main/org/h2/command/Command.java
浏览文件 @
3bad54e3
...
...
@@ -30,7 +30,7 @@ public abstract class Command implements CommandInterface {
/**
* The last start time.
*/
protected
long
startTime
_n
anos
;
protected
long
startTime
N
anos
;
/**
* The trace module.
...
...
@@ -127,7 +127,7 @@ public abstract class Command implements CommandInterface {
*/
void
start
()
{
if
(
trace
.
isInfoEnabled
()
||
session
.
getDatabase
().
getQueryStatistics
())
{
startTime
_n
anos
=
System
.
nanoTime
();
startTime
N
anos
=
System
.
nanoTime
();
}
}
...
...
@@ -162,10 +162,10 @@ public abstract class Command implements CommandInterface {
}
}
}
if
(
trace
.
isInfoEnabled
()
&&
startTime
_n
anos
>
0
)
{
long
time
_ms
=
(
System
.
nanoTime
()
-
startTime_n
anos
)
/
1000
/
1000
;
if
(
time
_m
s
>
Constants
.
SLOW_QUERY_LIMIT_MS
)
{
trace
.
info
(
"slow query: {0} ms"
,
time
_m
s
);
if
(
trace
.
isInfoEnabled
()
&&
startTime
N
anos
>
0
)
{
long
time
Millis
=
(
System
.
nanoTime
()
-
startTimeN
anos
)
/
1000
/
1000
;
if
(
time
Milli
s
>
Constants
.
SLOW_QUERY_LIMIT_MS
)
{
trace
.
info
(
"slow query: {0} ms"
,
time
Milli
s
);
}
}
}
...
...
@@ -180,7 +180,7 @@ public abstract class Command implements CommandInterface {
*/
@Override
public
ResultInterface
executeQuery
(
int
maxrows
,
boolean
scrollable
)
{
startTime
_n
anos
=
0
;
startTime
N
anos
=
0
;
long
start
=
0
;
Database
database
=
session
.
getDatabase
();
Object
sync
=
database
.
isMultiThreaded
()
?
(
Object
)
session
:
(
Object
)
database
;
...
...
h2/src/main/org/h2/command/CommandContainer.java
浏览文件 @
3bad54e3
...
...
@@ -96,7 +96,7 @@ public class CommandContainer extends Command {
session
.
setLastScopeIdentity
(
ValueNull
.
INSTANCE
);
prepared
.
checkParameters
();
int
updateCount
=
prepared
.
update
();
prepared
.
trace
(
startTime
_n
anos
,
updateCount
);
prepared
.
trace
(
startTime
N
anos
,
updateCount
);
setProgress
(
DatabaseEventListener
.
STATE_STATEMENT_END
);
return
updateCount
;
}
...
...
@@ -108,7 +108,7 @@ public class CommandContainer extends Command {
start
();
prepared
.
checkParameters
();
ResultInterface
result
=
prepared
.
query
(
maxrows
);
prepared
.
trace
(
startTime
_n
anos
,
result
.
getRowCount
());
prepared
.
trace
(
startTime
N
anos
,
result
.
getRowCount
());
setProgress
(
DatabaseEventListener
.
STATE_STATEMENT_END
);
return
result
;
}
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
3bad54e3
...
...
@@ -1885,8 +1885,9 @@ public class Parser {
read
(
")"
);
return
command
;
}
if
(
readIf
(
"WITH"
))
if
(
readIf
(
"WITH"
))
{
return
parseWith
();
}
Select
select
=
parseSelectSimple
();
return
select
;
}
...
...
h2/src/main/org/h2/command/Prepared.java
浏览文件 @
3bad54e3
...
...
@@ -302,20 +302,20 @@ public abstract class Prepared {
* Print information about the statement executed if info trace level is
* enabled.
*
* @param startTime
_n
anos when the statement was started
* @param startTime
N
anos when the statement was started
* @param rowCount the query or update row count
*/
void
trace
(
long
startTime
_n
anos
,
int
rowCount
)
{
if
(
session
.
getTrace
().
isInfoEnabled
()
&&
startTime
_n
anos
>
0
)
{
long
deltaTime
_nanos
=
System
.
nanoTime
()
-
startTime_n
anos
;
void
trace
(
long
startTime
N
anos
,
int
rowCount
)
{
if
(
session
.
getTrace
().
isInfoEnabled
()
&&
startTime
N
anos
>
0
)
{
long
deltaTime
Nanos
=
System
.
nanoTime
()
-
startTimeN
anos
;
String
params
=
Trace
.
formatParams
(
parameters
);
session
.
getTrace
().
infoSQL
(
sqlStatement
,
params
,
rowCount
,
deltaTime
_n
anos
/
1000
/
1000
);
session
.
getTrace
().
infoSQL
(
sqlStatement
,
params
,
rowCount
,
deltaTime
N
anos
/
1000
/
1000
);
}
// startTime_nanos can be zero for the command that actually turns on statistics
if
(
session
.
getDatabase
().
getQueryStatistics
()
&&
startTime
_n
anos
!=
0
)
{
long
deltaTime
_nanos
=
System
.
nanoTime
()
-
startTime_n
anos
;
if
(
session
.
getDatabase
().
getQueryStatistics
()
&&
startTime
N
anos
!=
0
)
{
long
deltaTime
Nanos
=
System
.
nanoTime
()
-
startTimeN
anos
;
session
.
getDatabase
().
getQueryStatisticsData
().
update
(
toString
(),
deltaTime
_n
anos
,
rowCount
);
update
(
toString
(),
deltaTime
N
anos
,
rowCount
);
}
}
...
...
h2/src/main/org/h2/engine/QueryStatisticsData.java
浏览文件 @
3bad54e3
...
...
@@ -54,11 +54,11 @@ public class QueryStatisticsData {
* Update query statistics.
*
* @param sqlStatement the statement being executed
* @param executionTime
_n
anos the time in nanoseconds the query/update took to
* @param executionTime
N
anos the time in nanoseconds the query/update took to
* execute
* @param rowCount the query or update row count
*/
public
synchronized
void
update
(
String
sqlStatement
,
long
executionTime
_n
anos
,
public
synchronized
void
update
(
String
sqlStatement
,
long
executionTime
N
anos
,
int
rowCount
)
{
QueryEntry
entry
=
map
.
get
(
sqlStatement
);
if
(
entry
==
null
)
{
...
...
@@ -66,7 +66,7 @@ public class QueryStatisticsData {
entry
.
sqlStatement
=
sqlStatement
;
map
.
put
(
sqlStatement
,
entry
);
}
entry
.
update
(
executionTime
_n
anos
,
rowCount
);
entry
.
update
(
executionTime
N
anos
,
rowCount
);
// Age-out the oldest entries if the map gets too big.
// Test against 1.5 x max-size so we don't do this too often
...
...
@@ -114,17 +114,17 @@ public class QueryStatisticsData {
/**
* The minimum execution time, in nanoseconds.
*/
public
long
executionTimeMin
_n
anos
;
public
long
executionTimeMin
N
anos
;
/**
* The maximum execution time, in nanoseconds.
*/
public
long
executionTimeMax
_n
anos
;
public
long
executionTimeMax
N
anos
;
/**
* The total execution time.
*/
public
long
executionTimeCumulative
_n
anos
;
public
long
executionTimeCumulative
N
anos
;
/**
* The minimum number of rows.
...
...
@@ -144,7 +144,7 @@ public class QueryStatisticsData {
/**
* The mean execution time.
*/
public
double
executionTimeMean
_n
anos
;
public
double
executionTimeMean
N
anos
;
/**
* The mean number of rows.
...
...
@@ -155,19 +155,19 @@ public class QueryStatisticsData {
// http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
// http://www.johndcook.com/standard_deviation.html
private
double
executionTimeM2
_n
anos
;
private
double
executionTimeM2
N
anos
;
private
double
rowCountM2
;
/**
* Update the statistics entry.
*
* @param time
_n
anos the execution time in nanos
* @param time
N
anos the execution time in nanos
* @param rows the number of rows
*/
void
update
(
long
time
_n
anos
,
int
rows
)
{
void
update
(
long
time
N
anos
,
int
rows
)
{
count
++;
executionTimeMin
_nanos
=
Math
.
min
(
time_nanos
,
executionTimeMin_n
anos
);
executionTimeMax
_nanos
=
Math
.
max
(
time_nanos
,
executionTimeMax_n
anos
);
executionTimeMin
Nanos
=
Math
.
min
(
timeNanos
,
executionTimeMinN
anos
);
executionTimeMax
Nanos
=
Math
.
max
(
timeNanos
,
executionTimeMaxN
anos
);
rowCountMin
=
Math
.
min
(
rows
,
rowCountMin
);
rowCountMax
=
Math
.
max
(
rows
,
rowCountMax
);
...
...
@@ -175,18 +175,18 @@ public class QueryStatisticsData {
rowCountMean
+=
rowDelta
/
count
;
rowCountM2
+=
rowDelta
*
(
rows
-
rowCountMean
);
double
timeDelta
=
time
_nanos
-
executionTimeMean_n
anos
;
executionTimeMean
_n
anos
+=
timeDelta
/
count
;
executionTimeM2
_nanos
+=
timeDelta
*
(
time_nanos
-
executionTimeMean_n
anos
);
double
timeDelta
=
time
Nanos
-
executionTimeMeanN
anos
;
executionTimeMean
N
anos
+=
timeDelta
/
count
;
executionTimeM2
Nanos
+=
timeDelta
*
(
timeNanos
-
executionTimeMeanN
anos
);
executionTimeCumulative
_nanos
+=
time_n
anos
;
executionTimeCumulative
Nanos
+=
timeN
anos
;
rowCountCumulative
+=
rows
;
lastUpdateTime
=
System
.
currentTimeMillis
();
}
public
double
getExecutionTimeStandardDeviation
()
{
// population standard deviation
return
Math
.
sqrt
(
executionTimeM2
_n
anos
/
count
);
return
Math
.
sqrt
(
executionTimeM2
N
anos
/
count
);
}
public
double
getRowCountStandardDeviation
()
{
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
3bad54e3
...
...
@@ -78,7 +78,7 @@ public class Session extends SessionWithState {
private
int
lockTimeout
;
private
Value
lastIdentity
=
ValueLong
.
get
(
0
);
private
Value
lastScopeIdentity
=
ValueLong
.
get
(
0
);
private
Value
lastTriggerIdentity
=
null
;
private
Value
lastTriggerIdentity
;
private
int
firstUncommittedLog
=
Session
.
LOG_WRITTEN
;
private
int
firstUncommittedPos
=
Session
.
LOG_WRITTEN
;
private
HashMap
<
String
,
Savepoint
>
savepoints
;
...
...
h2/src/main/org/h2/engine/SessionInterface.java
浏览文件 @
3bad54e3
...
...
@@ -8,7 +8,6 @@ package org.h2.engine;
import
java.io.Closeable
;
import
java.util.ArrayList
;
import
org.h2.command.CommandInterface
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.message.Trace
;
import
org.h2.store.DataHandler
;
import
org.h2.value.Value
;
...
...
h2/src/main/org/h2/index/SpatialTreeIndex.java
浏览文件 @
3bad54e3
...
...
@@ -7,7 +7,6 @@ package org.h2.index;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Session
;
import
org.h2.message.DbException
;
import
org.h2.mvstore.MVStore
;
...
...
@@ -187,7 +186,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
*/
public
static
long
getCostRangeIndex
(
int
[]
masks
,
long
rowCount
,
Column
[]
columns
)
{
// Never use spatial tree index without spatial filter
if
(
columns
.
length
==
0
)
{
if
(
columns
.
length
==
0
)
{
return
Long
.
MAX_VALUE
;
}
for
(
Column
column
:
columns
)
{
...
...
h2/src/main/org/h2/jdbc/JdbcConnection.java
浏览文件 @
3bad54e3
...
...
@@ -37,16 +37,13 @@ import org.h2.api.ErrorCode;
import
org.h2.command.CommandInterface
;
import
org.h2.engine.ConnectionInfo
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Database
;
import
org.h2.engine.Mode
;
import
org.h2.engine.Session
;
import
org.h2.engine.SessionInterface
;
import
org.h2.engine.SessionRemote
;
import
org.h2.engine.SysProperties
;
import
org.h2.message.DbException
;
import
org.h2.message.TraceObject
;
import
org.h2.result.ResultInterface
;
import
org.h2.schema.Schema
;
import
org.h2.util.CloseWatcher
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.Utils
;
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
3bad54e3
...
...
@@ -1834,13 +1834,13 @@ public class MetaTable extends Table {
// EXECUTION_COUNT
""
+
entry
.
count
,
// MIN_EXECUTION_TIME
""
+
entry
.
executionTimeMin
_n
anos
/
1000
d
/
1000
,
""
+
entry
.
executionTimeMin
N
anos
/
1000
d
/
1000
,
// MAX_EXECUTION_TIME
""
+
entry
.
executionTimeMax
_n
anos
/
1000
d
/
1000
,
""
+
entry
.
executionTimeMax
N
anos
/
1000
d
/
1000
,
// CUMULATIVE_EXECUTION_TIME
""
+
entry
.
executionTimeCumulative
_n
anos
/
1000
d
/
1000
,
""
+
entry
.
executionTimeCumulative
N
anos
/
1000
d
/
1000
,
// AVERAGE_EXECUTION_TIME
""
+
entry
.
executionTimeMean
_n
anos
/
1000
d
/
1000
,
""
+
entry
.
executionTimeMean
N
anos
/
1000
d
/
1000
,
// STD_DEV_EXECUTION_TIME
""
+
entry
.
getExecutionTimeStandardDeviation
()
/
1000
d
/
1000
,
// MIN_ROW_COUNT
...
...
h2/src/main/org/h2/value/Value.java
浏览文件 @
3bad54e3
...
...
@@ -914,8 +914,7 @@ public abstract class Value {
if
(
object
instanceof
java
.
util
.
UUID
)
{
java
.
util
.
UUID
uuid
=
(
java
.
util
.
UUID
)
object
;
return
ValueUuid
.
get
(
uuid
.
getMostSignificantBits
(),
uuid
.
getLeastSignificantBits
());
}
else
{
}
else
{
throw
DbException
.
get
(
ErrorCode
.
DATA_CONVERSION_ERROR_1
,
getString
());
}
case
TIMESTAMP_TZ:
...
...
h2/src/main/org/h2/value/ValueTimestampTimeZone.java
浏览文件 @
3bad54e3
...
...
@@ -294,14 +294,14 @@ public class ValueTimestampTimeZone extends Value {
// even if the DST database changes.
// convert to minutes and add timezone offset
long
a
=
DateTimeUtils
.
convertDateValueToMillis
(
TimeZone
.
getTimeZone
(
"UTC"
),
dateValue
)
/
(
1000L
*
60L
);
long
ma
=
timeNanos
/
(
1000L
*
1000L
*
1000L
*
60L
);
long
a
=
DateTimeUtils
.
convertDateValueToMillis
(
TimeZone
.
getTimeZone
(
"UTC"
),
dateValue
)
/
(
1000L
*
60L
);
long
ma
=
timeNanos
/
(
1000L
*
1000L
*
1000L
*
60L
);
a
+=
ma
;
a
-=
timeZoneOffsetMins
;
// convert to minutes and add timezone offset
long
b
=
DateTimeUtils
.
convertDateValueToMillis
(
TimeZone
.
getTimeZone
(
"UTC"
),
t
.
dateValue
)
/
(
1000L
*
60L
);
long
mb
=
t
.
timeNanos
/
(
1000L
*
1000L
*
1000L
*
60L
);
long
b
=
DateTimeUtils
.
convertDateValueToMillis
(
TimeZone
.
getTimeZone
(
"UTC"
),
t
.
dateValue
)
/
(
1000L
*
60L
);
long
mb
=
t
.
timeNanos
/
(
1000L
*
1000L
*
1000L
*
60L
);
b
+=
mb
;
b
-=
t
.
timeZoneOffsetMins
;
...
...
@@ -311,8 +311,8 @@ public class ValueTimestampTimeZone extends Value {
return
c
;
}
// compare time
long
na
=
timeNanos
-
(
ma
*
1000L
*
1000L
*
1000L
*
60L
);
long
nb
=
t
.
timeNanos
-
(
mb
*
1000L
*
1000L
*
1000L
*
60L
);
long
na
=
timeNanos
-
(
ma
*
1000L
*
1000L
*
1000L
*
60L
);
long
nb
=
t
.
timeNanos
-
(
mb
*
1000L
*
1000L
*
1000L
*
60L
);
return
MathUtils
.
compareLong
(
na
,
nb
);
}
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
3bad54e3
...
...
@@ -53,6 +53,7 @@ import org.h2.test.db.TestPowerOff;
import
org.h2.test.db.TestQueryCache
;
import
org.h2.test.db.TestReadOnly
;
import
org.h2.test.db.TestRecursiveQueries
;
import
org.h2.test.db.TestReplace
;
import
org.h2.test.db.TestRights
;
import
org.h2.test.db.TestRowFactory
;
import
org.h2.test.db.TestRunscript
;
...
...
@@ -717,6 +718,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
addTest
(
new
TestView
());
addTest
(
new
TestViewAlterTable
());
addTest
(
new
TestViewDropView
());
addTest
(
new
TestReplace
());
// jaqu
addTest
(
new
AliasMapTest
());
...
...
h2/src/test/org/h2/test/db/TestCompatibilityOracle.java
浏览文件 @
3bad54e3
...
...
@@ -171,8 +171,7 @@ public class TestCompatibilityOracle extends TestBase {
try
{
stat
.
executeQuery
(
"SELECT * FROM A WHERE ID IN ()"
);
fail
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
}
finally
{
conn
.
close
();
}
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
3bad54e3
...
...
@@ -1294,7 +1294,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
}
try
{
ToDateParser
.
toDate
(
"1-DEC-0000"
,
"DD-MON-RRRR"
);
ToDateParser
.
toDate
(
"1-DEC-0000"
,
"DD-MON-RRRR"
);
fail
(
"Oracle to_date should reject year 0 (ORA-01841)"
);
}
catch
(
Exception
e
)
{
}
}
...
...
@@ -2016,10 +2016,11 @@ public class TestFunctions extends TestBase implements AggregateFunction {
final
String
formatted
;
try
(
final
ResultSet
rs
=
stat
.
executeQuery
(
"select to_char(current_timestamp(9), 'YYYY MM DD HH24 MI SS FF3') from dual"
))
{
rs
.
next
();
formatted
=
rs
.
getString
(
1
);
}
final
ResultSet
rs
=
stat
.
executeQuery
(
"select to_char(current_timestamp(9), 'YYYY MM DD HH24 MI SS FF3') from dual"
);
rs
.
next
();
formatted
=
rs
.
getString
(
1
);
rs
.
close
();
Date
after
=
new
Date
();
...
...
@@ -2036,19 +2037,19 @@ public class TestFunctions extends TestBase implements AggregateFunction {
conn
.
setAutoCommit
(
false
);
Statement
stat
=
conn
.
createStatement
();
final
Timestamp
first
;
try
(
final
ResultSet
rs
=
stat
.
executeQuery
(
"select CURRENT_TIMESTAMP from DUAL"
))
{
rs
.
next
();
first
=
rs
.
getTimestamp
(
1
);
}
Timestamp
first
;
ResultSet
rs
=
stat
.
executeQuery
(
"select CURRENT_TIMESTAMP from DUAL"
);
rs
.
next
();
first
=
rs
.
getTimestamp
(
1
);
rs
.
close
();
Thread
.
sleep
(
1
);
final
Timestamp
second
;
try
(
final
ResultSet
rs
=
stat
.
executeQuery
(
"select CURRENT_TIMESTAMP from DUAL"
))
{
rs
.
next
();
second
=
rs
.
getTimestamp
(
1
);
}
Timestamp
second
;
rs
=
stat
.
executeQuery
(
"select CURRENT_TIMESTAMP from DUAL"
);
rs
.
next
();
second
=
rs
.
getTimestamp
(
1
);
rs
.
close
();
assertEquals
(
first
,
second
);
}
...
...
@@ -2059,19 +2060,19 @@ public class TestFunctions extends TestBase implements AggregateFunction {
conn
.
setAutoCommit
(
true
);
Statement
stat
=
conn
.
createStatement
();
final
Timestamp
first
;
try
(
final
ResultSet
rs
=
stat
.
executeQuery
(
"select CURRENT_TIMESTAMP from DUAL"
))
{
rs
.
next
();
first
=
rs
.
getTimestamp
(
1
);
}
Timestamp
first
;
ResultSet
rs
=
stat
.
executeQuery
(
"select CURRENT_TIMESTAMP from DUAL"
);
rs
.
next
();
first
=
rs
.
getTimestamp
(
1
);
rs
.
close
();
Thread
.
sleep
(
1
);
final
Timestamp
second
;
try
(
final
ResultSet
rs
=
stat
.
executeQuery
(
"select CURRENT_TIMESTAMP from DUAL"
))
{
rs
.
next
();
second
=
rs
.
getTimestamp
(
1
);
}
Timestamp
second
;
rs
=
stat
.
executeQuery
(
"select CURRENT_TIMESTAMP from DUAL"
);
rs
.
next
();
second
=
rs
.
getTimestamp
(
1
);
rs
.
close
();
assertTrue
(
second
.
after
(
first
));
}
...
...
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
浏览文件 @
3bad54e3
...
...
@@ -329,6 +329,9 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
}
/**
*
*/
public
static
class
TestViewGeneratedKeys
implements
Trigger
{
PreparedStatement
prepInsert
;
...
...
h2/src/test/org/h2/test/jaqu/UpdateTest.java
浏览文件 @
3bad54e3
...
...
@@ -57,7 +57,7 @@ public class UpdateTest extends TestBase {
Product
p2
=
new
Product
();
Product
pChang2
=
db
.
from
(
p2
).
where
(
p2
.
productName
).
is
(
"Chang"
)
.
selectFirst
();
assertEquals
((
Double
)
19.5
,
pChang2
.
unitPrice
);
assertEquals
((
Double
)
19.5
,
pChang2
.
unitPrice
);
assertEquals
(
16
,
pChang2
.
unitsInStock
.
intValue
());
// undo update
...
...
@@ -95,7 +95,7 @@ public class UpdateTest extends TestBase {
Product
p2
=
new
Product
();
Product
pChang2
=
db
.
from
(
p2
).
where
(
p2
.
productName
).
is
(
"Chang"
)
.
selectFirst
();
assertEquals
((
Double
)
19.5
,
pChang2
.
unitPrice
);
assertEquals
((
Double
)
19.5
,
pChang2
.
unitPrice
);
assertEquals
(
16
,
pChang2
.
unitsInStock
.
intValue
());
// undo update
...
...
@@ -136,7 +136,7 @@ public class UpdateTest extends TestBase {
// confirm the data was properly updated
Product
revised
=
db
.
from
(
p
).
where
(
p
.
productId
).
is
(
1
).
selectFirst
();
assertEquals
(
"updated"
,
revised
.
productName
);
assertEquals
((
Double
)(
original
.
unitPrice
+
3.14
),
revised
.
unitPrice
);
assertEquals
((
Double
)
(
original
.
unitPrice
+
3.14
),
revised
.
unitPrice
);
assertEquals
(
original
.
unitsInStock
+
2
,
revised
.
unitsInStock
.
intValue
());
// restore the data
...
...
h2/src/test/org/h2/test/store/TestBenchmark.java
浏览文件 @
3bad54e3
...
...
@@ -31,7 +31,6 @@ public class TestBenchmark extends TestBase {
@Override
public
void
test
()
throws
Exception
{
;
// TODO this test is currently disabled
test
(
true
);
...
...
h2/src/test/org/h2/test/store/TestStreamStore.java
浏览文件 @
3bad54e3
...
...
@@ -67,7 +67,7 @@ public class TestStreamStore extends TestBase {
if
(
max
==
-
1
)
{
assertTrue
(
map
.
isEmpty
());
}
else
{
assertEquals
(
map
.
lastKey
(),
(
Long
)
max
);
assertEquals
(
map
.
lastKey
(),
(
Long
)
max
);
}
}
}
...
...
h2/src/test/org/h2/test/unit/TestPgServer.java
浏览文件 @
3bad54e3
...
...
@@ -5,10 +5,8 @@
*/
package
org
.
h2
.
test
.
unit
;
import
java.math.BigDecimal
;
import
java.sql.Connection
;
import
java.sql.DatabaseMetaData
;
import
java.sql.Date
;
import
java.sql.DriverManager
;
import
java.sql.ParameterMetaData
;
import
java.sql.PreparedStatement
;
...
...
h2/src/test/org/h2/test/unit/TestTimeStampWithTimeZone.java
浏览文件 @
3bad54e3
...
...
@@ -87,24 +87,24 @@ public class TestTimeStampWithTimeZone extends TestBase {
}
private
void
test2
()
{
ValueTimestampTimeZone
a
=
ValueTimestampTimeZone
.
parse
(
"1970-01-01 12:00:00.00+00:15"
);
ValueTimestampTimeZone
b
=
ValueTimestampTimeZone
.
parse
(
"1970-01-01 12:00:01.00+01:15"
);
int
c
=
a
.
compareTo
(
b
,
null
);
assertEquals
(
c
,
1
);
ValueTimestampTimeZone
a
=
ValueTimestampTimeZone
.
parse
(
"1970-01-01 12:00:00.00+00:15"
);
ValueTimestampTimeZone
b
=
ValueTimestampTimeZone
.
parse
(
"1970-01-01 12:00:01.00+01:15"
);
int
c
=
a
.
compareTo
(
b
,
null
);
assertEquals
(
c
,
1
);
}
private
void
test3
()
{
ValueTimestampTimeZone
a
=
ValueTimestampTimeZone
.
parse
(
"1970-01-02 00:00:02.00+01:15"
);
ValueTimestampTimeZone
b
=
ValueTimestampTimeZone
.
parse
(
"1970-01-01 23:00:01.00+00:15"
);
int
c
=
a
.
compareTo
(
b
,
null
);
assertEquals
(
c
,
1
);
ValueTimestampTimeZone
a
=
ValueTimestampTimeZone
.
parse
(
"1970-01-02 00:00:02.00+01:15"
);
ValueTimestampTimeZone
b
=
ValueTimestampTimeZone
.
parse
(
"1970-01-01 23:00:01.00+00:15"
);
int
c
=
a
.
compareTo
(
b
,
null
);
assertEquals
(
c
,
1
);
}
private
void
test4
()
{
ValueTimestampTimeZone
a
=
ValueTimestampTimeZone
.
parse
(
"1970-01-02 00:00:01.00+01:15"
);
ValueTimestampTimeZone
b
=
ValueTimestampTimeZone
.
parse
(
"1970-01-01 23:00:01.00+00:15"
);
int
c
=
a
.
compareTo
(
b
,
null
);
assertEquals
(
c
,
0
);
ValueTimestampTimeZone
a
=
ValueTimestampTimeZone
.
parse
(
"1970-01-02 00:00:01.00+01:15"
);
ValueTimestampTimeZone
b
=
ValueTimestampTimeZone
.
parse
(
"1970-01-01 23:00:01.00+00:15"
);
int
c
=
a
.
compareTo
(
b
,
null
);
assertEquals
(
c
,
0
);
}
private
void
testOrder
()
throws
SQLException
{
...
...
h2/src/test/org/h2/test/unit/TestValue.java
浏览文件 @
3bad54e3
...
...
@@ -15,7 +15,6 @@ import java.sql.Timestamp;
import
java.sql.Types
;
import
java.util.UUID
;
import
org.h2.api.ErrorCode
;
import
org.h2.jdbc.JdbcSQLException
;
import
org.h2.message.DbException
;
import
org.h2.test.TestBase
;
import
org.h2.test.utils.AssertThrows
;
...
...
@@ -292,11 +291,11 @@ public class TestValue extends TestBase {
ValueJavaObject
valObj
=
ValueJavaObject
.
getNoCopy
(
origUUID
,
null
,
null
);
Value
valUUID
=
valObj
.
convertTo
(
Value
.
UUID
);
assertTrue
(
valUUID
instanceof
ValueUuid
);
assertTrue
(
(
valUUID
.
getString
().
equals
(
uuidStr
)
));
assertTrue
(
valUUID
.
getString
().
equals
(
uuidStr
));
assertTrue
(
valUUID
.
getObject
().
equals
(
origUUID
));
ValueJavaObject
vo
_s
tring
=
ValueJavaObject
.
getNoCopy
(
new
String
(
"This is not a ValueUuid object"
),
null
,
null
);
assertThrows
(
DbException
.
class
,
vo
_s
tring
).
convertTo
(
Value
.
UUID
);
ValueJavaObject
vo
S
tring
=
ValueJavaObject
.
getNoCopy
(
new
String
(
"This is not a ValueUuid object"
),
null
,
null
);
assertThrows
(
DbException
.
class
,
vo
S
tring
).
convertTo
(
Value
.
UUID
);
}
private
void
testModulusDouble
()
{
...
...
h2/src/tools/org/h2/dev/util/ImmutableArray.java
浏览文件 @
3bad54e3
...
...
@@ -111,7 +111,6 @@ public final class ImmutableArray<K> implements Iterable<K> {
* @param array the data
* @return the new immutable array
*/
@SuppressWarnings
(
"unchecked"
)
public
static
<
K
>
ImmutableArray
<
K
>
create
(
K
...
array
)
{
return
new
ImmutableArray
<
K
>(
array
);
}
...
...
h2/src/tools/org/h2/dev/util/ImmutableArray2.java
浏览文件 @
3bad54e3
...
...
@@ -151,7 +151,6 @@ public final class ImmutableArray2<K> implements Iterable<K> {
* @param array the data
* @return the new immutable array
*/
@SuppressWarnings
(
"unchecked"
)
public
static
<
K
>
ImmutableArray2
<
K
>
create
(
K
...
array
)
{
return
new
ImmutableArray2
<
K
>(
array
,
array
.
length
);
}
...
...
h2/src/tools/org/h2/dev/util/ImmutableArray3.java
浏览文件 @
3bad54e3
...
...
@@ -84,7 +84,6 @@ public abstract class ImmutableArray3<K> implements Iterable<K> {
* @param array the data
* @return the new immutable array
*/
@SuppressWarnings
(
"unchecked"
)
public
static
<
K
>
ImmutableArray3
<
K
>
create
(
K
...
array
)
{
return
new
Plain
<
K
>(
array
);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论