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 {
...
@@ -6844,34 +6844,22 @@ public class Parser {
* @return the quoted identifier
* @return the quoted identifier
*/
*/
public
static
String
quoteIdentifier
(
String
s
)
{
public
static
String
quoteIdentifier
(
String
s
)
{
if
(
s
==
null
||
s
.
length
()
==
0
)
{
if
(
s
==
null
)
{
return
"\"\""
;
return
"\"\""
;
}
}
char
c
=
s
.
charAt
(
0
);
if
(
isSimpleIdentifier
(
s
))
// lowercase a-z is quoted as well
return
s
;
if
((!
Character
.
isLetter
(
c
)
&&
c
!=
'_'
)
||
Character
.
isLowerCase
(
c
))
{
return
StringUtils
.
quoteIdentifier
(
s
);
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
);
}
return
s
;
}
}
/**
/**
* @param s
* @param s
* identifier to check
* identifier to check
* @return is specified identifier may be used without quotes
* @return is specified identifier may be used without quotes
* @throws NullPointerException if s is {@code null}
*/
*/
public
static
boolean
isSimpleIdentifier
(
String
s
)
{
public
static
boolean
isSimpleIdentifier
(
String
s
)
{
if
(
s
==
null
||
s
.
length
()
==
0
)
{
if
(
s
.
length
()
==
0
)
{
return
false
;
return
false
;
}
}
char
c
=
s
.
charAt
(
0
);
char
c
=
s
.
charAt
(
0
);
...
...
h2/src/main/org/h2/engine/Mode.java
浏览文件 @
00e46bf6
...
@@ -79,7 +79,7 @@ public class Mode {
...
@@ -79,7 +79,7 @@ public class Mode {
* [OFFSET .. ROW|ROWS] [FETCH FIRST .. ROW|ROWS ONLY]
* [OFFSET .. ROW|ROWS] [FETCH FIRST .. ROW|ROWS ONLY]
* as an alternative for LIMIT .. OFFSET.
* 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.
* The system columns 'CTID' and 'OID' are supported.
...
...
h2/src/main/org/h2/engine/SysProperties.java
浏览文件 @
00e46bf6
...
@@ -344,7 +344,7 @@ public class SysProperties {
...
@@ -344,7 +344,7 @@ public class SysProperties {
*/
*/
public
static
final
boolean
OLD_STYLE_OUTER_JOIN
=
public
static
final
boolean
OLD_STYLE_OUTER_JOIN
=
Utils
.
getProperty
(
"h2.oldStyleOuterJoin"
,
Utils
.
getProperty
(
"h2.oldStyleOuterJoin"
,
Constants
.
VERSION_MINOR
>=
4
?
false
:
true
);
Constants
.
VERSION_MINOR
<
4
);
/**
/**
* System property <code>h2.pgClientEncoding</code> (default: UTF-8).<br />
* System property <code>h2.pgClientEncoding</code> (default: UTF-8).<br />
...
@@ -401,7 +401,7 @@ public class SysProperties {
...
@@ -401,7 +401,7 @@ public class SysProperties {
*/
*/
public
static
final
boolean
SORT_BINARY_UNSIGNED
=
public
static
final
boolean
SORT_BINARY_UNSIGNED
=
Utils
.
getProperty
(
"h2.sortBinaryUnsigned"
,
Utils
.
getProperty
(
"h2.sortBinaryUnsigned"
,
Constants
.
VERSION_MINOR
>=
4
?
true
:
false
);
Constants
.
VERSION_MINOR
>=
4
);
/**
/**
* System property <code>h2.sortNullsHigh</code> (default: false).<br />
* System property <code>h2.sortNullsHigh</code> (default: false).<br />
...
@@ -455,7 +455,7 @@ public class SysProperties {
...
@@ -455,7 +455,7 @@ public class SysProperties {
*/
*/
public
static
final
boolean
IMPLICIT_RELATIVE_PATH
=
public
static
final
boolean
IMPLICIT_RELATIVE_PATH
=
Utils
.
getProperty
(
"h2.implicitRelativePath"
,
Utils
.
getProperty
(
"h2.implicitRelativePath"
,
Constants
.
VERSION_MINOR
>=
4
?
false
:
true
);
Constants
.
VERSION_MINOR
<
4
);
/**
/**
* System property <code>h2.urlMap</code> (default: null).<br />
* 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
...
@@ -3824,14 +3824,12 @@ public class JdbcResultSet extends TraceObject implements ResultSet, JdbcResultS
}
else
if
(
LocalDateTimeUtils
.
isLocalTime
(
type
))
{
}
else
if
(
LocalDateTimeUtils
.
isLocalTime
(
type
))
{
return
type
.
cast
(
LocalDateTimeUtils
.
valueToLocalTime
(
value
));
return
type
.
cast
(
LocalDateTimeUtils
.
valueToLocalTime
(
value
));
}
else
if
(
LocalDateTimeUtils
.
isLocalDateTime
(
type
))
{
}
else
if
(
LocalDateTimeUtils
.
isLocalDateTime
(
type
))
{
return
type
.
cast
(
LocalDateTimeUtils
.
valueToLocalDateTime
(
return
type
.
cast
(
LocalDateTimeUtils
.
valueToLocalDateTime
(
value
));
(
ValueTimestamp
)
value
));
}
else
if
(
LocalDateTimeUtils
.
isInstant
(
type
))
{
}
else
if
(
LocalDateTimeUtils
.
isInstant
(
type
))
{
return
type
.
cast
(
LocalDateTimeUtils
.
valueToInstant
(
value
));
return
type
.
cast
(
LocalDateTimeUtils
.
valueToInstant
(
value
));
}
else
if
(
LocalDateTimeUtils
.
isOffsetDateTime
(
type
)
&&
}
else
if
(
LocalDateTimeUtils
.
isOffsetDateTime
(
type
)
&&
value
instanceof
ValueTimestampTimeZone
)
{
value
instanceof
ValueTimestampTimeZone
)
{
return
type
.
cast
(
LocalDateTimeUtils
.
valueToOffsetDateTime
(
return
type
.
cast
(
LocalDateTimeUtils
.
valueToOffsetDateTime
(
value
));
(
ValueTimestampTimeZone
)
value
));
}
else
{
}
else
{
throw
unsupported
(
type
.
getName
());
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
...
@@ -1332,9 +1332,6 @@ public class JdbcStatement extends TraceObject implements Statement, JdbcStateme
*/
*/
@Override
@Override
public
boolean
isSimpleIdentifier
(
String
identifier
)
throws
SQLException
{
public
boolean
isSimpleIdentifier
(
String
identifier
)
throws
SQLException
{
if
(
identifier
==
null
)
// To conform with JDBC specification
throw
new
NullPointerException
();
return
Parser
.
isSimpleIdentifier
(
identifier
);
return
Parser
.
isSimpleIdentifier
(
identifier
);
}
}
...
...
h2/src/main/org/h2/server/web/WebApp.java
浏览文件 @
00e46bf6
...
@@ -1099,7 +1099,7 @@ public class WebApp {
...
@@ -1099,7 +1099,7 @@ public class WebApp {
if
(
isBuiltIn
(
sql
,
"@best_row_identifier"
))
{
if
(
isBuiltIn
(
sql
,
"@best_row_identifier"
))
{
String
[]
p
=
split
(
sql
);
String
[]
p
=
split
(
sql
);
int
scale
=
p
[
4
]
==
null
?
0
:
Integer
.
parseInt
(
p
[
4
]);
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
);
return
meta
.
getBestRowIdentifier
(
p
[
1
],
p
[
2
],
p
[
3
],
scale
,
nullable
);
}
else
if
(
isBuiltIn
(
sql
,
"@catalogs"
))
{
}
else
if
(
isBuiltIn
(
sql
,
"@catalogs"
))
{
return
meta
.
getCatalogs
();
return
meta
.
getCatalogs
();
...
@@ -1120,8 +1120,8 @@ public class WebApp {
...
@@ -1120,8 +1120,8 @@ public class WebApp {
return
meta
.
getImportedKeys
(
p
[
1
],
p
[
2
],
p
[
3
]);
return
meta
.
getImportedKeys
(
p
[
1
],
p
[
2
],
p
[
3
]);
}
else
if
(
isBuiltIn
(
sql
,
"@index_info"
))
{
}
else
if
(
isBuiltIn
(
sql
,
"@index_info"
))
{
String
[]
p
=
split
(
sql
);
String
[]
p
=
split
(
sql
);
boolean
unique
=
p
[
4
]
==
null
?
false
:
Boolean
.
parseBoolean
(
p
[
4
]);
boolean
unique
=
Boolean
.
parseBoolean
(
p
[
4
]);
boolean
approx
=
p
[
5
]
==
null
?
false
:
Boolean
.
parseBoolean
(
p
[
5
]);
boolean
approx
=
Boolean
.
parseBoolean
(
p
[
5
]);
return
meta
.
getIndexInfo
(
p
[
1
],
p
[
2
],
p
[
3
],
unique
,
approx
);
return
meta
.
getIndexInfo
(
p
[
1
],
p
[
2
],
p
[
3
],
unique
,
approx
);
}
else
if
(
isBuiltIn
(
sql
,
"@primary_keys"
))
{
}
else
if
(
isBuiltIn
(
sql
,
"@primary_keys"
))
{
String
[]
p
=
split
(
sql
);
String
[]
p
=
split
(
sql
);
...
...
h2/src/main/org/h2/util/LocalDateTimeUtils.java
浏览文件 @
00e46bf6
...
@@ -13,7 +13,6 @@ import java.sql.Timestamp;
...
@@ -13,7 +13,6 @@ import java.sql.Timestamp;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
org.h2.api.TimestampWithTimeZone
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
import
org.h2.value.ValueDate
;
import
org.h2.value.ValueDate
;
...
@@ -418,13 +417,12 @@ public class LocalDateTimeUtils {
...
@@ -418,13 +417,12 @@ public class LocalDateTimeUtils {
* @param value the value to convert
* @param value the value to convert
* @return the LocalDateTime
* @return the LocalDateTime
*/
*/
public
static
Object
valueToLocalDateTime
(
ValueTimestamp
value
)
{
public
static
Object
valueToLocalDateTime
(
Value
value
)
{
long
dateValue
=
value
.
getDateValue
();
ValueTimestamp
valueTimestamp
=
(
ValueTimestamp
)
value
.
convertTo
(
Value
.
TIMESTAMP
);
long
timeNanos
=
value
.
getTimeNanos
();
long
dateValue
=
valueTimestamp
.
getDateValue
();
long
timeNanos
=
valueTimestamp
.
getTimeNanos
();
try
{
try
{
Object
localDate
=
localDateFromDateValue
(
dateValue
);
return
localDateTimeFromDateNanos
(
dateValue
,
timeNanos
);
Object
localDateTime
=
LOCAL_DATE_AT_START_OF_DAY
.
invoke
(
localDate
);
return
LOCAL_DATE_TIME_PLUS_NANOS
.
invoke
(
localDateTime
,
timeNanos
);
}
catch
(
IllegalAccessException
e
)
{
}
catch
(
IllegalAccessException
e
)
{
throw
DbException
.
convert
(
e
);
throw
DbException
.
convert
(
e
);
}
catch
(
InvocationTargetException
e
)
{
}
catch
(
InvocationTargetException
e
)
{
...
@@ -458,19 +456,14 @@ public class LocalDateTimeUtils {
...
@@ -458,19 +456,14 @@ public class LocalDateTimeUtils {
* @param value the value to convert
* @param value the value to convert
* @return the OffsetDateTime
* @return the OffsetDateTime
*/
*/
public
static
Object
valueToOffsetDateTime
(
ValueTimestampTimeZone
value
)
{
public
static
Object
valueToOffsetDateTime
(
Value
value
)
{
return
timestampWithTimeZoneToOffsetDateTime
((
TimestampWithTimeZone
)
value
.
getObject
());
ValueTimestampTimeZone
valueTimestampTimeZone
=
(
ValueTimestampTimeZone
)
value
.
convertTo
(
Value
.
TIMESTAMP_TZ
);
}
long
dateValue
=
valueTimestampTimeZone
.
getDateValue
();
long
timeNanos
=
valueTimestampTimeZone
.
getTimeNanos
();
private
static
Object
timestampWithTimeZoneToOffsetDateTime
(
TimestampWithTimeZone
timestampWithTimeZone
)
{
long
dateValue
=
timestampWithTimeZone
.
getYMD
();
long
timeNanos
=
timestampWithTimeZone
.
getNanosSinceMidnight
();
try
{
try
{
Object
localDateTime
=
localDateTimeFromDateNanos
(
dateValue
,
timeNanos
);
Object
localDateTime
=
localDateTimeFromDateNanos
(
dateValue
,
timeNanos
);
short
timeZoneOffsetMins
=
timestampWith
TimeZone
.
getTimeZoneOffsetMins
();
short
timeZoneOffsetMins
=
valueTimestamp
TimeZone
.
getTimeZoneOffsetMins
();
int
offsetSeconds
=
(
int
)
TimeUnit
.
MINUTES
.
toSeconds
(
timeZoneOffsetMins
);
int
offsetSeconds
=
(
int
)
TimeUnit
.
MINUTES
.
toSeconds
(
timeZoneOffsetMins
);
Object
offset
=
ZONE_OFFSET_OF_TOTAL_SECONDS
.
invoke
(
null
,
offsetSeconds
);
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 {
...
@@ -31,6 +31,12 @@ public class ToChar {
*/
*/
private
static
final
long
JULIAN_EPOCH
;
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
{
static
{
GregorianCalendar
epoch
=
new
GregorianCalendar
(
Locale
.
ENGLISH
);
GregorianCalendar
epoch
=
new
GregorianCalendar
(
Locale
.
ENGLISH
);
epoch
.
setGregorianChange
(
new
Date
(
Long
.
MAX_VALUE
));
epoch
.
setGregorianChange
(
new
Date
(
Long
.
MAX_VALUE
));
...
@@ -410,14 +416,10 @@ public class ToChar {
...
@@ -410,14 +416,10 @@ public class ToChar {
}
}
private
static
String
toRomanNumeral
(
int
number
)
{
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
();
StringBuilder
result
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
ROMAN_VALUES
.
length
;
i
++)
{
int
value
=
values
[
i
];
int
value
=
ROMAN_VALUES
[
i
];
String
numeral
=
numerals
[
i
];
String
numeral
=
ROMAN_NUMERALS
[
i
];
while
(
number
>=
value
)
{
while
(
number
>=
value
)
{
result
.
append
(
numeral
);
result
.
append
(
numeral
);
number
-=
value
;
number
-=
value
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论