Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
2937be4a
提交
2937be4a
authored
6月 02, 2015
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pull request #125: Improved Oracle compatibility with truncate with timestamps and dates.
上级
d3853404
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
51 行增加
和
2 行删除
+51
-2
help.csv
h2/src/docsrc/help/help.csv
+3
-1
changelog.html
h2/src/docsrc/html/changelog.html
+2
-0
Function.java
h2/src/main/org/h2/expression/Function.java
+18
-0
testSimple.in.txt
h2/src/test/org/h2/test/testSimple.in.txt
+6
-0
TestBitStream.java
h2/src/test/org/h2/test/unit/TestBitStream.java
+2
-0
BitStream.java
h2/src/tools/org/h2/dev/util/BitStream.java
+20
-1
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
2937be4a
...
@@ -2975,11 +2975,13 @@ CALL HASH('SHA256', STRINGTOUTF8('Password'), 1000)
...
@@ -2975,11 +2975,13 @@ CALL HASH('SHA256', STRINGTOUTF8('Password'), 1000)
"
"
"Functions (Numeric)","TRUNCATE","
"Functions (Numeric)","TRUNCATE","
{ TRUNC | TRUNCATE } ( { {numeric, digitsInt} | timestamp } )
{ TRUNC | TRUNCATE } ( { {numeric, digitsInt} | timestamp
| date | timestampString
} )
","
","
Truncates to a number of digits (to the next value closer to 0).
Truncates to a number of digits (to the next value closer to 0).
This method returns a double.
This method returns a double.
When used with a timestamp, truncates a timestamp to a date (day) value.
When used with a timestamp, truncates a timestamp to a date (day) value.
When used with a date, truncates a date to a date (day) value less time part.
When used with a timestamp as string, truncates a timestamp to a date (day) value.
","
","
TRUNCATE(VALUE, 2)
TRUNCATE(VALUE, 2)
"
"
...
...
h2/src/docsrc/html/changelog.html
浏览文件 @
2937be4a
...
@@ -21,6 +21,8 @@ Change Log
...
@@ -21,6 +21,8 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul>
<ul>
<li>
Pull request #125: Improved Oracle compatibility with "truncate" with timestamps and dates.
</li>
<li>
Pull request #127: Linked tables now support geometry columns.
<li>
Pull request #127: Linked tables now support geometry columns.
</li>
</li>
<li>
ABS(CAST(0.0 AS DOUBLE)) returned -0.0 instead of 0.0.
<li>
ABS(CAST(0.0 AS DOUBLE)) returned -0.0 instead of 0.0.
...
...
h2/src/main/org/h2/expression/Function.java
浏览文件 @
2937be4a
...
@@ -1224,6 +1224,24 @@ public class Function extends Expression implements FunctionCall {
...
@@ -1224,6 +1224,24 @@ public class Function extends Expression implements FunctionCall {
c
.
set
(
Calendar
.
SECOND
,
0
);
c
.
set
(
Calendar
.
SECOND
,
0
);
c
.
set
(
Calendar
.
MILLISECOND
,
0
);
c
.
set
(
Calendar
.
MILLISECOND
,
0
);
result
=
ValueTimestamp
.
fromMillis
(
c
.
getTimeInMillis
());
result
=
ValueTimestamp
.
fromMillis
(
c
.
getTimeInMillis
());
}
else
if
(
v0
.
getType
()
==
Value
.
DATE
)
{
ValueDate
vd
=
(
ValueDate
)
v0
;
Calendar
c
=
Calendar
.
getInstance
();
c
.
setTime
(
vd
.
getDate
());
c
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
c
.
set
(
Calendar
.
MINUTE
,
0
);
c
.
set
(
Calendar
.
SECOND
,
0
);
c
.
set
(
Calendar
.
MILLISECOND
,
0
);
result
=
ValueTimestamp
.
fromMillis
(
c
.
getTimeInMillis
());
}
else
if
(
v0
.
getType
()
==
Value
.
STRING
)
{
ValueString
vd
=
(
ValueString
)
v0
;
Calendar
c
=
Calendar
.
getInstance
();
c
.
setTime
(
ValueTimestamp
.
parse
(
vd
.
getString
()).
getDate
());
c
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
c
.
set
(
Calendar
.
MINUTE
,
0
);
c
.
set
(
Calendar
.
SECOND
,
0
);
c
.
set
(
Calendar
.
MILLISECOND
,
0
);
result
=
ValueTimestamp
.
fromMillis
(
c
.
getTimeInMillis
());
}
else
{
}
else
{
double
d
=
v0
.
getDouble
();
double
d
=
v0
.
getDouble
();
int
p
=
v1
==
null
?
0
:
v1
.
getInt
();
int
p
=
v1
==
null
?
0
:
v1
.
getInt
();
...
...
h2/src/test/org/h2/test/testSimple.in.txt
浏览文件 @
2937be4a
select trunc('2015-05-29 15:00:00');
> 2015-05-29 00:00:00.0;
select trunc('2015-05-29');
> 2015-05-29 00:00:00.0;
select trunc(timestamp '2000-01-01 10:20:30.0');
> 2000-01-01 00:00:00.0;
select 1000L / 10;
select 1000L / 10;
> 100;
> 100;
select * from (select x as y from dual order by y);
select * from (select x as y from dual order by y);
...
...
h2/src/test/org/h2/test/unit/TestBitStream.java
浏览文件 @
2937be4a
...
@@ -100,7 +100,9 @@ public class TestBitStream extends TestBase {
...
@@ -100,7 +100,9 @@ public class TestBitStream extends TestBase {
}
}
};
};
o
.
writeGolomb
(
div
,
value
);
o
.
writeGolomb
(
div
,
value
);
int
size
=
Out
.
getGolombSize
(
div
,
value
);
String
got
=
buff
.
toString
();
String
got
=
buff
.
toString
();
assertEquals
(
size
,
got
.
length
());
assertEquals
(
expected
,
got
);
assertEquals
(
expected
,
got
);
}
}
...
...
h2/src/tools/org/h2/dev/util/BitStream.java
浏览文件 @
2937be4a
...
@@ -126,6 +126,23 @@ public class BitStream {
...
@@ -126,6 +126,23 @@ public class BitStream {
}
}
}
}
/**
* Get the size of the Golomb code for this value.
*
* @param divisor the divisor
* @param value the value
* @return the number of bits
*/
public
static
int
getGolombSize
(
int
divisor
,
int
value
)
{
int
q
=
value
/
divisor
;
int
r
=
value
-
q
*
divisor
;
int
bit
=
31
-
Integer
.
numberOfLeadingZeros
(
divisor
-
1
);
if
(
r
<
((
2
<<
bit
)
-
divisor
))
{
bit
--;
}
return
bit
+
q
+
2
;
}
/**
/**
* Write a bit.
* Write a bit.
*
*
...
@@ -195,8 +212,10 @@ public class BitStream {
...
@@ -195,8 +212,10 @@ public class BitStream {
}
}
codes
=
new
int
[
frequencies
.
length
];
codes
=
new
int
[
frequencies
.
length
];
tree
=
queue
.
poll
();
tree
=
queue
.
poll
();
if
(
tree
!=
null
)
{
tree
.
initCodes
(
codes
,
1
);
tree
.
initCodes
(
codes
,
1
);
}
}
}
/**
/**
* Write a value.
* Write a value.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论