mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Added Query-Id to http response header
This commit is contained in:
parent
51dd2198f0
commit
7294b8adf2
@ -296,7 +296,7 @@ void LocalServer::processQueries()
|
||||
|
||||
try
|
||||
{
|
||||
executeQuery(read_buf, write_buf, /* allow_into_outfile = */ true, *context, {});
|
||||
executeQuery(read_buf, write_buf, /* allow_into_outfile = */ true, *context, {}, {});
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
@ -563,7 +563,8 @@ void HTTPHandler::processQuery(
|
||||
context.setProgressCallback([&used_output] (const Progress & progress) { used_output.out->onProgress(progress); });
|
||||
|
||||
executeQuery(*in, *used_output.out_maybe_delayed_and_compressed, /* allow_into_outfile = */ false, context,
|
||||
[&response] (const String & content_type) { response.setContentType(content_type); });
|
||||
[&response] (const String & content_type) { response.setContentType(content_type); },
|
||||
[&response] (const String & current_query_id) { response.add("Query-Id", current_query_id); });
|
||||
|
||||
if (used_output.hasDelayed())
|
||||
{
|
||||
|
@ -528,7 +528,7 @@ bool DDLWorker::tryExecuteQuery(const String & query, const DDLTask & task, Exec
|
||||
{
|
||||
current_context = std::make_unique<Context>(context);
|
||||
current_context->setCurrentQueryId(""); // generate random query_id
|
||||
executeQuery(istr, ostr, false, *current_context, nullptr);
|
||||
executeQuery(istr, ostr, false, *current_context, nullptr, nullptr);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
@ -438,7 +438,8 @@ void executeQuery(
|
||||
WriteBuffer & ostr,
|
||||
bool allow_into_outfile,
|
||||
Context & context,
|
||||
std::function<void(const String &)> set_content_type)
|
||||
std::function<void(const String &)> set_content_type,
|
||||
std::function<void(const String &)> set_query_id)
|
||||
{
|
||||
PODArray<char> parse_buf;
|
||||
const char * begin;
|
||||
@ -521,6 +522,9 @@ void executeQuery(
|
||||
if (set_content_type)
|
||||
set_content_type(out->getContentType());
|
||||
|
||||
if (set_query_id)
|
||||
set_query_id(context.getClientInfo().current_query_id);
|
||||
|
||||
copyData(*streams.in, *out);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,8 @@ void executeQuery(
|
||||
WriteBuffer & ostr, /// Where to write query output to.
|
||||
bool allow_into_outfile, /// If true and the query contains INTO OUTFILE section, redirect output to that file.
|
||||
Context & context, /// DB, tables, data types, storage engines, functions, aggregate functions...
|
||||
std::function<void(const String &)> set_content_type /// If non-empty callback is passed, it will be called with the Content-Type of the result.
|
||||
std::function<void(const String &)> set_content_type, /// If non-empty callback is passed, it will be called with the Content-Type of the result.
|
||||
std::function<void(const String &)> set_query_id /// If non-empty callback is passed, it will be called with the query id.
|
||||
);
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ try
|
||||
ReadBufferFromFileDescriptor in(STDIN_FILENO);
|
||||
WriteBufferFromFileDescriptor out(STDOUT_FILENO);
|
||||
|
||||
executeQuery(in, out, /* allow_into_outfile = */ false, context, {});
|
||||
executeQuery(in, out, /* allow_into_outfile = */ false, context, {}, {});
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
Query-Id
|
7
dbms/tests/queries/0_stateless/00825_http_header_query_id.sh
Executable file
7
dbms/tests/queries/0_stateless/00825_http_header_query_id.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
. $CURDIR/../shell_config.sh
|
||||
|
||||
${CLICKHOUSE_CURL_COMMAND} -I -sSg ${CLICKHOUSE_URL}?query=SELECT%201 | grep -o Query-Id
|
Loading…
Reference in New Issue
Block a user