Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
19556a3e
提交
19556a3e
authored
1月 13, 2016
作者:
Erwan Bocher
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/h2database/h2database
into updateJTS
上级
2ff8f838
00a1b0e2
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
583 行增加
和
449 行删除
+583
-449
Function.java
h2/src/main/org/h2/expression/Function.java
+13
-3
JoinBatch.java
h2/src/main/org/h2/table/JoinBatch.java
+3
-3
DateTimeUtils.java
h2/src/main/org/h2/util/DateTimeUtils.java
+4
-1
ToDate.java
h2/src/main/org/h2/util/ToDate.java
+0
-19
ToDateParser.java
h2/src/main/org/h2/util/ToDateParser.java
+79
-61
ToDateTokenizer.java
h2/src/main/org/h2/util/ToDateTokenizer.java
+336
-229
Value.java
h2/src/main/org/h2/value/Value.java
+1
-1
ValueTimestampUtc.java
h2/src/main/org/h2/value/ValueTimestampUtc.java
+3
-3
ToDate.java
h2/src/test/org/h2/samples/ToDate.java
+16
-10
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+82
-72
TestOptimizations.java
h2/src/test/org/h2/test/db/TestOptimizations.java
+15
-15
TestTableEngines.java
h2/src/test/org/h2/test/db/TestTableEngines.java
+18
-18
TestDate.java
h2/src/test/org/h2/test/unit/TestDate.java
+2
-1
TestTimeStampUtc.java
h2/src/test/org/h2/test/unit/TestTimeStampUtc.java
+3
-3
BuildBase.java
h2/src/tools/org/h2/build/BuildBase.java
+3
-3
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+5
-7
没有找到文件。
h2/src/main/org/h2/expression/Function.java
浏览文件 @
19556a3e
...
...
@@ -44,7 +44,17 @@ import org.h2.table.Table;
import
org.h2.table.TableFilter
;
import
org.h2.tools.CompressTool
;
import
org.h2.tools.Csv
;
import
org.h2.util.*
;
import
org.h2.util.AutoCloseInputStream
;
import
org.h2.util.DateTimeUtils
;
import
org.h2.util.IOUtils
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.New
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.util.ToChar
;
import
org.h2.util.ToDateParser
;
import
org.h2.util.Utils
;
import
org.h2.value.DataType
;
import
org.h2.value.Value
;
import
org.h2.value.ValueArray
;
...
...
@@ -1424,11 +1434,11 @@ public class Function extends Expression implements FunctionCall {
}
break
;
case
TO_DATE:
result
=
ValueTimestamp
.
get
(
ToDate
.
TO_DATE
(
v0
.
getString
(),
result
=
ValueTimestamp
.
get
(
ToDate
Parser
.
toDate
(
v0
.
getString
(),
v1
==
null
?
null
:
v1
.
getString
()));
break
;
case
TO_TIMESTAMP:
result
=
ValueTimestamp
.
get
(
ToDate
.
TO_TIMESTAMP
(
v0
.
getString
(),
result
=
ValueTimestamp
.
get
(
ToDate
Parser
.
toTimestamp
(
v0
.
getString
(),
v1
==
null
?
null
:
v1
.
getString
()));
break
;
case
TRANSLATE:
{
...
...
h2/src/main/org/h2/table/JoinBatch.java
浏览文件 @
19556a3e
...
...
@@ -410,9 +410,9 @@ public final class JoinBatch {
@Override
public
String
toString
()
{
return
"JoinBatch->\nprev->"
+
(
current
==
null
?
null
:
current
.
prev
)
+
"\ncurr->"
+
current
+
"\nnext->"
+
(
current
==
null
?
null
:
current
.
next
);
return
"JoinBatch->\n
"
+
"
prev->"
+
(
current
==
null
?
null
:
current
.
prev
)
+
"\n
"
+
"
curr->"
+
current
+
"\n
"
+
"
next->"
+
(
current
==
null
?
null
:
current
.
next
);
}
/**
...
...
h2/src/main/org/h2/util/DateTimeUtils.java
浏览文件 @
19556a3e
...
...
@@ -11,7 +11,10 @@ import java.sql.Date;
import
java.sql.Time
;
import
java.sql.Timestamp
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.Calendar
;
import
java.util.GregorianCalendar
;
import
java.util.Locale
;
import
java.util.TimeZone
;
import
org.h2.api.ErrorCode
;
import
org.h2.message.DbException
;
...
...
h2/src/main/org/h2/util/ToDate.java
deleted
100644 → 0
浏览文件 @
2ff8f838
package
org
.
h2
.
util
;
import
java.sql.Timestamp
;
import
java.util.Date
;
/**
* Emulates Oracle's TO_DATE function.<br>
* Main class
*/
public
class
ToDate
{
public
static
Timestamp
TO_DATE
(
final
String
input
,
final
String
format
)
{
ToDateParser
parser
=
ToDateParser
.
toDate
(
input
,
format
);
return
parser
.
getResultingTimestamp
();
}
public
static
Timestamp
TO_TIMESTAMP
(
final
String
input
,
final
String
format
)
{
ToDateParser
parser
=
ToDateParser
.
toTimestamp
(
input
,
format
);
return
parser
.
getResultingTimestamp
();
}
}
\ No newline at end of file
h2/src/main/org/h2/util/ToDateParser.java
浏览文件 @
19556a3e
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: Daniel Gredler
*/
package
org
.
h2
.
util
;
import
static
java
.
lang
.
String
.
format
;
import
java.sql.Timestamp
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
/**
* Emulates Oracle's TO_DATE function.<br>
* This class holds and handles the input data form the TO_DATE-method
*/
class
ToDateParser
{
public
class
ToDateParser
{
private
final
String
unmodifiedInputStr
;
private
final
String
unmodifiedFormatStr
;
private
final
ConfigParam
functionName
;
private
String
inputStr
;
private
String
formatStr
;
private
final
Calendar
resultCalendar
=
(
Calendar
)
Calendar
.
getInstance
().
clone
();
private
Integer
nanos
=
null
;
private
enum
ConfigParam
{
TO_DATE
(
"DD MON YYYY"
),
TO_TIMESTAMP
(
"DD MON YYYY HH:MI:SS"
);
private
final
String
defaultFormatStr
;
ConfigParam
(
final
String
defaultFormatStr
)
{
this
.
defaultFormatStr
=
defaultFormatStr
;
}
String
getDefaultFormatStr
()
{
return
defaultFormatStr
;
}
}
static
ToDateParser
toDate
(
final
String
input
,
final
String
format
)
{
ToDateParser
result
=
new
ToDateParser
(
ConfigParam
.
TO_DATE
,
input
,
format
);
parse
(
result
);
return
result
;
}
static
ToDateParser
toTimestamp
(
final
String
input
,
final
String
format
)
{
ToDateParser
result
=
new
ToDateParser
(
ConfigParam
.
TO_TIMESTAMP
,
input
,
format
);
parse
(
result
);
return
result
;
}
private
Integer
nanos
;
/**
* @param input the input date with the date-time info
* @param format the format of date-time info
* @param functionName one of [TO_DATE, TO_TIMESTAMP] (both share the same code)
* @param format the format of date-time info
* @param functionName one of [TO_DATE, TO_TIMESTAMP] (both share the same
* code)
*/
ToDateParser
(
final
ConfigParam
functionName
,
final
String
input
,
final
String
format
)
{
private
ToDateParser
(
ConfigParam
functionName
,
String
input
,
String
format
)
{
// reset calendar - default oracle behaviour
resultCalendar
.
set
(
Calendar
.
YEAR
,
1970
);
resultCalendar
.
set
(
Calendar
.
MONTH
,
Calendar
.
getInstance
().
get
(
Calendar
.
MONTH
));
...
...
@@ -65,18 +47,34 @@ class ToDateParser {
this
.
functionName
=
functionName
;
inputStr
=
input
.
trim
();
unmodifiedInputStr
=
inputStr
;
// Keep a copy
// Keep a copy
unmodifiedInputStr
=
inputStr
;
if
(
format
==
null
||
format
.
isEmpty
())
{
formatStr
=
functionName
.
getDefaultFormatStr
();
// default Oracle format.
// default Oracle format.
formatStr
=
functionName
.
getDefaultFormatStr
();
}
else
{
formatStr
=
format
.
trim
();
}
unmodifiedFormatStr
=
formatStr
;
// Keep a copy
// Keep a copy
unmodifiedFormatStr
=
formatStr
;
}
private
static
ToDateParser
getDateParser
(
String
input
,
String
format
)
{
ToDateParser
result
=
new
ToDateParser
(
ConfigParam
.
TO_DATE
,
input
,
format
);
parse
(
result
);
return
result
;
}
private
static
ToDateParser
getTimestampParser
(
String
input
,
String
format
)
{
ToDateParser
result
=
new
ToDateParser
(
ConfigParam
.
TO_TIMESTAMP
,
input
,
format
);
parse
(
result
);
return
result
;
}
Timestamp
getResultingTimestamp
()
{
private
Timestamp
getResultingTimestamp
()
{
Calendar
cal
=
(
Calendar
)
getResultCalendar
().
clone
();
int
nanosToSet
=
nanos
==
null
?
cal
.
get
(
Calendar
.
MILLISECOND
)
*
1000000
:
nanos
.
intValue
();
int
nanosToSet
=
nanos
==
null
?
cal
.
get
(
Calendar
.
MILLISECOND
)
*
1000000
:
nanos
.
intValue
();
cal
.
set
(
Calendar
.
MILLISECOND
,
0
);
Timestamp
ts
=
new
Timestamp
(
cal
.
getTimeInMillis
());
ts
.
setNanos
(
nanosToSet
);
...
...
@@ -99,15 +97,15 @@ class ToDateParser {
return
functionName
.
name
();
}
void
setNanos
(
final
int
nanos
)
{
void
setNanos
(
int
nanos
)
{
this
.
nanos
=
nanos
;
}
boolean
hasToParseData
()
{
private
boolean
hasToParseData
()
{
return
formatStr
.
length
()
>
0
;
}
void
removeFirstChar
()
{
private
void
removeFirstChar
()
{
if
(!
formatStr
.
isEmpty
())
{
formatStr
=
formatStr
.
substring
(
1
);
}
...
...
@@ -116,9 +114,10 @@ class ToDateParser {
}
}
private
static
ToDateParser
parse
(
final
ToDateParser
p
)
{
private
static
ToDateParser
parse
(
ToDateParser
p
)
{
while
(
p
.
hasToParseData
())
{
List
<
ToDateTokenizer
.
FormatTokenEnum
>
tokenList
=
ToDateTokenizer
.
FormatTokenEnum
.
getTokensInQuestion
(
p
.
getFormatStr
());
List
<
ToDateTokenizer
.
FormatTokenEnum
>
tokenList
=
ToDateTokenizer
.
FormatTokenEnum
.
getTokensInQuestion
(
p
.
getFormatStr
());
if
(
tokenList
.
isEmpty
())
{
p
.
removeFirstChar
();
continue
;
...
...
@@ -138,19 +137,9 @@ class ToDateParser {
return
p
;
}
void
remove
(
final
String
toIgnore
)
{
if
(
toIgnore
!=
null
)
{
int
trimLeng
=
toIgnore
.
length
();
formatStr
=
formatStr
.
substring
(
trimLeng
);
if
(
inputStr
.
length
()
>=
trimLeng
)
{
inputStr
=
inputStr
.
substring
(
trimLeng
);
}
}
}
void
remove
(
final
String
intputFragmentStr
,
final
String
formatFragment
)
{
if
(
intputFragmentStr
!=
null
&&
inputStr
.
length
()
>=
intputFragmentStr
.
length
())
{
inputStr
=
inputStr
.
substring
(
intputFragmentStr
.
length
());
void
remove
(
String
inputFragmentStr
,
String
formatFragment
)
{
if
(
inputFragmentStr
!=
null
&&
inputStr
.
length
()
>=
inputFragmentStr
.
length
())
{
inputStr
=
inputStr
.
substring
(
inputFragmentStr
.
length
());
}
if
(
formatFragment
!=
null
&&
formatStr
.
length
()
>=
formatFragment
.
length
())
{
formatStr
=
formatStr
.
substring
(
formatFragment
.
length
());
...
...
@@ -159,21 +148,50 @@ class ToDateParser {
@Override
public
String
toString
()
{
int
inputStrLen
g
=
inputStr
.
length
();
int
orgInputLen
g
=
unmodifiedInputStr
.
length
();
int
currentInputPos
=
orgInputLen
g
-
inputStrLeng
;
int
restInputLen
g
=
inputStrLeng
<=
0
?
inputStrLeng
:
inputStrLeng
-
1
;
int
inputStrLen
=
inputStr
.
length
();
int
orgInputLen
=
unmodifiedInputStr
.
length
();
int
currentInputPos
=
orgInputLen
-
inputStrLen
;
int
restInputLen
=
inputStrLen
<=
0
?
inputStrLen
:
inputStrLen
-
1
;
int
orgFormatLen
g
=
unmodifiedFormatStr
.
length
();
int
currentFormatPos
=
orgFormatLen
g
-
formatStr
.
length
();
int
orgFormatLen
=
unmodifiedFormatStr
.
length
();
int
currentFormatPos
=
orgFormatLen
-
formatStr
.
length
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
format
(
"\n %s('%s', '%s')"
,
functionName
,
unmodifiedInputStr
,
unmodifiedFormatStr
));
sb
.
append
(
format
(
"\n %s^%s , %s^ <-- Parsing failed at this point"
,
//
sb
.
append
(
format
(
"\n %s('%s', '%s')"
,
functionName
,
unmodifiedInputStr
,
unmodifiedFormatStr
));
sb
.
append
(
format
(
"\n %s^%s , %s^ <-- Parsing failed at this point"
,
format
(
"%"
+
(
functionName
.
name
().
length
()
+
currentInputPos
)
+
"s"
,
""
),
restInputLen
g
<=
0
?
""
:
format
(
"%"
+
restInputLeng
+
"s"
,
""
),
restInputLen
<=
0
?
""
:
format
(
"%"
+
restInputLen
+
"s"
,
""
),
currentFormatPos
<=
0
?
""
:
format
(
"%"
+
currentFormatPos
+
"s"
,
""
)));
return
sb
.
toString
();
}
public
static
Timestamp
toTimestamp
(
String
input
,
String
format
)
{
ToDateParser
parser
=
getTimestampParser
(
input
,
format
);
return
parser
.
getResultingTimestamp
();
}
public
static
Timestamp
toDate
(
String
input
,
String
format
)
{
ToDateParser
parser
=
getDateParser
(
input
,
format
);
return
parser
.
getResultingTimestamp
();
}
/**
* The configuration of the date parser.
*/
private
enum
ConfigParam
{
TO_DATE
(
"DD MON YYYY"
),
TO_TIMESTAMP
(
"DD MON YYYY HH:MI:SS"
);
private
final
String
defaultFormatStr
;
ConfigParam
(
String
defaultFormatStr
)
{
this
.
defaultFormatStr
=
defaultFormatStr
;
}
String
getDefaultFormatStr
()
{
return
defaultFormatStr
;
}
}
}
\ No newline at end of file
h2/src/main/org/h2/util/ToDateTokenizer.java
浏览文件 @
19556a3e
差异被折叠。
点击展开。
h2/src/main/org/h2/value/Value.java
浏览文件 @
19556a3e
...
...
@@ -767,7 +767,7 @@ public abstract class Value {
case
TIMESTAMP_UTC:
return
ValueTimestamp
.
fromMillisNanos
(
((
ValueTimestampUtc
)
this
).
getUtcDateTimeMillis
(),
((
ValueTimestampUtc
)
this
).
getNanosSinceLastMilli
());
((
ValueTimestampUtc
)
this
).
getNanosSinceLastMilli
s
());
}
break
;
}
...
...
h2/src/main/org/h2/value/ValueTimestampUtc.java
浏览文件 @
19556a3e
...
...
@@ -110,14 +110,14 @@ public final class ValueTimestampUtc extends Value {
return
utcDateTimeNanos
/
1000
/
1000
;
}
public
int
getNanosSinceLastMilli
()
{
int
getNanosSinceLastMillis
()
{
return
(
int
)
(
utcDateTimeNanos
%
(
1000
*
1000
));
}
@Override
public
java
.
sql
.
Timestamp
getTimestamp
()
{
java
.
sql
.
Timestamp
ts
=
new
java
.
sql
.
Timestamp
(
getUtcDateTimeMillis
());
ts
.
setNanos
(
getNanosSinceLastMilli
());
ts
.
setNanos
(
getNanosSinceLastMilli
s
());
return
ts
;
}
...
...
@@ -157,7 +157,7 @@ public final class ValueTimestampUtc extends Value {
timeNanos
*=
60
;
timeNanos
+=
cal
.
get
(
Calendar
.
MILLISECOND
);
timeNanos
*=
1000
*
1000
;
timeNanos
+=
getNanosSinceLastMilli
();
timeNanos
+=
getNanosSinceLastMilli
s
();
ValueTime
.
appendTime
(
buff
,
timeNanos
,
true
);
buff
.
append
(
" UTC"
);
return
buff
.
toString
();
...
...
h2/src/test/org/h2/samples/ToDate.java
浏览文件 @
19556a3e
...
...
@@ -5,17 +5,14 @@
*/
package
org
.
h2
.
samples
;
import
org.h2.tools.DeleteDbFiles
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.ResultSet
;
import
java.sql.Statement
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Locale
;
import
java.util.TimeZone
;
import
org.h2.tools.DeleteDbFiles
;
/**
* A very simple class that shows how to load the driver, create a database,
...
...
@@ -37,11 +34,20 @@ public class ToDate {
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:~/test"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table ToDateTest(id int primary key, start_date datetime, end_date datetime)"
);
stat
.
execute
(
"insert into ToDateTest values(1, TO_DATE('2015-11-13', 'yyyy-MM-DD'), TO_DATE('2015-12-15', 'YYYY-MM-DD'))"
);
stat
.
execute
(
"insert into ToDateTest values(2, TO_DATE('2015-12-12 00:00:00', 'yyyy-MM-DD HH24:MI:ss'), TO_DATE('2015-12-16 15:00:00', 'YYYY-MM-DD HH24:MI:ss'))"
);
stat
.
execute
(
"insert into ToDateTest values(3, TO_DATE('2015-12-12 08:00 A.M.', 'yyyy-MM-DD HH:MI AM'), TO_DATE('2015-12-17 08:00 P.M.', 'YYYY-MM-DD HH:MI AM'))"
);
stat
.
execute
(
"insert into ToDateTest values(4, TO_DATE(substr('2015-12-12 08:00 A.M.', 1, 10), 'yyyy-MM-DD'), TO_DATE('2015-12-17 08:00 P.M.', 'YYYY-MM-DD HH:MI AM'))"
);
stat
.
execute
(
"create table ToDateTest(id int primary key, "
+
"start_date datetime, end_date datetime)"
);
stat
.
execute
(
"insert into ToDateTest values(1, "
+
"TO_DATE('2015-11-13', 'yyyy-MM-DD'), "
+
"TO_DATE('2015-12-15', 'YYYY-MM-DD'))"
);
stat
.
execute
(
"insert into ToDateTest values(2, "
+
"TO_DATE('2015-12-12 00:00:00', 'yyyy-MM-DD HH24:MI:ss'), "
+
"TO_DATE('2015-12-16 15:00:00', 'YYYY-MM-DD HH24:MI:ss'))"
);
stat
.
execute
(
"insert into ToDateTest values(3, "
+
"TO_DATE('2015-12-12 08:00 A.M.', 'yyyy-MM-DD HH:MI AM'), "
+
"TO_DATE('2015-12-17 08:00 P.M.', 'YYYY-MM-DD HH:MI AM'))"
);
stat
.
execute
(
"insert into ToDateTest values(4, "
+
"TO_DATE(substr('2015-12-12 08:00 A.M.', 1, 10), 'yyyy-MM-DD'), "
+
"TO_DATE('2015-12-17 08:00 P.M.', 'YYYY-MM-DD HH:MI AM'))"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from ToDateTest"
);
while
(
rs
.
next
())
{
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
19556a3e
差异被折叠。
点击展开。
h2/src/test/org/h2/test/db/TestOptimizations.java
浏览文件 @
19556a3e
...
...
@@ -1033,32 +1033,32 @@ public class TestOptimizations extends TestBase {
deleteDb
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE T
BL
_A(id IDENTITY PRIMARY KEY NOT NULL, "
+
stat
.
execute
(
"CREATE TABLE T
ABLE
_A(id IDENTITY PRIMARY KEY NOT NULL, "
+
"name VARCHAR NOT NULL, active BOOLEAN DEFAULT TRUE, "
+
"UNIQUE KEY T
BL
_A_UK (name) )"
);
stat
.
execute
(
"CREATE TABLE T
BL
_B(id IDENTITY PRIMARY KEY NOT NULL, "
+
"
tbl
_a_id BIGINT NOT NULL, createDate TIMESTAMP DEFAULT NOW(), "
+
"UNIQUE KEY T
BL_B_UK (tbl
_a_id, createDate), "
+
"FOREIGN KEY (t
bl_a_id) REFERENCES TBL
_A(id) )"
);
stat
.
execute
(
"INSERT INTO T
BL
_A (name) SELECT 'package_' || CAST(X as VARCHAR) "
+
"UNIQUE KEY T
ABLE
_A_UK (name) )"
);
stat
.
execute
(
"CREATE TABLE T
ABLE
_B(id IDENTITY PRIMARY KEY NOT NULL, "
+
"
TABLE
_a_id BIGINT NOT NULL, createDate TIMESTAMP DEFAULT NOW(), "
+
"UNIQUE KEY T
ABLE_B_UK (table
_a_id, createDate), "
+
"FOREIGN KEY (t
able_a_id) REFERENCES TABLE
_A(id) )"
);
stat
.
execute
(
"INSERT INTO T
ABLE
_A (name) SELECT 'package_' || CAST(X as VARCHAR) "
+
"FROM SYSTEM_RANGE(1, 100) WHERE X <= 100"
);
stat
.
execute
(
"INSERT INTO T
BL_B (tbl
_a_id, createDate) SELECT "
+
"CASE WHEN t
bl_a_id = 0 THEN 1 ELSE tbl
_a_id END, createDate "
+
"FROM ( SELECT ROUND((RAND() * 100)) AS t
bl
_a_id, "
+
stat
.
execute
(
"INSERT INTO T
ABLE_B (table
_a_id, createDate) SELECT "
+
"CASE WHEN t
able_a_id = 0 THEN 1 ELSE table
_a_id END, createDate "
+
"FROM ( SELECT ROUND((RAND() * 100)) AS t
able
_a_id, "
+
"DATEADD('SECOND', X, NOW()) as createDate FROM SYSTEM_RANGE(1, 50000) "
+
"WHERE X < 50000 )"
);
stat
.
execute
(
"CREATE INDEX t
bl_b_idx ON tbl_b(tbl
_a_id, id)"
);
stat
.
execute
(
"CREATE INDEX t
able_b_idx ON table_b(table
_a_id, id)"
);
stat
.
execute
(
"ANALYZE"
);
ResultSet
rs
=
stat
.
executeQuery
(
"EXPLAIN ANALYZE SELECT MAX(b.id) as id "
+
"FROM t
bl_b b JOIN tbl_a a ON b.tbl_a_id = a.id GROUP BY b.tbl
_a_id "
+
"FROM t
able_b b JOIN table_a a ON b.table_a_id = a.id GROUP BY b.table
_a_id "
+
"HAVING A.ACTIVE = TRUE"
);
rs
.
next
();
assertContains
(
rs
.
getString
(
1
),
"/* PUBLIC.T
BL_B_IDX: TBL
_A_ID = A.ID */"
);
assertContains
(
rs
.
getString
(
1
),
"/* PUBLIC.T
ABLE_B_IDX: TABLE
_A_ID = A.ID */"
);
rs
=
stat
.
executeQuery
(
"EXPLAIN ANALYZE SELECT MAX(id) FROM t
bl_b GROUP BY tbl
_a_id"
);
rs
=
stat
.
executeQuery
(
"EXPLAIN ANALYZE SELECT MAX(id) FROM t
able_b GROUP BY table
_a_id"
);
rs
.
next
();
assertContains
(
rs
.
getString
(
1
),
"/* PUBLIC.T
BL
_B_IDX"
);
assertContains
(
rs
.
getString
(
1
),
"/* PUBLIC.T
ABLE
_B_IDX"
);
conn
.
close
();
}
}
h2/src/test/org/h2/test/db/TestTableEngines.java
浏览文件 @
19556a3e
...
...
@@ -351,15 +351,15 @@ public class TestTableEngines extends TestBase {
deleteDb
(
"testQueryExpressionFlag"
);
Connection
conn
=
getConnection
(
"testQueryExpressionFlag"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table QRY_EXPR_TEST(id int) ENGINE \""
+
stat
.
execute
(
"create table Q
UE
RY_EXPR_TEST(id int) ENGINE \""
+
TreeSetIndexTableEngine
.
class
.
getName
()
+
"\""
);
stat
.
execute
(
"create table QRY_EXPR_TEST_NO(id int) ENGINE \""
+
stat
.
execute
(
"create table Q
UE
RY_EXPR_TEST_NO(id int) ENGINE \""
+
TreeSetIndexTableEngine
.
class
.
getName
()
+
"\""
);
stat
.
executeQuery
(
"select 1 + (select 1 from QRY_EXPR_TEST)"
).
next
();
stat
.
executeQuery
(
"select 1 from QRY_EXPR_TEST_NO where id in "
+
"(select id from QRY_EXPR_TEST)"
);
stat
.
executeQuery
(
"select 1 from QRY_EXPR_TEST_NO n "
+
"where exists(select 1 from QRY_EXPR_TEST y where y.id = n.id)"
);
stat
.
executeQuery
(
"select 1 + (select 1 from Q
UE
RY_EXPR_TEST)"
).
next
();
stat
.
executeQuery
(
"select 1 from Q
UE
RY_EXPR_TEST_NO where id in "
+
"(select id from Q
UE
RY_EXPR_TEST)"
);
stat
.
executeQuery
(
"select 1 from Q
UE
RY_EXPR_TEST_NO n "
+
"where exists(select 1 from Q
UE
RY_EXPR_TEST y where y.id = n.id)"
);
deleteDb
(
"testQueryExpressionFlag"
);
}
...
...
@@ -621,7 +621,7 @@ public class TestTableEngines extends TestBase {
setBatchingEnabled
(
stat
,
true
);
List
<
List
<
Object
>>
actual
=
query
(
stat
,
sql
);
if
(!
expected
.
equals
(
actual
))
{
fail
(
"\n
expected: "
+
expected
+
"\n
actual: "
+
actual
);
fail
(
"\n
"
+
"expected: "
+
expected
+
"\n"
+
"
actual: "
+
actual
);
}
}
...
...
@@ -699,10 +699,10 @@ public class TestTableEngines extends TestBase {
private
static
void
setBatchSize
(
TreeSetTable
t
,
int
batchSize
)
{
if
(
t
.
getIndexes
()
==
null
)
{
t
.
scan
.
preferedBatchSize
=
batchSize
;
t
.
scan
.
prefer
r
edBatchSize
=
batchSize
;
}
else
{
for
(
Index
idx
:
t
.
getIndexes
())
{
((
TreeSetIndex
)
idx
).
preferedBatchSize
=
batchSize
;
((
TreeSetIndex
)
idx
).
prefer
r
edBatchSize
=
batchSize
;
}
}
}
...
...
@@ -746,7 +746,7 @@ public class TestTableEngines extends TestBase {
t
>>>=
4
;
}
if
(
where
.
length
()
!=
0
)
{
b
.
append
(
"\nwhere "
).
append
(
where
);
b
.
append
(
"\n
"
+
"
where "
).
append
(
where
);
}
return
b
.
toString
();
...
...
@@ -1313,7 +1313,7 @@ public class TestTableEngines extends TestBase {
static
AtomicInteger
lookupBatches
=
new
AtomicInteger
();
int
preferedBatchSize
;
int
prefer
r
edBatchSize
;
final
TreeSet
<
SearchRow
>
set
=
new
TreeSet
<
SearchRow
>(
this
);
...
...
@@ -1337,8 +1337,8 @@ public class TestTableEngines extends TestBase {
@Override
public
IndexLookupBatch
createLookupBatch
(
final
TableFilter
filter
)
{
assert0
(
filter
.
getMasks
()
!=
null
||
"scan"
.
equals
(
getName
()),
"masks"
);
final
int
prefer
edSize
=
prefe
redBatchSize
;
if
(
preferedSize
==
0
)
{
final
int
prefer
redSize
=
prefer
redBatchSize
;
if
(
prefer
r
edSize
==
0
)
{
return
null
;
}
lookupBatches
.
incrementAndGet
();
...
...
@@ -1351,7 +1351,7 @@ public class TestTableEngines extends TestBase {
}
@Override
public
boolean
isBatchFull
()
{
return
searchRows
.
size
()
>=
preferedSize
*
2
;
return
searchRows
.
size
()
>=
prefer
r
edSize
*
2
;
}
@Override
...
...
@@ -1490,9 +1490,9 @@ public class TestTableEngines extends TestBase {
String
alias
=
alias
(
session
.
getSubQueryInfo
());
assert0
(
alias
.
equals
(
"ZZ"
),
"select expression sub-query: "
+
alias
);
assert0
(
session
.
getSubQueryInfo
().
getUpper
()
==
null
,
"upper"
);
}
else
if
(
getTable
().
getName
().
equals
(
"QRY_EXPR_TEST"
))
{
}
else
if
(
getTable
().
getName
().
equals
(
"Q
UE
RY_EXPR_TEST"
))
{
assert0
(
session
.
isPreparingQueryExpression
(),
"preparing query expression"
);
}
else
if
(
getTable
().
getName
().
equals
(
"QRY_EXPR_TEST_NO"
))
{
}
else
if
(
getTable
().
getName
().
equals
(
"Q
UE
RY_EXPR_TEST_NO"
))
{
assert0
(!
session
.
isPreparingQueryExpression
(),
"not preparing query expression"
);
}
}
...
...
@@ -1588,7 +1588,7 @@ public class TestTableEngines extends TestBase {
@Override
public
String
toString
()
{
return
"IterCursor->"
+
current
;
return
"Iter
ator
Cursor->"
+
current
;
}
}
...
...
h2/src/test/org/h2/test/unit/TestDate.java
浏览文件 @
19556a3e
...
...
@@ -474,7 +474,8 @@ public class TestDate extends TestBase {
assertEquals
(
"-999-08-07 13:14:15.16"
,
ts1a
.
getString
());
assertEquals
(
"19999-08-07 13:14:15.16"
,
ts2a
.
getString
());
// test for bug on Java 1.8.0_60 in "Europe/Moscow" timezone. Doesn't affect most other timezones
// test for bug on Java 1.8.0_60 in "Europe/Moscow" timezone.
// Doesn't affect most other timezones
long
millis
=
1407437460000L
;
long
result1
=
DateTimeUtils
.
nanosFromDate
(
DateTimeUtils
.
getTimeUTCWithoutDst
(
millis
));
long
result2
=
DateTimeUtils
.
nanosFromDate
(
DateTimeUtils
.
getTimeUTCWithoutDst
(
millis
));
...
...
h2/src/test/org/h2/test/unit/TestTimeStampUtc.java
浏览文件 @
19556a3e
...
...
@@ -26,13 +26,13 @@ public class TestTimeStampUtc extends TestBase {
@Override
public
void
test
()
throws
SQLException
{
deleteDb
(
"timestamputc"
);
deleteDb
(
"timestamp
_
utc"
);
test1
();
deleteDb
(
"timestamputc"
);
deleteDb
(
"timestamp
_
utc"
);
}
private
void
test1
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"timestamputc"
);
Connection
conn
=
getConnection
(
"timestamp
_
utc"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id identity, t1 timestamp_utc)"
);
stat
.
execute
(
"insert into test(t1) values(0)"
);
...
...
h2/src/tools/org/h2/build/BuildBase.java
浏览文件 @
19556a3e
...
...
@@ -308,9 +308,9 @@ public class BuildBase {
protected
int
execScript
(
String
script
,
StringList
args
)
{
if
(
isWindows
())
{
// Under windows, we use the "cmd" command interpreter since it will
// search the path for us without us having to hard
code an extensio
n
//
for the script we want. (Sometimes we don't know if the extension
// will be .bat or .cmd)
// search the path for us without us having to hard
-code a
n
//
extension for the script we want. (Sometimes we don't know if the
//
extension
will be .bat or .cmd)
StringList
newArgs
=
new
StringList
();
newArgs
.
add
(
"/C"
);
newArgs
.
add
(
script
);
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
19556a3e
...
...
@@ -778,10 +778,8 @@ dance schedule hitting reverted youngest footers inliner deadlocked reorder nger
nullid syspublic sysibmts sysibminternal syscat sysfun sysstat systools sysibmadm
sysproc jcc expecting gpg showed unreferenced activating cvf stephane lacoin
centrale umr ecole nantes sticc lab reordering preferable simultaneously
--- todo
timestamputc lazily satisfy nexpected messager participating eviction milli globally
futures atp lookups batches slot nnext forced tbl diagnostic filer stamp turn going
nwhere hardcode cancellation qry nprev fetched produced nactual incurring interpreter
batching ncurr prefered fewer runners iter
lazily satisfy participating eviction globally futures batches slot forced
diagnostic filer stamp turn going cancellation fetched produced incurring
interpreter batching fewer runners imperial correspond nine purge meridian
calendars moscow messager lookups unhandled buddha parslet
tzh roc xii tzm viii myydd mar vii
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论