Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
00e46bf6
Unverified
提交
00e46bf6
authored
1月 11, 2018
作者:
Noel Grandin
提交者:
GitHub
1月 11, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #741 from katzyn/misc
More cleanups in LocalDateTimeUtils and other minor changes
上级
522ca783
829e9d02
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
34 行增加
和
56 行删除
+34
-56
Parser.java
h2/src/main/org/h2/command/Parser.java
+6
-18
Mode.java
h2/src/main/org/h2/engine/Mode.java
+1
-1
SysProperties.java
h2/src/main/org/h2/engine/SysProperties.java
+3
-3
JdbcResultSet.java
h2/src/main/org/h2/jdbc/JdbcResultSet.java
+2
-4
JdbcStatement.java
h2/src/main/org/h2/jdbc/JdbcStatement.java
+0
-3
WebApp.java
h2/src/main/org/h2/server/web/WebApp.java
+3
-3
LocalDateTimeUtils.java
h2/src/main/org/h2/util/LocalDateTimeUtils.java
+10
-17
ToChar.java
h2/src/main/org/h2/util/ToChar.java
+9
-7
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
00e46bf6
...
...
@@ -6844,34 +6844,22 @@ public class Parser {
* @return the quoted identifier
*/
public
static
String
quoteIdentifier
(
String
s
)
{
if
(
s
==
null
||
s
.
length
()
==
0
)
{
if
(
s
==
null
)
{
return
"\"\""
;
}
char
c
=
s
.
charAt
(
0
);
// lowercase a-z is quoted as well
if
((!
Character
.
isLetter
(
c
)
&&
c
!=
'_'
)
||
Character
.
isLowerCase
(
c
))
{
return
StringUtils
.
quoteIdentifier
(
s
);
}
for
(
int
i
=
1
,
length
=
s
.
length
();
i
<
length
;
i
++)
{
c
=
s
.
charAt
(
i
);
if
((!
Character
.
isLetterOrDigit
(
c
)
&&
c
!=
'_'
)
||
Character
.
isLowerCase
(
c
))
{
return
StringUtils
.
quoteIdentifier
(
s
);
}
}
if
(
isKeyword
(
s
,
true
))
{
return
StringUtils
.
quoteIdentifier
(
s
);
}
if
(
isSimpleIdentifier
(
s
))
return
s
;
return
StringUtils
.
quoteIdentifier
(
s
);
}
/**
* @param s
* identifier to check
* @return is specified identifier may be used without quotes
* @throws NullPointerException if s is {@code null}
*/
public
static
boolean
isSimpleIdentifier
(
String
s
)
{
if
(
s
==
null
||
s
.
length
()
==
0
)
{
if
(
s
.
length
()
==
0
)
{
return
false
;
}
char
c
=
s
.
charAt
(
0
);
...
...
h2/src/main/org/h2/engine/Mode.java
浏览文件 @
00e46bf6
...
...
@@ -79,7 +79,7 @@ public class Mode {
* [OFFSET .. ROW|ROWS] [FETCH FIRST .. ROW|ROWS ONLY]
* as an alternative for LIMIT .. OFFSET.
*/
public
boolean
supportOffsetFetch
=
Constants
.
VERSION_MINOR
>=
4
?
true
:
false
;
public
boolean
supportOffsetFetch
=
Constants
.
VERSION_MINOR
>=
4
;
/**
* The system columns 'CTID' and 'OID' are supported.
...
...
h2/src/main/org/h2/engine/SysProperties.java
浏览文件 @
00e46bf6
...
...
@@ -344,7 +344,7 @@ public class SysProperties {
*/
public
static
final
boolean
OLD_STYLE_OUTER_JOIN
=
Utils
.
getProperty
(
"h2.oldStyleOuterJoin"
,
Constants
.
VERSION_MINOR
>=
4
?
false
:
true
);
Constants
.
VERSION_MINOR
<
4
);
/**
* System property <code>h2.pgClientEncoding</code> (default: UTF-8).<br />
...
...
@@ -401,7 +401,7 @@ public class SysProperties {
*/
public
static
final
boolean
SORT_BINARY_UNSIGNED
=
Utils
.
getProperty
(
"h2.sortBinaryUnsigned"
,
Constants
.
VERSION_MINOR
>=
4
?
true
:
false
);
Constants
.
VERSION_MINOR
>=
4
);
/**
* System property <code>h2.sortNullsHigh</code> (default: false).<br />
...
...
@@ -455,7 +455,7 @@ public class SysProperties {
*/
public
static
final
boolean
IMPLICIT_RELATIVE_PATH
=
Utils
.
getProperty
(
"h2.implicitRelativePath"
,
Constants
.
VERSION_MINOR
>=
4
?
false
:
true
);
Constants
.
VERSION_MINOR
<
4
);
/**
* System property <code>h2.urlMap</code> (default: null).<br />
...
...
h2/src/main/org/h2/jdbc/JdbcResultSet.java
浏览文件 @
00e46bf6
...
...
@@ -3824,14 +3824,12 @@ public class JdbcResultSet extends TraceObject implements ResultSet, JdbcResultS
}
else
if
(
LocalDateTimeUtils
.
isLocalTime
(
type
))
{
return
type
.
cast
(
LocalDateTimeUtils
.
valueToLocalTime
(
value
));
}
else
if
(
LocalDateTimeUtils
.
isLocalDateTime
(
type
))
{
return
type
.
cast
(
LocalDateTimeUtils
.
valueToLocalDateTime
(
(
ValueTimestamp
)
value
));
return
type
.
cast
(
LocalDateTimeUtils
.
valueToLocalDateTime
(
value
));
}
else
if
(
LocalDateTimeUtils
.
isInstant
(
type
))
{
return
type
.
cast
(
LocalDateTimeUtils
.
valueToInstant
(
value
));
}
else
if
(
LocalDateTimeUtils
.
isOffsetDateTime
(
type
)
&&
value
instanceof
ValueTimestampTimeZone
)
{
return
type
.
cast
(
LocalDateTimeUtils
.
valueToOffsetDateTime
(
(
ValueTimestampTimeZone
)
value
));
return
type
.
cast
(
LocalDateTimeUtils
.
valueToOffsetDateTime
(
value
));
}
else
{
throw
unsupported
(
type
.
getName
());
}
...
...
h2/src/main/org/h2/jdbc/JdbcStatement.java
浏览文件 @
00e46bf6
...
...
@@ -1332,9 +1332,6 @@ public class JdbcStatement extends TraceObject implements Statement, JdbcStateme
*/
@Override
public
boolean
isSimpleIdentifier
(
String
identifier
)
throws
SQLException
{
if
(
identifier
==
null
)
// To conform with JDBC specification
throw
new
NullPointerException
();
return
Parser
.
isSimpleIdentifier
(
identifier
);
}
...
...
h2/src/main/org/h2/server/web/WebApp.java
浏览文件 @
00e46bf6
...
...
@@ -1099,7 +1099,7 @@ public class WebApp {
if
(
isBuiltIn
(
sql
,
"@best_row_identifier"
))
{
String
[]
p
=
split
(
sql
);
int
scale
=
p
[
4
]
==
null
?
0
:
Integer
.
parseInt
(
p
[
4
]);
boolean
nullable
=
p
[
5
]
==
null
?
false
:
Boolean
.
parseBoolean
(
p
[
5
]);
boolean
nullable
=
Boolean
.
parseBoolean
(
p
[
5
]);
return
meta
.
getBestRowIdentifier
(
p
[
1
],
p
[
2
],
p
[
3
],
scale
,
nullable
);
}
else
if
(
isBuiltIn
(
sql
,
"@catalogs"
))
{
return
meta
.
getCatalogs
();
...
...
@@ -1120,8 +1120,8 @@ public class WebApp {
return
meta
.
getImportedKeys
(
p
[
1
],
p
[
2
],
p
[
3
]);
}
else
if
(
isBuiltIn
(
sql
,
"@index_info"
))
{
String
[]
p
=
split
(
sql
);
boolean
unique
=
p
[
4
]
==
null
?
false
:
Boolean
.
parseBoolean
(
p
[
4
]);
boolean
approx
=
p
[
5
]
==
null
?
false
:
Boolean
.
parseBoolean
(
p
[
5
]);
boolean
unique
=
Boolean
.
parseBoolean
(
p
[
4
]);
boolean
approx
=
Boolean
.
parseBoolean
(
p
[
5
]);
return
meta
.
getIndexInfo
(
p
[
1
],
p
[
2
],
p
[
3
],
unique
,
approx
);
}
else
if
(
isBuiltIn
(
sql
,
"@primary_keys"
))
{
String
[]
p
=
split
(
sql
);
...
...
h2/src/main/org/h2/util/LocalDateTimeUtils.java
浏览文件 @
00e46bf6
...
...
@@ -13,7 +13,6 @@ import java.sql.Timestamp;
import
java.util.Arrays
;
import
java.util.concurrent.TimeUnit
;
import
org.h2.api.TimestampWithTimeZone
;
import
org.h2.message.DbException
;
import
org.h2.value.Value
;
import
org.h2.value.ValueDate
;
...
...
@@ -418,13 +417,12 @@ public class LocalDateTimeUtils {
* @param value the value to convert
* @return the LocalDateTime
*/
public
static
Object
valueToLocalDateTime
(
ValueTimestamp
value
)
{
long
dateValue
=
value
.
getDateValue
();
long
timeNanos
=
value
.
getTimeNanos
();
public
static
Object
valueToLocalDateTime
(
Value
value
)
{
ValueTimestamp
valueTimestamp
=
(
ValueTimestamp
)
value
.
convertTo
(
Value
.
TIMESTAMP
);
long
dateValue
=
valueTimestamp
.
getDateValue
();
long
timeNanos
=
valueTimestamp
.
getTimeNanos
();
try
{
Object
localDate
=
localDateFromDateValue
(
dateValue
);
Object
localDateTime
=
LOCAL_DATE_AT_START_OF_DAY
.
invoke
(
localDate
);
return
LOCAL_DATE_TIME_PLUS_NANOS
.
invoke
(
localDateTime
,
timeNanos
);
return
localDateTimeFromDateNanos
(
dateValue
,
timeNanos
);
}
catch
(
IllegalAccessException
e
)
{
throw
DbException
.
convert
(
e
);
}
catch
(
InvocationTargetException
e
)
{
...
...
@@ -458,19 +456,14 @@ public class LocalDateTimeUtils {
* @param value the value to convert
* @return the OffsetDateTime
*/
public
static
Object
valueToOffsetDateTime
(
ValueTimestampTimeZone
value
)
{
return
timestampWithTimeZoneToOffsetDateTime
((
TimestampWithTimeZone
)
value
.
getObject
());
}
private
static
Object
timestampWithTimeZoneToOffsetDateTime
(
TimestampWithTimeZone
timestampWithTimeZone
)
{
long
dateValue
=
timestampWithTimeZone
.
getYMD
();
long
timeNanos
=
timestampWithTimeZone
.
getNanosSinceMidnight
();
public
static
Object
valueToOffsetDateTime
(
Value
value
)
{
ValueTimestampTimeZone
valueTimestampTimeZone
=
(
ValueTimestampTimeZone
)
value
.
convertTo
(
Value
.
TIMESTAMP_TZ
);
long
dateValue
=
valueTimestampTimeZone
.
getDateValue
();
long
timeNanos
=
valueTimestampTimeZone
.
getTimeNanos
();
try
{
Object
localDateTime
=
localDateTimeFromDateNanos
(
dateValue
,
timeNanos
);
short
timeZoneOffsetMins
=
timestampWith
TimeZone
.
getTimeZoneOffsetMins
();
short
timeZoneOffsetMins
=
valueTimestamp
TimeZone
.
getTimeZoneOffsetMins
();
int
offsetSeconds
=
(
int
)
TimeUnit
.
MINUTES
.
toSeconds
(
timeZoneOffsetMins
);
Object
offset
=
ZONE_OFFSET_OF_TOTAL_SECONDS
.
invoke
(
null
,
offsetSeconds
);
...
...
h2/src/main/org/h2/util/ToChar.java
浏览文件 @
00e46bf6
...
...
@@ -31,6 +31,12 @@ public class ToChar {
*/
private
static
final
long
JULIAN_EPOCH
;
private
static
final
int
[]
ROMAN_VALUES
=
{
1000
,
900
,
500
,
400
,
100
,
90
,
50
,
40
,
10
,
9
,
5
,
4
,
1
};
private
static
final
String
[]
ROMAN_NUMERALS
=
{
"M"
,
"CM"
,
"D"
,
"CD"
,
"C"
,
"XC"
,
"L"
,
"XL"
,
"X"
,
"IX"
,
"V"
,
"IV"
,
"I"
};
static
{
GregorianCalendar
epoch
=
new
GregorianCalendar
(
Locale
.
ENGLISH
);
epoch
.
setGregorianChange
(
new
Date
(
Long
.
MAX_VALUE
));
...
...
@@ -410,14 +416,10 @@ public class ToChar {
}
private
static
String
toRomanNumeral
(
int
number
)
{
int
[]
values
=
new
int
[]
{
1000
,
900
,
500
,
400
,
100
,
90
,
50
,
40
,
10
,
9
,
5
,
4
,
1
};
String
[]
numerals
=
new
String
[]
{
"M"
,
"CM"
,
"D"
,
"CD"
,
"C"
,
"XC"
,
"L"
,
"XL"
,
"X"
,
"IX"
,
"V"
,
"IV"
,
"I"
};
StringBuilder
result
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
int
value
=
values
[
i
];
String
numeral
=
numerals
[
i
];
for
(
int
i
=
0
;
i
<
ROMAN_VALUES
.
length
;
i
++)
{
int
value
=
ROMAN_VALUES
[
i
];
String
numeral
=
ROMAN_NUMERALS
[
i
];
while
(
number
>=
value
)
{
result
.
append
(
numeral
);
number
-=
value
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论