2020-12-14 03:30:39 +00:00
|
|
|
#include <Interpreters/IInterpreter.h>
|
|
|
|
#include <Interpreters/QueryLog.h>
|
2022-01-10 19:01:41 +00:00
|
|
|
#include <Interpreters/Context.h>
|
2022-01-31 22:27:55 +00:00
|
|
|
#include <Storages/IStorage.h>
|
2020-12-14 03:30:39 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2022-01-31 22:27:55 +00:00
|
|
|
|
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2020-12-14 03:30:39 +00:00
|
|
|
void IInterpreter::extendQueryLogElem(
|
2021-04-10 23:33:54 +00:00
|
|
|
QueryLogElement & elem, const ASTPtr & ast, ContextPtr context, const String & query_database, const String & query_table) const
|
2020-12-14 03:30:39 +00:00
|
|
|
{
|
|
|
|
if (!query_database.empty() && query_table.empty())
|
|
|
|
{
|
|
|
|
elem.query_databases.insert(backQuoteIfNeed(query_database));
|
|
|
|
}
|
|
|
|
else if (!query_table.empty())
|
|
|
|
{
|
2021-04-10 23:33:54 +00:00
|
|
|
auto quoted_database = query_database.empty() ? backQuoteIfNeed(context->getCurrentDatabase())
|
|
|
|
: backQuoteIfNeed(query_database);
|
2020-12-14 03:30:39 +00:00
|
|
|
elem.query_databases.insert(quoted_database);
|
|
|
|
elem.query_tables.insert(quoted_database + "." + backQuoteIfNeed(query_table));
|
|
|
|
}
|
|
|
|
|
|
|
|
extendQueryLogElemImpl(elem, ast, context);
|
|
|
|
}
|
2022-01-31 22:27:55 +00:00
|
|
|
|
|
|
|
void IInterpreter::checkStorageSupportsTransactionsIfNeeded(const StoragePtr & storage, ContextPtr context)
|
|
|
|
{
|
|
|
|
if (!context->getCurrentTransaction())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (storage->supportsTransactions())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (context->getSettingsRef().throw_on_unsupported_query_inside_transaction)
|
|
|
|
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Storage {} (table {}) does not support transactions",
|
|
|
|
storage->getName(), storage->getStorageID().getNameForLogs());
|
|
|
|
}
|
|
|
|
|
2020-12-14 03:30:39 +00:00
|
|
|
}
|