Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3665807c
提交
3665807c
authored
15 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Literals of type BIGINT now have the correct data type.
上级
7bbf1613
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
56 行增加
和
11 行删除
+56
-11
changelog.html
h2/src/docsrc/html/changelog.html
+1
-1
Parser.java
h2/src/main/org/h2/command/Parser.java
+22
-8
ValueLong.java
h2/src/main/org/h2/value/ValueLong.java
+5
-2
TestResultSet.java
h2/src/test/org/h2/test/jdbc/TestResultSet.java
+28
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
3665807c
...
...
@@ -18,7 +18,7 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
-
<ul><li>
Literals of type BIGINT now have the correct data type.
</li></ul>
<h2>
Version 1.2.131 (2010-03-05)
</h2>
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/Parser.java
浏览文件 @
3665807c
...
...
@@ -151,7 +151,7 @@ public class Parser {
// used during the tokenizer phase
private
static
final
int
CHAR_END
=
1
,
CHAR_VALUE
=
2
,
CHAR_QUOTED
=
3
;
private
static
final
int
CHAR_NAME
=
4
,
CHAR_SPECIAL_1
=
5
,
CHAR_SPECIAL_2
=
6
;
private
static
final
int
CHAR_STRING
=
7
,
CHAR_D
ECIMAL
=
8
,
CHAR_DOLLAR_QUOTED_STRING
=
9
;
private
static
final
int
CHAR_STRING
=
7
,
CHAR_D
OT
=
8
,
CHAR_DOLLAR_QUOTED_STRING
=
9
;
// this are token types
private
static
final
int
KEYWORD
=
1
,
IDENTIFIER
=
2
,
PARAMETER
=
3
,
END
=
4
,
VALUE
=
5
;
...
...
@@ -2303,10 +2303,14 @@ public class Parser {
read
();
if
(
currentTokenType
==
VALUE
)
{
r
=
ValueExpression
.
get
(
currentValue
.
negate
());
// convert Integer.MIN_VALUE to int (-Integer.MIN_VALUE needed
// to be a long)
if
(
r
.
getType
()
==
Value
.
LONG
&&
r
.
getValue
(
session
).
getLong
()
==
Integer
.
MIN_VALUE
)
{
// convert Integer.MIN_VALUE to type 'int'
// (Integer.MAX_VALUE+1 is of type 'long')
r
=
ValueExpression
.
get
(
ValueInt
.
get
(
Integer
.
MIN_VALUE
));
}
else
if
(
r
.
getType
()
==
Value
.
DECIMAL
&&
r
.
getValue
(
session
).
getBigDecimal
().
compareTo
(
ValueLong
.
MIN_BD
)
==
0
)
{
// convert Long.MIN_VALUE to type 'long'
// (Long.MAX_VALUE+1 is of type 'decimal')
r
=
ValueExpression
.
get
(
ValueLong
.
get
(
Long
.
MIN_VALUE
));
}
read
();
}
else
{
...
...
@@ -2698,7 +2702,7 @@ public class Parser {
i
++;
}
return
;
case
CHAR_D
ECIMAL
:
case
CHAR_D
OT
:
if
(
types
[
i
]
!=
CHAR_VALUE
)
{
currentTokenType
=
KEYWORD
;
currentToken
=
"."
;
...
...
@@ -2785,12 +2789,14 @@ public class Parser {
// go until the first non-number
while
(
true
)
{
int
t
=
types
[
i
];
if
(
t
!=
CHAR_D
ECIMAL
&&
t
!=
CHAR_VALUE
)
{
if
(
t
!=
CHAR_D
OT
&&
t
!=
CHAR_VALUE
)
{
break
;
}
i
++;
}
if
(
chars
[
i
]
==
'E'
)
{
boolean
containsE
=
false
;
if
(
chars
[
i
]
==
'E'
||
chars
[
i
]
==
'e'
)
{
containsE
=
true
;
i
++;
if
(
chars
[
i
]
==
'+'
||
chars
[
i
]
==
'-'
)
{
i
++;
...
...
@@ -2804,13 +2810,21 @@ public class Parser {
}
parseIndex
=
i
;
String
sub
=
sqlCommand
.
substring
(
start
,
i
);
checkLiterals
(
false
);
if
(!
containsE
&&
sub
.
indexOf
(
'.'
)
<
0
)
{
BigInteger
bi
=
new
BigInteger
(
sub
);
if
(
bi
.
compareTo
(
ValueLong
.
MAX
)
<=
0
)
{
currentValue
=
ValueLong
.
get
(
bi
.
longValue
());
currentTokenType
=
VALUE
;
return
;
}
}
BigDecimal
bd
;
try
{
bd
=
new
BigDecimal
(
sub
);
}
catch
(
NumberFormatException
e
)
{
throw
DbException
.
get
(
ErrorCode
.
DATA_CONVERSION_ERROR_1
,
e
,
sub
);
}
checkLiterals
(
false
);
currentValue
=
ValueDecimal
.
get
(
bd
);
currentTokenType
=
VALUE
;
}
...
...
@@ -2937,7 +2951,7 @@ public class Parser {
type
=
CHAR_SPECIAL_2
;
break
;
case
'.'
:
type
=
CHAR_D
ECIMAL
;
type
=
CHAR_D
OT
;
break
;
case
'\''
:
type
=
types
[
i
]
=
CHAR_STRING
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLong.java
浏览文件 @
3665807c
...
...
@@ -6,6 +6,7 @@
*/
package
org
.
h2
.
value
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
...
...
@@ -18,6 +19,9 @@ import org.h2.util.MathUtils;
*/
public
class
ValueLong
extends
Value
{
public
static
final
BigInteger
MAX
=
BigInteger
.
valueOf
(
Long
.
MAX_VALUE
);
public
static
final
BigDecimal
MIN_BD
=
BigDecimal
.
valueOf
(
Long
.
MIN_VALUE
);
/**
* The precision in digits.
*/
...
...
@@ -29,10 +33,9 @@ public class ValueLong extends Value {
*/
public
static
final
int
DISPLAY_SIZE
=
20
;
private
static
final
BigInteger
MIN
=
BigInteger
.
valueOf
(
Long
.
MIN_VALUE
);
private
static
final
int
STATIC_SIZE
=
100
;
private
static
final
ValueLong
[]
STATIC_CACHE
;
private
static
final
BigInteger
MIN
=
BigInteger
.
valueOf
(
Long
.
MIN_VALUE
);
private
static
final
BigInteger
MAX
=
BigInteger
.
valueOf
(
Long
.
MAX_VALUE
);
private
final
long
value
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/jdbc/TestResultSet.java
浏览文件 @
3665807c
...
...
@@ -11,6 +11,7 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.sql.Array
;
import
java.sql.Connection
;
import
java.sql.DatabaseMetaData
;
...
...
@@ -53,6 +54,7 @@ public class TestResultSet extends TestBase {
stat
=
conn
.
createStatement
();
testParseSpecialValues
();
testSpecialLocale
();
testSubstringPrecision
();
testSubstringDataType
();
...
...
@@ -86,6 +88,32 @@ public class TestResultSet extends TestBase {
}
private
void
testParseSpecialValues
()
throws
SQLException
{
for
(
int
i
=
-
10
;
i
<
10
;
i
++)
{
testParseSpecialValue
(
""
+
((
long
)
Integer
.
MIN_VALUE
+
i
));
testParseSpecialValue
(
""
+
((
long
)
Integer
.
MAX_VALUE
+
i
));
BigInteger
bi
=
BigInteger
.
valueOf
(
i
);
testParseSpecialValue
(
bi
.
add
(
BigInteger
.
valueOf
(
Long
.
MIN_VALUE
)).
toString
());
testParseSpecialValue
(
bi
.
add
(
BigInteger
.
valueOf
(
Long
.
MAX_VALUE
)).
toString
());
}
}
private
void
testParseSpecialValue
(
String
x
)
throws
SQLException
{
Object
expected
;
expected
=
new
BigDecimal
(
x
);
try
{
expected
=
Long
.
decode
(
x
);
expected
=
Integer
.
decode
(
x
);
}
catch
(
Exception
e
)
{
// ignore
}
ResultSet
rs
=
stat
.
executeQuery
(
"call "
+
x
);
rs
.
next
();
Object
o
=
rs
.
getObject
(
1
);
assertEquals
(
expected
.
getClass
().
getName
(),
o
.
getClass
().
getName
());
assertTrue
(
expected
.
equals
(
o
));
}
private
void
testSpecialLocale
()
throws
SQLException
{
Locale
old
=
Locale
.
getDefault
();
try
{
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论