ClickHouse/dbms/src/Databases/DatabaseDictionary.h

104 lines
2.5 KiB
C++
Raw Normal View History

2017-06-22 15:44:19 +00:00
#pragma once
#include <mutex>
#include <unordered_set>
#include <Databases/DatabasesCommon.h>
2017-06-22 15:44:19 +00:00
#include <Databases/IDatabase.h>
#include <Storages/IStorage.h>
namespace Poco
{
2017-06-22 18:00:29 +00:00
class Logger;
2017-06-22 15:44:19 +00:00
}
namespace DB
{
/* Database to store StorageDictionary tables
* automatically creates tables for all dictionaries
*/
class DatabaseDictionary : public IDatabase
{
public:
DatabaseDictionary(const String & name_);
2017-06-22 15:44:19 +00:00
String getDatabaseName() const override;
2017-06-22 18:00:29 +00:00
String getEngineName() const override
{
2017-06-22 15:44:19 +00:00
return "Dictionary";
}
void loadTables(
Context & context,
ThreadPool * thread_pool,
bool has_force_restore_data_flag) override;
2017-06-22 15:44:19 +00:00
bool isTableExist(
const Context & context,
const String & table_name) const override;
2017-06-22 15:44:19 +00:00
StoragePtr tryGetTable(
const Context & context,
const String & table_name) const override;
2017-06-22 15:44:19 +00:00
DatabaseIteratorPtr getIterator(const Context & context) override;
2017-06-22 15:44:19 +00:00
bool empty(const Context & context) const override;
2017-06-22 15:44:19 +00:00
void createTable(
const Context & context,
const String & table_name,
const StoragePtr & table,
const ASTPtr & query) override;
2017-06-22 15:44:19 +00:00
void removeTable(
const Context & context,
const String & table_name) override;
2017-06-22 15:44:19 +00:00
void attachTable(const String & table_name, const StoragePtr & table) override;
StoragePtr detachTable(const String & table_name) override;
2017-06-22 15:44:19 +00:00
void renameTable(
const Context & context,
const String & table_name,
IDatabase & to_database,
const String & to_table_name) override;
void alterTable(
const Context & context,
const String & name,
const ColumnsDescription & columns,
Data Skipping Indices (#4143) * made index parser * added index parsing * some fixes * added index interface and factory * fixed compilation * ptrs * added indexParts * indextypes * index condition * IndexCondition * added indexes in selectexecutor * fix * changed comment * fix * added granularity * comments * fix * fix * added writing indexes * removed indexpart class * fix * added setSkipIndexes * add rw for MergeTreeIndexes * fixes * upd error * fix * fix * reading * test index * fixed nullptr error * fixed * fix * unique names * asts -> exprlist * minmax index * fix * fixed select * fixed merging * fixed mutation * working minmax * removed test index * fixed style * added indexes to checkDataPart * added tests for minmax index * fixed constructor * fix style * fixed includes * fixed setSkipIndexes * added indexes meta to zookeeper * added parsing * removed throw * alter cmds parse * fix * added alter * fix * alters fix * fix alters * fix "after" * fixed alter * alter fix + test * fixes * upd setSkipIndexes * fixed alter bug with drop all indices * fix metadata editing * new test and repl fix * rm test files * fixed repl alter * fix * fix * indices * MTReadStream * upd test for bug * fix * added useful parsers and ast classes * fix * fix comments * replaced columns * fix * fixed parsing * fixed printing * fix err * basic IndicesDescription * go to IndicesDescr * moved indices * go to indicesDescr * fix test minmax_index* * fixed MT alter * fixed bug with replMT indices storing in zk * rename * refactoring * docs ru * docs ru * docs en * refactor * rename tests * fix docs * refactoring * fix * fix * fix * fixed style * unique idx * unique * fix * better minmax calculation * upd * added getBlock * unique_condition * added termForAST * unique * fixed not * uniqueCondition::mayBeTrueOnGranule * fix * fixed bug with double column * is always true * fix * key set * spaces * test * tests * fix * unique * fix * fix * fixed bug with duplicate column * removed unused data * fix * fixes * __bitSwapLastTwo * fix
2019-02-05 14:50:25 +00:00
const IndicesDescription & indices,
const ASTModifier & engine_modifier) override;
time_t getTableMetadataModificationTime(
const Context & context,
const String & table_name) override;
ASTPtr getCreateTableQuery(
const Context & context,
const String & table_name) const override;
2017-06-22 15:44:19 +00:00
ASTPtr tryGetCreateTableQuery(
2018-03-23 19:56:24 +00:00
const Context & context,
const String & table_name) const override;
ASTPtr getCreateDatabaseQuery(const Context & context) const override;
2017-06-22 15:44:19 +00:00
void shutdown() override;
2018-03-23 19:56:24 +00:00
private:
const String name;
mutable std::mutex mutex;
Poco::Logger * log;
Tables listTables(const Context & context);
2018-03-23 19:56:24 +00:00
ASTPtr getCreateTableQueryImpl(const Context & context, const String & table_name, bool throw_on_error) const;
2017-06-22 15:44:19 +00:00
};
2017-06-22 15:44:19 +00:00
}