Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
0832553e
提交
0832553e
authored
8月 04, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Specify data types for INFORMATION_SCHEMA.SESSIONS and use timestamps with time zones
上级
b3fbef16
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
27 行增加
和
19 行删除
+27
-19
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+7
-7
CurrentTimestamp.java
h2/src/main/org/h2/util/CurrentTimestamp.java
+1
-11
DateTimeUtils.java
h2/src/main/org/h2/util/DateTimeUtils.java
+19
-1
没有找到文件。
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
0832553e
...
@@ -11,7 +11,6 @@ import java.io.InputStreamReader;
...
@@ -11,7 +11,6 @@ import java.io.InputStreamReader;
import
java.io.Reader
;
import
java.io.Reader
;
import
java.sql.DatabaseMetaData
;
import
java.sql.DatabaseMetaData
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.Timestamp
;
import
java.sql.Types
;
import
java.sql.Types
;
import
java.text.Collator
;
import
java.text.Collator
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -58,6 +57,7 @@ import org.h2.schema.TriggerObject;
...
@@ -58,6 +57,7 @@ import org.h2.schema.TriggerObject;
import
org.h2.store.InDoubtTransaction
;
import
org.h2.store.InDoubtTransaction
;
import
org.h2.store.PageStore
;
import
org.h2.store.PageStore
;
import
org.h2.tools.Csv
;
import
org.h2.tools.Csv
;
import
org.h2.util.DateTimeUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.util.StringUtils
;
...
@@ -509,10 +509,10 @@ public class MetaTable extends Table {
...
@@ -509,10 +509,10 @@ public class MetaTable extends Table {
cols
=
createColumns
(
cols
=
createColumns
(
"ID INT"
,
"ID INT"
,
"USER_NAME"
,
"USER_NAME"
,
"SESSION_START"
,
"SESSION_START
TIMESTAMP WITH TIME ZONE
"
,
"STATEMENT"
,
"STATEMENT"
,
"STATEMENT_START"
,
"STATEMENT_START
TIMESTAMP WITH TIME ZONE
"
,
"CONTAINS_UNCOMMITTED"
,
"CONTAINS_UNCOMMITTED
BIT
"
,
"STATE"
,
"STATE"
,
"BLOCKER_ID INT"
"BLOCKER_ID INT"
);
);
...
@@ -1827,13 +1827,13 @@ public class MetaTable extends Table {
...
@@ -1827,13 +1827,13 @@ public class MetaTable extends Table {
// USER_NAME
// USER_NAME
s
.
getUser
().
getName
(),
s
.
getUser
().
getName
(),
// SESSION_START
// SESSION_START
new
Timestamp
(
s
.
getSessionStart
()).
toString
(
),
DateTimeUtils
.
timestampTimeZoneFromMillis
(
s
.
getSessionStart
()
),
// STATEMENT
// STATEMENT
command
==
null
?
null
:
command
.
toString
(),
command
==
null
?
null
:
command
.
toString
(),
// STATEMENT_START
// STATEMENT_START
new
Timestamp
(
start
).
toString
(
),
DateTimeUtils
.
timestampTimeZoneFromMillis
(
start
),
// CONTAINS_UNCOMMITTED
// CONTAINS_UNCOMMITTED
Boolean
.
toString
(
s
.
containsUncommitted
()),
ValueBoolean
.
get
(
s
.
containsUncommitted
()),
// STATE
// STATE
String
.
valueOf
(
s
.
getState
()),
String
.
valueOf
(
s
.
getState
()),
// BLOCKER_ID
// BLOCKER_ID
...
...
h2/src/main/org/h2/util/CurrentTimestamp.java
浏览文件 @
0832553e
...
@@ -21,17 +21,7 @@ public final class CurrentTimestamp {
...
@@ -21,17 +21,7 @@ public final class CurrentTimestamp {
* @return current timestamp
* @return current timestamp
*/
*/
public
static
ValueTimestampTimeZone
get
()
{
public
static
ValueTimestampTimeZone
get
()
{
long
ms
=
System
.
currentTimeMillis
();
return
DateTimeUtils
.
timestampTimeZoneFromMillis
(
System
.
currentTimeMillis
());
/*
* This code intentionally does not support properly dates before UNIX
* epoch and time zone offsets with seconds because such support is not
* required for current dates.
*/
int
offset
=
DateTimeUtils
.
getTimeZone
().
getOffset
(
ms
);
ms
+=
offset
;
return
ValueTimestampTimeZone
.
fromDateValueAndNanos
(
DateTimeUtils
.
dateValueFromAbsoluteDay
(
ms
/
DateTimeUtils
.
MILLIS_PER_DAY
),
ms
%
DateTimeUtils
.
MILLIS_PER_DAY
*
1_000_000
,
(
short
)
(
offset
/
60_000
));
}
}
private
CurrentTimestamp
()
{
private
CurrentTimestamp
()
{
...
...
h2/src/main/org/h2/util/DateTimeUtils.java
浏览文件 @
0832553e
...
@@ -111,7 +111,7 @@ public class DateTimeUtils {
...
@@ -111,7 +111,7 @@ public class DateTimeUtils {
*
*
* @return local time zone
* @return local time zone
*/
*/
static
TimeZone
getTimeZone
()
{
private
static
TimeZone
getTimeZone
()
{
TimeZone
tz
=
timeZone
;
TimeZone
tz
=
timeZone
;
if
(
tz
==
null
)
{
if
(
tz
==
null
)
{
timeZone
=
tz
=
TimeZone
.
getDefault
();
timeZone
=
tz
=
TimeZone
.
getDefault
();
...
@@ -1163,6 +1163,24 @@ public class DateTimeUtils {
...
@@ -1163,6 +1163,24 @@ public class DateTimeUtils {
return
ValueTimestampTimeZone
.
fromDateValueAndNanos
(
dateValue
,
timeNanos
,
(
short
)
offsetMins
);
return
ValueTimestampTimeZone
.
fromDateValueAndNanos
(
dateValue
,
timeNanos
,
(
short
)
offsetMins
);
}
}
/**
* @param ms milliseconds since 1970-01-01 (UTC)
* @return timestamp with time zone with specified value and current time zone
*/
public
static
ValueTimestampTimeZone
timestampTimeZoneFromMillis
(
long
ms
)
{
int
offset
=
getTimeZone
().
getOffset
(
ms
);
ms
+=
offset
;
long
absoluteDay
=
ms
/
MILLIS_PER_DAY
;
// Round toward negative infinity
if
(
ms
<
0
&&
(
absoluteDay
*
MILLIS_PER_DAY
!=
ms
))
{
absoluteDay
--;
}
return
ValueTimestampTimeZone
.
fromDateValueAndNanos
(
dateValueFromAbsoluteDay
(
absoluteDay
),
(
ms
-
absoluteDay
*
MILLIS_PER_DAY
)
*
1_000_000
,
(
short
)
(
offset
/
60_000
));
}
/**
/**
* Calculate the absolute day for a January, 1 of the specified year.
* Calculate the absolute day for a January, 1 of the specified year.
*
*
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论