diff --git a/.clang-tidy b/.clang-tidy
index 4aeb38ca409..13c1b116ead 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -5,9 +5,7 @@
# a) the new check is not controversial (this includes many checks in readability-* and google-*) or
# b) too noisy (checks with > 100 new warnings are considered noisy, this includes e.g. cppcoreguidelines-*).
-# TODO Let clang-tidy check headers in further directories
-# --> HeaderFilterRegex: '^.*/(src|base|programs|utils)/.*(h|hpp)$'
-HeaderFilterRegex: '^.*/(base|programs|utils)/.*(h|hpp)$'
+HeaderFilterRegex: '^.*/(base|src|programs|utils)/.*(h|hpp)$'
Checks: [
'*',
@@ -22,6 +20,7 @@ Checks: [
'-bugprone-branch-clone',
'-bugprone-easily-swappable-parameters',
'-bugprone-exception-escape',
+ '-bugprone-forward-declaration-namespace',
'-bugprone-implicit-widening-of-multiplication-result',
'-bugprone-narrowing-conversions',
'-bugprone-not-null-terminated-result',
@@ -37,6 +36,8 @@ Checks: [
'-cert-oop54-cpp',
'-cert-oop57-cpp',
+ '-clang-analyzer-optin.performance.Padding',
+
'-clang-analyzer-unix.Malloc',
'-cppcoreguidelines-*', # impractical in a codebase as large as ClickHouse, also slow
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/base/poco/Net/include/Poco/Net/HTTPRequestHandlerFactory.h b/base/poco/Net/include/Poco/Net/HTTPRequestHandlerFactory.h
index 029d936769b..9bc35b7ff70 100644
--- a/base/poco/Net/include/Poco/Net/HTTPRequestHandlerFactory.h
+++ b/base/poco/Net/include/Poco/Net/HTTPRequestHandlerFactory.h
@@ -30,7 +30,6 @@ namespace Net
class HTTPServerRequest;
- class HTTPServerResponse;
class HTTPRequestHandler;
diff --git a/cmake/sanitize.cmake b/cmake/sanitize.cmake
index 88dea294bf5..9d53b2004b4 100644
--- a/cmake/sanitize.cmake
+++ b/cmake/sanitize.cmake
@@ -30,7 +30,7 @@ if (SANITIZE)
elseif (SANITIZE STREQUAL "thread")
set (TSAN_FLAGS "-fsanitize=thread")
if (COMPILER_CLANG)
- set (TSAN_FLAGS "${TSAN_FLAGS} -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/tests/tsan_suppressions.txt")
+ set (TSAN_FLAGS "${TSAN_FLAGS} -fsanitize-ignorelist=${PROJECT_SOURCE_DIR}/tests/tsan_ignorelist.txt")
endif()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SAN_FLAGS} ${TSAN_FLAGS}")
@@ -48,7 +48,7 @@ if (SANITIZE)
set(UBSAN_FLAGS "${UBSAN_FLAGS} -fno-sanitize=unsigned-integer-overflow")
endif()
if (COMPILER_CLANG)
- set (UBSAN_FLAGS "${UBSAN_FLAGS} -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/tests/ubsan_suppressions.txt")
+ set (UBSAN_FLAGS "${UBSAN_FLAGS} -fsanitize-ignorelist=${PROJECT_SOURCE_DIR}/tests/ubsan_ignorelist.txt")
endif()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SAN_FLAGS} ${UBSAN_FLAGS}")
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/contrib/libmetrohash/src/metrohash64.cpp b/contrib/libmetrohash/src/metrohash64.cpp
index 7b5ec7f1a42..6ff64027292 100644
--- a/contrib/libmetrohash/src/metrohash64.cpp
+++ b/contrib/libmetrohash/src/metrohash64.cpp
@@ -26,13 +26,13 @@ const uint8_t MetroHash64::test_seed_1[8] = { 0x3B, 0x0D, 0x48, 0x1C, 0xF4, 0x
-MetroHash64::MetroHash64(const uint64_t seed)
+MetroHash64::MetroHash64(uint64_t seed)
{
Initialize(seed);
}
-void MetroHash64::Initialize(const uint64_t seed)
+void MetroHash64::Initialize(uint64_t seed)
{
vseed = (static_cast(seed) + k2) * k0;
@@ -47,7 +47,7 @@ void MetroHash64::Initialize(const uint64_t seed)
}
-void MetroHash64::Update(const uint8_t * const buffer, const uint64_t length)
+void MetroHash64::Update(const uint8_t * const buffer, uint64_t length)
{
const uint8_t * ptr = reinterpret_cast(buffer);
const uint8_t * const end = ptr + length;
@@ -62,7 +62,7 @@ void MetroHash64::Update(const uint8_t * const buffer, const uint64_t length)
memcpy(input.b + (bytes % 32), ptr, static_cast(fill));
ptr += fill;
bytes += fill;
-
+
// input buffer is still partially filled
if ((bytes % 32) != 0) return;
@@ -72,7 +72,7 @@ void MetroHash64::Update(const uint8_t * const buffer, const uint64_t length)
state.v[2] += read_u64(&input.b[16]) * k2; state.v[2] = rotate_right(state.v[2],29) + state.v[0];
state.v[3] += read_u64(&input.b[24]) * k3; state.v[3] = rotate_right(state.v[3],29) + state.v[1];
}
-
+
// bulk update
bytes += static_cast(end - ptr);
while (ptr <= (end - 32))
@@ -83,14 +83,14 @@ void MetroHash64::Update(const uint8_t * const buffer, const uint64_t length)
state.v[2] += read_u64(ptr) * k2; ptr += 8; state.v[2] = rotate_right(state.v[2],29) + state.v[0];
state.v[3] += read_u64(ptr) * k3; ptr += 8; state.v[3] = rotate_right(state.v[3],29) + state.v[1];
}
-
+
// store remaining bytes in input buffer
if (ptr < end)
memcpy(input.b, ptr, static_cast(end - ptr));
}
-void MetroHash64::Finalize(uint8_t * const hash)
+void MetroHash64::Finalize(uint8_t * hash)
{
// finalize bulk loop, if used
if (bytes >= 32)
@@ -102,11 +102,11 @@ void MetroHash64::Finalize(uint8_t * const hash)
state.v[0] = vseed + (state.v[0] ^ state.v[1]);
}
-
+
// process any bytes remaining in the input buffer
const uint8_t * ptr = reinterpret_cast(input.b);
const uint8_t * const end = ptr + (bytes % 32);
-
+
if ((end - ptr) >= 16)
{
state.v[1] = state.v[0] + (read_u64(ptr) * k2); ptr += 8; state.v[1] = rotate_right(state.v[1],29) * k3;
@@ -139,7 +139,7 @@ void MetroHash64::Finalize(uint8_t * const hash)
state.v[0] += read_u8 (ptr) * k3;
state.v[0] ^= rotate_right(state.v[0], 37) * k1;
}
-
+
state.v[0] ^= rotate_right(state.v[0], 28);
state.v[0] *= k0;
state.v[0] ^= rotate_right(state.v[0], 29);
@@ -152,7 +152,7 @@ void MetroHash64::Finalize(uint8_t * const hash)
}
-void MetroHash64::Hash(const uint8_t * buffer, const uint64_t length, uint8_t * const hash, const uint64_t seed)
+void MetroHash64::Hash(const uint8_t * buffer, uint64_t length, uint8_t * const hash, uint64_t seed)
{
const uint8_t * ptr = reinterpret_cast(buffer);
const uint8_t * const end = ptr + length;
@@ -238,7 +238,7 @@ bool MetroHash64::ImplementationVerified()
// verify incremental implementation
MetroHash64 metro;
-
+
metro.Initialize(0);
metro.Update(reinterpret_cast(MetroHash64::test_string), strlen(MetroHash64::test_string));
metro.Finalize(hash);
@@ -262,9 +262,9 @@ void metrohash64_1(const uint8_t * key, uint64_t len, uint32_t seed, uint8_t * o
const uint8_t * ptr = reinterpret_cast(key);
const uint8_t * const end = ptr + len;
-
+
uint64_t hash = ((static_cast(seed) + k2) * k0) + len;
-
+
if (len >= 32)
{
uint64_t v[4];
@@ -272,7 +272,7 @@ void metrohash64_1(const uint8_t * key, uint64_t len, uint32_t seed, uint8_t * o
v[1] = hash;
v[2] = hash;
v[3] = hash;
-
+
do
{
v[0] += read_u64(ptr) * k0; ptr += 8; v[0] = rotate_right(v[0],29) + v[2];
@@ -288,7 +288,7 @@ void metrohash64_1(const uint8_t * key, uint64_t len, uint32_t seed, uint8_t * o
v[1] ^= rotate_right(((v[1] + v[3]) * k1) + v[2], 33) * k0;
hash += v[0] ^ v[1];
}
-
+
if ((end - ptr) >= 16)
{
uint64_t v0 = hash + (read_u64(ptr) * k0); ptr += 8; v0 = rotate_right(v0,33) * k1;
@@ -297,32 +297,32 @@ void metrohash64_1(const uint8_t * key, uint64_t len, uint32_t seed, uint8_t * o
v1 ^= rotate_right(v1 * k3, 35) + v0;
hash += v1;
}
-
+
if ((end - ptr) >= 8)
{
hash += read_u64(ptr) * k3; ptr += 8;
hash ^= rotate_right(hash, 33) * k1;
-
+
}
-
+
if ((end - ptr) >= 4)
{
hash += read_u32(ptr) * k3; ptr += 4;
hash ^= rotate_right(hash, 15) * k1;
}
-
+
if ((end - ptr) >= 2)
{
hash += read_u16(ptr) * k3; ptr += 2;
hash ^= rotate_right(hash, 13) * k1;
}
-
+
if ((end - ptr) >= 1)
{
hash += read_u8 (ptr) * k3;
hash ^= rotate_right(hash, 25) * k1;
}
-
+
hash ^= rotate_right(hash, 33);
hash *= k0;
hash ^= rotate_right(hash, 33);
@@ -336,13 +336,13 @@ void metrohash64_2(const uint8_t * key, uint64_t len, uint32_t seed, uint8_t * o
static const uint64_t k0 = 0xD6D018F5;
static const uint64_t k1 = 0xA2AA033B;
static const uint64_t k2 = 0x62992FC1;
- static const uint64_t k3 = 0x30BC5B29;
+ static const uint64_t k3 = 0x30BC5B29;
const uint8_t * ptr = reinterpret_cast(key);
const uint8_t * const end = ptr + len;
-
+
uint64_t hash = ((static_cast(seed) + k2) * k0) + len;
-
+
if (len >= 32)
{
uint64_t v[4];
@@ -350,7 +350,7 @@ void metrohash64_2(const uint8_t * key, uint64_t len, uint32_t seed, uint8_t * o
v[1] = hash;
v[2] = hash;
v[3] = hash;
-
+
do
{
v[0] += read_u64(ptr) * k0; ptr += 8; v[0] = rotate_right(v[0],29) + v[2];
@@ -366,7 +366,7 @@ void metrohash64_2(const uint8_t * key, uint64_t len, uint32_t seed, uint8_t * o
v[1] ^= rotate_right(((v[1] + v[3]) * k1) + v[2], 30) * k0;
hash += v[0] ^ v[1];
}
-
+
if ((end - ptr) >= 16)
{
uint64_t v0 = hash + (read_u64(ptr) * k2); ptr += 8; v0 = rotate_right(v0,29) * k3;
@@ -375,31 +375,31 @@ void metrohash64_2(const uint8_t * key, uint64_t len, uint32_t seed, uint8_t * o
v1 ^= rotate_right(v1 * k3, 34) + v0;
hash += v1;
}
-
+
if ((end - ptr) >= 8)
{
hash += read_u64(ptr) * k3; ptr += 8;
hash ^= rotate_right(hash, 36) * k1;
}
-
+
if ((end - ptr) >= 4)
{
hash += read_u32(ptr) * k3; ptr += 4;
hash ^= rotate_right(hash, 15) * k1;
}
-
+
if ((end - ptr) >= 2)
{
hash += read_u16(ptr) * k3; ptr += 2;
hash ^= rotate_right(hash, 15) * k1;
}
-
+
if ((end - ptr) >= 1)
{
hash += read_u8 (ptr) * k3;
hash ^= rotate_right(hash, 23) * k1;
}
-
+
hash ^= rotate_right(hash, 28);
hash *= k0;
hash ^= rotate_right(hash, 29);
diff --git a/contrib/libmetrohash/src/metrohash64.h b/contrib/libmetrohash/src/metrohash64.h
index 911e54e6863..7003a1848be 100644
--- a/contrib/libmetrohash/src/metrohash64.h
+++ b/contrib/libmetrohash/src/metrohash64.h
@@ -25,24 +25,24 @@ public:
static const uint32_t bits = 64;
// Constructor initializes the same as Initialize()
- explicit MetroHash64(const uint64_t seed=0);
+ explicit MetroHash64(uint64_t seed=0);
// Initializes internal state for new hash with optional seed
- void Initialize(const uint64_t seed=0);
+ void Initialize(uint64_t seed=0);
// Update the hash state with a string of bytes. If the length
// is sufficiently long, the implementation switches to a bulk
// hashing algorithm directly on the argument buffer for speed.
- void Update(const uint8_t * buffer, const uint64_t length);
+ void Update(const uint8_t * buffer, uint64_t length);
// Constructs the final hash and writes it to the argument buffer.
// After a hash is finalized, this instance must be Initialized()-ed
// again or the behavior of Update() and Finalize() is undefined.
- void Finalize(uint8_t * const hash);
+ void Finalize(uint8_t * hash);
// A non-incremental function implementation. This can be significantly
// faster than the incremental implementation for some usage patterns.
- static void Hash(const uint8_t * buffer, const uint64_t length, uint8_t * const hash, const uint64_t seed=0);
+ static void Hash(const uint8_t * buffer, uint64_t length, uint8_t * hash, uint64_t seed=0);
// Does implementation correctly execute test vectors?
static bool ImplementationVerified();
diff --git a/contrib/xxHash b/contrib/xxHash
index 3078dc6039f..bbb27a5efb8 160000
--- a/contrib/xxHash
+++ b/contrib/xxHash
@@ -1 +1 @@
-Subproject commit 3078dc6039f8c0bffcb1904f81cfe6b2c3209435
+Subproject commit bbb27a5efb85b92a0486cf361a8635715a53f6ba
diff --git a/contrib/xxHash-cmake/CMakeLists.txt b/contrib/xxHash-cmake/CMakeLists.txt
index 314094e9523..bd7192ae944 100644
--- a/contrib/xxHash-cmake/CMakeLists.txt
+++ b/contrib/xxHash-cmake/CMakeLists.txt
@@ -7,7 +7,7 @@ add_library(xxHash ${SRCS})
target_include_directories(xxHash SYSTEM BEFORE INTERFACE "${LIBRARY_DIR}")
# XXH_INLINE_ALL - Make all functions inline, with implementations being directly included within xxhash.h. Inlining functions is beneficial for speed on small keys.
-# https://github.com/Cyan4973/xxHash/tree/v0.8.1#build-modifiers
+# https://github.com/Cyan4973/xxHash/tree/v0.8.2#build-modifiers
target_compile_definitions(xxHash PUBLIC XXH_INLINE_ALL)
add_library(ch_contrib::xxHash ALIAS xxHash)
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 63471c288dd..76661a5b51c 100755
--- a/docker/test/fuzzer/run-fuzzer.sh
+++ b/docker/test/fuzzer/run-fuzzer.sh
@@ -173,9 +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
- clickhouse-server --config-file db/config.xml --pid-file /var/run/clickhouse-server/clickhouse-server.pid -- --path db > server.log 2>&1 &
- server_pid=$!
+ # 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 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
@@ -427,6 +441,7 @@ p.links a { padding: 5px; margin: 3px; background: #FFF; line-height: 2; white-s
run.log
fuzzer.log.zst
server.log.zst
+ stderr.log
main.log
dmesg.log
${CORE_LINK}
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/stateless/run.sh b/docker/test/stateless/run.sh
index dc181339786..bac9d8df7a9 100755
--- a/docker/test/stateless/run.sh
+++ b/docker/test/stateless/run.sh
@@ -51,22 +51,22 @@ fi
config_logs_export_cluster /etc/clickhouse-server/config.d/system_logs_export.yaml
if [[ -n "$BUGFIX_VALIDATE_CHECK" ]] && [[ "$BUGFIX_VALIDATE_CHECK" -eq 1 ]]; then
- sudo cat /etc/clickhouse-server/config.d/zookeeper.xml \
- | sed "/1<\/use_compression>/d" \
- > /etc/clickhouse-server/config.d/zookeeper.xml.tmp
- sudo mv /etc/clickhouse-server/config.d/zookeeper.xml.tmp /etc/clickhouse-server/config.d/zookeeper.xml
+ sudo sed -i "/1<\/use_compression>/d" /etc/clickhouse-server/config.d/zookeeper.xml
# it contains some new settings, but we can safely remove it
rm /etc/clickhouse-server/config.d/handlers.yaml
rm /etc/clickhouse-server/users.d/s3_cache_new.xml
rm /etc/clickhouse-server/config.d/zero_copy_destructive_operations.xml
+ #todo: remove these after 24.3 released.
+ sudo sed -i "s|azure<|azure_blob_storage<|" /etc/clickhouse-server/config.d/azure_storage_conf.xml
+
+ #todo: remove these after 24.3 released.
+ sudo sed -i "s|local<|local_blob_storage<|" /etc/clickhouse-server/config.d/storage_conf.xml
+
function remove_keeper_config()
{
- sudo cat /etc/clickhouse-server/config.d/keeper_port.xml \
- | sed "/<$1>$2<\/$1>/d" \
- > /etc/clickhouse-server/config.d/keeper_port.xml.tmp
- sudo mv /etc/clickhouse-server/config.d/keeper_port.xml.tmp /etc/clickhouse-server/config.d/keeper_port.xml
+ sudo sed -i "/<$1>$2<\/$1>/d" /etc/clickhouse-server/config.d/keeper_port.xml
}
# commit_logs_cache_size_threshold setting doesn't exist on some older versions
remove_keeper_config "commit_logs_cache_size_threshold" "[[:digit:]]\+"
@@ -77,7 +77,7 @@ fi
if [ "$NUM_TRIES" -gt "1" ]; then
export THREAD_FUZZER_CPU_TIME_PERIOD_US=1000
export THREAD_FUZZER_SLEEP_PROBABILITY=0.1
- export THREAD_FUZZER_SLEEP_TIME_US=100000
+ export THREAD_FUZZER_SLEEP_TIME_US_MAX=100000
export THREAD_FUZZER_pthread_mutex_lock_BEFORE_MIGRATE_PROBABILITY=1
export THREAD_FUZZER_pthread_mutex_lock_AFTER_MIGRATE_PROBABILITY=1
@@ -88,10 +88,10 @@ if [ "$NUM_TRIES" -gt "1" ]; then
export THREAD_FUZZER_pthread_mutex_lock_AFTER_SLEEP_PROBABILITY=0.001
export THREAD_FUZZER_pthread_mutex_unlock_BEFORE_SLEEP_PROBABILITY=0.001
export THREAD_FUZZER_pthread_mutex_unlock_AFTER_SLEEP_PROBABILITY=0.001
- export THREAD_FUZZER_pthread_mutex_lock_BEFORE_SLEEP_TIME_US=10000
- export THREAD_FUZZER_pthread_mutex_lock_AFTER_SLEEP_TIME_US=10000
- export THREAD_FUZZER_pthread_mutex_unlock_BEFORE_SLEEP_TIME_US=10000
- export THREAD_FUZZER_pthread_mutex_unlock_AFTER_SLEEP_TIME_US=10000
+ export THREAD_FUZZER_pthread_mutex_lock_BEFORE_SLEEP_TIME_US_MAX=10000
+ export THREAD_FUZZER_pthread_mutex_lock_AFTER_SLEEP_TIME_US_MAX=10000
+ export THREAD_FUZZER_pthread_mutex_unlock_BEFORE_SLEEP_TIME_US_MAX=10000
+ export THREAD_FUZZER_pthread_mutex_unlock_AFTER_SLEEP_TIME_US_MAX=10000
mkdir -p /var/run/clickhouse-server
# simplest way to forward env variables to server
@@ -101,25 +101,13 @@ else
fi
if [[ -n "$USE_DATABASE_REPLICATED" ]] && [[ "$USE_DATABASE_REPLICATED" -eq 1 ]]; then
- sudo cat /etc/clickhouse-server1/config.d/filesystem_caches_path.xml \
- | sed "s|/var/lib/clickhouse/filesystem_caches/|/var/lib/clickhouse/filesystem_caches_1/|" \
- > /etc/clickhouse-server1/config.d/filesystem_caches_path.xml.tmp
- mv /etc/clickhouse-server1/config.d/filesystem_caches_path.xml.tmp /etc/clickhouse-server1/config.d/filesystem_caches_path.xml
+ sudo sed -i "s|/var/lib/clickhouse/filesystem_caches/|/var/lib/clickhouse/filesystem_caches_1/|" /etc/clickhouse-server1/config.d/filesystem_caches_path.xml
- sudo cat /etc/clickhouse-server2/config.d/filesystem_caches_path.xml \
- | sed "s|/var/lib/clickhouse/filesystem_caches/|/var/lib/clickhouse/filesystem_caches_2/|" \
- > /etc/clickhouse-server2/config.d/filesystem_caches_path.xml.tmp
- mv /etc/clickhouse-server2/config.d/filesystem_caches_path.xml.tmp /etc/clickhouse-server2/config.d/filesystem_caches_path.xml
+ sudo sed -i "s|/var/lib/clickhouse/filesystem_caches/|/var/lib/clickhouse/filesystem_caches_2/|" /etc/clickhouse-server2/config.d/filesystem_caches_path.xml
- sudo cat /etc/clickhouse-server1/config.d/filesystem_caches_path.xml \
- | sed "s|/var/lib/clickhouse/filesystem_caches/|/var/lib/clickhouse/filesystem_caches_1/|" \
- > /etc/clickhouse-server1/config.d/filesystem_caches_path.xml.tmp
- mv /etc/clickhouse-server1/config.d/filesystem_caches_path.xml.tmp /etc/clickhouse-server1/config.d/filesystem_caches_path.xml
+ sudo sed -i "s|/var/lib/clickhouse/filesystem_caches/|/var/lib/clickhouse/filesystem_caches_1/|" /etc/clickhouse-server1/config.d/filesystem_caches_path.xml
- sudo cat /etc/clickhouse-server2/config.d/filesystem_caches_path.xml \
- | sed "s|/var/lib/clickhouse/filesystem_caches/|/var/lib/clickhouse/filesystem_caches_2/|" \
- > /etc/clickhouse-server2/config.d/filesystem_caches_path.xml.tmp
- mv /etc/clickhouse-server2/config.d/filesystem_caches_path.xml.tmp /etc/clickhouse-server2/config.d/filesystem_caches_path.xml
+ sudo sed -i "s|/var/lib/clickhouse/filesystem_caches/|/var/lib/clickhouse/filesystem_caches_2/|" /etc/clickhouse-server2/config.d/filesystem_caches_path.xml
mkdir -p /var/run/clickhouse-server1
sudo chown clickhouse:clickhouse /var/run/clickhouse-server1
diff --git a/docker/test/stateless/stress_tests.lib b/docker/test/stateless/stress_tests.lib
index c0fc32ab718..b69f1d28fcf 100644
--- a/docker/test/stateless/stress_tests.lib
+++ b/docker/test/stateless/stress_tests.lib
@@ -215,7 +215,7 @@ function check_server_start()
function check_logs_for_critical_errors()
{
# Sanitizer asserts
- sed -n '/WARNING:.*anitizer/,/^$/p' >> /test_output/tmp
+ sed -n '/WARNING:.*anitizer/,/^$/p' /var/log/clickhouse-server/stderr.log >> /test_output/tmp
rg -Fav -e "ASan doesn't fully support makecontext/swapcontext functions" -e "DB::Exception" /test_output/tmp > /dev/null \
&& echo -e "Sanitizer assert (in stderr.log)$FAIL$(head_escaped /test_output/tmp)" >> /test_output/test_results.tsv \
|| echo -e "No sanitizer asserts$OK" >> /test_output/test_results.tsv
diff --git a/docker/test/stress/run.sh b/docker/test/stress/run.sh
index 621a6ced7f6..ea7e3aece1d 100644
--- a/docker/test/stress/run.sh
+++ b/docker/test/stress/run.sh
@@ -27,7 +27,7 @@ install_packages package_folder
# and find more potential issues.
export THREAD_FUZZER_CPU_TIME_PERIOD_US=1000
export THREAD_FUZZER_SLEEP_PROBABILITY=0.1
-export THREAD_FUZZER_SLEEP_TIME_US=100000
+export THREAD_FUZZER_SLEEP_TIME_US_MAX=100000
export THREAD_FUZZER_pthread_mutex_lock_BEFORE_MIGRATE_PROBABILITY=1
export THREAD_FUZZER_pthread_mutex_lock_AFTER_MIGRATE_PROBABILITY=1
@@ -38,11 +38,11 @@ export THREAD_FUZZER_pthread_mutex_lock_BEFORE_SLEEP_PROBABILITY=0.001
export THREAD_FUZZER_pthread_mutex_lock_AFTER_SLEEP_PROBABILITY=0.001
export THREAD_FUZZER_pthread_mutex_unlock_BEFORE_SLEEP_PROBABILITY=0.001
export THREAD_FUZZER_pthread_mutex_unlock_AFTER_SLEEP_PROBABILITY=0.001
-export THREAD_FUZZER_pthread_mutex_lock_BEFORE_SLEEP_TIME_US=10000
+export THREAD_FUZZER_pthread_mutex_lock_BEFORE_SLEEP_TIME_US_MAX=10000
-export THREAD_FUZZER_pthread_mutex_lock_AFTER_SLEEP_TIME_US=10000
-export THREAD_FUZZER_pthread_mutex_unlock_BEFORE_SLEEP_TIME_US=10000
-export THREAD_FUZZER_pthread_mutex_unlock_AFTER_SLEEP_TIME_US=10000
+export THREAD_FUZZER_pthread_mutex_lock_AFTER_SLEEP_TIME_US_MAX=10000
+export THREAD_FUZZER_pthread_mutex_unlock_BEFORE_SLEEP_TIME_US_MAX=10000
+export THREAD_FUZZER_pthread_mutex_unlock_AFTER_SLEEP_TIME_US_MAX=10000
export THREAD_FUZZER_EXPLICIT_SLEEP_PROBABILITY=0.01
export THREAD_FUZZER_EXPLICIT_MEMORY_EXCEPTION_PROBABILITY=0.01
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/docker/test/upgrade/run.sh b/docker/test/upgrade/run.sh
index 69228b1bfc9..6761ddba3e5 100644
--- a/docker/test/upgrade/run.sh
+++ b/docker/test/upgrade/run.sh
@@ -67,10 +67,7 @@ configure
function remove_keeper_config()
{
- sudo cat /etc/clickhouse-server/config.d/keeper_port.xml \
- | sed "/<$1>$2<\/$1>/d" \
- > /etc/clickhouse-server/config.d/keeper_port.xml.tmp
- sudo mv /etc/clickhouse-server/config.d/keeper_port.xml.tmp /etc/clickhouse-server/config.d/keeper_port.xml
+ sudo sed -i "/<$1>$2<\/$1>/d" /etc/clickhouse-server/config.d/keeper_port.xml
}
# async_replication setting doesn't exist on some older versions
@@ -80,16 +77,10 @@ remove_keeper_config "async_replication" "1"
remove_keeper_config "create_if_not_exists" "[01]"
#todo: remove these after 24.3 released.
-sudo cat /etc/clickhouse-server/config.d/azure_storage_conf.xml \
- | sed "s|azure|azure_blob_storage|" \
- > /etc/clickhouse-server/config.d/azure_storage_conf.xml.tmp
-sudo mv /etc/clickhouse-server/config.d/azure_storage_conf.xml.tmp /etc/clickhouse-server/config.d/azure_storage_conf.xml
+sudo sed -i "s|azure<|azure_blob_storage<|" /etc/clickhouse-server/config.d/azure_storage_conf.xml
#todo: remove these after 24.3 released.
-sudo cat /etc/clickhouse-server/config.d/storage_conf.xml \
- | sed "s|local|local_blob_storage|" \
- > /etc/clickhouse-server/config.d/storage_conf.xml.tmp
-sudo mv /etc/clickhouse-server/config.d/storage_conf.xml.tmp /etc/clickhouse-server/config.d/storage_conf.xml
+sudo sed -i "s|local<|local_blob_storage<|" /etc/clickhouse-server/config.d/storage_conf.xml
# latest_logs_cache_size_threshold setting doesn't exist on some older versions
remove_keeper_config "latest_logs_cache_size_threshold" "[[:digit:]]\+"
@@ -120,22 +111,13 @@ export ZOOKEEPER_FAULT_INJECTION=0
configure
# force_sync=false doesn't work correctly on some older versions
-sudo cat /etc/clickhouse-server/config.d/keeper_port.xml \
- | sed "s|false|true|" \
- > /etc/clickhouse-server/config.d/keeper_port.xml.tmp
-sudo mv /etc/clickhouse-server/config.d/keeper_port.xml.tmp /etc/clickhouse-server/config.d/keeper_port.xml
+sudo sed -i "s|false|true|" /etc/clickhouse-server/config.d/keeper_port.xml
#todo: remove these after 24.3 released.
-sudo cat /etc/clickhouse-server/config.d/azure_storage_conf.xml \
- | sed "s|azure|azure_blob_storage|" \
- > /etc/clickhouse-server/config.d/azure_storage_conf.xml.tmp
-sudo mv /etc/clickhouse-server/config.d/azure_storage_conf.xml.tmp /etc/clickhouse-server/config.d/azure_storage_conf.xml
+sudo sed -i "s|azure<|azure_blob_storage<|" /etc/clickhouse-server/config.d/azure_storage_conf.xml
#todo: remove these after 24.3 released.
-sudo cat /etc/clickhouse-server/config.d/storage_conf.xml \
- | sed "s|local|local_blob_storage|" \
- > /etc/clickhouse-server/config.d/storage_conf.xml.tmp
-sudo mv /etc/clickhouse-server/config.d/storage_conf.xml.tmp /etc/clickhouse-server/config.d/storage_conf.xml
+sudo sed -i "s|local<|local_blob_storage<|" /etc/clickhouse-server/config.d/storage_conf.xml
# async_replication setting doesn't exist on some older versions
remove_keeper_config "async_replication" "1"
@@ -150,10 +132,7 @@ remove_keeper_config "latest_logs_cache_size_threshold" "[[:digit:]]\+"
remove_keeper_config "commit_logs_cache_size_threshold" "[[:digit:]]\+"
# But we still need default disk because some tables loaded only into it
-sudo cat /etc/clickhouse-server/config.d/s3_storage_policy_by_default.xml \
- | sed "s|s3|s3default|" \
- > /etc/clickhouse-server/config.d/s3_storage_policy_by_default.xml.tmp
-mv /etc/clickhouse-server/config.d/s3_storage_policy_by_default.xml.tmp /etc/clickhouse-server/config.d/s3_storage_policy_by_default.xml
+sudo sed -i "s|s3|s3default|" /etc/clickhouse-server/config.d/s3_storage_policy_by_default.xml
sudo chown clickhouse /etc/clickhouse-server/config.d/s3_storage_policy_by_default.xml
sudo chgrp clickhouse /etc/clickhouse-server/config.d/s3_storage_policy_by_default.xml
@@ -256,10 +235,7 @@ then
fi
# Just in case previous version left some garbage in zk
-sudo cat /etc/clickhouse-server/config.d/lost_forever_check.xml \
- | sed "s|>1<|>0<|g" \
- > /etc/clickhouse-server/config.d/lost_forever_check.xml.tmp
-sudo mv /etc/clickhouse-server/config.d/lost_forever_check.xml.tmp /etc/clickhouse-server/config.d/lost_forever_check.xml
+sudo sed -i "s|>1<|>0<|g" /etc/clickhouse-server/config.d/lost_forever_check.xml \
rm /etc/clickhouse-server/config.d/filesystem_caches_path.xml
start 500
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/example-datasets/tw-weather.md b/docs/en/getting-started/example-datasets/tw-weather.md
new file mode 100644
index 00000000000..e5f16c403d5
--- /dev/null
+++ b/docs/en/getting-started/example-datasets/tw-weather.md
@@ -0,0 +1,293 @@
+---
+slug: /en/getting-started/example-datasets/tw-weather
+sidebar_label: Taiwan Historical Weather Datasets
+sidebar_position: 1
+description: 131 million rows of weather observation data for the last 128 yrs
+---
+
+# Taiwan Historical Weather Datasets
+
+This dataset contains historical meteorological observations measurements for the last 128 years. Each row is a measurement for a point in date time and weather station.
+
+The origin of this dataset is available [here](https://github.com/Raingel/historical_weather) and the list of weather station numbers can be found [here](https://github.com/Raingel/weather_station_list).
+
+> The sources of meteorological datasets include the meteorological stations that are established by the Central Weather Administration (station code is beginning with C0, C1, and 4) and the agricultural meteorological stations belonging to the Council of Agriculture (station code other than those mentioned above):
+
+ - StationId
+ - MeasuredDate, the observation time
+ - StnPres, the station air pressure
+ - SeaPres, the sea level pressure
+ - Td, the dew point temperature
+ - RH, the relative humidity
+ - Other elements where available
+
+## Downloading the data
+
+- A [pre-processed version](#pre-processed-data) of the data for the ClickHouse, which has been cleaned, re-structured, and enriched. This dataset covers the years from 1896 to 2023.
+- [Download the original raw data](#original-raw-data) and convert to the format required by ClickHouse. Users wanting to add their own columns may wish to explore or complete their approaches.
+
+### Pre-processed data
+
+The dataset has also been re-structured from a measurement per line to a row per weather station id and measured date, i.e.
+
+```csv
+StationId,MeasuredDate,StnPres,Tx,RH,WS,WD,WSGust,WDGust,Precp,GloblRad,TxSoil0cm,TxSoil5cm,TxSoil20cm,TxSoil50cm,TxSoil100cm,SeaPres,Td,PrecpHour,SunShine,TxSoil10cm,EvapA,Visb,UVI,Cloud Amount,TxSoil30cm,TxSoil200cm,TxSoil300cm,TxSoil500cm,VaporPressure
+C0X100,2016-01-01 01:00:00,1022.1,16.1,72,1.1,8.0,,,,,,,,,,,,,,,,,,,,,,,
+C0X100,2016-01-01 02:00:00,1021.6,16.0,73,1.2,358.0,,,,,,,,,,,,,,,,,,,,,,,
+C0X100,2016-01-01 03:00:00,1021.3,15.8,74,1.5,353.0,,,,,,,,,,,,,,,,,,,,,,,
+C0X100,2016-01-01 04:00:00,1021.2,15.8,74,1.7,8.0,,,,,,,,,,,,,,,,,,,,,,,
+```
+
+It is easy to query and ensure that the resulting table has less sparse and some elements are null because they're not available to be measured in this weather station.
+
+This dataset is available in the following Google CloudStorage location. Either download the dataset to your local filesystem (and insert them with the ClickHouse client) or insert them directly into the ClickHouse (see [Inserting from URL](#inserting-from-url)).
+
+To download:
+
+```bash
+wget https://storage.googleapis.com/taiwan-weather-observaiton-datasets/preprocessed_weather_daily_1896_2023.tar.gz
+
+# Option: Validate the checksum
+md5sum preprocessed_weather_daily_1896_2023.tar.gz
+# Checksum should be equal to: 11b484f5bd9ddafec5cfb131eb2dd008
+
+tar -xzvf preprocessed_weather_daily_1896_2023.tar.gz
+daily_weather_preprocessed_1896_2023.csv
+
+# Option: Validate the checksum
+md5sum daily_weather_preprocessed_1896_2023.csv
+# Checksum should be equal to: 1132248c78195c43d93f843753881754
+```
+
+### Original raw data
+
+The following details are about the steps to download the original raw data to transform and convert as you want.
+
+#### Download
+
+To download the original raw data:
+
+```bash
+mkdir tw_raw_weather_data && cd tw_raw_weather_data
+
+wget https://storage.googleapis.com/taiwan-weather-observaiton-datasets/raw_data_weather_daily_1896_2023.tar.gz
+
+# Option: Validate the checksum
+md5sum raw_data_weather_daily_1896_2023.tar.gz
+# Checksum should be equal to: b66b9f137217454d655e3004d7d1b51a
+
+tar -xzvf raw_data_weather_daily_1896_2023.tar.gz
+466920_1928.csv
+466920_1929.csv
+466920_1930.csv
+466920_1931.csv
+...
+
+# Option: Validate the checksum
+cat *.csv | md5sum
+# Checksum should be equal to: b26db404bf84d4063fac42e576464ce1
+```
+
+#### Retrieve the Taiwan weather stations
+
+```bash
+wget -O weather_sta_list.csv https://github.com/Raingel/weather_station_list/raw/main/data/weather_sta_list.csv
+
+# Option: Convert the UTF-8-BOM to UTF-8 encoding
+sed -i '1s/^\xEF\xBB\xBF//' weather_sta_list.csv
+```
+
+## Create table schema
+
+Create the MergeTree table in ClickHouse (from the ClickHouse client).
+
+```bash
+CREATE TABLE tw_weather_data (
+ StationId String null,
+ MeasuredDate DateTime64,
+ StnPres Float64 null,
+ SeaPres Float64 null,
+ Tx Float64 null,
+ Td Float64 null,
+ RH Float64 null,
+ WS Float64 null,
+ WD Float64 null,
+ WSGust Float64 null,
+ WDGust Float64 null,
+ Precp Float64 null,
+ PrecpHour Float64 null,
+ SunShine Float64 null,
+ GloblRad Float64 null,
+ TxSoil0cm Float64 null,
+ TxSoil5cm Float64 null,
+ TxSoil10cm Float64 null,
+ TxSoil20cm Float64 null,
+ TxSoil50cm Float64 null,
+ TxSoil100cm Float64 null,
+ TxSoil30cm Float64 null,
+ TxSoil200cm Float64 null,
+ TxSoil300cm Float64 null,
+ TxSoil500cm Float64 null,
+ VaporPressure Float64 null,
+ UVI Float64 null,
+ "Cloud Amount" Float64 null,
+ EvapA Float64 null,
+ Visb Float64 null
+)
+ENGINE = MergeTree
+ORDER BY (MeasuredDate);
+```
+
+## Inserting into ClickHouse
+
+### Inserting from local file
+
+Data can be inserted from a local file as follows (from the ClickHouse client):
+
+```sql
+INSERT INTO tw_weather_data FROM INFILE '/path/to/daily_weather_preprocessed_1896_2023.csv'
+```
+
+where `/path/to` represents the specific user path to the local file on the disk.
+
+And the sample response output is as follows after inserting data into the ClickHouse:
+
+```response
+Query id: 90e4b524-6e14-4855-817c-7e6f98fbeabb
+
+Ok.
+131985329 rows in set. Elapsed: 71.770 sec. Processed 131.99 million rows, 10.06 GB (1.84 million rows/s., 140.14 MB/s.)
+Peak memory usage: 583.23 MiB.
+```
+
+### Inserting from URL
+
+```sql
+INSERT INTO tw_weather_data SELECT *
+FROM url('https://storage.googleapis.com/taiwan-weather-observaiton-datasets/daily_weather_preprocessed_1896_2023.csv', 'CSVWithNames')
+
+```
+To know how to speed this up, please see our blog post on [tuning large data loads](https://clickhouse.com/blog/supercharge-your-clickhouse-data-loads-part2).
+
+## Check data rows and sizes
+
+1. Let's see how many rows are inserted:
+
+```sql
+SELECT formatReadableQuantity(count())
+FROM tw_weather_data;
+```
+
+```response
+┌─formatReadableQuantity(count())─┐
+│ 131.99 million │
+└─────────────────────────────────┘
+```
+
+2. Let's see how much disk space are used for this table:
+
+```sql
+SELECT
+ formatReadableSize(sum(bytes)) AS disk_size,
+ formatReadableSize(sum(data_uncompressed_bytes)) AS uncompressed_size
+FROM system.parts
+WHERE (`table` = 'tw_weather_data') AND active
+```
+
+```response
+┌─disk_size─┬─uncompressed_size─┐
+│ 2.13 GiB │ 32.94 GiB │
+└───────────┴───────────────────┘
+```
+
+## Sample queries
+
+### Q1: Retrieve the highest dew point temperature for each weather station in the specific year
+
+```sql
+SELECT
+ StationId,
+ max(Td) AS max_td
+FROM tw_weather_data
+WHERE (year(MeasuredDate) = 2023) AND (Td IS NOT NULL)
+GROUP BY StationId
+
+┌─StationId─┬─max_td─┐
+│ 466940 │ 1 │
+│ 467300 │ 1 │
+│ 467540 │ 1 │
+│ 467490 │ 1 │
+│ 467080 │ 1 │
+│ 466910 │ 1 │
+│ 467660 │ 1 │
+│ 467270 │ 1 │
+│ 467350 │ 1 │
+│ 467571 │ 1 │
+│ 466920 │ 1 │
+│ 467650 │ 1 │
+│ 467550 │ 1 │
+│ 467480 │ 1 │
+│ 467610 │ 1 │
+│ 467050 │ 1 │
+│ 467590 │ 1 │
+│ 466990 │ 1 │
+│ 467060 │ 1 │
+│ 466950 │ 1 │
+│ 467620 │ 1 │
+│ 467990 │ 1 │
+│ 466930 │ 1 │
+│ 467110 │ 1 │
+│ 466881 │ 1 │
+│ 467410 │ 1 │
+│ 467441 │ 1 │
+│ 467420 │ 1 │
+│ 467530 │ 1 │
+│ 466900 │ 1 │
+└───────────┴────────┘
+
+30 rows in set. Elapsed: 0.045 sec. Processed 6.41 million rows, 187.33 MB (143.92 million rows/s., 4.21 GB/s.)
+```
+
+### Q2: Raw data fetching with the specific duration time range, fields and weather station
+
+```sql
+SELECT
+ StnPres,
+ SeaPres,
+ Tx,
+ Td,
+ RH,
+ WS,
+ WD,
+ WSGust,
+ WDGust,
+ Precp,
+ PrecpHour
+FROM tw_weather_data
+WHERE (StationId = 'C0UB10') AND (MeasuredDate >= '2023-12-23') AND (MeasuredDate < '2023-12-24')
+ORDER BY MeasuredDate ASC
+LIMIT 10
+```
+
+```response
+┌─StnPres─┬─SeaPres─┬───Tx─┬───Td─┬─RH─┬──WS─┬──WD─┬─WSGust─┬─WDGust─┬─Precp─┬─PrecpHour─┐
+│ 1029.5 │ ᴺᵁᴸᴸ │ 11.8 │ ᴺᵁᴸᴸ │ 78 │ 2.7 │ 271 │ 5.5 │ 275 │ -99.8 │ -99.8 │
+│ 1029.8 │ ᴺᵁᴸᴸ │ 12.3 │ ᴺᵁᴸᴸ │ 78 │ 2.7 │ 289 │ 5.5 │ 308 │ -99.8 │ -99.8 │
+│ 1028.6 │ ᴺᵁᴸᴸ │ 12.3 │ ᴺᵁᴸᴸ │ 79 │ 2.3 │ 251 │ 6.1 │ 289 │ -99.8 │ -99.8 │
+│ 1028.2 │ ᴺᵁᴸᴸ │ 13 │ ᴺᵁᴸᴸ │ 75 │ 4.3 │ 312 │ 7.5 │ 316 │ -99.8 │ -99.8 │
+│ 1027.8 │ ᴺᵁᴸᴸ │ 11.1 │ ᴺᵁᴸᴸ │ 89 │ 7.1 │ 310 │ 11.6 │ 322 │ -99.8 │ -99.8 │
+│ 1027.8 │ ᴺᵁᴸᴸ │ 11.6 │ ᴺᵁᴸᴸ │ 90 │ 3.1 │ 269 │ 10.7 │ 295 │ -99.8 │ -99.8 │
+│ 1027.9 │ ᴺᵁᴸᴸ │ 12.3 │ ᴺᵁᴸᴸ │ 89 │ 4.7 │ 296 │ 8.1 │ 310 │ -99.8 │ -99.8 │
+│ 1028.2 │ ᴺᵁᴸᴸ │ 12.2 │ ᴺᵁᴸᴸ │ 94 │ 2.5 │ 246 │ 7.1 │ 283 │ -99.8 │ -99.8 │
+│ 1028.4 │ ᴺᵁᴸᴸ │ 12.5 │ ᴺᵁᴸᴸ │ 94 │ 3.1 │ 265 │ 4.8 │ 297 │ -99.8 │ -99.8 │
+│ 1028.3 │ ᴺᵁᴸᴸ │ 13.6 │ ᴺᵁᴸᴸ │ 91 │ 1.2 │ 273 │ 4.4 │ 256 │ -99.8 │ -99.8 │
+└─────────┴─────────┴──────┴──────┴────┴─────┴─────┴────────┴────────┴───────┴───────────┘
+
+10 rows in set. Elapsed: 0.009 sec. Processed 91.70 thousand rows, 2.33 MB (9.67 million rows/s., 245.31 MB/s.)
+```
+
+## Credits
+
+We would like to acknowledge the efforts of the Central Weather Administration and Agricultural Meteorological Observation Network (Station) of the Council of Agriculture for preparing, cleaning, and distributing this dataset. We appreciate your efforts.
+
+Ou, J.-H., Kuo, C.-H., Wu, Y.-F., Lin, G.-C., Lee, M.-H., Chen, R.-K., Chou, H.-P., Wu, H.-Y., Chu, S.-C., Lai, Q.-J., Tsai, Y.-C., Lin, C.-C., Kuo, C.-C., Liao, C.-T., Chen, Y.-N., Chu, Y.-W., Chen, C.-Y., 2023. Application-oriented deep learning model for early warning of rice blast in Taiwan. Ecological Informatics 73, 101950. https://doi.org/10.1016/j.ecoinf.2022.101950 [13/12/2022]
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/interfaces/cli.md b/docs/en/interfaces/cli.md
index 2b90d684c13..1eb426af617 100644
--- a/docs/en/interfaces/cli.md
+++ b/docs/en/interfaces/cli.md
@@ -178,7 +178,7 @@ You can pass parameters to `clickhouse-client` (all parameters have a default va
- `--password` – The password. Default value: empty string.
- `--ask-password` - Prompt the user to enter a password.
- `--query, -q` – The query to process when using non-interactive mode. `--query` can be specified multiple times, e.g. `--query "SELECT 1" --query "SELECT 2"`. Cannot be used simultaneously with `--queries-file`.
-- `--queries-file` – file path with queries to execute. `--queries-file` can be specified multiple times, e.g. `--query queries1.sql --query queries2.sql`. Cannot be used simultaneously with `--query`.
+- `--queries-file` – file path with queries to execute. `--queries-file` can be specified multiple times, e.g. `--queries-file queries1.sql --queries-file queries2.sql`. Cannot be used simultaneously with `--query`.
- `--multiquery, -n` – If specified, multiple queries separated by semicolons can be listed after the `--query` option. For convenience, it is also possible to omit `--query` and pass the queries directly after `--multiquery`.
- `--multiline, -m` – If specified, allow multiline queries (do not send the query on Enter).
- `--database, -d` – Select the current default database. Default value: the current database from the server settings (‘default’ by default).
diff --git a/docs/en/operations/backup.md b/docs/en/operations/backup.md
index 8639af468c2..2ba50b39934 100644
--- a/docs/en/operations/backup.md
+++ b/docs/en/operations/backup.md
@@ -87,6 +87,7 @@ The BACKUP and RESTORE statements take a list of DATABASE and TABLE names, a des
- `structure_only`: if enabled, allows to only backup or restore the CREATE statements without the data of tables
- `storage_policy`: storage policy for the tables being restored. See [Using Multiple Block Devices for Data Storage](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes). This setting is only applicable to the `RESTORE` command. The specified storage policy applies only to tables with an engine from the `MergeTree` family.
- `s3_storage_class`: the storage class used for S3 backup. For example, `STANDARD`
+ - `azure_attempt_to_create_container`: when using Azure Blob Storage, whether the specified container will try to be created if it doesn't exist. Default: true.
### Usage examples
diff --git a/docs/en/operations/monitoring.md b/docs/en/operations/monitoring.md
index de61da6f5c4..573e8075bca 100644
--- a/docs/en/operations/monitoring.md
+++ b/docs/en/operations/monitoring.md
@@ -3,6 +3,7 @@ slug: /en/operations/monitoring
sidebar_position: 45
sidebar_label: Monitoring
description: You can monitor the utilization of hardware resources and also ClickHouse server metrics.
+keywords: [monitoring, observability, advanced dashboard, dashboard, observability dashboard]
---
# Monitoring
@@ -15,11 +16,11 @@ You can monitor:
- Utilization of hardware resources.
- ClickHouse server metrics.
-## Built-in observability dashboard
+## Built-in advanced observability dashboard
-ClickHouse comes with a built-in observability dashboard feature which can be accessed by `$HOST:$PORT/dashboard` (requires user and password) that shows the following metrics:
+ClickHouse comes with a built-in advanced observability dashboard feature which can be accessed by `$HOST:$PORT/dashboard` (requires user and password) that shows the following metrics:
- Queries/second
- CPU usage (cores)
- Queries running
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/geo/polygon.md b/docs/en/sql-reference/functions/geo/polygon.md
index 35e2280e5cc..c2572779ada 100644
--- a/docs/en/sql-reference/functions/geo/polygon.md
+++ b/docs/en/sql-reference/functions/geo/polygon.md
@@ -4,6 +4,67 @@ sidebar_label: Polygons
title: "Functions for Working with Polygons"
---
+## WKT
+
+Returns a WKT (Well Known Text) geometric object from various [Geo Data Types](../../data-types/geo.md). Supported WKT objects are:
+
+- POINT
+- POLYGON
+- MULTIPOLYGON
+
+**Syntax**
+
+```sql
+WKT(geo_data)
+```
+
+**Parameters**
+
+`geo_data` can be one of the following [Geo Data Types](../../data-types/geo.md) or their underlying primitive types:
+
+- [Point](../../data-types/geo.md#point)
+- [Ring](../../data-types/geo.md#ring)
+- [Polygon](../../data-types/geo.md#polygon)
+- [MultiPolygon](../../data-types/geo.md#multipolygon)
+
+**Returned value**
+
+- WKT geometric object `POINT` is returned for a Point.
+- WKT geometric object `POLYGON` is returned for a Polygon
+- WKT geometric object `MULTIPOLYGON` is returned for a MultiPolygon.
+
+**Examples**
+
+POINT from tuple:
+
+```sql
+SELECT wkt((0., 0.));
+```
+
+```response
+POINT(0 0)
+```
+
+POLYGON from an array of tuples or an array of tuple arrays:
+
+```sql
+SELECT wkt([(0., 0.), (10., 0.), (10., 10.), (0., 10.)]);
+```
+
+```response
+POLYGON((0 0,10 0,10 10,0 10))
+```
+
+MULTIPOLYGON from an array of multi-dimensional tuple arrays:
+
+```sql
+SELECT wkt([[[(0., 0.), (10., 0.), (10., 10.), (0., 10.)], [(4., 4.), (5., 4.), (5., 5.), (4., 5.)]], [[(-10., -10.), (-10., -9.), (-9., 10.)]]]);
+```
+
+```response
+MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(4 4,5 4,5 5,4 5,4 4)),((-10 -10,-10 -9,-9 10,-10 -10)))
+```
+
## readWKTMultiPolygon
Converts a WKT (Well Known Text) MultiPolygon into a MultiPolygon type.
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/alter/partition.md b/docs/en/sql-reference/statements/alter/partition.md
index a21ef4f4af5..941dc000a02 100644
--- a/docs/en/sql-reference/statements/alter/partition.md
+++ b/docs/en/sql-reference/statements/alter/partition.md
@@ -133,6 +133,8 @@ For the query to run successfully, the following conditions must be met:
- Both tables must have the same indices and projections.
- Both tables must have the same storage policy.
+If both tables have the same storage policy, use hardlink to attach partition. Otherwise, use copying the data to attach partition.
+
## REPLACE PARTITION
``` sql
@@ -350,6 +352,7 @@ ALTER TABLE mt DELETE IN PARTITION ID '2' WHERE p = 2;
You can specify the partition expression in `ALTER ... PARTITION` queries in different ways:
- As a value from the `partition` column of the `system.parts` table. For example, `ALTER TABLE visits DETACH PARTITION 201901`.
+- Using the keyword `ALL`. It can be used only with DROP/DETACH/ATTACH. For example, `ALTER TABLE visits ATTACH PARTITION ALL`.
- As a tuple of expressions or constants that matches (in types) the table partitioning keys tuple. In the case of a single element partitioning key, the expression should be wrapped in the `tuple (...)` function. For example, `ALTER TABLE visits DETACH PARTITION tuple(toYYYYMM(toDate('2019-01-25')))`.
- Using the partition ID. Partition ID is a string identifier of the partition (human-readable, if possible) that is used as the names of partitions in the file system and in ZooKeeper. The partition ID must be specified in the `PARTITION ID` clause, in a single quotes. For example, `ALTER TABLE visits DETACH PARTITION ID '201901'`.
- In the [ALTER ATTACH PART](#alter_attach-partition) and [DROP DETACHED PART](#alter_drop-detached) query, to specify the name of a part, use string literal with a value from the `name` column of the [system.detached_parts](/docs/en/operations/system-tables/detached_parts.md/#system_tables-detached_parts) table. For example, `ALTER TABLE visits ATTACH PART '201901_1_1_0'`.
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 '