1#pragma once
2
3#define DBMS_DEFAULT_HOST "localhost"
4#define DBMS_DEFAULT_PORT 9000
5#define DBMS_DEFAULT_SECURE_PORT 9440
6#define DBMS_DEFAULT_HTTP_PORT 8123
7#define DBMS_DEFAULT_CONNECT_TIMEOUT_SEC 10
8#define DBMS_DEFAULT_CONNECT_TIMEOUT_WITH_FAILOVER_MS 50
9#define DBMS_DEFAULT_SEND_TIMEOUT_SEC 300
10#define DBMS_DEFAULT_RECEIVE_TIMEOUT_SEC 300
11/// Timeout for synchronous request-result protocol call (like Ping or TablesStatus).
12#define DBMS_DEFAULT_SYNC_REQUEST_TIMEOUT_SEC 5
13#define DBMS_DEFAULT_POLL_INTERVAL 10
14
15/// The size of the I/O buffer by default.
16#define DBMS_DEFAULT_BUFFER_SIZE 1048576ULL
17
18/** Which blocks by default read the data (by number of rows).
19 * Smaller values give better cache locality, less consumption of RAM, but more overhead to process the query.
20 */
21#define DEFAULT_BLOCK_SIZE 65536
22
23/** Which blocks should be formed for insertion into the table, if we control the formation of blocks.
24 * (Sometimes the blocks are inserted exactly such blocks that have been read / transmitted from the outside, and this parameter does not affect their size.)
25 * More than DEFAULT_BLOCK_SIZE, because in some tables a block of data on the disk is created for each block (quite a big thing),
26 * and if the parts were small, then it would be costly then to combine them.
27 */
28#define DEFAULT_INSERT_BLOCK_SIZE 1048576
29
30/** The same, but for merge operations. Less DEFAULT_BLOCK_SIZE for saving RAM (since all the columns are read).
31 * Significantly less, since there are 10-way mergers.
32 */
33#define DEFAULT_MERGE_BLOCK_SIZE 8192
34
35#define DEFAULT_TEMPORARY_LIVE_VIEW_TIMEOUT_SEC 5
36#define SHOW_CHARS_ON_SYNTAX_ERROR ptrdiff_t(160)
37#define DEFAULT_LIVE_VIEW_HEARTBEAT_INTERVAL_SEC 15
38#define DBMS_DEFAULT_DISTRIBUTED_CONNECTIONS_POOL_SIZE 1024
39#define DBMS_CONNECTION_POOL_WITH_FAILOVER_DEFAULT_MAX_TRIES 3
40/// each period reduces the error counter by 2 times
41/// too short a period can cause errors to disappear immediately after creation.
42#define DBMS_CONNECTION_POOL_WITH_FAILOVER_DEFAULT_DECREASE_ERROR_PERIOD 60
43/// replica error max cap, this is to prevent replica from accumulating too many errors and taking to long to recover.
44#define DBMS_CONNECTION_POOL_WITH_FAILOVER_MAX_ERROR_COUNT 1000
45
46#define DBMS_MIN_REVISION_WITH_CLIENT_INFO 54032
47#define DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE 54058
48#define DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO 54060
49#define DBMS_MIN_REVISION_WITH_TABLES_STATUS 54226
50#define DBMS_MIN_REVISION_WITH_TIME_ZONE_PARAMETER_IN_DATETIME_DATA_TYPE 54337
51#define DBMS_MIN_REVISION_WITH_SERVER_DISPLAY_NAME 54372
52#define DBMS_MIN_REVISION_WITH_VERSION_PATCH 54401
53#define DBMS_MIN_REVISION_WITH_SERVER_LOGS 54406
54#define DBMS_MIN_REVISION_WITH_CLIENT_SUPPORT_EMBEDDED_DATA 54415
55/// Minimum revision with exactly the same set of aggregation methods and rules to select them.
56/// Two-level (bucketed) aggregation is incompatible if servers are inconsistent in these rules
57/// (keys will be placed in different buckets and result will not be fully aggregated).
58#define DBMS_MIN_REVISION_WITH_CURRENT_AGGREGATION_VARIANT_SELECTION_METHOD 54408
59#define DBMS_MIN_REVISION_WITH_COLUMN_DEFAULTS_METADATA 54410
60
61#define DBMS_MIN_REVISION_WITH_LOW_CARDINALITY_TYPE 54405
62#define DBMS_MIN_REVISION_WITH_CLIENT_WRITE_INFO 54420
63
64/// Mininum revision supporting SettingsBinaryFormat::STRINGS.
65#define DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS 54429
66
67/// Version of ClickHouse TCP protocol. Set to git tag with latest protocol change.
68#define DBMS_TCP_PROTOCOL_VERSION 54226
69
70/// The boundary on which the blocks for asynchronous file operations should be aligned.
71#define DEFAULT_AIO_FILE_BLOCK_SIZE 4096
72
73#define DEFAULT_HTTP_READ_BUFFER_TIMEOUT 1800
74#define DEFAULT_HTTP_READ_BUFFER_CONNECTION_TIMEOUT 1
75/// Maximum namber of http-connections between two endpoints
76/// the number is unmotivated
77#define DEFAULT_COUNT_OF_HTTP_CONNECTIONS_PER_ENDPOINT 15
78
79#define DBMS_DEFAULT_PATH "/var/lib/clickhouse/"
80
81// more aliases: https://mailman.videolan.org/pipermail/x264-devel/2014-May/010660.html
82
83#if defined(_MSC_VER)
84 #define ALWAYS_INLINE __forceinline
85 #define NO_INLINE static __declspec(noinline)
86 #define MAY_ALIAS
87#else
88 #define ALWAYS_INLINE __attribute__((__always_inline__))
89 #define NO_INLINE __attribute__((__noinline__))
90 #define MAY_ALIAS __attribute__((__may_alias__))
91#endif
92
93
94#define PLATFORM_NOT_SUPPORTED "The only supported platforms are x86_64 and AArch64, PowerPC (work in progress)"
95
96#if !defined(__x86_64__) && !defined(__aarch64__) && !defined(__PPC__)
97 #error PLATFORM_NOT_SUPPORTED
98#endif
99
100/// Check for presence of address sanitizer
101#if !defined(ADDRESS_SANITIZER)
102#if defined(__has_feature)
103 #if __has_feature(address_sanitizer)
104 #define ADDRESS_SANITIZER 1
105 #endif
106#elif defined(__SANITIZE_ADDRESS__)
107 #define ADDRESS_SANITIZER 1
108#endif
109#endif
110
111#if !defined(THREAD_SANITIZER)
112#if defined(__has_feature)
113 #if __has_feature(thread_sanitizer)
114 #define THREAD_SANITIZER 1
115 #endif
116#elif defined(__SANITIZE_THREAD__)
117 #define THREAD_SANITIZER 1
118#endif
119#endif
120
121#if !defined(MEMORY_SANITIZER)
122#if defined(__has_feature)
123 #if __has_feature(memory_sanitizer)
124 #define MEMORY_SANITIZER 1
125 #endif
126#elif defined(__MEMORY_SANITIZER__)
127 #define MEMORY_SANITIZER 1
128#endif
129#endif
130
131/// TODO Strange enough, there is no way to detect UB sanitizer.
132
133/// Explicitly allow undefined behaviour for certain functions. Use it as a function attribute.
134/// It is useful in case when compiler cannot see (and exploit) it, but UBSan can.
135/// Example: multiplication of signed integers with possibility of overflow when both sides are from user input.
136#if defined(__clang__)
137 #define NO_SANITIZE_UNDEFINED __attribute__((__no_sanitize__("undefined")))
138 #define NO_SANITIZE_ADDRESS __attribute__((__no_sanitize__("address")))
139 #define NO_SANITIZE_THREAD __attribute__((__no_sanitize__("thread")))
140#else
141 /// It does not work in GCC. GCC 7 cannot recognize this attribute and GCC 8 simply ignores it.
142 #define NO_SANITIZE_UNDEFINED
143 #define NO_SANITIZE_ADDRESS
144 #define NO_SANITIZE_THREAD
145#endif
146
147#if defined __GNUC__ && !defined __clang__
148 #define OPTIMIZE(x) __attribute__((__optimize__(x)))
149#else
150 #define OPTIMIZE(x)
151#endif
152
153/// Marks that extra information is sent to a shard. It could be any magic numbers.
154#define DBMS_DISTRIBUTED_SIGNATURE_HEADER 0xCAFEDACEull
155#define DBMS_DISTRIBUTED_SIGNATURE_HEADER_OLD_FORMAT 0xCAFECABEull
156
157#if !__has_include(<sanitizer/asan_interface.h>)
158# define ASAN_UNPOISON_MEMORY_REGION(a, b)
159# define ASAN_POISON_MEMORY_REGION(a, b)
160#endif
161
162/// A macro for suppressing warnings about unused variables or function results.
163/// Useful for structured bindings which have no standard way to declare this.
164#define UNUSED(...) (void)(__VA_ARGS__)
165