mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
dbms: more uniform logging of query, logging client IP address [#METR-16277].
This commit is contained in:
parent
fc9bbaa2c1
commit
1b61065f50
@ -24,6 +24,14 @@ static void checkLimits(const IAST & ast, const Limits & limits)
|
||||
}
|
||||
|
||||
|
||||
static void logQuery(const String & query, const Context & context)
|
||||
{
|
||||
String logged_query = query;
|
||||
std::replace(logged_query.begin(), logged_query.end(), '\n', ' ');
|
||||
LOG_DEBUG(&Logger::get("executeQuery"), "(from " << context.getIPAddress().toString() << ") " << logged_query);
|
||||
}
|
||||
|
||||
|
||||
void executeQuery(
|
||||
ReadBuffer & istr,
|
||||
WriteBuffer & ostr,
|
||||
@ -73,9 +81,7 @@ void executeQuery(
|
||||
|
||||
String query(begin, query_size);
|
||||
|
||||
String logged_query = query;
|
||||
std::replace(logged_query.begin(), logged_query.end(), '\n', ' ');
|
||||
LOG_DEBUG(&Logger::get("executeQuery"), logged_query);
|
||||
logQuery(query, context);
|
||||
|
||||
/// Положим запрос в список процессов. Но запрос SHOW PROCESSLIST класть не будем.
|
||||
ProcessList::EntryPtr process_list_entry;
|
||||
@ -124,6 +130,8 @@ BlockIO executeQuery(
|
||||
ParserQuery parser;
|
||||
ASTPtr ast = parseQuery(parser, query.data(), query.data() + query.size(), "");
|
||||
|
||||
logQuery(query, context);
|
||||
|
||||
/// Проверка ограничений.
|
||||
checkLimits(*ast, context.getSettingsRef().limits);
|
||||
|
||||
|
@ -568,10 +568,6 @@ void TCPHandler::receiveQuery()
|
||||
state.compression = Protocol::Compression::Enum(compression);
|
||||
|
||||
readStringBinary(state.query, *in);
|
||||
|
||||
LOG_DEBUG(log, "Query ID: " << state.query_id);
|
||||
LOG_DEBUG(log, "Query: " << state.query);
|
||||
LOG_DEBUG(log, "Requested stage: " << QueryProcessingStage::toString(stage));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user