MCPcopy Create free account
hub / github.com/ByConity/ByConity / joinLines

Function joinLines

src/Interpreters/executeQuery.cpp:366–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

364
365
366static String joinLines(const String & query)
367{
368 /// Care should be taken. We don't join lines inside non-whitespace tokens (e.g. multiline string literals)
369 /// and we don't join line after comment (because it can be single-line comment).
370 /// All other whitespaces replaced to a single whitespace.
371
372 String res;
373 const char * begin = query.data();
374 const char * end = begin + query.size();
375
376 Lexer lexer(begin, end);
377 Token token = lexer.nextToken();
378 for (; !token.isEnd(); token = lexer.nextToken())
379 {
380 if (token.type == TokenType::Whitespace)
381 {
382 res += ' ';
383 }
384 else if (token.type == TokenType::Comment)
385 {
386 res.append(token.begin, token.end);
387 if (token.end < end && *token.end == '\n')
388 res += '\n';
389 }
390 else
391 res.append(token.begin, token.end);
392 }
393
394 return res;
395}
396
397
398static String prepareQueryForLogging(const String & query, ContextPtr context)

Callers 2

logQueryFunction · 0.85
logExceptionFunction · 0.85

Calls 5

nextTokenMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
isEndMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected