Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Questdb
提交
e13cf869
Q
Questdb
项目概览
jobily
/
Questdb
10 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
Questdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e13cf869
编写于
7月 31, 2019
作者:
V
Vlad Ilyushchenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PG: added some edge-tests for postgres wire (protocol abuse tests)
上级
2eaa1238
变更
2
展开全部
显示空白变更内容
内联
并排
Showing
2 changed file
with
283 addition
and
127 deletion
+283
-127
core/src/main/java/com/questdb/cutlass/pgwire/PGConnectionContext.java
.../java/com/questdb/cutlass/pgwire/PGConnectionContext.java
+32
-20
core/src/test/java/com/questdb/cutlass/pgwire/PGJobContextTest.java
...est/java/com/questdb/cutlass/pgwire/PGJobContextTest.java
+251
-107
未找到文件。
core/src/main/java/com/questdb/cutlass/pgwire/PGConnectionContext.java
浏览文件 @
e13cf869
...
...
@@ -316,6 +316,7 @@ public class PGConnectionContext implements IOContext, Mutable {
try
{
bindVariableService
.
setByte
(
index
,
(
byte
)
Numbers
.
parseInt
(
dbcs
.
of
(
address
,
address
+
valueLen
)));
}
catch
(
NumericException
e
)
{
LOG
.
error
().
$
(
"bad byte variable value [index="
).
$
(
index
).
$
(
", value=`"
).
$
(
dbcs
).
$
(
"`"
).
$
();
throw
BadProtocolException
.
INSTANCE
;
}
}
...
...
@@ -342,6 +343,7 @@ public class PGConnectionContext implements IOContext, Mutable {
try
{
bindVariableService
.
setDouble
(
index
,
Numbers
.
parseDouble
(
dbcs
.
of
(
address
,
address
+
valueLen
)));
}
catch
(
NumericException
e
)
{
LOG
.
error
().
$
(
"bad double variable value [index="
).
$
(
index
).
$
(
", value=`"
).
$
(
dbcs
).
$
(
"`]"
).
$
();
throw
BadProtocolException
.
INSTANCE
;
}
}
...
...
@@ -368,6 +370,7 @@ public class PGConnectionContext implements IOContext, Mutable {
try
{
bindVariableService
.
setInt
(
index
,
Numbers
.
parseInt
(
dbcs
.
of
(
address
,
address
+
valueLen
)));
}
catch
(
NumericException
e
)
{
LOG
.
error
().
$
(
"bad int variable value [index="
).
$
(
index
).
$
(
", value=`"
).
$
(
dbcs
).
$
(
"`]"
).
$
();
throw
BadProtocolException
.
INSTANCE
;
}
}
...
...
@@ -381,6 +384,7 @@ public class PGConnectionContext implements IOContext, Mutable {
try
{
bindVariableService
.
setLong
(
index
,
Numbers
.
parseLong
(
dbcs
.
of
(
address
,
address
+
valueLen
)));
}
catch
(
NumericException
e
)
{
LOG
.
error
().
$
(
"bad long variable value [index="
).
$
(
index
).
$
(
", value=`"
).
$
(
dbcs
).
$
(
"`]"
).
$
();
throw
BadProtocolException
.
INSTANCE
;
}
}
...
...
@@ -401,6 +405,7 @@ public class PGConnectionContext implements IOContext, Mutable {
private
static
void
ensureValueLength
(
int
required
,
int
valueLen
)
throws
BadProtocolException
{
if
(
required
!=
valueLen
)
{
LOG
.
error
().
$
(
"bad parameter value length [required="
).
$
(
required
).
$
(
", actual="
).
$
(
valueLen
).
$
(
']'
).
$
();
throw
BadProtocolException
.
INSTANCE
;
}
}
...
...
@@ -761,7 +766,6 @@ public class PGConnectionContext implements IOContext, Mutable {
switch
(
type
)
{
case
'P'
:
prepareForNewQuery
();
// 'Parse'
// this appears to be the execution side - we must at least return 'RowDescription'
// possibly more, check QueryExecutionImpl.processResults() in PG driver for more info
...
...
@@ -781,14 +785,8 @@ public class PGConnectionContext implements IOContext, Mutable {
throw
BadProtocolException
.
INSTANCE
;
}
CharacterStoreEntry
e
=
queryCharacterStore
.
newEntry
();
if
(
Chars
.
utf8Decode
(
lo
,
hi
,
e
))
{
queryText
=
queryCharacterStore
.
toImmutable
();
LOG
.
info
().
$
(
"parse [q="
).
utf8
(
queryText
).
$
(
']'
).
$
();
}
else
{
LOG
.
error
().
$
(
"invalid UTF8 bytes in parse query"
).
$
();
throw
BadProtocolException
.
INSTANCE
;
}
prepareForNewQuery
();
parseQueryText
(
lo
,
hi
);
lo
=
hi
+
1
;
if
(
lo
+
Short
.
BYTES
>
msgLimit
)
{
...
...
@@ -894,15 +892,7 @@ public class PGConnectionContext implements IOContext, Mutable {
case
'Q'
:
// vanilla query
prepareForNewQuery
();
e
=
queryCharacterStore
.
newEntry
();
if
(
Chars
.
utf8Decode
(
lo
,
limit
-
1
,
e
))
{
queryText
=
queryCharacterStore
.
toImmutable
();
LOG
.
info
().
$
(
"simple query [q="
).
utf8
(
queryText
).
$
(
']'
).
$
();
}
else
{
LOG
.
error
().
$
(
"invalid UTF8 bytes in simple query"
).
$
();
throw
BadProtocolException
.
INSTANCE
;
}
parseQueryText
(
lo
,
limit
-
1
);
currentFactory
=
factoryCache
.
peek
(
queryText
);
if
(
currentFactory
==
null
)
{
...
...
@@ -955,6 +945,17 @@ public class PGConnectionContext implements IOContext, Mutable {
}
}
private
void
parseQueryText
(
long
lo
,
long
hi
)
throws
BadProtocolException
{
CharacterStoreEntry
e
=
queryCharacterStore
.
newEntry
();
if
(
Chars
.
utf8Decode
(
lo
,
hi
,
e
))
{
queryText
=
queryCharacterStore
.
toImmutable
();
LOG
.
info
().
$
(
"parse [q="
).
utf8
(
queryText
).
$
(
']'
).
$
();
}
else
{
LOG
.
error
().
$
(
"invalid UTF8 bytes in parse query"
).
$
();
throw
BadProtocolException
.
INSTANCE
;
}
}
void
prepareCommandComplete
()
{
responseAsciiSink
.
put
(
MESSAGE_TYPE_COMMAND_COMPLETE
);
long
addr
=
responseAsciiSink
.
skip
();
...
...
@@ -1069,7 +1070,12 @@ public class PGConnectionContext implements IOContext, Mutable {
log
.
$
(
"property ["
);
try
{
long
hi
=
getStringLength
(
lo
,
msgLimit
);
assert
hi
>
-
1
;
if
(
hi
==
-
1
)
{
// we did not find 0 within message limit
log
.
$
(
"malformed property name"
);
throw
BadProtocolException
.
INSTANCE
;
}
log
.
$
(
"name="
).
$
(
dbcs
.
of
(
lo
,
hi
));
final
boolean
username
=
Chars
.
equals
(
"user"
,
dbcs
);
...
...
@@ -1077,7 +1083,12 @@ public class PGConnectionContext implements IOContext, Mutable {
// name is ready
lo
=
hi
+
1
;
hi
=
getStringLength
(
lo
,
msgLimit
);
assert
hi
>
-
1
;
if
(
hi
==
-
1
)
{
// we did not find 0 within message limit
log
.
$
(
", malformed property value"
);
throw
BadProtocolException
.
INSTANCE
;
}
log
.
$
(
", value="
).
$
(
dbcs
.
of
(
lo
,
hi
));
lo
=
hi
+
1
;
if
(
username
)
{
...
...
@@ -1128,6 +1139,7 @@ public class PGConnectionContext implements IOContext, Mutable {
}
if
(
n
<
0
)
{
LOG
.
info
().
$
(
"disconnect [code="
).
$
(
n
).
$
(
']'
).
$
();
throw
PeerDisconnectedException
.
INSTANCE
;
}
...
...
core/src/test/java/com/questdb/cutlass/pgwire/PGJobContextTest.java
浏览文件 @
e13cf869
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录