Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
59288b3d
Unverified
提交
59288b3d
authored
2月 28, 2018
作者:
Noel Grandin
提交者:
GitHub
2月 28, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #912 from katzyn/float
Check precision for FLOAT data type and describe it in documentation
上级
cc021a06
43a23abd
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
71 行增加
和
2 行删除
+71
-2
help.csv
h2/src/docsrc/help/help.csv
+4
-2
Parser.java
h2/src/main/org/h2/command/Parser.java
+12
-0
double.sql
h2/src/test/org/h2/test/scripts/datatypes/double.sql
+28
-0
real.sql
h2/src/test/org/h2/test/scripts/datatypes/real.sql
+27
-0
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
59288b3d
...
@@ -2412,10 +2412,11 @@ DECIMAL(20, 2)
...
@@ -2412,10 +2412,11 @@ DECIMAL(20, 2)
"
"
"Data Types","DOUBLE Type","
"Data Types","DOUBLE Type","
{ DOUBLE [ PRECISION ] | FLOAT | FLOAT8 }
{ DOUBLE [ PRECISION ] | FLOAT
[ ( precisionInt ) ]
| FLOAT8 }
","
","
A floating point number. Should not be used to represent currency values, because
A floating point number. Should not be used to represent currency values, because
of rounding problems.
of rounding problems.
If precision value is specified for FLOAT type name, it should be from 25 to 53.
Mapped to ""java.lang.Double"".
Mapped to ""java.lang.Double"".
","
","
...
@@ -2423,10 +2424,11 @@ DOUBLE
...
@@ -2423,10 +2424,11 @@ DOUBLE
"
"
"Data Types","REAL Type","
"Data Types","REAL Type","
{ REAL | FLOAT4 }
{ REAL | FLOAT
( precisionInt ) | FLOAT
4 }
","
","
A single precision floating point number. Should not be used to represent currency
A single precision floating point number. Should not be used to represent currency
values, because of rounding problems.
values, because of rounding problems.
Precision value for FLOAT type name should be from 0 to 24.
Mapped to ""java.lang.Float"".
Mapped to ""java.lang.Float"".
","
","
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
59288b3d
...
@@ -4446,6 +4446,18 @@ public class Parser {
...
@@ -4446,6 +4446,18 @@ public class Parser {
}
}
read
(
")"
);
read
(
")"
);
}
}
}
else
if
(
dataType
.
type
==
Value
.
DOUBLE
&&
original
.
equals
(
"FLOAT"
))
{
if
(
readIf
(
"("
))
{
int
p
=
readPositiveInt
();
read
(
")"
);
if
(
p
>
53
)
{
throw
DbException
.
get
(
ErrorCode
.
INVALID_VALUE_SCALE_PRECISION
,
Integer
.
toString
(
p
));
}
if
(
p
<=
24
)
{
dataType
=
DataType
.
getDataType
(
Value
.
FLOAT
);
}
original
=
original
+
'('
+
p
+
')'
;
}
}
else
if
(
dataType
.
type
==
Value
.
ENUM
)
{
}
else
if
(
dataType
.
type
==
Value
.
ENUM
)
{
if
(
readIf
(
"("
))
{
if
(
readIf
(
"("
))
{
java
.
util
.
List
<
String
>
enumeratorList
=
new
ArrayList
<>();
java
.
util
.
List
<
String
>
enumeratorList
=
new
ArrayList
<>();
...
...
h2/src/test/org/h2/test/scripts/datatypes/double.sql
浏览文件 @
59288b3d
...
@@ -2,3 +2,31 @@
...
@@ -2,3 +2,31 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
-- Initial Developer: H2 Group
--
--
CREATE
MEMORY
TABLE
TEST
(
D1
DOUBLE
,
D2
DOUBLE
PRECISION
,
D3
FLOAT
,
D4
FLOAT
(
25
),
D5
FLOAT
(
53
));
>
ok
ALTER
TABLE
TEST
ADD
COLUMN
D6
FLOAT
(
54
);
>
exception
SELECT
COLUMN_NAME
,
DATA_TYPE
,
TYPE_NAME
,
COLUMN_TYPE
FROM
INFORMATION_SCHEMA
.
COLUMNS
WHERE
TABLE_NAME
=
'TEST'
ORDER
BY
ORDINAL_POSITION
;
>
COLUMN_NAME
DATA_TYPE
TYPE_NAME
COLUMN_TYPE
>
----------- --------- --------- ----------------
>
D1
8
DOUBLE
DOUBLE
>
D2
8
DOUBLE
DOUBLE
PRECISION
>
D3
8
DOUBLE
FLOAT
>
D4
8
DOUBLE
FLOAT
(
25
)
>
D5
8
DOUBLE
FLOAT
(
53
)
>
rows
(
ordered
):
5
SCRIPT
NODATA
NOPASSWORDS
NOSETTINGS
TABLE
TEST
;
>
SCRIPT
>
--------------------------------------------------------------------------------------------------------
>
-- 0 +/- SELECT COUNT(*) FROM PUBLIC.TEST;
>
CREATE
MEMORY
TABLE
PUBLIC
.
TEST
(
D1
DOUBLE
,
D2
DOUBLE
PRECISION
,
D3
FLOAT
,
D4
FLOAT
(
25
),
D5
FLOAT
(
53
)
);
>
CREATE
USER
IF
NOT
EXISTS
SA
PASSWORD
''
ADMIN
;
>
rows
:
3
DROP
TABLE
TEST
;
>
ok
h2/src/test/org/h2/test/scripts/datatypes/real.sql
浏览文件 @
59288b3d
...
@@ -2,3 +2,30 @@
...
@@ -2,3 +2,30 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
-- Initial Developer: H2 Group
--
--
CREATE
MEMORY
TABLE
TEST
(
D1
REAL
,
D2
FLOAT4
,
D3
FLOAT
(
0
),
D4
FLOAT
(
24
));
>
ok
ALTER
TABLE
TEST
ADD
COLUMN
D5
FLOAT
(
-
1
);
>
exception
SELECT
COLUMN_NAME
,
DATA_TYPE
,
TYPE_NAME
,
COLUMN_TYPE
FROM
INFORMATION_SCHEMA
.
COLUMNS
WHERE
TABLE_NAME
=
'TEST'
ORDER
BY
ORDINAL_POSITION
;
>
COLUMN_NAME
DATA_TYPE
TYPE_NAME
COLUMN_TYPE
>
----------- --------- --------- -----------
>
D1
7
REAL
REAL
>
D2
7
REAL
FLOAT4
>
D3
7
REAL
FLOAT
(
0
)
>
D4
7
REAL
FLOAT
(
24
)
>
rows
(
ordered
):
4
SCRIPT
NODATA
NOPASSWORDS
NOSETTINGS
TABLE
TEST
;
>
SCRIPT
>
---------------------------------------------------------------------------------
>
-- 0 +/- SELECT COUNT(*) FROM PUBLIC.TEST;
>
CREATE
MEMORY
TABLE
PUBLIC
.
TEST
(
D1
REAL
,
D2
FLOAT4
,
D3
FLOAT
(
0
),
D4
FLOAT
(
24
)
);
>
CREATE
USER
IF
NOT
EXISTS
SA
PASSWORD
''
ADMIN
;
>
rows
:
3
DROP
TABLE
TEST
;
>
ok
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论