diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 7fb2abebbbb..fede3fe519d 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -40,3 +40,32 @@ At a minimum, the following information should be added (but add more as needed)
> Information about CI checks: https://clickhouse.com/docs/en/development/continuous-integration/
+
+---
+### Modify your CI run:
+**NOTE:** If your merge the PR with modified CI you **MUST KNOW** what you are doing
+**NOTE:** Set desired options before CI starts or re-push after updates
+
+#### Run only:
+- [ ] Integration tests
+- [ ] Integration tests (arm64)
+- [ ] Stateless tests (release)
+- [ ] Stateless tests (asan)
+- [ ] Stateful tests (release)
+- [ ] Stateful tests (asan)
+- [ ] No sanitizers
+- [ ] Tests with analyzer
+- [ ] Fast tests
+- [ ] Only package_debug build
+- [ ] Add your CI variant description here
+
+#### CI options:
+- [ ] do not test (only style check)
+- [ ] disable merge-commit (no merge from master before tests)
+- [ ] disable CI cache (job reuse)
+
+#### Only specified batches in multi-batch jobs:
+- [ ] 1
+- [ ] 2
+- [ ] 3
+- [ ] 4
diff --git a/.gitmessage b/.gitmessage
index 2ad30596de6..797446edd49 100644
--- a/.gitmessage
+++ b/.gitmessage
@@ -26,4 +26,4 @@
## To run only specified batches for multi-batch job(s)
#batch_2
-#btach_1_2_3
+#batch_1_2_3
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8c4e16eace2..42c21cae9f1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -61,11 +61,16 @@ if (ENABLE_CHECK_HEAVY_BUILDS)
# set CPU time limit to 1000 seconds
set (RLIMIT_CPU 1000)
- # -fsanitize=memory and address are too heavy
+ # Sanitizers are too heavy
if (SANITIZE OR SANITIZE_COVERAGE OR WITH_COVERAGE)
set (RLIMIT_DATA 10000000000) # 10G
endif()
+ # For some files currently building RISCV64 might be too slow. TODO: Improve compilation times per file
+ if (ARCH_RISCV64)
+ set (RLIMIT_CPU 1800)
+ endif()
+
set (CMAKE_CXX_COMPILER_LAUNCHER prlimit --as=${RLIMIT_AS} --data=${RLIMIT_DATA} --cpu=${RLIMIT_CPU} ${CMAKE_CXX_COMPILER_LAUNCHER})
endif ()
@@ -102,6 +107,8 @@ if (ENABLE_FUZZING)
# For codegen_select_fuzzer
set (ENABLE_PROTOBUF 1)
+
+ add_compile_definitions(FUZZING_MODE=1)
endif()
# Global libraries
@@ -574,7 +581,7 @@ if (FUZZER)
if (NOT(target_type STREQUAL "INTERFACE_LIBRARY" OR target_type STREQUAL "UTILITY"))
target_compile_options(${target} PRIVATE "-fsanitize=fuzzer-no-link")
endif()
- if (target_type STREQUAL "EXECUTABLE" AND (target MATCHES ".+_fuzzer" OR target STREQUAL "clickhouse"))
+ if (target_type STREQUAL "EXECUTABLE" AND target MATCHES ".+_fuzzer")
message(STATUS "${target} instrumented with fuzzer")
target_link_libraries(${target} PUBLIC ch_contrib::fuzzer)
# Add to fuzzers bundle
@@ -583,6 +590,12 @@ if (FUZZER)
get_target_property(target_bin_dir ${target} BINARY_DIR)
add_custom_command(TARGET fuzzers POST_BUILD COMMAND mv "${target_bin_dir}/${target_bin_name}" "${CMAKE_CURRENT_BINARY_DIR}/programs/" VERBATIM)
endif()
+ if (target STREQUAL "clickhouse")
+ message(STATUS "${target} instrumented with fuzzer")
+ target_link_libraries(${target} PUBLIC ch_contrib::fuzzer_no_main)
+ # Add to fuzzers bundle
+ add_dependencies(fuzzers ${target})
+ endif()
endif()
endforeach()
add_custom_command(TARGET fuzzers POST_BUILD COMMAND SRC=${CMAKE_SOURCE_DIR} BIN=${CMAKE_BINARY_DIR} OUT=${CMAKE_BINARY_DIR}/programs ${CMAKE_SOURCE_DIR}/tests/fuzz/build.sh VERBATIM)
diff --git a/base/base/CMakeLists.txt b/base/base/CMakeLists.txt
index 610877eae73..27aa0bd6baf 100644
--- a/base/base/CMakeLists.txt
+++ b/base/base/CMakeLists.txt
@@ -20,6 +20,7 @@ set (SRCS
getPageSize.cpp
getThreadId.cpp
int8_to_string.cpp
+ itoa.cpp
JSON.cpp
mremap.cpp
phdr_cache.cpp
diff --git a/base/base/IPv4andIPv6.h b/base/base/IPv4andIPv6.h
index e2f93b54124..9b1e518c161 100644
--- a/base/base/IPv4andIPv6.h
+++ b/base/base/IPv4andIPv6.h
@@ -1,8 +1,7 @@
#pragma once
-#include
#include
-#include
+#include
#include
namespace DB
@@ -62,7 +61,8 @@ namespace std
{
size_t operator()(const DB::IPv6 & x) const
{
- return std::hash{}(std::string_view(reinterpret_cast(&x.toUnderType()), IPV6_BINARY_LENGTH));
+ return std::hash{}(
+ std::string_view(reinterpret_cast(&x.toUnderType()), sizeof(DB::IPv6::UnderlyingType)));
}
};
diff --git a/base/base/itoa.cpp b/base/base/itoa.cpp
new file mode 100644
index 00000000000..fd8fd8de025
--- /dev/null
+++ b/base/base/itoa.cpp
@@ -0,0 +1,503 @@
+// Based on https://github.com/amdn/itoa and combined with our optimizations
+//
+//=== itoa.cpp - Fast integer to ascii conversion --*- C++ -*-//
+//
+// The MIT License (MIT)
+// Copyright (c) 2016 Arturo Martin-de-Nicolas
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+//===----------------------------------------------------------------------===//
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace
+{
+template
+ALWAYS_INLINE inline constexpr T pow10(size_t x)
+{
+ return x ? 10 * pow10(x - 1) : 1;
+}
+
+// Division by a power of 10 is implemented using a multiplicative inverse.
+// This strength reduction is also done by optimizing compilers, but
+// presently the fastest results are produced by using the values
+// for the multiplication and the shift as given by the algorithm
+// described by Agner Fog in "Optimizing Subroutines in Assembly Language"
+//
+// http://www.agner.org/optimize/optimizing_assembly.pdf
+//
+// "Integer division by a constant (all processors)
+// A floating point number can be divided by a constant by multiplying
+// with the reciprocal. If we want to do the same with integers, we have
+// to scale the reciprocal by 2n and then shift the product to the right
+// by n. There are various algorithms for finding a suitable value of n
+// and compensating for rounding errors. The algorithm described below
+// was invented by Terje Mathisen, Norway, and not published elsewhere."
+
+/// Division by constant is performed by:
+/// 1. Adding 1 if needed;
+/// 2. Multiplying by another constant;
+/// 3. Shifting right by another constant.
+template
+struct Division
+{
+ static constexpr bool add{add_};
+ static constexpr UInt multiplier{multiplier_};
+ static constexpr unsigned shift{shift_};
+};
+
+/// Select a type with appropriate number of bytes from the list of types.
+/// First parameter is the number of bytes requested. Then goes a list of types with 1, 2, 4, ... number of bytes.
+/// Example: SelectType<4, uint8_t, uint16_t, uint32_t, uint64_t> will select uint32_t.
+template
+struct SelectType
+{
+ using Result = typename SelectType::Result;
+};
+
+template
+struct SelectType<1, T, Ts...>
+{
+ using Result = T;
+};
+
+
+/// Division by 10^N where N is the size of the type.
+template
+using DivisionBy10PowN = typename SelectType<
+ N,
+ Division, /// divide by 10
+ Division, /// divide by 100
+ Division, /// divide by 10000
+ Division /// divide by 100000000
+ >::Result;
+
+template
+using UnsignedOfSize = typename SelectType::Result;
+
+/// Holds the result of dividing an unsigned N-byte variable by 10^N resulting in
+template
+struct QuotientAndRemainder
+{
+ UnsignedOfSize quotient; // quotient with fewer than 2*N decimal digits
+ UnsignedOfSize remainder; // remainder with at most N decimal digits
+};
+
+template
+QuotientAndRemainder inline split(UnsignedOfSize value)
+{
+ constexpr DivisionBy10PowN division;
+
+ UnsignedOfSize quotient = (division.multiplier * (UnsignedOfSize<2 * N>(value) + division.add)) >> division.shift;
+ UnsignedOfSize remainder = static_cast>(value - quotient * pow10>(N));
+
+ return {quotient, remainder};
+}
+
+ALWAYS_INLINE inline char * outDigit(char * p, uint8_t value)
+{
+ *p = '0' + value;
+ ++p;
+ return p;
+}
+
+// Using a lookup table to convert binary numbers from 0 to 99
+// into ascii characters as described by Andrei Alexandrescu in
+// https://www.facebook.com/notes/facebook-engineering/three-optimization-tips-for-c/10151361643253920/
+
+const char digits[201] = "00010203040506070809"
+ "10111213141516171819"
+ "20212223242526272829"
+ "30313233343536373839"
+ "40414243444546474849"
+ "50515253545556575859"
+ "60616263646566676869"
+ "70717273747576777879"
+ "80818283848586878889"
+ "90919293949596979899";
+
+ALWAYS_INLINE inline char * outTwoDigits(char * p, uint8_t value)
+{
+ memcpy(p, &digits[value * 2], 2);
+ p += 2;
+ return p;
+}
+
+namespace convert
+{
+template
+char * head(char * p, UInt u);
+template
+char * tail(char * p, UInt u);
+
+//===----------------------------------------------------------===//
+// head: find most significant digit, skip leading zeros
+//===----------------------------------------------------------===//
+
+// "x" contains quotient and remainder after division by 10^N
+// quotient is less than 10^N
+template
+ALWAYS_INLINE inline char * head(char * p, QuotientAndRemainder x)
+{
+ p = head(p, UnsignedOfSize(x.quotient));
+ p = tail(p, x.remainder);
+ return p;
+}
+
+// "u" is less than 10^2*N
+template
+ALWAYS_INLINE inline char * head(char * p, UInt u)
+{
+ return u < pow10>(N) ? head(p, UnsignedOfSize(u)) : head(p, split(u));
+}
+
+// recursion base case, selected when "u" is one byte
+template <>
+ALWAYS_INLINE inline char * head, 1>(char * p, UnsignedOfSize<1> u)
+{
+ return u < 10 ? outDigit(p, u) : outTwoDigits(p, u);
+}
+
+//===----------------------------------------------------------===//
+// tail: produce all digits including leading zeros
+//===----------------------------------------------------------===//
+
+// recursive step, "u" is less than 10^2*N
+template
+ALWAYS_INLINE inline char * tail(char * p, UInt u)
+{
+ QuotientAndRemainder x = split(u);
+ p = tail(p, UnsignedOfSize(x.quotient));
+ p = tail(p, x.remainder);
+ return p;
+}
+
+// recursion base case, selected when "u" is one byte
+template <>
+ALWAYS_INLINE inline char * tail, 1>(char * p, UnsignedOfSize<1> u)
+{
+ return outTwoDigits(p, u);
+}
+
+//===----------------------------------------------------------===//
+// large values are >= 10^2*N
+// where x contains quotient and remainder after division by 10^N
+//===----------------------------------------------------------===//
+template
+ALWAYS_INLINE inline char * large(char * p, QuotientAndRemainder x)
+{
+ QuotientAndRemainder y = split(x.quotient);
+ p = head(p, UnsignedOfSize(y.quotient));
+ p = tail(p, y.remainder);
+ p = tail(p, x.remainder);
+ return p;
+}
+
+//===----------------------------------------------------------===//
+// handle values of "u" that might be >= 10^2*N
+// where N is the size of "u" in bytes
+//===----------------------------------------------------------===//
+template
+ALWAYS_INLINE inline char * uitoa(char * p, UInt u)
+{
+ if (u < pow10>(N))
+ return head(p, UnsignedOfSize(u));
+ QuotientAndRemainder x = split(u);
+
+ return u < pow10>(2 * N) ? head(p, x) : large(p, x);
+}
+
+// selected when "u" is one byte
+template <>
+ALWAYS_INLINE inline char * uitoa, 1>(char * p, UnsignedOfSize<1> u)
+{
+ if (u < 10)
+ return outDigit(p, u);
+ else if (u < 100)
+ return outTwoDigits(p, u);
+ else
+ {
+ p = outDigit(p, u / 100);
+ p = outTwoDigits(p, u % 100);
+ return p;
+ }
+}
+
+//===----------------------------------------------------------===//
+// handle unsigned and signed integral operands
+//===----------------------------------------------------------===//
+
+// itoa: handle unsigned integral operands (selected by SFINAE)
+template && std::is_integral_v> * = nullptr>
+ALWAYS_INLINE inline char * itoa(U u, char * p)
+{
+ return convert::uitoa(p, u);
+}
+
+// itoa: handle signed integral operands (selected by SFINAE)
+template && std::is_integral_v> * = nullptr>
+ALWAYS_INLINE inline char * itoa(I i, char * p)
+{
+ // Need "mask" to be filled with a copy of the sign bit.
+ // If "i" is a negative value, then the result of "operator >>"
+ // is implementation-defined, though usually it is an arithmetic
+ // right shift that replicates the sign bit.
+ // Use a conditional expression to be portable,
+ // a good optimizing compiler generates an arithmetic right shift
+ // and avoids the conditional branch.
+ UnsignedOfSize mask = i < 0 ? ~UnsignedOfSize(0) : 0;
+ // Now get the absolute value of "i" and cast to unsigned type UnsignedOfSize.
+ // Cannot use std::abs() because the result is undefined
+ // in 2's complement systems for the most-negative value.
+ // Want to avoid conditional branch for performance reasons since
+ // CPU branch prediction will be ineffective when negative values
+ // occur randomly.
+ // Let "u" be "i" cast to unsigned type UnsignedOfSize.
+ // Subtract "u" from 2*u if "i" is positive or 0 if "i" is negative.
+ // This yields the absolute value with the desired type without
+ // using a conditional branch and without invoking undefined or
+ // implementation defined behavior:
+ UnsignedOfSize u = ((2 * UnsignedOfSize(i)) & ~mask) - UnsignedOfSize(i);
+ // Unconditionally store a minus sign when producing digits
+ // in a forward direction and increment the pointer only if
+ // the value is in fact negative.
+ // This avoids a conditional branch and is safe because we will
+ // always produce at least one digit and it will overwrite the
+ // minus sign when the value is not negative.
+ *p = '-';
+ p += (mask & 1);
+ p = convert::uitoa(p, u);
+ return p;
+}
+}
+
+const uint64_t max_multiple_of_hundred_that_fits_in_64_bits = 1'00'00'00'00'00'00'00'00'00ull;
+const int max_multiple_of_hundred_blocks = 9;
+static_assert(max_multiple_of_hundred_that_fits_in_64_bits % 100 == 0);
+
+ALWAYS_INLINE inline char * writeUIntText(UInt128 _x, char * p)
+{
+ /// If we the highest 64bit item is empty, we can print just the lowest item as u64
+ if (_x.items[UInt128::_impl::little(1)] == 0)
+ return convert::itoa(_x.items[UInt128::_impl::little(0)], p);
+
+ /// Doing operations using __int128 is faster and we already rely on this feature
+ using T = unsigned __int128;
+ T x = (T(_x.items[UInt128::_impl::little(1)]) << 64) + T(_x.items[UInt128::_impl::little(0)]);
+
+ /// We are going to accumulate blocks of 2 digits to print until the number is small enough to be printed as u64
+ /// To do this we could do: x / 100, x % 100
+ /// But these would mean doing many iterations with long integers, so instead we divide by a much longer integer
+ /// multiple of 100 (100^9) and then get the blocks out of it (as u64)
+ /// Once we reach u64::max we can stop and use the fast method to print that in the front
+ static const T large_divisor = max_multiple_of_hundred_that_fits_in_64_bits;
+ static const T largest_uint64 = std::numeric_limits::max();
+ uint8_t two_values[20] = {0}; // 39 Max characters / 2
+
+ int current_block = 0;
+ while (x > largest_uint64)
+ {
+ uint64_t u64_remainder = uint64_t(x % large_divisor);
+ x /= large_divisor;
+
+ int pos = current_block;
+ while (u64_remainder)
+ {
+ two_values[pos] = uint8_t(u64_remainder % 100);
+ pos++;
+ u64_remainder /= 100;
+ }
+ current_block += max_multiple_of_hundred_blocks;
+ }
+
+ char * highest_part_print = convert::itoa(uint64_t(x), p);
+ for (int i = 0; i < current_block; i++)
+ {
+ outTwoDigits(highest_part_print, two_values[current_block - 1 - i]);
+ highest_part_print += 2;
+ }
+
+ return highest_part_print;
+}
+
+ALWAYS_INLINE inline char * writeUIntText(UInt256 _x, char * p)
+{
+ /// If possible, treat it as a smaller integer as they are much faster to print
+ if (_x.items[UInt256::_impl::little(3)] == 0 && _x.items[UInt256::_impl::little(2)] == 0)
+ return writeUIntText(UInt128{_x.items[UInt256::_impl::little(0)], _x.items[UInt256::_impl::little(1)]}, p);
+
+ /// If available (x86) we transform from our custom class to _BitInt(256) which has better support in the compiler
+ /// and produces better code
+ using T =
+#if defined(__x86_64__)
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wbit-int-extension"
+ unsigned _BitInt(256)
+# pragma clang diagnostic pop
+#else
+ UInt256
+#endif
+ ;
+
+#if defined(__x86_64__)
+ T x = (T(_x.items[UInt256::_impl::little(3)]) << 192) + (T(_x.items[UInt256::_impl::little(2)]) << 128)
+ + (T(_x.items[UInt256::_impl::little(1)]) << 64) + T(_x.items[UInt256::_impl::little(0)]);
+#else
+ T x = _x;
+#endif
+
+ /// Similar to writeUIntText(UInt128) only that in this case we will stop as soon as we reach the largest u128
+ /// and switch to that function
+ uint8_t two_values[39] = {0}; // 78 Max characters / 2
+ int current_pos = 0;
+
+ static const T large_divisor = max_multiple_of_hundred_that_fits_in_64_bits;
+ static const T largest_uint128 = T(std::numeric_limits::max()) << 64 | T(std::numeric_limits::max());
+
+ while (x > largest_uint128)
+ {
+ uint64_t u64_remainder = uint64_t(x % large_divisor);
+ x /= large_divisor;
+
+ int pos = current_pos;
+ while (u64_remainder)
+ {
+ two_values[pos] = uint8_t(u64_remainder % 100);
+ pos++;
+ u64_remainder /= 100;
+ }
+ current_pos += max_multiple_of_hundred_blocks;
+ }
+
+#if defined(__x86_64__)
+ UInt128 pending{uint64_t(x), uint64_t(x >> 64)};
+#else
+ UInt128 pending{x.items[UInt256::_impl::little(0)], x.items[UInt256::_impl::little(1)]};
+#endif
+
+ char * highest_part_print = writeUIntText(pending, p);
+ for (int i = 0; i < current_pos; i++)
+ {
+ outTwoDigits(highest_part_print, two_values[current_pos - 1 - i]);
+ highest_part_print += 2;
+ }
+
+ return highest_part_print;
+}
+
+ALWAYS_INLINE inline char * writeLeadingMinus(char * pos)
+{
+ *pos = '-';
+ return pos + 1;
+}
+
+template
+ALWAYS_INLINE inline char * writeSIntText(T x, char * pos)
+{
+ static_assert(std::is_same_v || std::is_same_v);
+
+ using UnsignedT = make_unsigned_t;
+ static constexpr T min_int = UnsignedT(1) << (sizeof(T) * 8 - 1);
+
+ if (unlikely(x == min_int))
+ {
+ if constexpr (std::is_same_v)
+ {
+ const char * res = "-170141183460469231731687303715884105728";
+ memcpy(pos, res, strlen(res));
+ return pos + strlen(res);
+ }
+ else if constexpr (std::is_same_v)
+ {
+ const char * res = "-57896044618658097711785492504343953926634992332820282019728792003956564819968";
+ memcpy(pos, res, strlen(res));
+ return pos + strlen(res);
+ }
+ }
+
+ if (x < 0)
+ {
+ x = -x;
+ pos = writeLeadingMinus(pos);
+ }
+ return writeUIntText(UnsignedT(x), pos);
+}
+}
+
+char * itoa(UInt8 i, char * p)
+{
+ return convert::itoa(uint8_t(i), p);
+}
+
+char * itoa(Int8 i, char * p)
+{
+ return convert::itoa(int8_t(i), p);
+}
+
+char * itoa(UInt128 i, char * p)
+{
+ return writeUIntText(i, p);
+}
+
+char * itoa(Int128 i, char * p)
+{
+ return writeSIntText(i, p);
+}
+
+char * itoa(UInt256 i, char * p)
+{
+ return writeUIntText(i, p);
+}
+
+char * itoa(Int256 i, char * p)
+{
+ return writeSIntText(i, p);
+}
+
+#define DEFAULT_ITOA(T) \
+ char * itoa(T i, char * p) \
+ { \
+ return convert::itoa(i, p); \
+ }
+
+#define FOR_MISSING_INTEGER_TYPES(M) \
+ M(uint8_t) \
+ M(UInt16) \
+ M(UInt32) \
+ M(UInt64) \
+ M(int8_t) \
+ M(Int16) \
+ M(Int32) \
+ M(Int64)
+
+FOR_MISSING_INTEGER_TYPES(DEFAULT_ITOA)
+
+#if defined(OS_DARWIN)
+DEFAULT_ITOA(unsigned long)
+DEFAULT_ITOA(long)
+#endif
+
+#undef FOR_MISSING_INTEGER_TYPES
+#undef DEFAULT_ITOA
diff --git a/base/base/itoa.h b/base/base/itoa.h
index 513070c99d9..3461d679d43 100644
--- a/base/base/itoa.h
+++ b/base/base/itoa.h
@@ -1,446 +1,30 @@
#pragma once
-// Based on https://github.com/amdn/itoa and combined with our optimizations
-//
-//=== itoa.h - Fast integer to ascii conversion --*- C++ -*-//
-//
-// The MIT License (MIT)
-// Copyright (c) 2016 Arturo Martin-de-Nicolas
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-//===----------------------------------------------------------------------===//
-
-#include
-#include
-#include
-#include
#include
+#define FOR_INTEGER_TYPES(M) \
+ M(uint8_t) \
+ M(UInt8) \
+ M(UInt16) \
+ M(UInt32) \
+ M(UInt64) \
+ M(UInt128) \
+ M(UInt256) \
+ M(int8_t) \
+ M(Int8) \
+ M(Int16) \
+ M(Int32) \
+ M(Int64) \
+ M(Int128) \
+ M(Int256)
-template
-inline int digits10(T x)
-{
- if (x < 10ULL)
- return 1;
- if (x < 100ULL)
- return 2;
- if (x < 1000ULL)
- return 3;
+#define INSTANTIATION(T) char * itoa(T i, char * p);
+FOR_INTEGER_TYPES(INSTANTIATION)
- if (x < 1000000000000ULL)
- {
- if (x < 100000000ULL)
- {
- if (x < 1000000ULL)
- {
- if (x < 10000ULL)
- return 4;
- else
- return 5 + (x >= 100000ULL);
- }
+#if defined(OS_DARWIN)
+INSTANTIATION(unsigned long)
+INSTANTIATION(long)
+#endif
- return 7 + (x >= 10000000ULL);
- }
-
- if (x < 10000000000ULL)
- return 9 + (x >= 1000000000ULL);
-
- return 11 + (x >= 100000000000ULL);
- }
-
- return 12 + digits10(x / 1000000000000ULL);
-}
-
-
-namespace impl
-{
-
-template
-static constexpr T pow10(size_t x)
-{
- return x ? 10 * pow10(x - 1) : 1;
-}
-
-// Division by a power of 10 is implemented using a multiplicative inverse.
-// This strength reduction is also done by optimizing compilers, but
-// presently the fastest results are produced by using the values
-// for the multiplication and the shift as given by the algorithm
-// described by Agner Fog in "Optimizing Subroutines in Assembly Language"
-//
-// http://www.agner.org/optimize/optimizing_assembly.pdf
-//
-// "Integer division by a constant (all processors)
-// A floating point number can be divided by a constant by multiplying
-// with the reciprocal. If we want to do the same with integers, we have
-// to scale the reciprocal by 2n and then shift the product to the right
-// by n. There are various algorithms for finding a suitable value of n
-// and compensating for rounding errors. The algorithm described below
-// was invented by Terje Mathisen, Norway, and not published elsewhere."
-
-/// Division by constant is performed by:
-/// 1. Adding 1 if needed;
-/// 2. Multiplying by another constant;
-/// 3. Shifting right by another constant.
-template
-struct Division
-{
- static constexpr bool add{add_};
- static constexpr UInt multiplier{multiplier_};
- static constexpr unsigned shift{shift_};
-};
-
-/// Select a type with appropriate number of bytes from the list of types.
-/// First parameter is the number of bytes requested. Then goes a list of types with 1, 2, 4, ... number of bytes.
-/// Example: SelectType<4, uint8_t, uint16_t, uint32_t, uint64_t> will select uint32_t.
-template
-struct SelectType
-{
- using Result = typename SelectType::Result;
-};
-
-template
-struct SelectType<1, T, Ts...>
-{
- using Result = T;
-};
-
-
-/// Division by 10^N where N is the size of the type.
-template
-using DivisionBy10PowN = typename SelectType
-<
- N,
- Division, /// divide by 10
- Division, /// divide by 100
- Division, /// divide by 10000
- Division /// divide by 100000000
->::Result;
-
-template
-using UnsignedOfSize = typename SelectType
-<
- N,
- uint8_t,
- uint16_t,
- uint32_t,
- uint64_t,
- __uint128_t
->::Result;
-
-/// Holds the result of dividing an unsigned N-byte variable by 10^N resulting in
-template
-struct QuotientAndRemainder
-{
- UnsignedOfSize quotient; // quotient with fewer than 2*N decimal digits
- UnsignedOfSize remainder; // remainder with at most N decimal digits
-};
-
-template
-QuotientAndRemainder static inline split(UnsignedOfSize value)
-{
- constexpr DivisionBy10PowN division;
-
- UnsignedOfSize quotient = (division.multiplier * (UnsignedOfSize<2 * N>(value) + division.add)) >> division.shift;
- UnsignedOfSize remainder = static_cast>(value - quotient * pow10>(N));
-
- return {quotient, remainder};
-}
-
-
-static inline char * outDigit(char * p, uint8_t value)
-{
- *p = '0' + value;
- ++p;
- return p;
-}
-
-// Using a lookup table to convert binary numbers from 0 to 99
-// into ascii characters as described by Andrei Alexandrescu in
-// https://www.facebook.com/notes/facebook-engineering/three-optimization-tips-for-c/10151361643253920/
-
-static const char digits[201] = "00010203040506070809"
- "10111213141516171819"
- "20212223242526272829"
- "30313233343536373839"
- "40414243444546474849"
- "50515253545556575859"
- "60616263646566676869"
- "70717273747576777879"
- "80818283848586878889"
- "90919293949596979899";
-
-static inline char * outTwoDigits(char * p, uint8_t value)
-{
- memcpy(p, &digits[value * 2], 2);
- p += 2;
- return p;
-}
-
-
-namespace convert
-{
- template static char * head(char * p, UInt u);
- template static char * tail(char * p, UInt u);
-
- //===----------------------------------------------------------===//
- // head: find most significant digit, skip leading zeros
- //===----------------------------------------------------------===//
-
- // "x" contains quotient and remainder after division by 10^N
- // quotient is less than 10^N
- template
- static inline char * head(char * p, QuotientAndRemainder x)
- {
- p = head(p, UnsignedOfSize(x.quotient));
- p = tail(p, x.remainder);
- return p;
- }
-
- // "u" is less than 10^2*N
- template
- static inline char * head(char * p, UInt u)
- {
- return u < pow10>(N)
- ? head(p, UnsignedOfSize(u))
- : head(p, split(u));
- }
-
- // recursion base case, selected when "u" is one byte
- template <>
- inline char * head, 1>(char * p, UnsignedOfSize<1> u)
- {
- return u < 10
- ? outDigit(p, u)
- : outTwoDigits(p, u);
- }
-
- //===----------------------------------------------------------===//
- // tail: produce all digits including leading zeros
- //===----------------------------------------------------------===//
-
- // recursive step, "u" is less than 10^2*N
- template
- static inline char * tail(char * p, UInt u)
- {
- QuotientAndRemainder x = split(u);
- p = tail(p, UnsignedOfSize(x.quotient));
- p = tail(p, x.remainder);
- return p;
- }
-
- // recursion base case, selected when "u" is one byte
- template <>
- inline char * tail, 1>(char * p, UnsignedOfSize<1> u)
- {
- return outTwoDigits(p, u);
- }
-
- //===----------------------------------------------------------===//
- // large values are >= 10^2*N
- // where x contains quotient and remainder after division by 10^N
- //===----------------------------------------------------------===//
-
- template
- static inline char * large(char * p, QuotientAndRemainder x)
- {
- QuotientAndRemainder y = split(x.quotient);
- p = head(p, UnsignedOfSize(y.quotient));
- p = tail(p, y.remainder);
- p = tail(p, x.remainder);
- return p;
- }
-
- //===----------------------------------------------------------===//
- // handle values of "u" that might be >= 10^2*N
- // where N is the size of "u" in bytes
- //===----------------------------------------------------------===//
-
- template
- static inline char * uitoa(char * p, UInt u)
- {
- if (u < pow10>(N))
- return head(p, UnsignedOfSize(u));
- QuotientAndRemainder x = split(u);
-
- return u < pow10>(2 * N)
- ? head(p, x)
- : large(p, x);
- }
-
- // selected when "u" is one byte
- template <>
- inline char * uitoa, 1>(char * p, UnsignedOfSize<1> u)
- {
- if (u < 10)
- return outDigit(p, u);
- else if (u < 100)
- return outTwoDigits(p, u);
- else
- {
- p = outDigit(p, u / 100);
- p = outTwoDigits(p, u % 100);
- return p;
- }
- }
-
- //===----------------------------------------------------------===//
- // handle unsigned and signed integral operands
- //===----------------------------------------------------------===//
-
- // itoa: handle unsigned integral operands (selected by SFINAE)
- template && std::is_integral_v> * = nullptr>
- static inline char * itoa(U u, char * p)
- {
- return convert::uitoa(p, u);
- }
-
- // itoa: handle signed integral operands (selected by SFINAE)
- template && std::is_integral_v> * = nullptr>
- static inline char * itoa(I i, char * p)
- {
- // Need "mask" to be filled with a copy of the sign bit.
- // If "i" is a negative value, then the result of "operator >>"
- // is implementation-defined, though usually it is an arithmetic
- // right shift that replicates the sign bit.
- // Use a conditional expression to be portable,
- // a good optimizing compiler generates an arithmetic right shift
- // and avoids the conditional branch.
- UnsignedOfSize mask = i < 0 ? ~UnsignedOfSize(0) : 0;
- // Now get the absolute value of "i" and cast to unsigned type UnsignedOfSize.
- // Cannot use std::abs() because the result is undefined
- // in 2's complement systems for the most-negative value.
- // Want to avoid conditional branch for performance reasons since
- // CPU branch prediction will be ineffective when negative values
- // occur randomly.
- // Let "u" be "i" cast to unsigned type UnsignedOfSize.
- // Subtract "u" from 2*u if "i" is positive or 0 if "i" is negative.
- // This yields the absolute value with the desired type without
- // using a conditional branch and without invoking undefined or
- // implementation defined behavior:
- UnsignedOfSize u = ((2 * UnsignedOfSize(i)) & ~mask) - UnsignedOfSize(i);
- // Unconditionally store a minus sign when producing digits
- // in a forward direction and increment the pointer only if
- // the value is in fact negative.
- // This avoids a conditional branch and is safe because we will
- // always produce at least one digit and it will overwrite the
- // minus sign when the value is not negative.
- *p = '-';
- p += (mask & 1);
- p = convert::uitoa(p, u);
- return p;
- }
-}
-
-
-template
-static inline char * writeUIntText(T x, char * p)
-{
- static_assert(is_unsigned_v);
-
- int len = digits10(x);
- auto * pp = p + len;
- while (x >= 100)
- {
- const auto i = x % 100;
- x /= 100;
- pp -= 2;
- outTwoDigits(pp, i);
- }
- if (x < 10)
- *p = '0' + x;
- else
- outTwoDigits(p, x);
- return p + len;
-}
-
-static inline char * writeLeadingMinus(char * pos)
-{
- *pos = '-';
- return pos + 1;
-}
-
-template
-static inline char * writeSIntText(T x, char * pos)
-{
- static_assert(std::is_same_v || std::is_same_v);
-
- using UnsignedT = make_unsigned_t;
- static constexpr T min_int = UnsignedT(1) << (sizeof(T) * 8 - 1);
-
- if (unlikely(x == min_int))
- {
- if constexpr (std::is_same_v)
- {
- const char * res = "-170141183460469231731687303715884105728";
- memcpy(pos, res, strlen(res));
- return pos + strlen(res);
- }
- else if constexpr (std::is_same_v)
- {
- const char * res = "-57896044618658097711785492504343953926634992332820282019728792003956564819968";
- memcpy(pos, res, strlen(res));
- return pos + strlen(res);
- }
- }
-
- if (x < 0)
- {
- x = -x;
- pos = writeLeadingMinus(pos);
- }
- return writeUIntText(UnsignedT(x), pos);
-}
-
-}
-
-template
-char * itoa(I i, char * p)
-{
- return impl::convert::itoa(i, p);
-}
-
-template <>
-inline char * itoa(char8_t i, char * p)
-{
- return impl::convert::itoa(uint8_t(i), p);
-}
-
-template <>
-inline char * itoa(UInt128 i, char * p)
-{
- return impl::writeUIntText(i, p);
-}
-
-template <>
-inline char * itoa(Int128 i, char * p)
-{
- return impl::writeSIntText(i, p);
-}
-
-template <>
-inline char * itoa(UInt256 i, char * p)
-{
- return impl::writeUIntText(i, p);
-}
-
-template <>
-inline char * itoa(Int256 i, char * p)
-{
- return impl::writeSIntText(i, p);
-}
+#undef FOR_INTEGER_TYPES
+#undef INSTANTIATION
diff --git a/base/poco/Foundation/include/Poco/FPEnvironment_SUN.h b/base/poco/Foundation/include/Poco/FPEnvironment_SUN.h
new file mode 100644
index 00000000000..7b31307e1ca
--- /dev/null
+++ b/base/poco/Foundation/include/Poco/FPEnvironment_SUN.h
@@ -0,0 +1,75 @@
+//
+// FPEnvironment_SUN.h
+//
+// Library: Foundation
+// Package: Core
+// Module: FPEnvironment
+//
+// Definitions of class FPEnvironmentImpl for Solaris.
+//
+// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#ifndef Foundation_FPEnvironment_SUN_INCLUDED
+#define Foundation_FPEnvironment_SUN_INCLUDED
+
+
+#include
+#include "Poco/Foundation.h"
+
+
+namespace Poco
+{
+
+
+class FPEnvironmentImpl
+{
+protected:
+ enum RoundingModeImpl
+ {
+ FP_ROUND_DOWNWARD_IMPL = FP_RM,
+ FP_ROUND_UPWARD_IMPL = FP_RP,
+ FP_ROUND_TONEAREST_IMPL = FP_RN,
+ FP_ROUND_TOWARDZERO_IMPL = FP_RZ
+ };
+ enum FlagImpl
+ {
+ FP_DIVIDE_BY_ZERO_IMPL = FP_X_DZ,
+ FP_INEXACT_IMPL = FP_X_IMP,
+ FP_OVERFLOW_IMPL = FP_X_OFL,
+ FP_UNDERFLOW_IMPL = FP_X_UFL,
+ FP_INVALID_IMPL = FP_X_INV
+ };
+ FPEnvironmentImpl();
+ FPEnvironmentImpl(const FPEnvironmentImpl & env);
+ ~FPEnvironmentImpl();
+ FPEnvironmentImpl & operator=(const FPEnvironmentImpl & env);
+ void keepCurrentImpl();
+ static void clearFlagsImpl();
+ static bool isFlagImpl(FlagImpl flag);
+ static void setRoundingModeImpl(RoundingModeImpl mode);
+ static RoundingModeImpl getRoundingModeImpl();
+ static bool isInfiniteImpl(float value);
+ static bool isInfiniteImpl(double value);
+ static bool isInfiniteImpl(long double value);
+ static bool isNaNImpl(float value);
+ static bool isNaNImpl(double value);
+ static bool isNaNImpl(long double value);
+ static float copySignImpl(float target, float source);
+ static double copySignImpl(double target, double source);
+ static long double copySignImpl(long double target, long double source);
+
+private:
+ fp_rnd _rnd;
+ fp_except _exc;
+};
+
+
+} // namespace Poco
+
+
+#endif // Foundation_FPEnvironment_SUN_INCLUDED
diff --git a/base/poco/Foundation/src/Environment_UNIX.cpp b/base/poco/Foundation/src/Environment_UNIX.cpp
index 202e5d88f83..faabb374778 100644
--- a/base/poco/Foundation/src/Environment_UNIX.cpp
+++ b/base/poco/Foundation/src/Environment_UNIX.cpp
@@ -281,15 +281,15 @@ void EnvironmentImpl::nodeIdImpl(NodeId& id)
/// #include
#if defined(sun) || defined(__sun)
#include
+#include
+#include
+#include
#endif
/// #include
/// #include
/// #include
/// #include
/// #include
-/// #include
-/// #include
-/// #include
/// #include
diff --git a/base/poco/Foundation/src/FPEnvironment_SUN.cpp b/base/poco/Foundation/src/FPEnvironment_SUN.cpp
new file mode 100644
index 00000000000..36ee36431df
--- /dev/null
+++ b/base/poco/Foundation/src/FPEnvironment_SUN.cpp
@@ -0,0 +1,139 @@
+//
+// FPEnvironment_SUN.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: FPEnvironment
+//
+// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include
+#include "Poco/FPEnvironment_SUN.h"
+
+
+namespace Poco {
+
+
+FPEnvironmentImpl::FPEnvironmentImpl()
+{
+ _rnd = fpgetround();
+ _exc = fpgetmask();
+}
+
+
+FPEnvironmentImpl::FPEnvironmentImpl(const FPEnvironmentImpl& env)
+{
+ _rnd = env._rnd;
+ _exc = env._exc;
+}
+
+
+FPEnvironmentImpl::~FPEnvironmentImpl()
+{
+ fpsetround(_rnd);
+ fpsetmask(_exc);
+}
+
+
+FPEnvironmentImpl& FPEnvironmentImpl::operator = (const FPEnvironmentImpl& env)
+{
+ _rnd = env._rnd;
+ _exc = env._exc;
+ return *this;
+}
+
+
+bool FPEnvironmentImpl::isInfiniteImpl(float value)
+{
+ int cls = fpclass(value);
+ return cls == FP_PINF || cls == FP_NINF;
+}
+
+
+bool FPEnvironmentImpl::isInfiniteImpl(double value)
+{
+ int cls = fpclass(value);
+ return cls == FP_PINF || cls == FP_NINF;
+}
+
+
+bool FPEnvironmentImpl::isInfiniteImpl(long double value)
+{
+ int cls = fpclass(value);
+ return cls == FP_PINF || cls == FP_NINF;
+}
+
+
+bool FPEnvironmentImpl::isNaNImpl(float value)
+{
+ return isnanf(value) != 0;
+}
+
+
+bool FPEnvironmentImpl::isNaNImpl(double value)
+{
+ return isnan(value) != 0;
+}
+
+
+bool FPEnvironmentImpl::isNaNImpl(long double value)
+{
+ return isnan((double) value) != 0;
+}
+
+
+float FPEnvironmentImpl::copySignImpl(float target, float source)
+{
+ return (float) copysign(target, source);
+}
+
+
+double FPEnvironmentImpl::copySignImpl(double target, double source)
+{
+ return (float) copysign(target, source);
+}
+
+
+long double FPEnvironmentImpl::copySignImpl(long double target, long double source)
+{
+ return (source > 0 && target > 0) || (source < 0 && target < 0) ? target : -target;
+}
+
+
+void FPEnvironmentImpl::keepCurrentImpl()
+{
+ fpsetround(_rnd);
+ fpsetmask(_exc);
+}
+
+
+void FPEnvironmentImpl::clearFlagsImpl()
+{
+ fpsetsticky(0);
+}
+
+
+bool FPEnvironmentImpl::isFlagImpl(FlagImpl flag)
+{
+ return (fpgetsticky() & flag) != 0;
+}
+
+
+void FPEnvironmentImpl::setRoundingModeImpl(RoundingModeImpl mode)
+{
+ fpsetround((fp_rnd) mode);
+}
+
+
+FPEnvironmentImpl::RoundingModeImpl FPEnvironmentImpl::getRoundingModeImpl()
+{
+ return (FPEnvironmentImpl::RoundingModeImpl) fpgetround();
+}
+
+
+} // namespace Poco
diff --git a/base/poco/Foundation/src/NamedEvent_UNIX.cpp b/base/poco/Foundation/src/NamedEvent_UNIX.cpp
index 978e6e0bc02..3cda4104c73 100644
--- a/base/poco/Foundation/src/NamedEvent_UNIX.cpp
+++ b/base/poco/Foundation/src/NamedEvent_UNIX.cpp
@@ -31,7 +31,7 @@
namespace Poco {
-#if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_ANDROID) || (POCO_OS == POCO_OS_CYGWIN) || (POCO_OS == POCO_OS_FREE_BSD)
+#if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_ANDROID) || (POCO_OS == POCO_OS_CYGWIN) || (POCO_OS == POCO_OS_FREE_BSD) || (POCO_OS == POCO_OS_SOLARIS)
union semun
{
int val;
diff --git a/base/poco/Foundation/src/NamedMutex_UNIX.cpp b/base/poco/Foundation/src/NamedMutex_UNIX.cpp
index 6cfa1369c9d..d53d54d7bb5 100644
--- a/base/poco/Foundation/src/NamedMutex_UNIX.cpp
+++ b/base/poco/Foundation/src/NamedMutex_UNIX.cpp
@@ -31,7 +31,7 @@
namespace Poco {
-#if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_ANDROID) || (POCO_OS == POCO_OS_CYGWIN) || (POCO_OS == POCO_OS_FREE_BSD)
+#if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_ANDROID) || (POCO_OS == POCO_OS_CYGWIN) || (POCO_OS == POCO_OS_FREE_BSD) || (POCO_OS == POCO_OS_SOLARIS)
union semun
{
int val;
diff --git a/base/poco/Net/CMakeLists.txt b/base/poco/Net/CMakeLists.txt
index 792045c9b43..50ffbdf905a 100644
--- a/base/poco/Net/CMakeLists.txt
+++ b/base/poco/Net/CMakeLists.txt
@@ -9,6 +9,10 @@ elseif (OS_DARWIN OR OS_FREEBSD)
target_compile_definitions (_poco_net PUBLIC POCO_HAVE_FD_POLL)
endif ()
+if (OS_SUNOS)
+ target_link_libraries (_poco_net PUBLIC socket nsl)
+endif ()
+
# TODO: remove these warning exclusions
target_compile_options (_poco_net
PRIVATE
diff --git a/contrib/c-ares-cmake/CMakeLists.txt b/contrib/c-ares-cmake/CMakeLists.txt
index 86ab6f90260..daec96ff1b1 100644
--- a/contrib/c-ares-cmake/CMakeLists.txt
+++ b/contrib/c-ares-cmake/CMakeLists.txt
@@ -86,6 +86,8 @@ elseif (OS_DARWIN)
target_compile_definitions(_c-ares PRIVATE -D_DARWIN_C_SOURCE)
elseif (OS_FREEBSD)
target_include_directories(_c-ares SYSTEM PUBLIC "${ClickHouse_SOURCE_DIR}/contrib/c-ares-cmake/freebsd")
+elseif (OS_SUNOS)
+ target_include_directories(_c-ares SYSTEM PUBLIC "${ClickHouse_SOURCE_DIR}/contrib/c-ares-cmake/solaris")
endif()
add_library(ch_contrib::c-ares ALIAS _c-ares)
diff --git a/contrib/c-ares-cmake/solaris/ares_build.h b/contrib/c-ares-cmake/solaris/ares_build.h
new file mode 100644
index 00000000000..f42b59d07bd
--- /dev/null
+++ b/contrib/c-ares-cmake/solaris/ares_build.h
@@ -0,0 +1,104 @@
+/* include/ares_build.h. Generated from ares_build.h.in by configure. */
+#ifndef __CARES_BUILD_H
+#define __CARES_BUILD_H
+
+
+/* Copyright (C) 2009 - 2021 by Daniel Stenberg et al
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of M.I.T. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. M.I.T. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ */
+
+/* ================================================================ */
+/* NOTES FOR CONFIGURE CAPABLE SYSTEMS */
+/* ================================================================ */
+
+/*
+ * NOTE 1:
+ * -------
+ *
+ * Nothing in this file is intended to be modified or adjusted by the
+ * c-ares library user nor by the c-ares library builder.
+ *
+ * If you think that something actually needs to be changed, adjusted
+ * or fixed in this file, then, report it on the c-ares development
+ * mailing list: http://lists.haxx.se/listinfo/c-ares/
+ *
+ * This header file shall only export symbols which are 'cares' or 'CARES'
+ * prefixed, otherwise public name space would be polluted.
+ *
+ * NOTE 2:
+ * -------
+ *
+ * Right now you might be staring at file ares_build.h.in or ares_build.h,
+ * this is due to the following reason:
+ *
+ * On systems capable of running the configure script, the configure process
+ * will overwrite the distributed ares_build.h file with one that is suitable
+ * and specific to the library being configured and built, which is generated
+ * from the ares_build.h.in template file.
+ *
+ */
+
+/* ================================================================ */
+/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */
+/* ================================================================ */
+
+#ifdef CARES_TYPEOF_ARES_SOCKLEN_T
+# error "CARES_TYPEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h"
+ Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_already_defined
+#endif
+
+#define CARES_HAVE_ARPA_NAMESER_H 1
+#define CARES_HAVE_ARPA_NAMESER_COMPAT_H 1
+
+/* ================================================================ */
+/* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */
+/* ================================================================ */
+
+/* Configure process defines this to 1 when it finds out that system */
+/* header file ws2tcpip.h must be included by the external interface. */
+/* #undef CARES_PULL_WS2TCPIP_H */
+#ifdef CARES_PULL_WS2TCPIP_H
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif
+# include
+# include
+# include
+#endif
+
+/* Configure process defines this to 1 when it finds out that system */
+/* header file sys/types.h must be included by the external interface. */
+#define CARES_PULL_SYS_TYPES_H 1
+#ifdef CARES_PULL_SYS_TYPES_H
+# include
+#endif
+
+/* Configure process defines this to 1 when it finds out that system */
+/* header file sys/socket.h must be included by the external interface. */
+#define CARES_PULL_SYS_SOCKET_H 1
+#ifdef CARES_PULL_SYS_SOCKET_H
+# include
+#endif
+
+/* Integral data type used for ares_socklen_t. */
+#define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
+
+/* Data type definition of ares_socklen_t. */
+typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
+
+/* Integral data type used for ares_ssize_t. */
+#define CARES_TYPEOF_ARES_SSIZE_T ssize_t
+
+/* Data type definition of ares_ssize_t. */
+typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t;
+
+#endif /* __CARES_BUILD_H */
diff --git a/contrib/c-ares-cmake/solaris/ares_config.h b/contrib/c-ares-cmake/solaris/ares_config.h
new file mode 100644
index 00000000000..c4ac5e38966
--- /dev/null
+++ b/contrib/c-ares-cmake/solaris/ares_config.h
@@ -0,0 +1,503 @@
+/* src/lib/ares_config.h. Generated from ares_config.h.in by configure. */
+/* src/lib/ares_config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define if building universal (internal helper macro) */
+/* #undef AC_APPLE_UNIVERSAL_BUILD */
+
+/* define this if ares is built for a big endian system */
+/* #undef ARES_BIG_ENDIAN */
+
+/* Defined for build that exposes internal static functions for testing. */
+/* #undef CARES_EXPOSE_STATICS */
+
+/* a suitable file/device to read random data from */
+#define CARES_RANDOM_FILE "/dev/urandom"
+
+/* Defined for build with symbol hiding. */
+#define CARES_SYMBOL_HIDING 1
+
+/* Definition to make a library symbol externally visible. */
+#define CARES_SYMBOL_SCOPE_EXTERN __attribute__ ((__visibility__ ("default")))
+
+/* the signed version of size_t */
+#define CARES_TYPEOF_ARES_SSIZE_T ssize_t
+
+/* Use resolver library to configure cares */
+/* #undef CARES_USE_LIBRESOLV */
+
+/* if a /etc/inet dir is being used */
+#define ETC_INET 1
+
+/* Define to the type of arg 2 for gethostname. */
+#define GETHOSTNAME_TYPE_ARG2 int
+
+/* Define to the type qualifier of arg 1 for getnameinfo. */
+#define GETNAMEINFO_QUAL_ARG1 const
+
+/* Define to the type of arg 1 for getnameinfo. */
+#define GETNAMEINFO_TYPE_ARG1 struct sockaddr *
+
+/* Define to the type of arg 2 for getnameinfo. */
+#define GETNAMEINFO_TYPE_ARG2 socklen_t
+
+/* Define to the type of args 4 and 6 for getnameinfo. */
+#define GETNAMEINFO_TYPE_ARG46 socklen_t
+
+/* Define to the type of arg 7 for getnameinfo. */
+#define GETNAMEINFO_TYPE_ARG7 int
+
+/* Specifies the number of arguments to getservbyport_r */
+#define GETSERVBYPORT_R_ARGS 5
+
+/* Specifies the size of the buffer to pass to getservbyport_r */
+#define GETSERVBYPORT_R_BUFSIZE 4096
+
+/* Define to 1 if you have AF_INET6. */
+#define HAVE_AF_INET6 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_ARPA_INET_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_ARPA_NAMESER_COMPAT_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_ARPA_NAMESER_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_ASSERT_H 1
+
+/* Define to 1 if you have the `bitncmp' function. */
+/* #undef HAVE_BITNCMP */
+
+/* Define to 1 if bool is an available type. */
+#define HAVE_BOOL_T 1
+
+/* Define to 1 if you have the clock_gettime function and monotonic timer. */
+#define HAVE_CLOCK_GETTIME_MONOTONIC 1
+
+/* Define to 1 if you have the closesocket function. */
+/* #undef HAVE_CLOSESOCKET */
+
+/* Define to 1 if you have the CloseSocket camel case function. */
+/* #undef HAVE_CLOSESOCKET_CAMEL */
+
+/* Define to 1 if you have the connect function. */
+#define HAVE_CONNECT 1
+
+/* define if the compiler supports basic C++11 syntax */
+#define HAVE_CXX11 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define to 1 if you have the fcntl function. */
+#define HAVE_FCNTL 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have a working fcntl O_NONBLOCK function. */
+#define HAVE_FCNTL_O_NONBLOCK 1
+
+/* Define to 1 if you have the freeaddrinfo function. */
+#define HAVE_FREEADDRINFO 1
+
+/* Define to 1 if you have a working getaddrinfo function. */
+#define HAVE_GETADDRINFO 1
+
+/* Define to 1 if the getaddrinfo function is threadsafe. */
+#define HAVE_GETADDRINFO_THREADSAFE 1
+
+/* Define to 1 if you have the getenv function. */
+#define HAVE_GETENV 1
+
+/* Define to 1 if you have the gethostbyaddr function. */
+#define HAVE_GETHOSTBYADDR 1
+
+/* Define to 1 if you have the gethostbyname function. */
+#define HAVE_GETHOSTBYNAME 1
+
+/* Define to 1 if you have the gethostname function. */
+#define HAVE_GETHOSTNAME 1
+
+/* Define to 1 if you have the getnameinfo function. */
+#define HAVE_GETNAMEINFO 1
+
+/* Define to 1 if you have the getservbyport_r function. */
+#define HAVE_GETSERVBYPORT_R 1
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#define HAVE_GETTIMEOFDAY 1
+
+/* Define to 1 if you have the `if_indextoname' function. */
+#define HAVE_IF_INDEXTONAME 1
+
+/* Define to 1 if you have a IPv6 capable working inet_net_pton function. */
+/* #undef HAVE_INET_NET_PTON */
+
+/* Define to 1 if you have a IPv6 capable working inet_ntop function. */
+#define HAVE_INET_NTOP 1
+
+/* Define to 1 if you have a IPv6 capable working inet_pton function. */
+#define HAVE_INET_PTON 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the ioctl function. */
+#define HAVE_IOCTL 1
+
+/* Define to 1 if you have the ioctlsocket function. */
+/* #undef HAVE_IOCTLSOCKET */
+
+/* Define to 1 if you have the IoctlSocket camel case function. */
+/* #undef HAVE_IOCTLSOCKET_CAMEL */
+
+/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function.
+ */
+/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */
+
+/* Define to 1 if you have a working ioctlsocket FIONBIO function. */
+/* #undef HAVE_IOCTLSOCKET_FIONBIO */
+
+/* Define to 1 if you have a working ioctl FIONBIO function. */
+/* #undef HAVE_IOCTL_FIONBIO */
+
+/* Define to 1 if you have a working ioctl SIOCGIFADDR function. */
+/* #undef HAVE_IOCTL_SIOCGIFADDR */
+
+/* Define to 1 if you have the `resolve' library (-lresolve). */
+/* #undef HAVE_LIBRESOLVE */
+
+/* Define to 1 if you have the header file. */
+#define HAVE_LIMITS_H 1
+
+/* if your compiler supports LL */
+#define HAVE_LL 1
+
+/* Define to 1 if the compiler supports the 'long long' data type. */
+#define HAVE_LONGLONG 1
+
+/* Define to 1 if you have the malloc.h header file. */
+#define HAVE_MALLOC_H 1
+
+/* Define to 1 if you have the memory.h header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the MSG_NOSIGNAL flag. */
+#define HAVE_MSG_NOSIGNAL 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_NETDB_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_NETINET_IN_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_NETINET_TCP_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_NET_IF_H 1
+
+/* Define to 1 if you have PF_INET6. */
+#define HAVE_PF_INET6 1
+
+/* Define to 1 if you have the recv function. */
+#define HAVE_RECV 1
+
+/* Define to 1 if you have the recvfrom function. */
+#define HAVE_RECVFROM 1
+
+/* Define to 1 if you have the send function. */
+#define HAVE_SEND 1
+
+/* Define to 1 if you have the setsockopt function. */
+#define HAVE_SETSOCKOPT 1
+
+/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */
+/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SIGNAL_H 1
+
+/* Define to 1 if sig_atomic_t is an available typedef. */
+#define HAVE_SIG_ATOMIC_T 1
+
+/* Define to 1 if sig_atomic_t is already defined as volatile. */
+/* #undef HAVE_SIG_ATOMIC_T_VOLATILE */
+
+/* Define to 1 if your struct sockaddr_in6 has sin6_scope_id. */
+#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1
+
+/* Define to 1 if you have the socket function. */
+#define HAVE_SOCKET 1
+
+/* Define to 1 if you have the header file. */
+/* #undef HAVE_SOCKET_H */
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STDBOOL_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STDIO_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the strcasecmp function. */
+#define HAVE_STRCASECMP 1
+
+/* Define to 1 if you have the strcmpi function. */
+/* #undef HAVE_STRCMPI */
+
+/* Define to 1 if you have the strdup function. */
+#define HAVE_STRDUP 1
+
+/* Define to 1 if you have the stricmp function. */
+/* #undef HAVE_STRICMP */
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the strncasecmp function. */
+#define HAVE_STRNCASECMP 1
+
+/* Define to 1 if you have the strncmpi function. */
+/* #undef HAVE_STRNCMPI */
+
+/* Define to 1 if you have the strnicmp function. */
+/* #undef HAVE_STRNICMP */
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STROPTS_H 1
+
+/* Define to 1 if you have struct addrinfo. */
+#define HAVE_STRUCT_ADDRINFO 1
+
+/* Define to 1 if you have struct in6_addr. */
+#define HAVE_STRUCT_IN6_ADDR 1
+
+/* Define to 1 if you have struct sockaddr_in6. */
+#define HAVE_STRUCT_SOCKADDR_IN6 1
+
+/* if struct sockaddr_storage is defined */
+#define HAVE_STRUCT_SOCKADDR_STORAGE 1
+
+/* Define to 1 if you have the timeval struct. */
+#define HAVE_STRUCT_TIMEVAL 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SYS_IOCTL_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SYS_PARAM_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SYS_SELECT_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SYS_SOCKET_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SYS_UIO_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_TIME_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the windows.h header file. */
+/* #undef HAVE_WINDOWS_H */
+
+/* Define to 1 if you have the winsock2.h header file. */
+/* #undef HAVE_WINSOCK2_H */
+
+/* Define to 1 if you have the winsock.h header file. */
+/* #undef HAVE_WINSOCK_H */
+
+/* Define to 1 if you have the writev function. */
+#define HAVE_WRITEV 1
+
+/* Define to 1 if you have the ws2tcpip.h header file. */
+/* #undef HAVE_WS2TCPIP_H */
+
+/* Define if __system_property_get exists. */
+/* #undef HAVE___SYSTEM_PROPERTY_GET */
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#define LT_OBJDIR ".libs/"
+
+/* Define to 1 if you need the malloc.h header file even with stdlib.h */
+/* #undef NEED_MALLOC_H */
+
+/* Define to 1 if you need the memory.h header file even with stdlib.h */
+/* #undef NEED_MEMORY_H */
+
+/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */
+#define NEED_REENTRANT 1
+
+/* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */
+/* #undef NEED_THREAD_SAFE */
+
+/* cpu-machine-OS */
+#define OS "x86_64-pc-solaris2.11"
+
+/* Name of package */
+#define PACKAGE "c-ares"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "c-ares mailing list: http://lists.haxx.se/listinfo/c-ares"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "c-ares"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "c-ares 1.18.1"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "c-ares"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.18.1"
+
+/* Define to the type qualifier pointed by arg 5 for recvfrom. */
+#define RECVFROM_QUAL_ARG5
+
+/* Define to the type of arg 1 for recvfrom. */
+#define RECVFROM_TYPE_ARG1 int
+
+/* Define to the type pointed by arg 2 for recvfrom. */
+#define RECVFROM_TYPE_ARG2 void
+
+/* Define to 1 if the type pointed by arg 2 for recvfrom is void. */
+#define RECVFROM_TYPE_ARG2_IS_VOID 1
+
+/* Define to the type of arg 3 for recvfrom. */
+#define RECVFROM_TYPE_ARG3 size_t
+
+/* Define to the type of arg 4 for recvfrom. */
+#define RECVFROM_TYPE_ARG4 int
+
+/* Define to the type pointed by arg 5 for recvfrom. */
+#define RECVFROM_TYPE_ARG5 struct sockaddr
+
+/* Define to 1 if the type pointed by arg 5 for recvfrom is void. */
+/* #undef RECVFROM_TYPE_ARG5_IS_VOID */
+
+/* Define to the type pointed by arg 6 for recvfrom. */
+#define RECVFROM_TYPE_ARG6 void
+
+/* Define to 1 if the type pointed by arg 6 for recvfrom is void. */
+#define RECVFROM_TYPE_ARG6_IS_VOID 1
+
+/* Define to the function return type for recvfrom. */
+#define RECVFROM_TYPE_RETV ssize_t
+
+/* Define to the type of arg 1 for recv. */
+#define RECV_TYPE_ARG1 int
+
+/* Define to the type of arg 2 for recv. */
+#define RECV_TYPE_ARG2 void *
+
+/* Define to the type of arg 3 for recv. */
+#define RECV_TYPE_ARG3 size_t
+
+/* Define to the type of arg 4 for recv. */
+#define RECV_TYPE_ARG4 int
+
+/* Define to the function return type for recv. */
+#define RECV_TYPE_RETV ssize_t
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#define RETSIGTYPE void
+
+/* Define to the type qualifier of arg 2 for send. */
+#define SEND_QUAL_ARG2 const
+
+/* Define to the type of arg 1 for send. */
+#define SEND_TYPE_ARG1 int
+
+/* Define to the type of arg 2 for send. */
+#define SEND_TYPE_ARG2 void *
+
+/* Define to the type of arg 3 for send. */
+#define SEND_TYPE_ARG3 size_t
+
+/* Define to the type of arg 4 for send. */
+#define SEND_TYPE_ARG4 int
+
+/* Define to the function return type for send. */
+#define SEND_TYPE_RETV ssize_t
+
+/* Define to 1 if all of the C90 standard headers exist (not just the ones
+ required in a freestanding environment). This macro is provided for
+ backward compatibility; new code need not use it. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if you can safely include both and . This
+ macro is obsolete. */
+#define TIME_WITH_SYS_TIME 1
+
+/* Define to disable non-blocking sockets. */
+/* #undef USE_BLOCKING_SOCKETS */
+
+/* Version number of package */
+#define VERSION "1.18.1"
+
+/* Define to avoid automatic inclusion of winsock.h */
+/* #undef WIN32_LEAN_AND_MEAN */
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+ significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+# define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+/* # undef WORDS_BIGENDIAN */
+# endif
+#endif
+
+/* Define to 1 if OS is AIX. */
+#ifndef _ALL_SOURCE
+/* # undef _ALL_SOURCE */
+#endif
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+/* #undef _FILE_OFFSET_BITS */
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Type to use in place of in_addr_t when system does not provide it. */
+/* #undef in_addr_t */
+
+/* Define to `unsigned int' if does not define. */
+/* #undef size_t */
diff --git a/contrib/cppkafka b/contrib/cppkafka
index 5a119f689f8..9c5ea0e3324 160000
--- a/contrib/cppkafka
+++ b/contrib/cppkafka
@@ -1 +1 @@
-Subproject commit 5a119f689f8a4d90d10a9635e7ee2bee5c127de1
+Subproject commit 9c5ea0e332486961e612deacc6e3f0c1874c688d
diff --git a/contrib/curl-cmake/curl_config.h b/contrib/curl-cmake/curl_config.h
index a38aa60fe6d..4d4c2972f57 100644
--- a/contrib/curl-cmake/curl_config.h
+++ b/contrib/curl-cmake/curl_config.h
@@ -51,3 +51,8 @@
#define USE_OPENSSL
#define USE_THREADS_POSIX
#define USE_ARES
+
+#ifdef __illumos__
+#define HAVE_POSIX_STRERROR_R 1
+#define HAVE_STRERROR_R 1
+#endif
diff --git a/docker/packager/binary-builder/Dockerfile b/docker/packager/binary-builder/Dockerfile
index c9442accd7e..73ec4275f12 100644
--- a/docker/packager/binary-builder/Dockerfile
+++ b/docker/packager/binary-builder/Dockerfile
@@ -61,7 +61,7 @@ RUN arch=${TARGETARCH:-amd64} \
&& rm /tmp/nfpm.deb
ARG GO_VERSION=1.19.10
-# We need go for clickhouse-diagnostics
+# We needed go for clickhouse-diagnostics (it is not used anymore)
RUN arch=${TARGETARCH:-amd64} \
&& curl -Lo /tmp/go.tgz "https://go.dev/dl/go${GO_VERSION}.linux-${arch}.tar.gz" \
&& tar -xzf /tmp/go.tgz -C /usr/local/ \
diff --git a/docker/packager/binary-builder/build.sh b/docker/packager/binary-builder/build.sh
index b63643419fe..032aceb0af3 100755
--- a/docker/packager/binary-builder/build.sh
+++ b/docker/packager/binary-builder/build.sh
@@ -36,22 +36,6 @@ rm -f CMakeCache.txt
if [ -n "$MAKE_DEB" ]; then
rm -rf /build/packages/root
- # NOTE: this is for backward compatibility with previous releases,
- # that does not diagnostics tool (only script).
- if [ -d /build/programs/diagnostics ]; then
- if [ -z "$SANITIZER" ]; then
- # We need to check if clickhouse-diagnostics is fine and build it
- (
- cd /build/programs/diagnostics
- make test-no-docker
- GOARCH="${DEB_ARCH}" CGO_ENABLED=0 make VERSION="$VERSION_STRING" build
- mv clickhouse-diagnostics ..
- )
- else
- echo -e "#!/bin/sh\necho 'Not implemented for this type of package'" > /build/programs/clickhouse-diagnostics
- chmod +x /build/programs/clickhouse-diagnostics
- fi
- fi
fi
@@ -121,8 +105,6 @@ if [ -n "$MAKE_DEB" ]; then
# No quotes because I want it to expand to nothing if empty.
# shellcheck disable=SC2086
DESTDIR=/build/packages/root ninja $NINJA_FLAGS programs/install
- cp /build/programs/clickhouse-diagnostics /build/packages/root/usr/bin
- cp /build/programs/clickhouse-diagnostics /output
bash -x /build/packages/build
fi
diff --git a/docker/test/fuzzer/run-fuzzer.sh b/docker/test/fuzzer/run-fuzzer.sh
index c9e1681401d..76661a5b51c 100755
--- a/docker/test/fuzzer/run-fuzzer.sh
+++ b/docker/test/fuzzer/run-fuzzer.sh
@@ -173,16 +173,23 @@ function fuzz
mkdir -p /var/run/clickhouse-server
- # NOTE: we use process substitution here to preserve keep $! as a pid of clickhouse-server
- # server.log -> CH logs
- # stderr.log -> Process logs (sanitizer)
+ # server.log -> All server logs, including sanitizer
+ # stderr.log -> Process logs (sanitizer) only
clickhouse-server \
--config-file db/config.xml \
--pid-file /var/run/clickhouse-server/clickhouse-server.pid \
-- --path db \
--logger.console=0 \
- --logger.log=server.log > stderr.log 2>&1 &
- server_pid=$!
+ --logger.log=server.log 2>&1 | tee -a stderr.log >> server.log 2>&1 &
+ for _ in {1..30}
+ do
+ if clickhouse-client --query "select 1"
+ then
+ break
+ fi
+ sleep 1
+ done
+ server_pid=$(cat /var/run/clickhouse-server/clickhouse-server.pid)
kill -0 $server_pid
@@ -310,7 +317,7 @@ quit
if [ "$server_died" == 1 ]
then
# The server has died.
- if ! rg --text -o 'Received signal.*|Logical error.*|Assertion.*failed|Failed assertion.*|.*runtime error: .*|.*is located.*|(SUMMARY|ERROR): [a-zA-Z]+Sanitizer:.*|.*_LIBCPP_ASSERT.*|.*Child process was terminated by signal 9.*' server.log stderr.log > description.txt
+ if ! rg --text -o 'Received signal.*|Logical error.*|Assertion.*failed|Failed assertion.*|.*runtime error: .*|.*is located.*|(SUMMARY|ERROR): [a-zA-Z]+Sanitizer:.*|.*_LIBCPP_ASSERT.*|.*Child process was terminated by signal 9.*' server.log > description.txt
then
echo "Lost connection to server. See the logs." > description.txt
fi
diff --git a/docker/test/integration/runner/Dockerfile b/docker/test/integration/runner/Dockerfile
index b876f7b9635..8297a7100d1 100644
--- a/docker/test/integration/runner/Dockerfile
+++ b/docker/test/integration/runner/Dockerfile
@@ -126,7 +126,6 @@ RUN set -x \
COPY modprobe.sh /usr/local/bin/modprobe
COPY dockerd-entrypoint.sh /usr/local/bin/
-COPY compose/ /compose/
COPY misc/ /misc/
diff --git a/docker/test/style/Dockerfile b/docker/test/style/Dockerfile
index b4ffcfb597c..5d53d03606f 100644
--- a/docker/test/style/Dockerfile
+++ b/docker/test/style/Dockerfile
@@ -8,20 +8,22 @@ ARG apt_archive="http://archive.ubuntu.com"
RUN sed -i "s|http://archive.ubuntu.com|$apt_archive|g" /etc/apt/sources.list
RUN apt-get update && env DEBIAN_FRONTEND=noninteractive apt-get install --yes \
- aspell \
- curl \
- git \
- file \
- libxml2-utils \
- moreutils \
- python3-fuzzywuzzy \
- python3-pip \
- yamllint \
- locales \
- && pip3 install black==23.12.0 boto3 codespell==2.2.1 mypy==1.8.0 PyGithub unidiff pylint==3.1.0 \
- requests types-requests \
+ aspell \
+ curl \
+ git \
+ file \
+ libxml2-utils \
+ moreutils \
+ python3-fuzzywuzzy \
+ python3-pip \
+ yamllint \
+ locales \
&& apt-get clean \
- && rm -rf /var/lib/apt/lists/* /var/cache/debconf /tmp/* \
+ && rm -rf /var/lib/apt/lists/* /var/cache/debconf /tmp/*
+
+# python-magic is the same version as in Ubuntu 22.04
+RUN pip3 install black==23.12.0 boto3 codespell==2.2.1 mypy==1.8.0 PyGithub unidiff pylint==3.1.0 \
+ python-magic==0.4.24 requests types-requests \
&& rm -rf /root/.cache/pip
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen en_US.UTF-8
diff --git a/docs/en/engines/database-engines/mysql.md b/docs/en/engines/database-engines/mysql.md
index 20434ad124e..ac0ea5e5af1 100644
--- a/docs/en/engines/database-engines/mysql.md
+++ b/docs/en/engines/database-engines/mysql.md
@@ -4,7 +4,11 @@ sidebar_position: 50
sidebar_label: MySQL
---
-# MySQL
+import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge';
+
+# MySQL Database Engine
+
+
Allows to connect to databases on a remote MySQL server and perform `INSERT` and `SELECT` queries to exchange data between ClickHouse and MySQL.
diff --git a/docs/en/engines/table-engines/integrations/mysql.md b/docs/en/engines/table-engines/integrations/mysql.md
index 87d59a9394b..e9d0a43242b 100644
--- a/docs/en/engines/table-engines/integrations/mysql.md
+++ b/docs/en/engines/table-engines/integrations/mysql.md
@@ -4,7 +4,11 @@ sidebar_position: 138
sidebar_label: MySQL
---
-# MySQL
+import CloudAvailableBadge from '@theme/badges/CloudAvailableBadge';
+
+# MySQL Table Engine
+
+
The MySQL engine allows you to perform `SELECT` and `INSERT` queries on data that is stored on a remote MySQL server.
diff --git a/docs/en/engines/table-engines/integrations/postgresql.md b/docs/en/engines/table-engines/integrations/postgresql.md
index 131df1a435b..9cc4b11243e 100644
--- a/docs/en/engines/table-engines/integrations/postgresql.md
+++ b/docs/en/engines/table-engines/integrations/postgresql.md
@@ -8,6 +8,10 @@ sidebar_label: PostgreSQL
The PostgreSQL engine allows to perform `SELECT` and `INSERT` queries on data that is stored on a remote PostgreSQL server.
+:::note
+Currently, only PostgreSQL versions 12 and up are supported.
+:::
+
## Creating a Table {#creating-a-table}
``` sql
diff --git a/docs/en/getting-started/example-datasets/cell-towers.md b/docs/en/getting-started/example-datasets/cell-towers.md
index 090de1b32fd..94fa6998f5d 100644
--- a/docs/en/getting-started/example-datasets/cell-towers.md
+++ b/docs/en/getting-started/example-datasets/cell-towers.md
@@ -75,14 +75,14 @@ This is the output of `DESCRIBE`. Down further in this guide the field type cho
-1. Download the snapshot of the dataset from February 2021: [cell_towers.csv.xz](https://datasets.clickhouse.com/cell_towers.csv.xz) (729 MB).
+1. Download the snapshot of the dataset from February 2021: [cell_towers.csv.xz](https://datasets.clickhouse.com/cell_towers.csv.xz) (686 MB).
2. Validate the integrity (optional step):
```bash
md5sum cell_towers.csv.xz
```
```response
-8cf986f4a0d9f12c6f384a0e9192c908 cell_towers.csv.xz
+8a797f7bdb55faba93f6cbc37d47b037 cell_towers.csv.xz
```
3. Decompress it with the following command:
@@ -132,7 +132,7 @@ SELECT radio, count() AS c FROM cell_towers GROUP BY radio ORDER BY c DESC
┌─radio─┬────────c─┐
│ UMTS │ 20686487 │
│ LTE │ 12101148 │
-│ GSM │ 9931312 │
+│ GSM │ 9931304 │
│ CDMA │ 556344 │
│ NR │ 867 │
└───────┴──────────┘
diff --git a/docs/en/getting-started/install.md b/docs/en/getting-started/install.md
index ca689ef7995..e3be30bde8c 100644
--- a/docs/en/getting-started/install.md
+++ b/docs/en/getting-started/install.md
@@ -262,7 +262,7 @@ The required version can be downloaded with `curl` or `wget` from repository htt
After that downloaded archives should be unpacked and installed with installation scripts. Example for the latest stable version:
``` bash
-LATEST_VERSION=$(curl -s https://packages.clickhouse.com/tgz/stable/ | \
+LATEST_VERSION=$(curl -s https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/utils/list-versions/version_date.tsv | \
grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | sort -V -r | head -n 1)
export LATEST_VERSION
diff --git a/docs/en/operations/server-configuration-parameters/settings.md b/docs/en/operations/server-configuration-parameters/settings.md
index f20dcb9025e..63fbd9d1964 100644
--- a/docs/en/operations/server-configuration-parameters/settings.md
+++ b/docs/en/operations/server-configuration-parameters/settings.md
@@ -379,6 +379,18 @@ Type: UInt64
Default: 0
+## max_waiting_queries
+
+Limit on total number of concurrently waiting queries. Execution of a waiting query is blocked while required tables are loading asynchronously (see `async_load_databases`). Note that waiting queries are not counted when `max_concurrent_queries`, `max_concurrent_insert_queries`, `max_concurrent_select_queries`, `max_concurrent_queries_for_user` and `max_concurrent_queries_for_all_users` limits are checked. This correction is done to avoid hitting these limits just after server startup. Zero means unlimited.
+
+:::note
+This setting can be modified at runtime and will take effect immediately. Queries that are already running will remain unchanged.
+:::
+
+Type: UInt64
+
+Default: 0
+
## max_connections
Max server connections.
@@ -933,9 +945,9 @@ Hard limit is configured via system tools
## database_atomic_delay_before_drop_table_sec {#database_atomic_delay_before_drop_table_sec}
-The delay before a table data is dropped in seconds. If the `DROP TABLE` query has a `SYNC` modifier, this setting is ignored.
+Sets the delay before remove table data in seconds. If the query has `SYNC` modifier, this setting is ignored.
-Default value: `480` (8 minutes).
+Default value: `480` (8 minute).
## database_catalog_unused_dir_hide_timeout_sec {#database_catalog_unused_dir_hide_timeout_sec}
@@ -1725,7 +1737,7 @@ Default value: `0.5`.
Asynchronous loading of databases and tables.
-If `true` all non-system databases with `Ordinary`, `Atomic` and `Replicated` engine will be loaded asynchronously after the ClickHouse server start up. See `system.asynchronous_loader` table, `tables_loader_background_pool_size` and `tables_loader_foreground_pool_size` server settings. Any query that tries to access a table, that is not yet loaded, will wait for exactly this table to be started up. If load job fails, query will rethrow an error (instead of shutting down the whole server in case of `async_load_databases = false`). The table that is waited for by at least one query will be loaded with higher priority. DDL queries on a database will wait for exactly that database to be started up.
+If `true` all non-system databases with `Ordinary`, `Atomic` and `Replicated` engine will be loaded asynchronously after the ClickHouse server start up. See `system.asynchronous_loader` table, `tables_loader_background_pool_size` and `tables_loader_foreground_pool_size` server settings. Any query that tries to access a table, that is not yet loaded, will wait for exactly this table to be started up. If load job fails, query will rethrow an error (instead of shutting down the whole server in case of `async_load_databases = false`). The table that is waited for by at least one query will be loaded with higher priority. DDL queries on a database will wait for exactly that database to be started up. Also consider setting a limit `max_waiting_queries` for the total number of waiting queries.
If `false`, all databases are loaded when the server starts.
@@ -2926,7 +2938,7 @@ Default: 0
## ignore_empty_sql_security_in_create_view_query {#ignore_empty_sql_security_in_create_view_query}
-If true, ClickHouse doesn't write defaults for empty SQL security statement in CREATE VIEW queries.
+If true, ClickHouse doesn't write defaults for empty SQL security statement in CREATE VIEW queries.
:::note
This setting is only necessary for the migration period and will become obsolete in 24.4
diff --git a/docs/en/sql-reference/functions/other-functions.md b/docs/en/sql-reference/functions/other-functions.md
index e7fca31483a..0ca404274ec 100644
--- a/docs/en/sql-reference/functions/other-functions.md
+++ b/docs/en/sql-reference/functions/other-functions.md
@@ -405,7 +405,7 @@ Returns the name of the current user. In case of a distributed query, the name o
SELECT currentUser();
```
-Alias: `user()`, `USER()`.
+Aliases: `user()`, `USER()`, `current_user()`. Aliases are case insensitive.
**Returned values**
diff --git a/docs/en/sql-reference/statements/kill.md b/docs/en/sql-reference/statements/kill.md
index 294724dfa50..b665ad85a09 100644
--- a/docs/en/sql-reference/statements/kill.md
+++ b/docs/en/sql-reference/statements/kill.md
@@ -21,6 +21,35 @@ The queries to terminate are selected from the system.processes table using the
Examples:
+First, you'll need to get the list of incomplete queries. This SQL query provides them according to those running the longest:
+
+List from a single ClickHouse node:
+``` sql
+SELECT
+ initial_query_id,
+ query_id,
+ formatReadableTimeDelta(elapsed) AS time_delta,
+ query,
+ *
+ FROM system.processes
+ WHERE query ILIKE 'SELECT%'
+ ORDER BY time_delta DESC;
+```
+
+List from a ClickHouse cluster:
+``` sql
+SELECT
+ initial_query_id,
+ query_id,
+ formatReadableTimeDelta(elapsed) AS time_delta,
+ query,
+ *
+ FROM clusterAllReplicas(default, system.processes)
+ WHERE query ILIKE 'SELECT%'
+ ORDER BY time_delta DESC;
+```
+
+Kill the query:
``` sql
-- Forcibly terminates all queries with the specified query_id:
KILL QUERY WHERE query_id='2-857d-4a57-9ee0-327da5d60a90'
@@ -44,6 +73,11 @@ A test query (`TEST`) only checks the user’s rights and displays a list of que
## KILL MUTATION
+The presence of long-running or incomplete mutations often indicates that a ClickHouse service is running poorly. The asynchronous nature of mutations can cause them to consume all available resources on a system. You may need to either:
+
+- Pause all new mutations, `INSERT`s , and `SELECT`s and allow the queue of mutations to complete.
+- Or manually kill some of these mutations by sending a `KILL` command.
+
``` sql
KILL MUTATION [ON CLUSTER cluster]
WHERE
@@ -57,6 +91,39 @@ A test query (`TEST`) only checks the user’s rights and displays a list of mut
Examples:
+Get a `count()` of the number of incomplete mutations:
+
+Count of mutations from a single ClickHouse node:
+``` sql
+SELECT count(*)
+FROM system.mutations
+WHERE is_done = 0;
+```
+
+Count of mutations from a ClickHouse cluster of replicas:
+``` sql
+SELECT count(*)
+FROM clusterAllReplicas('default', system.mutations)
+WHERE is_done = 0;
+```
+
+Query the list of incomplete mutations:
+
+List of mutations from a single ClickHouse node:
+``` sql
+SELECT mutation_id, *
+FROM system.mutations
+WHERE is_done = 0;
+```
+
+List of mutations from a ClickHouse cluster:
+``` sql
+SELECT mutation_id, *
+FROM clusterAllReplicas('default', system.mutations)
+WHERE is_done = 0;
+```
+
+Kill the mutations as needed:
``` sql
-- Cancel and remove all mutations of the single table:
KILL MUTATION WHERE database = 'default' AND table = 'table'
diff --git a/docs/en/sql-reference/statements/undrop.md b/docs/en/sql-reference/statements/undrop.md
index 4b138bfe679..40ac1ab4f99 100644
--- a/docs/en/sql-reference/statements/undrop.md
+++ b/docs/en/sql-reference/statements/undrop.md
@@ -13,6 +13,13 @@ a system table called `system.dropped_tables`.
If you have a materialized view without a `TO` clause associated with the dropped table, then you will also have to UNDROP the inner table of that view.
+:::note
+UNDROP TABLE is experimental. To use it add this setting:
+```sql
+set allow_experimental_undrop_table_query = 1;
+```
+:::
+
:::tip
Also see [DROP TABLE](/docs/en/sql-reference/statements/drop.md)
:::
@@ -25,53 +32,60 @@ UNDROP TABLE [db.]name [UUID ''] [ON CLUSTER cluster]
**Example**
+``` sql
+set allow_experimental_undrop_table_query = 1;
+```
+
```sql
-CREATE TABLE tab
+CREATE TABLE undropMe
(
`id` UInt8
)
ENGINE = MergeTree
-ORDER BY id;
-
-DROP TABLE tab;
-
-SELECT *
-FROM system.dropped_tables
-FORMAT Vertical;
+ORDER BY id
```
+```sql
+DROP TABLE undropMe
+```
+```sql
+SELECT *
+FROM system.dropped_tables
+FORMAT Vertical
+```
```response
Row 1:
──────
index: 0
database: default
-table: tab
+table: undropMe
uuid: aa696a1a-1d70-4e60-a841-4c80827706cc
engine: MergeTree
-metadata_dropped_path: /var/lib/clickhouse/metadata_dropped/default.tab.aa696a1a-1d70-4e60-a841-4c80827706cc.sql
+metadata_dropped_path: /var/lib/clickhouse/metadata_dropped/default.undropMe.aa696a1a-1d70-4e60-a841-4c80827706cc.sql
table_dropped_time: 2023-04-05 14:12:12
1 row in set. Elapsed: 0.001 sec.
```
-
```sql
-UNDROP TABLE tab;
-
+UNDROP TABLE undropMe
+```
+```response
+Ok.
+```
+```sql
SELECT *
FROM system.dropped_tables
-FORMAT Vertical;
-
+FORMAT Vertical
+```
```response
Ok.
0 rows in set. Elapsed: 0.001 sec.
```
-
```sql
-DESCRIBE TABLE tab
-FORMAT Vertical;
+DESCRIBE TABLE undropMe
+FORMAT Vertical
```
-
```response
Row 1:
──────
diff --git a/docs/en/sql-reference/table-functions/generateSeries.md b/docs/en/sql-reference/table-functions/generateSeries.md
new file mode 100644
index 00000000000..addf539a959
--- /dev/null
+++ b/docs/en/sql-reference/table-functions/generateSeries.md
@@ -0,0 +1,8 @@
+---
+slug: /en/sql-reference/table-functions/generateSeries
+sidebar_position: 147
+sidebar_label: generateSeries
+---
+
+### Alias To
+[generate_series](generate_series.md)
\ No newline at end of file
diff --git a/docs/en/sql-reference/table-functions/generate_series.md b/docs/en/sql-reference/table-functions/generate_series.md
new file mode 100644
index 00000000000..c5d29369627
--- /dev/null
+++ b/docs/en/sql-reference/table-functions/generate_series.md
@@ -0,0 +1,25 @@
+---
+slug: /en/sql-reference/table-functions/generate_series
+sidebar_position: 146
+sidebar_label: generate_series
+---
+
+# generate_series
+
+`generate_series(START, STOP)` - Returns a table with the single ‘generate_series’ column (UInt64) that contains integers from start to stop inclusively.
+
+`generate_series(START, STOP, STEP)` - Returns a table with the single ‘generate_series’ column (UInt64) that contains integers from start to stop inclusively with spacing between values given by STEP.
+
+The following queries return tables with the same content but different column names:
+
+``` sql
+SELECT * FROM numbers(10, 5);
+SELECT * FROM generate_series(10, 14);
+```
+
+And the following queries return tables with the same content but different column names (but the second option is more efficient):
+
+``` sql
+SELECT * FROM numbers(10, 11) WHERE number % 3 == (10 % 3);
+SELECT * FROM generate_series(10, 20, 3) ;
+```
\ No newline at end of file
diff --git a/docs/en/sql-reference/table-functions/numbers.md b/docs/en/sql-reference/table-functions/numbers.md
index 7d3437b7d53..e0ff19b9824 100644
--- a/docs/en/sql-reference/table-functions/numbers.md
+++ b/docs/en/sql-reference/table-functions/numbers.md
@@ -8,6 +8,7 @@ sidebar_label: numbers
`numbers(N)` – Returns a table with the single ‘number’ column (UInt64) that contains integers from 0 to N-1.
`numbers(N, M)` - Returns a table with the single ‘number’ column (UInt64) that contains integers from N to (N + M - 1).
+`numbers(N, M, S)` - Returns a table with the single ‘number’ column (UInt64) that contains integers from N to (N + M - 1) with step S.
Similar to the `system.numbers` table, it can be used for testing and generating successive values, `numbers(N, M)` more efficient than `system.numbers`.
@@ -21,6 +22,15 @@ SELECT * FROM system.numbers WHERE number BETWEEN 0 AND 9;
SELECT * FROM system.numbers WHERE number IN (0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
```
+And the following queries are equivalent:
+
+``` sql
+SELECT number * 2 FROM numbers(10);
+SELECT (number - 10) * 2 FROM numbers(10, 10);
+SELECT * FROM numbers(0, 20, 2);
+```
+
+
Examples:
``` sql
diff --git a/docs/ru/index.md b/docs/ru/index.md
index 78bb382753b..29f2bbe07fb 100644
--- a/docs/ru/index.md
+++ b/docs/ru/index.md
@@ -35,13 +35,13 @@ ClickHouse — столбцовая система управления база
В примерах изображён только порядок расположения данных.
То есть значения из разных столбцов хранятся отдельно, а данные одного столбца — вместе.
-Примеры столбцовых СУБД: Vertica, Paraccel (Actian Matrix, Amazon Redshift), Sybase IQ, Exasol, Infobright, InfiniDB, MonetDB (VectorWise, Actian Vector), LucidDB, SAP HANA, Google Dremel, Google PowerDrill, Druid, kdb+.
+Примеры столбцовых СУБД: Vertica, Paraccel (Actian Matrix, Amazon Redshift), Sybase IQ, Exasol, Infobright, InfiniDB, MonetDB (VectorWise, Actian Vector), LucidDB, SAP HANA и прочий треш, Google Dremel, Google PowerDrill, Druid, kdb+.
{: .grey }
Разный порядок хранения данных лучше подходит для разных сценариев работы.
Сценарий работы с данными — это то, какие производятся запросы, как часто и в каком соотношении; сколько читается данных на запросы каждого вида — строк, столбцов, байтов; как соотносятся чтения и обновления данных; какой рабочий размер данных и насколько локально он используется; используются ли транзакции и с какой изолированностью; какие требования к дублированию данных и логической целостности; требования к задержкам на выполнение и пропускной способности запросов каждого вида и т. п.
-Чем больше нагрузка на систему, тем более важной становится специализация под сценарий работы, и тем более конкретной становится эта специализация. Не существует системы, одинаково хорошо подходящей под существенно различные сценарии работы. Если система подходит под широкое множество сценариев работы, то при достаточно большой нагрузке, система будет справляться со всеми сценариями работы плохо, или справляться хорошо только с одним из сценариев работы.
+Чем больше нагрузка на систему, тем более важной становится специализация под сценарий работы, и тем более конкретной становится эта специализация. Не существует системы, одинаково хорошо подходящей под существенно различные сценарии работы. Если система подходит под широкое множество сценариев работы, то при достаточно большой нагрузке система будет справляться со всеми сценариями работы плохо, или справляться хорошо только с одним из сценариев работы.
## Ключевые особенности OLAP-сценария работы {#kliuchevye-osobennosti-olap-stsenariia-raboty}
@@ -53,11 +53,11 @@ ClickHouse — столбцовая система управления база
- запросы идут сравнительно редко (обычно не более сотни в секунду на сервер);
- при выполнении простых запросов, допустимы задержки в районе 50 мс;
- значения в столбцах достаточно мелкие — числа и небольшие строки (например, 60 байт на URL);
-- требуется высокая пропускная способность при обработке одного запроса (до миллиардов строк в секунду на один узел);
+- требуется высокая пропускная способность при обработке одного запроса (до миллиардов строк в секунду на один сервер);
- транзакции отсутствуют;
-- низкие требования к консистентности данных;
-- в запросе одна большая таблица, все таблицы кроме одной маленькие;
-- результат выполнения запроса существенно меньше исходных данных — то есть данные фильтруются или агрегируются; результат выполнения помещается в оперативную память одного узла.
+- низкие требования к согласованности данных;
+- в запросе одна большая таблица, все остальные таблицы из запроса — маленькие;
+- результат выполнения запроса существенно меньше исходных данных — то есть данные фильтруются или агрегируются; результат выполнения помещается в оперативную память одного сервера.
Легко видеть, что OLAP-сценарий работы существенно отличается от других распространённых сценариев работы (например, OLTP или Key-Value сценариев работы). Таким образом, не имеет никакого смысла пытаться использовать OLTP-системы или системы класса «ключ — значение» для обработки аналитических запросов, если вы хотите получить приличную производительность («выше плинтуса»). Например, если вы попытаетесь использовать для аналитики MongoDB или Redis — вы получите анекдотически низкую производительность по сравнению с OLAP-СУБД.
@@ -77,11 +77,11 @@ ClickHouse — столбцовая система управления база
### По вводу-выводу {#po-vvodu-vyvodu}
-1. Для выполнения аналитического запроса, требуется прочитать небольшое количество столбцов таблицы. В столбцовой БД для этого можно читать только нужные данные. Например, если вам требуется только 5 столбцов из 100, то следует рассчитывать на 20-кратное уменьшение ввода-вывода.
-2. Так как данные читаются пачками, то их проще сжимать. Данные, лежащие по столбцам также лучше сжимаются. За счёт этого, дополнительно уменьшается объём ввода-вывода.
-3. За счёт уменьшения ввода-вывода, больше данных влезает в системный кэш.
+1. Для выполнения аналитического запроса требуется прочитать небольшое количество столбцов таблицы. В столбцовой БД для этого можно читать только нужные данные. Например, если вам требуется только 5 столбцов из 100, то следует рассчитывать на 20-кратное уменьшение ввода-вывода.
+2. Так как данные читаются пачками, то их проще сжимать. Данные, лежащие по столбцам, также лучше сжимаются. За счёт этого, дополнительно уменьшается объём ввода-вывода.
+3. За счёт уменьшения ввода-вывода больше данных влезает в системный кэш.
-Например, для запроса «посчитать количество записей для каждой рекламной системы», требуется прочитать один столбец «идентификатор рекламной системы», который занимает 1 байт в несжатом виде. Если большинство переходов было не с рекламных систем, то можно рассчитывать хотя бы на десятикратное сжатие этого столбца. При использовании быстрого алгоритма сжатия, возможно разжатие данных со скоростью более нескольких гигабайт несжатых данных в секунду. То есть, такой запрос может выполняться со скоростью около нескольких миллиардов строк в секунду на одном сервере. На практике, такая скорость действительно достигается.
+Например, для запроса «посчитать количество записей для каждой рекламной системы» требуется прочитать один столбец «идентификатор рекламной системы», который занимает 1 байт в несжатом виде. Если большинство переходов было не с рекламных систем, то можно рассчитывать хотя бы на десятикратное сжатие этого столбца. При использовании быстрого алгоритма сжатия возможно разжатие данных со скоростью более нескольких гигабайт несжатых данных в секунду. То есть такой запрос может выполняться со скоростью около нескольких миллиардов строк в секунду на одном сервере. На практике такая скорость действительно достигается.
### По вычислениям {#po-vychisleniiam}
@@ -96,4 +96,4 @@ ClickHouse — столбцовая система управления база
В «обычных» СУБД этого не делается, так как не имеет смысла при выполнении простых запросов. Хотя есть исключения. Например, в MemSQL кодогенерация используется для уменьшения времени отклика при выполнении SQL-запросов. Для сравнения: в аналитических СУБД требуется оптимизация по пропускной способности (throughput, ГБ/с), а не времени отклика (latency, с).
-Стоит заметить, что для эффективности по CPU требуется, чтобы язык запросов был декларативным (SQL, MDX) или хотя бы векторным (J, K). То есть необходимо, чтобы запрос содержал циклы только в неявном виде, открывая возможности для оптимизации.
+Стоит заметить, что для эффективности по CPU требуется, чтобы язык запросов был декларативным (SQL, MDX) или хотя бы векторным (J, K, APL). То есть необходимо, чтобы запрос содержал циклы только в неявном виде, открывая возможности для оптимизации.
diff --git a/packages/clickhouse-common-static.yaml b/packages/clickhouse-common-static.yaml
index 238126f95fd..383ad39591c 100644
--- a/packages/clickhouse-common-static.yaml
+++ b/packages/clickhouse-common-static.yaml
@@ -34,8 +34,6 @@ suggests:
contents:
- src: root/usr/bin/clickhouse
dst: /usr/bin/clickhouse
-- src: root/usr/bin/clickhouse-diagnostics
- dst: /usr/bin/clickhouse-diagnostics
- src: root/usr/bin/clickhouse-extract-from-config
dst: /usr/bin/clickhouse-extract-from-config
- src: root/usr/bin/clickhouse-library-bridge
diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt
index d945fdf4a6f..0d91de2dad8 100644
--- a/programs/CMakeLists.txt
+++ b/programs/CMakeLists.txt
@@ -268,10 +268,6 @@ if (ENABLE_TESTS)
add_dependencies(clickhouse-bundle clickhouse-tests)
endif()
-if (ENABLE_FUZZING)
- add_compile_definitions(FUZZING_MODE=1)
-endif ()
-
if (TARGET ch_contrib::protobuf)
get_property(google_proto_files TARGET ch_contrib::protobuf PROPERTY google_proto_files)
foreach (proto_file IN LISTS google_proto_files)
diff --git a/programs/benchmark/Benchmark.cpp b/programs/benchmark/Benchmark.cpp
index 45dadfef774..eecc352d073 100644
--- a/programs/benchmark/Benchmark.cpp
+++ b/programs/benchmark/Benchmark.cpp
@@ -34,6 +34,7 @@
#include
#include
#include
+#include
/** A tool for evaluating ClickHouse performance.
@@ -623,7 +624,7 @@ int mainEntryClickHouseBenchmark(int argc, char ** argv)
;
Settings settings;
- settings.addProgramOptions(desc);
+ addProgramOptions(settings, desc);
boost::program_options::variables_map options;
boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), options);
diff --git a/programs/client/Client.cpp b/programs/client/Client.cpp
index 4203e4738dd..d4bf2f686c8 100644
--- a/programs/client/Client.cpp
+++ b/programs/client/Client.cpp
@@ -1,4 +1,3 @@
-#include
#include
#include
#include