Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
bb06b10c
提交
bb06b10c
authored
7 年前
作者:
Niklas Mehner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug in parser when "ALLOW_LITERALS=NONE" is set: parameter indices are not "literals"
上级
78cc4925
master
noel-pr1
stumc-Issue#576
version-1.4.198
version-1.4.197
无相关合并请求
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
50 行增加
和
3 行删除
+50
-3
Parser.java
h2/src/main/org/h2/command/Parser.java
+28
-3
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+22
-0
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
bb06b10c
...
...
@@ -2812,10 +2812,10 @@ public class Parser {
case
PARAMETER:
// there must be no space between ? and the number
boolean
indexed
=
Character
.
isDigit
(
sqlCommandChars
[
parseIndex
]);
read
();
Parameter
p
;
if
(
indexed
&&
currentTokenType
==
VALUE
&&
currentValue
.
getType
()
==
Value
.
INT
)
{
if
(
indexed
)
{
readParameterIndex
();
if
(
indexedParameterList
==
null
)
{
if
(
parameters
==
null
)
{
// this can occur when parsing expressions only (for
...
...
@@ -2845,6 +2845,7 @@ public class Parser {
}
read
();
}
else
{
read
();
if
(
indexedParameterList
!=
null
)
{
throw
DbException
.
get
(
ErrorCode
.
CANNOT_MIX_INDEXED_AND_UNINDEXED_PARAMS
);
...
...
@@ -3481,6 +3482,30 @@ public class Parser {
}
}
private
void
readParameterIndex
()
{
int
i
=
parseIndex
;
char
[]
chars
=
sqlCommandChars
;
char
c
=
chars
[
i
++];
long
number
=
c
-
'0'
;
while
(
true
)
{
c
=
chars
[
i
];
if
(
c
<
'0'
||
c
>
'9'
)
{
currentValue
=
ValueInt
.
get
((
int
)
number
);
currentTokenType
=
VALUE
;
currentToken
=
"0"
;
parseIndex
=
i
;
break
;
}
number
=
number
*
10
+
(
c
-
'0'
);
if
(
number
>
Integer
.
MAX_VALUE
)
{
throw
DbException
.
getInvalidValueException
(
"parameter index"
,
number
);
}
i
++;
}
}
private
void
checkLiterals
(
boolean
text
)
{
if
(!
session
.
getAllowLiterals
())
{
int
allowed
=
database
.
getAllowLiterals
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
bb06b10c
...
...
@@ -95,6 +95,7 @@ public class TestPreparedStatement extends TestBase {
testColumnMetaDataWithIn
(
conn
);
conn
.
close
();
testPreparedStatementWithLiteralsNone
();
testPreparedStatementWithIndexedParameterAndLiteralsNone
();
deleteDb
(
"preparedStatement"
);
}
...
...
@@ -1420,6 +1421,27 @@ public class TestPreparedStatement extends TestBase {
deleteDb
(
"preparedStatement"
);
}
private
void
testPreparedStatementWithIndexedParameterAndLiteralsNone
()
throws
SQLException
{
// make sure that when the analyze table kicks in,
// it works with ALLOW_LITERALS=NONE
deleteDb
(
"preparedStatement"
);
Connection
conn
=
getConnection
(
"preparedStatement;ANALYZE_AUTO=100"
);
conn
.
createStatement
().
execute
(
"SET ALLOW_LITERALS NONE"
);
conn
.
prepareStatement
(
"CREATE TABLE test (id INT)"
).
execute
();
PreparedStatement
ps
=
conn
.
prepareStatement
(
"INSERT INTO test (id) VALUES (?1)"
);
ps
.
setInt
(
1
,
1
);
ps
.
executeUpdate
();
conn
.
close
();
deleteDb
(
"preparedStatement"
);
}
private
void
checkBigDecimal
(
ResultSet
rs
,
String
[]
value
)
throws
SQLException
{
for
(
String
v
:
value
)
{
assertTrue
(
rs
.
next
());
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论