Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions src/Storages/System/StorageSystemDDLWorkerQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ namespace Setting
extern const SettingsUInt64 max_query_size;
}

namespace ErrorCodes
{
extern const int SYNTAX_ERROR;
}

enum class Status : uint8_t
{
INACTIVE,
Expand Down Expand Up @@ -62,7 +67,7 @@ ColumnsDescription StorageSystemDDLWorkerQueue::getColumnsDescription()
{"entry_version", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt8>()), "Version of the entry."},
{"initiator_host", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeString>()), "Host that initiated the DDL operation."},
{"initiator_port", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt16>()), "Port used by the initiator."},
{"cluster", std::make_shared<DataTypeString>(), "Cluster name."},
{"cluster", std::make_shared<DataTypeString>(), "Cluster name, empty if not determined."},
{"query", std::make_shared<DataTypeString>(), "Query executed."},
{"settings", std::make_shared<DataTypeMap>(std::make_shared<DataTypeString>(), std::make_shared<DataTypeString>()), "Settings used in the DDL operation."},
{"query_create_time", std::make_shared<DataTypeDateTime>(), "Query created time."},
Expand All @@ -85,8 +90,23 @@ static String clusterNameFromDDLQuery(ContextPtr context, const DDLTask & task)

String description = fmt::format("from {}", task.entry_path);
ParserQuery parser_query(end, settings[Setting::allow_settings_after_format_in_insert]);
ASTPtr query = parseQuery(
parser_query, begin, end, description, settings[Setting::max_query_size], settings[Setting::max_parser_depth], settings[Setting::max_parser_backtracks]);
ASTPtr query;

try
{
query = parseQuery(
parser_query, begin, end, description, settings[Setting::max_query_size], settings[Setting::max_parser_depth], settings[Setting::max_parser_backtracks]);
}
catch (const Exception & e)
{
LOG_INFO(getLogger("StorageSystemDDLWorkerQueue"), "Failed to determine cluster");
if (e.code() == ErrorCodes::SYNTAX_ERROR)
{
/// ignore parse error and present available information
return "";
}
throw;
}

String cluster_name;
if (const auto * query_on_cluster = dynamic_cast<const ASTQueryWithOnCluster *>(query.get()))
Expand Down
Loading