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
|
|
|
{
|
2016-08-30 19:27:15 +00:00
|
|
|
friend class ext::shared_ptr_helper<StorageNull>;
|
2016-08-26 21:25:05 +00:00
|
|
|
|
2014-06-16 17:32:31 +00:00
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
std::string getName() const override { return "Null"; }
|
|
|
|
std::string getTableName() const override { return name; }
|
2014-06-16 17:32:31 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
const NamesAndTypesList & getColumnsListImpl() const override { return *columns; }
|
2014-06-16 17:32:31 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
BlockInputStreams read(
|
|
|
|
const Names & column_names,
|
2017-05-25 01:12:41 +00:00
|
|
|
const ASTPtr & query,
|
2017-04-01 07:20:54 +00:00
|
|
|
const Context & context,
|
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
2017-06-02 15:54:39 +00:00
|
|
|
size_t max_block_size,
|
|
|
|
unsigned num_streams) override
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
return { std::make_shared<NullBlockInputStream>() };
|
|
|
|
}
|
2014-06-16 17:32:31 +00:00
|
|
|
|
2017-05-21 22:25:25 +00:00
|
|
|
BlockOutputStreamPtr write(const ASTPtr & query, const Settings & settings) override
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
return std::make_shared<NullBlockOutputStream>();
|
|
|
|
}
|
2014-06-16 17:32:31 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void rename(const String & new_path_to_db, const String & new_database_name, const String & new_table_name) override
|
|
|
|
{
|
|
|
|
name = new_table_name;
|
|
|
|
}
|
2014-06-16 17:32:31 +00:00
|
|
|
|
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
String name;
|
|
|
|
NamesAndTypesListPtr columns;
|
2014-06-16 17:32:31 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
StorageNull(
|
|
|
|
const std::string & name_,
|
|
|
|
NamesAndTypesListPtr columns_,
|
|
|
|
const NamesAndTypesList & materialized_columns_,
|
|
|
|
const NamesAndTypesList & alias_columns_,
|
|
|
|
const ColumnDefaults & column_defaults_)
|
|
|
|
: IStorage{materialized_columns_, alias_columns_, column_defaults_}, name(name_), columns(columns_) {}
|
2014-06-16 17:32:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|