2015-06-18 02:11:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-10-15 20:18:20 +00:00
|
|
|
#include <QueryPipeline/BlockIO.h>
|
2021-04-10 23:33:54 +00:00
|
|
|
#include <Interpreters/Context_fwd.h>
|
2020-12-14 03:30:39 +00:00
|
|
|
#include <Parsers/IAST_fwd.h>
|
2022-01-31 22:27:55 +00:00
|
|
|
#include <Storages//IStorage_fwd.h>
|
2015-06-18 02:11:05 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-12-14 03:30:39 +00:00
|
|
|
struct QueryLogElement;
|
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/** Interpreters interface for different queries.
|
2015-06-18 02:11:05 +00:00
|
|
|
*/
|
|
|
|
class IInterpreter
|
|
|
|
{
|
|
|
|
public:
|
2017-06-02 21:37:28 +00:00
|
|
|
/** For queries that return a result (SELECT and similar), sets in BlockIO a stream from which you can read this result.
|
|
|
|
* For queries that receive data (INSERT), sets a thread in BlockIO where you can write data.
|
|
|
|
* For queries that do not require data and return nothing, BlockIO will be empty.
|
2015-06-18 02:11:05 +00:00
|
|
|
*/
|
|
|
|
virtual BlockIO execute() = 0;
|
|
|
|
|
2019-11-11 01:11:32 +00:00
|
|
|
virtual bool ignoreQuota() const { return false; }
|
|
|
|
virtual bool ignoreLimits() const { return false; }
|
|
|
|
|
2020-12-14 03:30:39 +00:00
|
|
|
// Fill query log element with query kind, query databases, query tables and query columns.
|
|
|
|
void extendQueryLogElem(
|
2020-12-14 06:17:24 +00:00
|
|
|
QueryLogElement & elem,
|
|
|
|
const ASTPtr & ast,
|
2021-04-10 23:33:54 +00:00
|
|
|
ContextPtr context,
|
2020-12-14 06:17:24 +00:00
|
|
|
const String & query_database,
|
|
|
|
const String & query_table) const;
|
2020-12-14 03:30:39 +00:00
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
virtual void extendQueryLogElemImpl(QueryLogElement &, const ASTPtr &, ContextPtr) const {}
|
2020-12-14 03:30:39 +00:00
|
|
|
|
2022-01-31 22:27:55 +00:00
|
|
|
/// Returns true if transactions maybe supported for this type of query.
|
|
|
|
/// If Interpreter returns true, than it is responsible to check that specific query with specific Storage is supported.
|
|
|
|
virtual bool supportsTransactions() const { return false; }
|
|
|
|
|
|
|
|
/// Helper function for some Interpreters.
|
2023-02-21 12:36:23 +00:00
|
|
|
static void checkStorageSupportsTransactionsIfNeeded(const StoragePtr & storage, ContextPtr context, bool is_readonly_query = false);
|
2022-01-31 22:27:55 +00:00
|
|
|
|
2020-05-28 09:07:40 +00:00
|
|
|
virtual ~IInterpreter() = default;
|
2015-06-18 02:11:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|