1 | #pragma once |
---|---|
2 | |
3 | #include <DataStreams/IBlockOutputStream.h> |
4 | #include <Storages/ConstraintsDescription.h> |
5 | |
6 | |
7 | namespace DB |
8 | { |
9 | |
10 | /** Check for constraints violation. If anything is found - throw an exception with detailed error message. |
11 | * Otherwise just pass block to output unchanged. |
12 | */ |
13 | |
14 | class CheckConstraintsBlockOutputStream : public IBlockOutputStream |
15 | { |
16 | public: |
17 | CheckConstraintsBlockOutputStream( |
18 | const String & table_, |
19 | const BlockOutputStreamPtr & output_, |
20 | const Block & header_, |
21 | const ConstraintsDescription & constraints_, |
22 | const Context & context_); |
23 | |
24 | Block getHeader() const override { return header; } |
25 | void write(const Block & block) override; |
26 | |
27 | void flush() override; |
28 | |
29 | void writePrefix() override; |
30 | void writeSuffix() override; |
31 | |
32 | private: |
33 | String table; |
34 | BlockOutputStreamPtr output; |
35 | Block header; |
36 | const ConstraintsDescription constraints; |
37 | const ConstraintsExpressions expressions; |
38 | size_t rows_written = 0; |
39 | }; |
40 | } |
41 |