This commit is contained in:
kssenii 2021-09-24 08:29:01 +00:00
parent 04575eb12b
commit f3784780fd
5 changed files with 31 additions and 13 deletions

View File

@ -1078,6 +1078,7 @@ void Client::processOptions(const OptionsDescription & options_description,
exit(exit_code);
}
}
send_external_tables = true;
shared_context = Context::createShared();
global_context = Context::createGlobal(shared_context.get());

View File

@ -172,7 +172,8 @@ void ClientBase::sendExternalTables(ASTPtr parsed_query)
for (auto & table : external_tables)
data.emplace_back(table.getData(global_context));
connection->sendExternalTablesData(data);
if (send_external_tables)
connection->sendExternalTablesData(data);
}
@ -376,7 +377,18 @@ void ClientBase::processTextAsSingleQuery(const String & full_query)
else
query_to_execute = full_query;
processParsedSingleQuery(full_query, query_to_execute, parsed_query);
try
{
processParsedSingleQuery(full_query, query_to_execute, parsed_query);
}
catch (Exception & e)
{
if (!is_interactive)
{
e.addMessage("(query: {})", full_query);
throw;
}
}
if (have_error)
processError(full_query);
@ -413,7 +425,9 @@ void ClientBase::processOrdinaryQuery(const String & query_to_execute, ASTPtr pa
&global_context->getClientInfo(),
true);
sendExternalTables(parsed_query);
if (send_external_tables)
sendExternalTables(parsed_query);
receiveResult(parsed_query);
break;
@ -679,7 +693,8 @@ void ClientBase::processInsertQuery(const String & query_to_execute, ASTPtr pars
&global_context->getClientInfo(),
true);
sendExternalTables(parsed_query);
if (send_external_tables)
sendExternalTables(parsed_query);
/// Receive description of table structure.
Block sample;

View File

@ -201,6 +201,7 @@ protected:
bool have_error = false;
std::list<ExternalTable> external_tables; /// External tables info.
bool send_external_tables = false;
NameToNameMap query_parameters; /// Dictionary with query parameters for prepared statements.
QueryFuzzer fuzzer;

View File

@ -19,14 +19,10 @@ LocalConnection::LocalConnection(ContextPtr context_, bool send_progress_)
{
/// Authenticate and create a context to execute queries.
session.authenticate("default", "", Poco::Net::SocketAddress{});
session.makeSessionContext();
if (!CurrentThread::isInitialized())
thread_status.emplace();
query_context = session.makeQueryContext();
query_context->makeSessionContext(); /// initial_create_query requires a session context to be set.
if (send_progress)
query_context->setProgressCallback([this] (const Progress & value) { return this->updateProgress(value); });
}
LocalConnection::~LocalConnection()
@ -65,6 +61,13 @@ void LocalConnection::sendQuery(
const ClientInfo *,
bool)
{
query_context = session.makeQueryContext();
query_context->setCurrentQueryId(query_id_);
if (send_progress)
query_context->setProgressCallback([this] (const Progress & value) { return this->updateProgress(value); });
CurrentThread::QueryScope query_scope_holder(query_context);
state.reset();
state.emplace();
@ -75,8 +78,6 @@ void LocalConnection::sendQuery(
state->after_send_progress.restart();
next_packet_type.reset();
query_context->setCurrentQueryId(query_id_);
CurrentThread::QueryScope query_scope_holder(query_context);
try
{
@ -399,7 +400,7 @@ const String & LocalConnection::getServerDisplayName(const ConnectionTimeouts &)
void LocalConnection::sendExternalTablesData(ExternalTablesData &)
{
/// Do nothing.
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Not implemented");
}
ServerConnectionPtr LocalConnection::createConnection(const ConnectionParameters &, ContextPtr current_context, bool send_progress)

View File

@ -89,7 +89,7 @@ idx10 ['This','is','a','test']
23
24
=== Try load data from datapage_v2.snappy.parquet
Code: 33. DB::ParsingEx---tion: Error while reading Parquet data: IOError: Not yet implemented: Unsupported encoding.: While executing ParquetBlockInputFormat: data for INSERT was parsed from stdin. (CANNOT_READ_ALL_DATA)
Code: 33. DB::ParsingEx---tion: Error while reading Parquet data: IOError: Not yet implemented: Unsupported encoding.: While executing ParquetBlockInputFormat: data for INSERT was parsed from stdin: (in query: INSERT INTO parquet_load FORMAT Parquet). (CANNOT_READ_ALL_DATA)
=== Try load data from datatype-date32.parquet
1925-01-01