Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d6cebc3f
Unverified
提交
d6cebc3f
authored
12月 11, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
12月 11, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1595 from katzyn/misc
DBSettings.optimizeIsNull removal and other minor changes
上级
79f5d819
f2c0abba
显示空白字符变更
内嵌
并排
正在显示
17 个修改的文件
包含
67 行增加
和
69 行删除
+67
-69
help.csv
h2/src/docsrc/help/help.csv
+2
-0
changelog.html
h2/src/docsrc/html/changelog.html
+14
-0
CurrentTimestamp.class
h2/src/java9/precompiled/org/h2/util/CurrentTimestamp.class
+0
-0
CurrentTimestamp.java
h2/src/java9/src/org/h2/util/CurrentTimestamp.java
+1
-1
DbSettings.java
h2/src/main/org/h2/engine/DbSettings.java
+0
-6
Comparison.java
h2/src/main/org/h2/expression/condition/Comparison.java
+2
-6
IndexCursor.java
h2/src/main/org/h2/index/IndexCursor.java
+5
-23
DateTimeUtils.java
h2/src/main/org/h2/util/DateTimeUtils.java
+13
-15
StringUtils.java
h2/src/main/org/h2/util/StringUtils.java
+3
-2
Value.java
h2/src/main/org/h2/value/Value.java
+3
-1
ValueDate.java
h2/src/main/org/h2/value/ValueDate.java
+3
-2
ValueTime.java
h2/src/main/org/h2/value/ValueTime.java
+3
-2
ValueTimestamp.java
h2/src/main/org/h2/value/ValueTimestamp.java
+9
-6
TestDate.java
h2/src/test/org/h2/test/unit/TestDate.java
+4
-2
TestDateTimeUtils.java
h2/src/test/org/h2/test/unit/TestDateTimeUtils.java
+3
-2
GenerateHelp.java
h2/src/tools/org/h2/build/doc/GenerateHelp.java
+1
-1
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+1
-0
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
d6cebc3f
...
...
@@ -4816,10 +4816,12 @@ When converting a number to binary, the number of bytes matches the precision.
When converting a string to binary, it is hex encoded (every byte two characters);
a hex string can be converted to a number by first converting it to binary.
If a direct conversion is not possible, the value is first converted to a string.
Note that some data types may need explicitly specified precision to avoid overflow or rounding.
","
CAST(NAME AS INT);
CAST(65535 AS BINARY);
CAST(CAST('FFFF' AS BINARY) AS INT);
CAST(TIMESTAMP '2010-01-01 10:40:00.123456' AS TIME(6))
"
"Functions (System)","COALESCE","
...
...
h2/src/docsrc/html/changelog.html
浏览文件 @
d6cebc3f
...
...
@@ -21,8 +21,22 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<ul>
<li>
Issue #1594: DBSettings.optimizeIsNull and dead code in IndexCursor.getMax()
</li>
<li>
PR #1591: Use multi-catch java 7 language construction to simplify code
</li>
<li>
Issue #1582: h2 not using best index for
>
=
</li>
<li>
PR #1588: Add support for java.time.Period
</li>
<li>
Issue #446: FILE_READ from classpath not working because of 0 byte file length
</li>
<li>
PR #1579: fix unintentional append mode disruption
</li>
<li>
Issue #1573: DELETE FROM w/ ROWNUM and subquery
</li>
<li>
Issue #187: SHUTDOWN DEFRAG corrupts splitted file database
</li>
<li>
PR #1571: Optimizing ConditionAndOr queries
</li>
<li>
Issue #1565: SOME / ANY conflict
...
...
h2/src/java9/precompiled/org/h2/util/CurrentTimestamp.class
浏览文件 @
d6cebc3f
No preview for this file type
h2/src/java9/src/org/h2/util/CurrentTimestamp.java
浏览文件 @
d6cebc3f
...
...
@@ -25,7 +25,7 @@ public final class CurrentTimestamp {
* epoch and time zone offsets with seconds because such support is not
* required for current dates.
*/
int
offsetSec
=
DateTimeUtils
.
getTimeZone
().
get
Offset
(
second
*
1_000
+
nano
/
1_000_000
)
/
1000
;
int
offsetSec
=
DateTimeUtils
.
getTimeZoneOffset
(
second
*
1_000
+
nano
/
1_000_000
)
/
1000
;
second
+=
offsetSec
;
return
ValueTimestampTimeZone
.
fromDateValueAndNanos
(
DateTimeUtils
.
dateValueFromAbsoluteDay
(
second
/
DateTimeUtils
.
SECONDS_PER_DAY
),
...
...
h2/src/main/org/h2/engine/DbSettings.java
浏览文件 @
d6cebc3f
...
...
@@ -206,12 +206,6 @@ public class DbSettings extends SettingsBase {
*/
public
final
boolean
optimizeInSelect
=
get
(
"OPTIMIZE_IN_SELECT"
,
true
);
/**
* Database setting <code>OPTIMIZE_IS_NULL</code> (default: false).<br />
* Use an index for condition of the form columnName IS NULL.
*/
public
final
boolean
optimizeIsNull
=
get
(
"OPTIMIZE_IS_NULL"
,
true
);
/**
* Database setting <code>OPTIMIZE_OR</code> (default: true).<br />
* Convert (C=? OR C=?) to (C IN(?, ?)).
...
...
h2/src/main/org/h2/expression/condition/Comparison.java
浏览文件 @
d6cebc3f
...
...
@@ -397,12 +397,8 @@ public class Comparison extends Condition {
if
(
l
!=
null
)
{
switch
(
compareType
)
{
case
IS_NULL:
if
(
session
.
getDatabase
().
getSettings
().
optimizeIsNull
)
{
filter
.
addIndexCondition
(
IndexCondition
.
get
(
Comparison
.
EQUAL_NULL_SAFE
,
l
,
ValueExpression
.
getNull
()));
}
IndexCondition
.
get
(
Comparison
.
EQUAL_NULL_SAFE
,
l
,
ValueExpression
.
getNull
()));
}
}
return
;
...
...
h2/src/main/org/h2/index/IndexCursor.java
浏览文件 @
d6cebc3f
...
...
@@ -33,7 +33,6 @@ import org.h2.value.ValueNull;
*/
public
class
IndexCursor
implements
Cursor
{
private
Session
session
;
private
final
TableFilter
tableFilter
;
private
Index
index
;
private
Table
table
;
...
...
@@ -75,7 +74,6 @@ public class IndexCursor implements Cursor {
* @param indexConditions Index conditions.
*/
public
void
prepare
(
Session
s
,
ArrayList
<
IndexCondition
>
indexConditions
)
{
this
.
session
=
s
;
alwaysFalse
=
false
;
start
=
end
=
null
;
inList
=
null
;
...
...
@@ -142,14 +140,6 @@ public class IndexCursor implements Cursor {
inList
=
null
;
inResult
=
null
;
}
if
(!
session
.
getDatabase
().
getSettings
().
optimizeIsNull
)
{
if
(
isStart
&&
isEnd
)
{
if
(
v
==
ValueNull
.
INSTANCE
)
{
// join on a column=NULL is always false
alwaysFalse
=
true
;
}
}
}
}
}
if
(
inColumn
!=
null
)
{
...
...
@@ -239,24 +229,16 @@ public class IndexCursor implements Cursor {
}
else
if
(
b
==
null
)
{
return
a
;
}
if
(
session
.
getDatabase
().
getSettings
().
optimizeIsNull
)
{
// IS NULL must be checked later
if
(
a
==
ValueNull
.
INSTANCE
)
{
return
b
;
}
else
if
(
b
==
ValueNull
.
INSTANCE
)
{
return
a
;
}
}
int
comp
=
table
.
getDatabase
().
compare
(
a
,
b
);
if
(
comp
==
0
)
{
return
a
;
}
if
(
a
==
ValueNull
.
INSTANCE
||
b
==
ValueNull
.
INSTANCE
)
{
if
(
session
.
getDatabase
().
getSettings
().
optimizeIsNull
)
{
// column IS NULL AND column <op> <not null> is always false
return
null
;
}
}
return
(
comp
>
0
)
==
bigger
?
a
:
b
;
}
...
...
h2/src/main/org/h2/util/DateTimeUtils.java
浏览文件 @
d6cebc3f
...
...
@@ -122,16 +122,17 @@ public class DateTimeUtils {
}
/**
* Returns local time zone.
* Returns local time zone
offset for a specified timestamp
.
*
* @return local time zone
* @param ms milliseconds since Epoch in UTC
* @return local time zone offset
*/
static
TimeZone
getTimeZone
(
)
{
public
static
int
getTimeZoneOffset
(
long
ms
)
{
TimeZone
tz
=
timeZone
;
if
(
tz
==
null
)
{
timeZone
=
tz
=
TimeZone
.
getDefault
();
}
return
tz
;
return
tz
.
getOffset
(
ms
)
;
}
/**
...
...
@@ -568,8 +569,9 @@ public class DateTimeUtils {
}
}
else
{
long
millis
=
convertDateTimeValueToMillis
(
tz
,
dateValue
,
nanos
/
1_000_000
);
dateValue
=
dateValueFromDate
(
millis
);
nanos
=
nanos
%
1_000_000
+
nanosFromDate
(
millis
);
millis
+=
getTimeZoneOffset
(
millis
);
dateValue
=
dateValueFromLocalMillis
(
millis
);
nanos
=
nanos
%
1_000_000
+
nanosFromLocalMillis
(
millis
);
}
}
}
...
...
@@ -1119,14 +1121,12 @@ public class DateTimeUtils {
}
/**
* Convert a UTC datetime in millis to an encoded date in the default
* timezone.
* Convert a local datetime in millis to an encoded date.
*
* @param ms the milliseconds
* @return the date value
*/
public
static
long
dateValueFromDate
(
long
ms
)
{
ms
+=
getTimeZone
().
getOffset
(
ms
);
public
static
long
dateValueFromLocalMillis
(
long
ms
)
{
long
absoluteDay
=
ms
/
MILLIS_PER_DAY
;
// Round toward negative infinity
if
(
ms
<
0
&&
(
absoluteDay
*
MILLIS_PER_DAY
!=
ms
))
{
...
...
@@ -1152,14 +1152,12 @@ public class DateTimeUtils {
}
/**
* Convert a time in milliseconds in UTC to the nanoseconds since midnight
* (in the default timezone).
* Convert a time in milliseconds in local time to the nanoseconds since midnight.
*
* @param ms the milliseconds
* @return the nanoseconds
*/
public
static
long
nanosFromDate
(
long
ms
)
{
ms
+=
getTimeZone
().
getOffset
(
ms
);
public
static
long
nanosFromLocalMillis
(
long
ms
)
{
long
absoluteDay
=
ms
/
MILLIS_PER_DAY
;
// Round toward negative infinity
if
(
ms
<
0
&&
(
absoluteDay
*
MILLIS_PER_DAY
!=
ms
))
{
...
...
@@ -1236,7 +1234,7 @@ public class DateTimeUtils {
* @return timestamp with time zone with specified value and current time zone
*/
public
static
ValueTimestampTimeZone
timestampTimeZoneFromMillis
(
long
ms
)
{
int
offset
=
getTimeZone
().
get
Offset
(
ms
);
int
offset
=
getTimeZoneOffset
(
ms
);
ms
+=
offset
;
long
absoluteDay
=
ms
/
MILLIS_PER_DAY
;
// Round toward negative infinity
...
...
h2/src/main/org/h2/util/StringUtils.java
浏览文件 @
d6cebc3f
...
...
@@ -242,8 +242,9 @@ public class StringUtils {
*/
public
static
String
addAsterisk
(
String
s
,
int
index
)
{
if
(
s
!=
null
)
{
index
=
Math
.
min
(
index
,
s
.
length
());
s
=
s
.
substring
(
0
,
index
)
+
"[*]"
+
s
.
substring
(
index
);
int
len
=
s
.
length
();
index
=
Math
.
min
(
index
,
len
);
s
=
new
StringBuilder
(
len
+
3
).
append
(
s
,
0
,
index
).
append
(
"[*]"
).
append
(
s
,
index
,
len
).
toString
();
}
return
s
;
}
...
...
h2/src/main/org/h2/value/Value.java
浏览文件 @
d6cebc3f
...
...
@@ -1043,7 +1043,9 @@ public abstract class Value {
ValueTimestampTimeZone
ts
=
(
ValueTimestampTimeZone
)
this
;
long
dateValue
=
ts
.
getDateValue
(),
timeNanos
=
ts
.
getTimeNanos
();
long
millis
=
DateTimeUtils
.
getMillis
(
dateValue
,
timeNanos
,
ts
.
getTimeZoneOffsetMins
());
return
ValueTime
.
fromNanos
(
DateTimeUtils
.
nanosFromDate
(
millis
)
+
timeNanos
%
1_000_000
);
return
ValueTime
.
fromNanos
(
DateTimeUtils
.
nanosFromLocalMillis
(
millis
+
DateTimeUtils
.
getTimeZoneOffset
(
millis
))
+
timeNanos
%
1_000_000
);
}
case
ENUM:
throw
getDataConversionError
(
TIME
);
...
...
h2/src/main/org/h2/value/ValueDate.java
浏览文件 @
d6cebc3f
...
...
@@ -47,7 +47,8 @@ public class ValueDate extends Value {
* @return the value
*/
public
static
ValueDate
get
(
Date
date
)
{
return
fromDateValue
(
DateTimeUtils
.
dateValueFromDate
(
date
.
getTime
()));
long
ms
=
date
.
getTime
();
return
fromDateValue
(
DateTimeUtils
.
dateValueFromLocalMillis
(
ms
+
DateTimeUtils
.
getTimeZoneOffset
(
ms
)));
}
/**
...
...
@@ -58,7 +59,7 @@ public class ValueDate extends Value {
* @return the value
*/
public
static
ValueDate
fromMillis
(
long
ms
)
{
return
fromDateValue
(
DateTimeUtils
.
dateValueFrom
Date
(
ms
));
return
fromDateValue
(
DateTimeUtils
.
dateValueFrom
LocalMillis
(
ms
+
DateTimeUtils
.
getTimeZoneOffset
(
ms
)
));
}
/**
...
...
h2/src/main/org/h2/value/ValueTime.java
浏览文件 @
d6cebc3f
...
...
@@ -84,7 +84,8 @@ public class ValueTime extends Value {
* @return the value
*/
public
static
ValueTime
get
(
Time
time
)
{
return
fromNanos
(
DateTimeUtils
.
nanosFromDate
(
time
.
getTime
()));
long
ms
=
time
.
getTime
();
return
fromNanos
(
DateTimeUtils
.
nanosFromLocalMillis
(
ms
+
DateTimeUtils
.
getTimeZoneOffset
(
ms
)));
}
/**
...
...
@@ -95,7 +96,7 @@ public class ValueTime extends Value {
* @return the value
*/
public
static
ValueTime
fromMillis
(
long
ms
)
{
return
fromNanos
(
DateTimeUtils
.
nanosFrom
Date
(
ms
));
return
fromNanos
(
DateTimeUtils
.
nanosFrom
LocalMillis
(
ms
+
DateTimeUtils
.
getTimeZoneOffset
(
ms
)
));
}
/**
...
...
h2/src/main/org/h2/value/ValueTimestamp.java
浏览文件 @
d6cebc3f
...
...
@@ -89,8 +89,9 @@ public class ValueTimestamp extends Value {
public
static
ValueTimestamp
get
(
Timestamp
timestamp
)
{
long
ms
=
timestamp
.
getTime
();
long
nanos
=
timestamp
.
getNanos
()
%
1_000_000
;
long
dateValue
=
DateTimeUtils
.
dateValueFromDate
(
ms
);
nanos
+=
DateTimeUtils
.
nanosFromDate
(
ms
);
ms
+=
DateTimeUtils
.
getTimeZoneOffset
(
ms
);
long
dateValue
=
DateTimeUtils
.
dateValueFromLocalMillis
(
ms
);
nanos
+=
DateTimeUtils
.
nanosFromLocalMillis
(
ms
);
return
fromDateValueAndNanos
(
dateValue
,
nanos
);
}
...
...
@@ -102,8 +103,9 @@ public class ValueTimestamp extends Value {
* @return the value
*/
public
static
ValueTimestamp
fromMillisNanos
(
long
ms
,
int
nanos
)
{
long
dateValue
=
DateTimeUtils
.
dateValueFromDate
(
ms
);
long
timeNanos
=
nanos
+
DateTimeUtils
.
nanosFromDate
(
ms
);
ms
+=
DateTimeUtils
.
getTimeZoneOffset
(
ms
);
long
dateValue
=
DateTimeUtils
.
dateValueFromLocalMillis
(
ms
);
long
timeNanos
=
nanos
+
DateTimeUtils
.
nanosFromLocalMillis
(
ms
);
return
fromDateValueAndNanos
(
dateValue
,
timeNanos
);
}
...
...
@@ -114,8 +116,9 @@ public class ValueTimestamp extends Value {
* @return the value
*/
public
static
ValueTimestamp
fromMillis
(
long
ms
)
{
long
dateValue
=
DateTimeUtils
.
dateValueFromDate
(
ms
);
long
nanos
=
DateTimeUtils
.
nanosFromDate
(
ms
);
ms
+=
DateTimeUtils
.
getTimeZoneOffset
(
ms
);
long
dateValue
=
DateTimeUtils
.
dateValueFromLocalMillis
(
ms
);
long
nanos
=
DateTimeUtils
.
nanosFromLocalMillis
(
ms
);
return
fromDateValueAndNanos
(
dateValue
,
nanos
);
}
...
...
h2/src/test/org/h2/test/unit/TestDate.java
浏览文件 @
d6cebc3f
...
...
@@ -462,8 +462,10 @@ public class TestDate extends TestBase {
// 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
));
long
ms
=
DateTimeUtils
.
getTimeUTCWithoutDst
(
millis
);
ms
+=
DateTimeUtils
.
getTimeZoneOffset
(
ms
);
long
result1
=
DateTimeUtils
.
nanosFromLocalMillis
(
ms
);
long
result2
=
DateTimeUtils
.
nanosFromLocalMillis
(
ms
);
assertEquals
(
result1
,
result2
);
}
...
...
h2/src/test/org/h2/test/unit/TestDateTimeUtils.java
浏览文件 @
d6cebc3f
...
...
@@ -159,8 +159,9 @@ public class TestDateTimeUtils extends TestBase {
gc
.
set
(
year
,
month
-
1
,
day
,
j
/
2
,
(
j
&
1
)
*
30
,
0
);
long
timeMillis
=
gc
.
getTimeInMillis
();
ValueTimestamp
ts
=
DateTimeUtils
.
convertTimestamp
(
new
Timestamp
(
timeMillis
),
gc
);
assertEquals
(
ts
.
getDateValue
(),
DateTimeUtils
.
dateValueFromDate
(
timeMillis
));
assertEquals
(
ts
.
getTimeNanos
(),
DateTimeUtils
.
nanosFromDate
(
timeMillis
));
timeMillis
+=
DateTimeUtils
.
getTimeZoneOffset
(
timeMillis
);
assertEquals
(
ts
.
getDateValue
(),
DateTimeUtils
.
dateValueFromLocalMillis
(
timeMillis
));
assertEquals
(
ts
.
getTimeNanos
(),
DateTimeUtils
.
nanosFromLocalMillis
(
timeMillis
));
}
}
}
...
...
h2/src/tools/org/h2/build/doc/GenerateHelp.java
浏览文件 @
d6cebc3f
...
...
@@ -66,7 +66,7 @@ public class GenerateHelp {
"Multiple-Licensed under the MPL 2.0,\n"
+
"# and the EPL 1.0 "
+
"(http://h2database.com/html/license.html).\n"
+
"# Initial Developer: H2 Group
)
\n"
);
"# Initial Developer: H2 Group\n"
);
csv
=
new
Csv
();
csv
.
setLineSeparator
(
"\n"
);
csv
.
write
(
writer
,
rs2
);
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
d6cebc3f
...
...
@@ -804,3 +804,4 @@ qualification opportunity jumping exploited unacceptable vrs duplicated
queryparser tokenized freeze factorings recompilation unenclosed rfe dsync
econd irst bcef ordinality nord unnest
analyst occupation distributive josaph aor engineer sajeewa isuru randil kevin doctor businessman artist ashan
corrupts splitted disruption unintentional
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论