dbms: more uniform logging of query, logging client IP address [#METR-16277].

This commit is contained in:
Alexey Milovidov 2015-06-18 00:34:15 +03:00
parent fc9bbaa2c1
commit 1b61065f50
2 changed files with 11 additions and 7 deletions

View File

@ -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);

View File

@ -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));
}