mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 10:02:01 +00:00
Added setting 'log_queries_cut_to_length' [#METR-21843].
This commit is contained in:
parent
c68d6ea303
commit
d9b8b74180
@ -162,6 +162,11 @@ struct Settings
|
|||||||
/** Логгировать запросы и писать лог в системную таблицу. */ \
|
/** Логгировать запросы и писать лог в системную таблицу. */ \
|
||||||
M(SettingBool, log_queries, 0) \
|
M(SettingBool, log_queries, 0) \
|
||||||
\
|
\
|
||||||
|
/** If query length is greater than specified threshold (in bytes), then cut query when writing to query log. \
|
||||||
|
* Also limit length of printed query in ordinary text log. \
|
||||||
|
*/ \
|
||||||
|
M(SettingUInt64, log_queries_cut_to_length, 100000) \
|
||||||
|
\
|
||||||
/** Как выполняются распределённые подзапросы внутри секций IN или JOIN? */ \
|
/** Как выполняются распределённые подзапросы внутри секций IN или JOIN? */ \
|
||||||
M(SettingDistributedProductMode, distributed_product_mode, DistributedProductMode::DENY) \
|
M(SettingDistributedProductMode, distributed_product_mode, DistributedProductMode::DENY) \
|
||||||
\
|
\
|
||||||
|
@ -75,7 +75,7 @@ static void onExceptionBeforeStart(const String & query, Context & context, time
|
|||||||
elem.event_time = current_time;
|
elem.event_time = current_time;
|
||||||
elem.query_start_time = current_time;
|
elem.query_start_time = current_time;
|
||||||
|
|
||||||
elem.query = query;
|
elem.query = query.substr(0, context.getSettingsRef().log_queries_cut_to_length);
|
||||||
elem.exception = getCurrentExceptionMessage(false);
|
elem.exception = getCurrentExceptionMessage(false);
|
||||||
|
|
||||||
setClientInfo(elem, context);
|
setClientInfo(elem, context);
|
||||||
@ -105,10 +105,12 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
|
|||||||
ProfileEvents::increment(ProfileEvents::Query);
|
ProfileEvents::increment(ProfileEvents::Query);
|
||||||
time_t current_time = time(0);
|
time_t current_time = time(0);
|
||||||
|
|
||||||
|
const Settings & settings = context.getSettingsRef();
|
||||||
|
|
||||||
ParserQuery parser;
|
ParserQuery parser;
|
||||||
ASTPtr ast;
|
ASTPtr ast;
|
||||||
size_t query_size;
|
size_t query_size;
|
||||||
size_t max_query_size = context.getSettingsRef().max_query_size;
|
size_t max_query_size = settings.max_query_size;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -127,7 +129,7 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
|
|||||||
if (!internal)
|
if (!internal)
|
||||||
{
|
{
|
||||||
String query = String(begin, begin + std::min(end - begin, static_cast<ptrdiff_t>(max_query_size)));
|
String query = String(begin, begin + std::min(end - begin, static_cast<ptrdiff_t>(max_query_size)));
|
||||||
logQuery(query, context);
|
logQuery(query.substr(0, settings.log_queries_cut_to_length), context);
|
||||||
onExceptionBeforeStart(query, context, current_time);
|
onExceptionBeforeStart(query, context, current_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,18 +142,16 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!internal)
|
if (!internal)
|
||||||
logQuery(query, context);
|
logQuery(query.substr(0, settings.log_queries_cut_to_length), context);
|
||||||
|
|
||||||
/// Проверка ограничений.
|
/// Проверка ограничений.
|
||||||
checkLimits(*ast, context.getSettingsRef().limits);
|
checkLimits(*ast, settings.limits);
|
||||||
|
|
||||||
QuotaForIntervals & quota = context.getQuota();
|
QuotaForIntervals & quota = context.getQuota();
|
||||||
|
|
||||||
quota.addQuery(current_time);
|
quota.addQuery(current_time);
|
||||||
quota.checkExceeded(current_time);
|
quota.checkExceeded(current_time);
|
||||||
|
|
||||||
const Settings & settings = context.getSettingsRef();
|
|
||||||
|
|
||||||
/// Положим запрос в список процессов. Но запрос SHOW PROCESSLIST класть не будем.
|
/// Положим запрос в список процессов. Но запрос SHOW PROCESSLIST класть не будем.
|
||||||
ProcessList::EntryPtr process_list_entry;
|
ProcessList::EntryPtr process_list_entry;
|
||||||
if (!internal && nullptr == typeid_cast<const ASTShowProcesslistQuery *>(&*ast))
|
if (!internal && nullptr == typeid_cast<const ASTShowProcesslistQuery *>(&*ast))
|
||||||
@ -190,7 +190,7 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
|
|||||||
elem.event_time = current_time;
|
elem.event_time = current_time;
|
||||||
elem.query_start_time = current_time;
|
elem.query_start_time = current_time;
|
||||||
|
|
||||||
elem.query = query;
|
elem.query = query.substr(0, settings.log_queries_cut_to_length);
|
||||||
|
|
||||||
setClientInfo(elem, context);
|
setClientInfo(elem, context);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user