Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
98d28706
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
98d28706
编写于
5月 29, 2019
作者:
D
Danila Kutenin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix settings in ExternalData HTTP request
上级
0c2aa460
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
31 deletion
+43
-31
dbms/programs/server/HTTPHandler.cpp
dbms/programs/server/HTTPHandler.cpp
+40
-31
dbms/tests/queries/0_stateless/00304_http_external_data.reference
...ts/queries/0_stateless/00304_http_external_data.reference
+2
-0
dbms/tests/queries/0_stateless/00304_http_external_data.sh
dbms/tests/queries/0_stateless/00304_http_external_data.sh
+1
-0
未找到文件。
dbms/programs/server/HTTPHandler.cpp
浏览文件 @
98d28706
...
...
@@ -453,30 +453,6 @@ void HTTPHandler::processQuery(
return
false
;
};
/// Used in case of POST request with form-data, but it isn't expected to be deleted after that scope.
std
::
string
full_query
;
/// Support for "external data for query processing".
if
(
startsWith
(
request
.
getContentType
().
data
(),
"multipart/form-data"
))
{
ExternalTablesHandler
handler
(
context
,
params
);
params
.
load
(
request
,
istr
,
handler
);
/// Skip unneeded parameters to avoid confusing them later with context settings or query parameters.
reserved_param_suffixes
.
emplace_back
(
"_format"
);
reserved_param_suffixes
.
emplace_back
(
"_types"
);
reserved_param_suffixes
.
emplace_back
(
"_structure"
);
/// Params are of both form params POST and uri (GET params)
for
(
const
auto
&
it
:
params
)
if
(
it
.
first
==
"query"
)
full_query
+=
it
.
second
;
in
=
std
::
make_unique
<
ReadBufferFromString
>
(
full_query
);
}
else
in
=
std
::
make_unique
<
ConcatReadBuffer
>
(
*
in_param
,
*
in_post_maybe_compressed
);
/// Settings can be overridden in the query.
/// Some parameters (database, default_format, everything used in the code above) do not
/// belong to the Settings class.
...
...
@@ -497,30 +473,63 @@ void HTTPHandler::processQuery(
settings
.
readonly
=
2
;
}
bool
isExternalData
=
startsWith
(
request
.
getContentType
().
data
(),
"multipart/form-data"
);
if
(
isExternalData
)
{
/// Skip unneeded parameters to avoid confusing them later with context settings or query parameters.
reserved_param_suffixes
.
reserve
(
3
);
/// It is a bug and ambiguity with `date_time_input_format` and `low_cardinality_allow_in_native_format` formats/settings.
reserved_param_suffixes
.
emplace_back
(
"_format"
);
reserved_param_suffixes
.
emplace_back
(
"_types"
);
reserved_param_suffixes
.
emplace_back
(
"_structure"
);
}
SettingsChanges
settings_changes
;
for
(
auto
it
=
params
.
begin
();
it
!=
params
.
end
();
++
it
)
for
(
const
auto
&
[
key
,
value
]
:
params
)
{
if
(
it
->
first
==
"database"
)
if
(
key
==
"database"
)
{
context
.
setCurrentDatabase
(
it
->
second
);
context
.
setCurrentDatabase
(
value
);
}
else
if
(
it
->
first
==
"default_format"
)
else
if
(
key
==
"default_format"
)
{
context
.
setDefaultFormat
(
it
->
second
);
context
.
setDefaultFormat
(
value
);
}
else
if
(
param_could_be_skipped
(
it
->
first
))
else
if
(
param_could_be_skipped
(
key
))
{
}
else
{
/// All other query parameters are treated as settings.
settings_changes
.
push_back
({
it
->
first
,
it
->
second
});
settings_changes
.
push_back
({
key
,
value
});
}
}
/// For external data we also want settings
context
.
checkSettingsConstraints
(
settings_changes
);
context
.
applySettingsChanges
(
settings_changes
);
/// Used in case of POST request with form-data, but it isn't expected to be deleted after that scope.
std
::
string
full_query
;
/// Support for "external data for query processing".
if
(
isExternalData
)
{
ExternalTablesHandler
handler
(
context
,
params
);
params
.
load
(
request
,
istr
,
handler
);
/// Params are of both form params POST and uri (GET params)
for
(
const
auto
&
it
:
params
)
if
(
it
.
first
==
"query"
)
full_query
+=
it
.
second
;
in
=
std
::
make_unique
<
ReadBufferFromString
>
(
full_query
);
}
else
in
=
std
::
make_unique
<
ConcatReadBuffer
>
(
*
in_param
,
*
in_post_maybe_compressed
);
/// HTTP response compression is turned on only if the client signalled that they support it
/// (using Accept-Encoding header) and 'enable_http_compression' setting is turned on.
used_output
.
out
->
setCompression
(
client_supports_http_compression
&&
settings
.
enable_http_compression
);
...
...
dbms/tests/queries/0_stateless/00304_http_external_data.reference
浏览文件 @
98d28706
1 Hello
2 World
1 Hello
2 World
dbms/tests/queries/0_stateless/00304_http_external_data.sh
浏览文件 @
98d28706
...
...
@@ -4,3 +4,4 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
.
$CURDIR
/../shell_config.sh
echo
-ne
'1,Hello\n2,World\n'
|
${
CLICKHOUSE_CURL
}
-sSF
'file=@-'
"
${
CLICKHOUSE_URL
}
?query=SELECT+*+FROM+file&file_format=CSV&file_types=UInt8,String"
;
echo
-ne
'1@Hello\n2@World\n'
|
${
CLICKHOUSE_CURL
}
-sSF
'file=@-'
"
${
CLICKHOUSE_URL
}
?query=SELECT+*+FROM+file&file_format=CSV&file_types=UInt8,String&format_csv_delimiter=@"
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录