2011-08-09 19:19:25 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-05-17 13:32:51 +00:00
|
|
|
#ifndef CLICKHOUSE_PROGRAM_STANDALONE_BUILD
|
|
|
|
|
2023-02-03 13:34:18 +00:00
|
|
|
#include <base/types.h>
|
|
|
|
#include <Common/isLocalAddress.h>
|
|
|
|
#include <Common/MultiVersion.h>
|
|
|
|
#include <Common/RemoteHostFilter.h>
|
2023-06-15 13:49:49 +00:00
|
|
|
#include <Common/HTTPHeaderFilter.h>
|
2023-04-06 17:00:51 +00:00
|
|
|
#include <Common/ThreadPool_fwd.h>
|
2023-03-29 14:18:56 +00:00
|
|
|
#include <Common/Throttler_fwd.h>
|
2019-03-11 14:01:45 +00:00
|
|
|
#include <Core/NamesAndTypes.h>
|
2019-05-17 14:34:25 +00:00
|
|
|
#include <Core/Settings.h>
|
2020-02-04 22:22:27 +00:00
|
|
|
#include <Core/UUID.h>
|
2023-02-07 17:50:31 +00:00
|
|
|
#include <IO/AsyncReadCounters.h>
|
2023-05-02 17:41:42 +00:00
|
|
|
#include <Disks/IO/getThreadPoolReader.h>
|
2019-03-11 14:01:45 +00:00
|
|
|
#include <Interpreters/ClientInfo.h>
|
2021-04-10 23:33:54 +00:00
|
|
|
#include <Interpreters/Context_fwd.h>
|
2020-02-10 13:10:17 +00:00
|
|
|
#include <Interpreters/DatabaseCatalog.h>
|
2022-03-18 11:01:26 +00:00
|
|
|
#include <Interpreters/MergeTreeTransactionHolder.h>
|
2022-09-27 13:26:41 +00:00
|
|
|
#include <IO/IResourceManager.h>
|
2023-02-03 13:34:18 +00:00
|
|
|
#include <Parsers/IAST_fwd.h>
|
2022-11-09 14:51:41 +00:00
|
|
|
#include <Server/HTTP/HTTPContext.h>
|
2023-02-03 13:34:18 +00:00
|
|
|
#include <Storages/ColumnsDescription.h>
|
|
|
|
#include <Storages/IStorage_fwd.h>
|
2021-12-28 07:45:48 +00:00
|
|
|
|
2022-09-28 13:29:29 +00:00
|
|
|
#include "config.h"
|
2021-04-10 23:33:54 +00:00
|
|
|
|
2021-11-18 13:04:42 +00:00
|
|
|
#include <boost/container/flat_set.hpp>
|
2015-04-16 06:12:35 +00:00
|
|
|
#include <functional>
|
|
|
|
#include <memory>
|
2017-06-02 18:48:33 +00:00
|
|
|
#include <mutex>
|
2018-11-07 11:46:39 +00:00
|
|
|
#include <optional>
|
2015-04-16 06:12:35 +00:00
|
|
|
|
2011-08-09 19:19:25 +00:00
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
namespace Poco::Net { class IPAddress; }
|
2023-05-19 14:06:43 +00:00
|
|
|
namespace zkutil
|
|
|
|
{
|
|
|
|
class ZooKeeper;
|
|
|
|
using ZooKeeperPtr = std::shared_ptr<ZooKeeper>;
|
|
|
|
}
|
2015-04-16 07:22:29 +00:00
|
|
|
|
2021-10-22 12:56:09 +00:00
|
|
|
struct OvercommitTracker;
|
2015-04-16 07:22:29 +00:00
|
|
|
|
2011-08-09 19:19:25 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2023-03-24 02:44:52 +00:00
|
|
|
class ASTSelectQuery;
|
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
struct ContextSharedPart;
|
2020-03-07 17:37:38 +00:00
|
|
|
class ContextAccess;
|
2020-02-12 03:03:33 +00:00
|
|
|
struct User;
|
|
|
|
using UserPtr = std::shared_ptr<const User>;
|
2023-07-01 17:58:38 +00:00
|
|
|
struct SettingsProfilesInfo;
|
2020-04-29 19:35:56 +00:00
|
|
|
struct EnabledRolesInfo;
|
2022-08-18 07:47:29 +00:00
|
|
|
struct RowPolicyFilter;
|
2022-10-24 07:58:14 +00:00
|
|
|
using RowPolicyFilterPtr = std::shared_ptr<const RowPolicyFilter>;
|
2020-03-07 17:37:38 +00:00
|
|
|
class EnabledQuota;
|
2020-05-08 12:50:45 +00:00
|
|
|
struct QuotaUsage;
|
2020-01-26 09:49:53 +00:00
|
|
|
class AccessFlags;
|
|
|
|
struct AccessRightsElement;
|
|
|
|
class AccessRightsElements;
|
2021-11-18 13:04:42 +00:00
|
|
|
enum class RowPolicyFilterType;
|
2017-01-21 04:24:28 +00:00
|
|
|
class EmbeddedDictionaries;
|
2019-09-26 10:41:33 +00:00
|
|
|
class ExternalDictionariesLoader;
|
2021-09-07 23:55:17 +00:00
|
|
|
class ExternalUserDefinedExecutableFunctionsLoader;
|
2022-09-24 21:24:39 +00:00
|
|
|
class IUserDefinedSQLObjectsLoader;
|
2021-04-07 13:52:11 +00:00
|
|
|
class InterserverCredentials;
|
|
|
|
using InterserverCredentialsPtr = std::shared_ptr<const InterserverCredentials>;
|
2015-04-16 06:12:35 +00:00
|
|
|
class InterserverIOHandler;
|
2017-12-29 22:32:04 +00:00
|
|
|
class BackgroundSchedulePool;
|
2015-04-16 06:12:35 +00:00
|
|
|
class MergeList;
|
2022-10-25 13:56:46 +00:00
|
|
|
class MovesList;
|
2020-10-26 16:38:35 +00:00
|
|
|
class ReplicatedFetchList;
|
2015-04-16 06:12:35 +00:00
|
|
|
class Cluster;
|
|
|
|
class Compiler;
|
|
|
|
class MarkCache;
|
2021-03-28 19:24:28 +00:00
|
|
|
class MMappedFileCache;
|
2015-04-16 06:12:35 +00:00
|
|
|
class UncompressedCache;
|
|
|
|
class ProcessList;
|
2018-05-14 16:09:00 +00:00
|
|
|
class QueryStatus;
|
2022-10-17 02:21:08 +00:00
|
|
|
using QueryStatusPtr = std::shared_ptr<QueryStatus>;
|
2015-04-16 06:12:35 +00:00
|
|
|
class Macros;
|
2016-03-07 04:31:10 +00:00
|
|
|
struct Progress;
|
2021-08-01 14:12:34 +00:00
|
|
|
struct FileProgress;
|
2015-04-30 12:43:16 +00:00
|
|
|
class Clusters;
|
2023-01-26 22:23:10 +00:00
|
|
|
class QueryCache;
|
2015-06-26 20:48:10 +00:00
|
|
|
class QueryLog;
|
2018-05-31 15:54:08 +00:00
|
|
|
class QueryThreadLog;
|
2021-06-18 13:44:08 +00:00
|
|
|
class QueryViewsLog;
|
2017-03-07 17:13:54 +00:00
|
|
|
class PartLog;
|
2019-07-22 13:54:08 +00:00
|
|
|
class TextLog;
|
2019-02-03 21:30:45 +00:00
|
|
|
class TraceLog;
|
2019-08-13 14:31:46 +00:00
|
|
|
class MetricLog;
|
2020-06-10 19:17:30 +00:00
|
|
|
class AsynchronousMetricLog;
|
2020-08-20 20:59:40 +00:00
|
|
|
class OpenTelemetrySpanLog;
|
2021-07-09 14:05:35 +00:00
|
|
|
class ZooKeeperLog;
|
2021-03-05 14:57:16 +00:00
|
|
|
class SessionLog;
|
2022-05-02 17:09:51 +00:00
|
|
|
class BackupsWorker;
|
2022-01-14 14:03:00 +00:00
|
|
|
class TransactionsInfoLog;
|
2022-02-05 16:33:42 +00:00
|
|
|
class ProcessorsProfileLog;
|
2022-04-30 05:00:40 +00:00
|
|
|
class FilesystemCacheLog;
|
2023-02-07 17:50:31 +00:00
|
|
|
class FilesystemReadPrefetchesLog;
|
2022-10-03 18:52:14 +00:00
|
|
|
class AsynchronousInsertLog;
|
2023-02-03 13:34:18 +00:00
|
|
|
class IAsynchronousReader;
|
2015-07-16 21:32:51 +00:00
|
|
|
struct MergeTreeSettings;
|
2023-02-03 13:34:18 +00:00
|
|
|
struct InitialAllRangesAnnouncement;
|
|
|
|
struct ParallelReadRequest;
|
|
|
|
struct ParallelReadResponse;
|
2020-06-01 17:16:09 +00:00
|
|
|
class StorageS3Settings;
|
2016-03-19 01:18:49 +00:00
|
|
|
class IDatabase;
|
2017-04-13 13:42:29 +00:00
|
|
|
class DDLWorker;
|
2018-03-01 01:49:36 +00:00
|
|
|
class ITableFunction;
|
2023-05-22 16:36:34 +00:00
|
|
|
using TableFunctionPtr = std::shared_ptr<ITableFunction>;
|
2017-01-21 04:24:28 +00:00
|
|
|
class Block;
|
2018-05-21 13:49:54 +00:00
|
|
|
class ActionLocksManager;
|
|
|
|
using ActionLocksManagerPtr = std::shared_ptr<ActionLocksManager>;
|
2018-11-22 15:59:00 +00:00
|
|
|
class ShellCommand;
|
2018-12-21 12:17:30 +00:00
|
|
|
class ICompressionCodec;
|
2021-11-02 11:06:20 +00:00
|
|
|
class AccessControl;
|
2021-03-11 20:41:10 +00:00
|
|
|
class Credentials;
|
|
|
|
class GSSAcceptorContext;
|
2021-07-22 16:07:03 +00:00
|
|
|
struct SettingsConstraintsAndProfileIDs;
|
2022-12-07 00:29:48 +00:00
|
|
|
class SettingsProfileElements;
|
2019-10-10 12:58:06 +00:00
|
|
|
class RemoteHostFilter;
|
2019-12-05 11:42:13 +00:00
|
|
|
struct StorageID;
|
2019-12-12 08:57:25 +00:00
|
|
|
class IDisk;
|
|
|
|
using DiskPtr = std::shared_ptr<IDisk>;
|
|
|
|
class DiskSelector;
|
2020-01-09 14:50:34 +00:00
|
|
|
using DiskSelectorPtr = std::shared_ptr<const DiskSelector>;
|
2020-05-22 10:33:57 +00:00
|
|
|
using DisksMap = std::map<String, DiskPtr>;
|
2021-01-23 15:20:15 +00:00
|
|
|
class IStoragePolicy;
|
|
|
|
using StoragePolicyPtr = std::shared_ptr<const IStoragePolicy>;
|
2020-05-22 10:33:57 +00:00
|
|
|
using StoragePoliciesMap = std::map<String, StoragePolicyPtr>;
|
2019-12-12 08:57:25 +00:00
|
|
|
class StoragePolicySelector;
|
2020-01-09 14:50:34 +00:00
|
|
|
using StoragePolicySelectorPtr = std::shared_ptr<const StoragePolicySelector>;
|
2023-07-26 17:58:41 +00:00
|
|
|
class ServerType;
|
2021-09-30 21:26:24 +00:00
|
|
|
template <class Queue>
|
2021-08-30 19:37:03 +00:00
|
|
|
class MergeTreeBackgroundExecutor;
|
2023-02-09 19:49:11 +00:00
|
|
|
|
2023-02-11 16:18:42 +00:00
|
|
|
/// Scheduling policy can be changed using `background_merges_mutations_scheduling_policy` config option.
|
|
|
|
/// By default concurrent merges are scheduled using "round_robin" to ensure fair and starvation-free operation.
|
2023-02-09 19:49:11 +00:00
|
|
|
/// Previously in heavily overloaded shards big merges could possibly be starved by smaller
|
2023-02-11 16:18:42 +00:00
|
|
|
/// merges due to the use of strict priority scheduling "shortest_task_first".
|
|
|
|
class DynamicRuntimeQueue;
|
|
|
|
using MergeMutateBackgroundExecutor = MergeTreeBackgroundExecutor<DynamicRuntimeQueue>;
|
2021-09-30 21:26:24 +00:00
|
|
|
using MergeMutateBackgroundExecutorPtr = std::shared_ptr<MergeMutateBackgroundExecutor>;
|
2023-02-09 19:49:11 +00:00
|
|
|
|
2023-02-11 16:18:42 +00:00
|
|
|
class RoundRobinRuntimeQueue;
|
2023-02-09 19:31:54 +00:00
|
|
|
using OrdinaryBackgroundExecutor = MergeTreeBackgroundExecutor<RoundRobinRuntimeQueue>;
|
2021-09-30 21:26:24 +00:00
|
|
|
using OrdinaryBackgroundExecutorPtr = std::shared_ptr<OrdinaryBackgroundExecutor>;
|
2020-11-20 17:23:53 +00:00
|
|
|
struct PartUUIDs;
|
|
|
|
using PartUUIDsPtr = std::shared_ptr<PartUUIDs>;
|
2021-08-24 12:30:31 +00:00
|
|
|
class KeeperDispatcher;
|
2021-03-05 14:57:16 +00:00
|
|
|
class Session;
|
2022-03-21 08:52:48 +00:00
|
|
|
struct WriteSettings;
|
2019-04-24 22:52:08 +00:00
|
|
|
|
2021-10-11 16:11:50 +00:00
|
|
|
class IInputFormat;
|
2019-04-05 10:52:07 +00:00
|
|
|
class IOutputFormat;
|
2021-10-11 16:11:50 +00:00
|
|
|
using InputFormatPtr = std::shared_ptr<IInputFormat>;
|
2019-04-05 10:52:07 +00:00
|
|
|
using OutputFormatPtr = std::shared_ptr<IOutputFormat>;
|
2020-07-08 14:25:23 +00:00
|
|
|
class IVolume;
|
|
|
|
using VolumePtr = std::shared_ptr<IVolume>;
|
2020-03-05 19:23:39 +00:00
|
|
|
struct NamedSession;
|
2020-10-16 10:12:31 +00:00
|
|
|
struct BackgroundTaskSchedulingSettings;
|
2020-01-19 14:26:28 +00:00
|
|
|
|
2021-07-30 13:30:30 +00:00
|
|
|
#if USE_NLP
|
|
|
|
class SynonymsExtensions;
|
|
|
|
class Lemmatizers;
|
|
|
|
#endif
|
|
|
|
|
2021-02-19 23:41:58 +00:00
|
|
|
class ZooKeeperMetadataTransaction;
|
|
|
|
using ZooKeeperMetadataTransactionPtr = std::shared_ptr<ZooKeeperMetadataTransaction>;
|
2018-08-30 16:31:20 +00:00
|
|
|
|
2021-06-02 15:39:12 +00:00
|
|
|
class AsynchronousInsertQueue;
|
|
|
|
|
2018-06-01 15:32:27 +00:00
|
|
|
/// Callback for external tables initializer
|
2021-04-10 23:33:54 +00:00
|
|
|
using ExternalTablesInitializer = std::function<void(ContextPtr)>;
|
2018-06-01 15:32:27 +00:00
|
|
|
|
2019-05-28 18:30:10 +00:00
|
|
|
/// Callback for initialize input()
|
2021-04-10 23:33:54 +00:00
|
|
|
using InputInitializer = std::function<void(ContextPtr, const StoragePtr &)>;
|
2019-05-28 18:30:10 +00:00
|
|
|
/// Callback for reading blocks of data from client for function input()
|
2021-04-10 23:33:54 +00:00
|
|
|
using InputBlocksReader = std::function<Block(ContextPtr)>;
|
2019-05-28 18:30:10 +00:00
|
|
|
|
2021-04-10 02:21:18 +00:00
|
|
|
/// Used in distributed task processing
|
2021-04-13 10:59:02 +00:00
|
|
|
using ReadTaskCallback = std::function<String()>;
|
2019-10-19 20:36:35 +00:00
|
|
|
|
2023-02-03 13:34:18 +00:00
|
|
|
using MergeTreeAllRangesCallback = std::function<void(InitialAllRangesAnnouncement)>;
|
|
|
|
using MergeTreeReadTaskCallback = std::function<std::optional<ParallelReadResponse>(ParallelReadRequest)>;
|
2021-12-09 10:39:28 +00:00
|
|
|
|
2022-09-15 10:19:39 +00:00
|
|
|
class TemporaryDataOnDiskScope;
|
|
|
|
using TemporaryDataOnDiskScopePtr = std::shared_ptr<TemporaryDataOnDiskScope>;
|
2021-12-29 04:31:54 +00:00
|
|
|
|
2023-02-03 13:34:18 +00:00
|
|
|
class ParallelReplicasReadingCoordinator;
|
|
|
|
using ParallelReplicasReadingCoordinatorPtr = std::shared_ptr<ParallelReplicasReadingCoordinator>;
|
|
|
|
|
2021-12-29 04:31:54 +00:00
|
|
|
#if USE_ROCKSDB
|
|
|
|
class MergeTreeMetadataCache;
|
|
|
|
using MergeTreeMetadataCachePtr = std::shared_ptr<MergeTreeMetadataCache>;
|
|
|
|
#endif
|
|
|
|
|
2023-03-02 19:19:58 +00:00
|
|
|
class PreparedSetsCache;
|
|
|
|
using PreparedSetsCachePtr = std::shared_ptr<PreparedSetsCache>;
|
|
|
|
|
2019-03-06 16:41:35 +00:00
|
|
|
/// An empty interface for an arbitrary object that may be attached by a shared pointer
|
|
|
|
/// to query context, when using ClickHouse as a library.
|
|
|
|
struct IHostContext
|
|
|
|
{
|
|
|
|
virtual ~IHostContext() = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
using IHostContextPtr = std::shared_ptr<IHostContext>;
|
|
|
|
|
2020-04-17 09:47:40 +00:00
|
|
|
/// A small class which owns ContextShared.
|
|
|
|
/// We don't use something like unique_ptr directly to allow ContextShared type to be incomplete.
|
2020-04-16 14:51:33 +00:00
|
|
|
struct SharedContextHolder
|
|
|
|
{
|
|
|
|
~SharedContextHolder();
|
2020-04-19 15:41:35 +00:00
|
|
|
SharedContextHolder();
|
2021-04-10 23:33:54 +00:00
|
|
|
explicit SharedContextHolder(std::unique_ptr<ContextSharedPart> shared_context);
|
2020-04-17 09:47:40 +00:00
|
|
|
SharedContextHolder(SharedContextHolder &&) noexcept;
|
|
|
|
|
2022-02-17 21:18:12 +00:00
|
|
|
SharedContextHolder & operator=(SharedContextHolder &&) noexcept;
|
2020-04-19 15:46:12 +00:00
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
ContextSharedPart * get() const { return shared.get(); }
|
2020-04-17 12:58:52 +00:00
|
|
|
void reset();
|
2021-04-10 23:33:54 +00:00
|
|
|
|
2020-04-17 09:47:40 +00:00
|
|
|
private:
|
2021-04-10 23:33:54 +00:00
|
|
|
std::unique_ptr<ContextSharedPart> shared;
|
2020-04-16 14:51:33 +00:00
|
|
|
};
|
|
|
|
|
2021-12-08 02:40:59 +00:00
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/** A set of known objects that can be used in the query.
|
|
|
|
* Consists of a shared part (always common to all sessions and queries)
|
|
|
|
* and copied part (which can be its own for each session or query).
|
2012-08-02 17:33:31 +00:00
|
|
|
*
|
2017-06-02 21:37:28 +00:00
|
|
|
* Everything is encapsulated for all sorts of checks and locks.
|
2012-08-02 17:33:31 +00:00
|
|
|
*/
|
2021-04-10 23:33:54 +00:00
|
|
|
class Context: public std::enable_shared_from_this<Context>
|
2012-08-02 17:33:31 +00:00
|
|
|
{
|
|
|
|
private:
|
2021-04-10 23:33:54 +00:00
|
|
|
ContextSharedPart * shared;
|
2012-06-18 07:49:19 +00:00
|
|
|
|
2016-10-24 21:40:39 +00:00
|
|
|
ClientInfo client_info;
|
2018-06-01 15:32:27 +00:00
|
|
|
ExternalTablesInitializer external_tables_initializer_callback;
|
2015-06-26 20:48:10 +00:00
|
|
|
|
2019-05-28 18:30:10 +00:00
|
|
|
InputInitializer input_initializer_callback;
|
|
|
|
InputBlocksReader input_blocks_reader;
|
|
|
|
|
2020-02-12 03:03:33 +00:00
|
|
|
std::optional<UUID> user_id;
|
2021-07-22 13:44:48 +00:00
|
|
|
std::shared_ptr<std::vector<UUID>> current_roles;
|
2021-07-22 16:07:03 +00:00
|
|
|
std::shared_ptr<const SettingsConstraintsAndProfileIDs> settings_constraints_and_current_profiles;
|
2023-07-01 15:39:50 +00:00
|
|
|
mutable std::shared_ptr<const ContextAccess> access;
|
|
|
|
mutable bool need_recalculate_access = true;
|
2016-11-16 05:09:41 +00:00
|
|
|
String current_database;
|
2021-04-26 13:34:44 +00:00
|
|
|
Settings settings; /// Setting for query execution.
|
|
|
|
|
2015-04-16 06:12:35 +00:00
|
|
|
using ProgressCallback = std::function<void(const Progress & progress)>;
|
2021-04-26 13:34:44 +00:00
|
|
|
ProgressCallback progress_callback; /// Callback for tracking progress of query execution.
|
2021-05-13 22:56:42 +00:00
|
|
|
|
|
|
|
using FileProgressCallback = std::function<void(const FileProgress & progress)>;
|
|
|
|
FileProgressCallback file_progress_callback; /// Callback for tracking progress of file loading.
|
2021-04-26 13:34:44 +00:00
|
|
|
|
2022-10-17 02:21:08 +00:00
|
|
|
std::weak_ptr<QueryStatus> process_list_elem; /// For tracking total resource usage for query.
|
2022-12-01 16:20:39 +00:00
|
|
|
bool has_process_list_elem = false; /// It's impossible to check if weak_ptr was initialized or not
|
2020-03-02 20:23:58 +00:00
|
|
|
StorageID insertion_table = StorageID::createEmpty(); /// Saved insertion table in query context
|
2021-07-30 09:23:49 +00:00
|
|
|
bool is_distributed = false; /// Whether the current context it used for distributed query
|
2016-11-16 05:09:41 +00:00
|
|
|
|
2017-06-02 21:01:17 +00:00
|
|
|
String default_format; /// Format, used when server formats data by itself and if query does not have FORMAT specification.
|
2016-11-16 05:09:41 +00:00
|
|
|
/// Thus, used in HTTP interface. If not specified - then some globally default format is used.
|
2022-10-14 15:09:35 +00:00
|
|
|
|
|
|
|
String insert_format; /// Format, used in insert query.
|
|
|
|
|
2020-01-30 19:00:51 +00:00
|
|
|
TemporaryTablesMapping external_tables_mapping;
|
2019-10-19 20:36:35 +00:00
|
|
|
Scalars scalars;
|
2022-04-06 06:53:10 +00:00
|
|
|
/// Used to store constant values which are different on each instance during distributed plan, such as _shard_num.
|
|
|
|
Scalars special_scalars;
|
2020-02-21 15:22:28 +00:00
|
|
|
|
2021-12-09 10:39:28 +00:00
|
|
|
/// Used in s3Cluster table function. With this callback, a worker node could ask an initiator
|
|
|
|
/// about next file to read from s3.
|
2021-04-08 19:00:39 +00:00
|
|
|
std::optional<ReadTaskCallback> next_task_callback;
|
2021-12-09 10:39:28 +00:00
|
|
|
/// Used in parallel reading from replicas. A replica tells about its intentions to read
|
|
|
|
/// some ranges from some part and initiator will tell the replica about whether it is accepted or denied.
|
|
|
|
std::optional<MergeTreeReadTaskCallback> merge_tree_read_task_callback;
|
2023-02-03 13:34:18 +00:00
|
|
|
std::optional<MergeTreeAllRangesCallback> merge_tree_all_ranges_callback;
|
|
|
|
UUID parallel_replicas_group_uuid{UUIDHelpers::Nil};
|
2021-04-06 11:05:47 +00:00
|
|
|
|
2023-02-14 08:12:40 +00:00
|
|
|
/// This parameter can be set by the HTTP client to tune the behavior of output formats for compatibility.
|
|
|
|
UInt64 client_protocol_version = 0;
|
2021-04-06 11:05:47 +00:00
|
|
|
|
2020-12-13 22:36:04 +00:00
|
|
|
/// Record entities accessed by current query, and store this information in system.query_log.
|
2020-12-02 12:08:03 +00:00
|
|
|
struct QueryAccessInfo
|
|
|
|
{
|
2021-01-20 12:30:41 +00:00
|
|
|
QueryAccessInfo() = default;
|
|
|
|
|
|
|
|
QueryAccessInfo(const QueryAccessInfo & rhs)
|
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> lock(rhs.mutex);
|
|
|
|
databases = rhs.databases;
|
|
|
|
tables = rhs.tables;
|
|
|
|
columns = rhs.columns;
|
2023-05-08 10:01:24 +00:00
|
|
|
partitions = rhs.partitions;
|
2021-02-10 14:12:49 +00:00
|
|
|
projections = rhs.projections;
|
2021-06-24 16:54:04 +00:00
|
|
|
views = rhs.views;
|
2021-01-20 12:30:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QueryAccessInfo(QueryAccessInfo && rhs) = delete;
|
|
|
|
|
|
|
|
QueryAccessInfo & operator=(QueryAccessInfo rhs)
|
|
|
|
{
|
|
|
|
swap(rhs);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2021-01-20 12:37:53 +00:00
|
|
|
void swap(QueryAccessInfo & rhs)
|
2021-01-20 12:30:41 +00:00
|
|
|
{
|
|
|
|
std::swap(databases, rhs.databases);
|
|
|
|
std::swap(tables, rhs.tables);
|
|
|
|
std::swap(columns, rhs.columns);
|
2023-05-08 10:01:24 +00:00
|
|
|
std::swap(partitions, rhs.partitions);
|
2021-02-10 14:12:49 +00:00
|
|
|
std::swap(projections, rhs.projections);
|
2021-06-24 16:54:04 +00:00
|
|
|
std::swap(views, rhs.views);
|
2021-01-20 12:30:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// To prevent a race between copy-constructor and other uses of this structure.
|
|
|
|
mutable std::mutex mutex{};
|
|
|
|
std::set<std::string> databases{};
|
|
|
|
std::set<std::string> tables{};
|
|
|
|
std::set<std::string> columns{};
|
2023-05-08 10:01:24 +00:00
|
|
|
std::set<std::string> partitions{};
|
2021-06-24 16:54:04 +00:00
|
|
|
std::set<std::string> projections{};
|
|
|
|
std::set<std::string> views{};
|
2020-12-02 12:08:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
QueryAccessInfo query_access_info;
|
|
|
|
|
2021-01-21 21:15:11 +00:00
|
|
|
/// Record names of created objects of factories (for testing, etc)
|
2021-01-20 10:54:11 +00:00
|
|
|
struct QueryFactoriesInfo
|
|
|
|
{
|
2022-05-25 15:15:23 +00:00
|
|
|
QueryFactoriesInfo() = default;
|
|
|
|
|
|
|
|
QueryFactoriesInfo(const QueryFactoriesInfo & rhs)
|
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> lock(rhs.mutex);
|
|
|
|
aggregate_functions = rhs.aggregate_functions;
|
|
|
|
aggregate_function_combinators = rhs.aggregate_function_combinators;
|
|
|
|
database_engines = rhs.database_engines;
|
|
|
|
data_type_families = rhs.data_type_families;
|
|
|
|
dictionaries = rhs.dictionaries;
|
|
|
|
formats = rhs.formats;
|
|
|
|
functions = rhs.functions;
|
|
|
|
storages = rhs.storages;
|
|
|
|
table_functions = rhs.table_functions;
|
|
|
|
}
|
|
|
|
|
|
|
|
QueryFactoriesInfo(QueryFactoriesInfo && rhs) = delete;
|
|
|
|
|
|
|
|
QueryFactoriesInfo & operator=(QueryFactoriesInfo rhs)
|
|
|
|
{
|
|
|
|
swap(rhs);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void swap(QueryFactoriesInfo & rhs)
|
|
|
|
{
|
|
|
|
std::swap(aggregate_functions, rhs.aggregate_functions);
|
|
|
|
std::swap(aggregate_function_combinators, rhs.aggregate_function_combinators);
|
|
|
|
std::swap(database_engines, rhs.database_engines);
|
|
|
|
std::swap(data_type_families, rhs.data_type_families);
|
|
|
|
std::swap(dictionaries, rhs.dictionaries);
|
|
|
|
std::swap(formats, rhs.formats);
|
|
|
|
std::swap(functions, rhs.functions);
|
|
|
|
std::swap(storages, rhs.storages);
|
|
|
|
std::swap(table_functions, rhs.table_functions);
|
|
|
|
}
|
|
|
|
|
2021-01-21 21:15:11 +00:00
|
|
|
std::unordered_set<std::string> aggregate_functions;
|
2021-01-23 12:07:37 +00:00
|
|
|
std::unordered_set<std::string> aggregate_function_combinators;
|
|
|
|
std::unordered_set<std::string> database_engines;
|
|
|
|
std::unordered_set<std::string> data_type_families;
|
2021-01-21 21:15:11 +00:00
|
|
|
std::unordered_set<std::string> dictionaries;
|
|
|
|
std::unordered_set<std::string> formats;
|
|
|
|
std::unordered_set<std::string> functions;
|
|
|
|
std::unordered_set<std::string> storages;
|
|
|
|
std::unordered_set<std::string> table_functions;
|
2022-05-25 15:15:23 +00:00
|
|
|
|
2022-05-25 16:59:46 +00:00
|
|
|
mutable std::mutex mutex;
|
2021-01-20 10:54:11 +00:00
|
|
|
};
|
|
|
|
|
2022-05-25 14:13:12 +00:00
|
|
|
/// Needs to be changed while having const context in factories methods
|
2021-01-20 10:54:11 +00:00
|
|
|
mutable QueryFactoriesInfo query_factories_info;
|
2023-02-07 17:50:31 +00:00
|
|
|
/// Query metrics for reading data asynchronously with IAsynchronousReader.
|
|
|
|
mutable std::shared_ptr<AsyncReadCounters> async_read_counters;
|
2021-01-20 10:54:11 +00:00
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
/// TODO: maybe replace with temporary tables?
|
2019-08-04 00:29:32 +00:00
|
|
|
StoragePtr view_source; /// Temporary StorageValues used to generate alias columns for materialized views
|
2018-03-01 01:49:36 +00:00
|
|
|
Tables table_function_results; /// Temporary tables obtained by execution of table functions. Keyed by AST tree id.
|
2020-02-21 15:22:28 +00:00
|
|
|
|
2021-05-31 14:49:02 +00:00
|
|
|
ContextWeakMutablePtr query_context;
|
|
|
|
ContextWeakMutablePtr session_context; /// Session context or nullptr. Could be equal to this.
|
|
|
|
ContextWeakMutablePtr global_context; /// Global context. Could be equal to this.
|
2021-04-10 23:33:54 +00:00
|
|
|
|
|
|
|
/// XXX: move this stuff to shared part instead.
|
2021-05-31 14:49:02 +00:00
|
|
|
ContextMutablePtr buffer_context; /// Buffer context. Could be equal to this.
|
2012-06-18 07:49:19 +00:00
|
|
|
|
2021-09-24 23:10:10 +00:00
|
|
|
/// A flag, used to distinguish between user query and internal query to a database engine (MaterializedPostgreSQL).
|
2021-05-16 21:35:37 +00:00
|
|
|
bool is_internal_query = false;
|
|
|
|
|
2021-12-28 11:23:35 +00:00
|
|
|
inline static ContextPtr global_context_instance;
|
2021-09-16 21:19:58 +00:00
|
|
|
|
2022-09-15 10:19:39 +00:00
|
|
|
/// Temporary data for query execution accounting.
|
|
|
|
TemporaryDataOnDiskScopePtr temp_data_on_disk;
|
2023-02-03 13:34:18 +00:00
|
|
|
|
2023-03-02 19:19:58 +00:00
|
|
|
/// Prepared sets that can be shared between different queries. One use case is when is to share prepared sets between
|
|
|
|
/// mutation tasks of one mutation executed against different parts of the same table.
|
|
|
|
PreparedSetsCachePtr prepared_sets_cache;
|
|
|
|
|
2020-11-18 17:43:18 +00:00
|
|
|
public:
|
2022-08-18 09:13:47 +00:00
|
|
|
/// Some counters for current query execution.
|
|
|
|
/// Most of them are workarounds and should be removed in the future.
|
|
|
|
struct KitchenSink
|
|
|
|
{
|
|
|
|
std::atomic<size_t> analyze_counter = 0;
|
|
|
|
|
|
|
|
KitchenSink() = default;
|
|
|
|
|
|
|
|
KitchenSink(const KitchenSink & rhs)
|
|
|
|
: analyze_counter(rhs.analyze_counter.load())
|
|
|
|
{}
|
|
|
|
|
|
|
|
KitchenSink & operator=(const KitchenSink & rhs)
|
|
|
|
{
|
|
|
|
analyze_counter = rhs.analyze_counter.load();
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
KitchenSink kitchen_sink;
|
|
|
|
|
2023-02-03 13:34:18 +00:00
|
|
|
ParallelReplicasReadingCoordinatorPtr parallel_reading_coordinator;
|
|
|
|
|
2020-11-18 17:43:18 +00:00
|
|
|
private:
|
2018-07-05 23:36:09 +00:00
|
|
|
using SampleBlockCache = std::unordered_map<std::string, Block>;
|
|
|
|
mutable SampleBlockCache sample_block_cache;
|
|
|
|
|
2021-02-05 10:31:46 +00:00
|
|
|
PartUUIDsPtr part_uuids; /// set of parts' uuids, is used for query parts deduplication
|
|
|
|
PartUUIDsPtr ignored_part_uuids; /// set of parts' uuids are meant to be excluded from query processing
|
2020-11-20 17:23:53 +00:00
|
|
|
|
2019-06-15 17:52:53 +00:00
|
|
|
NameToNameMap query_parameters; /// Dictionary with query parameters for prepared statements.
|
2019-05-18 21:07:23 +00:00
|
|
|
/// (key=name, value)
|
|
|
|
|
2019-03-06 16:41:35 +00:00
|
|
|
IHostContextPtr host_context; /// Arbitrary object that may used to attach some host specific information to query context,
|
|
|
|
/// when using ClickHouse as a library in some project. For example, it may contain host
|
|
|
|
/// logger, some query identification information, profiling guards, etc. This field is
|
2021-04-10 23:33:54 +00:00
|
|
|
/// to be customized in HTTP and TCP servers by overloading the customizeContext(DB::ContextPtr)
|
2019-03-06 16:41:35 +00:00
|
|
|
/// methods.
|
|
|
|
|
2021-02-19 23:41:58 +00:00
|
|
|
ZooKeeperMetadataTransactionPtr metadata_transaction; /// Distributed DDL context. I'm not sure if it's a suitable place for this,
|
2020-11-20 16:06:27 +00:00
|
|
|
/// but it's the easiest way to pass this through the whole stack from executeQuery(...)
|
|
|
|
/// to DatabaseOnDisk::commitCreateTable(...) or IStorage::alter(...) without changing
|
|
|
|
/// thousands of signatures.
|
|
|
|
/// And I hope it will be replaced with more common Transaction sometime.
|
|
|
|
|
2021-03-31 17:55:04 +00:00
|
|
|
MergeTreeTransactionPtr merge_tree_transaction; /// Current transaction context. Can be inside session or query context.
|
2021-04-09 12:53:51 +00:00
|
|
|
/// It's shared with all children contexts.
|
|
|
|
MergeTreeTransactionHolder merge_tree_transaction_holder; /// It will rollback or commit transaction on Context destruction.
|
2021-03-31 17:55:04 +00:00
|
|
|
|
2017-06-19 20:31:23 +00:00
|
|
|
/// Use copy constructor or createGlobal() instead
|
2015-04-16 06:12:35 +00:00
|
|
|
Context();
|
2021-04-10 23:33:54 +00:00
|
|
|
Context(const Context &);
|
|
|
|
Context & operator=(const Context &);
|
2017-06-19 20:31:23 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/// Create initial Context with ContextShared and etc.
|
2021-05-31 14:49:02 +00:00
|
|
|
static ContextMutablePtr createGlobal(ContextSharedPart * shared);
|
2021-06-01 12:20:52 +00:00
|
|
|
static ContextMutablePtr createCopy(const ContextWeakPtr & other);
|
2021-05-31 14:49:02 +00:00
|
|
|
static ContextMutablePtr createCopy(const ContextMutablePtr & other);
|
|
|
|
static ContextMutablePtr createCopy(const ContextPtr & other);
|
2020-04-16 14:51:33 +00:00
|
|
|
static SharedContextHolder createShared();
|
2017-06-19 20:31:23 +00:00
|
|
|
|
2015-04-16 06:12:35 +00:00
|
|
|
~Context();
|
|
|
|
|
2012-08-02 17:33:31 +00:00
|
|
|
String getPath() const;
|
2016-10-24 14:01:24 +00:00
|
|
|
String getFlagsPath() const;
|
2018-04-19 05:32:09 +00:00
|
|
|
String getUserFilesPath() const;
|
2019-12-10 17:27:29 +00:00
|
|
|
String getDictionariesLibPath() const;
|
2021-08-25 19:30:22 +00:00
|
|
|
String getUserScriptsPath() const;
|
2018-04-19 05:32:09 +00:00
|
|
|
|
2021-07-13 00:59:52 +00:00
|
|
|
/// A list of warnings about server configuration to place in `system.warnings` table.
|
2021-11-10 15:45:15 +00:00
|
|
|
Strings getWarnings() const;
|
2018-04-19 05:32:09 +00:00
|
|
|
|
2023-04-05 13:42:13 +00:00
|
|
|
VolumePtr getGlobalTemporaryVolume() const; /// TODO: remove, use `getTempDataOnDisk`
|
2022-08-31 17:17:31 +00:00
|
|
|
|
2022-09-15 10:19:39 +00:00
|
|
|
TemporaryDataOnDiskScopePtr getTempDataOnDisk() const;
|
2023-04-05 10:07:44 +00:00
|
|
|
TemporaryDataOnDiskScopePtr getSharedTempDataOnDisk() const;
|
2022-09-15 10:19:39 +00:00
|
|
|
void setTempDataOnDisk(TemporaryDataOnDiskScopePtr temp_data_on_disk_);
|
2020-01-19 14:26:28 +00:00
|
|
|
|
2012-08-02 17:33:31 +00:00
|
|
|
void setPath(const String & path);
|
2016-10-24 14:01:24 +00:00
|
|
|
void setFlagsPath(const String & path);
|
2018-04-19 05:32:09 +00:00
|
|
|
void setUserFilesPath(const String & path);
|
2019-12-10 17:27:29 +00:00
|
|
|
void setDictionariesLibPath(const String & path);
|
2021-08-25 19:30:22 +00:00
|
|
|
void setUserScriptsPath(const String & path);
|
2013-05-05 20:07:11 +00:00
|
|
|
|
2022-05-18 19:57:20 +00:00
|
|
|
void addWarningMessage(const String & msg) const;
|
2013-05-05 20:07:11 +00:00
|
|
|
|
2022-12-06 10:04:15 +00:00
|
|
|
void setTemporaryStorageInCache(const String & cache_disk_name, size_t max_size);
|
|
|
|
void setTemporaryStoragePolicy(const String & policy_name, size_t max_size);
|
|
|
|
void setTemporaryStoragePath(const String & path, size_t max_size);
|
2020-01-19 14:26:28 +00:00
|
|
|
|
2015-04-16 06:12:35 +00:00
|
|
|
using ConfigurationPtr = Poco::AutoPtr<Poco::Util::AbstractConfiguration>;
|
|
|
|
|
2017-08-24 14:51:13 +00:00
|
|
|
/// Global application configuration settings.
|
|
|
|
void setConfig(const ConfigurationPtr & config);
|
2018-07-08 04:54:37 +00:00
|
|
|
const Poco::Util::AbstractConfiguration & getConfigRef() const;
|
2017-08-24 14:51:13 +00:00
|
|
|
|
2021-11-02 11:06:20 +00:00
|
|
|
AccessControl & getAccessControl();
|
|
|
|
const AccessControl & getAccessControl() const;
|
2020-02-12 03:03:33 +00:00
|
|
|
|
2021-03-11 20:41:10 +00:00
|
|
|
/// Sets external authenticators config (LDAP, Kerberos).
|
2020-06-10 22:48:15 +00:00
|
|
|
void setExternalAuthenticatorsConfig(const Poco::Util::AbstractConfiguration & config);
|
|
|
|
|
2021-03-11 20:41:10 +00:00
|
|
|
/// Creates GSSAcceptorContext instance based on external authenticator params.
|
|
|
|
std::unique_ptr<GSSAcceptorContext> makeGSSAcceptorContext() const;
|
|
|
|
|
2020-02-12 03:03:33 +00:00
|
|
|
/** Take the list of users, quotas and configuration profiles from this config.
|
|
|
|
* The list of users is completely replaced.
|
|
|
|
* The accumulated quota values are not reset if the quota is not deleted.
|
|
|
|
*/
|
|
|
|
void setUsersConfig(const ConfigurationPtr & config);
|
|
|
|
ConfigurationPtr getUsersConfig();
|
|
|
|
|
2021-08-01 14:12:34 +00:00
|
|
|
/// Sets the current user assuming that he/she is already authenticated.
|
2021-08-12 15:16:55 +00:00
|
|
|
/// WARNING: This function doesn't check password!
|
2023-07-01 17:58:38 +00:00
|
|
|
void setUser(const UUID & user_id_, bool set_current_profiles_ = true, bool set_current_roles_ = true, bool set_current_database_ = true);
|
2020-02-12 03:03:33 +00:00
|
|
|
UserPtr getUser() const;
|
2023-07-01 17:58:38 +00:00
|
|
|
|
|
|
|
void setUserID(const UUID & user_id_);
|
2020-04-05 23:03:20 +00:00
|
|
|
std::optional<UUID> getUserID() const;
|
2020-01-12 21:00:55 +00:00
|
|
|
|
2023-07-01 17:58:38 +00:00
|
|
|
String getUserName() const;
|
|
|
|
|
2021-08-01 14:12:34 +00:00
|
|
|
void setQuotaKey(String quota_key_);
|
|
|
|
|
2021-02-26 22:37:00 +00:00
|
|
|
void setCurrentRoles(const std::vector<UUID> & current_roles_);
|
2020-02-21 00:17:07 +00:00
|
|
|
void setCurrentRolesDefault();
|
2020-04-29 19:35:56 +00:00
|
|
|
boost::container::flat_set<UUID> getCurrentRoles() const;
|
|
|
|
boost::container::flat_set<UUID> getEnabledRoles() const;
|
|
|
|
std::shared_ptr<const EnabledRolesInfo> getRolesInfo() const;
|
2020-01-12 21:00:55 +00:00
|
|
|
|
2023-07-01 17:58:38 +00:00
|
|
|
void setCurrentProfile(const String & profile_name, bool check_constraints = true);
|
|
|
|
void setCurrentProfile(const UUID & profile_id, bool check_constraints = true);
|
|
|
|
void setCurrentProfiles(const SettingsProfilesInfo & profiles_info, bool check_constraints = true);
|
2021-07-22 16:07:03 +00:00
|
|
|
std::vector<UUID> getCurrentProfiles() const;
|
|
|
|
std::vector<UUID> getEnabledProfiles() const;
|
|
|
|
|
2020-01-12 21:00:55 +00:00
|
|
|
/// Checks access rights.
|
|
|
|
/// Empty database means the current database.
|
2020-03-07 17:37:38 +00:00
|
|
|
void checkAccess(const AccessFlags & flags) const;
|
2022-07-14 16:11:35 +00:00
|
|
|
void checkAccess(const AccessFlags & flags, std::string_view database) const;
|
|
|
|
void checkAccess(const AccessFlags & flags, std::string_view database, std::string_view table) const;
|
|
|
|
void checkAccess(const AccessFlags & flags, std::string_view database, std::string_view table, std::string_view column) const;
|
|
|
|
void checkAccess(const AccessFlags & flags, std::string_view database, std::string_view table, const std::vector<std::string_view> & columns) const;
|
|
|
|
void checkAccess(const AccessFlags & flags, std::string_view database, std::string_view table, const Strings & columns) const;
|
2020-03-07 17:37:38 +00:00
|
|
|
void checkAccess(const AccessFlags & flags, const StorageID & table_id) const;
|
2022-07-14 16:11:35 +00:00
|
|
|
void checkAccess(const AccessFlags & flags, const StorageID & table_id, std::string_view column) const;
|
2020-03-07 17:37:38 +00:00
|
|
|
void checkAccess(const AccessFlags & flags, const StorageID & table_id, const std::vector<std::string_view> & columns) const;
|
|
|
|
void checkAccess(const AccessFlags & flags, const StorageID & table_id, const Strings & columns) const;
|
|
|
|
void checkAccess(const AccessRightsElement & element) const;
|
|
|
|
void checkAccess(const AccessRightsElements & elements) const;
|
|
|
|
|
|
|
|
std::shared_ptr<const ContextAccess> getAccess() const;
|
|
|
|
|
2022-10-24 07:58:14 +00:00
|
|
|
RowPolicyFilterPtr getRowPolicyFilter(const String & database, const String & table_name, RowPolicyFilterType filter_type) const;
|
2020-02-07 19:31:09 +00:00
|
|
|
|
2020-03-07 17:37:38 +00:00
|
|
|
std::shared_ptr<const EnabledQuota> getQuota() const;
|
2020-05-08 12:50:45 +00:00
|
|
|
std::optional<QuotaUsage> getQuotaUsage() const;
|
2019-07-28 13:12:26 +00:00
|
|
|
|
2022-09-27 13:26:41 +00:00
|
|
|
/// Resource management related
|
|
|
|
ResourceManagerPtr getResourceManager() const;
|
|
|
|
ClassifierPtr getClassifier() const;
|
|
|
|
|
2018-06-14 13:03:23 +00:00
|
|
|
/// We have to copy external tables inside executeQuery() to track limits. Therefore, set callback for it. Must set once.
|
2018-06-01 15:32:27 +00:00
|
|
|
void setExternalTablesInitializer(ExternalTablesInitializer && initializer);
|
|
|
|
/// This method is called in executeQuery() and will call the external tables initializer.
|
|
|
|
void initializeExternalTablesIfSet();
|
|
|
|
|
2019-05-28 18:30:10 +00:00
|
|
|
/// When input() is present we have to send columns structure to client
|
|
|
|
void setInputInitializer(InputInitializer && initializer);
|
|
|
|
/// This method is called in StorageInput::read while executing query
|
|
|
|
void initializeInput(const StoragePtr & input_storage);
|
|
|
|
|
|
|
|
/// Callback for read data blocks from client one by one for function input()
|
|
|
|
void setInputBlocksReaderCallback(InputBlocksReader && reader);
|
|
|
|
/// Get callback for reading data for input()
|
|
|
|
InputBlocksReader getInputBlocksReaderCallback() const;
|
|
|
|
void resetInputCallbacks();
|
|
|
|
|
2023-07-07 10:49:50 +00:00
|
|
|
/// Returns information about the client executing a query.
|
2018-06-03 17:43:56 +00:00
|
|
|
const ClientInfo & getClientInfo() const { return client_info; }
|
2015-06-26 20:48:10 +00:00
|
|
|
|
2023-07-07 10:49:50 +00:00
|
|
|
/// Modify stored in the context information about the client executing a query.
|
|
|
|
void setClientInfo(const ClientInfo & client_info_);
|
|
|
|
void setClientName(const String & client_name);
|
|
|
|
void setClientInterface(ClientInfo::Interface interface);
|
|
|
|
void setClientVersion(UInt64 client_version_major, UInt64 client_version_minor, UInt64 client_version_patch, unsigned client_tcp_protocol_version);
|
|
|
|
void setClientConnectionId(uint32_t connection_id);
|
|
|
|
void setHttpClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer);
|
|
|
|
void setForwardedFor(const String & forwarded_for);
|
|
|
|
void setQueryKind(ClientInfo::QueryKind query_kind);
|
|
|
|
void setQueryKindInitial();
|
|
|
|
void setQueryKindReplicatedDatabaseInternal();
|
|
|
|
void setCurrentUserName(const String & current_user_name);
|
|
|
|
void setCurrentAddress(const Poco::Net::SocketAddress & current_address);
|
|
|
|
void setInitialUserName(const String & initial_user_name);
|
|
|
|
void setInitialAddress(const Poco::Net::SocketAddress & initial_address);
|
|
|
|
void setInitialQueryId(const String & initial_query_id);
|
|
|
|
void setInitialQueryStartTime(std::chrono::time_point<std::chrono::system_clock> initial_query_start_time);
|
|
|
|
void setQuotaClientKey(const String & quota_key);
|
|
|
|
void setConnectionClientVersion(UInt64 client_version_major, UInt64 client_version_minor, UInt64 client_version_patch, unsigned client_tcp_protocol_version);
|
|
|
|
void setReplicaInfo(bool collaborate_with_initiator, size_t all_replicas_count, size_t number_of_current_replica);
|
|
|
|
void increaseDistributedDepth();
|
|
|
|
const OpenTelemetry::TracingContext & getClientTraceContext() const { return client_info.client_trace_context; }
|
|
|
|
OpenTelemetry::TracingContext & getClientTraceContext() { return client_info.client_trace_context; }
|
|
|
|
|
2020-02-10 18:19:35 +00:00
|
|
|
enum StorageNamespace
|
|
|
|
{
|
2020-02-12 18:14:12 +00:00
|
|
|
ResolveGlobal = 1u, /// Database name must be specified
|
|
|
|
ResolveCurrentDatabase = 2u, /// Use current database
|
|
|
|
ResolveOrdinary = ResolveGlobal | ResolveCurrentDatabase, /// If database name is not specified, use current database
|
|
|
|
ResolveExternal = 4u, /// Try get external table
|
|
|
|
ResolveAll = ResolveExternal | ResolveOrdinary /// If database name is not specified, try get external table,
|
|
|
|
/// if external table not found use current database.
|
2020-02-10 18:19:35 +00:00
|
|
|
};
|
|
|
|
|
2020-02-03 12:54:36 +00:00
|
|
|
String resolveDatabase(const String & database_name) const;
|
2020-02-12 18:14:12 +00:00
|
|
|
StorageID resolveStorageID(StorageID storage_id, StorageNamespace where = StorageNamespace::ResolveAll) const;
|
|
|
|
StorageID tryResolveStorageID(StorageID storage_id, StorageNamespace where = StorageNamespace::ResolveAll) const;
|
|
|
|
StorageID resolveStorageIDImpl(StorageID storage_id, StorageNamespace where, std::optional<Exception> * exception) const;
|
2012-08-02 17:33:31 +00:00
|
|
|
|
2020-03-10 19:36:17 +00:00
|
|
|
Tables getExternalTables() const;
|
|
|
|
void addExternalTable(const String & table_name, TemporaryTableHolder && temporary_table);
|
2023-05-25 19:18:11 +00:00
|
|
|
std::shared_ptr<TemporaryTableHolder> findExternalTable(const String & table_name) const;
|
2020-03-13 15:41:36 +00:00
|
|
|
std::shared_ptr<TemporaryTableHolder> removeExternalTable(const String & table_name);
|
2020-03-10 19:36:17 +00:00
|
|
|
|
2019-10-19 20:36:35 +00:00
|
|
|
const Scalars & getScalars() const;
|
|
|
|
const Block & getScalar(const String & name) const;
|
|
|
|
void addScalar(const String & name, const Block & block);
|
|
|
|
bool hasScalar(const String & name) const;
|
2014-08-22 00:57:20 +00:00
|
|
|
|
2022-04-06 06:53:10 +00:00
|
|
|
const Block * tryGetSpecialScalar(const String & name) const;
|
|
|
|
void addSpecialScalar(const String & name, const Block & block);
|
2021-07-31 07:45:26 +00:00
|
|
|
|
2020-12-02 12:08:03 +00:00
|
|
|
const QueryAccessInfo & getQueryAccessInfo() const { return query_access_info; }
|
2021-02-10 14:12:49 +00:00
|
|
|
void addQueryAccessInfo(
|
|
|
|
const String & quoted_database_name,
|
|
|
|
const String & full_quoted_table_name,
|
|
|
|
const Names & column_names,
|
2021-06-24 16:54:04 +00:00
|
|
|
const String & projection_name = {},
|
|
|
|
const String & view_name = {});
|
2023-05-08 10:01:24 +00:00
|
|
|
void addQueryAccessInfo(const Names & partition_names);
|
2023-07-20 03:12:22 +00:00
|
|
|
|
|
|
|
struct QualifiedProjectionName
|
|
|
|
{
|
|
|
|
StorageID storage_id = StorageID::createEmpty();
|
|
|
|
String projection_name;
|
|
|
|
explicit operator bool() const { return !projection_name.empty(); }
|
|
|
|
};
|
|
|
|
void addQueryAccessInfo(const QualifiedProjectionName & qualified_projection_name);
|
2020-12-02 12:08:03 +00:00
|
|
|
|
|
|
|
|
2021-01-21 21:15:11 +00:00
|
|
|
/// Supported factories for records in query_log
|
|
|
|
enum class QueryLogFactories
|
|
|
|
{
|
|
|
|
AggregateFunction,
|
2021-01-23 12:07:37 +00:00
|
|
|
AggregateFunctionCombinator,
|
2021-01-21 21:15:11 +00:00
|
|
|
Database,
|
|
|
|
DataType,
|
|
|
|
Dictionary,
|
|
|
|
Format,
|
|
|
|
Function,
|
|
|
|
Storage,
|
|
|
|
TableFunction
|
|
|
|
};
|
|
|
|
|
2021-01-20 10:54:11 +00:00
|
|
|
const QueryFactoriesInfo & getQueryFactoriesInfo() const { return query_factories_info; }
|
2021-01-21 21:15:11 +00:00
|
|
|
void addQueryFactoriesInfo(QueryLogFactories factory_type, const String & created_object) const;
|
2021-01-20 10:54:11 +00:00
|
|
|
|
2022-10-14 15:09:35 +00:00
|
|
|
/// For table functions s3/file/url/hdfs/input we can use structure from
|
|
|
|
/// insertion table depending on select expression.
|
|
|
|
StoragePtr executeTableFunction(const ASTPtr & table_expression, const ASTSelectQuery * select_query_hint = nullptr);
|
2023-05-22 16:36:34 +00:00
|
|
|
/// Overload for the new analyzer. Structure inference is performed in QueryAnalysisPass.
|
|
|
|
StoragePtr executeTableFunction(const ASTPtr & table_expression, const TableFunctionPtr & table_function_ptr);
|
2018-03-01 01:49:36 +00:00
|
|
|
|
2018-12-09 17:50:35 +00:00
|
|
|
void addViewSource(const StoragePtr & storage);
|
2021-05-31 14:49:02 +00:00
|
|
|
StoragePtr getViewSource() const;
|
2018-12-09 17:50:35 +00:00
|
|
|
|
2012-08-02 17:33:31 +00:00
|
|
|
String getCurrentDatabase() const;
|
2021-01-29 15:11:44 +00:00
|
|
|
String getCurrentQueryId() const { return client_info.current_query_id; }
|
2019-08-31 12:18:14 +00:00
|
|
|
|
|
|
|
/// Id of initiating query for distributed queries; or current query id if it's not a distributed query.
|
|
|
|
String getInitialQueryId() const;
|
|
|
|
|
2012-08-02 17:33:31 +00:00
|
|
|
void setCurrentDatabase(const String & name);
|
2020-09-25 11:27:00 +00:00
|
|
|
/// Set current_database for global context. We don't validate that database
|
|
|
|
/// exists because it should be set before databases loading.
|
|
|
|
void setCurrentDatabaseNameInGlobalContext(const String & name);
|
2014-02-12 17:31:02 +00:00
|
|
|
void setCurrentQueryId(const String & query_id);
|
2012-08-02 17:33:31 +00:00
|
|
|
|
2022-12-02 12:00:49 +00:00
|
|
|
void killCurrentQuery() const;
|
2019-02-01 01:48:25 +00:00
|
|
|
|
2022-09-09 16:08:50 +00:00
|
|
|
bool hasInsertionTable() const { return !insertion_table.empty(); }
|
2020-03-02 20:23:58 +00:00
|
|
|
void setInsertionTable(StorageID db_and_table) { insertion_table = std::move(db_and_table); }
|
|
|
|
const StorageID & getInsertionTable() const { return insertion_table; }
|
2018-11-15 15:03:13 +00:00
|
|
|
|
2021-07-30 09:23:49 +00:00
|
|
|
void setDistributed(bool is_distributed_) { is_distributed = is_distributed_; }
|
|
|
|
bool isDistributed() const { return is_distributed; }
|
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
String getDefaultFormat() const; /// If default_format is not specified, some global default format is returned.
|
2013-06-29 18:03:57 +00:00
|
|
|
void setDefaultFormat(const String & name);
|
|
|
|
|
2022-10-14 15:09:35 +00:00
|
|
|
String getInsertFormat() const;
|
|
|
|
void setInsertFormat(const String & name);
|
|
|
|
|
2018-03-13 23:44:23 +00:00
|
|
|
MultiVersion<Macros>::Version getMacros() const;
|
|
|
|
void setMacros(std::unique_ptr<Macros> && macros);
|
2014-08-11 15:59:01 +00:00
|
|
|
|
2023-04-28 12:42:23 +00:00
|
|
|
bool displaySecretsInShowAndSelect() const;
|
2012-08-02 17:33:31 +00:00
|
|
|
Settings getSettings() const;
|
|
|
|
void setSettings(const Settings & settings_);
|
2012-08-02 19:03:32 +00:00
|
|
|
|
2019-04-18 23:29:32 +00:00
|
|
|
/// Set settings by name.
|
2022-07-17 15:22:12 +00:00
|
|
|
void setSetting(std::string_view name, const String & value);
|
|
|
|
void setSetting(std::string_view name, const Field & value);
|
2019-04-18 23:29:32 +00:00
|
|
|
void applySettingChange(const SettingChange & change);
|
|
|
|
void applySettingsChanges(const SettingsChanges & changes);
|
2014-02-14 17:38:33 +00:00
|
|
|
|
2019-04-18 23:29:32 +00:00
|
|
|
/// Checks the constraints.
|
2022-12-07 00:29:48 +00:00
|
|
|
void checkSettingsConstraints(const SettingsProfileElements & profile_elements) const;
|
2020-02-28 18:55:21 +00:00
|
|
|
void checkSettingsConstraints(const SettingChange & change) const;
|
|
|
|
void checkSettingsConstraints(const SettingsChanges & changes) const;
|
2020-07-19 14:59:07 +00:00
|
|
|
void checkSettingsConstraints(SettingsChanges & changes) const;
|
2020-02-28 18:55:21 +00:00
|
|
|
void clampToSettingsConstraints(SettingsChanges & changes) const;
|
2022-12-02 19:30:14 +00:00
|
|
|
void checkMergeTreeSettingsConstraints(const MergeTreeSettings & merge_tree_settings, const SettingsChanges & changes) const;
|
2014-02-13 07:17:22 +00:00
|
|
|
|
2022-10-11 18:25:28 +00:00
|
|
|
/// Reset settings to default value
|
|
|
|
void resetSettingsToDefaultValue(const std::vector<String> & names);
|
|
|
|
|
2019-10-31 08:45:14 +00:00
|
|
|
/// Returns the current constraints (can return null).
|
2021-07-22 16:07:03 +00:00
|
|
|
std::shared_ptr<const SettingsConstraintsAndProfileIDs> getSettingsConstraintsAndCurrentProfiles() const;
|
2019-10-30 21:37:28 +00:00
|
|
|
|
2019-09-26 10:41:33 +00:00
|
|
|
const ExternalDictionariesLoader & getExternalDictionariesLoader() const;
|
|
|
|
ExternalDictionariesLoader & getExternalDictionariesLoader();
|
2021-09-29 12:52:58 +00:00
|
|
|
ExternalDictionariesLoader & getExternalDictionariesLoaderUnlocked();
|
2022-09-24 21:24:39 +00:00
|
|
|
const EmbeddedDictionaries & getEmbeddedDictionaries() const;
|
|
|
|
EmbeddedDictionaries & getEmbeddedDictionaries();
|
2021-09-29 12:52:58 +00:00
|
|
|
void tryCreateEmbeddedDictionaries(const Poco::Util::AbstractConfiguration & config) const;
|
|
|
|
void loadOrReloadDictionaries(const Poco::Util::AbstractConfiguration & config);
|
2022-09-24 21:24:39 +00:00
|
|
|
|
|
|
|
const ExternalUserDefinedExecutableFunctionsLoader & getExternalUserDefinedExecutableFunctionsLoader() const;
|
|
|
|
ExternalUserDefinedExecutableFunctionsLoader & getExternalUserDefinedExecutableFunctionsLoader();
|
|
|
|
ExternalUserDefinedExecutableFunctionsLoader & getExternalUserDefinedExecutableFunctionsLoaderUnlocked();
|
|
|
|
const IUserDefinedSQLObjectsLoader & getUserDefinedSQLObjectsLoader() const;
|
|
|
|
IUserDefinedSQLObjectsLoader & getUserDefinedSQLObjectsLoader();
|
2021-09-29 12:52:58 +00:00
|
|
|
void loadOrReloadUserDefinedExecutableFunctions(const Poco::Util::AbstractConfiguration & config);
|
2015-03-27 13:11:22 +00:00
|
|
|
|
2021-07-30 13:30:30 +00:00
|
|
|
#if USE_NLP
|
2021-06-04 00:33:41 +00:00
|
|
|
SynonymsExtensions & getSynonymsExtensions() const;
|
2021-06-05 00:52:35 +00:00
|
|
|
Lemmatizers & getLemmatizers() const;
|
2021-07-30 13:30:30 +00:00
|
|
|
#endif
|
2015-03-27 13:11:22 +00:00
|
|
|
|
2022-05-02 17:09:51 +00:00
|
|
|
BackupsWorker & getBackupsWorker() const;
|
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/// I/O formats.
|
2023-02-21 16:03:00 +00:00
|
|
|
InputFormatPtr getInputFormat(const String & name, ReadBuffer & buf, const Block & sample, UInt64 max_block_size,
|
2023-04-29 08:34:59 +00:00
|
|
|
const std::optional<FormatSettings> & format_settings = std::nullopt, const std::optional<size_t> max_parsing_threads = std::nullopt) const;
|
2016-02-13 06:37:19 +00:00
|
|
|
|
2021-10-11 16:11:50 +00:00
|
|
|
OutputFormatPtr getOutputFormat(const String & name, WriteBuffer & buf, const Block & sample) const;
|
2020-12-30 03:07:30 +00:00
|
|
|
OutputFormatPtr getOutputFormatParallelIfPossible(const String & name, WriteBuffer & buf, const Block & sample) const;
|
2016-02-13 06:37:19 +00:00
|
|
|
|
2015-04-16 06:12:35 +00:00
|
|
|
InterserverIOHandler & getInterserverIOHandler();
|
2022-05-03 08:20:50 +00:00
|
|
|
const InterserverIOHandler & getInterserverIOHandler() const;
|
2014-03-21 13:42:14 +00:00
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/// How other servers can access this for downloading replicated data.
|
2014-11-19 20:40:51 +00:00
|
|
|
void setInterserverIOAddress(const String & host, UInt16 port);
|
|
|
|
std::pair<String, UInt16> getInterserverIOAddress() const;
|
2018-07-26 15:10:57 +00:00
|
|
|
|
2018-07-30 18:32:21 +00:00
|
|
|
/// Credentials which server will use to communicate with others
|
2020-08-26 08:36:58 +00:00
|
|
|
void updateInterserverCredentials(const Poco::Util::AbstractConfiguration & config);
|
2022-05-03 08:06:28 +00:00
|
|
|
InterserverCredentialsPtr getInterserverCredentials() const;
|
2018-07-26 15:10:57 +00:00
|
|
|
|
2018-07-30 18:32:21 +00:00
|
|
|
/// Interserver requests scheme (http or https)
|
|
|
|
void setInterserverScheme(const String & scheme);
|
|
|
|
String getInterserverScheme() const;
|
|
|
|
|
2019-10-09 20:29:41 +00:00
|
|
|
/// Storage of allowed hosts from config.xml
|
2019-10-10 12:58:06 +00:00
|
|
|
void setRemoteHostFilter(const Poco::Util::AbstractConfiguration & config);
|
2019-10-21 14:36:24 +00:00
|
|
|
const RemoteHostFilter & getRemoteHostFilter() const;
|
2019-10-09 20:29:41 +00:00
|
|
|
|
2023-06-15 13:49:49 +00:00
|
|
|
/// Storage of forbidden HTTP headers from config.xml
|
|
|
|
void setHTTPHeaderFilter(const Poco::Util::AbstractConfiguration & config);
|
|
|
|
const HTTPHeaderFilter & getHTTPHeaderFilter() const;
|
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/// The port that the server listens for executing SQL queries.
|
2015-09-24 04:50:53 +00:00
|
|
|
UInt16 getTCPPort() const;
|
2014-03-21 19:49:27 +00:00
|
|
|
|
2018-11-06 14:42:30 +00:00
|
|
|
std::optional<UInt16> getTCPPortSecure() const;
|
2014-03-21 19:49:27 +00:00
|
|
|
|
2021-08-20 04:11:47 +00:00
|
|
|
/// Register server ports during server starting up. No lock is held.
|
|
|
|
void registerServerPort(String port_name, UInt16 port);
|
2017-06-02 18:48:33 +00:00
|
|
|
|
2021-08-20 04:11:47 +00:00
|
|
|
UInt16 getServerPort(const String & port_name) const;
|
2016-03-19 01:18:49 +00:00
|
|
|
|
2020-02-13 21:00:03 +00:00
|
|
|
/// For methods below you may need to acquire the context lock by yourself.
|
2012-08-02 17:33:31 +00:00
|
|
|
|
2021-05-31 14:49:02 +00:00
|
|
|
ContextMutablePtr getQueryContext() const;
|
2021-04-10 23:33:54 +00:00
|
|
|
bool hasQueryContext() const { return !query_context.expired(); }
|
|
|
|
bool isInternalSubquery() const;
|
2018-03-02 05:44:17 +00:00
|
|
|
|
2021-05-31 14:49:02 +00:00
|
|
|
ContextMutablePtr getSessionContext() const;
|
2021-04-10 23:33:54 +00:00
|
|
|
bool hasSessionContext() const { return !session_context.expired(); }
|
2016-11-16 11:29:51 +00:00
|
|
|
|
2021-05-31 14:49:02 +00:00
|
|
|
ContextMutablePtr getGlobalContext() const;
|
2021-03-05 14:57:16 +00:00
|
|
|
|
2021-12-28 11:23:35 +00:00
|
|
|
static ContextPtr getGlobalContextInstance() { return global_context_instance; }
|
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
bool hasGlobalContext() const { return !global_context.expired(); }
|
|
|
|
bool isGlobalContext() const
|
|
|
|
{
|
|
|
|
auto ptr = global_context.lock();
|
|
|
|
return ptr && ptr.get() == this;
|
|
|
|
}
|
2012-08-02 17:33:31 +00:00
|
|
|
|
2021-05-31 14:49:02 +00:00
|
|
|
ContextMutablePtr getBufferContext() const;
|
2021-01-27 18:05:18 +00:00
|
|
|
|
2021-05-31 14:49:02 +00:00
|
|
|
void setQueryContext(ContextMutablePtr context_) { query_context = context_; }
|
|
|
|
void setSessionContext(ContextMutablePtr context_) { session_context = context_; }
|
2019-07-08 00:51:43 +00:00
|
|
|
|
2023-03-30 16:50:12 +00:00
|
|
|
void makeQueryContext();
|
|
|
|
void makeSessionContext();
|
|
|
|
void makeGlobalContext();
|
2012-08-02 17:33:31 +00:00
|
|
|
|
2018-06-03 17:43:56 +00:00
|
|
|
const Settings & getSettingsRef() const { return settings; }
|
2013-02-16 14:55:14 +00:00
|
|
|
|
|
|
|
void setProgressCallback(ProgressCallback callback);
|
2021-10-19 09:58:10 +00:00
|
|
|
/// Used in executeQuery() to pass it to the QueryPipeline.
|
2013-02-16 14:55:14 +00:00
|
|
|
ProgressCallback getProgressCallback() const;
|
2013-09-03 20:21:28 +00:00
|
|
|
|
2021-05-13 22:56:42 +00:00
|
|
|
void setFileProgressCallback(FileProgressCallback && callback) { file_progress_callback = callback; }
|
|
|
|
FileProgressCallback getFileProgressCallback() const { return file_progress_callback; }
|
2021-04-26 13:34:44 +00:00
|
|
|
|
2021-10-19 09:58:10 +00:00
|
|
|
/** Set in executeQuery and InterpreterSelectQuery. Then it is used in QueryPipeline,
|
2017-06-02 21:37:28 +00:00
|
|
|
* to update and monitor information about the total number of resources spent for the query.
|
2013-11-03 05:32:42 +00:00
|
|
|
*/
|
2022-10-17 02:21:08 +00:00
|
|
|
void setProcessListElement(QueryStatusPtr elem);
|
2017-06-02 21:37:28 +00:00
|
|
|
/// Can return nullptr if the query was not inserted into the ProcessList.
|
2022-10-17 02:21:08 +00:00
|
|
|
QueryStatusPtr getProcessListElement() const;
|
2013-11-03 05:32:42 +00:00
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/// List all queries.
|
2015-04-16 06:12:35 +00:00
|
|
|
ProcessList & getProcessList();
|
|
|
|
const ProcessList & getProcessList() const;
|
2013-09-08 05:53:10 +00:00
|
|
|
|
2021-10-22 12:56:09 +00:00
|
|
|
OvercommitTracker * getGlobalOvercommitTracker() const;
|
|
|
|
|
2015-04-16 06:12:35 +00:00
|
|
|
MergeList & getMergeList();
|
|
|
|
const MergeList & getMergeList() const;
|
2014-09-10 11:34:26 +00:00
|
|
|
|
2022-10-25 13:56:46 +00:00
|
|
|
MovesList & getMovesList();
|
|
|
|
const MovesList & getMovesList() const;
|
|
|
|
|
2020-10-26 16:38:35 +00:00
|
|
|
ReplicatedFetchList & getReplicatedFetchList();
|
|
|
|
const ReplicatedFetchList & getReplicatedFetchList() const;
|
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/// If the current session is expired at the time of the call, synchronously creates and returns a new session with the startNewSession() call.
|
2018-04-21 18:41:06 +00:00
|
|
|
/// If no ZooKeeper configured, throws an exception.
|
2015-04-16 07:22:29 +00:00
|
|
|
std::shared_ptr<zkutil::ZooKeeper> getZooKeeper() const;
|
2020-08-27 14:19:18 +00:00
|
|
|
/// Same as above but return a zookeeper connection from auxiliary_zookeepers configuration entry.
|
|
|
|
std::shared_ptr<zkutil::ZooKeeper> getAuxiliaryZooKeeper(const String & name) const;
|
2023-05-19 14:06:43 +00:00
|
|
|
/// return Auxiliary Zookeeper map
|
|
|
|
std::map<String, zkutil::ZooKeeperPtr> getAuxiliaryZooKeepers() const;
|
2020-11-03 07:52:31 +00:00
|
|
|
|
2021-10-18 09:13:24 +00:00
|
|
|
/// Try to connect to Keeper using get(Auxiliary)ZooKeeper. Useful for
|
|
|
|
/// internal Keeper start (check connection to some other node). Return true
|
|
|
|
/// if connected successfully (without exception) or our zookeeper client
|
|
|
|
/// connection configured for some other cluster without our node.
|
|
|
|
bool tryCheckClientConnectionToMyKeeperCluster() const;
|
2021-10-14 10:21:41 +00:00
|
|
|
|
2021-09-13 12:19:37 +00:00
|
|
|
UInt32 getZooKeeperSessionUptime() const;
|
2023-02-10 10:47:06 +00:00
|
|
|
UInt64 getClientProtocolVersion() const;
|
|
|
|
void setClientProtocolVersion(UInt64 version);
|
2021-09-13 12:19:37 +00:00
|
|
|
|
2021-12-27 03:50:59 +00:00
|
|
|
#if USE_ROCKSDB
|
2021-12-28 10:06:13 +00:00
|
|
|
MergeTreeMetadataCachePtr getMergeTreeMetadataCache() const;
|
2022-01-11 03:09:52 +00:00
|
|
|
MergeTreeMetadataCachePtr tryGetMergeTreeMetadataCache() const;
|
2021-12-27 03:50:59 +00:00
|
|
|
#endif
|
2021-12-08 02:40:59 +00:00
|
|
|
|
2021-02-01 13:18:17 +00:00
|
|
|
#if USE_NURAFT
|
2021-08-24 12:30:31 +00:00
|
|
|
std::shared_ptr<KeeperDispatcher> & getKeeperDispatcher() const;
|
2022-07-04 02:26:19 +00:00
|
|
|
std::shared_ptr<KeeperDispatcher> & tryGetKeeperDispatcher() const;
|
2021-02-01 13:18:17 +00:00
|
|
|
#endif
|
2021-10-14 10:21:41 +00:00
|
|
|
void initializeKeeperDispatcher(bool start_async) const;
|
2021-08-24 12:30:31 +00:00
|
|
|
void shutdownKeeperDispatcher() const;
|
2021-10-18 15:27:51 +00:00
|
|
|
void updateKeeperConfiguration(const Poco::Util::AbstractConfiguration & config);
|
2020-11-11 13:57:24 +00:00
|
|
|
|
2020-11-03 07:52:31 +00:00
|
|
|
/// Set auxiliary zookeepers configuration at server starting or configuration reloading.
|
|
|
|
void reloadAuxiliaryZooKeepersConfigIfChanged(const ConfigurationPtr & config);
|
2017-06-15 20:08:26 +00:00
|
|
|
/// Has ready or expired ZooKeeper
|
|
|
|
bool hasZooKeeper() const;
|
2020-11-16 08:27:33 +00:00
|
|
|
/// Has ready or expired auxiliary ZooKeeper
|
|
|
|
bool hasAuxiliaryZooKeeper(const String & name) const;
|
2019-07-04 14:48:40 +00:00
|
|
|
/// Reset current zookeeper session. Do not create a new one.
|
|
|
|
void resetZooKeeper() const;
|
2020-09-10 04:00:33 +00:00
|
|
|
// Reload Zookeeper
|
|
|
|
void reloadZooKeeperIfChanged(const ConfigurationPtr & config) const;
|
2013-12-07 16:51:29 +00:00
|
|
|
|
2021-07-29 14:48:49 +00:00
|
|
|
void setSystemZooKeeperLogAfterInitializationIfNeeded();
|
|
|
|
|
2017-08-07 17:01:04 +00:00
|
|
|
/// Create a cache of uncompressed blocks of specified size. This can be done only once.
|
2023-03-13 09:06:58 +00:00
|
|
|
void setUncompressedCache(const String & uncompressed_cache_policy, size_t max_size_in_bytes);
|
2017-08-07 17:01:04 +00:00
|
|
|
std::shared_ptr<UncompressedCache> getUncompressedCache() const;
|
|
|
|
void dropUncompressedCache() const;
|
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/// Create a cache of marks of specified size. This can be done only once.
|
2023-03-13 09:06:58 +00:00
|
|
|
void setMarkCache(const String & mark_cache_policy, size_t cache_size_in_bytes);
|
2015-04-16 06:12:35 +00:00
|
|
|
std::shared_ptr<MarkCache> getMarkCache() const;
|
2017-08-07 17:01:04 +00:00
|
|
|
void dropMarkCache() const;
|
2022-09-05 18:12:40 +00:00
|
|
|
ThreadPool & getLoadMarksThreadpool() const;
|
2017-08-07 17:01:04 +00:00
|
|
|
|
2023-02-07 17:50:31 +00:00
|
|
|
ThreadPool & getPrefetchThreadpool() const;
|
|
|
|
|
|
|
|
/// Note: prefetchThreadpool is different from threadpoolReader
|
|
|
|
/// in the way that its tasks are - wait for marks to be loaded
|
|
|
|
/// and make a prefetch by putting a read task to threadpoolReader.
|
|
|
|
size_t getPrefetchThreadpoolSize() const;
|
|
|
|
|
2021-08-21 17:27:22 +00:00
|
|
|
/// Create a cache of index uncompressed blocks of specified size. This can be done only once.
|
|
|
|
void setIndexUncompressedCache(size_t max_size_in_bytes);
|
|
|
|
std::shared_ptr<UncompressedCache> getIndexUncompressedCache() const;
|
|
|
|
void dropIndexUncompressedCache() const;
|
|
|
|
|
|
|
|
/// Create a cache of index marks of specified size. This can be done only once.
|
|
|
|
void setIndexMarkCache(size_t cache_size_in_bytes);
|
|
|
|
std::shared_ptr<MarkCache> getIndexMarkCache() const;
|
|
|
|
void dropIndexMarkCache() const;
|
|
|
|
|
2021-03-28 01:10:30 +00:00
|
|
|
/// Create a cache of mapped files to avoid frequent open/map/unmap/close and to reuse from several threads.
|
2021-03-28 19:24:28 +00:00
|
|
|
void setMMappedFileCache(size_t cache_size_in_num_entries);
|
|
|
|
std::shared_ptr<MMappedFileCache> getMMappedFileCache() const;
|
|
|
|
void dropMMappedFileCache() const;
|
2021-03-28 01:10:30 +00:00
|
|
|
|
2022-11-29 13:15:28 +00:00
|
|
|
/// Create a cache of query results for statements which run repeatedly.
|
2023-02-02 19:16:25 +00:00
|
|
|
void setQueryCache(const Poco::Util::AbstractConfiguration & config);
|
2023-01-29 20:43:52 +00:00
|
|
|
void updateQueryCacheConfiguration(const Poco::Util::AbstractConfiguration & config);
|
2023-01-26 22:23:10 +00:00
|
|
|
std::shared_ptr<QueryCache> getQueryCache() const;
|
|
|
|
void dropQueryCache() const;
|
2022-11-29 13:15:28 +00:00
|
|
|
|
2017-08-07 17:01:04 +00:00
|
|
|
/** Clear the caches of the uncompressed blocks and marks.
|
|
|
|
* This is usually done when renaming tables, changing the type of columns, deleting a table.
|
|
|
|
* - since caches are linked to file names, and become incorrect.
|
|
|
|
* (when deleting a table - it is necessary, since in its place another can appear)
|
|
|
|
* const - because the change in the cache is not considered significant.
|
|
|
|
*/
|
|
|
|
void dropCaches() const;
|
2014-02-11 13:30:42 +00:00
|
|
|
|
2020-10-16 10:12:31 +00:00
|
|
|
/// Settings for MergeTree background tasks stored in config.xml
|
|
|
|
BackgroundTaskSchedulingSettings getBackgroundProcessingTaskSchedulingSettings() const;
|
|
|
|
BackgroundTaskSchedulingSettings getBackgroundMoveTaskSchedulingSettings() const;
|
|
|
|
|
2020-11-06 14:07:56 +00:00
|
|
|
BackgroundSchedulePool & getBufferFlushSchedulePool() const;
|
|
|
|
BackgroundSchedulePool & getSchedulePool() const;
|
2021-01-27 18:08:06 +00:00
|
|
|
BackgroundSchedulePool & getMessageBrokerSchedulePool() const;
|
2020-11-06 14:07:56 +00:00
|
|
|
BackgroundSchedulePool & getDistributedSchedulePool() const;
|
2014-07-02 12:30:38 +00:00
|
|
|
|
2020-11-12 20:11:04 +00:00
|
|
|
/// Has distributed_ddl configuration or not.
|
2020-11-06 18:28:59 +00:00
|
|
|
bool hasDistributedDDL() const;
|
2019-02-21 16:41:27 +00:00
|
|
|
void setDDLWorker(std::unique_ptr<DDLWorker> ddl_worker);
|
2017-09-04 17:49:39 +00:00
|
|
|
DDLWorker & getDDLWorker() const;
|
2017-04-13 13:42:29 +00:00
|
|
|
|
2023-04-14 19:41:26 +00:00
|
|
|
std::map<String, std::shared_ptr<Cluster>> getClusters() const;
|
2016-10-14 15:06:46 +00:00
|
|
|
std::shared_ptr<Cluster> getCluster(const std::string & cluster_name) const;
|
|
|
|
std::shared_ptr<Cluster> tryGetCluster(const std::string & cluster_name) const;
|
2021-11-16 13:01:57 +00:00
|
|
|
void setClustersConfig(const ConfigurationPtr & config, bool enable_discovery = false, const String & config_name = "remote_servers");
|
2021-11-11 09:03:53 +00:00
|
|
|
|
2021-11-18 08:57:26 +00:00
|
|
|
void startClusterDiscovery();
|
2021-11-11 09:03:53 +00:00
|
|
|
|
2017-11-03 19:53:10 +00:00
|
|
|
/// Sets custom cluster, but doesn't update configuration
|
|
|
|
void setCluster(const String & cluster_name, const std::shared_ptr<Cluster> & cluster);
|
2021-05-31 14:49:02 +00:00
|
|
|
void reloadClusterConfig() const;
|
2014-03-03 20:11:09 +00:00
|
|
|
|
2015-01-10 02:30:03 +00:00
|
|
|
Compiler & getCompiler();
|
2018-03-10 19:57:13 +00:00
|
|
|
|
|
|
|
/// Call after initialization before using system logs. Call for global context.
|
|
|
|
void initializeSystemLogs();
|
|
|
|
|
2020-03-03 00:24:44 +00:00
|
|
|
/// Call after initialization before using trace collector.
|
2019-02-03 21:30:45 +00:00
|
|
|
void initializeTraceCollector();
|
2020-03-03 00:24:44 +00:00
|
|
|
|
2021-12-27 03:50:59 +00:00
|
|
|
#if USE_ROCKSDB
|
2021-12-28 10:06:13 +00:00
|
|
|
void initializeMergeTreeMetadataCache(const String & dir, size_t size);
|
2021-12-27 03:50:59 +00:00
|
|
|
#endif
|
2021-12-08 02:40:59 +00:00
|
|
|
|
2023-07-28 07:23:34 +00:00
|
|
|
/// Call after unexpected crash happen.
|
|
|
|
void handleCrash() const;
|
|
|
|
|
2020-03-03 00:24:44 +00:00
|
|
|
bool hasTraceCollector() const;
|
2019-02-03 21:30:45 +00:00
|
|
|
|
2018-03-10 19:57:13 +00:00
|
|
|
/// Nullptr if the query log is not ready for this moment.
|
2021-05-31 14:49:02 +00:00
|
|
|
std::shared_ptr<QueryLog> getQueryLog() const;
|
|
|
|
std::shared_ptr<QueryThreadLog> getQueryThreadLog() const;
|
2021-06-18 13:44:08 +00:00
|
|
|
std::shared_ptr<QueryViewsLog> getQueryViewsLog() const;
|
2021-05-31 14:49:02 +00:00
|
|
|
std::shared_ptr<TraceLog> getTraceLog() const;
|
|
|
|
std::shared_ptr<TextLog> getTextLog() const;
|
|
|
|
std::shared_ptr<MetricLog> getMetricLog() const;
|
2021-04-10 23:33:54 +00:00
|
|
|
std::shared_ptr<AsynchronousMetricLog> getAsynchronousMetricLog() const;
|
2021-05-31 14:49:02 +00:00
|
|
|
std::shared_ptr<OpenTelemetrySpanLog> getOpenTelemetrySpanLog() const;
|
2021-07-09 14:05:35 +00:00
|
|
|
std::shared_ptr<ZooKeeperLog> getZooKeeperLog() const;
|
2021-03-05 14:57:16 +00:00
|
|
|
std::shared_ptr<SessionLog> getSessionLog() const;
|
2022-01-14 14:03:00 +00:00
|
|
|
std::shared_ptr<TransactionsInfoLog> getTransactionsInfoLog() const;
|
2022-02-05 16:33:42 +00:00
|
|
|
std::shared_ptr<ProcessorsProfileLog> getProcessorsProfileLog() const;
|
2022-04-30 05:00:40 +00:00
|
|
|
std::shared_ptr<FilesystemCacheLog> getFilesystemCacheLog() const;
|
2023-02-07 17:50:31 +00:00
|
|
|
std::shared_ptr<FilesystemReadPrefetchesLog> getFilesystemReadPrefetchesLog() const;
|
2022-10-03 18:52:14 +00:00
|
|
|
std::shared_ptr<AsynchronousInsertLog> getAsynchronousInsertLog() const;
|
2017-06-05 13:59:38 +00:00
|
|
|
|
2020-08-08 01:01:47 +00:00
|
|
|
/// Returns an object used to log operations with parts if it possible.
|
|
|
|
/// Provide table name to make required checks.
|
2021-05-31 14:49:02 +00:00
|
|
|
std::shared_ptr<PartLog> getPartLog(const String & part_database) const;
|
2018-03-10 19:57:13 +00:00
|
|
|
|
2018-08-10 17:42:12 +00:00
|
|
|
const MergeTreeSettings & getMergeTreeSettings() const;
|
2020-08-10 11:23:58 +00:00
|
|
|
const MergeTreeSettings & getReplicatedMergeTreeSettings() const;
|
2020-06-01 17:16:09 +00:00
|
|
|
const StorageS3Settings & getStorageS3Settings() const;
|
2015-06-26 20:48:10 +00:00
|
|
|
|
2017-01-23 19:18:25 +00:00
|
|
|
/// Prevents DROP TABLE if its size is greater than max_size (50GB by default, max_size=0 turn off this check)
|
2017-01-19 19:11:12 +00:00
|
|
|
void setMaxTableSizeToDrop(size_t max_size);
|
2019-01-04 12:10:00 +00:00
|
|
|
void checkTableCanBeDropped(const String & database, const String & table, const size_t & table_size) const;
|
2017-01-19 19:11:12 +00:00
|
|
|
|
2018-08-01 17:41:18 +00:00
|
|
|
/// Prevents DROP PARTITION if its size is greater than max_size (50GB by default, max_size=0 turn off this check)
|
2018-08-03 08:33:57 +00:00
|
|
|
void setMaxPartitionSizeToDrop(size_t max_size);
|
2019-01-04 12:10:00 +00:00
|
|
|
void checkPartitionCanBeDropped(const String & database, const String & table, const size_t & partition_size) const;
|
2017-01-19 19:11:12 +00:00
|
|
|
|
2018-12-21 12:17:30 +00:00
|
|
|
/// Lets you select the compression codec according to the conditions described in the configuration file.
|
|
|
|
std::shared_ptr<ICompressionCodec> chooseCompressionCodec(size_t part_size, double part_size_ratio) const;
|
2015-04-17 05:35:53 +00:00
|
|
|
|
2019-04-21 18:38:44 +00:00
|
|
|
|
|
|
|
/// Provides storage disks
|
2020-01-09 14:50:34 +00:00
|
|
|
DiskPtr getDisk(const String & name) const;
|
2022-09-30 12:12:06 +00:00
|
|
|
using DiskCreator = std::function<DiskPtr(const DisksMap & disks_map)>;
|
|
|
|
DiskPtr getOrCreateDisk(const String & name, DiskCreator creator) const;
|
2019-04-21 18:38:44 +00:00
|
|
|
|
2020-05-22 10:33:57 +00:00
|
|
|
StoragePoliciesMap getPoliciesMap() const;
|
|
|
|
DisksMap getDisksMap() const;
|
2020-01-09 14:50:34 +00:00
|
|
|
void updateStorageConfiguration(const Poco::Util::AbstractConfiguration & config);
|
2019-05-24 19:03:07 +00:00
|
|
|
|
2019-04-05 17:37:27 +00:00
|
|
|
/// Provides storage politics schemes
|
2020-01-09 14:50:34 +00:00
|
|
|
StoragePolicyPtr getStoragePolicy(const String & name) const;
|
2019-04-04 17:19:11 +00:00
|
|
|
|
2023-01-06 15:10:00 +00:00
|
|
|
StoragePolicyPtr getStoragePolicyFromDisk(const String & disk_name) const;
|
2022-09-27 20:34:31 +00:00
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/// Get the server uptime in seconds.
|
2022-09-11 01:21:34 +00:00
|
|
|
double getUptimeSeconds() const;
|
2016-04-09 07:47:08 +00:00
|
|
|
|
2018-03-13 10:41:47 +00:00
|
|
|
using ConfigReloadCallback = std::function<void()>;
|
|
|
|
void setConfigReloadCallback(ConfigReloadCallback && callback);
|
|
|
|
void reloadConfig() const;
|
|
|
|
|
2023-07-26 17:58:41 +00:00
|
|
|
using StartStopServersCallback = std::function<void(const ServerType &)>;
|
|
|
|
void setStartServersCallback(StartStopServersCallback && callback);
|
|
|
|
void setStopServersCallback(StartStopServersCallback && callback);
|
|
|
|
|
|
|
|
void startServers(const ServerType & server_type) const;
|
|
|
|
void stopServers(const ServerType & server_type) const;
|
|
|
|
|
2015-04-16 06:12:35 +00:00
|
|
|
void shutdown();
|
2015-04-02 16:30:18 +00:00
|
|
|
|
2021-05-16 21:35:37 +00:00
|
|
|
bool isInternalQuery() const { return is_internal_query; }
|
|
|
|
void setInternalQuery(bool internal) { is_internal_query = internal; }
|
|
|
|
|
2022-09-09 16:27:19 +00:00
|
|
|
ActionLocksManagerPtr getActionLocksManager() const;
|
2018-05-21 13:49:54 +00:00
|
|
|
|
2016-11-11 17:01:02 +00:00
|
|
|
enum class ApplicationType
|
|
|
|
{
|
2017-06-05 13:59:38 +00:00
|
|
|
SERVER, /// The program is run as clickhouse-server daemon (default behavior)
|
|
|
|
CLIENT, /// clickhouse-client
|
2021-05-18 14:08:56 +00:00
|
|
|
LOCAL, /// clickhouse-local
|
|
|
|
KEEPER, /// clickhouse-keeper (also daemon)
|
2022-04-08 07:52:16 +00:00
|
|
|
DISKS, /// clickhouse-disks
|
2016-11-11 17:01:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ApplicationType getApplicationType() const;
|
|
|
|
void setApplicationType(ApplicationType type);
|
|
|
|
|
2018-02-01 13:52:29 +00:00
|
|
|
/// Sets default_profile and system_profile, must be called once during the initialization
|
|
|
|
void setDefaultProfiles(const Poco::Util::AbstractConfiguration & config);
|
2017-03-23 14:14:56 +00:00
|
|
|
String getDefaultProfileName() const;
|
2018-02-01 13:52:29 +00:00
|
|
|
String getSystemProfileName() const;
|
2017-03-23 14:14:56 +00:00
|
|
|
|
2017-11-10 06:48:28 +00:00
|
|
|
/// Base path for format schemas
|
|
|
|
String getFormatSchemaPath() const;
|
|
|
|
void setFormatSchemaPath(const String & path);
|
|
|
|
|
2018-07-05 23:36:09 +00:00
|
|
|
SampleBlockCache & getSampleBlockCache() const;
|
2018-05-30 19:23:15 +00:00
|
|
|
|
2019-05-18 21:07:23 +00:00
|
|
|
/// Query parameters for prepared statements.
|
2019-05-25 13:43:52 +00:00
|
|
|
bool hasQueryParameters() const;
|
2019-06-15 17:52:53 +00:00
|
|
|
const NameToNameMap & getQueryParameters() const;
|
2022-08-12 12:28:35 +00:00
|
|
|
|
|
|
|
/// Throws if parameter with the given name already set.
|
2019-06-15 17:52:53 +00:00
|
|
|
void setQueryParameter(const String & name, const String & value);
|
2019-10-02 19:54:40 +00:00
|
|
|
void setQueryParameters(const NameToNameMap & parameters) { query_parameters = parameters; }
|
2019-05-18 21:07:23 +00:00
|
|
|
|
2022-08-12 12:28:35 +00:00
|
|
|
/// Overrides values of existing parameters.
|
|
|
|
void addQueryParameters(const NameToNameMap & parameters);
|
|
|
|
|
2018-11-22 15:59:00 +00:00
|
|
|
/// Add started bridge command. It will be killed after context destruction
|
2021-03-17 08:21:04 +00:00
|
|
|
void addBridgeCommand(std::unique_ptr<ShellCommand> cmd) const;
|
2018-11-22 15:59:00 +00:00
|
|
|
|
2019-03-06 16:41:35 +00:00
|
|
|
IHostContextPtr & getHostContext();
|
|
|
|
const IHostContextPtr & getHostContext() const;
|
|
|
|
|
2021-02-19 23:41:58 +00:00
|
|
|
/// Initialize context of distributed DDL query with Replicated database.
|
|
|
|
void initZooKeeperMetadataTransaction(ZooKeeperMetadataTransactionPtr txn, bool attach_existing = false);
|
|
|
|
/// Returns context of current distributed DDL query or nullptr.
|
|
|
|
ZooKeeperMetadataTransactionPtr getZooKeeperMetadataTransaction() const;
|
2021-07-02 16:39:55 +00:00
|
|
|
/// Removes context of current distributed DDL.
|
|
|
|
void resetZooKeeperMetadataTransaction();
|
2020-11-20 16:06:27 +00:00
|
|
|
|
2022-01-31 22:27:55 +00:00
|
|
|
void checkTransactionsAreAllowed(bool explicit_tcl_query = false) const;
|
2021-04-09 12:53:51 +00:00
|
|
|
void initCurrentTransaction(MergeTreeTransactionPtr txn);
|
2021-03-31 17:55:04 +00:00
|
|
|
void setCurrentTransaction(MergeTreeTransactionPtr txn);
|
|
|
|
MergeTreeTransactionPtr getCurrentTransaction() const;
|
|
|
|
|
2022-03-14 20:43:34 +00:00
|
|
|
bool isServerCompletelyStarted() const;
|
|
|
|
void setServerCompletelyStarted();
|
|
|
|
|
2021-05-31 14:49:02 +00:00
|
|
|
PartUUIDsPtr getPartUUIDs() const;
|
|
|
|
PartUUIDsPtr getIgnoredPartUUIDs() const;
|
2021-04-06 11:05:47 +00:00
|
|
|
|
2021-04-21 13:16:16 +00:00
|
|
|
AsynchronousInsertQueue * getAsynchronousInsertQueue() const;
|
2021-04-19 19:16:34 +00:00
|
|
|
void setAsynchronousInsertQueue(const std::shared_ptr<AsynchronousInsertQueue> & ptr);
|
2021-03-17 14:11:47 +00:00
|
|
|
|
2021-04-08 19:00:39 +00:00
|
|
|
ReadTaskCallback getReadTaskCallback() const;
|
|
|
|
void setReadTaskCallback(ReadTaskCallback && callback);
|
2021-04-06 11:05:47 +00:00
|
|
|
|
2021-12-09 10:39:28 +00:00
|
|
|
MergeTreeReadTaskCallback getMergeTreeReadTaskCallback() const;
|
|
|
|
void setMergeTreeReadTaskCallback(MergeTreeReadTaskCallback && callback);
|
|
|
|
|
2023-02-03 13:34:18 +00:00
|
|
|
MergeTreeAllRangesCallback getMergeTreeAllRangesCallback() const;
|
|
|
|
void setMergeTreeAllRangesCallback(MergeTreeAllRangesCallback && callback);
|
|
|
|
|
|
|
|
UUID getParallelReplicasGroupUUID() const;
|
|
|
|
void setParallelReplicasGroupUUID(UUID uuid);
|
|
|
|
|
2021-08-30 19:37:03 +00:00
|
|
|
/// Background executors related methods
|
2021-10-19 08:19:43 +00:00
|
|
|
void initializeBackgroundExecutorsIfNeeded();
|
2022-04-19 15:01:41 +00:00
|
|
|
bool areBackgroundExecutorsInitialized();
|
2021-08-30 19:37:03 +00:00
|
|
|
|
2021-09-30 21:26:24 +00:00
|
|
|
MergeMutateBackgroundExecutorPtr getMergeMutateExecutor() const;
|
|
|
|
OrdinaryBackgroundExecutorPtr getMovesExecutor() const;
|
|
|
|
OrdinaryBackgroundExecutorPtr getFetchesExecutor() const;
|
|
|
|
OrdinaryBackgroundExecutorPtr getCommonExecutor() const;
|
2021-08-30 19:37:03 +00:00
|
|
|
|
2022-09-23 17:35:16 +00:00
|
|
|
IAsynchronousReader & getThreadPoolReader(FilesystemReaderType type) const;
|
|
|
|
|
2023-02-07 17:50:31 +00:00
|
|
|
std::shared_ptr<AsyncReadCounters> getAsyncReadCounters() const;
|
|
|
|
|
2022-09-07 15:44:29 +00:00
|
|
|
ThreadPool & getThreadPoolWriter() const;
|
|
|
|
|
2021-08-24 21:45:58 +00:00
|
|
|
/** Get settings for reading from filesystem. */
|
|
|
|
ReadSettings getReadSettings() const;
|
|
|
|
|
2023-03-30 17:06:49 +00:00
|
|
|
/** Get settings for reading from filesystem for BACKUPs. */
|
|
|
|
ReadSettings getBackupReadSettings() const;
|
|
|
|
|
2022-03-21 08:52:48 +00:00
|
|
|
/** Get settings for writing to filesystem. */
|
|
|
|
WriteSettings getWriteSettings() const;
|
|
|
|
|
2023-02-03 13:34:18 +00:00
|
|
|
/** There are multiple conditions that have to be met to be able to use parallel replicas */
|
|
|
|
bool canUseParallelReplicasOnInitiator() const;
|
|
|
|
bool canUseParallelReplicasOnFollower() const;
|
|
|
|
|
2023-03-03 15:14:49 +00:00
|
|
|
enum class ParallelReplicasMode : uint8_t
|
|
|
|
{
|
|
|
|
SAMPLE_KEY,
|
|
|
|
CUSTOM_KEY,
|
|
|
|
READ_TASKS,
|
|
|
|
};
|
|
|
|
|
|
|
|
ParallelReplicasMode getParallelReplicasMode() const;
|
|
|
|
|
2023-03-02 19:19:58 +00:00
|
|
|
void setPreparedSetsCache(const PreparedSetsCachePtr & cache);
|
|
|
|
PreparedSetsCachePtr getPreparedSetsCache() const;
|
|
|
|
|
2015-04-02 16:30:18 +00:00
|
|
|
private:
|
2020-02-13 21:00:03 +00:00
|
|
|
std::unique_lock<std::recursive_mutex> getLock() const;
|
|
|
|
|
2020-09-07 23:08:17 +00:00
|
|
|
void initGlobal();
|
|
|
|
|
2020-01-12 21:00:55 +00:00
|
|
|
template <typename... Args>
|
|
|
|
void checkAccessImpl(const Args &... args) const;
|
|
|
|
|
2017-08-24 18:19:06 +00:00
|
|
|
EmbeddedDictionaries & getEmbeddedDictionariesImpl(bool throw_on_error) const;
|
2015-08-19 21:15:27 +00:00
|
|
|
|
2019-01-04 12:10:00 +00:00
|
|
|
void checkCanBeDropped(const String & database, const String & table, const size_t & size, const size_t & max_size_to_drop) const;
|
2020-05-21 14:11:56 +00:00
|
|
|
|
|
|
|
StoragePolicySelectorPtr getStoragePolicySelector(std::lock_guard<std::mutex> & lock) const;
|
|
|
|
|
2022-09-30 12:12:06 +00:00
|
|
|
DiskSelectorPtr getDiskSelector(std::lock_guard<std::mutex> & lock) const;
|
|
|
|
|
|
|
|
DisksMap getDisksMap(std::lock_guard<std::mutex> & lock) const;
|
2023-03-29 14:18:56 +00:00
|
|
|
|
2023-04-18 12:01:45 +00:00
|
|
|
/// Expect lock for shared->clusters_mutex
|
|
|
|
std::shared_ptr<Clusters> getClustersImpl(std::lock_guard<std::mutex> & lock) const;
|
2023-04-14 19:41:26 +00:00
|
|
|
|
2023-03-29 14:18:56 +00:00
|
|
|
/// Throttling
|
|
|
|
public:
|
|
|
|
ThrottlerPtr getReplicatedFetchesThrottler() const;
|
|
|
|
ThrottlerPtr getReplicatedSendsThrottler() const;
|
|
|
|
|
|
|
|
ThrottlerPtr getRemoteReadThrottler() const;
|
|
|
|
ThrottlerPtr getRemoteWriteThrottler() const;
|
2023-03-30 17:00:34 +00:00
|
|
|
|
2023-03-30 17:02:28 +00:00
|
|
|
ThrottlerPtr getLocalReadThrottler() const;
|
|
|
|
ThrottlerPtr getLocalWriteThrottler() const;
|
|
|
|
|
2023-03-30 17:12:00 +00:00
|
|
|
ThrottlerPtr getBackupsThrottler() const;
|
2023-03-30 17:06:49 +00:00
|
|
|
|
2023-03-30 17:00:34 +00:00
|
|
|
private:
|
|
|
|
mutable ThrottlerPtr remote_read_query_throttler; /// A query-wide throttler for remote IO reads
|
|
|
|
mutable ThrottlerPtr remote_write_query_throttler; /// A query-wide throttler for remote IO writes
|
2023-03-30 17:02:28 +00:00
|
|
|
|
|
|
|
mutable ThrottlerPtr local_read_query_throttler; /// A query-wide throttler for local IO reads
|
|
|
|
mutable ThrottlerPtr local_write_query_throttler; /// A query-wide throttler for local IO writes
|
2023-03-30 17:06:49 +00:00
|
|
|
|
2023-03-30 17:12:00 +00:00
|
|
|
mutable ThrottlerPtr backups_query_throttler; /// A query-wide throttler for BACKUPs
|
2017-06-02 18:48:33 +00:00
|
|
|
};
|
|
|
|
|
2022-11-09 14:51:41 +00:00
|
|
|
struct HTTPContext : public IHTTPContext
|
|
|
|
{
|
|
|
|
explicit HTTPContext(ContextPtr context_)
|
|
|
|
: context(Context::createCopy(context_))
|
|
|
|
{}
|
|
|
|
|
|
|
|
uint64_t getMaxHstsAge() const override
|
|
|
|
{
|
|
|
|
return context->getSettingsRef().hsts_max_age;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t getMaxUriSize() const override
|
|
|
|
{
|
|
|
|
return context->getSettingsRef().http_max_uri_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t getMaxFields() const override
|
|
|
|
{
|
|
|
|
return context->getSettingsRef().http_max_fields;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t getMaxFieldNameSize() const override
|
|
|
|
{
|
|
|
|
return context->getSettingsRef().http_max_field_name_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t getMaxFieldValueSize() const override
|
|
|
|
{
|
|
|
|
return context->getSettingsRef().http_max_field_value_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t getMaxChunkSize() const override
|
|
|
|
{
|
|
|
|
return context->getSettingsRef().http_max_chunk_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
Poco::Timespan getReceiveTimeout() const override
|
|
|
|
{
|
|
|
|
return context->getSettingsRef().http_receive_timeout;
|
|
|
|
}
|
|
|
|
|
|
|
|
Poco::Timespan getSendTimeout() const override
|
|
|
|
{
|
|
|
|
return context->getSettingsRef().http_send_timeout;
|
|
|
|
}
|
|
|
|
|
|
|
|
ContextPtr context;
|
|
|
|
};
|
|
|
|
|
2011-08-09 19:19:25 +00:00
|
|
|
}
|
2023-05-17 13:32:51 +00:00
|
|
|
|
2023-05-24 07:36:39 +00:00
|
|
|
#else
|
2023-05-17 13:32:51 +00:00
|
|
|
|
2023-05-22 12:24:16 +00:00
|
|
|
#include <Coordination/Standalone/Context.h>
|
2023-05-17 13:32:51 +00:00
|
|
|
|
|
|
|
#endif
|