mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 17:32:32 +00:00
c29768325c
executeQuery() logging query without new lines in SQL, and it is useful, since you can grep and see the whole query (usually). So let's use the same in fatal error handler to make CI reports more informative. Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
35 lines
738 B
C++
35 lines
738 B
C++
#include <Parsers/toOneLineQuery.h>
|
|
#include <Parsers/Lexer.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
String toOneLineQuery(const String & query)
|
|
{
|
|
String res;
|
|
const char * begin = query.data();
|
|
const char * end = begin + query.size();
|
|
|
|
Lexer lexer(begin, end);
|
|
Token token = lexer.nextToken();
|
|
for (; !token.isEnd(); token = lexer.nextToken())
|
|
{
|
|
if (token.type == TokenType::Whitespace)
|
|
{
|
|
res += ' ';
|
|
}
|
|
else if (token.type == TokenType::Comment)
|
|
{
|
|
res.append(token.begin, token.end);
|
|
if (token.end < end && *token.end == '\n')
|
|
res += '\n';
|
|
}
|
|
else
|
|
res.append(token.begin, token.end);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
}
|