2019-05-19 05:27:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DataStreams/IBlockOutputStream.h>
|
|
|
|
#include <Storages/ConstraintsDescription.h>
|
2020-03-13 10:30:55 +00:00
|
|
|
#include <Interpreters/StorageID.h>
|
2019-08-24 13:00:04 +00:00
|
|
|
|
2019-05-19 05:27:00 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-08-24 13:00:04 +00:00
|
|
|
/** Check for constraints violation. If anything is found - throw an exception with detailed error message.
|
|
|
|
* Otherwise just pass block to output unchanged.
|
|
|
|
*/
|
2019-05-19 05:27:00 +00:00
|
|
|
|
|
|
|
class CheckConstraintsBlockOutputStream : public IBlockOutputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CheckConstraintsBlockOutputStream(
|
2020-03-02 20:23:58 +00:00
|
|
|
const StorageID & table_,
|
2019-05-19 05:27:00 +00:00
|
|
|
const BlockOutputStreamPtr & output_,
|
|
|
|
const Block & header_,
|
2019-05-19 07:19:44 +00:00
|
|
|
const ConstraintsDescription & constraints_,
|
2019-08-24 13:00:04 +00:00
|
|
|
const Context & context_);
|
2019-05-19 05:27:00 +00:00
|
|
|
|
|
|
|
Block getHeader() const override { return header; }
|
|
|
|
void write(const Block & block) override;
|
|
|
|
|
|
|
|
void flush() override;
|
|
|
|
|
|
|
|
void writePrefix() override;
|
|
|
|
void writeSuffix() override;
|
|
|
|
|
|
|
|
private:
|
2020-03-02 20:23:58 +00:00
|
|
|
StorageID table_id;
|
2019-05-19 05:27:00 +00:00
|
|
|
BlockOutputStreamPtr output;
|
|
|
|
Block header;
|
|
|
|
const ConstraintsDescription constraints;
|
|
|
|
const ConstraintsExpressions expressions;
|
2019-08-24 13:00:04 +00:00
|
|
|
size_t rows_written = 0;
|
2019-05-19 05:27:00 +00:00
|
|
|
};
|
|
|
|
}
|