Added queries-file parameter. Fixed code review issues

This commit is contained in:
Maksim Kita 2020-10-31 22:41:19 +03:00
parent f5d1a9e59a
commit 963ee5211b
4 changed files with 10 additions and 14 deletions

View File

@ -483,8 +483,7 @@ private:
if (config().has("query") && config().has("queries-file"))
{
std::cerr << "Specify either `query` or `queries-file` option" << std::endl;
return Application::EXIT_OK;
throw Exception("Specify either `query` or `queries-file` option", ErrorCodes::BAD_ARGUMENTS);
}
std::cout << std::fixed << std::setprecision(3);
@ -797,7 +796,7 @@ private:
if (config().has("queries-file"))
{
ReadBufferFromFile in(config().getRawString("queries-file"));
ReadBufferFromFile in(config().getString("queries-file"));
readStringUntilEOF(text, in);
processMultiQuery(text);
return;

View File

@ -207,8 +207,7 @@ try
if (config().has("query") && config().has("queries-file"))
{
std::cerr << "Specify either `query` or `queries-file` option" << std::endl;
return Application::EXIT_OK;
throw Exception("Specify either `query` or `queries-file` option", ErrorCodes::BAD_ARGUMENTS);
}
shared_context = Context::createShared();
@ -355,7 +354,7 @@ void LocalServer::processQueries()
else
{
String queries_from_file;
ReadBufferFromFile in(config().getRawString("queries-file"));
ReadBufferFromFile in(config().getString("queries-file"));
readStringUntilEOF(queries_from_file, in);
queries_str += queries_from_file;
}

View File

@ -1,8 +1,8 @@
1
1
2
3
Specify either `query` or `queries-file` option
Code: 81. DB::Exception: Received from localhost:9000. DB::Exception: Database `test` doesn't exist.
Code: 81. DB::Exception: Received from localhost:9000. DB::Exception: Database `test` doesn't exist.
Code: 36. DB::Exception: Specify either `query` or `queries-file` option
1 2
3 4
Specify either `query` or `queries-file` option

View File

@ -21,6 +21,4 @@ DROP TABLE table;" > 01523_client_local_queries_file_parameter_tmp.sql
echo -e "1,2\n3,4" | $CLICKHOUSE_LOCAL --queries-file=01523_client_local_queries_file_parameter_tmp.sql 2>&1
$CLICKHOUSE_LOCAL --queries='t' --query='t' 2>&1
rm 01523_client_local_queries_file_parameter_tmp.sql