2016-03-19 01:18:49 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-03-23 20:46:43 +00:00
|
|
|
#include <Databases/DatabasesCommon.h>
|
2019-08-27 20:43:08 +00:00
|
|
|
#include <Common/ThreadPool.h>
|
2016-03-19 01:18:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-10-25 13:49:07 +00:00
|
|
|
/** Default engine of databases.
|
|
|
|
* It stores tables list in filesystem using list of .sql files,
|
|
|
|
* that contain declaration of table represented by SQL ATTACH TABLE query.
|
2016-03-19 01:18:49 +00:00
|
|
|
*/
|
2018-03-23 20:46:43 +00:00
|
|
|
class DatabaseOrdinary : public DatabaseWithOwnTablesBase
|
2016-03-19 01:18:49 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-03-23 20:46:43 +00:00
|
|
|
DatabaseOrdinary(String name_, const String & metadata_path_, const Context & context);
|
2016-03-19 01:18:49 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String getEngineName() const override { return "Ordinary"; }
|
2016-03-19 01:18:49 +00:00
|
|
|
|
2019-10-10 17:33:01 +00:00
|
|
|
void loadStoredObjects(
|
2017-09-11 12:39:01 +00:00
|
|
|
Context & context,
|
|
|
|
bool has_force_restore_data_flag) override;
|
2016-06-10 20:46:58 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void createTable(
|
2017-09-11 12:39:01 +00:00
|
|
|
const Context & context,
|
|
|
|
const String & table_name,
|
|
|
|
const StoragePtr & table,
|
2017-10-25 19:52:32 +00:00
|
|
|
const ASTPtr & query) override;
|
2017-01-23 18:05:07 +00:00
|
|
|
|
2019-10-10 17:33:01 +00:00
|
|
|
void createDictionary(
|
|
|
|
const Context & context,
|
|
|
|
const String & dictionary_name,
|
|
|
|
const ASTPtr & query) override;
|
|
|
|
|
2017-09-11 12:39:01 +00:00
|
|
|
void removeTable(
|
|
|
|
const Context & context,
|
|
|
|
const String & table_name) override;
|
2016-03-19 01:18:49 +00:00
|
|
|
|
2019-10-10 17:33:01 +00:00
|
|
|
void removeDictionary(
|
|
|
|
const Context & context,
|
|
|
|
const String & table_name) override;
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void renameTable(
|
2017-09-11 12:39:01 +00:00
|
|
|
const Context & context,
|
|
|
|
const String & table_name,
|
|
|
|
IDatabase & to_database,
|
2019-08-27 20:43:08 +00:00
|
|
|
const String & to_table_name,
|
|
|
|
TableStructureWriteLockHolder &) override;
|
2016-05-13 21:08:19 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void alterTable(
|
|
|
|
const Context & context,
|
|
|
|
const String & name,
|
2018-03-06 20:18:34 +00:00
|
|
|
const ColumnsDescription & columns,
|
2019-02-05 14:50:25 +00:00
|
|
|
const IndicesDescription & indices,
|
2019-06-02 14:41:12 +00:00
|
|
|
const ConstraintsDescription & constraints,
|
2017-04-01 07:20:54 +00:00
|
|
|
const ASTModifier & engine_modifier) override;
|
2017-06-06 17:06:14 +00:00
|
|
|
|
2019-10-10 17:33:01 +00:00
|
|
|
time_t getObjectMetadataModificationTime(
|
2017-09-11 12:39:01 +00:00
|
|
|
const Context & context,
|
|
|
|
const String & table_name) override;
|
|
|
|
|
2018-03-13 13:28:32 +00:00
|
|
|
ASTPtr getCreateTableQuery(
|
2017-09-11 12:39:01 +00:00
|
|
|
const Context & context,
|
|
|
|
const String & table_name) const override;
|
|
|
|
|
2018-03-14 19:56:44 +00:00
|
|
|
ASTPtr tryGetCreateTableQuery(
|
2018-03-23 19:56:24 +00:00
|
|
|
const Context & context,
|
|
|
|
const String & table_name) const override;
|
2018-03-14 19:56:44 +00:00
|
|
|
|
2019-10-10 17:33:01 +00:00
|
|
|
ASTPtr tryGetCreateDictionaryQuery(
|
|
|
|
const Context & context,
|
|
|
|
const String & name) const override;
|
|
|
|
|
|
|
|
ASTPtr getCreateDictionaryQuery(
|
|
|
|
const Context & context,
|
|
|
|
const String & name) const override;
|
|
|
|
|
2018-03-13 13:28:32 +00:00
|
|
|
ASTPtr getCreateDatabaseQuery(const Context & context) const override;
|
|
|
|
|
2018-02-21 19:26:59 +00:00
|
|
|
String getDataPath() const override;
|
2018-05-10 15:56:38 +00:00
|
|
|
String getDatabaseName() const override;
|
2018-02-21 19:26:59 +00:00
|
|
|
String getMetadataPath() const override;
|
2019-10-10 17:33:01 +00:00
|
|
|
String getObjectMetadataPath(const String & table_name) const override;
|
2017-11-03 19:53:10 +00:00
|
|
|
|
2018-06-09 15:48:22 +00:00
|
|
|
void drop() override;
|
|
|
|
|
2017-06-06 17:06:14 +00:00
|
|
|
private:
|
2018-03-23 20:46:43 +00:00
|
|
|
const String metadata_path;
|
|
|
|
const String data_path;
|
|
|
|
Poco::Logger * log;
|
|
|
|
|
2019-07-19 14:22:57 +00:00
|
|
|
void startupTables(ThreadPool & thread_pool);
|
2016-03-19 01:18:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|