Merge pull request #12522 from ClickHouse/aku/std-logic-error

Abort on std::logic_error in debug builds
This commit is contained in:
Alexander Kuzmenkov 2020-07-20 14:50:03 +03:00 committed by GitHub
commit 232cd2648f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -47,6 +47,10 @@ void MarkTableIdentifiersMatcher::visit(const ASTFunction & func, ASTPtr &, Data
// First argument of dictGet can be a dictionary name, perhaps with a database. // First argument of dictGet can be a dictionary name, perhaps with a database.
if (functionIsJoinGet(func.name) || functionIsDictGet(func.name)) if (functionIsJoinGet(func.name) || functionIsDictGet(func.name))
{ {
if (func.arguments->children.empty())
{
return;
}
auto & ast = func.arguments->children.at(0); auto & ast = func.arguments->children.at(0);
auto opt_name = tryGetIdentifierName(ast); auto opt_name = tryGetIdentifierName(ast);
if (opt_name && !data.aliases.count(*opt_name)) if (opt_name && !data.aliases.count(*opt_name))

View File

@ -313,6 +313,18 @@ void TCPHandler::runImpl()
state.io.onException(); state.io.onException();
exception.emplace(Exception::CreateFromPocoTag{}, e); exception.emplace(Exception::CreateFromPocoTag{}, e);
} }
// Server should die on std logic errors in debug, like with assert()
// or ErrorCodes::LOGICAL_ERROR. This helps catch these errors in
// tests.
#ifndef NDEBUG
catch (const std::logic_error & e)
{
state.io.onException();
exception.emplace(Exception::CreateFromSTDTag{}, e);
sendException(*exception, send_exception_with_stack_trace);
std::abort();
}
#endif
catch (const std::exception & e) catch (const std::exception & e)
{ {
state.io.onException(); state.io.onException();