2016-10-25 13:49:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-03-23 20:46:43 +00:00
|
|
|
#include <Databases/DatabasesCommon.h>
|
2016-10-25 13:49:07 +00:00
|
|
|
|
|
|
|
|
2017-01-21 04:24:28 +00:00
|
|
|
namespace Poco { class Logger; }
|
|
|
|
|
|
|
|
|
2016-10-25 13:49:07 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/** A non-persistent database to store temporary data.
|
|
|
|
* It doesn't make any manipulations with filesystem.
|
|
|
|
* All tables are created by calling code.
|
|
|
|
* TODO: Maybe DatabaseRuntime is more suitable class name.
|
|
|
|
*/
|
2018-03-23 20:46:43 +00:00
|
|
|
class DatabaseMemory : public DatabaseWithOwnTablesBase
|
2016-10-25 13:49:07 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-03-23 20:46:43 +00:00
|
|
|
DatabaseMemory(String name_);
|
2016-10-25 13:49:07 +00:00
|
|
|
|
2018-05-10 15:56:38 +00:00
|
|
|
String getDatabaseName() const override;
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String getEngineName() const override { return "Memory"; }
|
2016-10-25 13:49:07 +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-10-25 13:49:07 +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;
|
|
|
|
|
2019-10-17 13:05:12 +00:00
|
|
|
void attachDictionary(
|
|
|
|
const String & name,
|
2019-12-12 16:41:41 +00:00
|
|
|
const Context & context) override;
|
2019-10-17 13:05:12 +00:00
|
|
|
|
2017-09-11 12:39:01 +00:00
|
|
|
void removeTable(
|
|
|
|
const Context & context,
|
|
|
|
const String & table_name) override;
|
2016-10-25 13:49:07 +00:00
|
|
|
|
2019-10-10 17:33:01 +00:00
|
|
|
void removeDictionary(
|
2017-09-11 12:39:01 +00:00
|
|
|
const Context & context,
|
2019-10-10 17:33:01 +00:00
|
|
|
const String & dictionary_name) override;
|
|
|
|
|
2019-10-17 13:05:12 +00:00
|
|
|
void detachDictionary(
|
|
|
|
const String & name,
|
2019-12-12 16:41:41 +00:00
|
|
|
const Context & context) override;
|
2019-10-17 13:05:12 +00:00
|
|
|
|
2019-10-10 17:33:01 +00:00
|
|
|
time_t getObjectMetadataModificationTime(const Context & context, const String & table_name) override;
|
2017-09-11 12:39:01 +00:00
|
|
|
|
2018-03-23 19:56:24 +00:00
|
|
|
ASTPtr getCreateTableQuery(const Context & context, const String & table_name) const override;
|
2019-10-10 17:33:01 +00:00
|
|
|
ASTPtr getCreateDictionaryQuery(const Context & context, const String & table_name) const override;
|
2018-03-23 19:56:24 +00:00
|
|
|
ASTPtr tryGetCreateTableQuery(const Context &, const String &) const override { return nullptr; }
|
2019-10-10 17:33:01 +00:00
|
|
|
ASTPtr tryGetCreateDictionaryQuery(const Context &, const String &) const override { return nullptr; }
|
2018-03-14 19:56:44 +00:00
|
|
|
|
2018-03-13 13:28:32 +00:00
|
|
|
ASTPtr getCreateDatabaseQuery(const Context & context) const override;
|
2017-09-11 12:39:01 +00:00
|
|
|
|
2018-03-23 20:46:43 +00:00
|
|
|
private:
|
|
|
|
Poco::Logger * log;
|
2016-10-25 13:49:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|