1#pragma once
2
3#include <unordered_set>
4#include <unordered_map>
5
6#include <Core/Types.h>
7#include <Core/QualifiedTableName.h>
8
9namespace DB
10{
11
12namespace ErrorCodes
13{
14 extern const int LOGICAL_ERROR;
15 extern const int TOO_LARGE_ARRAY_SIZE;
16}
17
18class ReadBuffer;
19class WriteBuffer;
20
21
22/// The following are request-response messages for TablesStatus request of the client-server protocol.
23/// Client can ask for about a set of tables and the server will respond with the following information for each table:
24/// - Is the table Replicated?
25/// - If yes, replication delay for that table.
26///
27/// For nonexistent tables there will be no TableStatus entry in the response.
28
29struct TableStatus
30{
31 bool is_replicated = false;
32 UInt32 absolute_delay = 0;
33
34 void write(WriteBuffer & out) const;
35 void read(ReadBuffer & in);
36};
37
38struct TablesStatusRequest
39{
40 std::unordered_set<QualifiedTableName> tables;
41
42 void write(WriteBuffer & out, UInt64 server_protocol_revision) const;
43 void read(ReadBuffer & in, UInt64 client_protocol_revision);
44};
45
46struct TablesStatusResponse
47{
48 std::unordered_map<QualifiedTableName, TableStatus> table_states_by_id;
49
50 void write(WriteBuffer & out, UInt64 client_protocol_revision) const;
51 void read(ReadBuffer & in, UInt64 server_protocol_revision);
52};
53
54}
55