2014-06-16 17:32:31 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-06-06 17:18:32 +00:00
|
|
|
#include <ext/shared_ptr_helper.h>
|
2016-08-26 21:25:05 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/NamesAndTypes.h>
|
|
|
|
#include <Storages/IStorage.h>
|
|
|
|
#include <DataStreams/NullBlockInputStream.h>
|
|
|
|
#include <DataStreams/NullBlockOutputStream.h>
|
2014-06-16 17:32:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/** When writing, does nothing.
|
|
|
|
* When reading, returns nothing.
|
2014-06-16 17:32:31 +00:00
|
|
|
*/
|
2017-06-06 18:36:13 +00:00
|
|
|
class StorageNull : public ext::shared_ptr_helper<StorageNull>, public IStorage
|
2014-06-16 17:32:31 +00:00
|
|
|
{
|
2019-08-26 19:07:29 +00:00
|
|
|
friend struct ext::shared_ptr_helper<StorageNull>;
|
2014-06-16 17:32:31 +00:00
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
std::string getName() const override { return "Null"; }
|
2018-03-06 20:18:34 +00:00
|
|
|
std::string getTableName() const override { return table_name; }
|
2019-07-09 15:40:21 +00:00
|
|
|
std::string getDatabaseName() const override { return database_name; }
|
2014-06-16 17:32:31 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
BlockInputStreams read(
|
2018-01-09 02:09:08 +00:00
|
|
|
const Names & column_names,
|
2017-12-01 21:13:25 +00:00
|
|
|
const SelectQueryInfo &,
|
2018-09-08 11:29:23 +00:00
|
|
|
const Context & /*context*/,
|
|
|
|
QueryProcessingStage::Enum /*processing_stage*/,
|
2017-12-01 21:13:25 +00:00
|
|
|
size_t,
|
|
|
|
unsigned) override
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
2018-01-09 02:09:08 +00:00
|
|
|
return { std::make_shared<NullBlockInputStream>(getSampleBlockForColumns(column_names)) };
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2014-06-16 17:32:31 +00:00
|
|
|
|
2019-02-27 18:26:24 +00:00
|
|
|
BlockOutputStreamPtr write(const ASTPtr &, const Context &) override
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
2018-02-19 00:45:32 +00:00
|
|
|
return std::make_shared<NullBlockOutputStream>(getSampleBlock());
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2014-06-16 17:32:31 +00:00
|
|
|
|
2019-08-27 23:47:30 +00:00
|
|
|
void rename(const String & /*new_path_to_db*/, const String & new_database_name, const String & new_table_name, TableStructureWriteLockHolder &) override
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
2018-03-06 20:18:34 +00:00
|
|
|
table_name = new_table_name;
|
2019-07-09 15:40:21 +00:00
|
|
|
database_name = new_database_name;
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2014-06-16 17:32:31 +00:00
|
|
|
|
2019-03-05 10:12:20 +00:00
|
|
|
void alter(
|
2019-08-26 14:50:34 +00:00
|
|
|
const AlterCommands & params, const Context & context, TableStructureWriteLockHolder & table_lock_holder) override;
|
2018-01-11 19:13:19 +00:00
|
|
|
|
2014-06-16 17:32:31 +00:00
|
|
|
private:
|
2018-03-06 20:18:34 +00:00
|
|
|
String table_name;
|
2019-07-09 15:40:21 +00:00
|
|
|
String database_name;
|
2014-06-16 17:32:31 +00:00
|
|
|
|
2017-11-04 03:20:18 +00:00
|
|
|
protected:
|
2019-08-24 21:20:20 +00:00
|
|
|
StorageNull(String database_name_, String table_name_, ColumnsDescription columns_description_, ConstraintsDescription constraints_)
|
|
|
|
: table_name(std::move(table_name_)), database_name(std::move(database_name_))
|
2018-03-06 20:18:34 +00:00
|
|
|
{
|
2019-08-24 21:20:20 +00:00
|
|
|
setColumns(std::move(columns_description_));
|
|
|
|
setConstraints(std::move(constraints_));
|
2018-03-06 20:18:34 +00:00
|
|
|
}
|
2014-06-16 17:32:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|