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>
|
2020-02-03 11:22:21 +00:00
|
|
|
#include <Processors/Sources/NullSource.h>
|
|
|
|
#include <Processors/Pipe.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
|
|
|
*/
|
2020-03-19 23:48:53 +00:00
|
|
|
class StorageNull final : 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"; }
|
2014-06-16 17:32:31 +00:00
|
|
|
|
2020-02-19 16:07:28 +00:00
|
|
|
Pipes read(
|
2018-01-09 02:09:08 +00:00
|
|
|
const Names & column_names,
|
2020-06-16 14:25:08 +00:00
|
|
|
const StorageMetadataPtr & metadata_snapshot,
|
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
|
|
|
{
|
2020-02-03 11:22:21 +00:00
|
|
|
Pipes pipes;
|
2020-06-16 14:25:08 +00:00
|
|
|
pipes.emplace_back(
|
2020-06-19 17:17:13 +00:00
|
|
|
std::make_shared<NullSource>(metadata_snapshot->getSampleBlockForColumns(column_names, getVirtuals(), getStorageID())));
|
2020-02-03 11:22:21 +00:00
|
|
|
return pipes;
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2014-06-16 17:32:31 +00:00
|
|
|
|
2020-06-16 14:25:08 +00:00
|
|
|
BlockOutputStreamPtr write(const ASTPtr &, const StorageMetadataPtr & metadata_snapshot, const Context &) override
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
2020-06-16 14:25:08 +00:00
|
|
|
return std::make_shared<NullBlockOutputStream>(metadata_snapshot->getSampleBlock());
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2014-06-16 17:32:31 +00:00
|
|
|
|
2020-06-10 11:16:31 +00:00
|
|
|
void checkAlterIsPossible(const AlterCommands & commands, const Settings & /* settings */) const override;
|
2019-12-26 18:17:05 +00:00
|
|
|
|
2020-06-18 16:10:47 +00:00
|
|
|
void alter(const AlterCommands & params, const Context & context, TableLockHolder & table_lock_holder) override;
|
2018-01-11 19:13:19 +00:00
|
|
|
|
2020-03-29 12:22:17 +00:00
|
|
|
std::optional<UInt64> totalRows() const override
|
|
|
|
{
|
|
|
|
return {0};
|
|
|
|
}
|
2020-03-29 14:44:32 +00:00
|
|
|
std::optional<UInt64> totalBytes() const override
|
|
|
|
{
|
|
|
|
return {0};
|
|
|
|
}
|
2020-03-29 12:22:17 +00:00
|
|
|
|
2014-06-16 17:32:31 +00:00
|
|
|
private:
|
|
|
|
|
2017-11-04 03:20:18 +00:00
|
|
|
protected:
|
2019-12-04 16:06:55 +00:00
|
|
|
StorageNull(const StorageID & table_id_, ColumnsDescription columns_description_, ConstraintsDescription constraints_)
|
|
|
|
: IStorage(table_id_)
|
2018-03-06 20:18:34 +00:00
|
|
|
{
|
2020-06-15 16:55:33 +00:00
|
|
|
StorageInMemoryMetadata metadata_;
|
|
|
|
metadata_.setColumns(columns_description_);
|
|
|
|
metadata_.setConstraints(constraints_);
|
|
|
|
setInMemoryMetadata(metadata_);
|
2018-03-06 20:18:34 +00:00
|
|
|
}
|
2014-06-16 17:32:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|