Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7e8fa541
提交
7e8fa541
authored
1月 11, 2016
作者:
Thomas Mueller Graf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Formatting / spellcheck
上级
3d253279
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
465 行增加
和
404 行删除
+465
-404
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
+70
-56
ToDateTokenizer.java
h2/src/main/org/h2/util/ToDateTokenizer.java
+250
-204
Value.java
h2/src/main/org/h2/value/Value.java
+1
-1
ValueTimestampUtc.java
h2/src/main/org/h2/value/ValueTimestampUtc.java
+3
-3
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+77
-69
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
+1
-1
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+5
-7
没有找到文件。
h2/src/main/org/h2/expression/Function.java
浏览文件 @
7e8fa541
...
@@ -44,7 +44,17 @@ import org.h2.table.Table;
...
@@ -44,7 +44,17 @@ import org.h2.table.Table;
import
org.h2.table.TableFilter
;
import
org.h2.table.TableFilter
;
import
org.h2.tools.CompressTool
;
import
org.h2.tools.CompressTool
;
import
org.h2.tools.Csv
;
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.DataType
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
import
org.h2.value.ValueArray
;
import
org.h2.value.ValueArray
;
...
@@ -1424,11 +1434,11 @@ public class Function extends Expression implements FunctionCall {
...
@@ -1424,11 +1434,11 @@ public class Function extends Expression implements FunctionCall {
}
}
break
;
break
;
case
TO_DATE:
case
TO_DATE:
result
=
ValueTimestamp
.
get
(
ToDate
.
TO_DATE
(
v0
.
getString
(),
result
=
ValueTimestamp
.
get
(
ToDate
Parser
.
toDate
(
v0
.
getString
(),
v1
==
null
?
null
:
v1
.
getString
()));
v1
==
null
?
null
:
v1
.
getString
()));
break
;
break
;
case
TO_TIMESTAMP:
case
TO_TIMESTAMP:
result
=
ValueTimestamp
.
get
(
ToDate
.
TO_TIMESTAMP
(
v0
.
getString
(),
result
=
ValueTimestamp
.
get
(
ToDate
Parser
.
toTimestamp
(
v0
.
getString
(),
v1
==
null
?
null
:
v1
.
getString
()));
v1
==
null
?
null
:
v1
.
getString
()));
break
;
break
;
case
TRANSLATE:
{
case
TRANSLATE:
{
...
...
h2/src/main/org/h2/table/JoinBatch.java
浏览文件 @
7e8fa541
...
@@ -410,9 +410,9 @@ public final class JoinBatch {
...
@@ -410,9 +410,9 @@ public final class JoinBatch {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"JoinBatch->\nprev->"
+
(
current
==
null
?
null
:
current
.
prev
)
+
return
"JoinBatch->\n
"
+
"
prev->"
+
(
current
==
null
?
null
:
current
.
prev
)
+
"\ncurr->"
+
current
+
"\n
"
+
"
curr->"
+
current
+
"\nnext->"
+
(
current
==
null
?
null
:
current
.
next
);
"\n
"
+
"
next->"
+
(
current
==
null
?
null
:
current
.
next
);
}
}
/**
/**
...
...
h2/src/main/org/h2/util/DateTimeUtils.java
浏览文件 @
7e8fa541
...
@@ -11,7 +11,10 @@ import java.sql.Date;
...
@@ -11,7 +11,10 @@ import java.sql.Date;
import
java.sql.Time
;
import
java.sql.Time
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.text.SimpleDateFormat
;
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.api.ErrorCode
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
...
...
h2/src/main/org/h2/util/ToDate.java
deleted
100644 → 0
浏览文件 @
3d253279
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
浏览文件 @
7e8fa541
/*
* Copyright 2004-2016 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
;
package
org
.
h2
.
util
;
import
static
java
.
lang
.
String
.
format
;
import
static
java
.
lang
.
String
.
format
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
/**
/**
* Emulates Oracle's TO_DATE function.<br>
* Emulates Oracle's TO_DATE function.<br>
* This class holds and handles the input data form the TO_DATE-method
* 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
unmodifiedInputStr
;
private
final
String
unmodifiedFormatStr
;
private
final
String
unmodifiedFormatStr
;
private
final
ConfigParam
functionName
;
private
final
ConfigParam
functionName
;
private
String
inputStr
;
private
String
inputStr
;
private
String
formatStr
;
private
String
formatStr
;
private
final
Calendar
resultCalendar
=
(
Calendar
)
Calendar
.
getInstance
().
clone
();
private
final
Calendar
resultCalendar
=
(
Calendar
)
Calendar
.
getInstance
().
clone
();
private
Integer
nanos
=
null
;
private
Integer
nanos
;
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
;
}
/**
/**
* @param input the input date with the date-time info
* @param input the input date with the date-time info
* @param format the format of 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 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
// reset calendar - default oracle behaviour
resultCalendar
.
set
(
Calendar
.
YEAR
,
1970
);
resultCalendar
.
set
(
Calendar
.
YEAR
,
1970
);
resultCalendar
.
set
(
Calendar
.
MONTH
,
Calendar
.
getInstance
().
get
(
Calendar
.
MONTH
));
resultCalendar
.
set
(
Calendar
.
MONTH
,
Calendar
.
getInstance
().
get
(
Calendar
.
MONTH
));
...
@@ -65,16 +46,31 @@ class ToDateParser {
...
@@ -65,16 +46,31 @@ class ToDateParser {
this
.
functionName
=
functionName
;
this
.
functionName
=
functionName
;
inputStr
=
input
.
trim
();
inputStr
=
input
.
trim
();
unmodifiedInputStr
=
inputStr
;
// Keep a copy
// Keep a copy
unmodifiedInputStr
=
inputStr
;
if
(
format
==
null
||
format
.
isEmpty
())
{
if
(
format
==
null
||
format
.
isEmpty
())
{
formatStr
=
functionName
.
getDefaultFormatStr
();
// default Oracle format.
// default Oracle format.
formatStr
=
functionName
.
getDefaultFormatStr
();
}
else
{
}
else
{
formatStr
=
format
.
trim
();
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
();
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
);
cal
.
set
(
Calendar
.
MILLISECOND
,
0
);
...
@@ -99,15 +95,15 @@ class ToDateParser {
...
@@ -99,15 +95,15 @@ class ToDateParser {
return
functionName
.
name
();
return
functionName
.
name
();
}
}
void
setNanos
(
final
int
nanos
)
{
void
setNanos
(
int
nanos
)
{
this
.
nanos
=
nanos
;
this
.
nanos
=
nanos
;
}
}
boolean
hasToParseData
()
{
private
boolean
hasToParseData
()
{
return
formatStr
.
length
()
>
0
;
return
formatStr
.
length
()
>
0
;
}
}
void
removeFirstChar
()
{
private
void
removeFirstChar
()
{
if
(!
formatStr
.
isEmpty
())
{
if
(!
formatStr
.
isEmpty
())
{
formatStr
=
formatStr
.
substring
(
1
);
formatStr
=
formatStr
.
substring
(
1
);
}
}
...
@@ -116,7 +112,7 @@ class ToDateParser {
...
@@ -116,7 +112,7 @@ class ToDateParser {
}
}
}
}
private
static
ToDateParser
parse
(
final
ToDateParser
p
)
{
private
static
ToDateParser
parse
(
ToDateParser
p
)
{
while
(
p
.
hasToParseData
())
{
while
(
p
.
hasToParseData
())
{
List
<
ToDateTokenizer
.
FormatTokenEnum
>
tokenList
=
ToDateTokenizer
.
FormatTokenEnum
.
getTokensInQuestion
(
p
.
getFormatStr
());
List
<
ToDateTokenizer
.
FormatTokenEnum
>
tokenList
=
ToDateTokenizer
.
FormatTokenEnum
.
getTokensInQuestion
(
p
.
getFormatStr
());
if
(
tokenList
.
isEmpty
())
{
if
(
tokenList
.
isEmpty
())
{
...
@@ -138,19 +134,9 @@ class ToDateParser {
...
@@ -138,19 +134,9 @@ class ToDateParser {
return
p
;
return
p
;
}
}
void
remove
(
final
String
toIgnore
)
{
void
remove
(
String
inputFragmentStr
,
String
formatFragment
)
{
if
(
toIgnore
!=
null
)
{
if
(
inputFragmentStr
!=
null
&&
inputStr
.
length
()
>=
inputFragmentStr
.
length
())
{
int
trimLeng
=
toIgnore
.
length
();
inputStr
=
inputStr
.
substring
(
inputFragmentStr
.
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
());
}
}
if
(
formatFragment
!=
null
&&
formatStr
.
length
()
>=
formatFragment
.
length
())
{
if
(
formatFragment
!=
null
&&
formatStr
.
length
()
>=
formatFragment
.
length
())
{
formatStr
=
formatStr
.
substring
(
formatFragment
.
length
());
formatStr
=
formatStr
.
substring
(
formatFragment
.
length
());
...
@@ -159,21 +145,49 @@ class ToDateParser {
...
@@ -159,21 +145,49 @@ class ToDateParser {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
int
inputStrLen
g
=
inputStr
.
length
();
int
inputStrLen
=
inputStr
.
length
();
int
orgInputLen
g
=
unmodifiedInputStr
.
length
();
int
orgInputLen
=
unmodifiedInputStr
.
length
();
int
currentInputPos
=
orgInputLen
g
-
inputStrLeng
;
int
currentInputPos
=
orgInputLen
-
inputStrLen
;
int
restInputLen
g
=
inputStrLeng
<=
0
?
inputStrLeng
:
inputStrLeng
-
1
;
int
restInputLen
=
inputStrLen
<=
0
?
inputStrLen
:
inputStrLen
-
1
;
int
orgFormatLen
g
=
unmodifiedFormatStr
.
length
();
int
orgFormatLen
=
unmodifiedFormatStr
.
length
();
int
currentFormatPos
=
orgFormatLen
g
-
formatStr
.
length
();
int
currentFormatPos
=
orgFormatLen
-
formatStr
.
length
();
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
format
(
"\n %s('%s', '%s')"
,
functionName
,
unmodifiedInputStr
,
unmodifiedFormatStr
));
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^ <-- Parsing failed at this point"
,
format
(
"%"
+
(
functionName
.
name
().
length
()
+
currentInputPos
)
+
"s"
,
""
),
format
(
"%"
+
(
functionName
.
name
().
length
()
+
currentInputPos
)
+
"s"
,
""
),
restInputLen
g
<=
0
?
""
:
format
(
"%"
+
restInputLeng
+
"s"
,
""
),
restInputLen
<=
0
?
""
:
format
(
"%"
+
restInputLen
+
"s"
,
""
),
currentFormatPos
<=
0
?
""
:
format
(
"%"
+
currentFormatPos
+
"s"
,
""
)));
currentFormatPos
<=
0
?
""
:
format
(
"%"
+
currentFormatPos
+
"s"
,
""
)));
return
sb
.
toString
();
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
浏览文件 @
7e8fa541
差异被折叠。
点击展开。
h2/src/main/org/h2/value/Value.java
浏览文件 @
7e8fa541
...
@@ -767,7 +767,7 @@ public abstract class Value {
...
@@ -767,7 +767,7 @@ public abstract class Value {
case
TIMESTAMP_UTC:
case
TIMESTAMP_UTC:
return
ValueTimestamp
.
fromMillisNanos
(
return
ValueTimestamp
.
fromMillisNanos
(
((
ValueTimestampUtc
)
this
).
getUtcDateTimeMillis
(),
((
ValueTimestampUtc
)
this
).
getUtcDateTimeMillis
(),
((
ValueTimestampUtc
)
this
).
getNanosSinceLastMilli
());
((
ValueTimestampUtc
)
this
).
getNanosSinceLastMilli
s
());
}
}
break
;
break
;
}
}
...
...
h2/src/main/org/h2/value/ValueTimestampUtc.java
浏览文件 @
7e8fa541
...
@@ -110,14 +110,14 @@ public final class ValueTimestampUtc extends Value {
...
@@ -110,14 +110,14 @@ public final class ValueTimestampUtc extends Value {
return
utcDateTimeNanos
/
1000
/
1000
;
return
utcDateTimeNanos
/
1000
/
1000
;
}
}
public
int
getNanosSinceLastMilli
()
{
int
getNanosSinceLastMillis
()
{
return
(
int
)
(
utcDateTimeNanos
%
(
1000
*
1000
));
return
(
int
)
(
utcDateTimeNanos
%
(
1000
*
1000
));
}
}
@Override
@Override
public
java
.
sql
.
Timestamp
getTimestamp
()
{
public
java
.
sql
.
Timestamp
getTimestamp
()
{
java
.
sql
.
Timestamp
ts
=
new
java
.
sql
.
Timestamp
(
getUtcDateTimeMillis
());
java
.
sql
.
Timestamp
ts
=
new
java
.
sql
.
Timestamp
(
getUtcDateTimeMillis
());
ts
.
setNanos
(
getNanosSinceLastMilli
());
ts
.
setNanos
(
getNanosSinceLastMilli
s
());
return
ts
;
return
ts
;
}
}
...
@@ -157,7 +157,7 @@ public final class ValueTimestampUtc extends Value {
...
@@ -157,7 +157,7 @@ public final class ValueTimestampUtc extends Value {
timeNanos
*=
60
;
timeNanos
*=
60
;
timeNanos
+=
cal
.
get
(
Calendar
.
MILLISECOND
);
timeNanos
+=
cal
.
get
(
Calendar
.
MILLISECOND
);
timeNanos
*=
1000
*
1000
;
timeNanos
*=
1000
*
1000
;
timeNanos
+=
getNanosSinceLastMilli
();
timeNanos
+=
getNanosSinceLastMilli
s
();
ValueTime
.
appendTime
(
buff
,
timeNanos
,
true
);
ValueTime
.
appendTime
(
buff
,
timeNanos
,
true
);
buff
.
append
(
" UTC"
);
buff
.
append
(
" UTC"
);
return
buff
.
toString
();
return
buff
.
toString
();
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
7e8fa541
差异被折叠。
点击展开。
h2/src/test/org/h2/test/db/TestOptimizations.java
浏览文件 @
7e8fa541
...
@@ -1033,32 +1033,32 @@ public class TestOptimizations extends TestBase {
...
@@ -1033,32 +1033,32 @@ public class TestOptimizations extends TestBase {
deleteDb
(
"optimizations"
);
deleteDb
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Statement
stat
=
conn
.
createStatement
();
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, "
+
"name VARCHAR NOT NULL, active BOOLEAN DEFAULT TRUE, "
+
"UNIQUE KEY T
BL
_A_UK (name) )"
);
"UNIQUE KEY T
ABLE
_A_UK (name) )"
);
stat
.
execute
(
"CREATE TABLE T
BL
_B(id IDENTITY PRIMARY KEY NOT NULL, "
+
stat
.
execute
(
"CREATE TABLE T
ABLE
_B(id IDENTITY PRIMARY KEY NOT NULL, "
+
"
tbl
_a_id BIGINT NOT NULL, createDate TIMESTAMP DEFAULT NOW(), "
+
"
TABLE
_a_id BIGINT NOT NULL, createDate TIMESTAMP DEFAULT NOW(), "
+
"UNIQUE KEY T
BL_B_UK (tbl
_a_id, createDate), "
+
"UNIQUE KEY T
ABLE_B_UK (table
_a_id, createDate), "
+
"FOREIGN KEY (t
bl_a_id) REFERENCES TBL
_A(id) )"
);
"FOREIGN KEY (t
able_a_id) REFERENCES TABLE
_A(id) )"
);
stat
.
execute
(
"INSERT INTO T
BL
_A (name) SELECT 'package_' || CAST(X as VARCHAR) "
+
stat
.
execute
(
"INSERT INTO T
ABLE
_A (name) SELECT 'package_' || CAST(X as VARCHAR) "
+
"FROM SYSTEM_RANGE(1, 100) WHERE X <= 100"
);
"FROM SYSTEM_RANGE(1, 100) WHERE X <= 100"
);
stat
.
execute
(
"INSERT INTO T
BL_B (tbl
_a_id, createDate) SELECT "
+
stat
.
execute
(
"INSERT INTO T
ABLE_B (table
_a_id, createDate) SELECT "
+
"CASE WHEN t
bl_a_id = 0 THEN 1 ELSE tbl
_a_id END, createDate "
+
"CASE WHEN t
able_a_id = 0 THEN 1 ELSE table
_a_id END, createDate "
+
"FROM ( SELECT ROUND((RAND() * 100)) AS t
bl
_a_id, "
+
"FROM ( SELECT ROUND((RAND() * 100)) AS t
able
_a_id, "
+
"DATEADD('SECOND', X, NOW()) as createDate FROM SYSTEM_RANGE(1, 50000) "
+
"DATEADD('SECOND', X, NOW()) as createDate FROM SYSTEM_RANGE(1, 50000) "
+
"WHERE X < 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"
);
stat
.
execute
(
"ANALYZE"
);
ResultSet
rs
=
stat
.
executeQuery
(
"EXPLAIN ANALYZE SELECT MAX(b.id) as id "
+
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"
);
"HAVING A.ACTIVE = TRUE"
);
rs
.
next
();
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
();
rs
.
next
();
assertContains
(
rs
.
getString
(
1
),
"/* PUBLIC.T
BL
_B_IDX"
);
assertContains
(
rs
.
getString
(
1
),
"/* PUBLIC.T
ABLE
_B_IDX"
);
conn
.
close
();
conn
.
close
();
}
}
}
}
h2/src/test/org/h2/test/db/TestTableEngines.java
浏览文件 @
7e8fa541
...
@@ -351,15 +351,15 @@ public class TestTableEngines extends TestBase {
...
@@ -351,15 +351,15 @@ public class TestTableEngines extends TestBase {
deleteDb
(
"testQueryExpressionFlag"
);
deleteDb
(
"testQueryExpressionFlag"
);
Connection
conn
=
getConnection
(
"testQueryExpressionFlag"
);
Connection
conn
=
getConnection
(
"testQueryExpressionFlag"
);
Statement
stat
=
conn
.
createStatement
();
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
()
+
"\""
);
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
()
+
"\""
);
TreeSetIndexTableEngine
.
class
.
getName
()
+
"\""
);
stat
.
executeQuery
(
"select 1 + (select 1 from QRY_EXPR_TEST)"
).
next
();
stat
.
executeQuery
(
"select 1 + (select 1 from Q
UE
RY_EXPR_TEST)"
).
next
();
stat
.
executeQuery
(
"select 1 from QRY_EXPR_TEST_NO where id in "
stat
.
executeQuery
(
"select 1 from Q
UE
RY_EXPR_TEST_NO where id in "
+
"(select id from QRY_EXPR_TEST)"
);
+
"(select id from Q
UE
RY_EXPR_TEST)"
);
stat
.
executeQuery
(
"select 1 from QRY_EXPR_TEST_NO n "
stat
.
executeQuery
(
"select 1 from Q
UE
RY_EXPR_TEST_NO n "
+
"where exists(select 1 from QRY_EXPR_TEST y where y.id = n.id)"
);
+
"where exists(select 1 from Q
UE
RY_EXPR_TEST y where y.id = n.id)"
);
deleteDb
(
"testQueryExpressionFlag"
);
deleteDb
(
"testQueryExpressionFlag"
);
}
}
...
@@ -621,7 +621,7 @@ public class TestTableEngines extends TestBase {
...
@@ -621,7 +621,7 @@ public class TestTableEngines extends TestBase {
setBatchingEnabled
(
stat
,
true
);
setBatchingEnabled
(
stat
,
true
);
List
<
List
<
Object
>>
actual
=
query
(
stat
,
sql
);
List
<
List
<
Object
>>
actual
=
query
(
stat
,
sql
);
if
(!
expected
.
equals
(
actual
))
{
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 {
...
@@ -699,10 +699,10 @@ public class TestTableEngines extends TestBase {
private
static
void
setBatchSize
(
TreeSetTable
t
,
int
batchSize
)
{
private
static
void
setBatchSize
(
TreeSetTable
t
,
int
batchSize
)
{
if
(
t
.
getIndexes
()
==
null
)
{
if
(
t
.
getIndexes
()
==
null
)
{
t
.
scan
.
preferedBatchSize
=
batchSize
;
t
.
scan
.
prefer
r
edBatchSize
=
batchSize
;
}
else
{
}
else
{
for
(
Index
idx
:
t
.
getIndexes
())
{
for
(
Index
idx
:
t
.
getIndexes
())
{
((
TreeSetIndex
)
idx
).
preferedBatchSize
=
batchSize
;
((
TreeSetIndex
)
idx
).
prefer
r
edBatchSize
=
batchSize
;
}
}
}
}
}
}
...
@@ -746,7 +746,7 @@ public class TestTableEngines extends TestBase {
...
@@ -746,7 +746,7 @@ public class TestTableEngines extends TestBase {
t
>>>=
4
;
t
>>>=
4
;
}
}
if
(
where
.
length
()
!=
0
)
{
if
(
where
.
length
()
!=
0
)
{
b
.
append
(
"\nwhere "
).
append
(
where
);
b
.
append
(
"\n
"
+
"
where "
).
append
(
where
);
}
}
return
b
.
toString
();
return
b
.
toString
();
...
@@ -1313,7 +1313,7 @@ public class TestTableEngines extends TestBase {
...
@@ -1313,7 +1313,7 @@ public class TestTableEngines extends TestBase {
static
AtomicInteger
lookupBatches
=
new
AtomicInteger
();
static
AtomicInteger
lookupBatches
=
new
AtomicInteger
();
int
preferedBatchSize
;
int
prefer
r
edBatchSize
;
final
TreeSet
<
SearchRow
>
set
=
new
TreeSet
<
SearchRow
>(
this
);
final
TreeSet
<
SearchRow
>
set
=
new
TreeSet
<
SearchRow
>(
this
);
...
@@ -1337,8 +1337,8 @@ public class TestTableEngines extends TestBase {
...
@@ -1337,8 +1337,8 @@ public class TestTableEngines extends TestBase {
@Override
@Override
public
IndexLookupBatch
createLookupBatch
(
final
TableFilter
filter
)
{
public
IndexLookupBatch
createLookupBatch
(
final
TableFilter
filter
)
{
assert0
(
filter
.
getMasks
()
!=
null
||
"scan"
.
equals
(
getName
()),
"masks"
);
assert0
(
filter
.
getMasks
()
!=
null
||
"scan"
.
equals
(
getName
()),
"masks"
);
final
int
prefer
edSize
=
prefe
redBatchSize
;
final
int
prefer
redSize
=
prefer
redBatchSize
;
if
(
preferedSize
==
0
)
{
if
(
prefer
r
edSize
==
0
)
{
return
null
;
return
null
;
}
}
lookupBatches
.
incrementAndGet
();
lookupBatches
.
incrementAndGet
();
...
@@ -1351,7 +1351,7 @@ public class TestTableEngines extends TestBase {
...
@@ -1351,7 +1351,7 @@ public class TestTableEngines extends TestBase {
}
}
@Override
public
boolean
isBatchFull
()
{
@Override
public
boolean
isBatchFull
()
{
return
searchRows
.
size
()
>=
preferedSize
*
2
;
return
searchRows
.
size
()
>=
prefer
r
edSize
*
2
;
}
}
@Override
@Override
...
@@ -1490,9 +1490,9 @@ public class TestTableEngines extends TestBase {
...
@@ -1490,9 +1490,9 @@ public class TestTableEngines extends TestBase {
String
alias
=
alias
(
session
.
getSubQueryInfo
());
String
alias
=
alias
(
session
.
getSubQueryInfo
());
assert0
(
alias
.
equals
(
"ZZ"
),
"select expression sub-query: "
+
alias
);
assert0
(
alias
.
equals
(
"ZZ"
),
"select expression sub-query: "
+
alias
);
assert0
(
session
.
getSubQueryInfo
().
getUpper
()
==
null
,
"upper"
);
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"
);
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"
);
assert0
(!
session
.
isPreparingQueryExpression
(),
"not preparing query expression"
);
}
}
}
}
...
@@ -1588,7 +1588,7 @@ public class TestTableEngines extends TestBase {
...
@@ -1588,7 +1588,7 @@ public class TestTableEngines extends TestBase {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"IterCursor->"
+
current
;
return
"Iter
ator
Cursor->"
+
current
;
}
}
}
}
...
...
h2/src/test/org/h2/test/unit/TestDate.java
浏览文件 @
7e8fa541
...
@@ -474,7 +474,8 @@ public class TestDate extends TestBase {
...
@@ -474,7 +474,8 @@ public class TestDate extends TestBase {
assertEquals
(
"-999-08-07 13:14:15.16"
,
ts1a
.
getString
());
assertEquals
(
"-999-08-07 13:14:15.16"
,
ts1a
.
getString
());
assertEquals
(
"19999-08-07 13:14:15.16"
,
ts2a
.
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
millis
=
1407437460000L
;
long
result1
=
DateTimeUtils
.
nanosFromDate
(
DateTimeUtils
.
getTimeUTCWithoutDst
(
millis
));
long
result1
=
DateTimeUtils
.
nanosFromDate
(
DateTimeUtils
.
getTimeUTCWithoutDst
(
millis
));
long
result2
=
DateTimeUtils
.
nanosFromDate
(
DateTimeUtils
.
getTimeUTCWithoutDst
(
millis
));
long
result2
=
DateTimeUtils
.
nanosFromDate
(
DateTimeUtils
.
getTimeUTCWithoutDst
(
millis
));
...
...
h2/src/test/org/h2/test/unit/TestTimeStampUtc.java
浏览文件 @
7e8fa541
...
@@ -26,13 +26,13 @@ public class TestTimeStampUtc extends TestBase {
...
@@ -26,13 +26,13 @@ public class TestTimeStampUtc extends TestBase {
@Override
@Override
public
void
test
()
throws
SQLException
{
public
void
test
()
throws
SQLException
{
deleteDb
(
"timestamputc"
);
deleteDb
(
"timestamp
_
utc"
);
test1
();
test1
();
deleteDb
(
"timestamputc"
);
deleteDb
(
"timestamp
_
utc"
);
}
}
private
void
test1
()
throws
SQLException
{
private
void
test1
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"timestamputc"
);
Connection
conn
=
getConnection
(
"timestamp
_
utc"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id identity, t1 timestamp_utc)"
);
stat
.
execute
(
"create table test(id identity, t1 timestamp_utc)"
);
stat
.
execute
(
"insert into test(t1) values(0)"
);
stat
.
execute
(
"insert into test(t1) values(0)"
);
...
...
h2/src/tools/org/h2/build/BuildBase.java
浏览文件 @
7e8fa541
...
@@ -308,7 +308,7 @@ public class BuildBase {
...
@@ -308,7 +308,7 @@ public class BuildBase {
protected
int
execScript
(
String
script
,
StringList
args
)
{
protected
int
execScript
(
String
script
,
StringList
args
)
{
if
(
isWindows
())
{
if
(
isWindows
())
{
// Under windows, we use the "cmd" command interpreter since it will
// Under windows, we use the "cmd" command interpreter since it will
// search the path for us without us having to hardcode an extension
// search the path for us without us having to hard
-
code an extension
// for the script we want. (Sometimes we don't know if the extension
// for the script we want. (Sometimes we don't know if the extension
// will be .bat or .cmd)
// will be .bat or .cmd)
StringList
newArgs
=
new
StringList
();
StringList
newArgs
=
new
StringList
();
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
7e8fa541
...
@@ -778,10 +778,8 @@ dance schedule hitting reverted youngest footers inliner deadlocked reorder nger
...
@@ -778,10 +778,8 @@ dance schedule hitting reverted youngest footers inliner deadlocked reorder nger
nullid syspublic sysibmts sysibminternal syscat sysfun sysstat systools sysibmadm
nullid syspublic sysibmts sysibminternal syscat sysfun sysstat systools sysibmadm
sysproc jcc expecting gpg showed unreferenced activating cvf stephane lacoin
sysproc jcc expecting gpg showed unreferenced activating cvf stephane lacoin
centrale umr ecole nantes sticc lab reordering preferable simultaneously
centrale umr ecole nantes sticc lab reordering preferable simultaneously
lazily satisfy participating eviction globally futures batches slot forced
--- todo
diagnostic filer stamp turn going cancellation fetched produced incurring
interpreter batching fewer runners imperial correspond nine purge meridian
timestamputc lazily satisfy nexpected messager participating eviction milli globally
calendars moscow messager lookups unhandled buddha parslet
futures atp lookups batches slot nnext forced tbl diagnostic filer stamp turn going
tzh roc xii tzm viii myydd mar vii
nwhere hardcode cancellation qry nprev fetched produced nactual incurring interpreter
batching ncurr prefered fewer runners iter
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论