mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Fixed bad code in Client.cpp [#CLICKHOUSE-2].
This commit is contained in:
parent
99a19de80e
commit
548cb4e658
@ -14,6 +14,9 @@
|
|||||||
#include <Poco/File.h>
|
#include <Poco/File.h>
|
||||||
#include <Poco/Util/Application.h>
|
#include <Poco/Util/Application.h>
|
||||||
|
|
||||||
|
#include <common/readline_use.h>
|
||||||
|
#include <common/find_first_symbols.h>
|
||||||
|
|
||||||
#include <Common/ClickHouseRevision.h>
|
#include <Common/ClickHouseRevision.h>
|
||||||
#include <Common/Stopwatch.h>
|
#include <Common/Stopwatch.h>
|
||||||
#include <Common/Exception.h>
|
#include <Common/Exception.h>
|
||||||
@ -22,7 +25,6 @@
|
|||||||
#include <Common/UnicodeBar.h>
|
#include <Common/UnicodeBar.h>
|
||||||
#include <Common/formatReadable.h>
|
#include <Common/formatReadable.h>
|
||||||
#include <Common/NetException.h>
|
#include <Common/NetException.h>
|
||||||
#include <common/readline_use.h>
|
|
||||||
#include <Common/Throttler.h>
|
#include <Common/Throttler.h>
|
||||||
#include <Common/typeid_cast.h>
|
#include <Common/typeid_cast.h>
|
||||||
#include <Core/Types.h>
|
#include <Core/Types.h>
|
||||||
@ -528,22 +530,23 @@ private:
|
|||||||
|
|
||||||
void nonInteractive()
|
void nonInteractive()
|
||||||
{
|
{
|
||||||
String line;
|
String text;
|
||||||
|
|
||||||
if (config().has("query"))
|
if (config().has("query"))
|
||||||
line = config().getString("query");
|
text = config().getString("query");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/// If 'query' parameter is not set, read a query from stdin.
|
/// If 'query' parameter is not set, read a query from stdin.
|
||||||
/// The query is read entirely into memory (streaming is disabled).
|
/// The query is read entirely into memory (streaming is disabled).
|
||||||
ReadBufferFromFileDescriptor in(STDIN_FILENO);
|
ReadBufferFromFileDescriptor in(STDIN_FILENO);
|
||||||
readStringUntilEOF(line, in);
|
readStringUntilEOF(text, in);
|
||||||
}
|
}
|
||||||
|
|
||||||
process(line);
|
process(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool process(const String & line)
|
bool process(const String & text)
|
||||||
{
|
{
|
||||||
if (config().has("multiquery"))
|
if (config().has("multiquery"))
|
||||||
{
|
{
|
||||||
@ -552,8 +555,8 @@ private:
|
|||||||
|
|
||||||
String query;
|
String query;
|
||||||
|
|
||||||
const char * begin = line.data();
|
const char * begin = text.data();
|
||||||
const char * end = begin + line.size();
|
const char * end = begin + text.size();
|
||||||
|
|
||||||
while (begin < end)
|
while (begin < end)
|
||||||
{
|
{
|
||||||
@ -565,14 +568,9 @@ private:
|
|||||||
ASTInsertQuery * insert = typeid_cast<ASTInsertQuery *>(&*ast);
|
ASTInsertQuery * insert = typeid_cast<ASTInsertQuery *>(&*ast);
|
||||||
|
|
||||||
if (insert && insert->data)
|
if (insert && insert->data)
|
||||||
{
|
insert->end = find_first_symbols<'\n'>(insert->data, end);
|
||||||
pos = insert->data;
|
|
||||||
while (*pos && *pos != '\n')
|
|
||||||
++pos;
|
|
||||||
insert->end = pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
query = line.substr(begin - line.data(), pos - begin);
|
query = text.substr(begin - text.data(), pos - begin);
|
||||||
|
|
||||||
begin = pos;
|
begin = pos;
|
||||||
while (isWhitespace(*begin) || *begin == ';')
|
while (isWhitespace(*begin) || *begin == ';')
|
||||||
@ -594,7 +592,7 @@ private:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return processSingleQuery(line);
|
return processSingleQuery(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user