mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-21 01:00:48 +00:00
merge master and solve conflicts
This commit is contained in:
commit
ae7a657a3f
@ -12,6 +12,7 @@ BraceWrapping:
|
|||||||
AfterUnion: true
|
AfterUnion: true
|
||||||
BeforeCatch: true
|
BeforeCatch: true
|
||||||
BeforeElse: true
|
BeforeElse: true
|
||||||
|
BeforeLambdaBody: true
|
||||||
IndentBraces: false
|
IndentBraces: false
|
||||||
BreakConstructorInitializersBeforeComma: false
|
BreakConstructorInitializersBeforeComma: false
|
||||||
Cpp11BracedListStyle: true
|
Cpp11BracedListStyle: true
|
||||||
|
312
.clang-tidy
312
.clang-tidy
@ -1,169 +1,168 @@
|
|||||||
Checks: '-*,
|
# To run clang-tidy from CMake, build ClickHouse with -DENABLE_CLANG_TIDY=1. To show all warnings, it is
|
||||||
misc-throw-by-value-catch-by-reference,
|
# recommended to pass "-k0" to Ninja.
|
||||||
misc-misplaced-const,
|
|
||||||
misc-unconventional-assign-operator,
|
|
||||||
misc-redundant-expression,
|
|
||||||
misc-static-assert,
|
|
||||||
misc-unconventional-assign-operator,
|
|
||||||
misc-uniqueptr-reset-release,
|
|
||||||
misc-unused-alias-decls,
|
|
||||||
misc-unused-parameters,
|
|
||||||
misc-unused-using-decls,
|
|
||||||
|
|
||||||
modernize-avoid-bind,
|
# Enable all checks + disable selected checks. Feel free to remove disabled checks from below list if
|
||||||
modernize-loop-convert,
|
# a) the new check is not controversial (this includes many checks in readability-* and google-*) or
|
||||||
modernize-make-shared,
|
# b) too noisy (checks with > 100 new warnings are considered noisy, this includes e.g. cppcoreguidelines-*).
|
||||||
modernize-make-unique,
|
|
||||||
modernize-raw-string-literal,
|
|
||||||
modernize-redundant-void-arg,
|
|
||||||
modernize-replace-auto-ptr,
|
|
||||||
modernize-replace-random-shuffle,
|
|
||||||
modernize-use-bool-literals,
|
|
||||||
modernize-use-nullptr,
|
|
||||||
modernize-use-using,
|
|
||||||
modernize-use-equals-default,
|
|
||||||
modernize-use-equals-delete,
|
|
||||||
|
|
||||||
performance-faster-string-find,
|
# TODO Let clang-tidy check headers in further directories
|
||||||
performance-for-range-copy,
|
# --> HeaderFilterRegex: '^.*/(src|base|programs|utils)/.*(h|hpp)$'
|
||||||
performance-implicit-conversion-in-loop,
|
HeaderFilterRegex: '^.*/(base)/.*(h|hpp)$'
|
||||||
performance-inefficient-algorithm,
|
|
||||||
performance-inefficient-vector-operation,
|
|
||||||
performance-move-constructor-init,
|
|
||||||
performance-no-automatic-move,
|
|
||||||
performance-trivially-destructible,
|
|
||||||
performance-unnecessary-copy-initialization,
|
|
||||||
|
|
||||||
readability-avoid-const-params-in-decls,
|
Checks: '*,
|
||||||
readability-const-return-type,
|
-abseil-*,
|
||||||
readability-container-size-empty,
|
|
||||||
readability-convert-member-functions-to-static,
|
|
||||||
readability-delete-null-pointer,
|
|
||||||
readability-deleted-default,
|
|
||||||
readability-make-member-function-const,
|
|
||||||
readability-misplaced-array-index,
|
|
||||||
readability-non-const-parameter,
|
|
||||||
readability-qualified-auto,
|
|
||||||
readability-redundant-access-specifiers,
|
|
||||||
readability-redundant-control-flow,
|
|
||||||
readability-redundant-function-ptr-dereference,
|
|
||||||
readability-redundant-smartptr-get,
|
|
||||||
readability-redundant-string-cstr,
|
|
||||||
readability-redundant-string-init,
|
|
||||||
readability-static-definition-in-anonymous-namespace,
|
|
||||||
readability-string-compare,
|
|
||||||
readability-uniqueptr-delete-release,
|
|
||||||
readability-redundant-member-init,
|
|
||||||
readability-simplify-subscript-expr,
|
|
||||||
readability-simplify-boolean-expr,
|
|
||||||
readability-inconsistent-declaration-parameter-name,
|
|
||||||
readability-identifier-naming,
|
|
||||||
|
|
||||||
bugprone-undelegated-constructor,
|
-altera-*,
|
||||||
bugprone-argument-comment,
|
|
||||||
bugprone-bad-signal-to-kill-thread,
|
|
||||||
bugprone-bool-pointer-implicit-conversion,
|
|
||||||
bugprone-copy-constructor-init,
|
|
||||||
bugprone-dangling-handle,
|
|
||||||
bugprone-forward-declaration-namespace,
|
|
||||||
bugprone-fold-init-type,
|
|
||||||
bugprone-inaccurate-erase,
|
|
||||||
bugprone-incorrect-roundings,
|
|
||||||
bugprone-infinite-loop,
|
|
||||||
bugprone-integer-division,
|
|
||||||
bugprone-macro-parentheses,
|
|
||||||
bugprone-macro-repeated-side-effects,
|
|
||||||
bugprone-misplaced-operator-in-strlen-in-alloc,
|
|
||||||
bugprone-misplaced-pointer-artithmetic-in-alloc,
|
|
||||||
bugprone-misplaced-widening-cast,
|
|
||||||
bugprone-move-forwarding-reference,
|
|
||||||
bugprone-multiple-statement-macro,
|
|
||||||
bugprone-parent-virtual-call,
|
|
||||||
bugprone-posix-return,
|
|
||||||
bugprone-reserved-identifier,
|
|
||||||
bugprone-signed-char-misuse,
|
|
||||||
bugprone-sizeof-container,
|
|
||||||
bugprone-sizeof-expression,
|
|
||||||
bugprone-string-constructor,
|
|
||||||
bugprone-string-integer-assignment,
|
|
||||||
bugprone-string-literal-with-embedded-nul,
|
|
||||||
bugprone-suspicious-enum-usage,
|
|
||||||
bugprone-suspicious-include,
|
|
||||||
bugprone-suspicious-memset-usage,
|
|
||||||
bugprone-suspicious-missing-comma,
|
|
||||||
bugprone-suspicious-string-compare,
|
|
||||||
bugprone-swapped-arguments,
|
|
||||||
bugprone-terminating-continue,
|
|
||||||
bugprone-throw-keyword-missing,
|
|
||||||
bugprone-too-small-loop-variable,
|
|
||||||
bugprone-undefined-memory-manipulation,
|
|
||||||
bugprone-unhandled-self-assignment,
|
|
||||||
bugprone-unused-raii,
|
|
||||||
bugprone-unused-return-value,
|
|
||||||
bugprone-use-after-move,
|
|
||||||
bugprone-virtual-near-miss,
|
|
||||||
|
|
||||||
cert-dcl21-cpp,
|
-android-*,
|
||||||
cert-dcl50-cpp,
|
|
||||||
cert-env33-c,
|
|
||||||
cert-err34-c,
|
|
||||||
cert-err52-cpp,
|
|
||||||
cert-flp30-c,
|
|
||||||
cert-mem57-cpp,
|
|
||||||
cert-msc50-cpp,
|
|
||||||
cert-oop58-cpp,
|
|
||||||
|
|
||||||
google-build-explicit-make-pair,
|
-bugprone-assignment-in-if-condition,
|
||||||
google-build-namespaces,
|
-bugprone-branch-clone,
|
||||||
google-default-arguments,
|
-bugprone-easily-swappable-parameters,
|
||||||
google-explicit-constructor,
|
-bugprone-exception-escape,
|
||||||
google-readability-casting,
|
-bugprone-implicit-widening-of-multiplication-result,
|
||||||
google-readability-avoid-underscore-in-googletest-name,
|
-bugprone-narrowing-conversions,
|
||||||
google-runtime-int,
|
-bugprone-not-null-terminated-result,
|
||||||
google-runtime-operator,
|
-bugprone-unchecked-optional-access,
|
||||||
|
|
||||||
hicpp-exception-baseclass,
|
-cert-dcl16-c,
|
||||||
|
-cert-err58-cpp,
|
||||||
|
-cert-msc32-c,
|
||||||
|
-cert-msc51-cpp,
|
||||||
|
-cert-oop54-cpp,
|
||||||
|
-cert-oop57-cpp,
|
||||||
|
|
||||||
clang-analyzer-core.CallAndMessage,
|
-clang-analyzer-optin.performance.Padding,
|
||||||
clang-analyzer-core.DivideZero,
|
-clang-analyzer-optin.portability.UnixAPI,
|
||||||
clang-analyzer-core.NonNullParamChecker,
|
-clang-analyzer-security.insecureAPI.bzero,
|
||||||
clang-analyzer-core.NullDereference,
|
-clang-analyzer-security.insecureAPI.strcpy,
|
||||||
clang-analyzer-core.StackAddressEscape,
|
|
||||||
clang-analyzer-core.UndefinedBinaryOperatorResult,
|
|
||||||
clang-analyzer-core.VLASize,
|
|
||||||
clang-analyzer-core.uninitialized.ArraySubscript,
|
|
||||||
clang-analyzer-core.uninitialized.Assign,
|
|
||||||
clang-analyzer-core.uninitialized.Branch,
|
|
||||||
clang-analyzer-core.uninitialized.CapturedBlockVariable,
|
|
||||||
clang-analyzer-core.uninitialized.UndefReturn,
|
|
||||||
clang-analyzer-cplusplus.InnerPointer,
|
|
||||||
clang-analyzer-cplusplus.NewDelete,
|
|
||||||
clang-analyzer-cplusplus.NewDeleteLeaks,
|
|
||||||
clang-analyzer-cplusplus.PlacementNewChecker,
|
|
||||||
clang-analyzer-cplusplus.SelfAssignment,
|
|
||||||
clang-analyzer-deadcode.DeadStores,
|
|
||||||
clang-analyzer-optin.cplusplus.VirtualCall,
|
|
||||||
clang-analyzer-security.insecureAPI.UncheckedReturn,
|
|
||||||
clang-analyzer-security.insecureAPI.bcmp,
|
|
||||||
clang-analyzer-security.insecureAPI.bcopy,
|
|
||||||
clang-analyzer-security.insecureAPI.bzero,
|
|
||||||
clang-analyzer-security.insecureAPI.getpw,
|
|
||||||
clang-analyzer-security.insecureAPI.gets,
|
|
||||||
clang-analyzer-security.insecureAPI.mkstemp,
|
|
||||||
clang-analyzer-security.insecureAPI.mktemp,
|
|
||||||
clang-analyzer-security.insecureAPI.rand,
|
|
||||||
clang-analyzer-security.insecureAPI.strcpy,
|
|
||||||
clang-analyzer-unix.Malloc,
|
|
||||||
clang-analyzer-unix.MallocSizeof,
|
|
||||||
clang-analyzer-unix.MismatchedDeallocator,
|
|
||||||
clang-analyzer-unix.Vfork,
|
|
||||||
clang-analyzer-unix.cstring.BadSizeArg,
|
|
||||||
clang-analyzer-unix.cstring.NullArg,
|
|
||||||
|
|
||||||
boost-use-to-string,
|
-cppcoreguidelines-avoid-c-arrays,
|
||||||
|
-cppcoreguidelines-avoid-goto,
|
||||||
|
-cppcoreguidelines-avoid-magic-numbers,
|
||||||
|
-cppcoreguidelines-avoid-non-const-global-variables,
|
||||||
|
-cppcoreguidelines-explicit-virtual-functions,
|
||||||
|
-cppcoreguidelines-init-variables,
|
||||||
|
-cppcoreguidelines-interfaces-global-init,
|
||||||
|
-cppcoreguidelines-macro-usage,
|
||||||
|
-cppcoreguidelines-narrowing-conversions,
|
||||||
|
-cppcoreguidelines-no-malloc,
|
||||||
|
-cppcoreguidelines-non-private-member-variables-in-classes,
|
||||||
|
-cppcoreguidelines-owning-memory,
|
||||||
|
-cppcoreguidelines-prefer-member-initializer,
|
||||||
|
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||||
|
-cppcoreguidelines-pro-bounds-constant-array-index,
|
||||||
|
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
||||||
|
-cppcoreguidelines-pro-type-const-cast,
|
||||||
|
-cppcoreguidelines-pro-type-cstyle-cast,
|
||||||
|
-cppcoreguidelines-pro-type-member-init,
|
||||||
|
-cppcoreguidelines-pro-type-reinterpret-cast,
|
||||||
|
-cppcoreguidelines-pro-type-static-cast-downcast,
|
||||||
|
-cppcoreguidelines-pro-type-union-access,
|
||||||
|
-cppcoreguidelines-pro-type-vararg,
|
||||||
|
-cppcoreguidelines-slicing,
|
||||||
|
-cppcoreguidelines-special-member-functions,
|
||||||
|
|
||||||
|
-darwin-*,
|
||||||
|
|
||||||
|
-fuchsia-*,
|
||||||
|
|
||||||
|
-google-build-using-namespace,
|
||||||
|
-google-readability-braces-around-statements,
|
||||||
|
-google-readability-casting,
|
||||||
|
-google-readability-function-size,
|
||||||
|
-google-readability-namespace-comments,
|
||||||
|
-google-readability-todo,
|
||||||
|
-google-upgrade-googletest-case,
|
||||||
|
|
||||||
|
-hicpp-avoid-c-arrays,
|
||||||
|
-hicpp-avoid-goto,
|
||||||
|
-hicpp-braces-around-statements,
|
||||||
|
-hicpp-explicit-conversions,
|
||||||
|
-hicpp-function-size,
|
||||||
|
-hicpp-member-init,
|
||||||
|
-hicpp-move-const-arg,
|
||||||
|
-hicpp-multiway-paths-covered,
|
||||||
|
-hicpp-named-parameter,
|
||||||
|
-hicpp-no-array-decay,
|
||||||
|
-hicpp-no-assembler,
|
||||||
|
-hicpp-no-malloc,
|
||||||
|
-hicpp-signed-bitwise,
|
||||||
|
-hicpp-special-member-functions,
|
||||||
|
-hicpp-uppercase-literal-suffix,
|
||||||
|
-hicpp-use-auto,
|
||||||
|
-hicpp-use-emplace,
|
||||||
|
-hicpp-vararg,
|
||||||
|
|
||||||
|
-linuxkernel-*,
|
||||||
|
|
||||||
|
-llvm-*,
|
||||||
|
|
||||||
|
-llvmlibc-*,
|
||||||
|
|
||||||
|
-openmp-*,
|
||||||
|
|
||||||
|
-misc-const-correctness,
|
||||||
|
-misc-no-recursion,
|
||||||
|
-misc-non-private-member-variables-in-classes,
|
||||||
|
|
||||||
|
-modernize-avoid-c-arrays,
|
||||||
|
-modernize-concat-nested-namespaces,
|
||||||
|
-modernize-macro-to-enum,
|
||||||
|
-modernize-pass-by-value,
|
||||||
|
-modernize-return-braced-init-list,
|
||||||
|
-modernize-use-auto,
|
||||||
|
-modernize-use-default-member-init,
|
||||||
|
-modernize-use-emplace,
|
||||||
|
-modernize-use-nodiscard,
|
||||||
|
-modernize-use-override,
|
||||||
|
-modernize-use-trailing-return-type,
|
||||||
|
|
||||||
|
-performance-inefficient-string-concatenation,
|
||||||
|
-performance-no-int-to-ptr,
|
||||||
|
-performance-unnecessary-value-param,
|
||||||
|
|
||||||
|
-portability-simd-intrinsics,
|
||||||
|
|
||||||
|
-readability-braces-around-statements,
|
||||||
|
-readability-else-after-return,
|
||||||
|
-readability-function-cognitive-complexity,
|
||||||
|
-readability-function-size,
|
||||||
|
-readability-identifier-length,
|
||||||
|
-readability-implicit-bool-conversion,
|
||||||
|
-readability-isolate-declaration,
|
||||||
|
-readability-magic-numbers,
|
||||||
|
-readability-named-parameter,
|
||||||
|
-readability-redundant-declaration,
|
||||||
|
-readability-simplify-boolean-expr,
|
||||||
|
-readability-static-accessed-through-instance,
|
||||||
|
-readability-suspicious-call-argument,
|
||||||
|
-readability-uppercase-literal-suffix,
|
||||||
|
-readability-use-anyofallof,
|
||||||
|
|
||||||
|
-zirkon-*,
|
||||||
|
|
||||||
|
-misc-*, # temporarily disabled due to being too slow
|
||||||
|
# also disable checks in other categories which are aliases of checks in misc-*:
|
||||||
|
# https://releases.llvm.org/15.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/list.html
|
||||||
|
-cert-dcl54-cpp, # alias of misc-new-delete-overloads
|
||||||
|
-hicpp-new-delete-operators, # alias of misc-new-delete-overloads
|
||||||
|
-cert-fio38-c, # alias of misc-non-copyable-objects
|
||||||
|
-cert-dcl03-c, # alias of misc-static-assert
|
||||||
|
-hicpp-static-assert, # alias of misc-static-assert
|
||||||
|
-cert-err09-cpp, # alias of misc-throw-by-value-catch-by-reference
|
||||||
|
-cert-err61-cpp, # alias of misc-throw-by-value-catch-by-reference
|
||||||
|
-cppcoreguidelines-c-copy-assignment-signature, # alias of misc-unconventional-assign-operator
|
||||||
|
-cppcoreguidelines-non-private-member-variables-in-classes, # alias of misc-non-private-member-variables-in-classes
|
||||||
'
|
'
|
||||||
|
|
||||||
WarningsAsErrors: '*'
|
WarningsAsErrors: '*'
|
||||||
|
|
||||||
|
# TODO: use dictionary syntax for CheckOptions when minimum clang-tidy level rose to 15
|
||||||
|
# some-check.SomeOption: 'some value'
|
||||||
|
# instead of
|
||||||
|
# - key: some-check.SomeOption
|
||||||
|
# value: 'some value'
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
- key: readability-identifier-naming.ClassCase
|
- key: readability-identifier-naming.ClassCase
|
||||||
value: CamelCase
|
value: CamelCase
|
||||||
@ -205,3 +204,8 @@ CheckOptions:
|
|||||||
value: CamelCase
|
value: CamelCase
|
||||||
- key: modernize-loop-convert.UseCxx20ReverseRanges
|
- key: modernize-loop-convert.UseCxx20ReverseRanges
|
||||||
value: false
|
value: false
|
||||||
|
- key: performance-move-const-arg.CheckTriviallyCopyableMove
|
||||||
|
value: false
|
||||||
|
# Workaround clang-tidy bug: https://github.com/llvm/llvm-project/issues/46097
|
||||||
|
- key: readability-identifier-naming.TypeTemplateParameterIgnoredRegexp
|
||||||
|
value: expr-type
|
||||||
|
1
.exrc
Normal file
1
.exrc
Normal file
@ -0,0 +1 @@
|
|||||||
|
au BufRead,BufNewFile * set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab tags=tags,../tags
|
15
.git-blame-ignore-revs
Normal file
15
.git-blame-ignore-revs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# This is a file that can be used by git-blame to ignore some revisions.
|
||||||
|
# (git 2.23+, released in August 2019)
|
||||||
|
#
|
||||||
|
# Can be configured as follow:
|
||||||
|
#
|
||||||
|
# $ git config blame.ignoreRevsFile .git-blame-ignore-revs
|
||||||
|
#
|
||||||
|
# For more information you can look at git-blame(1) man page.
|
||||||
|
|
||||||
|
# Changed tabs to spaces in code [#CLICKHOUSE-3]
|
||||||
|
137ad95929ee016cc6d3c03bccb5586941c163ff
|
||||||
|
|
||||||
|
# dbms/ → src/
|
||||||
|
# (though it is unlikely that you will see it in blame)
|
||||||
|
06446b4f08a142d6f1bc30664c47ded88ab51782
|
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -1,4 +1,4 @@
|
|||||||
contrib/* linguist-vendored
|
contrib/* linguist-vendored
|
||||||
*.h linguist-language=C++
|
*.h linguist-language=C++
|
||||||
# to avoid frequent conflicts
|
tests/queries/0_stateless/data_json/* binary
|
||||||
tests/queries/0_stateless/arcadia_skip_list.txt text merge=union
|
tests/queries/0_stateless/*.reference -crlf
|
||||||
|
4
.github/CODEOWNERS
vendored
4
.github/CODEOWNERS
vendored
@ -1,3 +1 @@
|
|||||||
docs/* @ClickHouse/docs
|
|
||||||
docs/zh/* @ClickHouse/docs-zh
|
|
||||||
website/* @ClickHouse/docs
|
|
||||||
|
2
.github/ISSUE_TEMPLATE/10_question.md
vendored
2
.github/ISSUE_TEMPLATE/10_question.md
vendored
@ -7,6 +7,6 @@ assignees: ''
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
> Make sure to check documentation https://clickhouse.yandex/docs/en/ first. If the question is concise and probably has a short answer, asking it in Telegram chat https://telegram.me/clickhouse_en is probably the fastest way to find the answer. For more complicated questions, consider asking them on StackOverflow with "clickhouse" tag https://stackoverflow.com/questions/tagged/clickhouse
|
> Make sure to check documentation https://clickhouse.com/docs/en/ first. If the question is concise and probably has a short answer, asking it in [community Slack](https://join.slack.com/t/clickhousedb/shared_invite/zt-1gh9ds7f4-PgDhJAaF8ad5RbWBAAjzFg) is probably the fastest way to find the answer. For more complicated questions, consider asking them on StackOverflow with "clickhouse" tag https://stackoverflow.com/questions/tagged/clickhouse
|
||||||
|
|
||||||
> If you still prefer GitHub issues, remove all this text and ask your question here.
|
> If you still prefer GitHub issues, remove all this text and ask your question here.
|
||||||
|
2
.github/ISSUE_TEMPLATE/50_build-issue.md
vendored
2
.github/ISSUE_TEMPLATE/50_build-issue.md
vendored
@ -7,7 +7,7 @@ assignees: ''
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
> Make sure that `git diff` result is empty and you've just pulled fresh master. Try cleaning up cmake cache. Just in case, official build instructions are published here: https://clickhouse.yandex/docs/en/development/build/
|
> Make sure that `git diff` result is empty and you've just pulled fresh master. Try cleaning up cmake cache. Just in case, official build instructions are published here: https://clickhouse.com/docs/en/development/build/
|
||||||
|
|
||||||
**Operating system**
|
**Operating system**
|
||||||
|
|
||||||
|
4
.github/ISSUE_TEMPLATE/85_bug-report.md
vendored
4
.github/ISSUE_TEMPLATE/85_bug-report.md
vendored
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: Bug report
|
name: Bug report
|
||||||
about: Wrong behaviour (visible to users) in official ClickHouse release.
|
about: Wrong behavior (visible to users) in the official ClickHouse release.
|
||||||
title: ''
|
title: ''
|
||||||
labels: 'potential bug'
|
labels: 'potential bug'
|
||||||
assignees: ''
|
assignees: ''
|
||||||
@ -13,6 +13,8 @@ assignees: ''
|
|||||||
|
|
||||||
> A clear and concise description of what works not as it is supposed to.
|
> A clear and concise description of what works not as it is supposed to.
|
||||||
|
|
||||||
|
> A link to reproducer in [https://fiddle.clickhouse.com/](https://fiddle.clickhouse.com/).
|
||||||
|
|
||||||
**Does it reproduce on recent release?**
|
**Does it reproduce on recent release?**
|
||||||
|
|
||||||
[The list of releases](https://github.com/ClickHouse/ClickHouse/blob/master/utils/list-versions/version_date.tsv)
|
[The list of releases](https://github.com/ClickHouse/ClickHouse/blob/master/utils/list-versions/version_date.tsv)
|
||||||
|
31
.github/ISSUE_TEMPLATE/96_installation-issues.md
vendored
Normal file
31
.github/ISSUE_TEMPLATE/96_installation-issues.md
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
name: Installation issue
|
||||||
|
about: Issue with ClickHouse installation from https://clickhouse.com/docs/en/install/
|
||||||
|
title: ''
|
||||||
|
labels: comp-install
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**I have tried the following solutions**: https://clickhouse.com/docs/en/faq/troubleshooting/#troubleshooting-installation-errors
|
||||||
|
|
||||||
|
**Installation type**
|
||||||
|
|
||||||
|
Packages, docker, single binary, curl?
|
||||||
|
|
||||||
|
**Source of the ClickHouse**
|
||||||
|
|
||||||
|
A link to the source. Or the command you've tried
|
||||||
|
|
||||||
|
**Expected result**
|
||||||
|
|
||||||
|
What you expected
|
||||||
|
|
||||||
|
**The actual result**
|
||||||
|
|
||||||
|
What you get
|
||||||
|
|
||||||
|
**How to reproduce**
|
||||||
|
|
||||||
|
* For Linux-based operating systems: provide a script for clear docker container from the official image
|
||||||
|
* For anything else: steps to reproduce on as much as possible clear system
|
38
.github/PULL_REQUEST_TEMPLATE.md
vendored
38
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,7 +1,13 @@
|
|||||||
Changelog category (leave one):
|
<!---
|
||||||
|
A technical comment, you are free to remove or leave it as it is when PR is created
|
||||||
|
The following categories are used in the next scripts, update them accordingly
|
||||||
|
utils/changelog/changelog.py
|
||||||
|
tests/ci/run_check.py
|
||||||
|
-->
|
||||||
|
### Changelog category (leave one):
|
||||||
- New Feature
|
- New Feature
|
||||||
- Improvement
|
- Improvement
|
||||||
- Bug Fix (user-visible misbehaviour in official stable or prestable release)
|
- Bug Fix (user-visible misbehavior in official stable or prestable release)
|
||||||
- Performance Improvement
|
- Performance Improvement
|
||||||
- Backward Incompatible Change
|
- Backward Incompatible Change
|
||||||
- Build/Testing/Packaging Improvement
|
- Build/Testing/Packaging Improvement
|
||||||
@ -9,17 +15,27 @@ Changelog category (leave one):
|
|||||||
- Not for changelog (changelog entry is not required)
|
- Not for changelog (changelog entry is not required)
|
||||||
|
|
||||||
|
|
||||||
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
|
### Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
### Documentation entry for user-facing changes
|
||||||
|
|
||||||
Detailed description / Documentation draft:
|
- [ ] Documentation is written (mandatory for new features)
|
||||||
...
|
|
||||||
|
<!---
|
||||||
|
Directly edit documentation source files in the "docs" folder with the same pull-request as code changes
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
Add a user-readable short description of the changes that should be added to docs.clickhouse.com below.
|
||||||
|
|
||||||
|
At a minimum, the following information should be added (but add more as needed).
|
||||||
|
- Motivation: Why is this function, table engine, etc. useful to ClickHouse users?
|
||||||
|
|
||||||
|
- Parameters: If the feature being added takes arguments, options or is influenced by settings, please list them below with a brief explanation.
|
||||||
|
|
||||||
|
- Example use: A query or command.
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
> By adding documentation, you'll allow users to try your new feature immediately, not when someone else will have time to document it later. Documentation is necessary for all features that affect user experience in any way. You can add brief documentation draft above, or add documentation right into your patch as Markdown files in [docs](https://github.com/ClickHouse/ClickHouse/tree/master/docs) folder.
|
> Information about CI checks: https://clickhouse.com/docs/en/development/continuous-integration/
|
||||||
|
|
||||||
> If you are doing this for the first time, it's recommended to read the lightweight [Contributing to ClickHouse Documentation](https://github.com/ClickHouse/ClickHouse/tree/master/docs/README.md) guide first.
|
|
||||||
|
|
||||||
|
|
||||||
> Information about CI checks: https://clickhouse.tech/docs/en/development/continuous-integration/
|
|
||||||
|
9
.github/actionlint.yml
vendored
Normal file
9
.github/actionlint.yml
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
self-hosted-runner:
|
||||||
|
labels:
|
||||||
|
- builder
|
||||||
|
- func-tester
|
||||||
|
- func-tester-aarch64
|
||||||
|
- fuzzer-unit-tester
|
||||||
|
- stress-tester
|
||||||
|
- style-checker
|
||||||
|
- style-checker-aarch64
|
17
.github/codecov.yml
vendored
17
.github/codecov.yml
vendored
@ -1,17 +0,0 @@
|
|||||||
codecov:
|
|
||||||
max_report_age: "off"
|
|
||||||
strict_yaml_branch: "master"
|
|
||||||
|
|
||||||
ignore:
|
|
||||||
- "contrib"
|
|
||||||
- "docs"
|
|
||||||
- "benchmark"
|
|
||||||
- "tests"
|
|
||||||
- "docker"
|
|
||||||
- "debian"
|
|
||||||
- "cmake"
|
|
||||||
|
|
||||||
comment: false
|
|
||||||
|
|
||||||
github_checks:
|
|
||||||
annotations: false
|
|
39
.github/workflows/anchore-analysis.yml
vendored
39
.github/workflows/anchore-analysis.yml
vendored
@ -1,39 +0,0 @@
|
|||||||
# This workflow checks out code, performs an Anchore container image
|
|
||||||
# vulnerability and compliance scan, and integrates the results with
|
|
||||||
# GitHub Advanced Security code scanning feature. For more information on
|
|
||||||
# the Anchore scan action usage and parameters, see
|
|
||||||
# https://github.com/anchore/scan-action. For more information on
|
|
||||||
# Anchore container image scanning in general, see
|
|
||||||
# https://docs.anchore.com.
|
|
||||||
|
|
||||||
name: Docker Container Scan (clickhouse-server)
|
|
||||||
|
|
||||||
"on":
|
|
||||||
pull_request:
|
|
||||||
paths:
|
|
||||||
- docker/server/Dockerfile
|
|
||||||
- .github/workflows/anchore-analysis.yml
|
|
||||||
schedule:
|
|
||||||
- cron: '0 21 * * *'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
Anchore-Build-Scan:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout the code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Build the Docker image
|
|
||||||
run: |
|
|
||||||
cd docker/server
|
|
||||||
perl -pi -e 's|=\$version||g' Dockerfile
|
|
||||||
docker build . --file Dockerfile --tag localbuild/testimage:latest
|
|
||||||
- name: Run the local Anchore scan action itself with GitHub Advanced Security code scanning integration enabled
|
|
||||||
uses: anchore/scan-action@v2
|
|
||||||
id: scan
|
|
||||||
with:
|
|
||||||
image: "localbuild/testimage:latest"
|
|
||||||
acs-report-enable: true
|
|
||||||
- name: Upload Anchore Scan Report
|
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
|
||||||
with:
|
|
||||||
sarif_file: ${{ steps.scan.outputs.sarif }}
|
|
755
.github/workflows/backport_branches.yml
vendored
Normal file
755
.github/workflows/backport_branches.yml
vendored
Normal file
@ -0,0 +1,755 @@
|
|||||||
|
name: BackportPR
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Force the stdout and stderr streams to be unbuffered
|
||||||
|
PYTHONUNBUFFERED: 1
|
||||||
|
|
||||||
|
on: # yamllint disable-line rule:truthy
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'backport/**'
|
||||||
|
jobs:
|
||||||
|
PythonUnitTests:
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Python unit tests
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 -m unittest discover -s . -p '*_test.py'
|
||||||
|
DockerHubPushAarch64:
|
||||||
|
runs-on: [self-hosted, style-checker-aarch64]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Images check
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 docker_images_check.py --suffix aarch64
|
||||||
|
- name: Upload images files to artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images_aarch64
|
||||||
|
path: ${{ runner.temp }}/docker_images_check/changed_images_aarch64.json
|
||||||
|
DockerHubPushAmd64:
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Images check
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 docker_images_check.py --suffix amd64
|
||||||
|
- name: Upload images files to artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images_amd64
|
||||||
|
path: ${{ runner.temp }}/docker_images_check/changed_images_amd64.json
|
||||||
|
DockerHubPush:
|
||||||
|
needs: [DockerHubPushAmd64, DockerHubPushAarch64]
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Download changed aarch64 images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images_aarch64
|
||||||
|
path: ${{ runner.temp }}
|
||||||
|
- name: Download changed amd64 images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images_amd64
|
||||||
|
path: ${{ runner.temp }}
|
||||||
|
- name: Images check
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 docker_manifests_merge.py --suffix amd64 --suffix aarch64
|
||||||
|
- name: Upload images files to artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images
|
||||||
|
path: ${{ runner.temp }}/changed_images.json
|
||||||
|
CompatibilityCheck:
|
||||||
|
needs: [BuilderDebRelease]
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/compatibility_check
|
||||||
|
REPO_COPY=${{runner.temp}}/compatibility_check/ClickHouse
|
||||||
|
REPORTS_PATH=${{runner.temp}}/reports_dir
|
||||||
|
EOF
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Download json reports
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
path: ${{ env.REPORTS_PATH }}
|
||||||
|
- name: CompatibilityCheck
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci" && python3 compatibility_check.py
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
#########################################################################################
|
||||||
|
#################################### ORDINARY BUILDS ####################################
|
||||||
|
#########################################################################################
|
||||||
|
BuilderDebRelease:
|
||||||
|
needs: [DockerHubPush]
|
||||||
|
runs-on: [self-hosted, builder]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/build_check
|
||||||
|
IMAGES_PATH=${{runner.temp}}/images_path
|
||||||
|
REPO_COPY=${{runner.temp}}/build_check/ClickHouse
|
||||||
|
CACHES_PATH=${{runner.temp}}/../ccaches
|
||||||
|
BUILD_NAME=package_release
|
||||||
|
EOF
|
||||||
|
- name: Download changed images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images
|
||||||
|
path: ${{ env.IMAGES_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
submodules: true
|
||||||
|
fetch-depth: 0 # For a proper version and performance artifacts
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci" && python3 build_check.py "$BUILD_NAME"
|
||||||
|
- name: Upload build URLs to artifacts
|
||||||
|
if: ${{ success() || failure() }}
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ${{ env.BUILD_URLS }}
|
||||||
|
path: ${{ env.TEMP_PATH }}/${{ env.BUILD_URLS }}.json
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH" "$CACHES_PATH"
|
||||||
|
BuilderDebAarch64:
|
||||||
|
needs: [DockerHubPush]
|
||||||
|
runs-on: [self-hosted, builder]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/build_check
|
||||||
|
IMAGES_PATH=${{runner.temp}}/images_path
|
||||||
|
REPO_COPY=${{runner.temp}}/build_check/ClickHouse
|
||||||
|
CACHES_PATH=${{runner.temp}}/../ccaches
|
||||||
|
BUILD_NAME=package_aarch64
|
||||||
|
EOF
|
||||||
|
- name: Download changed images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images
|
||||||
|
path: ${{ env.IMAGES_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
submodules: true
|
||||||
|
fetch-depth: 0 # For a proper version and performance artifacts
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci" && python3 build_check.py "$BUILD_NAME"
|
||||||
|
- name: Upload build URLs to artifacts
|
||||||
|
if: ${{ success() || failure() }}
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ${{ env.BUILD_URLS }}
|
||||||
|
path: ${{ env.TEMP_PATH }}/${{ env.BUILD_URLS }}.json
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH" "$CACHES_PATH"
|
||||||
|
BuilderDebAsan:
|
||||||
|
needs: [DockerHubPush]
|
||||||
|
runs-on: [self-hosted, builder]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/build_check
|
||||||
|
IMAGES_PATH=${{runner.temp}}/images_path
|
||||||
|
REPO_COPY=${{runner.temp}}/build_check/ClickHouse
|
||||||
|
CACHES_PATH=${{runner.temp}}/../ccaches
|
||||||
|
BUILD_NAME=package_asan
|
||||||
|
EOF
|
||||||
|
- name: Download changed images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images
|
||||||
|
path: ${{ env.IMAGES_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
submodules: true
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci" && python3 build_check.py "$BUILD_NAME"
|
||||||
|
- name: Upload build URLs to artifacts
|
||||||
|
if: ${{ success() || failure() }}
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ${{ env.BUILD_URLS }}
|
||||||
|
path: ${{ env.TEMP_PATH }}/${{ env.BUILD_URLS }}.json
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH" "$CACHES_PATH"
|
||||||
|
BuilderDebTsan:
|
||||||
|
needs: [DockerHubPush]
|
||||||
|
runs-on: [self-hosted, builder]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/build_check
|
||||||
|
IMAGES_PATH=${{runner.temp}}/images_path
|
||||||
|
REPO_COPY=${{runner.temp}}/build_check/ClickHouse
|
||||||
|
CACHES_PATH=${{runner.temp}}/../ccaches
|
||||||
|
BUILD_NAME=package_tsan
|
||||||
|
EOF
|
||||||
|
- name: Download changed images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images
|
||||||
|
path: ${{ env.IMAGES_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
submodules: true
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci" && python3 build_check.py "$BUILD_NAME"
|
||||||
|
- name: Upload build URLs to artifacts
|
||||||
|
if: ${{ success() || failure() }}
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ${{ env.BUILD_URLS }}
|
||||||
|
path: ${{ env.TEMP_PATH }}/${{ env.BUILD_URLS }}.json
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH" "$CACHES_PATH"
|
||||||
|
BuilderDebDebug:
|
||||||
|
needs: [DockerHubPush]
|
||||||
|
runs-on: [self-hosted, builder]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/build_check
|
||||||
|
IMAGES_PATH=${{runner.temp}}/images_path
|
||||||
|
REPO_COPY=${{runner.temp}}/build_check/ClickHouse
|
||||||
|
CACHES_PATH=${{runner.temp}}/../ccaches
|
||||||
|
BUILD_NAME=package_debug
|
||||||
|
EOF
|
||||||
|
- name: Download changed images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images
|
||||||
|
path: ${{ env.IMAGES_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
submodules: true
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci" && python3 build_check.py "$BUILD_NAME"
|
||||||
|
- name: Upload build URLs to artifacts
|
||||||
|
if: ${{ success() || failure() }}
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ${{ env.BUILD_URLS }}
|
||||||
|
path: ${{ env.TEMP_PATH }}/${{ env.BUILD_URLS }}.json
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH" "$CACHES_PATH"
|
||||||
|
BuilderBinDarwin:
|
||||||
|
needs: [DockerHubPush]
|
||||||
|
runs-on: [self-hosted, builder]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/build_check
|
||||||
|
IMAGES_PATH=${{runner.temp}}/images_path
|
||||||
|
REPO_COPY=${{runner.temp}}/build_check/ClickHouse
|
||||||
|
CACHES_PATH=${{runner.temp}}/../ccaches
|
||||||
|
BUILD_NAME=binary_darwin
|
||||||
|
EOF
|
||||||
|
- name: Download changed images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images
|
||||||
|
path: ${{ env.IMAGES_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
submodules: true
|
||||||
|
fetch-depth: 0 # otherwise we will have no info about contributors
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci" && python3 build_check.py "$BUILD_NAME"
|
||||||
|
- name: Upload build URLs to artifacts
|
||||||
|
if: ${{ success() || failure() }}
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ${{ env.BUILD_URLS }}
|
||||||
|
path: ${{ env.TEMP_PATH }}/${{ env.BUILD_URLS }}.json
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH" "$CACHES_PATH"
|
||||||
|
BuilderBinDarwinAarch64:
|
||||||
|
needs: [DockerHubPush]
|
||||||
|
runs-on: [self-hosted, builder]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/build_check
|
||||||
|
IMAGES_PATH=${{runner.temp}}/images_path
|
||||||
|
REPO_COPY=${{runner.temp}}/build_check/ClickHouse
|
||||||
|
CACHES_PATH=${{runner.temp}}/../ccaches
|
||||||
|
BUILD_NAME=binary_darwin_aarch64
|
||||||
|
EOF
|
||||||
|
- name: Download changed images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images
|
||||||
|
path: ${{ env.IMAGES_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
submodules: true
|
||||||
|
fetch-depth: 0 # otherwise we will have no info about contributors
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci" && python3 build_check.py "$BUILD_NAME"
|
||||||
|
- name: Upload build URLs to artifacts
|
||||||
|
if: ${{ success() || failure() }}
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ${{ env.BUILD_URLS }}
|
||||||
|
path: ${{ env.TEMP_PATH }}/${{ env.BUILD_URLS }}.json
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH" "$CACHES_PATH"
|
||||||
|
############################################################################################
|
||||||
|
##################################### Docker images #######################################
|
||||||
|
############################################################################################
|
||||||
|
DockerServerImages:
|
||||||
|
needs:
|
||||||
|
- BuilderDebRelease
|
||||||
|
- BuilderDebAarch64
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
fetch-depth: 0 # It MUST BE THE SAME for all dependencies and the job itself
|
||||||
|
- name: Check docker clickhouse/clickhouse-server building
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 docker_server.py --release-type head --no-push
|
||||||
|
python3 docker_server.py --release-type head --no-push --no-ubuntu \
|
||||||
|
--image-repo clickhouse/clickhouse-keeper --image-path docker/keeper
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
############################################################################################
|
||||||
|
##################################### BUILD REPORTER #######################################
|
||||||
|
############################################################################################
|
||||||
|
BuilderReport:
|
||||||
|
needs:
|
||||||
|
- BuilderDebRelease
|
||||||
|
- BuilderDebAarch64
|
||||||
|
- BuilderDebAsan
|
||||||
|
- BuilderDebTsan
|
||||||
|
- BuilderDebDebug
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
if: ${{ success() || failure() }}
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
CHECK_NAME=ClickHouse build check
|
||||||
|
REPORTS_PATH=${{runner.temp}}/reports_dir
|
||||||
|
TEMP_PATH=${{runner.temp}}/report_check
|
||||||
|
NEEDS_DATA_PATH=${{runner.temp}}/needs.json
|
||||||
|
EOF
|
||||||
|
- name: Download json reports
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
path: ${{ env.REPORTS_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Report Builder
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cat > "$NEEDS_DATA_PATH" << 'EOF'
|
||||||
|
${{ toJSON(needs) }}
|
||||||
|
EOF
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 build_report_check.py "$CHECK_NAME"
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
BuilderSpecialReport:
|
||||||
|
needs:
|
||||||
|
- BuilderBinDarwin
|
||||||
|
- BuilderBinDarwinAarch64
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
if: ${{ success() || failure() }}
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/report_check
|
||||||
|
REPORTS_PATH=${{runner.temp}}/reports_dir
|
||||||
|
CHECK_NAME=ClickHouse special build check
|
||||||
|
NEEDS_DATA_PATH=${{runner.temp}}/needs.json
|
||||||
|
EOF
|
||||||
|
- name: Download json reports
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
path: ${{ env.REPORTS_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Report Builder
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cat > "$NEEDS_DATA_PATH" << 'EOF'
|
||||||
|
${{ toJSON(needs) }}
|
||||||
|
EOF
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 build_report_check.py "$CHECK_NAME"
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
############################################################################################
|
||||||
|
#################################### INSTALL PACKAGES ######################################
|
||||||
|
############################################################################################
|
||||||
|
InstallPackagesTestRelease:
|
||||||
|
needs: [BuilderDebRelease]
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/test_install
|
||||||
|
REPORTS_PATH=${{runner.temp}}/reports_dir
|
||||||
|
CHECK_NAME=Install packages (amd64)
|
||||||
|
REPO_COPY=${{runner.temp}}/test_install/ClickHouse
|
||||||
|
EOF
|
||||||
|
- name: Download json reports
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
path: ${{ env.REPORTS_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Test packages installation
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci"
|
||||||
|
python3 install_check.py "$CHECK_NAME"
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
InstallPackagesTestAarch64:
|
||||||
|
needs: [BuilderDebRelease]
|
||||||
|
runs-on: [self-hosted, style-checker-aarch64]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/test_install
|
||||||
|
REPORTS_PATH=${{runner.temp}}/reports_dir
|
||||||
|
CHECK_NAME=Install packages (arm64)
|
||||||
|
REPO_COPY=${{runner.temp}}/test_install/ClickHouse
|
||||||
|
EOF
|
||||||
|
- name: Download json reports
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
path: ${{ env.REPORTS_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Test packages installation
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci"
|
||||||
|
python3 install_check.py "$CHECK_NAME"
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
##############################################################################################
|
||||||
|
########################### FUNCTIONAl STATELESS TESTS #######################################
|
||||||
|
##############################################################################################
|
||||||
|
FunctionalStatelessTestAsan:
|
||||||
|
needs: [BuilderDebAsan]
|
||||||
|
runs-on: [self-hosted, func-tester]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/stateless_debug
|
||||||
|
REPORTS_PATH=${{runner.temp}}/reports_dir
|
||||||
|
CHECK_NAME=Stateless tests (asan)
|
||||||
|
REPO_COPY=${{runner.temp}}/stateless_debug/ClickHouse
|
||||||
|
KILL_TIMEOUT=10800
|
||||||
|
EOF
|
||||||
|
- name: Download json reports
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
path: ${{ env.REPORTS_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Functional test
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci"
|
||||||
|
python3 functional_test_check.py "$CHECK_NAME" "$KILL_TIMEOUT"
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
##############################################################################################
|
||||||
|
############################ FUNCTIONAl STATEFUL TESTS #######################################
|
||||||
|
##############################################################################################
|
||||||
|
FunctionalStatefulTestDebug:
|
||||||
|
needs: [BuilderDebDebug]
|
||||||
|
runs-on: [self-hosted, func-tester]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/stateful_debug
|
||||||
|
REPORTS_PATH=${{runner.temp}}/reports_dir
|
||||||
|
CHECK_NAME=Stateful tests (debug)
|
||||||
|
REPO_COPY=${{runner.temp}}/stateful_debug/ClickHouse
|
||||||
|
KILL_TIMEOUT=3600
|
||||||
|
EOF
|
||||||
|
- name: Download json reports
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
path: ${{ env.REPORTS_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Functional test
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci"
|
||||||
|
python3 functional_test_check.py "$CHECK_NAME" "$KILL_TIMEOUT"
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
##############################################################################################
|
||||||
|
######################################### STRESS TESTS #######################################
|
||||||
|
##############################################################################################
|
||||||
|
StressTestTsan:
|
||||||
|
needs: [BuilderDebTsan]
|
||||||
|
# func testers have 16 cores + 128 GB memory
|
||||||
|
# while stress testers have 36 cores + 72 memory
|
||||||
|
# It would be better to have something like 32 + 128,
|
||||||
|
# but such servers almost unavailable as spot instances.
|
||||||
|
runs-on: [self-hosted, func-tester]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/stress_thread
|
||||||
|
REPORTS_PATH=${{runner.temp}}/reports_dir
|
||||||
|
CHECK_NAME=Stress test (tsan)
|
||||||
|
REPO_COPY=${{runner.temp}}/stress_thread/ClickHouse
|
||||||
|
EOF
|
||||||
|
- name: Download json reports
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
path: ${{ env.REPORTS_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Stress test
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci"
|
||||||
|
python3 stress_check.py "$CHECK_NAME"
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
#############################################################################################
|
||||||
|
############################# INTEGRATION TESTS #############################################
|
||||||
|
#############################################################################################
|
||||||
|
IntegrationTestsRelease:
|
||||||
|
needs: [BuilderDebRelease]
|
||||||
|
runs-on: [self-hosted, stress-tester]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/integration_tests_release
|
||||||
|
REPORTS_PATH=${{runner.temp}}/reports_dir
|
||||||
|
CHECK_NAME=Integration tests (release)
|
||||||
|
REPO_COPY=${{runner.temp}}/integration_tests_release/ClickHouse
|
||||||
|
EOF
|
||||||
|
- name: Download json reports
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
path: ${{ env.REPORTS_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Integration test
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci"
|
||||||
|
python3 integration_test_check.py "$CHECK_NAME"
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
FinishCheck:
|
||||||
|
needs:
|
||||||
|
- DockerHubPush
|
||||||
|
- DockerServerImages
|
||||||
|
- BuilderReport
|
||||||
|
- BuilderSpecialReport
|
||||||
|
- FunctionalStatelessTestAsan
|
||||||
|
- FunctionalStatefulTestDebug
|
||||||
|
- StressTestTsan
|
||||||
|
- IntegrationTestsRelease
|
||||||
|
- CompatibilityCheck
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Finish label
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 finish_check.py
|
||||||
|
python3 merge_pr.py
|
8
.github/workflows/cancel.yml
vendored
8
.github/workflows/cancel.yml
vendored
@ -1,7 +1,12 @@
|
|||||||
name: Cancel
|
name: Cancel
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Force the stdout and stderr streams to be unbuffered
|
||||||
|
PYTHONUNBUFFERED: 1
|
||||||
|
|
||||||
on: # yamllint disable-line rule:truthy
|
on: # yamllint disable-line rule:truthy
|
||||||
workflow_run:
|
workflow_run:
|
||||||
workflows: ["CIGithubActions"]
|
workflows: ["PullRequestCI", "ReleaseBranchCI", "DocsCheck", "BackportPR"]
|
||||||
types:
|
types:
|
||||||
- requested
|
- requested
|
||||||
jobs:
|
jobs:
|
||||||
@ -10,4 +15,5 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: styfle/cancel-workflow-action@0.9.1
|
- uses: styfle/cancel-workflow-action@0.9.1
|
||||||
with:
|
with:
|
||||||
|
all_but_latest: true
|
||||||
workflow_id: ${{ github.event.workflow.id }}
|
workflow_id: ${{ github.event.workflow.id }}
|
||||||
|
46
.github/workflows/cherry_pick.yml
vendored
Normal file
46
.github/workflows/cherry_pick.yml
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
name: CherryPick
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Force the stdout and stderr streams to be unbuffered
|
||||||
|
PYTHONUNBUFFERED: 1
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: cherry-pick
|
||||||
|
on: # yamllint disable-line rule:truthy
|
||||||
|
schedule:
|
||||||
|
- cron: '0 * * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
CherryPick:
|
||||||
|
runs-on: [self-hosted, style-checker-aarch64]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#multiline-strings
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/cherry_pick
|
||||||
|
ROBOT_CLICKHOUSE_SSH_KEY<<RCSK
|
||||||
|
${{secrets.ROBOT_CLICKHOUSE_SSH_KEY}}
|
||||||
|
RCSK
|
||||||
|
REPO_OWNER=ClickHouse
|
||||||
|
REPO_NAME=ClickHouse
|
||||||
|
REPO_TEAM=core
|
||||||
|
EOF
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
token: ${{secrets.ROBOT_CLICKHOUSE_COMMIT_TOKEN}}
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Cherry pick
|
||||||
|
run: |
|
||||||
|
sudo pip install GitPython
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 cherry_pick.py
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
11
.github/workflows/debug.yml
vendored
Normal file
11
.github/workflows/debug.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# The CI for each commit, prints envs and content of GITHUB_EVENT_PATH
|
||||||
|
name: Debug
|
||||||
|
|
||||||
|
'on':
|
||||||
|
[push, pull_request, release, workflow_dispatch, workflow_call]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
DebugInfo:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: hmarr/debug-action@a701ed95a46e6f2fb0df25e1a558c16356fae35a
|
172
.github/workflows/docs_check.yml
vendored
Normal file
172
.github/workflows/docs_check.yml
vendored
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
name: DocsCheck
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Force the stdout and stderr streams to be unbuffered
|
||||||
|
PYTHONUNBUFFERED: 1
|
||||||
|
|
||||||
|
on: # yamllint disable-line rule:truthy
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- opened
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths:
|
||||||
|
- 'docker/docs/**'
|
||||||
|
- 'docs/**'
|
||||||
|
- 'website/**'
|
||||||
|
- 'utils/check-style/aspell-ignore/**'
|
||||||
|
jobs:
|
||||||
|
CheckLabels:
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Labels check
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 run_check.py
|
||||||
|
DockerHubPushAarch64:
|
||||||
|
needs: CheckLabels
|
||||||
|
runs-on: [self-hosted, style-checker-aarch64]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Images check
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 docker_images_check.py --suffix aarch64
|
||||||
|
- name: Upload images files to artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images_aarch64
|
||||||
|
path: ${{ runner.temp }}/docker_images_check/changed_images_aarch64.json
|
||||||
|
DockerHubPushAmd64:
|
||||||
|
needs: CheckLabels
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Images check
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 docker_images_check.py --suffix amd64
|
||||||
|
- name: Upload images files to artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images_amd64
|
||||||
|
path: ${{ runner.temp }}/docker_images_check/changed_images_amd64.json
|
||||||
|
DockerHubPush:
|
||||||
|
needs: [DockerHubPushAmd64, DockerHubPushAarch64]
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Download changed aarch64 images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images_aarch64
|
||||||
|
path: ${{ runner.temp }}
|
||||||
|
- name: Download changed amd64 images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images_amd64
|
||||||
|
path: ${{ runner.temp }}
|
||||||
|
- name: Images check
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 docker_manifests_merge.py --suffix amd64 --suffix aarch64
|
||||||
|
- name: Upload images files to artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images
|
||||||
|
path: ${{ runner.temp }}/changed_images.json
|
||||||
|
StyleCheck:
|
||||||
|
needs: DockerHubPush
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
if: ${{ success() || failure() }}
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{ runner.temp }}/style_check
|
||||||
|
ROBOT_CLICKHOUSE_SSH_KEY<<RCSK
|
||||||
|
${{secrets.ROBOT_CLICKHOUSE_SSH_KEY}}
|
||||||
|
RCSK
|
||||||
|
EOF
|
||||||
|
- name: Download changed images
|
||||||
|
# even if artifact does not exist, e.g. on `do not test` label or failed Docker job
|
||||||
|
continue-on-error: true
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images
|
||||||
|
path: ${{ env.TEMP_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Style Check
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 style_check.py
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
DocsCheck:
|
||||||
|
needs: DockerHubPush
|
||||||
|
runs-on: [self-hosted, func-tester-aarch64]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/docs_check
|
||||||
|
REPO_COPY=${{runner.temp}}/docs_check/ClickHouse
|
||||||
|
EOF
|
||||||
|
- name: Download changed images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images
|
||||||
|
path: ${{ env.TEMP_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Docs Check
|
||||||
|
run: |
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci"
|
||||||
|
python3 docs_check.py
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
FinishCheck:
|
||||||
|
needs:
|
||||||
|
- StyleCheck
|
||||||
|
- DockerHubPush
|
||||||
|
- DocsCheck
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Finish label
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 finish_check.py
|
||||||
|
python3 merge_pr.py --check-approved
|
118
.github/workflows/docs_release.yml
vendored
Normal file
118
.github/workflows/docs_release.yml
vendored
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
name: DocsReleaseChecks
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Force the stdout and stderr streams to be unbuffered
|
||||||
|
PYTHONUNBUFFERED: 1
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: master-release
|
||||||
|
cancel-in-progress: true
|
||||||
|
'on':
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths:
|
||||||
|
- '.github/**'
|
||||||
|
- 'docker/docs/release/**'
|
||||||
|
- 'docs/**'
|
||||||
|
- 'utils/list-versions/version_date.tsv'
|
||||||
|
- 'website/**'
|
||||||
|
- 'utils/check-style/aspell-ignore/**'
|
||||||
|
workflow_dispatch:
|
||||||
|
jobs:
|
||||||
|
DockerHubPushAarch64:
|
||||||
|
runs-on: [self-hosted, style-checker-aarch64]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Images check
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 docker_images_check.py --suffix aarch64
|
||||||
|
- name: Upload images files to artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images_aarch64
|
||||||
|
path: ${{ runner.temp }}/docker_images_check/changed_images_aarch64.json
|
||||||
|
DockerHubPushAmd64:
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Images check
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 docker_images_check.py --suffix amd64
|
||||||
|
- name: Upload images files to artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images_amd64
|
||||||
|
path: ${{ runner.temp }}/docker_images_check/changed_images_amd64.json
|
||||||
|
DockerHubPush:
|
||||||
|
needs: [DockerHubPushAmd64, DockerHubPushAarch64]
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Download changed aarch64 images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images_aarch64
|
||||||
|
path: ${{ runner.temp }}
|
||||||
|
- name: Download changed amd64 images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images_amd64
|
||||||
|
path: ${{ runner.temp }}
|
||||||
|
- name: Images check
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 docker_manifests_merge.py --suffix amd64 --suffix aarch64
|
||||||
|
- name: Upload images files to artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images
|
||||||
|
path: ${{ runner.temp }}/changed_images.json
|
||||||
|
DocsRelease:
|
||||||
|
needs: DockerHubPush
|
||||||
|
runs-on: [self-hosted, func-tester]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#multiline-strings
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/docs_release
|
||||||
|
REPO_COPY=${{runner.temp}}/docs_release/ClickHouse
|
||||||
|
CLOUDFLARE_TOKEN=${{secrets.CLOUDFLARE}}
|
||||||
|
ROBOT_CLICKHOUSE_SSH_KEY<<RCSK
|
||||||
|
${{secrets.ROBOT_CLICKHOUSE_SSH_KEY}}
|
||||||
|
RCSK
|
||||||
|
EOF
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Download changed images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images
|
||||||
|
path: ${{ env.TEMP_PATH }}
|
||||||
|
- name: Docs Release
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci"
|
||||||
|
python3 docs_release.py
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
68
.github/workflows/jepsen.yml
vendored
Normal file
68
.github/workflows/jepsen.yml
vendored
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
name: JepsenWorkflow
|
||||||
|
env:
|
||||||
|
# Force the stdout and stderr streams to be unbuffered
|
||||||
|
PYTHONUNBUFFERED: 1
|
||||||
|
concurrency:
|
||||||
|
group: jepsen
|
||||||
|
on: # yamllint disable-line rule:truthy
|
||||||
|
schedule:
|
||||||
|
- cron: '0 */6 * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
workflow_call:
|
||||||
|
jobs:
|
||||||
|
KeeperJepsenRelease:
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/keeper_jepsen
|
||||||
|
REPO_COPY=${{runner.temp}}/keeper_jepsen/ClickHouse
|
||||||
|
EOF
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Jepsen Test
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci"
|
||||||
|
python3 jepsen_check.py keeper
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
# ServerJepsenRelease:
|
||||||
|
# runs-on: [self-hosted, style-checker]
|
||||||
|
# if: ${{ always() }}
|
||||||
|
# needs: [KeeperJepsenRelease]
|
||||||
|
# steps:
|
||||||
|
# - name: Set envs
|
||||||
|
# run: |
|
||||||
|
# cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
# TEMP_PATH=${{runner.temp}}/server_jepsen
|
||||||
|
# REPO_COPY=${{runner.temp}}/server_jepsen/ClickHouse
|
||||||
|
# EOF
|
||||||
|
# - name: Check out repository code
|
||||||
|
# uses: ClickHouse/checkout@v1
|
||||||
|
# with:
|
||||||
|
# clear-repository: true
|
||||||
|
# fetch-depth: 0
|
||||||
|
# - name: Jepsen Test
|
||||||
|
# run: |
|
||||||
|
# sudo rm -fr "$TEMP_PATH"
|
||||||
|
# mkdir -p "$TEMP_PATH"
|
||||||
|
# cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
# cd "$REPO_COPY/tests/ci"
|
||||||
|
# python3 jepsen_check.py server
|
||||||
|
# - name: Cleanup
|
||||||
|
# if: always()
|
||||||
|
# run: |
|
||||||
|
# docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
# docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
# sudo rm -fr "$TEMP_PATH"
|
300
.github/workflows/main.yml
vendored
300
.github/workflows/main.yml
vendored
@ -1,300 +0,0 @@
|
|||||||
name: CIGithubActions
|
|
||||||
on: # yamllint disable-line rule:truthy
|
|
||||||
pull_request:
|
|
||||||
types:
|
|
||||||
- labeled
|
|
||||||
- unlabeled
|
|
||||||
- synchronize
|
|
||||||
- reopened
|
|
||||||
- opened
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
jobs:
|
|
||||||
CheckLabels:
|
|
||||||
runs-on: [self-hosted, style-checker]
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Labels check
|
|
||||||
run: |
|
|
||||||
cd $GITHUB_WORKSPACE/tests/ci
|
|
||||||
python3 run_check.py
|
|
||||||
DockerHubPush:
|
|
||||||
needs: CheckLabels
|
|
||||||
runs-on: [self-hosted, style-checker]
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Images check
|
|
||||||
run: |
|
|
||||||
cd $GITHUB_WORKSPACE/tests/ci
|
|
||||||
python3 docker_images_check.py
|
|
||||||
- name: Upload images files to artifacts
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: changed_images
|
|
||||||
path: ${{ runner.temp }}/docker_images_check/changed_images.json
|
|
||||||
StyleCheck:
|
|
||||||
needs: DockerHubPush
|
|
||||||
runs-on: [self-hosted, style-checker]
|
|
||||||
steps:
|
|
||||||
- name: Download changed images
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: changed_images
|
|
||||||
path: ${{ runner.temp }}/style_check
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Style Check
|
|
||||||
env:
|
|
||||||
TEMP_PATH: ${{ runner.temp }}/style_check
|
|
||||||
run: |
|
|
||||||
cd $GITHUB_WORKSPACE/tests/ci
|
|
||||||
python3 style_check.py
|
|
||||||
- name: Cleanup
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
docker kill $(docker ps -q) ||:
|
|
||||||
docker rm -f $(docker ps -a -q) ||:
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
DocsCheck:
|
|
||||||
needs: DockerHubPush
|
|
||||||
runs-on: [self-hosted, func-tester]
|
|
||||||
steps:
|
|
||||||
- name: Download changed images
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: changed_images
|
|
||||||
path: ${{ runner.temp }}/docs_check
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Docs Check
|
|
||||||
env:
|
|
||||||
TEMP_PATH: ${{runner.temp}}/docs_check
|
|
||||||
REPO_COPY: ${{runner.temp}}/docs_check/ClickHouse
|
|
||||||
run: |
|
|
||||||
cp -r $GITHUB_WORKSPACE $TEMP_PATH
|
|
||||||
cd $REPO_COPY/tests/ci
|
|
||||||
python3 docs_check.py
|
|
||||||
- name: Cleanup
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
docker kill $(docker ps -q) ||:
|
|
||||||
docker rm -f $(docker ps -a -q) ||:
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
BuilderDebDebug:
|
|
||||||
needs: DockerHubPush
|
|
||||||
if: ${{ !contains(github.event.pull_request.labels.*.name, 'pr-documentation') && !contains(github.event.pull_request.labels.*.name, 'pr-doc-fix') }}
|
|
||||||
runs-on: [self-hosted, builder]
|
|
||||||
steps:
|
|
||||||
- name: Download changed images
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: changed_images
|
|
||||||
path: ${{ runner.temp }}/images_path
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: 'recursive'
|
|
||||||
fetch-depth: 0 # otherwise we will have no info about contributors
|
|
||||||
- name: Build
|
|
||||||
env:
|
|
||||||
TEMP_PATH: ${{runner.temp}}/build_check
|
|
||||||
IMAGES_PATH: ${{runner.temp}}/images_path
|
|
||||||
REPO_COPY: ${{runner.temp}}/build_check/ClickHouse
|
|
||||||
CACHES_PATH: ${{runner.temp}}/../ccaches
|
|
||||||
CHECK_NAME: 'ClickHouse build check (actions)'
|
|
||||||
BUILD_NUMBER: 7
|
|
||||||
run: |
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
mkdir -p $TEMP_PATH
|
|
||||||
cp -r $GITHUB_WORKSPACE $TEMP_PATH
|
|
||||||
cd $REPO_COPY/tests/ci && python3 build_check.py "$CHECK_NAME" $BUILD_NUMBER
|
|
||||||
- name: Upload build URLs to artifacts
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: ${{ env.BUILD_NAME }}
|
|
||||||
path: ${{ runner.temp }}/build_check/${{ env.BUILD_NAME }}.json
|
|
||||||
- name: Cleanup
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
docker kill $(docker ps -q) ||:
|
|
||||||
docker rm -f $(docker ps -a -q) ||:
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
BuilderReport:
|
|
||||||
needs: [BuilderDebDebug]
|
|
||||||
runs-on: [self-hosted, style-checker]
|
|
||||||
steps:
|
|
||||||
- name: Download json reports
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
path: ${{runner.temp}}/reports_dir
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Report Builder
|
|
||||||
env:
|
|
||||||
TEMP_PATH: ${{runner.temp}}/report_check
|
|
||||||
REPORTS_PATH: ${{runner.temp}}/reports_dir
|
|
||||||
CHECK_NAME: 'ClickHouse build check (actions)'
|
|
||||||
run: |
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
mkdir -p $TEMP_PATH
|
|
||||||
cd $GITHUB_WORKSPACE/tests/ci
|
|
||||||
python3 build_report_check.py "$CHECK_NAME"
|
|
||||||
- name: Cleanup
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
docker kill $(docker ps -q) ||:
|
|
||||||
docker rm -f $(docker ps -a -q) ||:
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
FunctionalStatelessTestDebug:
|
|
||||||
needs: [BuilderDebDebug]
|
|
||||||
runs-on: [self-hosted, func-tester]
|
|
||||||
steps:
|
|
||||||
- name: Download json reports
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
path: ${{runner.temp}}/reports_dir
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Functional test
|
|
||||||
env:
|
|
||||||
TEMP_PATH: ${{runner.temp}}/stateless_debug
|
|
||||||
REPORTS_PATH: ${{runner.temp}}/reports_dir
|
|
||||||
CHECK_NAME: 'Stateless tests (debug, actions)'
|
|
||||||
REPO_COPY: ${{runner.temp}}/stateless_debug/ClickHouse
|
|
||||||
REQUIRED_BUILD_NUMBER: 7
|
|
||||||
KILL_TIMEOUT: 10800
|
|
||||||
run: |
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
mkdir -p $TEMP_PATH
|
|
||||||
cp -r $GITHUB_WORKSPACE $TEMP_PATH
|
|
||||||
cd $REPO_COPY/tests/ci
|
|
||||||
python3 functional_test_check.py "$CHECK_NAME" $REQUIRED_BUILD_NUMBER $KILL_TIMEOUT
|
|
||||||
- name: Cleanup
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
docker kill $(docker ps -q) ||:
|
|
||||||
docker rm -f $(docker ps -a -q) ||:
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
FunctionalStatefulTestDebug:
|
|
||||||
needs: [BuilderDebDebug]
|
|
||||||
runs-on: [self-hosted, func-tester]
|
|
||||||
steps:
|
|
||||||
- name: Download json reports
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
path: ${{runner.temp}}/reports_dir
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Functional test
|
|
||||||
env:
|
|
||||||
TEMP_PATH: ${{runner.temp}}/stateful_debug
|
|
||||||
REPORTS_PATH: ${{runner.temp}}/reports_dir
|
|
||||||
CHECK_NAME: 'Stateful tests (debug, actions)'
|
|
||||||
REPO_COPY: ${{runner.temp}}/stateful_debug/ClickHouse
|
|
||||||
REQUIRED_BUILD_NUMBER: 7
|
|
||||||
KILL_TIMEOUT: 3600
|
|
||||||
run: |
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
mkdir -p $TEMP_PATH
|
|
||||||
cp -r $GITHUB_WORKSPACE $TEMP_PATH
|
|
||||||
cd $REPO_COPY/tests/ci
|
|
||||||
python3 functional_test_check.py "$CHECK_NAME" $REQUIRED_BUILD_NUMBER $KILL_TIMEOUT
|
|
||||||
- name: Cleanup
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
docker kill $(docker ps -q) ||:
|
|
||||||
docker rm -f $(docker ps -a -q) ||:
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
StressTestDebug:
|
|
||||||
needs: [BuilderDebDebug]
|
|
||||||
runs-on: [self-hosted, stress-tester]
|
|
||||||
steps:
|
|
||||||
- name: Download json reports
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
path: ${{runner.temp}}/reports_dir
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Stress test
|
|
||||||
env:
|
|
||||||
TEMP_PATH: ${{runner.temp}}/stress_debug
|
|
||||||
REPORTS_PATH: ${{runner.temp}}/reports_dir
|
|
||||||
CHECK_NAME: 'Stress tests (debug, actions)'
|
|
||||||
REPO_COPY: ${{runner.temp}}/stress_debug/ClickHouse
|
|
||||||
REQUIRED_BUILD_NUMBER: 7
|
|
||||||
run: |
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
mkdir -p $TEMP_PATH
|
|
||||||
cp -r $GITHUB_WORKSPACE $TEMP_PATH
|
|
||||||
cd $REPO_COPY/tests/ci
|
|
||||||
python3 stress_check.py "$CHECK_NAME" $REQUIRED_BUILD_NUMBER
|
|
||||||
- name: Cleanup
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
docker kill $(docker ps -q) ||:
|
|
||||||
docker rm -f $(docker ps -a -q) ||:
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
ASTFuzzerTestDebug:
|
|
||||||
needs: [BuilderDebDebug]
|
|
||||||
runs-on: [self-hosted, func-tester]
|
|
||||||
steps:
|
|
||||||
- name: Download json reports
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
path: ${{runner.temp}}/reports_dir
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Fuzzer
|
|
||||||
env:
|
|
||||||
TEMP_PATH: ${{runner.temp}}/ast_fuzzer_debug
|
|
||||||
REPORTS_PATH: ${{runner.temp}}/reports_dir
|
|
||||||
CHECK_NAME: 'AST fuzzer (debug, actions)'
|
|
||||||
REPO_COPY: ${{runner.temp}}/ast_fuzzer_debug/ClickHouse
|
|
||||||
REQUIRED_BUILD_NUMBER: 7
|
|
||||||
run: |
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
mkdir -p $TEMP_PATH
|
|
||||||
cp -r $GITHUB_WORKSPACE $TEMP_PATH
|
|
||||||
cd $REPO_COPY/tests/ci
|
|
||||||
python3 ast_fuzzer_check.py "$CHECK_NAME" $REQUIRED_BUILD_NUMBER
|
|
||||||
- name: Cleanup
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
docker kill $(docker ps -q) ||:
|
|
||||||
docker rm -f $(docker ps -a -q) ||:
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
FastTest:
|
|
||||||
needs: DockerHubPush
|
|
||||||
if: ${{ !contains(github.event.pull_request.labels.*.name, 'pr-documentation') && !contains(github.event.pull_request.labels.*.name, 'pr-doc-fix') }}
|
|
||||||
runs-on: [self-hosted, builder]
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Fast Test
|
|
||||||
env:
|
|
||||||
TEMP_PATH: ${{runner.temp}}/fasttest
|
|
||||||
REPO_COPY: ${{runner.temp}}/fasttest/ClickHouse
|
|
||||||
CACHES_PATH: ${{runner.temp}}/../ccaches
|
|
||||||
run: |
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
mkdir -p $TEMP_PATH
|
|
||||||
cp -r $GITHUB_WORKSPACE $TEMP_PATH
|
|
||||||
cd $REPO_COPY/tests/ci && python3 fast_test_check.py
|
|
||||||
- name: Cleanup
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
docker kill $(docker ps -q) ||:
|
|
||||||
docker rm -f $(docker ps -a -q) ||:
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
FinishCheck:
|
|
||||||
needs: [StyleCheck, DockerHubPush, CheckLabels, BuilderReport, FastTest, FunctionalStatelessTestDebug, FunctionalStatefulTestDebug, DocsCheck, StressTestDebug, ASTFuzzerTestDebug]
|
|
||||||
runs-on: [self-hosted, style-checker]
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Finish label
|
|
||||||
run: |
|
|
||||||
cd $GITHUB_WORKSPACE/tests/ci
|
|
||||||
python3 finish_check.py
|
|
3149
.github/workflows/master.yml
vendored
Normal file
3149
.github/workflows/master.yml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
176
.github/workflows/nightly.yml
vendored
Normal file
176
.github/workflows/nightly.yml
vendored
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
name: NightlyBuilds
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Force the stdout and stderr streams to be unbuffered
|
||||||
|
PYTHONUNBUFFERED: 1
|
||||||
|
|
||||||
|
"on":
|
||||||
|
schedule:
|
||||||
|
- cron: '13 3 * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Debug:
|
||||||
|
# The task for having a preserved ENV and event.json for later investigation
|
||||||
|
uses: ./.github/workflows/debug.yml
|
||||||
|
DockerHubPushAarch64:
|
||||||
|
runs-on: [self-hosted, style-checker-aarch64]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Images check
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 docker_images_check.py --suffix aarch64 --all
|
||||||
|
- name: Upload images files to artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images_aarch64
|
||||||
|
path: ${{ runner.temp }}/docker_images_check/changed_images_aarch64.json
|
||||||
|
DockerHubPushAmd64:
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Images check
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 docker_images_check.py --suffix amd64 --all
|
||||||
|
- name: Upload images files to artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images_amd64
|
||||||
|
path: ${{ runner.temp }}/docker_images_check/changed_images_amd64.json
|
||||||
|
DockerHubPush:
|
||||||
|
needs: [DockerHubPushAmd64, DockerHubPushAarch64]
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
- name: Download changed aarch64 images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images_aarch64
|
||||||
|
path: ${{ runner.temp }}
|
||||||
|
- name: Download changed amd64 images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images_amd64
|
||||||
|
path: ${{ runner.temp }}
|
||||||
|
- name: Images check
|
||||||
|
run: |
|
||||||
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
|
python3 docker_manifests_merge.py --suffix amd64 --suffix aarch64
|
||||||
|
- name: Upload images files to artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images
|
||||||
|
path: ${{ runner.temp }}/changed_images.json
|
||||||
|
BuilderCoverity:
|
||||||
|
needs: DockerHubPush
|
||||||
|
runs-on: [self-hosted, builder]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
BUILD_NAME=coverity
|
||||||
|
CACHES_PATH=${{runner.temp}}/../ccaches
|
||||||
|
IMAGES_PATH=${{runner.temp}}/images_path
|
||||||
|
REPO_COPY=${{runner.temp}}/build_check/ClickHouse
|
||||||
|
TEMP_PATH=${{runner.temp}}/build_check
|
||||||
|
EOF
|
||||||
|
echo "COVERITY_TOKEN=${{ secrets.COVERITY_TOKEN }}" >> "$GITHUB_ENV"
|
||||||
|
- name: Download changed images
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: changed_images
|
||||||
|
path: ${{ env.IMAGES_PATH }}
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
submodules: true
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci" && python3 build_check.py "$BUILD_NAME"
|
||||||
|
- name: Upload Coverity Analysis
|
||||||
|
if: ${{ success() || failure() }}
|
||||||
|
run: |
|
||||||
|
curl --form token="${COVERITY_TOKEN}" \
|
||||||
|
--form email='security+coverity@clickhouse.com' \
|
||||||
|
--form file="@$TEMP_PATH/$BUILD_NAME/coverity-scan.tar.zst" \
|
||||||
|
--form version="${GITHUB_REF#refs/heads/}-${GITHUB_SHA::6}" \
|
||||||
|
--form description="Nighly Scan: $(date +'%Y-%m-%dT%H:%M:%S')" \
|
||||||
|
https://scan.coverity.com/builds?project=ClickHouse%2FClickHouse
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH" "$CACHES_PATH"
|
||||||
|
SonarCloud:
|
||||||
|
runs-on: [self-hosted, builder]
|
||||||
|
env:
|
||||||
|
SONAR_SCANNER_VERSION: 4.7.0.2747
|
||||||
|
SONAR_SERVER_URL: "https://sonarcloud.io"
|
||||||
|
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
|
||||||
|
CC: clang-15
|
||||||
|
CXX: clang++-15
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||||
|
submodules: true
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 11
|
||||||
|
- name: Download and set up sonar-scanner
|
||||||
|
env:
|
||||||
|
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
|
||||||
|
run: |
|
||||||
|
mkdir -p "$HOME/.sonar"
|
||||||
|
curl -sSLo "$HOME/.sonar/sonar-scanner.zip" "${{ env.SONAR_SCANNER_DOWNLOAD_URL }}"
|
||||||
|
unzip -o "$HOME/.sonar/sonar-scanner.zip" -d "$HOME/.sonar/"
|
||||||
|
echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> "$GITHUB_PATH"
|
||||||
|
- name: Download and set up build-wrapper
|
||||||
|
env:
|
||||||
|
BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip
|
||||||
|
run: |
|
||||||
|
curl -sSLo "$HOME/.sonar/build-wrapper-linux-x86.zip" "${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}"
|
||||||
|
unzip -o "$HOME/.sonar/build-wrapper-linux-x86.zip" -d "$HOME/.sonar/"
|
||||||
|
echo "$HOME/.sonar/build-wrapper-linux-x86" >> "$GITHUB_PATH"
|
||||||
|
- name: Set Up Build Tools
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -yq git cmake ccache python3 ninja-build
|
||||||
|
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
|
||||||
|
- name: Run build-wrapper
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
cd ..
|
||||||
|
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/
|
||||||
|
- name: Run sonar-scanner
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
run: |
|
||||||
|
sonar-scanner \
|
||||||
|
--define sonar.host.url="${{ env.SONAR_SERVER_URL }}" \
|
||||||
|
--define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
|
||||||
|
--define sonar.projectKey="ClickHouse_ClickHouse" \
|
||||||
|
--define sonar.organization="clickhouse-java" \
|
||||||
|
--define sonar.exclusions="**/*.java,**/*.ts,**/*.js,**/*.css,**/*.sql"
|
4671
.github/workflows/pull_request.yml
vendored
Normal file
4671
.github/workflows/pull_request.yml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
87
.github/workflows/release.yml
vendored
87
.github/workflows/release.yml
vendored
@ -1,55 +1,42 @@
|
|||||||
name: DocsReleaseChecks
|
name: PublishedReleaseCI
|
||||||
concurrency:
|
# - Gets artifacts from S3
|
||||||
group: master-release
|
# - Sends it to JFROG Artifactory
|
||||||
cancel-in-progress: true
|
# - Adds them to the release assets
|
||||||
|
|
||||||
on: # yamllint disable-line rule:truthy
|
on: # yamllint disable-line rule:truthy
|
||||||
push:
|
release:
|
||||||
branches:
|
types:
|
||||||
- master
|
- published
|
||||||
paths:
|
|
||||||
- 'docs/**'
|
|
||||||
- 'website/**'
|
|
||||||
- 'benchmark/**'
|
|
||||||
- 'docker/**'
|
|
||||||
jobs:
|
jobs:
|
||||||
DockerHubPush:
|
ReleasePublish:
|
||||||
runs-on: [self-hosted, style-checker]
|
runs-on: [self-hosted, style-checker]
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository code
|
- name: Deploy packages and assets
|
||||||
uses: actions/checkout@v2
|
run: |
|
||||||
- name: Images check
|
GITHUB_TAG="${GITHUB_REF#refs/tags/}"
|
||||||
run: |
|
curl --silent --data '' \
|
||||||
cd $GITHUB_WORKSPACE/tests/ci
|
'${{ secrets.PACKAGES_RELEASE_URL }}/release/'"${GITHUB_TAG}"'?binary=binary_darwin&binary=binary_darwin_aarch64&sync=true'
|
||||||
python3 docker_images_check.py
|
############################################################################################
|
||||||
- name: Upload images files to artifacts
|
##################################### Docker images #######################################
|
||||||
uses: actions/upload-artifact@v2
|
############################################################################################
|
||||||
with:
|
DockerServerImages:
|
||||||
name: changed_images
|
runs-on: [self-hosted, style-checker]
|
||||||
path: ${{ runner.temp }}/docker_images_check/changed_images.json
|
|
||||||
DocsRelease:
|
|
||||||
needs: DockerHubPush
|
|
||||||
runs-on: [self-hosted, func-tester]
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v2
|
uses: ClickHouse/checkout@v1
|
||||||
- name: Download changed images
|
with:
|
||||||
uses: actions/download-artifact@v2
|
clear-repository: true
|
||||||
with:
|
fetch-depth: 0 # otherwise we will have no version info
|
||||||
name: changed_images
|
- name: Check docker clickhouse/clickhouse-server building
|
||||||
path: ${{runner.temp}}/docs_release
|
run: |
|
||||||
- name: Docs Release
|
cd "$GITHUB_WORKSPACE/tests/ci"
|
||||||
env:
|
python3 docker_server.py --release-type auto --version "${{ github.ref }}"
|
||||||
TEMP_PATH: ${{runner.temp}}/docs_release
|
python3 docker_server.py --release-type auto --version "${{ github.ref }}" --no-ubuntu \
|
||||||
REPO_COPY: ${{runner.temp}}/docs_release/ClickHouse
|
--image-repo clickhouse/clickhouse-keeper --image-path docker/keeper
|
||||||
CLOUDFLARE_TOKEN: ${{secrets.CLOUDFLARE}}
|
- name: Cleanup
|
||||||
ROBOT_CLICKHOUSE_SSH_KEY: ${{secrets.ROBOT_CLICKHOUSE_SSH_KEY}}
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
cp -r $GITHUB_WORKSPACE $TEMP_PATH
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
cd $REPO_COPY/tests/ci
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
python3 docs_release.py
|
sudo rm -fr "$TEMP_PATH"
|
||||||
- name: Cleanup
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
docker kill $(docker ps -q) ||:
|
|
||||||
docker rm -f $(docker ps -a -q) ||:
|
|
||||||
sudo rm -fr $TEMP_PATH
|
|
||||||
|
1960
.github/workflows/release_branches.yml
vendored
Normal file
1960
.github/workflows/release_branches.yml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
72
.github/workflows/tags_stable.yml
vendored
Normal file
72
.github/workflows/tags_stable.yml
vendored
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
name: TagsStableWorkflow
|
||||||
|
# - Gets artifacts from S3
|
||||||
|
# - Sends it to JFROG Artifactory
|
||||||
|
# - Adds them to the release assets
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Force the stdout and stderr streams to be unbuffered
|
||||||
|
PYTHONUNBUFFERED: 1
|
||||||
|
|
||||||
|
on: # yamllint disable-line rule:truthy
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*-prestable'
|
||||||
|
- 'v*-stable'
|
||||||
|
- 'v*-lts'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'Test tag'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
UpdateVersions:
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Set test tag
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
run: |
|
||||||
|
echo "GITHUB_TAG=${{ github.event.inputs.tag }}" >> "$GITHUB_ENV"
|
||||||
|
- name: Get tag name
|
||||||
|
if: github.event_name != 'workflow_dispatch'
|
||||||
|
run: |
|
||||||
|
echo "GITHUB_TAG=${GITHUB_REF#refs/tags/}" >> "$GITHUB_ENV"
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
ref: master
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Update versions, docker version, changelog, security
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.ROBOT_CLICKHOUSE_COMMIT_TOKEN }}
|
||||||
|
run: |
|
||||||
|
./utils/list-versions/list-versions.sh > ./utils/list-versions/version_date.tsv
|
||||||
|
./utils/list-versions/update-docker-version.sh
|
||||||
|
GID=$(id -g "${UID}")
|
||||||
|
docker run -u "${UID}:${GID}" -e PYTHONUNBUFFERED=1 \
|
||||||
|
--volume="${GITHUB_WORKSPACE}:/ClickHouse" clickhouse/style-test \
|
||||||
|
/ClickHouse/utils/changelog/changelog.py -v --debug-helpers \
|
||||||
|
--gh-user-or-token="$GITHUB_TOKEN" --jobs=5 \
|
||||||
|
--output="/ClickHouse/docs/changelogs/${GITHUB_TAG}.md" "${GITHUB_TAG}"
|
||||||
|
git add "./docs/changelogs/${GITHUB_TAG}.md"
|
||||||
|
python3 ./utils/security-generator/generate_security.py > SECURITY.md
|
||||||
|
git diff HEAD
|
||||||
|
- name: Create Pull Request
|
||||||
|
uses: peter-evans/create-pull-request@v3
|
||||||
|
with:
|
||||||
|
author: "robot-clickhouse <robot-clickhouse@users.noreply.github.com>"
|
||||||
|
token: ${{ secrets.ROBOT_CLICKHOUSE_COMMIT_TOKEN }}
|
||||||
|
committer: "robot-clickhouse <robot-clickhouse@users.noreply.github.com>"
|
||||||
|
commit-message: Update version_date.tsv and changelogs after ${{ env.GITHUB_TAG }}
|
||||||
|
branch: auto/${{ env.GITHUB_TAG }}
|
||||||
|
assignees: ${{ github.event.sender.login }} # assign the PR to the tag pusher
|
||||||
|
delete-branch: true
|
||||||
|
title: Update version_date.tsv and changelogs after ${{ env.GITHUB_TAG }}
|
||||||
|
labels: do not test
|
||||||
|
body: |
|
||||||
|
Update version_date.tsv and changelogs after ${{ env.GITHUB_TAG }}
|
||||||
|
|
||||||
|
### Changelog category (leave one):
|
||||||
|
- Not for changelog (changelog entry is not required)
|
40
.github/workflows/woboq.yml
vendored
Normal file
40
.github/workflows/woboq.yml
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
name: WoboqBuilder
|
||||||
|
env:
|
||||||
|
# Force the stdout and stderr streams to be unbuffered
|
||||||
|
PYTHONUNBUFFERED: 1
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: woboq
|
||||||
|
on: # yamllint disable-line rule:truthy
|
||||||
|
schedule:
|
||||||
|
- cron: '0 */18 * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
jobs:
|
||||||
|
# don't use dockerhub push because this image updates so rarely
|
||||||
|
WoboqCodebrowser:
|
||||||
|
runs-on: [self-hosted, style-checker]
|
||||||
|
steps:
|
||||||
|
- name: Set envs
|
||||||
|
run: |
|
||||||
|
cat >> "$GITHUB_ENV" << 'EOF'
|
||||||
|
TEMP_PATH=${{runner.temp}}/codebrowser
|
||||||
|
REPO_COPY=${{runner.temp}}/codebrowser/ClickHouse
|
||||||
|
IMAGES_PATH=${{runner.temp}}/images_path
|
||||||
|
EOF
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: ClickHouse/checkout@v1
|
||||||
|
with:
|
||||||
|
clear-repository: true
|
||||||
|
submodules: 'true'
|
||||||
|
- name: Codebrowser
|
||||||
|
run: |
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
||||||
|
mkdir -p "$TEMP_PATH"
|
||||||
|
cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
|
||||||
|
cd "$REPO_COPY/tests/ci" && python3 codebrowser_check.py
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker ps --quiet | xargs --no-run-if-empty docker kill ||:
|
||||||
|
docker ps --all --quiet | xargs --no-run-if-empty docker rm -f ||:
|
||||||
|
sudo rm -fr "$TEMP_PATH"
|
22
.gitignore
vendored
22
.gitignore
vendored
@ -13,9 +13,11 @@
|
|||||||
/build_*
|
/build_*
|
||||||
/build-*
|
/build-*
|
||||||
/tests/venv
|
/tests/venv
|
||||||
|
/obj-x86_64-linux-gnu/
|
||||||
|
|
||||||
# logs
|
# logs
|
||||||
*.log
|
*.log
|
||||||
|
*.debuglog
|
||||||
*.stderr
|
*.stderr
|
||||||
*.stdout
|
*.stdout
|
||||||
|
|
||||||
@ -32,10 +34,6 @@
|
|||||||
/docs/zh/single.md
|
/docs/zh/single.md
|
||||||
/docs/ja/single.md
|
/docs/ja/single.md
|
||||||
/docs/fa/single.md
|
/docs/fa/single.md
|
||||||
/docs/en/development/cmake-in-clickhouse.md
|
|
||||||
/docs/ja/development/cmake-in-clickhouse.md
|
|
||||||
/docs/zh/development/cmake-in-clickhouse.md
|
|
||||||
/docs/ru/development/cmake-in-clickhouse.md
|
|
||||||
|
|
||||||
# callgrind files
|
# callgrind files
|
||||||
callgrind.out.*
|
callgrind.out.*
|
||||||
@ -61,6 +59,10 @@ cmake_install.cmake
|
|||||||
CTestTestfile.cmake
|
CTestTestfile.cmake
|
||||||
*.a
|
*.a
|
||||||
*.o
|
*.o
|
||||||
|
*.so
|
||||||
|
*.dll
|
||||||
|
*.lib
|
||||||
|
*.dylib
|
||||||
cmake-build-*
|
cmake-build-*
|
||||||
|
|
||||||
# Python cache
|
# Python cache
|
||||||
@ -79,6 +81,7 @@ core
|
|||||||
vgcore*
|
vgcore*
|
||||||
|
|
||||||
*.deb
|
*.deb
|
||||||
|
*.tar.zst
|
||||||
*.build
|
*.build
|
||||||
*.upload
|
*.upload
|
||||||
*.changes
|
*.changes
|
||||||
@ -151,4 +154,15 @@ website/package-lock.json
|
|||||||
/programs/server/data
|
/programs/server/data
|
||||||
/programs/server/metadata
|
/programs/server/metadata
|
||||||
/programs/server/store
|
/programs/server/store
|
||||||
|
/programs/server/uuid
|
||||||
|
/programs/server/coordination
|
||||||
|
|
||||||
|
# temporary test files
|
||||||
|
tests/queries/0_stateless/test_*
|
||||||
|
tests/queries/0_stateless/*.binary
|
||||||
|
tests/queries/0_stateless/*.generated-expect
|
||||||
|
|
||||||
|
# rust
|
||||||
|
/rust/**/target
|
||||||
|
# It is autogenerated from *.in
|
||||||
|
/rust/**/.cargo/config.toml
|
||||||
|
268
.gitmodules
vendored
268
.gitmodules
vendored
@ -1,188 +1,163 @@
|
|||||||
[submodule "contrib/poco"]
|
|
||||||
path = contrib/poco
|
|
||||||
url = https://github.com/ClickHouse-Extras/poco.git
|
|
||||||
branch = clickhouse
|
|
||||||
[submodule "contrib/zstd"]
|
[submodule "contrib/zstd"]
|
||||||
path = contrib/zstd
|
path = contrib/zstd
|
||||||
url = https://github.com/facebook/zstd.git
|
url = https://github.com/facebook/zstd
|
||||||
[submodule "contrib/lz4"]
|
[submodule "contrib/lz4"]
|
||||||
path = contrib/lz4
|
path = contrib/lz4
|
||||||
url = https://github.com/lz4/lz4.git
|
url = https://github.com/lz4/lz4
|
||||||
[submodule "contrib/librdkafka"]
|
[submodule "contrib/librdkafka"]
|
||||||
path = contrib/librdkafka
|
path = contrib/librdkafka
|
||||||
url = https://github.com/ClickHouse-Extras/librdkafka.git
|
url = https://github.com/ClickHouse/librdkafka
|
||||||
[submodule "contrib/cctz"]
|
[submodule "contrib/cctz"]
|
||||||
path = contrib/cctz
|
path = contrib/cctz
|
||||||
url = https://github.com/ClickHouse-Extras/cctz.git
|
url = https://github.com/ClickHouse/cctz
|
||||||
[submodule "contrib/zlib-ng"]
|
[submodule "contrib/zlib-ng"]
|
||||||
path = contrib/zlib-ng
|
path = contrib/zlib-ng
|
||||||
url = https://github.com/ClickHouse-Extras/zlib-ng.git
|
url = https://github.com/ClickHouse/zlib-ng
|
||||||
branch = clickhouse-new
|
branch = clickhouse-2.0.x
|
||||||
[submodule "contrib/googletest"]
|
[submodule "contrib/googletest"]
|
||||||
path = contrib/googletest
|
path = contrib/googletest
|
||||||
url = https://github.com/google/googletest.git
|
url = https://github.com/google/googletest
|
||||||
[submodule "contrib/capnproto"]
|
[submodule "contrib/capnproto"]
|
||||||
path = contrib/capnproto
|
path = contrib/capnproto
|
||||||
url = https://github.com/capnproto/capnproto.git
|
url = https://github.com/capnproto/capnproto
|
||||||
[submodule "contrib/double-conversion"]
|
[submodule "contrib/double-conversion"]
|
||||||
path = contrib/double-conversion
|
path = contrib/double-conversion
|
||||||
url = https://github.com/google/double-conversion.git
|
url = https://github.com/google/double-conversion
|
||||||
[submodule "contrib/re2"]
|
[submodule "contrib/re2"]
|
||||||
path = contrib/re2
|
path = contrib/re2
|
||||||
url = https://github.com/google/re2.git
|
url = https://github.com/google/re2
|
||||||
[submodule "contrib/llvm"]
|
|
||||||
path = contrib/llvm
|
|
||||||
url = https://github.com/ClickHouse-Extras/llvm
|
|
||||||
[submodule "contrib/mariadb-connector-c"]
|
[submodule "contrib/mariadb-connector-c"]
|
||||||
path = contrib/mariadb-connector-c
|
path = contrib/mariadb-connector-c
|
||||||
url = https://github.com/ClickHouse-Extras/mariadb-connector-c.git
|
url = https://github.com/ClickHouse/mariadb-connector-c
|
||||||
[submodule "contrib/jemalloc"]
|
[submodule "contrib/jemalloc"]
|
||||||
path = contrib/jemalloc
|
path = contrib/jemalloc
|
||||||
url = https://github.com/ClickHouse-Extras/jemalloc.git
|
url = https://github.com/jemalloc/jemalloc
|
||||||
[submodule "contrib/unixodbc"]
|
[submodule "contrib/unixodbc"]
|
||||||
path = contrib/unixodbc
|
path = contrib/unixodbc
|
||||||
url = https://github.com/ClickHouse-Extras/UnixODBC.git
|
url = https://github.com/ClickHouse/UnixODBC
|
||||||
[submodule "contrib/protobuf"]
|
[submodule "contrib/protobuf"]
|
||||||
path = contrib/protobuf
|
path = contrib/protobuf
|
||||||
url = https://github.com/ClickHouse-Extras/protobuf.git
|
url = https://github.com/ClickHouse/protobuf
|
||||||
branch = v3.13.0.1
|
branch = v3.13.0.1
|
||||||
[submodule "contrib/boost"]
|
[submodule "contrib/boost"]
|
||||||
path = contrib/boost
|
path = contrib/boost
|
||||||
url = https://github.com/ClickHouse-Extras/boost.git
|
url = https://github.com/ClickHouse/boost
|
||||||
[submodule "contrib/base64"]
|
[submodule "contrib/base64"]
|
||||||
path = contrib/base64
|
path = contrib/base64
|
||||||
url = https://github.com/ClickHouse-Extras/Turbo-Base64.git
|
url = https://github.com/ClickHouse/Turbo-Base64
|
||||||
[submodule "contrib/arrow"]
|
[submodule "contrib/arrow"]
|
||||||
path = contrib/arrow
|
path = contrib/arrow
|
||||||
url = https://github.com/ClickHouse-Extras/arrow
|
url = https://github.com/ClickHouse/arrow
|
||||||
branch = clickhouse-arrow-2.0.0
|
branch = blessed/release-6.0.1
|
||||||
[submodule "contrib/thrift"]
|
[submodule "contrib/thrift"]
|
||||||
path = contrib/thrift
|
path = contrib/thrift
|
||||||
url = https://github.com/apache/thrift.git
|
url = https://github.com/apache/thrift
|
||||||
[submodule "contrib/libhdfs3"]
|
[submodule "contrib/libhdfs3"]
|
||||||
path = contrib/libhdfs3
|
path = contrib/libhdfs3
|
||||||
url = https://github.com/ClickHouse-Extras/libhdfs3.git
|
url = https://github.com/ClickHouse/libhdfs3
|
||||||
[submodule "contrib/libxml2"]
|
[submodule "contrib/libxml2"]
|
||||||
path = contrib/libxml2
|
path = contrib/libxml2
|
||||||
url = https://github.com/GNOME/libxml2.git
|
url = https://github.com/GNOME/libxml2
|
||||||
[submodule "contrib/libgsasl"]
|
[submodule "contrib/libgsasl"]
|
||||||
path = contrib/libgsasl
|
path = contrib/libgsasl
|
||||||
url = https://github.com/ClickHouse-Extras/libgsasl.git
|
url = https://github.com/ClickHouse/libgsasl
|
||||||
[submodule "contrib/libcxx"]
|
|
||||||
path = contrib/libcxx
|
|
||||||
url = https://github.com/ClickHouse-Extras/libcxx.git
|
|
||||||
[submodule "contrib/libcxxabi"]
|
|
||||||
path = contrib/libcxxabi
|
|
||||||
url = https://github.com/ClickHouse-Extras/libcxxabi.git
|
|
||||||
[submodule "contrib/snappy"]
|
[submodule "contrib/snappy"]
|
||||||
path = contrib/snappy
|
path = contrib/snappy
|
||||||
url = https://github.com/ClickHouse-Extras/snappy.git
|
url = https://github.com/ClickHouse/snappy
|
||||||
[submodule "contrib/cppkafka"]
|
[submodule "contrib/cppkafka"]
|
||||||
path = contrib/cppkafka
|
path = contrib/cppkafka
|
||||||
url = https://github.com/mfontanini/cppkafka.git
|
url = https://github.com/mfontanini/cppkafka
|
||||||
[submodule "contrib/brotli"]
|
[submodule "contrib/brotli"]
|
||||||
path = contrib/brotli
|
path = contrib/brotli
|
||||||
url = https://github.com/google/brotli.git
|
url = https://github.com/google/brotli
|
||||||
[submodule "contrib/h3"]
|
[submodule "contrib/h3"]
|
||||||
path = contrib/h3
|
path = contrib/h3
|
||||||
url = https://github.com/ClickHouse-Extras/h3
|
url = https://github.com/ClickHouse/h3
|
||||||
[submodule "contrib/hyperscan"]
|
|
||||||
path = contrib/hyperscan
|
|
||||||
url = https://github.com/ClickHouse-Extras/hyperscan.git
|
|
||||||
[submodule "contrib/libunwind"]
|
[submodule "contrib/libunwind"]
|
||||||
path = contrib/libunwind
|
path = contrib/libunwind
|
||||||
url = https://github.com/ClickHouse-Extras/libunwind.git
|
url = https://github.com/ClickHouse/libunwind
|
||||||
[submodule "contrib/simdjson"]
|
[submodule "contrib/simdjson"]
|
||||||
path = contrib/simdjson
|
path = contrib/simdjson
|
||||||
url = https://github.com/simdjson/simdjson.git
|
url = https://github.com/simdjson/simdjson
|
||||||
[submodule "contrib/rapidjson"]
|
[submodule "contrib/rapidjson"]
|
||||||
path = contrib/rapidjson
|
path = contrib/rapidjson
|
||||||
url = https://github.com/ClickHouse-Extras/rapidjson
|
url = https://github.com/ClickHouse/rapidjson
|
||||||
[submodule "contrib/fastops"]
|
[submodule "contrib/fastops"]
|
||||||
path = contrib/fastops
|
path = contrib/fastops
|
||||||
url = https://github.com/ClickHouse-Extras/fastops
|
url = https://github.com/ClickHouse/fastops
|
||||||
[submodule "contrib/orc"]
|
[submodule "contrib/orc"]
|
||||||
path = contrib/orc
|
path = contrib/orc
|
||||||
url = https://github.com/ClickHouse-Extras/orc
|
url = https://github.com/ClickHouse/orc
|
||||||
[submodule "contrib/sparsehash-c11"]
|
[submodule "contrib/sparsehash-c11"]
|
||||||
path = contrib/sparsehash-c11
|
path = contrib/sparsehash-c11
|
||||||
url = https://github.com/sparsehash/sparsehash-c11.git
|
url = https://github.com/sparsehash/sparsehash-c11
|
||||||
[submodule "contrib/grpc"]
|
[submodule "contrib/grpc"]
|
||||||
path = contrib/grpc
|
path = contrib/grpc
|
||||||
url = https://github.com/ClickHouse-Extras/grpc.git
|
url = https://github.com/ClickHouse/grpc
|
||||||
branch = v1.33.2
|
branch = v1.33.2
|
||||||
[submodule "contrib/aws"]
|
[submodule "contrib/aws"]
|
||||||
path = contrib/aws
|
path = contrib/aws
|
||||||
url = https://github.com/ClickHouse-Extras/aws-sdk-cpp.git
|
url = https://github.com/ClickHouse/aws-sdk-cpp
|
||||||
[submodule "aws-c-event-stream"]
|
[submodule "aws-c-event-stream"]
|
||||||
path = contrib/aws-c-event-stream
|
path = contrib/aws-c-event-stream
|
||||||
url = https://github.com/ClickHouse-Extras/aws-c-event-stream.git
|
url = https://github.com/awslabs/aws-c-event-stream
|
||||||
[submodule "aws-c-common"]
|
[submodule "aws-c-common"]
|
||||||
path = contrib/aws-c-common
|
path = contrib/aws-c-common
|
||||||
url = https://github.com/ClickHouse-Extras/aws-c-common.git
|
url = https://github.com/ClickHouse/aws-c-common
|
||||||
[submodule "aws-checksums"]
|
[submodule "aws-checksums"]
|
||||||
path = contrib/aws-checksums
|
path = contrib/aws-checksums
|
||||||
url = https://github.com/ClickHouse-Extras/aws-checksums.git
|
url = https://github.com/awslabs/aws-checksums
|
||||||
[submodule "contrib/curl"]
|
[submodule "contrib/curl"]
|
||||||
path = contrib/curl
|
path = contrib/curl
|
||||||
url = https://github.com/curl/curl.git
|
url = https://github.com/curl/curl
|
||||||
[submodule "contrib/icudata"]
|
[submodule "contrib/icudata"]
|
||||||
path = contrib/icudata
|
path = contrib/icudata
|
||||||
url = https://github.com/ClickHouse-Extras/icudata.git
|
url = https://github.com/ClickHouse/icudata
|
||||||
[submodule "contrib/icu"]
|
[submodule "contrib/icu"]
|
||||||
path = contrib/icu
|
path = contrib/icu
|
||||||
url = https://github.com/unicode-org/icu.git
|
url = https://github.com/unicode-org/icu
|
||||||
[submodule "contrib/flatbuffers"]
|
[submodule "contrib/flatbuffers"]
|
||||||
path = contrib/flatbuffers
|
path = contrib/flatbuffers
|
||||||
url = https://github.com/ClickHouse-Extras/flatbuffers.git
|
url = https://github.com/ClickHouse/flatbuffers
|
||||||
[submodule "contrib/libc-headers"]
|
|
||||||
path = contrib/libc-headers
|
|
||||||
url = https://github.com/ClickHouse-Extras/libc-headers.git
|
|
||||||
[submodule "contrib/replxx"]
|
[submodule "contrib/replxx"]
|
||||||
path = contrib/replxx
|
path = contrib/replxx
|
||||||
url = https://github.com/AmokHuginnsson/replxx.git
|
url = https://github.com/ClickHouse/replxx
|
||||||
[submodule "contrib/avro"]
|
[submodule "contrib/avro"]
|
||||||
path = contrib/avro
|
path = contrib/avro
|
||||||
url = https://github.com/ClickHouse-Extras/avro.git
|
url = https://github.com/ClickHouse/avro
|
||||||
ignore = untracked
|
ignore = untracked
|
||||||
[submodule "contrib/msgpack-c"]
|
[submodule "contrib/msgpack-c"]
|
||||||
path = contrib/msgpack-c
|
path = contrib/msgpack-c
|
||||||
url = https://github.com/msgpack/msgpack-c
|
url = https://github.com/msgpack/msgpack-c
|
||||||
[submodule "contrib/libcpuid"]
|
[submodule "contrib/libcpuid"]
|
||||||
path = contrib/libcpuid
|
path = contrib/libcpuid
|
||||||
url = https://github.com/ClickHouse-Extras/libcpuid.git
|
url = https://github.com/ClickHouse/libcpuid
|
||||||
[submodule "contrib/openldap"]
|
[submodule "contrib/openldap"]
|
||||||
path = contrib/openldap
|
path = contrib/openldap
|
||||||
url = https://github.com/ClickHouse-Extras/openldap.git
|
url = https://github.com/ClickHouse/openldap
|
||||||
[submodule "contrib/AMQP-CPP"]
|
[submodule "contrib/AMQP-CPP"]
|
||||||
path = contrib/AMQP-CPP
|
path = contrib/AMQP-CPP
|
||||||
url = https://github.com/ClickHouse-Extras/AMQP-CPP.git
|
url = https://github.com/ClickHouse/AMQP-CPP
|
||||||
[submodule "contrib/cassandra"]
|
[submodule "contrib/cassandra"]
|
||||||
path = contrib/cassandra
|
path = contrib/cassandra
|
||||||
url = https://github.com/ClickHouse-Extras/cpp-driver.git
|
url = https://github.com/ClickHouse/cpp-driver
|
||||||
branch = clickhouse
|
branch = clickhouse
|
||||||
[submodule "contrib/libuv"]
|
[submodule "contrib/libuv"]
|
||||||
path = contrib/libuv
|
path = contrib/libuv
|
||||||
url = https://github.com/ClickHouse-Extras/libuv.git
|
url = https://github.com/ClickHouse/libuv
|
||||||
branch = clickhouse
|
branch = clickhouse
|
||||||
[submodule "contrib/fmtlib"]
|
[submodule "contrib/fmtlib"]
|
||||||
path = contrib/fmtlib
|
path = contrib/fmtlib
|
||||||
url = https://github.com/fmtlib/fmt.git
|
url = https://github.com/fmtlib/fmt
|
||||||
[submodule "contrib/sentry-native"]
|
[submodule "contrib/sentry-native"]
|
||||||
path = contrib/sentry-native
|
path = contrib/sentry-native
|
||||||
url = https://github.com/ClickHouse-Extras/sentry-native.git
|
url = https://github.com/ClickHouse/sentry-native
|
||||||
[submodule "contrib/gcem"]
|
|
||||||
path = contrib/gcem
|
|
||||||
url = https://github.com/kthohr/gcem.git
|
|
||||||
[submodule "contrib/stats"]
|
|
||||||
path = contrib/stats
|
|
||||||
url = https://github.com/kthohr/stats.git
|
|
||||||
[submodule "contrib/krb5"]
|
[submodule "contrib/krb5"]
|
||||||
path = contrib/krb5
|
path = contrib/krb5
|
||||||
url = https://github.com/ClickHouse-Extras/krb5
|
url = https://github.com/ClickHouse/krb5
|
||||||
[submodule "contrib/cyrus-sasl"]
|
[submodule "contrib/cyrus-sasl"]
|
||||||
path = contrib/cyrus-sasl
|
path = contrib/cyrus-sasl
|
||||||
url = https://github.com/ClickHouse-Extras/cyrus-sasl
|
url = https://github.com/ClickHouse/cyrus-sasl
|
||||||
branch = cyrus-sasl-2.1
|
branch = cyrus-sasl-2.1
|
||||||
[submodule "contrib/croaring"]
|
[submodule "contrib/croaring"]
|
||||||
path = contrib/croaring
|
path = contrib/croaring
|
||||||
@ -193,60 +168,63 @@
|
|||||||
url = https://github.com/danlark1/miniselect
|
url = https://github.com/danlark1/miniselect
|
||||||
[submodule "contrib/rocksdb"]
|
[submodule "contrib/rocksdb"]
|
||||||
path = contrib/rocksdb
|
path = contrib/rocksdb
|
||||||
url = https://github.com/ClickHouse-Extras/rocksdb.git
|
url = https://github.com/ClickHouse/rocksdb
|
||||||
[submodule "contrib/xz"]
|
[submodule "contrib/xz"]
|
||||||
path = contrib/xz
|
path = contrib/xz
|
||||||
url = https://github.com/xz-mirror/xz
|
url = https://github.com/xz-mirror/xz
|
||||||
[submodule "contrib/abseil-cpp"]
|
[submodule "contrib/abseil-cpp"]
|
||||||
path = contrib/abseil-cpp
|
path = contrib/abseil-cpp
|
||||||
url = https://github.com/ClickHouse-Extras/abseil-cpp.git
|
url = https://github.com/abseil/abseil-cpp
|
||||||
branch = lts_2020_02_25
|
branch = lts_2021_11_02
|
||||||
[submodule "contrib/dragonbox"]
|
[submodule "contrib/dragonbox"]
|
||||||
path = contrib/dragonbox
|
path = contrib/dragonbox
|
||||||
url = https://github.com/ClickHouse-Extras/dragonbox.git
|
url = https://github.com/ClickHouse/dragonbox
|
||||||
[submodule "contrib/fast_float"]
|
[submodule "contrib/fast_float"]
|
||||||
path = contrib/fast_float
|
path = contrib/fast_float
|
||||||
url = https://github.com/fastfloat/fast_float
|
url = https://github.com/fastfloat/fast_float
|
||||||
[submodule "contrib/libpq"]
|
[submodule "contrib/libpq"]
|
||||||
path = contrib/libpq
|
path = contrib/libpq
|
||||||
url = https://github.com/ClickHouse-Extras/libpq
|
url = https://github.com/ClickHouse/libpq
|
||||||
[submodule "contrib/boringssl"]
|
[submodule "contrib/boringssl"]
|
||||||
path = contrib/boringssl
|
path = contrib/boringssl
|
||||||
url = https://github.com/ClickHouse-Extras/boringssl.git
|
url = https://github.com/ClickHouse/boringssl
|
||||||
branch = MergeWithUpstream
|
branch = unknown_branch_from_artur
|
||||||
[submodule "contrib/NuRaft"]
|
[submodule "contrib/NuRaft"]
|
||||||
path = contrib/NuRaft
|
path = contrib/NuRaft
|
||||||
url = https://github.com/ClickHouse-Extras/NuRaft.git
|
url = https://github.com/ClickHouse/NuRaft
|
||||||
[submodule "contrib/nanodbc"]
|
[submodule "contrib/nanodbc"]
|
||||||
path = contrib/nanodbc
|
path = contrib/nanodbc
|
||||||
url = https://github.com/ClickHouse-Extras/nanodbc.git
|
url = https://github.com/ClickHouse/nanodbc
|
||||||
[submodule "contrib/datasketches-cpp"]
|
[submodule "contrib/datasketches-cpp"]
|
||||||
path = contrib/datasketches-cpp
|
path = contrib/datasketches-cpp
|
||||||
url = https://github.com/ClickHouse-Extras/datasketches-cpp.git
|
url = https://github.com/ClickHouse/datasketches-cpp
|
||||||
[submodule "contrib/yaml-cpp"]
|
[submodule "contrib/yaml-cpp"]
|
||||||
path = contrib/yaml-cpp
|
path = contrib/yaml-cpp
|
||||||
url = https://github.com/ClickHouse-Extras/yaml-cpp.git
|
url = https://github.com/ClickHouse/yaml-cpp
|
||||||
|
[submodule "contrib/cld2"]
|
||||||
|
path = contrib/cld2
|
||||||
|
url = https://github.com/ClickHouse/cld2
|
||||||
[submodule "contrib/libstemmer_c"]
|
[submodule "contrib/libstemmer_c"]
|
||||||
path = contrib/libstemmer_c
|
path = contrib/libstemmer_c
|
||||||
url = https://github.com/ClickHouse-Extras/libstemmer_c.git
|
url = https://github.com/ClickHouse/libstemmer_c
|
||||||
[submodule "contrib/wordnet-blast"]
|
[submodule "contrib/wordnet-blast"]
|
||||||
path = contrib/wordnet-blast
|
path = contrib/wordnet-blast
|
||||||
url = https://github.com/ClickHouse-Extras/wordnet-blast.git
|
url = https://github.com/ClickHouse/wordnet-blast
|
||||||
[submodule "contrib/lemmagen-c"]
|
[submodule "contrib/lemmagen-c"]
|
||||||
path = contrib/lemmagen-c
|
path = contrib/lemmagen-c
|
||||||
url = https://github.com/ClickHouse-Extras/lemmagen-c.git
|
url = https://github.com/ClickHouse/lemmagen-c
|
||||||
[submodule "contrib/libpqxx"]
|
[submodule "contrib/libpqxx"]
|
||||||
path = contrib/libpqxx
|
path = contrib/libpqxx
|
||||||
url = https://github.com/ClickHouse-Extras/libpqxx.git
|
url = https://github.com/ClickHouse/libpqxx
|
||||||
[submodule "contrib/sqlite-amalgamation"]
|
[submodule "contrib/sqlite-amalgamation"]
|
||||||
path = contrib/sqlite-amalgamation
|
path = contrib/sqlite-amalgamation
|
||||||
url = https://github.com/azadkuh/sqlite-amalgamation
|
url = https://github.com/ClickHouse/sqlite-amalgamation
|
||||||
[submodule "contrib/s2geometry"]
|
[submodule "contrib/s2geometry"]
|
||||||
path = contrib/s2geometry
|
path = contrib/s2geometry
|
||||||
url = https://github.com/ClickHouse-Extras/s2geometry.git
|
url = https://github.com/ClickHouse/s2geometry
|
||||||
[submodule "contrib/bzip2"]
|
[submodule "contrib/bzip2"]
|
||||||
path = contrib/bzip2
|
path = contrib/bzip2
|
||||||
url = https://github.com/ClickHouse-Extras/bzip2.git
|
url = https://github.com/ClickHouse/bzip2
|
||||||
[submodule "contrib/magic_enum"]
|
[submodule "contrib/magic_enum"]
|
||||||
path = contrib/magic_enum
|
path = contrib/magic_enum
|
||||||
url = https://github.com/Neargye/magic_enum
|
url = https://github.com/Neargye/magic_enum
|
||||||
@ -255,4 +233,102 @@
|
|||||||
url = https://github.com/google/libprotobuf-mutator
|
url = https://github.com/google/libprotobuf-mutator
|
||||||
[submodule "contrib/sysroot"]
|
[submodule "contrib/sysroot"]
|
||||||
path = contrib/sysroot
|
path = contrib/sysroot
|
||||||
url = https://github.com/ClickHouse-Extras/sysroot.git
|
url = https://github.com/ClickHouse/sysroot
|
||||||
|
[submodule "contrib/nlp-data"]
|
||||||
|
path = contrib/nlp-data
|
||||||
|
url = https://github.com/ClickHouse/nlp-data
|
||||||
|
[submodule "contrib/hive-metastore"]
|
||||||
|
path = contrib/hive-metastore
|
||||||
|
url = https://github.com/ClickHouse/hive-metastore
|
||||||
|
[submodule "contrib/azure"]
|
||||||
|
path = contrib/azure
|
||||||
|
url = https://github.com/ClickHouse/azure-sdk-for-cpp
|
||||||
|
[submodule "contrib/minizip-ng"]
|
||||||
|
path = contrib/minizip-ng
|
||||||
|
url = https://github.com/zlib-ng/minizip-ng
|
||||||
|
[submodule "contrib/annoy"]
|
||||||
|
path = contrib/annoy
|
||||||
|
url = https://github.com/ClickHouse/annoy
|
||||||
|
branch = ClickHouse-master
|
||||||
|
[submodule "contrib/qpl"]
|
||||||
|
path = contrib/qpl
|
||||||
|
url = https://github.com/intel/qpl
|
||||||
|
[submodule "contrib/idxd-config"]
|
||||||
|
path = contrib/idxd-config
|
||||||
|
url = https://github.com/intel/idxd-config
|
||||||
|
[submodule "contrib/wyhash"]
|
||||||
|
path = contrib/wyhash
|
||||||
|
url = https://github.com/wangyi-fudan/wyhash
|
||||||
|
[submodule "contrib/hashidsxx"]
|
||||||
|
path = contrib/hashidsxx
|
||||||
|
url = https://github.com/schoentoon/hashidsxx
|
||||||
|
[submodule "contrib/nats-io"]
|
||||||
|
path = contrib/nats-io
|
||||||
|
url = https://github.com/ClickHouse/nats.c
|
||||||
|
[submodule "contrib/vectorscan"]
|
||||||
|
path = contrib/vectorscan
|
||||||
|
url = https://github.com/VectorCamp/vectorscan
|
||||||
|
[submodule "contrib/c-ares"]
|
||||||
|
path = contrib/c-ares
|
||||||
|
url = https://github.com/ClickHouse/c-ares
|
||||||
|
[submodule "contrib/llvm-project"]
|
||||||
|
path = contrib/llvm-project
|
||||||
|
url = https://github.com/ClickHouse/llvm-project
|
||||||
|
[submodule "contrib/corrosion"]
|
||||||
|
path = contrib/corrosion
|
||||||
|
url = https://github.com/corrosion-rs/corrosion
|
||||||
|
[submodule "contrib/morton-nd"]
|
||||||
|
path = contrib/morton-nd
|
||||||
|
url = https://github.com/morton-nd/morton-nd
|
||||||
|
[submodule "contrib/xxHash"]
|
||||||
|
path = contrib/xxHash
|
||||||
|
url = https://github.com/Cyan4973/xxHash
|
||||||
|
[submodule "contrib/crc32-s390x"]
|
||||||
|
path = contrib/crc32-s390x
|
||||||
|
url = https://github.com/linux-on-ibm-z/crc32-s390x
|
||||||
|
[submodule "contrib/openssl"]
|
||||||
|
path = contrib/openssl
|
||||||
|
url = https://github.com/openssl/openssl
|
||||||
|
branch = openssl-3.0
|
||||||
|
[submodule "contrib/google-benchmark"]
|
||||||
|
path = contrib/google-benchmark
|
||||||
|
url = https://github.com/google/benchmark
|
||||||
|
[submodule "contrib/libdivide"]
|
||||||
|
path = contrib/libdivide
|
||||||
|
url = https://github.com/ridiculousfish/libdivide
|
||||||
|
[submodule "contrib/aws-crt-cpp"]
|
||||||
|
path = contrib/aws-crt-cpp
|
||||||
|
url = https://github.com/ClickHouse/aws-crt-cpp
|
||||||
|
[submodule "contrib/aws-c-io"]
|
||||||
|
path = contrib/aws-c-io
|
||||||
|
url = https://github.com/ClickHouse/aws-c-io
|
||||||
|
[submodule "contrib/aws-c-mqtt"]
|
||||||
|
path = contrib/aws-c-mqtt
|
||||||
|
url = https://github.com/awslabs/aws-c-mqtt
|
||||||
|
[submodule "contrib/aws-c-auth"]
|
||||||
|
path = contrib/aws-c-auth
|
||||||
|
url = https://github.com/awslabs/aws-c-auth
|
||||||
|
[submodule "contrib/aws-c-cal"]
|
||||||
|
path = contrib/aws-c-cal
|
||||||
|
url = https://github.com/ClickHouse/aws-c-cal
|
||||||
|
[submodule "contrib/aws-c-sdkutils"]
|
||||||
|
path = contrib/aws-c-sdkutils
|
||||||
|
url = https://github.com/awslabs/aws-c-sdkutils
|
||||||
|
[submodule "contrib/aws-c-http"]
|
||||||
|
path = contrib/aws-c-http
|
||||||
|
url = https://github.com/awslabs/aws-c-http
|
||||||
|
[submodule "contrib/aws-c-s3"]
|
||||||
|
path = contrib/aws-c-s3
|
||||||
|
url = https://github.com/awslabs/aws-c-s3
|
||||||
|
[submodule "contrib/aws-c-compression"]
|
||||||
|
path = contrib/aws-c-compression
|
||||||
|
url = https://github.com/awslabs/aws-c-compression
|
||||||
|
[submodule "contrib/aws-s2n-tls"]
|
||||||
|
path = contrib/aws-s2n-tls
|
||||||
|
url = https://github.com/ClickHouse/s2n-tls
|
||||||
|
[submodule "contrib/crc32-vpmsum"]
|
||||||
|
path = contrib/crc32-vpmsum
|
||||||
|
url = https://github.com/antonblanchard/crc32-vpmsum.git
|
||||||
|
[submodule "contrib/liburing"]
|
||||||
|
path = contrib/liburing
|
||||||
|
url = https://github.com/axboe/liburing
|
||||||
|
27
.potato.yml
27
.potato.yml
@ -1,27 +0,0 @@
|
|||||||
# This is the configuration file with settings for Potato.
|
|
||||||
# Potato is an internal Yandex technology that allows us to sync internal [Yandex.Tracker](https://yandex.com/tracker/) and GitHub.
|
|
||||||
|
|
||||||
# For all PRs where documentation is needed, just add a 'pr-feature' label and we will include it into documentation sprints.
|
|
||||||
|
|
||||||
# The project name.
|
|
||||||
name: clickhouse
|
|
||||||
# Object handlers defines which handlers we use.
|
|
||||||
handlers:
|
|
||||||
# The handler for creating an Yandex.Tracker issue.
|
|
||||||
- name: issue-create
|
|
||||||
params:
|
|
||||||
triggers:
|
|
||||||
# The trigger for creating the Yandex.Tracker issue. When the specified event occurs, it transfers PR data to Yandex.Tracker.
|
|
||||||
github:pullRequest:labeled:
|
|
||||||
data:
|
|
||||||
# The Yandex.Tracker queue to create the issue in. Each issue in Tracker belongs to one of the project queues.
|
|
||||||
queue: CLICKHOUSEDOCS
|
|
||||||
# The issue title.
|
|
||||||
summary: '[Potato] Pull Request #{{pullRequest.number}}'
|
|
||||||
# The issue description.
|
|
||||||
description: >
|
|
||||||
{{pullRequest.description}}
|
|
||||||
|
|
||||||
Ссылка на Pull Request: {{pullRequest.webUrl}}
|
|
||||||
# The condition for creating the Yandex.Tracker issue.
|
|
||||||
condition: eventPayload.labels.filter(label => ['pr-feature'].includes(label.name)).length
|
|
@ -13,9 +13,7 @@ max-statements=200
|
|||||||
ignore-long-lines = (# )?<?https?://\S+>?$
|
ignore-long-lines = (# )?<?https?://\S+>?$
|
||||||
|
|
||||||
[MESSAGES CONTROL]
|
[MESSAGES CONTROL]
|
||||||
disable = bad-continuation,
|
disable = missing-docstring,
|
||||||
missing-docstring,
|
|
||||||
bad-whitespace,
|
|
||||||
too-few-public-methods,
|
too-few-public-methods,
|
||||||
invalid-name,
|
invalid-name,
|
||||||
too-many-arguments,
|
too-many-arguments,
|
||||||
|
4
.snyk
Normal file
4
.snyk
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Snyk (https://snyk.io) policy file
|
||||||
|
exclude:
|
||||||
|
global:
|
||||||
|
- tests/**
|
2
.vimrc
2
.vimrc
@ -1,2 +0,0 @@
|
|||||||
au BufRead,BufNewFile ./* set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab tags=tags,../tags
|
|
||||||
|
|
2024
CHANGELOG.md
2024
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
527
CMakeLists.txt
527
CMakeLists.txt
@ -1,32 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
foreach(policy
|
project(ClickHouse LANGUAGES C CXX ASM)
|
||||||
CMP0023
|
|
||||||
CMP0048 # CMake 3.0
|
|
||||||
CMP0074 # CMake 3.12
|
|
||||||
CMP0077
|
|
||||||
CMP0079
|
|
||||||
)
|
|
||||||
if(POLICY ${policy})
|
|
||||||
cmake_policy(SET ${policy} NEW)
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# set default policy
|
|
||||||
foreach(default_policy_var_name
|
|
||||||
# make option() honor normal variables for BUILD_SHARED_LIBS:
|
|
||||||
# - re2
|
|
||||||
# - snappy
|
|
||||||
CMAKE_POLICY_DEFAULT_CMP0077
|
|
||||||
# Google Test from sources uses too old cmake, 2.6.x, and CMP0022 should
|
|
||||||
# set, to avoid using deprecated LINK_INTERFACE_LIBRARIES(_<CONFIG>)? over
|
|
||||||
# INTERFACE_LINK_LIBRARIES.
|
|
||||||
CMAKE_POLICY_DEFAULT_CMP0022
|
|
||||||
)
|
|
||||||
set(${default_policy_var_name} NEW)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
project(ClickHouse)
|
|
||||||
|
|
||||||
# If turned off: e.g. when ENABLE_FOO is ON, but FOO tool was not found, the CMake will continue.
|
# If turned off: e.g. when ENABLE_FOO is ON, but FOO tool was not found, the CMake will continue.
|
||||||
option(FAIL_ON_UNSUPPORTED_OPTIONS_COMBINATION
|
option(FAIL_ON_UNSUPPORTED_OPTIONS_COMBINATION
|
||||||
@ -39,20 +13,18 @@ else()
|
|||||||
set(RECONFIGURE_MESSAGE_LEVEL WARNING)
|
set(RECONFIGURE_MESSAGE_LEVEL WARNING)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
enable_language(C CXX ASM)
|
|
||||||
|
|
||||||
include (cmake/arch.cmake)
|
include (cmake/arch.cmake)
|
||||||
include (cmake/target.cmake)
|
include (cmake/target.cmake)
|
||||||
include (cmake/tools.cmake)
|
include (cmake/tools.cmake)
|
||||||
include (cmake/analysis.cmake)
|
include (cmake/ccache.cmake)
|
||||||
include (cmake/git_status.cmake)
|
include (cmake/clang_tidy.cmake)
|
||||||
|
include (cmake/git.cmake)
|
||||||
|
|
||||||
# Ignore export() since we don't use it,
|
# Ignore export() since we don't use it,
|
||||||
# but it gets broken with a global targets via link_libraries()
|
# but it gets broken with a global targets via link_libraries()
|
||||||
macro (export)
|
macro (export)
|
||||||
endmacro ()
|
endmacro ()
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS 1) # Write compile_commands.json
|
set(CMAKE_EXPORT_COMPILE_COMMANDS 1) # Write compile_commands.json
|
||||||
set(CMAKE_LINK_DEPENDS_NO_SHARED 1) # Do not relink all depended targets on .so
|
set(CMAKE_LINK_DEPENDS_NO_SHARED 1) # Do not relink all depended targets on .so
|
||||||
set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Debug;Release;MinSizeRel" CACHE STRING "" FORCE)
|
set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Debug;Release;MinSizeRel" CACHE STRING "" FORCE)
|
||||||
@ -62,13 +34,11 @@ set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Generate debug library name with a pos
|
|||||||
# For more info see https://cmake.org/cmake/help/latest/prop_gbl/USE_FOLDERS.html
|
# For more info see https://cmake.org/cmake/help/latest/prop_gbl/USE_FOLDERS.html
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
# Check that submodules are present only if source was downloaded with git
|
# Check that submodules are present
|
||||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git" AND NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/boost/boost")
|
if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/sysroot/README.md")
|
||||||
message (FATAL_ERROR "Submodules are not initialized. Run\n\tgit submodule update --init --recursive")
|
message (FATAL_ERROR "Submodules are not initialized. Run\n\tgit submodule update --init")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
include (cmake/find/ccache.cmake)
|
|
||||||
|
|
||||||
# Take care to add prlimit in command line before ccache, or else ccache thinks that
|
# Take care to add prlimit in command line before ccache, or else ccache thinks that
|
||||||
# prlimit is compiler, and clang++ is its input file, and refuses to work with
|
# prlimit is compiler, and clang++ is its input file, and refuses to work with
|
||||||
# multiple inputs, e.g in ccache log:
|
# multiple inputs, e.g in ccache log:
|
||||||
@ -103,29 +73,7 @@ message (STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
|
|||||||
|
|
||||||
string (TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC)
|
string (TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC)
|
||||||
|
|
||||||
option(USE_STATIC_LIBRARIES "Disable to use shared libraries" ON)
|
list(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
|
||||||
option(MAKE_STATIC_LIBRARIES "Disable to make shared libraries" ${USE_STATIC_LIBRARIES})
|
|
||||||
|
|
||||||
if (NOT MAKE_STATIC_LIBRARIES)
|
|
||||||
# DEVELOPER ONLY.
|
|
||||||
# Faster linking if turned on.
|
|
||||||
option(SPLIT_SHARED_LIBRARIES "Keep all internal libraries as separate .so files")
|
|
||||||
|
|
||||||
option(CLICKHOUSE_SPLIT_BINARY
|
|
||||||
"Make several binaries (clickhouse-server, clickhouse-client etc.) instead of one bundled")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (MAKE_STATIC_LIBRARIES AND SPLIT_SHARED_LIBRARIES)
|
|
||||||
message(FATAL_ERROR "Defining SPLIT_SHARED_LIBRARIES=1 without MAKE_STATIC_LIBRARIES=0 has no effect.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (NOT MAKE_STATIC_LIBRARIES AND SPLIT_SHARED_LIBRARIES)
|
|
||||||
set(BUILD_SHARED_LIBS 1 CACHE INTERNAL "")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (USE_STATIC_LIBRARIES)
|
|
||||||
list(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
option (ENABLE_FUZZING "Fuzzy testing using libfuzzer" OFF)
|
option (ENABLE_FUZZING "Fuzzy testing using libfuzzer" OFF)
|
||||||
|
|
||||||
@ -139,7 +87,6 @@ if (ENABLE_FUZZING)
|
|||||||
set (ENABLE_CLICKHOUSE_ODBC_BRIDGE OFF)
|
set (ENABLE_CLICKHOUSE_ODBC_BRIDGE OFF)
|
||||||
set (ENABLE_LIBRARIES 0)
|
set (ENABLE_LIBRARIES 0)
|
||||||
set (ENABLE_SSL 1)
|
set (ENABLE_SSL 1)
|
||||||
set (USE_INTERNAL_SSL_LIBRARY 1)
|
|
||||||
set (USE_UNWIND ON)
|
set (USE_UNWIND ON)
|
||||||
set (ENABLE_EMBEDDED_COMPILER 0)
|
set (ENABLE_EMBEDDED_COMPILER 0)
|
||||||
set (ENABLE_EXAMPLES 0)
|
set (ENABLE_EXAMPLES 0)
|
||||||
@ -149,6 +96,10 @@ if (ENABLE_FUZZING)
|
|||||||
set (ENABLE_JEMALLOC 0)
|
set (ENABLE_JEMALLOC 0)
|
||||||
set (ENABLE_CHECK_HEAVY_BUILDS 1)
|
set (ENABLE_CHECK_HEAVY_BUILDS 1)
|
||||||
set (GLIBC_COMPATIBILITY OFF)
|
set (GLIBC_COMPATIBILITY OFF)
|
||||||
|
set (ENABLE_BENCHMARKS 0)
|
||||||
|
|
||||||
|
# For codegen_select_fuzzer
|
||||||
|
set (ENABLE_PROTOBUF 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Global libraries
|
# Global libraries
|
||||||
@ -160,34 +111,38 @@ add_library(global-libs INTERFACE)
|
|||||||
include (cmake/fuzzer.cmake)
|
include (cmake/fuzzer.cmake)
|
||||||
include (cmake/sanitize.cmake)
|
include (cmake/sanitize.cmake)
|
||||||
|
|
||||||
if (CMAKE_GENERATOR STREQUAL "Ninja" AND NOT DISABLE_COLORED_BUILD)
|
option(ENABLE_COLORED_BUILD "Enable colors in compiler output" ON)
|
||||||
|
|
||||||
|
set (CMAKE_COLOR_MAKEFILE ${ENABLE_COLORED_BUILD}) # works only for the makefile generator
|
||||||
|
|
||||||
|
if (ENABLE_COLORED_BUILD AND CMAKE_GENERATOR STREQUAL "Ninja")
|
||||||
# Turn on colored output. https://github.com/ninja-build/ninja/wiki/FAQ
|
# Turn on colored output. https://github.com/ninja-build/ninja/wiki/FAQ
|
||||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
|
||||||
|
# ... such manually setting of flags can be removed once CMake supports a variable to
|
||||||
|
# activate colors in *all* build systems: https://gitlab.kitware.com/cmake/cmake/-/issues/15502
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
include (cmake/check_flags.cmake)
|
include (cmake/check_flags.cmake)
|
||||||
include (cmake/add_warning.cmake)
|
include (cmake/add_warning.cmake)
|
||||||
|
|
||||||
if (NOT MSVC)
|
|
||||||
set (COMMON_WARNING_FLAGS "${COMMON_WARNING_FLAGS} -Wall") # -Werror and many more is also added inside cmake/warnings.cmake
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (COMPILER_CLANG)
|
if (COMPILER_CLANG)
|
||||||
# clang: warning: argument unused during compilation: '-specs=/usr/share/dpkg/no-pie-compile.specs' [-Wunused-command-line-argument]
|
|
||||||
set (COMMON_WARNING_FLAGS "${COMMON_WARNING_FLAGS} -Wno-unused-command-line-argument")
|
|
||||||
# generate ranges for fast "addr2line" search
|
# generate ranges for fast "addr2line" search
|
||||||
if (NOT CMAKE_BUILD_TYPE_UC STREQUAL "RELEASE")
|
if (NOT CMAKE_BUILD_TYPE_UC STREQUAL "RELEASE")
|
||||||
|
# NOTE: that clang has a bug because of it does not emit .debug_aranges
|
||||||
|
# with ThinLTO, so custom ld.lld wrapper is shipped in docker images.
|
||||||
set(COMPILER_FLAGS "${COMPILER_FLAGS} -gdwarf-aranges")
|
set(COMPILER_FLAGS "${COMPILER_FLAGS} -gdwarf-aranges")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (HAS_USE_CTOR_HOMING)
|
if (HAS_USE_CTOR_HOMING)
|
||||||
# For more info see https://blog.llvm.org/posts/2021-04-05-constructor-homing-for-debug-info/
|
# For more info see https://blog.llvm.org/posts/2021-04-05-constructor-homing-for-debug-info/
|
||||||
if (CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE_UC STREQUAL "RELWITHDEBINFO")
|
if (CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE_UC STREQUAL "RELWITHDEBINFO")
|
||||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -fuse-ctor-homing")
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -fuse-ctor-homing")
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Xclang -fuse-ctor-homing")
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Xclang -fuse-ctor-homing")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
no_warning(enum-constexpr-conversion) # breaks Protobuf in clang-16
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# If compiler has support for -Wreserved-identifier. It is difficult to detect by clang version,
|
# If compiler has support for -Wreserved-identifier. It is difficult to detect by clang version,
|
||||||
@ -197,70 +152,44 @@ if (HAS_RESERVED_IDENTIFIER)
|
|||||||
add_compile_definitions (HAS_RESERVED_IDENTIFIER)
|
add_compile_definitions (HAS_RESERVED_IDENTIFIER)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# If turned `ON`, assumes the user has either the system GTest library or the bundled one.
|
|
||||||
option(ENABLE_TESTS "Provide unit_test_dbms target with Google.Test unit tests" ON)
|
option(ENABLE_TESTS "Provide unit_test_dbms target with Google.Test unit tests" ON)
|
||||||
option(ENABLE_EXAMPLES "Build all example programs in 'examples' subdirectories" OFF)
|
option(ENABLE_EXAMPLES "Build all example programs in 'examples' subdirectories" OFF)
|
||||||
|
option(ENABLE_BENCHMARKS "Build all benchmark programs in 'benchmarks' subdirectories" OFF)
|
||||||
|
|
||||||
if (OS_LINUX AND (ARCH_AMD64 OR ARCH_AARCH64) AND NOT UNBUNDLED AND MAKE_STATIC_LIBRARIES AND NOT SPLIT_SHARED_LIBRARIES AND NOT USE_MUSL)
|
if (OS_LINUX AND (ARCH_AMD64 OR ARCH_AARCH64) AND NOT USE_MUSL)
|
||||||
# Only for Linux, x86_64 or aarch64.
|
# Only for Linux, x86_64 or aarch64.
|
||||||
option(GLIBC_COMPATIBILITY "Enable compatibility with older glibc libraries." ON)
|
option(GLIBC_COMPATIBILITY "Enable compatibility with older glibc libraries." ON)
|
||||||
elseif(GLIBC_COMPATIBILITY)
|
elseif(GLIBC_COMPATIBILITY)
|
||||||
message (${RECONFIGURE_MESSAGE_LEVEL} "Glibc compatibility cannot be enabled in current configuration")
|
message (${RECONFIGURE_MESSAGE_LEVEL} "Glibc compatibility cannot be enabled in current configuration")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (GLIBC_COMPATIBILITY)
|
|
||||||
# NOTE: we may also want to check glibc version and add -include only for 2.32+
|
|
||||||
# however this is extra complexity, especially for cross compiling.
|
|
||||||
# And anyway it should not break anything for <2.32.
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include ${CMAKE_CURRENT_SOURCE_DIR}/base/glibc-compatibility/glibc-compat-2.32.h")
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -include ${CMAKE_CURRENT_SOURCE_DIR}/base/glibc-compatibility/glibc-compat-2.32.h")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Make sure the final executable has symbols exported
|
# Make sure the final executable has symbols exported
|
||||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
|
||||||
|
|
||||||
find_program (OBJCOPY_PATH NAMES "llvm-objcopy" "llvm-objcopy-13" "llvm-objcopy-12" "llvm-objcopy-11" "llvm-objcopy-10" "llvm-objcopy-9" "llvm-objcopy-8" "objcopy")
|
|
||||||
|
|
||||||
if (NOT OBJCOPY_PATH AND OS_DARWIN)
|
|
||||||
find_program (BREW_PATH NAMES "brew")
|
|
||||||
if (BREW_PATH)
|
|
||||||
execute_process (COMMAND ${BREW_PATH} --prefix llvm ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE LLVM_PREFIX)
|
|
||||||
if (LLVM_PREFIX)
|
|
||||||
find_program (OBJCOPY_PATH NAMES "llvm-objcopy" PATHS "${LLVM_PREFIX}/bin" NO_DEFAULT_PATH)
|
|
||||||
endif ()
|
|
||||||
if (NOT OBJCOPY_PATH)
|
|
||||||
execute_process (COMMAND ${BREW_PATH} --prefix binutils ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE BINUTILS_PREFIX)
|
|
||||||
if (BINUTILS_PREFIX)
|
|
||||||
find_program (OBJCOPY_PATH NAMES "objcopy" PATHS "${BINUTILS_PREFIX}/bin" NO_DEFAULT_PATH)
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (OBJCOPY_PATH)
|
|
||||||
message (STATUS "Using objcopy: ${OBJCOPY_PATH}")
|
|
||||||
else ()
|
|
||||||
message (FATAL_ERROR "Cannot find objcopy.")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (OS_DARWIN)
|
if (OS_DARWIN)
|
||||||
# The `-all_load` flag forces loading of all symbols from all libraries,
|
# The `-all_load` flag forces loading of all symbols from all libraries,
|
||||||
# and leads to multiply-defined symbols. This flag allows force loading
|
# and leads to multiply-defined symbols. This flag allows force loading
|
||||||
# from a _specific_ library, which is what we need.
|
# from a _specific_ library, which is what we need.
|
||||||
set(WHOLE_ARCHIVE -force_load)
|
set(WHOLE_ARCHIVE -force_load)
|
||||||
# The `-noall_load` flag is the default and now obsolete.
|
# The `-noall_load` flag is the default and now obsolete.
|
||||||
set(NO_WHOLE_ARCHIVE "")
|
set(NO_WHOLE_ARCHIVE "-undefined,error") # Effectively, a no-op. Here to avoid empty "-Wl, " sequence to be generated in the command line.
|
||||||
else ()
|
else ()
|
||||||
set(WHOLE_ARCHIVE --whole-archive)
|
set(WHOLE_ARCHIVE --whole-archive)
|
||||||
set(NO_WHOLE_ARCHIVE --no-whole-archive)
|
set(NO_WHOLE_ARCHIVE --no-whole-archive)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
option(ENABLE_CURL_BUILD "Enable curl, azure, sentry build on by default except MacOS." ON)
|
||||||
|
if (OS_DARWIN)
|
||||||
|
# Disable the curl, azure, senry build on MacOS
|
||||||
|
set (ENABLE_CURL_BUILD OFF)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Ignored if `lld` is used
|
# Ignored if `lld` is used
|
||||||
option(ADD_GDB_INDEX_FOR_GOLD "Add .gdb-index to resulting binaries for gold linker.")
|
option(ADD_GDB_INDEX_FOR_GOLD "Add .gdb-index to resulting binaries for gold linker.")
|
||||||
|
|
||||||
if (NOT CMAKE_BUILD_TYPE_UC STREQUAL "RELEASE")
|
if (NOT CMAKE_BUILD_TYPE_UC STREQUAL "RELEASE")
|
||||||
# Can be lld or ld-lld.
|
# Can be lld or ld-lld or lld-13 or /path/to/lld.
|
||||||
if (LINKER_NAME MATCHES "lld$")
|
if (LINKER_NAME MATCHES "lld" AND OS_LINUX)
|
||||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index")
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index")
|
||||||
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gdb-index")
|
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gdb-index")
|
||||||
message (STATUS "Adding .gdb-index via --gdb-index linker option.")
|
message (STATUS "Adding .gdb-index via --gdb-index linker option.")
|
||||||
@ -278,8 +207,35 @@ if (NOT CMAKE_BUILD_TYPE_UC STREQUAL "RELEASE")
|
|||||||
endif ()
|
endif ()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (CMAKE_BUILD_TYPE_UC STREQUAL "RELEASE"
|
||||||
|
OR CMAKE_BUILD_TYPE_UC STREQUAL "RELWITHDEBINFO"
|
||||||
|
OR CMAKE_BUILD_TYPE_UC STREQUAL "MINSIZEREL")
|
||||||
|
set (OMIT_HEAVY_DEBUG_SYMBOLS_DEFAULT ON)
|
||||||
|
else()
|
||||||
|
set (OMIT_HEAVY_DEBUG_SYMBOLS_DEFAULT OFF)
|
||||||
|
endif()
|
||||||
|
# Provides faster linking and lower binary size.
|
||||||
|
# Tradeoff is the inability to debug some source files with e.g. gdb
|
||||||
|
# (empty stack frames and no local variables)."
|
||||||
|
option(OMIT_HEAVY_DEBUG_SYMBOLS
|
||||||
|
"Do not generate debugger info for heavy modules (ClickHouse functions and dictionaries, some contrib)"
|
||||||
|
${OMIT_HEAVY_DEBUG_SYMBOLS_DEFAULT})
|
||||||
|
|
||||||
|
if (CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG")
|
||||||
|
set(USE_DEBUG_HELPERS ON)
|
||||||
|
endif()
|
||||||
|
option(USE_DEBUG_HELPERS "Enable debug helpers" ${USE_DEBUG_HELPERS})
|
||||||
|
|
||||||
|
option(BUILD_STANDALONE_KEEPER "Build keeper as small standalone binary" OFF)
|
||||||
|
if (NOT BUILD_STANDALONE_KEEPER)
|
||||||
|
option(CREATE_KEEPER_SYMLINK "Create symlink for clickhouse-keeper to main server binary" ON)
|
||||||
|
else ()
|
||||||
|
option(CREATE_KEEPER_SYMLINK "Create symlink for clickhouse-keeper to main server binary" OFF)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Create BuildID when using lld. For other linkers it is created by default.
|
# Create BuildID when using lld. For other linkers it is created by default.
|
||||||
if (LINKER_NAME MATCHES "lld$")
|
# (NOTE: LINKER_NAME can be either path or name, and in different variants)
|
||||||
|
if (LINKER_NAME MATCHES "lld" AND OS_LINUX)
|
||||||
# SHA1 is not cryptographically secure but it is the best what lld is offering.
|
# SHA1 is not cryptographically secure but it is the best what lld is offering.
|
||||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id=sha1")
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id=sha1")
|
||||||
endif ()
|
endif ()
|
||||||
@ -287,10 +243,20 @@ endif ()
|
|||||||
# Add a section with the hash of the compiled machine code for integrity checks.
|
# Add a section with the hash of the compiled machine code for integrity checks.
|
||||||
# Only for official builds, because adding a section can be time consuming (rewrite of several GB).
|
# Only for official builds, because adding a section can be time consuming (rewrite of several GB).
|
||||||
# And cross compiled binaries are not supported (since you cannot execute clickhouse hash-binary)
|
# And cross compiled binaries are not supported (since you cannot execute clickhouse hash-binary)
|
||||||
if (OBJCOPY_PATH AND YANDEX_OFFICIAL_BUILD AND (NOT CMAKE_TOOLCHAIN_FILE))
|
if (CLICKHOUSE_OFFICIAL_BUILD AND (NOT CMAKE_TOOLCHAIN_FILE OR CMAKE_TOOLCHAIN_FILE MATCHES "linux/toolchain-x86_64.cmake$"))
|
||||||
set (USE_BINARY_HASH 1)
|
message(STATUS "Official build: A checksum hash will be added to the clickhouse executable")
|
||||||
|
set (USE_BINARY_HASH 1 CACHE STRING "Calculate binary hash and store it in the separate section")
|
||||||
|
else ()
|
||||||
|
message(STATUS "No official build: A checksum hash will not be added to the clickhouse executable")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
# Optionally split binaries and debug symbols.
|
||||||
|
option(SPLIT_DEBUG_SYMBOLS "Split binaries and debug symbols" OFF)
|
||||||
|
if (SPLIT_DEBUG_SYMBOLS)
|
||||||
|
message(STATUS "Will split binaries and debug symbols")
|
||||||
|
set(SPLITTED_DEBUG_SYMBOLS_DIR "stripped" CACHE STRING "A separate directory for stripped information")
|
||||||
|
endif()
|
||||||
|
|
||||||
cmake_host_system_information(RESULT AVAILABLE_PHYSICAL_MEMORY QUERY AVAILABLE_PHYSICAL_MEMORY) # Not available under freebsd
|
cmake_host_system_information(RESULT AVAILABLE_PHYSICAL_MEMORY QUERY AVAILABLE_PHYSICAL_MEMORY) # Not available under freebsd
|
||||||
|
|
||||||
|
|
||||||
@ -312,24 +278,33 @@ include(cmake/cpu_features.cmake)
|
|||||||
# Enable it explicitly.
|
# Enable it explicitly.
|
||||||
set (COMPILER_FLAGS "${COMPILER_FLAGS} -fasynchronous-unwind-tables")
|
set (COMPILER_FLAGS "${COMPILER_FLAGS} -fasynchronous-unwind-tables")
|
||||||
|
|
||||||
if (${CMAKE_VERSION} VERSION_LESS "3.12.4")
|
# Reproducible builds.
|
||||||
# CMake < 3.12 doesn't support setting 20 as a C++ standard version.
|
if (CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG")
|
||||||
# We will add C++ standard controlling flag in CMAKE_CXX_FLAGS manually for now.
|
set (ENABLE_BUILD_PATH_MAPPING_DEFAULT OFF)
|
||||||
|
|
||||||
if (COMPILER_GCC OR COMPILER_CLANG)
|
|
||||||
# to make numeric_limits<__int128> works with GCC
|
|
||||||
set (_CXX_STANDARD "gnu++2a")
|
|
||||||
else ()
|
|
||||||
set (_CXX_STANDARD "c++2a")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=${_CXX_STANDARD}")
|
|
||||||
else ()
|
else ()
|
||||||
set (CMAKE_CXX_STANDARD 20)
|
set (ENABLE_BUILD_PATH_MAPPING_DEFAULT ON)
|
||||||
set (CMAKE_CXX_EXTENSIONS ON) # Same as gnu++2a (ON) vs c++2a (OFF): https://cmake.org/cmake/help/latest/prop_tgt/CXX_EXTENSIONS.html
|
|
||||||
set (CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
option (ENABLE_BUILD_PATH_MAPPING "Enable remapping of file source paths in debug info, predefined preprocessor macros, and __builtin_FILE(). It's used to generate reproducible builds. See https://reproducible-builds.org/docs/build-path" ${ENABLE_BUILD_PATH_MAPPING_DEFAULT})
|
||||||
|
|
||||||
|
if (ENABLE_BUILD_PATH_MAPPING)
|
||||||
|
set (COMPILER_FLAGS "${COMPILER_FLAGS} -ffile-prefix-map=${CMAKE_SOURCE_DIR}=.")
|
||||||
|
set (CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -ffile-prefix-map=${CMAKE_SOURCE_DIR}=.")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
option (ENABLE_BUILD_PROFILING "Enable profiling of build time" OFF)
|
||||||
|
if (ENABLE_BUILD_PROFILING)
|
||||||
|
if (COMPILER_CLANG)
|
||||||
|
set (COMPILER_FLAGS "${COMPILER_FLAGS} -ftime-trace")
|
||||||
|
else ()
|
||||||
|
message (${RECONFIGURE_MESSAGE_LEVEL} "Build profiling is only available with CLang")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set (CMAKE_CXX_STANDARD 20)
|
||||||
|
set (CMAKE_CXX_EXTENSIONS ON) # Same as gnu++2a (ON) vs c++2a (OFF): https://cmake.org/cmake/help/latest/prop_tgt/CXX_EXTENSIONS.html
|
||||||
|
set (CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
set (CMAKE_C_STANDARD 11)
|
set (CMAKE_C_STANDARD 11)
|
||||||
set (CMAKE_C_EXTENSIONS ON)
|
set (CMAKE_C_EXTENSIONS ON)
|
||||||
set (CMAKE_C_STANDARD_REQUIRED ON)
|
set (CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
@ -345,6 +320,22 @@ if (COMPILER_GCC OR COMPILER_CLANG)
|
|||||||
set(COMPILER_FLAGS "${COMPILER_FLAGS} -falign-functions=32")
|
set(COMPILER_FLAGS "${COMPILER_FLAGS} -falign-functions=32")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if (ARCH_AMD64)
|
||||||
|
# align branches within a 32-Byte boundary to avoid the potential performance loss when code layout change,
|
||||||
|
# which makes benchmark results more stable.
|
||||||
|
set(BRANCHES_WITHIN_32B_BOUNDARIES "-mbranches-within-32B-boundaries")
|
||||||
|
if (COMPILER_GCC)
|
||||||
|
# gcc is in assembler, need to add "-Wa," prefix
|
||||||
|
set(BRANCHES_WITHIN_32B_BOUNDARIES "-Wa,${BRANCHES_WITHIN_32B_BOUNDARIES}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
check_cxx_compiler_flag("${BRANCHES_WITHIN_32B_BOUNDARIES}" HAS_BRANCHES_WITHIN_32B_BOUNDARIES)
|
||||||
|
if (HAS_BRANCHES_WITHIN_32B_BOUNDARIES)
|
||||||
|
set(COMPILER_FLAGS "${COMPILER_FLAGS} ${BRANCHES_WITHIN_32B_BOUNDARIES}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (COMPILER_GCC)
|
if (COMPILER_GCC)
|
||||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines")
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines")
|
||||||
endif ()
|
endif ()
|
||||||
@ -364,16 +355,22 @@ if (WITH_COVERAGE AND COMPILER_GCC)
|
|||||||
set(WITHOUT_COVERAGE "-fno-profile-arcs -fno-test-coverage")
|
set(WITHOUT_COVERAGE "-fno-profile-arcs -fno-test-coverage")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(COMPILER_FLAGS "${COMPILER_FLAGS}")
|
set (COMPILER_FLAGS "${COMPILER_FLAGS}")
|
||||||
|
|
||||||
set (CMAKE_BUILD_COLOR_MAKEFILE ON)
|
# Our built-in unwinder only supports DWARF version up to 4.
|
||||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS} ${PLATFORM_EXTRA_CXX_FLAG} ${COMMON_WARNING_FLAGS} ${CXX_WARNING_FLAGS}")
|
set (DEBUG_INFO_FLAGS "-g -gdwarf-4")
|
||||||
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 ${CMAKE_CXX_FLAGS_ADD}")
|
|
||||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3 -ggdb3 -fno-inline ${CMAKE_CXX_FLAGS_ADD}")
|
|
||||||
|
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILER_FLAGS} ${COMMON_WARNING_FLAGS} ${CMAKE_C_FLAGS_ADD}")
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS}")
|
||||||
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3 ${CMAKE_C_FLAGS_ADD}")
|
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 ${DEBUG_INFO_FLAGS} ${CMAKE_CXX_FLAGS_ADD}")
|
||||||
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g3 -ggdb3 -fno-inline ${CMAKE_C_FLAGS_ADD}")
|
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 ${DEBUG_INFO_FLAGS} ${CMAKE_CXX_FLAGS_ADD}")
|
||||||
|
|
||||||
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILER_FLAGS} ${CMAKE_C_FLAGS_ADD}")
|
||||||
|
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3 ${DEBUG_INFO_FLAGS} ${CMAKE_C_FLAGS_ADD}")
|
||||||
|
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 ${DEBUG_INFO_FLAGS} ${CMAKE_C_FLAGS_ADD}")
|
||||||
|
|
||||||
|
set (CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${COMPILER_FLAGS} ${CMAKE_ASM_FLAGS_ADD}")
|
||||||
|
set (CMAKE_ASM_FLAGS_RELWITHDEBINFO "${CMAKE_ASM_FLAGS_RELWITHDEBINFO} -O3 ${DEBUG_INFO_FLAGS} ${CMAKE_ASM_FLAGS_ADD}")
|
||||||
|
set (CMAKE_ASM_FLAGS_DEBUG "${CMAKE_ASM_FLAGS_DEBUG} -O0 ${DEBUG_INFO_FLAGS} ${CMAKE_ASM_FLAGS_ADD}")
|
||||||
|
|
||||||
if (COMPILER_CLANG)
|
if (COMPILER_CLANG)
|
||||||
if (OS_DARWIN)
|
if (OS_DARWIN)
|
||||||
@ -392,6 +389,8 @@ if (COMPILER_CLANG)
|
|||||||
option(ENABLE_THINLTO "Clang-specific link time optimization" ON)
|
option(ENABLE_THINLTO "Clang-specific link time optimization" ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstrict-vtable-pointers")
|
||||||
|
|
||||||
# Set new experimental pass manager, it's a performance, build time and binary size win.
|
# Set new experimental pass manager, it's a performance, build time and binary size win.
|
||||||
# Can be removed after https://reviews.llvm.org/D66490 merged and released to at least two versions of clang.
|
# Can be removed after https://reviews.llvm.org/D66490 merged and released to at least two versions of clang.
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexperimental-new-pass-manager")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexperimental-new-pass-manager")
|
||||||
@ -402,77 +401,54 @@ if (COMPILER_CLANG)
|
|||||||
# completely.
|
# completely.
|
||||||
if (ENABLE_THINLTO AND NOT ENABLE_TESTS AND NOT SANITIZE)
|
if (ENABLE_THINLTO AND NOT ENABLE_TESTS AND NOT SANITIZE)
|
||||||
# Link time optimization
|
# Link time optimization
|
||||||
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -flto=thin")
|
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -flto=thin -fwhole-program-vtables")
|
||||||
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -flto=thin")
|
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -flto=thin -fwhole-program-vtables")
|
||||||
set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} -flto=thin")
|
set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} -flto=thin -fwhole-program-vtables")
|
||||||
elseif (ENABLE_THINLTO)
|
elseif (ENABLE_THINLTO)
|
||||||
message (${RECONFIGURE_MESSAGE_LEVEL} "Cannot enable ThinLTO")
|
message (${RECONFIGURE_MESSAGE_LEVEL} "Cannot enable ThinLTO")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Always prefer llvm tools when using clang. For instance, we cannot use GNU ar when llvm LTO is enabled
|
|
||||||
find_program (LLVM_AR_PATH NAMES "llvm-ar" "llvm-ar-13" "llvm-ar-12" "llvm-ar-11" "llvm-ar-10" "llvm-ar-9" "llvm-ar-8")
|
|
||||||
|
|
||||||
if (LLVM_AR_PATH)
|
|
||||||
message(STATUS "Using llvm-ar: ${LLVM_AR_PATH}.")
|
|
||||||
set (CMAKE_AR ${LLVM_AR_PATH})
|
|
||||||
else ()
|
|
||||||
message(WARNING "Cannot find llvm-ar. System ar will be used instead. It does not work with ThinLTO.")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
find_program (LLVM_RANLIB_PATH NAMES "llvm-ranlib" "llvm-ranlib-13" "llvm-ranlib-12" "llvm-ranlib-11" "llvm-ranlib-10" "llvm-ranlib-9" "llvm-ranlib-8")
|
|
||||||
|
|
||||||
if (LLVM_RANLIB_PATH)
|
|
||||||
message(STATUS "Using llvm-ranlib: ${LLVM_RANLIB_PATH}.")
|
|
||||||
set (CMAKE_RANLIB ${LLVM_RANLIB_PATH})
|
|
||||||
else ()
|
|
||||||
message(WARNING "Cannot find llvm-ranlib. System ranlib will be used instead. It does not work with ThinLTO.")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
elseif (ENABLE_THINLTO)
|
elseif (ENABLE_THINLTO)
|
||||||
message (${RECONFIGURE_MESSAGE_LEVEL} "ThinLTO is only available with CLang")
|
message (${RECONFIGURE_MESSAGE_LEVEL} "ThinLTO is only available with Clang")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Turns on all external libs like s3, kafka, ODBC, ...
|
# Turns on all external libs like s3, kafka, ODBC, ...
|
||||||
option(ENABLE_LIBRARIES "Enable all external libraries by default" ON)
|
option(ENABLE_LIBRARIES "Enable all external libraries by default" ON)
|
||||||
|
|
||||||
# We recommend avoiding this mode for production builds because we can't guarantee
|
# Increase stack size on Musl. We need big stack for our recursive-descend parser.
|
||||||
# all needed libraries exist in your system.
|
if (USE_MUSL)
|
||||||
# This mode exists for enthusiastic developers who are searching for trouble.
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,stack-size=2097152")
|
||||||
# The whole idea of using unknown version of libraries from the OS distribution is deeply flawed.
|
|
||||||
# Useful for maintainers of OS packages.
|
|
||||||
option (UNBUNDLED "Use system libraries instead of ones in contrib/" OFF)
|
|
||||||
|
|
||||||
if (UNBUNDLED)
|
|
||||||
set(NOT_UNBUNDLED OFF)
|
|
||||||
else ()
|
|
||||||
set(NOT_UNBUNDLED ON)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (UNBUNDLED OR NOT (OS_LINUX OR OS_DARWIN))
|
|
||||||
# Using system libs can cause a lot of warnings in includes (on macro expansion).
|
|
||||||
option(WERROR "Enable -Werror compiler option" OFF)
|
|
||||||
else ()
|
|
||||||
option(WERROR "Enable -Werror compiler option" ON)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (WERROR)
|
|
||||||
add_warning(error)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# Make this extra-checks for correct library dependencies.
|
|
||||||
if (OS_LINUX AND NOT SANITIZE)
|
|
||||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined")
|
|
||||||
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
include(cmake/dbms_glob_sources.cmake)
|
include(cmake/dbms_glob_sources.cmake)
|
||||||
|
|
||||||
|
add_library(global-group INTERFACE)
|
||||||
if (OS_LINUX OR OS_ANDROID)
|
if (OS_LINUX OR OS_ANDROID)
|
||||||
include(cmake/linux/default_libs.cmake)
|
include(cmake/linux/default_libs.cmake)
|
||||||
elseif (OS_DARWIN)
|
elseif (OS_DARWIN)
|
||||||
include(cmake/darwin/default_libs.cmake)
|
include(cmake/darwin/default_libs.cmake)
|
||||||
elseif (OS_FREEBSD)
|
elseif (OS_FREEBSD)
|
||||||
include(cmake/freebsd/default_libs.cmake)
|
include(cmake/freebsd/default_libs.cmake)
|
||||||
|
else()
|
||||||
|
link_libraries(global-group)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
option (ENABLE_GWP_ASAN "Enable Gwp-Asan" ON)
|
||||||
|
if (NOT OS_LINUX AND NOT OS_ANDROID)
|
||||||
|
set(ENABLE_GWP_ASAN OFF)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
option(WERROR "Enable -Werror compiler option" ON)
|
||||||
|
|
||||||
|
if (WERROR)
|
||||||
|
# Don't pollute CMAKE_CXX_FLAGS with -Werror as it will break some CMake checks.
|
||||||
|
# Instead, adopt modern cmake usage requirement.
|
||||||
|
target_compile_options(global-group INTERFACE "-Werror")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Make this extra-checks for correct library dependencies.
|
||||||
|
if (OS_LINUX AND NOT SANITIZE)
|
||||||
|
target_link_options(global-group INTERFACE "LINKER:--no-undefined")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
######################################
|
######################################
|
||||||
@ -481,30 +457,13 @@ endif ()
|
|||||||
|
|
||||||
set (CMAKE_POSTFIX_VARIABLE "CMAKE_${CMAKE_BUILD_TYPE_UC}_POSTFIX")
|
set (CMAKE_POSTFIX_VARIABLE "CMAKE_${CMAKE_BUILD_TYPE_UC}_POSTFIX")
|
||||||
|
|
||||||
if (MAKE_STATIC_LIBRARIES)
|
set (CMAKE_POSITION_INDEPENDENT_CODE OFF)
|
||||||
set (CMAKE_POSITION_INDEPENDENT_CODE OFF)
|
if (OS_LINUX AND NOT ARCH_AARCH64)
|
||||||
if (OS_LINUX AND NOT ARCH_ARM)
|
# Slightly more efficient code can be generated
|
||||||
# Slightly more efficient code can be generated
|
# It's disabled for ARM because otherwise ClickHouse cannot run on Android.
|
||||||
# It's disabled for ARM because otherwise ClickHouse cannot run on Android.
|
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-pie")
|
||||||
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-pie")
|
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -fno-pie")
|
||||||
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -fno-pie")
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie -Wl,-no-pie")
|
||||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no-pie")
|
|
||||||
endif ()
|
|
||||||
else ()
|
|
||||||
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# https://github.com/include-what-you-use/include-what-you-use
|
|
||||||
option (USE_INCLUDE_WHAT_YOU_USE "Automatically reduce unneeded includes in source code (external tool)" OFF)
|
|
||||||
|
|
||||||
if (USE_INCLUDE_WHAT_YOU_USE)
|
|
||||||
find_program(IWYU_PATH NAMES include-what-you-use iwyu)
|
|
||||||
if (NOT IWYU_PATH)
|
|
||||||
message(FATAL_ERROR "Could not find the program include-what-you-use")
|
|
||||||
endif()
|
|
||||||
if (${CMAKE_VERSION} VERSION_LESS "3.3.0")
|
|
||||||
message(FATAL_ERROR "include-what-you-use requires CMake version at least 3.3.")
|
|
||||||
endif()
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (ENABLE_TESTS)
|
if (ENABLE_TESTS)
|
||||||
@ -515,6 +474,10 @@ endif ()
|
|||||||
|
|
||||||
enable_testing() # Enable for tests without binary
|
enable_testing() # Enable for tests without binary
|
||||||
|
|
||||||
|
option(ENABLE_OPENSSL "This option performs a build with OpenSSL. NOTE! This option is insecure and should never be used. By default, ClickHouse uses and only supports BoringSSL" OFF)
|
||||||
|
|
||||||
|
option(ENABLE_OPENSSL_DYNAMIC "This option removes SSL from ClickHouse and will link to the OpenSSL version supplied by OS." OFF)
|
||||||
|
|
||||||
# when installing to /usr - place configs to /etc but for /usr/local place to /usr/local/etc
|
# when installing to /usr - place configs to /etc but for /usr/local place to /usr/local/etc
|
||||||
if (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
|
if (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
|
||||||
set (CLICKHOUSE_ETC_DIR "/etc")
|
set (CLICKHOUSE_ETC_DIR "/etc")
|
||||||
@ -522,94 +485,12 @@ else ()
|
|||||||
set (CLICKHOUSE_ETC_DIR "${CMAKE_INSTALL_PREFIX}/etc")
|
set (CLICKHOUSE_ETC_DIR "${CMAKE_INSTALL_PREFIX}/etc")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
message (STATUS
|
message (STATUS "Building for: ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_PROCESSOR} ${CMAKE_LIBRARY_ARCHITECTURE}")
|
||||||
"Building for: ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_PROCESSOR} ${CMAKE_LIBRARY_ARCHITECTURE} ;
|
|
||||||
USE_STATIC_LIBRARIES=${USE_STATIC_LIBRARIES}
|
|
||||||
MAKE_STATIC_LIBRARIES=${MAKE_STATIC_LIBRARIES}
|
|
||||||
SPLIT_SHARED=${SPLIT_SHARED_LIBRARIES}
|
|
||||||
UNBUNDLED=${UNBUNDLED}
|
|
||||||
CCACHE=${CCACHE_FOUND} ${CCACHE_VERSION}")
|
|
||||||
|
|
||||||
include (GNUInstallDirs)
|
include (GNUInstallDirs)
|
||||||
include (cmake/contrib_finder.cmake)
|
|
||||||
|
|
||||||
find_contrib_lib(double-conversion) # Must be before parquet
|
|
||||||
include (cmake/find/ssl.cmake)
|
|
||||||
include (cmake/find/ldap.cmake) # after ssl
|
|
||||||
include (cmake/find/icu.cmake)
|
|
||||||
include (cmake/find/xz.cmake)
|
|
||||||
include (cmake/find/zlib.cmake)
|
|
||||||
include (cmake/find/zstd.cmake)
|
|
||||||
include (cmake/find/ltdl.cmake) # for odbc
|
|
||||||
# openssl, zlib before poco
|
|
||||||
include (cmake/find/sparsehash.cmake)
|
|
||||||
include (cmake/find/re2.cmake)
|
|
||||||
include (cmake/find/krb5.cmake)
|
|
||||||
include (cmake/find/libgsasl.cmake)
|
|
||||||
include (cmake/find/cyrus-sasl.cmake)
|
|
||||||
include (cmake/find/rdkafka.cmake)
|
|
||||||
include (cmake/find/libuv.cmake) # for amqpcpp and cassandra
|
|
||||||
include (cmake/find/amqpcpp.cmake)
|
|
||||||
include (cmake/find/capnp.cmake)
|
|
||||||
include (cmake/find/llvm.cmake)
|
|
||||||
include (cmake/find/h3.cmake)
|
|
||||||
include (cmake/find/libxml2.cmake)
|
|
||||||
include (cmake/find/brotli.cmake)
|
|
||||||
include (cmake/find/protobuf.cmake)
|
|
||||||
include (cmake/find/grpc.cmake)
|
|
||||||
include (cmake/find/pdqsort.cmake)
|
|
||||||
include (cmake/find/miniselect.cmake)
|
|
||||||
include (cmake/find/hdfs3.cmake) # uses protobuf
|
|
||||||
include (cmake/find/poco.cmake)
|
|
||||||
include (cmake/find/curl.cmake)
|
|
||||||
include (cmake/find/s3.cmake)
|
|
||||||
include (cmake/find/base64.cmake)
|
|
||||||
include (cmake/find/parquet.cmake)
|
|
||||||
include (cmake/find/simdjson.cmake)
|
|
||||||
include (cmake/find/fast_float.cmake)
|
|
||||||
include (cmake/find/rapidjson.cmake)
|
|
||||||
include (cmake/find/fastops.cmake)
|
|
||||||
include (cmake/find/odbc.cmake)
|
|
||||||
include (cmake/find/nanodbc.cmake)
|
|
||||||
include (cmake/find/sqlite.cmake)
|
|
||||||
include (cmake/find/rocksdb.cmake)
|
|
||||||
include (cmake/find/libpqxx.cmake)
|
|
||||||
include (cmake/find/nuraft.cmake)
|
|
||||||
include (cmake/find/yaml-cpp.cmake)
|
|
||||||
include (cmake/find/s2geometry.cmake)
|
|
||||||
include (cmake/find/nlp.cmake)
|
|
||||||
include (cmake/find/bzip2.cmake)
|
|
||||||
include (cmake/find/filelog.cmake)
|
|
||||||
|
|
||||||
if(NOT USE_INTERNAL_PARQUET_LIBRARY)
|
|
||||||
set (ENABLE_ORC OFF CACHE INTERNAL "")
|
|
||||||
endif()
|
|
||||||
include (cmake/find/orc.cmake)
|
|
||||||
|
|
||||||
include (cmake/find/avro.cmake)
|
|
||||||
include (cmake/find/msgpack.cmake)
|
|
||||||
include (cmake/find/cassandra.cmake)
|
|
||||||
include (cmake/find/sentry.cmake)
|
|
||||||
include (cmake/find/stats.cmake)
|
|
||||||
include (cmake/find/datasketches.cmake)
|
|
||||||
include (cmake/find/libprotobuf-mutator.cmake)
|
|
||||||
|
|
||||||
set (USE_INTERNAL_CITYHASH_LIBRARY ON CACHE INTERNAL "")
|
|
||||||
find_contrib_lib(cityhash)
|
|
||||||
|
|
||||||
find_contrib_lib(farmhash)
|
|
||||||
|
|
||||||
if (ENABLE_TESTS)
|
|
||||||
include (cmake/find/gtest.cmake)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# Need to process before "contrib" dir:
|
|
||||||
include (cmake/find/mysqlclient.cmake)
|
|
||||||
|
|
||||||
# When testing for memory leaks with Valgrind, don't link tcmalloc or jemalloc.
|
# When testing for memory leaks with Valgrind, don't link tcmalloc or jemalloc.
|
||||||
|
|
||||||
include (cmake/print_flags.cmake)
|
|
||||||
|
|
||||||
if (TARGET global-group)
|
if (TARGET global-group)
|
||||||
install (EXPORT global DESTINATION cmake)
|
install (EXPORT global DESTINATION cmake)
|
||||||
endif ()
|
endif ()
|
||||||
@ -620,14 +501,14 @@ if (NOT ENABLE_JEMALLOC)
|
|||||||
message (WARNING "Non default allocator is disabled. This is not recommended for production builds.")
|
message (WARNING "Non default allocator is disabled. This is not recommended for production builds.")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
macro (add_executable target)
|
macro (clickhouse_add_executable target)
|
||||||
# invoke built-in add_executable
|
# invoke built-in add_executable
|
||||||
# explicitly acquire and interpose malloc symbols by clickhouse_malloc
|
# explicitly acquire and interpose malloc symbols by clickhouse_malloc
|
||||||
# if GLIBC_COMPATIBILITY is ON and ENABLE_THINLTO is on than provide memcpy symbol explicitly to neutrialize thinlto's libcall generation.
|
# if GLIBC_COMPATIBILITY is ON and ENABLE_THINLTO is on than provide memcpy symbol explicitly to neutrialize thinlto's libcall generation.
|
||||||
if (GLIBC_COMPATIBILITY AND ENABLE_THINLTO)
|
if (ARCH_AMD64 AND GLIBC_COMPATIBILITY AND ENABLE_THINLTO)
|
||||||
_add_executable (${ARGV} $<TARGET_OBJECTS:clickhouse_malloc> $<TARGET_OBJECTS:memcpy>)
|
add_executable (${ARGV} $<TARGET_OBJECTS:clickhouse_malloc> $<TARGET_OBJECTS:memcpy>)
|
||||||
else ()
|
else ()
|
||||||
_add_executable (${ARGV} $<TARGET_OBJECTS:clickhouse_malloc>)
|
add_executable (${ARGV} $<TARGET_OBJECTS:clickhouse_malloc>)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
get_target_property (type ${target} TYPE)
|
get_target_property (type ${target} TYPE)
|
||||||
@ -650,17 +531,32 @@ macro (add_executable target)
|
|||||||
# - _je_zone_register due to JEMALLOC_PRIVATE_NAMESPACE=je_ under OS X.
|
# - _je_zone_register due to JEMALLOC_PRIVATE_NAMESPACE=je_ under OS X.
|
||||||
# - but jemalloc-cmake does not run private_namespace.sh
|
# - but jemalloc-cmake does not run private_namespace.sh
|
||||||
# so symbol name should be _zone_register
|
# so symbol name should be _zone_register
|
||||||
if (ENABLE_JEMALLOC AND MAKE_STATIC_LIBRARIES AND OS_DARWIN)
|
if (ENABLE_JEMALLOC AND OS_DARWIN)
|
||||||
set_property(TARGET ${target} APPEND PROPERTY LINK_OPTIONS -u_zone_register)
|
set_property(TARGET ${target} APPEND PROPERTY LINK_OPTIONS -u_zone_register)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
set(ConfigIncludePath ${CMAKE_CURRENT_BINARY_DIR}/includes/configs CACHE INTERNAL "Path to generated configuration files.")
|
# With cross-compiling, all targets are built for the target platform which usually different from the host
|
||||||
include_directories(${ConfigIncludePath})
|
# platform. This is problematic if a build artifact X (e.g. a file or an executable) is generated by running
|
||||||
|
# another executable Y previously produced in the build. This is solved by compiling and running Y for/on
|
||||||
|
# the host platform. Add target to the list:
|
||||||
|
# add_native_target(<target> ...)
|
||||||
|
set_property (GLOBAL PROPERTY NATIVE_BUILD_TARGETS)
|
||||||
|
function (add_native_target)
|
||||||
|
set_property (GLOBAL APPEND PROPERTY NATIVE_BUILD_TARGETS ${ARGV})
|
||||||
|
endfunction (add_native_target)
|
||||||
|
|
||||||
|
set(CONFIG_INCLUDE_PATH ${CMAKE_CURRENT_BINARY_DIR}/includes/configs CACHE INTERNAL "Path to generated configuration files.")
|
||||||
|
include_directories(${CONFIG_INCLUDE_PATH})
|
||||||
|
|
||||||
# Add as many warnings as possible for our own code.
|
# Add as many warnings as possible for our own code.
|
||||||
include (cmake/warnings.cmake)
|
include (cmake/warnings.cmake)
|
||||||
|
include (cmake/print_flags.cmake)
|
||||||
|
|
||||||
|
if (ENABLE_RUST)
|
||||||
|
add_subdirectory (rust)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory (base)
|
add_subdirectory (base)
|
||||||
add_subdirectory (src)
|
add_subdirectory (src)
|
||||||
@ -668,6 +564,37 @@ add_subdirectory (programs)
|
|||||||
add_subdirectory (tests)
|
add_subdirectory (tests)
|
||||||
add_subdirectory (utils)
|
add_subdirectory (utils)
|
||||||
|
|
||||||
include (cmake/print_include_directories.cmake)
|
include (cmake/sanitize_targets.cmake)
|
||||||
|
|
||||||
include (cmake/sanitize_target_link_libraries.cmake)
|
# Build native targets if necessary
|
||||||
|
get_property(NATIVE_BUILD_TARGETS GLOBAL PROPERTY NATIVE_BUILD_TARGETS)
|
||||||
|
if (NATIVE_BUILD_TARGETS
|
||||||
|
AND NOT(
|
||||||
|
CMAKE_HOST_SYSTEM_NAME STREQUAL CMAKE_SYSTEM_NAME
|
||||||
|
AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL CMAKE_SYSTEM_PROCESSOR
|
||||||
|
)
|
||||||
|
)
|
||||||
|
message (STATUS "Building native targets...")
|
||||||
|
|
||||||
|
set (NATIVE_BUILD_DIR "${CMAKE_BINARY_DIR}/native")
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${NATIVE_BUILD_DIR}"
|
||||||
|
COMMAND_ECHO STDOUT)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND}
|
||||||
|
"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
|
||||||
|
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
|
||||||
|
"-DENABLE_CCACHE=${ENABLE_CCACHE}"
|
||||||
|
# Avoid overriding .cargo/config.toml with native toolchain.
|
||||||
|
"-DENABLE_RUST=OFF"
|
||||||
|
"-DENABLE_CLICKHOUSE_SELF_EXTRACTING=${ENABLE_CLICKHOUSE_SELF_EXTRACTING}"
|
||||||
|
${CMAKE_SOURCE_DIR}
|
||||||
|
WORKING_DIRECTORY "${NATIVE_BUILD_DIR}"
|
||||||
|
COMMAND_ECHO STDOUT)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} --build "${NATIVE_BUILD_DIR}" --target ${NATIVE_BUILD_TARGETS}
|
||||||
|
COMMAND_ECHO STDOUT)
|
||||||
|
endif ()
|
||||||
|
@ -2,7 +2,13 @@
|
|||||||
|
|
||||||
ClickHouse is an open project, and you can contribute to it in many ways. You can help with ideas, code, or documentation. We appreciate any efforts that help us to make the project better.
|
ClickHouse is an open project, and you can contribute to it in many ways. You can help with ideas, code, or documentation. We appreciate any efforts that help us to make the project better.
|
||||||
|
|
||||||
Thank you.
|
Thank you!
|
||||||
|
|
||||||
|
## Legal Info
|
||||||
|
|
||||||
|
When you open your first pull-request to ClickHouse repo, a bot will invite you to accept ClickHouse Individual CLA (Contributor License Agreement). It is a simple few click process. For subsequent pull-requests the bot will check if you have already signed it and won't bother you again.
|
||||||
|
|
||||||
|
Optionally, to make contributions even more tight legally, your employer as a legal entity may want to sign a ClickHouse Corporate CLA with ClickHouse, Inc. If you're interested to do so, contact us at [legal@clickhouse.com](mailto:legal@clickhouse.com).
|
||||||
|
|
||||||
## Technical Info
|
## Technical Info
|
||||||
|
|
||||||
|
4
LICENSE
4
LICENSE
@ -1,4 +1,4 @@
|
|||||||
Copyright 2016-2021 ClickHouse, Inc.
|
Copyright 2016-2023 ClickHouse, Inc.
|
||||||
|
|
||||||
Apache License
|
Apache License
|
||||||
Version 2.0, January 2004
|
Version 2.0, January 2004
|
||||||
@ -188,7 +188,7 @@ Copyright 2016-2021 ClickHouse, Inc.
|
|||||||
same "printed page" as the copyright notice for easier
|
same "printed page" as the copyright notice for easier
|
||||||
identification within third-party archives.
|
identification within third-party archives.
|
||||||
|
|
||||||
Copyright 2016-2021 ClickHouse, Inc.
|
Copyright 2016-2023 ClickHouse, Inc.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -7,14 +7,84 @@
|
|||||||
# How to install Ninja on Ubuntu:
|
# How to install Ninja on Ubuntu:
|
||||||
# sudo apt-get install ninja-build
|
# sudo apt-get install ninja-build
|
||||||
|
|
||||||
# CLion does not support Ninja
|
|
||||||
# You can add your vote on CLion task tracker:
|
|
||||||
# https://youtrack.jetbrains.com/issue/CPP-2659
|
|
||||||
# https://youtrack.jetbrains.com/issue/CPP-870
|
|
||||||
|
|
||||||
if (NOT DEFINED ENV{CLION_IDE} AND NOT DEFINED ENV{XCODE_IDE})
|
if (NOT DEFINED ENV{XCODE_IDE})
|
||||||
find_program(NINJA_PATH ninja)
|
find_program(NINJA_PATH ninja)
|
||||||
if (NINJA_PATH)
|
if (NINJA_PATH)
|
||||||
set(CMAKE_GENERATOR "Ninja" CACHE INTERNAL "" FORCE)
|
set(CMAKE_GENERATOR "Ninja" CACHE INTERNAL "")
|
||||||
|
endif ()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Check if environment is polluted.
|
||||||
|
if (NOT "$ENV{CFLAGS}" STREQUAL ""
|
||||||
|
OR NOT "$ENV{CXXFLAGS}" STREQUAL ""
|
||||||
|
OR NOT "$ENV{LDFLAGS}" STREQUAL ""
|
||||||
|
OR CMAKE_C_FLAGS OR CMAKE_CXX_FLAGS OR CMAKE_EXE_LINKER_FLAGS OR CMAKE_SHARED_LINKER_FLAGS OR CMAKE_MODULE_LINKER_FLAGS
|
||||||
|
OR CMAKE_C_FLAGS_INIT OR CMAKE_CXX_FLAGS_INIT OR CMAKE_EXE_LINKER_FLAGS_INIT OR CMAKE_SHARED_LINKER_FLAGS_INIT OR CMAKE_MODULE_LINKER_FLAGS_INIT)
|
||||||
|
|
||||||
|
# if $ENV
|
||||||
|
message("CFLAGS: $ENV{CFLAGS}")
|
||||||
|
message("CXXFLAGS: $ENV{CXXFLAGS}")
|
||||||
|
message("LDFLAGS: $ENV{LDFLAGS}")
|
||||||
|
# if *_FLAGS
|
||||||
|
message("CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
|
||||||
|
message("CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
|
||||||
|
message("CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}")
|
||||||
|
message("CMAKE_SHARED_LINKER_FLAGS: ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||||
|
message("CMAKE_MODULE_LINKER_FLAGS: ${CMAKE_MODULE_LINKER_FLAGS}")
|
||||||
|
# if *_FLAGS_INIT
|
||||||
|
message("CMAKE_C_FLAGS_INIT: ${CMAKE_C_FLAGS_INIT}")
|
||||||
|
message("CMAKE_CXX_FLAGS_INIT: ${CMAKE_CXX_FLAGS_INIT}")
|
||||||
|
message("CMAKE_EXE_LINKER_FLAGS_INIT: ${CMAKE_EXE_LINKER_FLAGS_INIT}")
|
||||||
|
message("CMAKE_SHARED_LINKER_FLAGS_INIT: ${CMAKE_SHARED_LINKER_FLAGS_INIT}")
|
||||||
|
message("CMAKE_MODULE_LINKER_FLAGS_INIT: ${CMAKE_MODULE_LINKER_FLAGS_INIT}")
|
||||||
|
|
||||||
|
message(FATAL_ERROR "
|
||||||
|
Some of the variables like CFLAGS, CXXFLAGS, LDFLAGS are not empty.
|
||||||
|
It is not possible to build ClickHouse with custom flags.
|
||||||
|
These variables can be set up by previous invocation of some other build tools.
|
||||||
|
You should cleanup these variables and start over again.
|
||||||
|
|
||||||
|
Run the `env` command to check the details.
|
||||||
|
You will also need to remove the contents of the build directory.
|
||||||
|
|
||||||
|
Note: if you don't like this behavior, you can manually edit the cmake files, but please don't complain to developers.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Default toolchain - this is needed to avoid dependency on OS files.
|
||||||
|
execute_process(COMMAND uname -s OUTPUT_VARIABLE OS)
|
||||||
|
execute_process(COMMAND uname -m OUTPUT_VARIABLE ARCH)
|
||||||
|
|
||||||
|
# By default, prefer clang on Linux
|
||||||
|
# But note, that you still may change the compiler with -DCMAKE_C_COMPILER/-DCMAKE_CXX_COMPILER.
|
||||||
|
if (OS MATCHES "Linux"
|
||||||
|
AND "$ENV{CC}" STREQUAL ""
|
||||||
|
AND "$ENV{CXX}" STREQUAL ""
|
||||||
|
AND NOT DEFINED CMAKE_C_COMPILER
|
||||||
|
AND NOT DEFINED CMAKE_CXX_COMPILER)
|
||||||
|
find_program(CLANG_PATH clang)
|
||||||
|
if (CLANG_PATH)
|
||||||
|
set(CMAKE_C_COMPILER "clang" CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_program(CLANG_CXX_PATH clang++)
|
||||||
|
if (CLANG_CXX_PATH)
|
||||||
|
set(CMAKE_CXX_COMPILER "clang++" CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (OS MATCHES "Linux"
|
||||||
|
AND NOT DEFINED CMAKE_TOOLCHAIN_FILE
|
||||||
|
AND NOT DISABLE_HERMETIC_BUILD
|
||||||
|
AND ("$ENV{CC}" MATCHES ".*clang.*" OR CMAKE_C_COMPILER MATCHES ".*clang.*"))
|
||||||
|
|
||||||
|
if (ARCH MATCHES "amd64|x86_64")
|
||||||
|
set (CMAKE_TOOLCHAIN_FILE "cmake/linux/toolchain-x86_64.cmake" CACHE INTERNAL "")
|
||||||
|
elseif (ARCH MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)")
|
||||||
|
set (CMAKE_TOOLCHAIN_FILE "cmake/linux/toolchain-aarch64.cmake" CACHE INTERNAL "")
|
||||||
|
elseif (ARCH MATCHES "^(ppc64le.*|PPC64LE.*)")
|
||||||
|
set (CMAKE_TOOLCHAIN_FILE "cmake/linux/toolchain-ppc64le.cmake" CACHE INTERNAL "")
|
||||||
|
else ()
|
||||||
|
message (FATAL_ERROR "Unsupported architecture: ${ARCH}")
|
||||||
endif ()
|
endif ()
|
||||||
endif()
|
endif()
|
||||||
|
17
README.md
17
README.md
@ -1,14 +1,21 @@
|
|||||||
[![ClickHouse — open source distributed column-oriented DBMS](https://github.com/ClickHouse/ClickHouse/raw/master/website/images/logo-400x240.png)](https://clickhouse.com)
|
[![ClickHouse — open source distributed column-oriented DBMS](https://github.com/ClickHouse/clickhouse-presentations/raw/master/images/logo-400x240.png)](https://clickhouse.com)
|
||||||
|
|
||||||
ClickHouse® is an open-source column-oriented database management system that allows generating analytical data reports in real-time.
|
ClickHouse® is an open-source column-oriented database management system that allows generating analytical data reports in real-time.
|
||||||
|
|
||||||
## Useful Links
|
## Useful Links
|
||||||
|
|
||||||
* [Official website](https://clickhouse.com/) has a quick high-level overview of ClickHouse on the main page.
|
* [Official website](https://clickhouse.com/) has a quick high-level overview of ClickHouse on the main page.
|
||||||
|
* [ClickHouse Cloud](https://clickhouse.cloud) ClickHouse as a service, built by the creators and maintainers.
|
||||||
* [Tutorial](https://clickhouse.com/docs/en/getting_started/tutorial/) shows how to set up and query a small ClickHouse cluster.
|
* [Tutorial](https://clickhouse.com/docs/en/getting_started/tutorial/) shows how to set up and query a small ClickHouse cluster.
|
||||||
* [Documentation](https://clickhouse.com/docs/en/) provides more in-depth information.
|
* [Documentation](https://clickhouse.com/docs/en/) provides more in-depth information.
|
||||||
* [YouTube channel](https://www.youtube.com/c/ClickHouseDB) has a lot of content about ClickHouse in video format.
|
* [YouTube channel](https://www.youtube.com/c/ClickHouseDB) has a lot of content about ClickHouse in video format.
|
||||||
* [Slack](https://join.slack.com/t/clickhousedb/shared_invite/zt-rxm3rdrk-lIUmhLC3V8WTaL0TGxsOmg) and [Telegram](https://telegram.me/clickhouse_en) allow chatting with ClickHouse users in real-time.
|
* [Slack](https://clickhousedb.slack.com/) and [Telegram](https://telegram.me/clickhouse_en) allow chatting with ClickHouse users in real-time.
|
||||||
* [Blog](https://clickhouse.com/blog/en/) contains various ClickHouse-related articles, as well as announcements and reports about events.
|
* [Blog](https://clickhouse.com/blog/) contains various ClickHouse-related articles, as well as announcements and reports about events.
|
||||||
* [Code Browser](https://clickhouse.com/codebrowser/html_report/ClickHouse/index.html) with syntax highlight and navigation.
|
* [Code Browser (Woboq)](https://clickhouse.com/codebrowser/ClickHouse/index.html) with syntax highlight and navigation.
|
||||||
* [Contacts](https://clickhouse.com/company/#contact) can help to get your questions answered if there are any.
|
* [Code Browser (github.dev)](https://github.dev/ClickHouse/ClickHouse) with syntax highlight, powered by github.dev.
|
||||||
|
* [Contacts](https://clickhouse.com/company/contact) can help to get your questions answered if there are any.
|
||||||
|
|
||||||
|
## Events
|
||||||
|
* **FOSDEM 2023**: In the "Fast and Streaming Data" room Alexey gave a talk entitled "Building Analytical Apps With ClickHouse" that looks at the landscape of data tools, an interesting data set, and how you can interact with data quickly. Check out the recording on **[YouTube](https://www.youtube.com/watch?v=JlcI2Vfz_uk)**.
|
||||||
|
* **Recording available**: [**v23.1 Release Webinar**](https://www.youtube.com/watch?v=zYSZXBnTMSE) 23.1 is the ClickHouse New Year release. Original creator, co-founder, and CTO of ClickHouse Alexey Milovidov will walk us through the highlights of the release. Inverted indices, query cache, and so -- very -- much more.
|
||||||
|
* **Recording available**: [**ClickHouse Meetup at the CHEQ office in Tel Aviv**](https://www.meetup.com/clickhouse-tel-aviv-user-group/events/289599423/) - We are very excited to be holding our next in-person ClickHouse meetup at the CHEQ office in Tel Aviv! Hear from CHEQ, ServiceNow and Contentsquare, as well as a deep dive presentation from ClickHouse CTO Alexey Milovidov. Join us for a fun evening of talks, food and discussion!
|
||||||
|
44
SECURITY.md
44
SECURITY.md
@ -1,3 +1,7 @@
|
|||||||
|
<!--
|
||||||
|
the file is autogenerated by utils/security-generator/generate_security.py
|
||||||
|
-->
|
||||||
|
|
||||||
# Security Policy
|
# Security Policy
|
||||||
|
|
||||||
## Security Announcements
|
## Security Announcements
|
||||||
@ -7,27 +11,32 @@ Security fixes will be announced by posting them in the [security changelog](htt
|
|||||||
|
|
||||||
The following versions of ClickHouse server are currently being supported with security updates:
|
The following versions of ClickHouse server are currently being supported with security updates:
|
||||||
|
|
||||||
| Version | Supported |
|
| Version | Supported |
|
||||||
| ------- | ------------------ |
|
|:-|:-|
|
||||||
| 1.x | :x: |
|
| 23.1 | ✔️ |
|
||||||
| 18.x | :x: |
|
| 22.12 | ✔️ |
|
||||||
| 19.x | :x: |
|
| 22.11 | ✔️ |
|
||||||
| 20.x | :x: |
|
| 22.10 | ❌ |
|
||||||
| 21.1 | :x: |
|
| 22.9 | ❌ |
|
||||||
| 21.2 | :x: |
|
| 22.8 | ✔️ |
|
||||||
| 21.3 | ✅ |
|
| 22.7 | ❌ |
|
||||||
| 21.4 | :x: |
|
| 22.6 | ❌ |
|
||||||
| 21.5 | :x: |
|
| 22.5 | ❌ |
|
||||||
| 21.6 | :x: |
|
| 22.4 | ❌ |
|
||||||
| 21.7 | ✅ |
|
| 22.3 | ✔️ |
|
||||||
| 21.8 | ✅ |
|
| 22.2 | ❌ |
|
||||||
| 21.9 | ✅ |
|
| 22.1 | ❌ |
|
||||||
|
| 21.* | ❌ |
|
||||||
|
| 20.* | ❌ |
|
||||||
|
| 19.* | ❌ |
|
||||||
|
| 18.* | ❌ |
|
||||||
|
| 1.* | ❌ |
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
We're extremely grateful for security researchers and users that report vulnerabilities to the ClickHouse Open Source Community. All reports are thoroughly investigated by developers.
|
We're extremely grateful for security researchers and users that report vulnerabilities to the ClickHouse Open Source Community. All reports are thoroughly investigated by developers.
|
||||||
|
|
||||||
To report a potential vulnerability in ClickHouse please send the details about it to [security@clickhouse.com](mailto:security@clickhouse.com).
|
To report a potential vulnerability in ClickHouse please send the details about it to [security@clickhouse.com](mailto:security@clickhouse.com). We do not offer any financial rewards for reporting issues to us using this method. Alternatively, you can also submit your findings through our public bug bounty program hosted by [Bugcrowd](https://bugcrowd.com/clickhouse) and be rewarded for it as per the program scope and rules of engagement.
|
||||||
|
|
||||||
### When Should I Report a Vulnerability?
|
### When Should I Report a Vulnerability?
|
||||||
|
|
||||||
@ -47,6 +56,5 @@ As the security issue moves from triage, to identified fix, to release planning
|
|||||||
|
|
||||||
## Public Disclosure Timing
|
## Public Disclosure Timing
|
||||||
|
|
||||||
A public disclosure date is negotiated by the ClickHouse maintainers and the bug submitter. We prefer to fully disclose the bug as soon as possible once a user mitigation is available. It is reasonable to delay disclosure when the bug or the fix is not yet fully understood, the solution is not well-tested, or for vendor coordination. The timeframe for disclosure is from immediate (especially if it's already publicly known) to 90 days. For a vulnerability with a straightforward mitigation, we expect report date to disclosure date to be on the order of 7 days.
|
A public disclosure date is negotiated by the ClickHouse maintainers and the bug submitter. We prefer to fully disclose the bug as soon as possible once a user mitigation is available. It is reasonable to delay disclosure when the bug or the fix is not yet fully understood, the solution is not well-tested, or for vendor coordination. The timeframe for disclosure is from immediate (especially if it's already publicly known) to 90 days. For a vulnerability with a straightforward mitigation, we expect the report date to disclosure date to be on the order of 7 days.
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,15 +1,5 @@
|
|||||||
if (USE_CLANG_TIDY)
|
|
||||||
set (CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
add_subdirectory (base)
|
add_subdirectory (base)
|
||||||
add_subdirectory (daemon)
|
|
||||||
add_subdirectory (loggers)
|
|
||||||
add_subdirectory (pcg-random)
|
add_subdirectory (pcg-random)
|
||||||
|
add_subdirectory (poco)
|
||||||
add_subdirectory (widechar_width)
|
add_subdirectory (widechar_width)
|
||||||
add_subdirectory (readpassphrase)
|
add_subdirectory (readpassphrase)
|
||||||
add_subdirectory (bridge)
|
|
||||||
|
|
||||||
if (USE_MYSQL)
|
|
||||||
add_subdirectory (mysqlxx)
|
|
||||||
endif ()
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <base/MoveOrCopyIfThrow.h>
|
#include <base/MoveOrCopyIfThrow.h>
|
||||||
|
|
||||||
/** Pool for limited size objects that cannot be used from different threads simultaneously.
|
/** Pool for limited size objects that cannot be used from different threads simultaneously.
|
||||||
* The main use case is to have fixed size of objects that can be reused in difference threads during their lifetime
|
* The main use case is to have fixed size of objects that can be reused in different threads during their lifetime
|
||||||
* and have to be initialized on demand.
|
* and have to be initialized on demand.
|
||||||
* Two main properties of pool are allocated objects size and borrowed objects size.
|
* Two main properties of pool are allocated objects size and borrowed objects size.
|
||||||
* Allocated objects size is size of objects that are currently allocated by the pool.
|
* Allocated objects size is size of objects that are currently allocated by the pool.
|
||||||
@ -89,7 +89,7 @@ public:
|
|||||||
inline void returnObject(T && object_to_return)
|
inline void returnObject(T && object_to_return)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(objects_mutex);
|
std::lock_guard lock(objects_mutex);
|
||||||
|
|
||||||
objects.emplace_back(std::move(object_to_return));
|
objects.emplace_back(std::move(object_to_return));
|
||||||
--borrowed_objects_size;
|
--borrowed_objects_size;
|
||||||
@ -107,14 +107,14 @@ public:
|
|||||||
/// Allocated objects size by the pool. If allocatedObjectsSize == maxSize then pool is full.
|
/// Allocated objects size by the pool. If allocatedObjectsSize == maxSize then pool is full.
|
||||||
inline size_t allocatedObjectsSize() const
|
inline size_t allocatedObjectsSize() const
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(objects_mutex);
|
std::lock_guard lock(objects_mutex);
|
||||||
return allocated_objects_size;
|
return allocated_objects_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns allocatedObjectsSize == maxSize
|
/// Returns allocatedObjectsSize == maxSize
|
||||||
inline bool isFull() const
|
inline bool isFull() const
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(objects_mutex);
|
std::lock_guard lock(objects_mutex);
|
||||||
return allocated_objects_size == max_size;
|
return allocated_objects_size == max_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ public:
|
|||||||
/// Then client will wait during borrowObject function call.
|
/// Then client will wait during borrowObject function call.
|
||||||
inline size_t borrowedObjectsSize() const
|
inline size_t borrowedObjectsSize() const
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(objects_mutex);
|
std::lock_guard lock(objects_mutex);
|
||||||
return borrowed_objects_size;
|
return borrowed_objects_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,36 +1,36 @@
|
|||||||
|
if (USE_CLANG_TIDY)
|
||||||
|
set (CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
set (SRCS
|
set (SRCS
|
||||||
argsToConfig.cpp
|
argsToConfig.cpp
|
||||||
coverage.cpp
|
coverage.cpp
|
||||||
DateLUT.cpp
|
|
||||||
DateLUTImpl.cpp
|
|
||||||
demangle.cpp
|
demangle.cpp
|
||||||
|
getAvailableMemoryAmount.cpp
|
||||||
getFQDNOrHostName.cpp
|
getFQDNOrHostName.cpp
|
||||||
getMemoryAmount.cpp
|
getMemoryAmount.cpp
|
||||||
getPageSize.cpp
|
getPageSize.cpp
|
||||||
getThreadId.cpp
|
getThreadId.cpp
|
||||||
JSON.cpp
|
JSON.cpp
|
||||||
LineReader.cpp
|
|
||||||
mremap.cpp
|
mremap.cpp
|
||||||
phdr_cache.cpp
|
phdr_cache.cpp
|
||||||
preciseExp10.cpp
|
preciseExp10.cpp
|
||||||
setTerminalEcho.cpp
|
|
||||||
shift10.cpp
|
shift10.cpp
|
||||||
sleep.cpp
|
sleep.cpp
|
||||||
terminalColors.cpp
|
terminalColors.cpp
|
||||||
errnoToString.cpp
|
errnoToString.cpp
|
||||||
getResource.cpp
|
|
||||||
StringRef.cpp
|
StringRef.cpp
|
||||||
|
safeExit.cpp
|
||||||
|
throwError.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ENABLE_REPLXX)
|
|
||||||
list (APPEND SRCS ReplxxLineReader.cpp)
|
|
||||||
elseif (ENABLE_READLINE)
|
|
||||||
list (APPEND SRCS ReadlineLineReader.cpp)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (USE_DEBUG_HELPERS)
|
if (USE_DEBUG_HELPERS)
|
||||||
set (INCLUDE_DEBUG_HELPERS "-include \"${ClickHouse_SOURCE_DIR}/base/base/iostream_debug_helpers.h\"")
|
get_target_property(MAGIC_ENUM_INCLUDE_DIR ch_contrib::magic_enum INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${INCLUDE_DEBUG_HELPERS}")
|
# CMake generator expression will do insane quoting when it encounters special character like quotes, spaces, etc.
|
||||||
|
# Prefixing "SHELL:" will force it to use the original text.
|
||||||
|
set (INCLUDE_DEBUG_HELPERS "SHELL:-I\"${MAGIC_ENUM_INCLUDE_DIR}\" -include \"${ClickHouse_SOURCE_DIR}/base/base/iostream_debug_helpers.h\"")
|
||||||
|
# Use generator expression as we don't want to pollute CMAKE_CXX_FLAGS, which will interfere with CMake check system.
|
||||||
|
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:${INCLUDE_DEBUG_HELPERS}>)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_library (common ${SRCS})
|
add_library (common ${SRCS})
|
||||||
@ -41,51 +41,21 @@ else ()
|
|||||||
target_compile_definitions(common PUBLIC WITH_COVERAGE=0)
|
target_compile_definitions(common PUBLIC WITH_COVERAGE=0)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (USE_INTERNAL_CCTZ)
|
|
||||||
set_source_files_properties(DateLUTImpl.cpp PROPERTIES COMPILE_DEFINITIONS USE_INTERNAL_CCTZ)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_include_directories(common PUBLIC .. "${CMAKE_CURRENT_BINARY_DIR}/..")
|
target_include_directories(common PUBLIC .. "${CMAKE_CURRENT_BINARY_DIR}/..")
|
||||||
|
|
||||||
if (OS_DARWIN AND NOT MAKE_STATIC_LIBRARIES)
|
|
||||||
target_link_libraries(common PUBLIC -Wl,-U,_inside_main)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Allow explicit fallback to readline
|
|
||||||
if (NOT ENABLE_REPLXX AND ENABLE_READLINE)
|
|
||||||
message (STATUS "Attempt to fallback to readline explicitly")
|
|
||||||
set (READLINE_PATHS "/usr/local/opt/readline/lib")
|
|
||||||
# First try find custom lib for macos users (default lib without history support)
|
|
||||||
find_library (READLINE_LIB NAMES readline PATHS ${READLINE_PATHS} NO_DEFAULT_PATH)
|
|
||||||
if (NOT READLINE_LIB)
|
|
||||||
find_library (READLINE_LIB NAMES readline PATHS ${READLINE_PATHS})
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
set(READLINE_INCLUDE_PATHS "/usr/local/opt/readline/include")
|
|
||||||
find_path (READLINE_INCLUDE_DIR NAMES readline/readline.h PATHS ${READLINE_INCLUDE_PATHS} NO_DEFAULT_PATH)
|
|
||||||
if (NOT READLINE_INCLUDE_DIR)
|
|
||||||
find_path (READLINE_INCLUDE_DIR NAMES readline/readline.h PATHS ${READLINE_INCLUDE_PATHS})
|
|
||||||
endif ()
|
|
||||||
if (READLINE_INCLUDE_DIR AND READLINE_LIB)
|
|
||||||
target_link_libraries(common PUBLIC ${READLINE_LIB})
|
|
||||||
target_compile_definitions(common PUBLIC USE_READLINE=1)
|
|
||||||
message (STATUS "Using readline: ${READLINE_INCLUDE_DIR} : ${READLINE_LIB}")
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
target_link_libraries (common
|
target_link_libraries (common
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${CITYHASH_LIBRARIES}
|
ch_contrib::cityhash
|
||||||
boost::headers_only
|
boost::headers_only
|
||||||
boost::system
|
boost::system
|
||||||
Poco::Net
|
Poco::Net
|
||||||
Poco::Net::SSL
|
Poco::Net::SSL
|
||||||
Poco::Util
|
Poco::Util
|
||||||
Poco::Foundation
|
Poco::Foundation
|
||||||
replxx
|
ch_contrib::replxx
|
||||||
cctz
|
ch_contrib::cctz
|
||||||
fmt
|
ch_contrib::fmt
|
||||||
magic_enum
|
ch_contrib::magic_enum
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ENABLE_TESTS)
|
if (ENABLE_TESTS)
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <tuple>
|
|
||||||
#include <mutex>
|
|
||||||
#include "FnTraits.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Caching proxy for a functor that decays to a pointer-to-function.
|
|
||||||
* Saves pairs (func args, func result on args).
|
|
||||||
* Cache size is unlimited. Cache items are evicted only on manual drop.
|
|
||||||
* Invocation/update is O(log(saved cache values)).
|
|
||||||
*
|
|
||||||
* See Common/tests/cached_fn.cpp for examples.
|
|
||||||
*/
|
|
||||||
template <auto * Func>
|
|
||||||
struct CachedFn
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
using Traits = FnTraits<decltype(Func)>;
|
|
||||||
using DecayedArgs = TLMap<std::decay_t, typename Traits::Args>;
|
|
||||||
using Key = TLChangeRoot<std::tuple, DecayedArgs>;
|
|
||||||
using Result = typename Traits::Ret;
|
|
||||||
|
|
||||||
std::map<Key, Result> cache; // Can't use hashmap as tuples are unhashable by default
|
|
||||||
mutable std::mutex mutex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
template <class ...Args>
|
|
||||||
Result operator()(Args && ...args)
|
|
||||||
{
|
|
||||||
Key key{std::forward<Args>(args)...};
|
|
||||||
|
|
||||||
{
|
|
||||||
std::lock_guard lock(mutex);
|
|
||||||
|
|
||||||
if (auto it = cache.find(key); it != cache.end())
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result res = std::apply(Func, key);
|
|
||||||
|
|
||||||
{
|
|
||||||
std::lock_guard lock(mutex);
|
|
||||||
cache.emplace(std::move(key), res);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ...Args>
|
|
||||||
void update(Args && ...args)
|
|
||||||
{
|
|
||||||
Key key{std::forward<Args>(args)...};
|
|
||||||
Result res = std::apply(Func, key);
|
|
||||||
|
|
||||||
{
|
|
||||||
std::lock_guard lock(mutex);
|
|
||||||
// TODO Can't use emplace(std::move(key), ..), causes test_host_ip_change errors.
|
|
||||||
cache[key] = std::move(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t size() const
|
|
||||||
{
|
|
||||||
std::lock_guard lock(mutex);
|
|
||||||
return cache.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void drop()
|
|
||||||
{
|
|
||||||
std::lock_guard lock(mutex);
|
|
||||||
cache.clear();
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,57 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "DateLUTImpl.h"
|
|
||||||
|
|
||||||
#include "defines.h"
|
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
#include <memory>
|
|
||||||
#include <mutex>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
|
|
||||||
/// This class provides lazy initialization and lookup of singleton DateLUTImpl objects for a given timezone.
|
|
||||||
class DateLUT : private boost::noncopyable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Return singleton DateLUTImpl instance for the default time zone.
|
|
||||||
static ALWAYS_INLINE const DateLUTImpl & instance() // -V1071
|
|
||||||
{
|
|
||||||
const auto & date_lut = getInstance();
|
|
||||||
return *date_lut.default_impl.load(std::memory_order_acquire);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return singleton DateLUTImpl instance for a given time zone.
|
|
||||||
static ALWAYS_INLINE const DateLUTImpl & instance(const std::string & time_zone)
|
|
||||||
{
|
|
||||||
const auto & date_lut = getInstance();
|
|
||||||
if (time_zone.empty())
|
|
||||||
return *date_lut.default_impl.load(std::memory_order_acquire);
|
|
||||||
|
|
||||||
return date_lut.getImplementation(time_zone);
|
|
||||||
}
|
|
||||||
static void setDefaultTimezone(const std::string & time_zone)
|
|
||||||
{
|
|
||||||
auto & date_lut = getInstance();
|
|
||||||
const auto & impl = date_lut.getImplementation(time_zone);
|
|
||||||
date_lut.default_impl.store(&impl, std::memory_order_release);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
DateLUT();
|
|
||||||
|
|
||||||
private:
|
|
||||||
static DateLUT & getInstance();
|
|
||||||
|
|
||||||
const DateLUTImpl & getImplementation(const std::string & time_zone) const;
|
|
||||||
|
|
||||||
using DateLUTImplPtr = std::unique_ptr<DateLUTImpl>;
|
|
||||||
|
|
||||||
/// Time zone name -> implementation.
|
|
||||||
mutable std::unordered_map<std::string, DateLUTImplPtr> impls;
|
|
||||||
mutable std::mutex mutex;
|
|
||||||
|
|
||||||
std::atomic<const DateLUTImpl *> default_impl;
|
|
||||||
};
|
|
File diff suppressed because it is too large
Load Diff
@ -49,18 +49,18 @@ struct Decimal
|
|||||||
using NativeType = T;
|
using NativeType = T;
|
||||||
|
|
||||||
constexpr Decimal() = default;
|
constexpr Decimal() = default;
|
||||||
constexpr Decimal(Decimal<T> &&) = default;
|
constexpr Decimal(Decimal<T> &&) noexcept = default;
|
||||||
constexpr Decimal(const Decimal<T> &) = default;
|
constexpr Decimal(const Decimal<T> &) = default;
|
||||||
|
|
||||||
constexpr Decimal(const T & value_): value(value_) {}
|
constexpr Decimal(const T & value_): value(value_) {} // NOLINT(google-explicit-constructor)
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
constexpr Decimal(const Decimal<U> & x): value(x.value) {}
|
constexpr Decimal(const Decimal<U> & x): value(x.value) {} // NOLINT(google-explicit-constructor)
|
||||||
|
|
||||||
constexpr Decimal<T> & operator = (Decimal<T> &&) = default;
|
constexpr Decimal<T> & operator=(Decimal<T> &&) noexcept = default;
|
||||||
constexpr Decimal<T> & operator = (const Decimal<T> &) = default;
|
constexpr Decimal<T> & operator = (const Decimal<T> &) = default;
|
||||||
|
|
||||||
constexpr operator T () const { return value; }
|
constexpr operator T () const { return value; } // NOLINT(google-explicit-constructor)
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
constexpr U convertTo() const
|
constexpr U convertTo() const
|
||||||
@ -111,7 +111,7 @@ public:
|
|||||||
using Base::Base;
|
using Base::Base;
|
||||||
using NativeType = Base::NativeType;
|
using NativeType = Base::NativeType;
|
||||||
|
|
||||||
constexpr DateTime64(const Base & v): Base(v) {}
|
constexpr DateTime64(const Base & v): Base(v) {} // NOLINT(google-explicit-constructor)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,14 +36,14 @@ struct DecomposedFloat
|
|||||||
{
|
{
|
||||||
using Traits = FloatTraits<T>;
|
using Traits = FloatTraits<T>;
|
||||||
|
|
||||||
DecomposedFloat(T x)
|
explicit DecomposedFloat(T x)
|
||||||
{
|
{
|
||||||
memcpy(&x_uint, &x, sizeof(x));
|
memcpy(&x_uint, &x, sizeof(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
typename Traits::UInt x_uint;
|
typename Traits::UInt x_uint;
|
||||||
|
|
||||||
bool is_negative() const
|
bool isNegative() const
|
||||||
{
|
{
|
||||||
return x_uint >> (Traits::bits - 1);
|
return x_uint >> (Traits::bits - 1);
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ struct DecomposedFloat
|
|||||||
{
|
{
|
||||||
return (exponent() == 0 && mantissa() == 0)
|
return (exponent() == 0 && mantissa() == 0)
|
||||||
? 0
|
? 0
|
||||||
: (is_negative()
|
: (isNegative()
|
||||||
? -1
|
? -1
|
||||||
: 1);
|
: 1);
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ struct DecomposedFloat
|
|||||||
return (x_uint >> (Traits::mantissa_bits)) & (((1ull << (Traits::exponent_bits + 1)) - 1) >> 1);
|
return (x_uint >> (Traits::mantissa_bits)) & (((1ull << (Traits::exponent_bits + 1)) - 1) >> 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t normalized_exponent() const
|
int16_t normalizedExponent() const
|
||||||
{
|
{
|
||||||
return int16_t(exponent()) - ((1ull << (Traits::exponent_bits - 1)) - 1);
|
return int16_t(exponent()) - ((1ull << (Traits::exponent_bits - 1)) - 1);
|
||||||
}
|
}
|
||||||
@ -73,20 +73,20 @@ struct DecomposedFloat
|
|||||||
return x_uint & ((1ull << Traits::mantissa_bits) - 1);
|
return x_uint & ((1ull << Traits::mantissa_bits) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t mantissa_with_sign() const
|
int64_t mantissaWithSign() const
|
||||||
{
|
{
|
||||||
return is_negative() ? -mantissa() : mantissa();
|
return isNegative() ? -mantissa() : mantissa();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// NOTE Probably floating point instructions can be better.
|
/// NOTE Probably floating point instructions can be better.
|
||||||
bool is_integer_in_representable_range() const
|
bool isIntegerInRepresentableRange() const
|
||||||
{
|
{
|
||||||
return x_uint == 0
|
return x_uint == 0
|
||||||
|| (normalized_exponent() >= 0 /// The number is not less than one
|
|| (normalizedExponent() >= 0 /// The number is not less than one
|
||||||
/// The number is inside the range where every integer has exact representation in float
|
/// The number is inside the range where every integer has exact representation in float
|
||||||
&& normalized_exponent() <= static_cast<int16_t>(Traits::mantissa_bits)
|
&& normalizedExponent() <= static_cast<int16_t>(Traits::mantissa_bits)
|
||||||
/// After multiplying by 2^exp, the fractional part becomes zero, means the number is integer
|
/// After multiplying by 2^exp, the fractional part becomes zero, means the number is integer
|
||||||
&& ((mantissa() & ((1ULL << (Traits::mantissa_bits - normalized_exponent())) - 1)) == 0));
|
&& ((mantissa() & ((1ULL << (Traits::mantissa_bits - normalizedExponent())) - 1)) == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -102,15 +102,15 @@ struct DecomposedFloat
|
|||||||
return sign();
|
return sign();
|
||||||
|
|
||||||
/// Different signs
|
/// Different signs
|
||||||
if (is_negative() && rhs > 0)
|
if (isNegative() && rhs > 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (!is_negative() && rhs < 0)
|
if (!isNegative() && rhs < 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/// Fractional number with magnitude less than one
|
/// Fractional number with magnitude less than one
|
||||||
if (normalized_exponent() < 0)
|
if (normalizedExponent() < 0)
|
||||||
{
|
{
|
||||||
if (!is_negative())
|
if (!isNegative())
|
||||||
return rhs > 0 ? -1 : 1;
|
return rhs > 0 ? -1 : 1;
|
||||||
else
|
else
|
||||||
return rhs >= 0 ? -1 : 1;
|
return rhs >= 0 ? -1 : 1;
|
||||||
@ -121,11 +121,11 @@ struct DecomposedFloat
|
|||||||
{
|
{
|
||||||
if (rhs == std::numeric_limits<Int>::lowest())
|
if (rhs == std::numeric_limits<Int>::lowest())
|
||||||
{
|
{
|
||||||
assert(is_negative());
|
assert(isNegative());
|
||||||
|
|
||||||
if (normalized_exponent() < static_cast<int16_t>(8 * sizeof(Int) - is_signed_v<Int>))
|
if (normalizedExponent() < static_cast<int16_t>(8 * sizeof(Int) - is_signed_v<Int>))
|
||||||
return 1;
|
return 1;
|
||||||
if (normalized_exponent() > static_cast<int16_t>(8 * sizeof(Int) - is_signed_v<Int>))
|
if (normalizedExponent() > static_cast<int16_t>(8 * sizeof(Int) - is_signed_v<Int>))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (mantissa() == 0)
|
if (mantissa() == 0)
|
||||||
@ -136,44 +136,44 @@ struct DecomposedFloat
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Too large number: abs(float) > abs(rhs). Also the case with infinities and NaN.
|
/// Too large number: abs(float) > abs(rhs). Also the case with infinities and NaN.
|
||||||
if (normalized_exponent() >= static_cast<int16_t>(8 * sizeof(Int) - is_signed_v<Int>))
|
if (normalizedExponent() >= static_cast<int16_t>(8 * sizeof(Int) - is_signed_v<Int>))
|
||||||
return is_negative() ? -1 : 1;
|
return isNegative() ? -1 : 1;
|
||||||
|
|
||||||
using UInt = std::conditional_t<(sizeof(Int) > sizeof(typename Traits::UInt)), make_unsigned_t<Int>, typename Traits::UInt>;
|
using UInt = std::conditional_t<(sizeof(Int) > sizeof(typename Traits::UInt)), make_unsigned_t<Int>, typename Traits::UInt>;
|
||||||
UInt uint_rhs = rhs < 0 ? -rhs : rhs;
|
UInt uint_rhs = rhs < 0 ? -rhs : rhs;
|
||||||
|
|
||||||
/// Smaller octave: abs(rhs) < abs(float)
|
/// Smaller octave: abs(rhs) < abs(float)
|
||||||
/// FYI, TIL: octave is also called "binade", https://en.wikipedia.org/wiki/Binade
|
/// FYI, TIL: octave is also called "binade", https://en.wikipedia.org/wiki/Binade
|
||||||
if (uint_rhs < (static_cast<UInt>(1) << normalized_exponent()))
|
if (uint_rhs < (static_cast<UInt>(1) << normalizedExponent()))
|
||||||
return is_negative() ? -1 : 1;
|
return isNegative() ? -1 : 1;
|
||||||
|
|
||||||
/// Larger octave: abs(rhs) > abs(float)
|
/// Larger octave: abs(rhs) > abs(float)
|
||||||
if (normalized_exponent() + 1 < static_cast<int16_t>(8 * sizeof(Int) - is_signed_v<Int>)
|
if (normalizedExponent() + 1 < static_cast<int16_t>(8 * sizeof(Int) - is_signed_v<Int>)
|
||||||
&& uint_rhs >= (static_cast<UInt>(1) << (normalized_exponent() + 1)))
|
&& uint_rhs >= (static_cast<UInt>(1) << (normalizedExponent() + 1)))
|
||||||
return is_negative() ? 1 : -1;
|
return isNegative() ? 1 : -1;
|
||||||
|
|
||||||
/// The same octave
|
/// The same octave
|
||||||
/// uint_rhs == 2 ^ normalized_exponent + mantissa * 2 ^ (normalized_exponent - mantissa_bits)
|
/// uint_rhs == 2 ^ normalizedExponent + mantissa * 2 ^ (normalizedExponent - mantissa_bits)
|
||||||
|
|
||||||
bool large_and_always_integer = normalized_exponent() >= static_cast<int16_t>(Traits::mantissa_bits);
|
bool large_and_always_integer = normalizedExponent() >= static_cast<int16_t>(Traits::mantissa_bits);
|
||||||
|
|
||||||
UInt a = large_and_always_integer
|
UInt a = large_and_always_integer
|
||||||
? static_cast<UInt>(mantissa()) << (normalized_exponent() - Traits::mantissa_bits)
|
? static_cast<UInt>(mantissa()) << (normalizedExponent() - Traits::mantissa_bits)
|
||||||
: static_cast<UInt>(mantissa()) >> (Traits::mantissa_bits - normalized_exponent());
|
: static_cast<UInt>(mantissa()) >> (Traits::mantissa_bits - normalizedExponent());
|
||||||
|
|
||||||
UInt b = uint_rhs - (static_cast<UInt>(1) << normalized_exponent());
|
UInt b = uint_rhs - (static_cast<UInt>(1) << normalizedExponent());
|
||||||
|
|
||||||
if (a < b)
|
if (a < b)
|
||||||
return is_negative() ? 1 : -1;
|
return isNegative() ? 1 : -1;
|
||||||
if (a > b)
|
if (a > b)
|
||||||
return is_negative() ? -1 : 1;
|
return isNegative() ? -1 : 1;
|
||||||
|
|
||||||
/// Float has no fractional part means that the numbers are equal.
|
/// Float has no fractional part means that the numbers are equal.
|
||||||
if (large_and_always_integer || (mantissa() & ((1ULL << (Traits::mantissa_bits - normalized_exponent())) - 1)) == 0)
|
if (large_and_always_integer || (mantissa() & ((1ULL << (Traits::mantissa_bits - normalizedExponent())) - 1)) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
/// Float has fractional part means its abs value is larger.
|
/// Float has fractional part means its abs value is larger.
|
||||||
return is_negative() ? -1 : 1;
|
return isNegative() ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Typelist.h"
|
#include "TypeList.h"
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
@ -14,7 +14,7 @@ struct FnTraits<R(A...)>
|
|||||||
static constexpr bool value = std::is_invocable_r_v<R, F, A...>;
|
static constexpr bool value = std::is_invocable_r_v<R, F, A...>;
|
||||||
|
|
||||||
using Ret = R;
|
using Ret = R;
|
||||||
using Args = Typelist<A...>;
|
using Args = TypeList<A...>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class R, class ...A>
|
template <class R, class ...A>
|
||||||
|
53
base/base/IPv4andIPv6.h
Normal file
53
base/base/IPv4andIPv6.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <base/strong_typedef.h>
|
||||||
|
#include <base/extended_types.h>
|
||||||
|
#include <Common/memcmpSmall.h>
|
||||||
|
|
||||||
|
namespace DB
|
||||||
|
{
|
||||||
|
|
||||||
|
using IPv4 = StrongTypedef<UInt32, struct IPv4Tag>;
|
||||||
|
|
||||||
|
struct IPv6 : StrongTypedef<UInt128, struct IPv6Tag>
|
||||||
|
{
|
||||||
|
constexpr IPv6() = default;
|
||||||
|
constexpr explicit IPv6(const UInt128 & x) : StrongTypedef(x) {}
|
||||||
|
constexpr explicit IPv6(UInt128 && x) : StrongTypedef(std::move(x)) {}
|
||||||
|
|
||||||
|
IPv6 & operator=(const UInt128 & rhs) { StrongTypedef::operator=(rhs); return *this; }
|
||||||
|
IPv6 & operator=(UInt128 && rhs) { StrongTypedef::operator=(std::move(rhs)); return *this; }
|
||||||
|
|
||||||
|
bool operator<(const IPv6 & rhs) const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
memcmp16(
|
||||||
|
reinterpret_cast<const unsigned char *>(toUnderType().items),
|
||||||
|
reinterpret_cast<const unsigned char *>(rhs.toUnderType().items)
|
||||||
|
) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator>(const IPv6 & rhs) const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
memcmp16(
|
||||||
|
reinterpret_cast<const unsigned char *>(toUnderType().items),
|
||||||
|
reinterpret_cast<const unsigned char *>(rhs.toUnderType().items)
|
||||||
|
) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const IPv6 & rhs) const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
memcmp16(
|
||||||
|
reinterpret_cast<const unsigned char *>(toUnderType().items),
|
||||||
|
reinterpret_cast<const unsigned char *>(rhs.toUnderType().items)
|
||||||
|
) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator<=(const IPv6 & rhs) const { return !operator>(rhs); }
|
||||||
|
bool operator>=(const IPv6 & rhs) const { return !operator<(rhs); }
|
||||||
|
bool operator!=(const IPv6 & rhs) const { return !operator==(rhs); }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
#include <Poco/UTF8Encoding.h>
|
#include <Poco/UTF8Encoding.h>
|
||||||
#include <Poco/NumberParser.h>
|
#include <Poco/NumberParser.h>
|
||||||
@ -12,10 +12,17 @@
|
|||||||
#define JSON_MAX_DEPTH 100
|
#define JSON_MAX_DEPTH 100
|
||||||
|
|
||||||
|
|
||||||
POCO_IMPLEMENT_EXCEPTION(JSONException, Poco::Exception, "JSONException")
|
#ifdef __clang__
|
||||||
|
# pragma clang diagnostic push
|
||||||
|
# pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
|
||||||
|
#endif
|
||||||
|
POCO_IMPLEMENT_EXCEPTION(JSONException, Poco::Exception, "JSONException") // NOLINT(cert-err60-cpp, modernize-use-noexcept, hicpp-use-noexcept)
|
||||||
|
#ifdef __clang__
|
||||||
|
# pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/// Прочитать беззнаковое целое в простом формате из не-0-terminated строки.
|
/// Read unsigned integer in a simple form from a non-0-terminated string.
|
||||||
static UInt64 readUIntText(const char * buf, const char * end)
|
static UInt64 readUIntText(const char * buf, const char * end)
|
||||||
{
|
{
|
||||||
UInt64 x = 0;
|
UInt64 x = 0;
|
||||||
@ -52,7 +59,7 @@ static UInt64 readUIntText(const char * buf, const char * end)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Прочитать знаковое целое в простом формате из не-0-terminated строки.
|
/// Read signed integer in a simple form from a non-0-terminated string.
|
||||||
static Int64 readIntText(const char * buf, const char * end)
|
static Int64 readIntText(const char * buf, const char * end)
|
||||||
{
|
{
|
||||||
bool negative = false;
|
bool negative = false;
|
||||||
@ -95,7 +102,7 @@ static Int64 readIntText(const char * buf, const char * end)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Прочитать число с плавающей запятой в простом формате, с грубым округлением, из не-0-terminated строки.
|
/// Read floating point number in simple format, imprecisely, from a non-0-terminated string.
|
||||||
static double readFloatText(const char * buf, const char * end)
|
static double readFloatText(const char * buf, const char * end)
|
||||||
{
|
{
|
||||||
bool negative = false;
|
bool negative = false;
|
||||||
@ -144,8 +151,8 @@ static double readFloatText(const char * buf, const char * end)
|
|||||||
case 'E':
|
case 'E':
|
||||||
{
|
{
|
||||||
++buf;
|
++buf;
|
||||||
Int32 exponent = readIntText(buf, end);
|
auto exponent = readIntText(buf, end);
|
||||||
x *= preciseExp10(exponent);
|
x *= preciseExp10(static_cast<double>(exponent));
|
||||||
|
|
||||||
run = false;
|
run = false;
|
||||||
break;
|
break;
|
||||||
@ -200,7 +207,7 @@ JSON::ElementType JSON::getType() const
|
|||||||
return TYPE_NUMBER;
|
return TYPE_NUMBER;
|
||||||
case '"':
|
case '"':
|
||||||
{
|
{
|
||||||
/// Проверим - это просто строка или name-value pair
|
/// Is it a string or a name-value pair?
|
||||||
Pos after_string = skipString();
|
Pos after_string = skipString();
|
||||||
if (after_string < ptr_end && *after_string == ':')
|
if (after_string < ptr_end && *after_string == ':')
|
||||||
return TYPE_NAME_VALUE_PAIR;
|
return TYPE_NAME_VALUE_PAIR;
|
||||||
@ -222,15 +229,13 @@ void JSON::checkPos(Pos pos) const
|
|||||||
|
|
||||||
JSON::Pos JSON::skipString() const
|
JSON::Pos JSON::skipString() const
|
||||||
{
|
{
|
||||||
//std::cerr << "skipString()\t" << data() << std::endl;
|
|
||||||
|
|
||||||
Pos pos = ptr_begin;
|
Pos pos = ptr_begin;
|
||||||
checkPos(pos);
|
checkPos(pos);
|
||||||
if (*pos != '"')
|
if (*pos != '"')
|
||||||
throw JSONException(std::string("JSON: expected \", got ") + *pos);
|
throw JSONException(std::string("JSON: expected \", got ") + *pos);
|
||||||
++pos;
|
++pos;
|
||||||
|
|
||||||
/// fast path: находим следующую двойную кавычку. Если перед ней нет бэкслеша - значит это конец строки (при допущении корректности JSON).
|
/// fast path: find next double quote. If it is not escaped by backslash - then it's an end of string (assuming JSON is valid).
|
||||||
Pos closing_quote = reinterpret_cast<const char *>(memchr(reinterpret_cast<const void *>(pos), '\"', ptr_end - pos));
|
Pos closing_quote = reinterpret_cast<const char *>(memchr(reinterpret_cast<const void *>(pos), '\"', ptr_end - pos));
|
||||||
if (nullptr != closing_quote && closing_quote[-1] != '\\')
|
if (nullptr != closing_quote && closing_quote[-1] != '\\')
|
||||||
return closing_quote + 1;
|
return closing_quote + 1;
|
||||||
@ -262,8 +267,6 @@ JSON::Pos JSON::skipString() const
|
|||||||
|
|
||||||
JSON::Pos JSON::skipNumber() const
|
JSON::Pos JSON::skipNumber() const
|
||||||
{
|
{
|
||||||
//std::cerr << "skipNumber()\t" << data() << std::endl;
|
|
||||||
|
|
||||||
Pos pos = ptr_begin;
|
Pos pos = ptr_begin;
|
||||||
|
|
||||||
checkPos(pos);
|
checkPos(pos);
|
||||||
@ -289,8 +292,6 @@ JSON::Pos JSON::skipNumber() const
|
|||||||
|
|
||||||
JSON::Pos JSON::skipBool() const
|
JSON::Pos JSON::skipBool() const
|
||||||
{
|
{
|
||||||
//std::cerr << "skipBool()\t" << data() << std::endl;
|
|
||||||
|
|
||||||
Pos pos = ptr_begin;
|
Pos pos = ptr_begin;
|
||||||
checkPos(pos);
|
checkPos(pos);
|
||||||
|
|
||||||
@ -307,16 +308,12 @@ JSON::Pos JSON::skipBool() const
|
|||||||
|
|
||||||
JSON::Pos JSON::skipNull() const
|
JSON::Pos JSON::skipNull() const
|
||||||
{
|
{
|
||||||
//std::cerr << "skipNull()\t" << data() << std::endl;
|
|
||||||
|
|
||||||
return ptr_begin + 4;
|
return ptr_begin + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JSON::Pos JSON::skipNameValuePair() const
|
JSON::Pos JSON::skipNameValuePair() const
|
||||||
{
|
{
|
||||||
//std::cerr << "skipNameValuePair()\t" << data() << std::endl;
|
|
||||||
|
|
||||||
Pos pos = skipString();
|
Pos pos = skipString();
|
||||||
checkPos(pos);
|
checkPos(pos);
|
||||||
|
|
||||||
@ -331,8 +328,6 @@ JSON::Pos JSON::skipNameValuePair() const
|
|||||||
|
|
||||||
JSON::Pos JSON::skipArray() const
|
JSON::Pos JSON::skipArray() const
|
||||||
{
|
{
|
||||||
//std::cerr << "skipArray()\t" << data() << std::endl;
|
|
||||||
|
|
||||||
if (!isArray())
|
if (!isArray())
|
||||||
throw JSONException("JSON: expected [");
|
throw JSONException("JSON: expected [");
|
||||||
Pos pos = ptr_begin;
|
Pos pos = ptr_begin;
|
||||||
@ -363,8 +358,6 @@ JSON::Pos JSON::skipArray() const
|
|||||||
|
|
||||||
JSON::Pos JSON::skipObject() const
|
JSON::Pos JSON::skipObject() const
|
||||||
{
|
{
|
||||||
//std::cerr << "skipObject()\t" << data() << std::endl;
|
|
||||||
|
|
||||||
if (!isObject())
|
if (!isObject())
|
||||||
throw JSONException("JSON: expected {");
|
throw JSONException("JSON: expected {");
|
||||||
Pos pos = ptr_begin;
|
Pos pos = ptr_begin;
|
||||||
@ -395,8 +388,6 @@ JSON::Pos JSON::skipObject() const
|
|||||||
|
|
||||||
JSON::Pos JSON::skipElement() const
|
JSON::Pos JSON::skipElement() const
|
||||||
{
|
{
|
||||||
//std::cerr << "skipElement()\t" << data() << std::endl;
|
|
||||||
|
|
||||||
ElementType type = getType();
|
ElementType type = getType();
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
@ -633,7 +624,7 @@ std::string JSON::getString() const
|
|||||||
{
|
{
|
||||||
throw JSONException("JSON: incorrect syntax: incorrect HEX code.");
|
throw JSONException("JSON: incorrect syntax: incorrect HEX code.");
|
||||||
}
|
}
|
||||||
buf.resize(buf.size() + 6); /// максимальный размер UTF8 многобайтовой последовательности
|
buf.resize(buf.size() + 6); /// Max size of UTF-8 sequence, including pre-standard mapping of UCS-4 to UTF-8.
|
||||||
int res = utf8.convert(unicode,
|
int res = utf8.convert(unicode,
|
||||||
reinterpret_cast<unsigned char *>(const_cast<char*>(buf.data())) + buf.size() - 6, 6);
|
reinterpret_cast<unsigned char *>(const_cast<char*>(buf.data())) + buf.size() - 6, 6);
|
||||||
if (!res)
|
if (!res)
|
||||||
@ -662,18 +653,18 @@ std::string JSON::getName() const
|
|||||||
return getString();
|
return getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef JSON::getRawString() const
|
std::string_view JSON::getRawString() const
|
||||||
{
|
{
|
||||||
Pos s = ptr_begin;
|
Pos s = ptr_begin;
|
||||||
if (*s != '"')
|
if (*s != '"')
|
||||||
throw JSONException(std::string("JSON: expected \", got ") + *s);
|
throw JSONException(std::string("JSON: expected \", got ") + *s);
|
||||||
while (++s != ptr_end && *s != '"');
|
while (++s != ptr_end && *s != '"');
|
||||||
if (s != ptr_end)
|
if (s != ptr_end)
|
||||||
return StringRef(ptr_begin + 1, s - ptr_begin - 1);
|
return std::string_view(ptr_begin + 1, s - ptr_begin - 1);
|
||||||
throw JSONException("JSON: incorrect syntax (expected end of string, found end of JSON).");
|
throw JSONException("JSON: incorrect syntax (expected end of string, found end of JSON).");
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef JSON::getRawName() const
|
std::string_view JSON::getRawName() const
|
||||||
{
|
{
|
||||||
return getRawString();
|
return getRawString();
|
||||||
}
|
}
|
||||||
@ -747,8 +738,6 @@ JSON::iterator JSON::iterator::begin() const
|
|||||||
if (type != TYPE_ARRAY && type != TYPE_OBJECT)
|
if (type != TYPE_ARRAY && type != TYPE_OBJECT)
|
||||||
throw JSONException("JSON: not array or object when calling begin() method.");
|
throw JSONException("JSON: not array or object when calling begin() method.");
|
||||||
|
|
||||||
//std::cerr << "begin()\t" << data() << std::endl;
|
|
||||||
|
|
||||||
Pos pos = ptr_begin + 1;
|
Pos pos = ptr_begin + 1;
|
||||||
checkPos(pos);
|
checkPos(pos);
|
||||||
if (*pos == '}' || *pos == ']')
|
if (*pos == '}' || *pos == ']')
|
||||||
@ -839,4 +828,3 @@ bool JSON::isType<bool>() const
|
|||||||
{
|
{
|
||||||
return isBool();
|
return isBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +38,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// NOLINTBEGIN(google-explicit-constructor)
|
||||||
|
#ifdef __clang__
|
||||||
|
# pragma clang diagnostic push
|
||||||
|
# pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
|
||||||
|
#endif
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, JSONException, Poco::Exception)
|
POCO_DECLARE_EXCEPTION(Foundation_API, JSONException, Poco::Exception)
|
||||||
|
#ifdef __clang__
|
||||||
|
# pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
// NOLINTEND(google-explicit-constructor)
|
||||||
|
|
||||||
class JSON
|
class JSON
|
||||||
{
|
{
|
||||||
@ -55,7 +63,7 @@ public:
|
|||||||
checkInit();
|
checkInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
JSON(const std::string & s) : ptr_begin(s.data()), ptr_end(s.data() + s.size()), level(0)
|
explicit JSON(std::string_view s) : ptr_begin(s.data()), ptr_end(s.data() + s.size()), level(0)
|
||||||
{
|
{
|
||||||
checkInit();
|
checkInit();
|
||||||
}
|
}
|
||||||
@ -65,13 +73,7 @@ public:
|
|||||||
*this = rhs;
|
*this = rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSON & operator=(const JSON & rhs)
|
JSON & operator=(const JSON & rhs) = default;
|
||||||
{
|
|
||||||
ptr_begin = rhs.ptr_begin;
|
|
||||||
ptr_end = rhs.ptr_end;
|
|
||||||
level = rhs.level;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * data() const { return ptr_begin; }
|
const char * data() const { return ptr_begin; }
|
||||||
const char * dataEnd() const { return ptr_end; }
|
const char * dataEnd() const { return ptr_end; }
|
||||||
@ -130,8 +132,8 @@ public:
|
|||||||
std::string getName() const; /// Получить имя name-value пары.
|
std::string getName() const; /// Получить имя name-value пары.
|
||||||
JSON getValue() const; /// Получить значение name-value пары.
|
JSON getValue() const; /// Получить значение name-value пары.
|
||||||
|
|
||||||
StringRef getRawString() const;
|
std::string_view getRawString() const;
|
||||||
StringRef getRawName() const;
|
std::string_view getRawName() const;
|
||||||
|
|
||||||
/// Получить значение элемента; если элемент - строка, то распарсить значение из строки; если не строка или число - то исключение.
|
/// Получить значение элемента; если элемент - строка, то распарсить значение из строки; если не строка или число - то исключение.
|
||||||
double toDouble() const;
|
double toDouble() const;
|
||||||
@ -163,7 +165,7 @@ public:
|
|||||||
|
|
||||||
/// Перейти к следующему элементу массива или следующей name-value паре объекта.
|
/// Перейти к следующему элементу массива или следующей name-value паре объекта.
|
||||||
iterator & operator++();
|
iterator & operator++();
|
||||||
iterator operator++(int);
|
iterator operator++(int); // NOLINT(cert-dcl21-cpp)
|
||||||
|
|
||||||
/// Есть ли в строке escape-последовательности
|
/// Есть ли в строке escape-последовательности
|
||||||
bool hasEscapes() const;
|
bool hasEscapes() const;
|
||||||
|
@ -1,191 +0,0 @@
|
|||||||
#include <base/LineReader.h>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <string_view>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef OS_LINUX
|
|
||||||
/// We can detect if code is linked with one or another readline variants or open the library dynamically.
|
|
||||||
# include <dlfcn.h>
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
char * readline(const char *) __attribute__((__weak__));
|
|
||||||
char * (*readline_ptr)(const char *) = readline;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAS_RESERVED_IDENTIFIER
|
|
||||||
#pragma clang diagnostic ignored "-Wreserved-identifier"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
/// Trim ending whitespace inplace
|
|
||||||
void trim(String & s)
|
|
||||||
{
|
|
||||||
s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { return !std::isspace(ch); }).base(), s.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if multi-line query is inserted from the paste buffer.
|
|
||||||
/// Allows delaying the start of query execution until the entirety of query is inserted.
|
|
||||||
bool hasInputData()
|
|
||||||
{
|
|
||||||
timeval timeout = {0, 0};
|
|
||||||
fd_set fds{};
|
|
||||||
FD_ZERO(&fds);
|
|
||||||
FD_SET(STDIN_FILENO, &fds);
|
|
||||||
return select(1, &fds, nullptr, nullptr, &timeout) == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<LineReader::Suggest::WordsRange> LineReader::Suggest::getCompletions(const String & prefix, size_t prefix_length) const
|
|
||||||
{
|
|
||||||
if (!ready)
|
|
||||||
return std::nullopt;
|
|
||||||
|
|
||||||
std::string_view last_word;
|
|
||||||
|
|
||||||
auto last_word_pos = prefix.find_last_of(word_break_characters);
|
|
||||||
if (std::string::npos == last_word_pos)
|
|
||||||
last_word = prefix;
|
|
||||||
else
|
|
||||||
last_word = std::string_view(prefix).substr(last_word_pos + 1, std::string::npos);
|
|
||||||
|
|
||||||
/// last_word can be empty.
|
|
||||||
|
|
||||||
/// Only perform case sensitive completion when the prefix string contains any uppercase characters
|
|
||||||
if (std::none_of(prefix.begin(), prefix.end(), [&](auto c) { return c >= 'A' && c <= 'Z'; }))
|
|
||||||
return std::equal_range(
|
|
||||||
words_no_case.begin(), words_no_case.end(), last_word, [prefix_length](std::string_view s, std::string_view prefix_searched)
|
|
||||||
{
|
|
||||||
return strncasecmp(s.data(), prefix_searched.data(), prefix_length) < 0;
|
|
||||||
});
|
|
||||||
else
|
|
||||||
return std::equal_range(words.begin(), words.end(), last_word, [prefix_length](std::string_view s, std::string_view prefix_searched)
|
|
||||||
{
|
|
||||||
return strncmp(s.data(), prefix_searched.data(), prefix_length) < 0;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
LineReader::LineReader(const String & history_file_path_, bool multiline_, Patterns extenders_, Patterns delimiters_)
|
|
||||||
: history_file_path(history_file_path_), multiline(multiline_), extenders(std::move(extenders_)), delimiters(std::move(delimiters_))
|
|
||||||
{
|
|
||||||
/// FIXME: check extender != delimiter
|
|
||||||
}
|
|
||||||
|
|
||||||
String LineReader::readLine(const String & first_prompt, const String & second_prompt)
|
|
||||||
{
|
|
||||||
String line;
|
|
||||||
bool need_next_line = false;
|
|
||||||
|
|
||||||
while (auto status = readOneLine(need_next_line ? second_prompt : first_prompt))
|
|
||||||
{
|
|
||||||
if (status == RESET_LINE)
|
|
||||||
{
|
|
||||||
line.clear();
|
|
||||||
need_next_line = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (input.empty())
|
|
||||||
{
|
|
||||||
if (!line.empty() && !multiline && !hasInputData())
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * has_extender = nullptr;
|
|
||||||
for (const auto * extender : extenders)
|
|
||||||
{
|
|
||||||
if (input.ends_with(extender))
|
|
||||||
{
|
|
||||||
has_extender = extender;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * has_delimiter = nullptr;
|
|
||||||
for (const auto * delimiter : delimiters)
|
|
||||||
{
|
|
||||||
if (input.ends_with(delimiter))
|
|
||||||
{
|
|
||||||
has_delimiter = delimiter;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
need_next_line = has_extender || (multiline && !has_delimiter) || hasInputData();
|
|
||||||
|
|
||||||
if (has_extender)
|
|
||||||
{
|
|
||||||
input.resize(input.size() - strlen(has_extender));
|
|
||||||
trim(input);
|
|
||||||
if (input.empty())
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
line += (line.empty() ? "" : "\n") + input;
|
|
||||||
|
|
||||||
if (!need_next_line)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!line.empty() && line != prev_line)
|
|
||||||
{
|
|
||||||
addToHistory(line);
|
|
||||||
prev_line = line;
|
|
||||||
}
|
|
||||||
|
|
||||||
return line;
|
|
||||||
}
|
|
||||||
|
|
||||||
LineReader::InputStatus LineReader::readOneLine(const String & prompt)
|
|
||||||
{
|
|
||||||
input.clear();
|
|
||||||
|
|
||||||
#ifdef OS_LINUX
|
|
||||||
if (!readline_ptr)
|
|
||||||
{
|
|
||||||
for (const auto * name : {"libreadline.so", "libreadline.so.0", "libeditline.so", "libeditline.so.0"})
|
|
||||||
{
|
|
||||||
void * dl_handle = dlopen(name, RTLD_LAZY);
|
|
||||||
if (dl_handle)
|
|
||||||
{
|
|
||||||
readline_ptr = reinterpret_cast<char * (*)(const char *)>(dlsym(dl_handle, "readline"));
|
|
||||||
if (readline_ptr)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Minimal support for readline
|
|
||||||
if (readline_ptr)
|
|
||||||
{
|
|
||||||
char * line_read = (*readline_ptr)(prompt.c_str());
|
|
||||||
if (!line_read)
|
|
||||||
return ABORT;
|
|
||||||
input = line_read;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
std::cout << prompt;
|
|
||||||
std::getline(std::cin, input);
|
|
||||||
if (!std::cin.good())
|
|
||||||
return ABORT;
|
|
||||||
}
|
|
||||||
|
|
||||||
trim(input);
|
|
||||||
return INPUT_LINE;
|
|
||||||
}
|
|
@ -1,165 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <exception>
|
|
||||||
#include <base/DateLUT.h>
|
|
||||||
#include <base/LocalDate.h>
|
|
||||||
|
|
||||||
|
|
||||||
/** Stores calendar date and time in broken-down form.
|
|
||||||
* Could be initialized from date and time in text form like '2011-01-01 00:00:00' or from time_t.
|
|
||||||
* Could be implicitly casted to time_t.
|
|
||||||
* NOTE: Transforming between time_t and LocalDate is done in local time zone!
|
|
||||||
*
|
|
||||||
* When local time was shifted backwards (due to daylight saving time or whatever reason)
|
|
||||||
* - then to resolve the ambiguity of transforming to time_t, lowest of two possible values is selected.
|
|
||||||
*/
|
|
||||||
class LocalDateTime
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
unsigned short m_year;
|
|
||||||
unsigned char m_month;
|
|
||||||
unsigned char m_day;
|
|
||||||
unsigned char m_hour;
|
|
||||||
unsigned char m_minute;
|
|
||||||
unsigned char m_second;
|
|
||||||
|
|
||||||
/// For struct to fill 8 bytes and for safe invocation of memcmp.
|
|
||||||
/// NOTE We may use attribute packed instead, but it is less portable.
|
|
||||||
unsigned char pad = 0;
|
|
||||||
|
|
||||||
void init(time_t time, const DateLUTImpl & time_zone)
|
|
||||||
{
|
|
||||||
DateLUTImpl::DateTimeComponents components = time_zone.toDateTimeComponents(time);
|
|
||||||
|
|
||||||
m_year = components.date.year;
|
|
||||||
m_month = components.date.month;
|
|
||||||
m_day = components.date.day;
|
|
||||||
m_hour = components.time.hour;
|
|
||||||
m_minute = components.time.minute;
|
|
||||||
m_second = components.time.second;
|
|
||||||
|
|
||||||
(void)pad; /// Suppress unused private field warning.
|
|
||||||
}
|
|
||||||
|
|
||||||
void init(const char * s, size_t length)
|
|
||||||
{
|
|
||||||
if (length < 19)
|
|
||||||
throw std::runtime_error("Cannot parse LocalDateTime: " + std::string(s, length));
|
|
||||||
|
|
||||||
m_year = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
|
|
||||||
m_month = (s[5] - '0') * 10 + (s[6] - '0');
|
|
||||||
m_day = (s[8] - '0') * 10 + (s[9] - '0');
|
|
||||||
|
|
||||||
m_hour = (s[11] - '0') * 10 + (s[12] - '0');
|
|
||||||
m_minute = (s[14] - '0') * 10 + (s[15] - '0');
|
|
||||||
m_second = (s[17] - '0') * 10 + (s[18] - '0');
|
|
||||||
|
|
||||||
(void)pad;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit LocalDateTime(time_t time, const DateLUTImpl & time_zone = DateLUT::instance())
|
|
||||||
{
|
|
||||||
init(time, time_zone);
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalDateTime(unsigned short year_, unsigned char month_, unsigned char day_,
|
|
||||||
unsigned char hour_, unsigned char minute_, unsigned char second_)
|
|
||||||
: m_year(year_), m_month(month_), m_day(day_), m_hour(hour_), m_minute(minute_), m_second(second_)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit LocalDateTime(const std::string & s)
|
|
||||||
{
|
|
||||||
if (s.size() < 19)
|
|
||||||
throw std::runtime_error("Cannot parse LocalDateTime: " + s);
|
|
||||||
|
|
||||||
init(s.data(), s.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalDateTime() : m_year(0), m_month(0), m_day(0), m_hour(0), m_minute(0), m_second(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalDateTime(const char * data, size_t length)
|
|
||||||
{
|
|
||||||
init(data, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalDateTime(const LocalDateTime &) noexcept = default;
|
|
||||||
LocalDateTime & operator= (const LocalDateTime &) noexcept = default;
|
|
||||||
|
|
||||||
unsigned short year() const { return m_year; }
|
|
||||||
unsigned char month() const { return m_month; }
|
|
||||||
unsigned char day() const { return m_day; }
|
|
||||||
unsigned char hour() const { return m_hour; }
|
|
||||||
unsigned char minute() const { return m_minute; }
|
|
||||||
unsigned char second() const { return m_second; }
|
|
||||||
|
|
||||||
void year(unsigned short x) { m_year = x; }
|
|
||||||
void month(unsigned char x) { m_month = x; }
|
|
||||||
void day(unsigned char x) { m_day = x; }
|
|
||||||
void hour(unsigned char x) { m_hour = x; }
|
|
||||||
void minute(unsigned char x) { m_minute = x; }
|
|
||||||
void second(unsigned char x) { m_second = x; }
|
|
||||||
|
|
||||||
LocalDate toDate() const { return LocalDate(m_year, m_month, m_day); }
|
|
||||||
LocalDateTime toStartOfDate() const { return LocalDateTime(m_year, m_month, m_day, 0, 0, 0); }
|
|
||||||
|
|
||||||
std::string toString() const
|
|
||||||
{
|
|
||||||
std::string s{"0000-00-00 00:00:00"};
|
|
||||||
|
|
||||||
s[0] += m_year / 1000;
|
|
||||||
s[1] += (m_year / 100) % 10;
|
|
||||||
s[2] += (m_year / 10) % 10;
|
|
||||||
s[3] += m_year % 10;
|
|
||||||
s[5] += m_month / 10;
|
|
||||||
s[6] += m_month % 10;
|
|
||||||
s[8] += m_day / 10;
|
|
||||||
s[9] += m_day % 10;
|
|
||||||
|
|
||||||
s[11] += m_hour / 10;
|
|
||||||
s[12] += m_hour % 10;
|
|
||||||
s[14] += m_minute / 10;
|
|
||||||
s[15] += m_minute % 10;
|
|
||||||
s[17] += m_second / 10;
|
|
||||||
s[18] += m_second % 10;
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator< (const LocalDateTime & other) const
|
|
||||||
{
|
|
||||||
return 0 > memcmp(this, &other, sizeof(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator> (const LocalDateTime & other) const
|
|
||||||
{
|
|
||||||
return 0 < memcmp(this, &other, sizeof(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator<= (const LocalDateTime & other) const
|
|
||||||
{
|
|
||||||
return 0 >= memcmp(this, &other, sizeof(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator>= (const LocalDateTime & other) const
|
|
||||||
{
|
|
||||||
return 0 <= memcmp(this, &other, sizeof(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator== (const LocalDateTime & other) const
|
|
||||||
{
|
|
||||||
return 0 == memcmp(this, &other, sizeof(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!= (const LocalDateTime & other) const
|
|
||||||
{
|
|
||||||
return !(*this == other);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static_assert(sizeof(LocalDateTime) == 8);
|
|
@ -1,187 +0,0 @@
|
|||||||
#include <base/ReadlineLineReader.h>
|
|
||||||
#include <base/errnoToString.h>
|
|
||||||
#include <base/scope_guard.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
/// Trim ending whitespace inplace
|
|
||||||
void trim(String & s)
|
|
||||||
{
|
|
||||||
s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { return !std::isspace(ch); }).base(), s.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static const LineReader::Suggest * suggest;
|
|
||||||
|
|
||||||
/// Points to current word to suggest.
|
|
||||||
static LineReader::Suggest::Words::const_iterator pos;
|
|
||||||
/// Points after the last possible match.
|
|
||||||
static LineReader::Suggest::Words::const_iterator end;
|
|
||||||
|
|
||||||
/// Set iterators to the matched range of words if any.
|
|
||||||
static void findRange(const char * prefix, size_t prefix_length)
|
|
||||||
{
|
|
||||||
std::string prefix_str(prefix);
|
|
||||||
if (auto completions = suggest->getCompletions(prefix_str, prefix_length))
|
|
||||||
std::tie(pos, end) = *completions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Iterates through matched range.
|
|
||||||
static char * nextMatch()
|
|
||||||
{
|
|
||||||
if (pos >= end)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
/// readline will free memory by itself.
|
|
||||||
char * word = strdup(pos->c_str());
|
|
||||||
++pos;
|
|
||||||
return word;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char * generate(const char * text, int state)
|
|
||||||
{
|
|
||||||
if (!suggest->ready)
|
|
||||||
return nullptr;
|
|
||||||
if (state == 0)
|
|
||||||
findRange(text, strlen(text));
|
|
||||||
|
|
||||||
/// Do not append whitespace after word. For unknown reason, rl_completion_append_character = '\0' does not work.
|
|
||||||
rl_completion_suppress_append = 1;
|
|
||||||
|
|
||||||
return nextMatch();
|
|
||||||
};
|
|
||||||
|
|
||||||
ReadlineLineReader::ReadlineLineReader(
|
|
||||||
const Suggest & suggest_, const String & history_file_path_, bool multiline_, Patterns extenders_, Patterns delimiters_)
|
|
||||||
: LineReader(history_file_path_, multiline_, std::move(extenders_), std::move(delimiters_))
|
|
||||||
{
|
|
||||||
suggest = &suggest_;
|
|
||||||
|
|
||||||
if (!history_file_path.empty())
|
|
||||||
{
|
|
||||||
int res = read_history(history_file_path.c_str());
|
|
||||||
if (res)
|
|
||||||
std::cerr << "Cannot read history from file " + history_file_path + ": "+ errnoToString(errno) << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Added '.' to the default list. Because it is used to separate database and table.
|
|
||||||
rl_basic_word_break_characters = word_break_characters;
|
|
||||||
|
|
||||||
/// Not append whitespace after single suggestion. Because whitespace after function name is meaningless.
|
|
||||||
rl_completion_append_character = '\0';
|
|
||||||
|
|
||||||
rl_completion_entry_function = generate;
|
|
||||||
|
|
||||||
/// Install Ctrl+C signal handler that will be used in interactive mode.
|
|
||||||
|
|
||||||
if (rl_initialize())
|
|
||||||
throw std::runtime_error("Cannot initialize readline");
|
|
||||||
|
|
||||||
auto clear_prompt_or_exit = [](int)
|
|
||||||
{
|
|
||||||
/// This is signal safe.
|
|
||||||
ssize_t res = write(STDOUT_FILENO, "\n", 1);
|
|
||||||
|
|
||||||
/// Allow to quit client while query is in progress by pressing Ctrl+C twice.
|
|
||||||
/// (First press to Ctrl+C will try to cancel query by InterruptListener).
|
|
||||||
if (res == 1 && rl_line_buffer[0] && !RL_ISSTATE(RL_STATE_DONE))
|
|
||||||
{
|
|
||||||
rl_replace_line("", 0);
|
|
||||||
if (rl_forced_update_display())
|
|
||||||
_exit(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/// A little dirty, but we struggle to find better way to correctly
|
|
||||||
/// force readline to exit after returning from the signal handler.
|
|
||||||
_exit(0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (signal(SIGINT, clear_prompt_or_exit) == SIG_ERR)
|
|
||||||
throw std::runtime_error(std::string("Cannot set signal handler for readline: ") + errnoToString(errno));
|
|
||||||
|
|
||||||
rl_variable_bind("completion-ignore-case", "on");
|
|
||||||
// TODO: it doesn't work
|
|
||||||
// history_write_timestamps = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReadlineLineReader::~ReadlineLineReader()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
LineReader::InputStatus ReadlineLineReader::readOneLine(const String & prompt)
|
|
||||||
{
|
|
||||||
input.clear();
|
|
||||||
|
|
||||||
const char* cinput = readline(prompt.c_str());
|
|
||||||
if (cinput == nullptr)
|
|
||||||
return (errno != EAGAIN) ? ABORT : RESET_LINE;
|
|
||||||
input = cinput;
|
|
||||||
|
|
||||||
trim(input);
|
|
||||||
return INPUT_LINE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReadlineLineReader::addToHistory(const String & line)
|
|
||||||
{
|
|
||||||
add_history(line.c_str());
|
|
||||||
|
|
||||||
// Flush changes to the disk
|
|
||||||
// NOTE readline builds a buffer of all the lines to write, and write them in one syscall.
|
|
||||||
// Thus there is no need to lock the history file here.
|
|
||||||
write_history(history_file_path.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
#if RL_VERSION_MAJOR >= 7
|
|
||||||
|
|
||||||
#define BRACK_PASTE_PREF "\033[200~"
|
|
||||||
#define BRACK_PASTE_SUFF "\033[201~"
|
|
||||||
|
|
||||||
#define BRACK_PASTE_LAST '~'
|
|
||||||
#define BRACK_PASTE_SLEN 6
|
|
||||||
|
|
||||||
/// This handler bypasses some unused macro/event checkings and remove trailing newlines before insertion.
|
|
||||||
static int clickhouse_rl_bracketed_paste_begin(int /* count */, int /* key */)
|
|
||||||
{
|
|
||||||
std::string buf;
|
|
||||||
buf.reserve(128);
|
|
||||||
|
|
||||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
|
||||||
SCOPE_EXIT(RL_UNSETSTATE(RL_STATE_MOREINPUT));
|
|
||||||
int c;
|
|
||||||
while ((c = rl_read_key()) >= 0)
|
|
||||||
{
|
|
||||||
if (c == '\r')
|
|
||||||
c = '\n';
|
|
||||||
buf.push_back(c);
|
|
||||||
if (buf.size() >= BRACK_PASTE_SLEN && c == BRACK_PASTE_LAST && buf.substr(buf.size() - BRACK_PASTE_SLEN) == BRACK_PASTE_SUFF)
|
|
||||||
{
|
|
||||||
buf.resize(buf.size() - BRACK_PASTE_SLEN);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trim(buf);
|
|
||||||
return static_cast<size_t>(rl_insert_text(buf.c_str())) == buf.size() ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void ReadlineLineReader::enableBracketedPaste()
|
|
||||||
{
|
|
||||||
#if RL_VERSION_MAJOR >= 7
|
|
||||||
rl_variable_bind("enable-bracketed-paste", "on");
|
|
||||||
|
|
||||||
/// Use our bracketed paste handler to get better user experience. See comments above.
|
|
||||||
rl_bind_keyseq(BRACK_PASTE_PREF, clickhouse_rl_bracketed_paste_begin);
|
|
||||||
#endif
|
|
||||||
};
|
|
@ -1,19 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "LineReader.h"
|
|
||||||
|
|
||||||
#include <readline/readline.h>
|
|
||||||
#include <readline/history.h>
|
|
||||||
|
|
||||||
class ReadlineLineReader : public LineReader
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ReadlineLineReader(const Suggest & suggest, const String & history_file_path, bool multiline, Patterns extenders_, Patterns delimiters_);
|
|
||||||
~ReadlineLineReader() override;
|
|
||||||
|
|
||||||
void enableBracketedPaste() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
InputStatus readOneLine(const String & prompt) override;
|
|
||||||
void addToHistory(const String & line) override;
|
|
||||||
};
|
|
@ -1,349 +0,0 @@
|
|||||||
#include <base/ReplxxLineReader.h>
|
|
||||||
#include <base/errnoToString.h>
|
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <cerrno>
|
|
||||||
#include <cstring>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <functional>
|
|
||||||
#include <sys/file.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <csignal>
|
|
||||||
#include <dlfcn.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <fstream>
|
|
||||||
#include <fmt/format.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
/// Trim ending whitespace inplace
|
|
||||||
void trim(String & s)
|
|
||||||
{
|
|
||||||
s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { return !std::isspace(ch); }).base(), s.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Copied from replxx::src/util.cxx::now_ms_str() under the terms of 3-clause BSD license of Replxx.
|
|
||||||
/// Copyright (c) 2017-2018, Marcin Konarski (amok at codestation.org)
|
|
||||||
/// Copyright (c) 2010, Salvatore Sanfilippo (antirez at gmail dot com)
|
|
||||||
/// Copyright (c) 2010, Pieter Noordhuis (pcnoordhuis at gmail dot com)
|
|
||||||
std::string replxx_now_ms_str()
|
|
||||||
{
|
|
||||||
std::chrono::milliseconds ms(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()));
|
|
||||||
time_t t = ms.count() / 1000;
|
|
||||||
tm broken;
|
|
||||||
if (!localtime_r(&t, &broken))
|
|
||||||
{
|
|
||||||
return std::string();
|
|
||||||
}
|
|
||||||
|
|
||||||
static int const BUFF_SIZE(32);
|
|
||||||
char str[BUFF_SIZE];
|
|
||||||
strftime(str, BUFF_SIZE, "%Y-%m-%d %H:%M:%S.", &broken);
|
|
||||||
snprintf(str + sizeof("YYYY-mm-dd HH:MM:SS"), 5, "%03d", static_cast<int>(ms.count() % 1000));
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Convert from readline to replxx format.
|
|
||||||
///
|
|
||||||
/// replxx requires each history line to prepended with time line:
|
|
||||||
///
|
|
||||||
/// ### YYYY-MM-DD HH:MM:SS.SSS
|
|
||||||
/// select 1
|
|
||||||
///
|
|
||||||
/// And w/o those service lines it will load all lines from history file as
|
|
||||||
/// one history line for suggestion. And if there are lots of lines in file it
|
|
||||||
/// will take lots of time (getline() + tons of reallocations).
|
|
||||||
///
|
|
||||||
/// NOTE: this code uses std::ifstream/std::ofstream like original replxx code.
|
|
||||||
void convertHistoryFile(const std::string & path, replxx::Replxx & rx)
|
|
||||||
{
|
|
||||||
std::ifstream in(path);
|
|
||||||
if (!in)
|
|
||||||
{
|
|
||||||
rx.print("Cannot open %s reading (for conversion): %s\n",
|
|
||||||
path.c_str(), errnoToString(errno).c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string line;
|
|
||||||
if (getline(in, line).bad())
|
|
||||||
{
|
|
||||||
rx.print("Cannot read from %s (for conversion): %s\n",
|
|
||||||
path.c_str(), errnoToString(errno).c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This is the marker of the date, no need to convert.
|
|
||||||
static char const REPLXX_TIMESTAMP_PATTERN[] = "### dddd-dd-dd dd:dd:dd.ddd";
|
|
||||||
if (line.empty() || (line.starts_with("### ") && line.size() == strlen(REPLXX_TIMESTAMP_PATTERN)))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> lines;
|
|
||||||
in.seekg(0);
|
|
||||||
while (getline(in, line).good())
|
|
||||||
{
|
|
||||||
lines.push_back(line);
|
|
||||||
}
|
|
||||||
in.close();
|
|
||||||
|
|
||||||
size_t lines_size = lines.size();
|
|
||||||
std::sort(lines.begin(), lines.end());
|
|
||||||
lines.erase(std::unique(lines.begin(), lines.end()), lines.end());
|
|
||||||
rx.print("The history file (%s) is in old format. %zu lines, %zu unique lines.\n",
|
|
||||||
path.c_str(), lines_size, lines.size());
|
|
||||||
|
|
||||||
std::ofstream out(path);
|
|
||||||
if (!out)
|
|
||||||
{
|
|
||||||
rx.print("Cannot open %s for writing (for conversion): %s\n",
|
|
||||||
path.c_str(), errnoToString(errno).c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string & timestamp = replxx_now_ms_str();
|
|
||||||
for (const auto & out_line : lines)
|
|
||||||
{
|
|
||||||
out << "### " << timestamp << "\n" << out_line << std::endl;
|
|
||||||
}
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ReplxxLineReader::ReplxxLineReader(
|
|
||||||
const Suggest & suggest,
|
|
||||||
const String & history_file_path_,
|
|
||||||
bool multiline_,
|
|
||||||
Patterns extenders_,
|
|
||||||
Patterns delimiters_,
|
|
||||||
replxx::Replxx::highlighter_callback_t highlighter_)
|
|
||||||
: LineReader(history_file_path_, multiline_, std::move(extenders_), std::move(delimiters_)), highlighter(std::move(highlighter_))
|
|
||||||
{
|
|
||||||
using namespace std::placeholders;
|
|
||||||
using Replxx = replxx::Replxx;
|
|
||||||
|
|
||||||
if (!history_file_path.empty())
|
|
||||||
{
|
|
||||||
history_file_fd = open(history_file_path.c_str(), O_RDWR);
|
|
||||||
if (history_file_fd < 0)
|
|
||||||
{
|
|
||||||
rx.print("Open of history file failed: %s\n", errnoToString(errno).c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
convertHistoryFile(history_file_path, rx);
|
|
||||||
|
|
||||||
if (flock(history_file_fd, LOCK_SH))
|
|
||||||
{
|
|
||||||
rx.print("Shared lock of history file failed: %s\n", errnoToString(errno).c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!rx.history_load(history_file_path))
|
|
||||||
{
|
|
||||||
rx.print("Loading history failed: %s\n", errnoToString(errno).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flock(history_file_fd, LOCK_UN))
|
|
||||||
{
|
|
||||||
rx.print("Unlock of history file failed: %s\n", errnoToString(errno).c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rx.install_window_change_handler();
|
|
||||||
|
|
||||||
auto callback = [&suggest] (const String & context, size_t context_size)
|
|
||||||
{
|
|
||||||
if (auto range = suggest.getCompletions(context, context_size))
|
|
||||||
return Replxx::completions_t(range->first, range->second);
|
|
||||||
return Replxx::completions_t();
|
|
||||||
};
|
|
||||||
|
|
||||||
rx.set_completion_callback(callback);
|
|
||||||
rx.set_complete_on_empty(false);
|
|
||||||
rx.set_word_break_characters(word_break_characters);
|
|
||||||
|
|
||||||
if (highlighter)
|
|
||||||
rx.set_highlighter_callback(highlighter);
|
|
||||||
|
|
||||||
/// By default C-p/C-n binded to COMPLETE_NEXT/COMPLETE_PREV,
|
|
||||||
/// bind C-p/C-n to history-previous/history-next like readline.
|
|
||||||
rx.bind_key(Replxx::KEY::control('N'), [this](char32_t code) { return rx.invoke(Replxx::ACTION::HISTORY_NEXT, code); });
|
|
||||||
rx.bind_key(Replxx::KEY::control('P'), [this](char32_t code) { return rx.invoke(Replxx::ACTION::HISTORY_PREVIOUS, code); });
|
|
||||||
|
|
||||||
/// bind C-j to ENTER action.
|
|
||||||
rx.bind_key(Replxx::KEY::control('J'), [this](char32_t code) { return rx.invoke(Replxx::ACTION::COMMIT_LINE, code); });
|
|
||||||
|
|
||||||
/// By default COMPLETE_NEXT/COMPLETE_PREV was binded to C-p/C-n, re-bind
|
|
||||||
/// to M-P/M-N (that was used for HISTORY_COMMON_PREFIX_SEARCH before, but
|
|
||||||
/// it also binded to M-p/M-n).
|
|
||||||
rx.bind_key(Replxx::KEY::meta('N'), [this](char32_t code) { return rx.invoke(Replxx::ACTION::COMPLETE_NEXT, code); });
|
|
||||||
rx.bind_key(Replxx::KEY::meta('P'), [this](char32_t code) { return rx.invoke(Replxx::ACTION::COMPLETE_PREVIOUS, code); });
|
|
||||||
/// By default M-BACKSPACE is KILL_TO_WHITESPACE_ON_LEFT, while in readline it is backward-kill-word
|
|
||||||
rx.bind_key(Replxx::KEY::meta(Replxx::KEY::BACKSPACE), [this](char32_t code) { return rx.invoke(Replxx::ACTION::KILL_TO_BEGINING_OF_WORD, code); });
|
|
||||||
/// By default C-w is KILL_TO_BEGINING_OF_WORD, while in readline it is unix-word-rubout
|
|
||||||
rx.bind_key(Replxx::KEY::control('W'), [this](char32_t code) { return rx.invoke(Replxx::ACTION::KILL_TO_WHITESPACE_ON_LEFT, code); });
|
|
||||||
|
|
||||||
rx.bind_key(Replxx::KEY::meta('E'), [this](char32_t) { openEditor(); return Replxx::ACTION_RESULT::CONTINUE; });
|
|
||||||
}
|
|
||||||
|
|
||||||
ReplxxLineReader::~ReplxxLineReader()
|
|
||||||
{
|
|
||||||
if (close(history_file_fd))
|
|
||||||
rx.print("Close of history file failed: %s\n", errnoToString(errno).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
LineReader::InputStatus ReplxxLineReader::readOneLine(const String & prompt)
|
|
||||||
{
|
|
||||||
input.clear();
|
|
||||||
|
|
||||||
const char* cinput = rx.input(prompt);
|
|
||||||
if (cinput == nullptr)
|
|
||||||
return (errno != EAGAIN) ? ABORT : RESET_LINE;
|
|
||||||
input = cinput;
|
|
||||||
|
|
||||||
trim(input);
|
|
||||||
return INPUT_LINE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReplxxLineReader::addToHistory(const String & line)
|
|
||||||
{
|
|
||||||
// locking history file to prevent from inconsistent concurrent changes
|
|
||||||
//
|
|
||||||
// replxx::Replxx::history_save() already has lockf(),
|
|
||||||
// but replxx::Replxx::history_load() does not
|
|
||||||
// and that is why flock() is added here.
|
|
||||||
bool locked = false;
|
|
||||||
if (flock(history_file_fd, LOCK_EX))
|
|
||||||
rx.print("Lock of history file failed: %s\n", errnoToString(errno).c_str());
|
|
||||||
else
|
|
||||||
locked = true;
|
|
||||||
|
|
||||||
rx.history_add(line);
|
|
||||||
|
|
||||||
// flush changes to the disk
|
|
||||||
if (!rx.history_save(history_file_path))
|
|
||||||
rx.print("Saving history failed: %s\n", errnoToString(errno).c_str());
|
|
||||||
|
|
||||||
if (locked && 0 != flock(history_file_fd, LOCK_UN))
|
|
||||||
rx.print("Unlock of history file failed: %s\n", errnoToString(errno).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
int ReplxxLineReader::execute(const std::string & command)
|
|
||||||
{
|
|
||||||
std::vector<char> argv0("sh", &("sh"[3]));
|
|
||||||
std::vector<char> argv1("-c", &("-c"[3]));
|
|
||||||
std::vector<char> argv2(command.data(), command.data() + command.size() + 1);
|
|
||||||
|
|
||||||
const char * filename = "/bin/sh";
|
|
||||||
char * const argv[] = {argv0.data(), argv1.data(), argv2.data(), nullptr};
|
|
||||||
|
|
||||||
static void * real_vfork = dlsym(RTLD_DEFAULT, "vfork");
|
|
||||||
if (!real_vfork)
|
|
||||||
{
|
|
||||||
rx.print("Cannot find symbol vfork in myself: %s\n", errnoToString(errno).c_str());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pid_t pid = reinterpret_cast<pid_t (*)()>(real_vfork)();
|
|
||||||
|
|
||||||
if (-1 == pid)
|
|
||||||
{
|
|
||||||
rx.print("Cannot vfork: %s\n", errnoToString(errno).c_str());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 == pid)
|
|
||||||
{
|
|
||||||
sigset_t mask;
|
|
||||||
sigemptyset(&mask);
|
|
||||||
sigprocmask(0, nullptr, &mask);
|
|
||||||
sigprocmask(SIG_UNBLOCK, &mask, nullptr);
|
|
||||||
|
|
||||||
execv(filename, argv);
|
|
||||||
_exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int status = 0;
|
|
||||||
if (-1 == waitpid(pid, &status, 0))
|
|
||||||
{
|
|
||||||
rx.print("Cannot waitpid: %s\n", errnoToString(errno).c_str());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReplxxLineReader::openEditor()
|
|
||||||
{
|
|
||||||
char filename[] = "clickhouse_replxx_XXXXXX.sql";
|
|
||||||
int fd = ::mkstemps(filename, 4);
|
|
||||||
if (-1 == fd)
|
|
||||||
{
|
|
||||||
rx.print("Cannot create temporary file to edit query: %s\n", errnoToString(errno).c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * editor = std::getenv("EDITOR");
|
|
||||||
if (!editor || !*editor)
|
|
||||||
editor = "vim";
|
|
||||||
|
|
||||||
replxx::Replxx::State state(rx.get_state());
|
|
||||||
|
|
||||||
size_t bytes_written = 0;
|
|
||||||
const char * begin = state.text();
|
|
||||||
size_t offset = strlen(state.text());
|
|
||||||
while (bytes_written != offset)
|
|
||||||
{
|
|
||||||
ssize_t res = ::write(fd, begin + bytes_written, offset - bytes_written);
|
|
||||||
if ((-1 == res || 0 == res) && errno != EINTR)
|
|
||||||
{
|
|
||||||
rx.print("Cannot write to temporary query file %s: %s\n", filename, errnoToString(errno).c_str());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
bytes_written += res;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 != ::close(fd))
|
|
||||||
{
|
|
||||||
rx.print("Cannot close temporary query file %s: %s\n", filename, errnoToString(errno).c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 == execute(fmt::format("{} {}", editor, filename)))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
std::ifstream t(filename);
|
|
||||||
std::string str;
|
|
||||||
t.seekg(0, std::ios::end);
|
|
||||||
str.reserve(t.tellg());
|
|
||||||
t.seekg(0, std::ios::beg);
|
|
||||||
str.assign((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
|
|
||||||
rx.set_state(replxx::Replxx::State(str.c_str(), str.size()));
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
rx.print("Cannot read from temporary query file %s: %s\n", filename, errnoToString(errno).c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bracketed_paste_enabled)
|
|
||||||
enableBracketedPaste();
|
|
||||||
|
|
||||||
if (0 != ::unlink(filename))
|
|
||||||
rx.print("Cannot remove temporary query file %s: %s\n", filename, errnoToString(errno).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReplxxLineReader::enableBracketedPaste()
|
|
||||||
{
|
|
||||||
bracketed_paste_enabled = true;
|
|
||||||
rx.enable_bracketed_paste();
|
|
||||||
};
|
|
@ -1,34 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "LineReader.h"
|
|
||||||
|
|
||||||
#include <replxx.hxx>
|
|
||||||
|
|
||||||
|
|
||||||
class ReplxxLineReader : public LineReader
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ReplxxLineReader(
|
|
||||||
const Suggest & suggest,
|
|
||||||
const String & history_file_path,
|
|
||||||
bool multiline,
|
|
||||||
Patterns extenders_,
|
|
||||||
Patterns delimiters_,
|
|
||||||
replxx::Replxx::highlighter_callback_t highlighter_);
|
|
||||||
~ReplxxLineReader() override;
|
|
||||||
|
|
||||||
void enableBracketedPaste() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
InputStatus readOneLine(const String & prompt) override;
|
|
||||||
void addToHistory(const String & line) override;
|
|
||||||
int execute(const std::string & command);
|
|
||||||
void openEditor();
|
|
||||||
|
|
||||||
replxx::Replxx rx;
|
|
||||||
replxx::Replxx::highlighter_callback_t highlighter;
|
|
||||||
|
|
||||||
// used to call flock() to synchronize multiple clients using same history file
|
|
||||||
int history_file_fd = -1;
|
|
||||||
bool bracketed_paste_enabled = false;
|
|
||||||
};
|
|
@ -19,6 +19,12 @@
|
|||||||
#if defined(__SSE4_2__)
|
#if defined(__SSE4_2__)
|
||||||
#include <smmintrin.h>
|
#include <smmintrin.h>
|
||||||
#include <nmmintrin.h>
|
#include <nmmintrin.h>
|
||||||
|
#define CRC_INT _mm_crc32_u64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
|
||||||
|
#include <arm_acle.h>
|
||||||
|
#define CRC_INT __crc32cd
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -31,7 +37,8 @@ struct StringRef
|
|||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
|
||||||
/// Non-constexpr due to reinterpret_cast.
|
/// Non-constexpr due to reinterpret_cast.
|
||||||
template <typename CharT, typename = std::enable_if_t<sizeof(CharT) == 1>>
|
template <typename CharT>
|
||||||
|
requires (sizeof(CharT) == 1)
|
||||||
StringRef(const CharT * data_, size_t size_) : data(reinterpret_cast<const char *>(data_)), size(size_)
|
StringRef(const CharT * data_, size_t size_) : data(reinterpret_cast<const char *>(data_)), size(size_)
|
||||||
{
|
{
|
||||||
/// Sanity check for overflowed values.
|
/// Sanity check for overflowed values.
|
||||||
@ -40,22 +47,20 @@ struct StringRef
|
|||||||
|
|
||||||
constexpr StringRef(const char * data_, size_t size_) : data(data_), size(size_) {}
|
constexpr StringRef(const char * data_, size_t size_) : data(data_), size(size_) {}
|
||||||
|
|
||||||
StringRef(const std::string & s) : data(s.data()), size(s.size()) {}
|
StringRef(const std::string & s) : data(s.data()), size(s.size()) {} /// NOLINT
|
||||||
constexpr explicit StringRef(std::string_view s) : data(s.data()), size(s.size()) {}
|
constexpr explicit StringRef(std::string_view s) : data(s.data()), size(s.size()) {}
|
||||||
constexpr StringRef(const char * data_) : StringRef(std::string_view{data_}) {}
|
constexpr StringRef(const char * data_) : StringRef(std::string_view{data_}) {} /// NOLINT
|
||||||
constexpr StringRef() = default;
|
constexpr StringRef() = default;
|
||||||
|
|
||||||
std::string toString() const { return std::string(data, size); }
|
bool empty() const { return size == 0; }
|
||||||
|
|
||||||
|
std::string toString() const { return std::string(data, size); }
|
||||||
explicit operator std::string() const { return toString(); }
|
explicit operator std::string() const { return toString(); }
|
||||||
constexpr explicit operator std::string_view() const { return {data, size}; }
|
|
||||||
|
std::string_view toView() const { return std::string_view(data, size); }
|
||||||
|
constexpr explicit operator std::string_view() const { return std::string_view(data, size); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Here constexpr doesn't implicate inline, see https://www.viva64.com/en/w/v1043/
|
|
||||||
/// nullptr can't be used because the StringRef values are used in SipHash's pointer arithmetic
|
|
||||||
/// and the UBSan thinks that something like nullptr + 8 is UB.
|
|
||||||
constexpr const inline char empty_string_ref_addr{};
|
|
||||||
constexpr const inline StringRef EMPTY_STRING_REF{&empty_string_ref_addr, 0};
|
|
||||||
|
|
||||||
using StringRefs = std::vector<StringRef>;
|
using StringRefs = std::vector<StringRef>;
|
||||||
|
|
||||||
@ -203,7 +208,7 @@ struct StringRefHash64
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(__SSE4_2__)
|
#if defined(CRC_INT)
|
||||||
|
|
||||||
/// Parts are taken from CityHash.
|
/// Parts are taken from CityHash.
|
||||||
|
|
||||||
@ -217,7 +222,7 @@ inline UInt64 shiftMix(UInt64 val)
|
|||||||
return val ^ (val >> 47);
|
return val ^ (val >> 47);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline UInt64 rotateByAtLeast1(UInt64 val, int shift)
|
inline UInt64 rotateByAtLeast1(UInt64 val, UInt8 shift)
|
||||||
{
|
{
|
||||||
return (val >> shift) | (val << (64 - shift));
|
return (val >> shift) | (val << (64 - shift));
|
||||||
}
|
}
|
||||||
@ -239,7 +244,7 @@ inline size_t hashLessThan8(const char * data, size_t size)
|
|||||||
uint8_t b = data[size >> 1];
|
uint8_t b = data[size >> 1];
|
||||||
uint8_t c = data[size - 1];
|
uint8_t c = data[size - 1];
|
||||||
uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
|
uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
|
||||||
uint32_t z = size + (static_cast<uint32_t>(c) << 2);
|
uint32_t z = static_cast<uint32_t>(size) + (static_cast<uint32_t>(c) << 2);
|
||||||
return shiftMix(y * k2 ^ z * k3) * k2;
|
return shiftMix(y * k2 ^ z * k3) * k2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +257,7 @@ inline size_t hashLessThan16(const char * data, size_t size)
|
|||||||
{
|
{
|
||||||
UInt64 a = unalignedLoad<UInt64>(data);
|
UInt64 a = unalignedLoad<UInt64>(data);
|
||||||
UInt64 b = unalignedLoad<UInt64>(data + size - 8);
|
UInt64 b = unalignedLoad<UInt64>(data + size - 8);
|
||||||
return hashLen16(a, rotateByAtLeast1(b + size, size)) ^ b;
|
return hashLen16(a, rotateByAtLeast1(b + size, static_cast<UInt8>(size))) ^ b;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hashLessThan8(data, size);
|
return hashLessThan8(data, size);
|
||||||
@ -260,7 +265,7 @@ inline size_t hashLessThan16(const char * data, size_t size)
|
|||||||
|
|
||||||
struct CRC32Hash
|
struct CRC32Hash
|
||||||
{
|
{
|
||||||
size_t operator() (StringRef x) const
|
unsigned operator() (StringRef x) const
|
||||||
{
|
{
|
||||||
const char * pos = x.data;
|
const char * pos = x.data;
|
||||||
size_t size = x.size;
|
size_t size = x.size;
|
||||||
@ -270,22 +275,22 @@ struct CRC32Hash
|
|||||||
|
|
||||||
if (size < 8)
|
if (size < 8)
|
||||||
{
|
{
|
||||||
return hashLessThan8(x.data, x.size);
|
return static_cast<unsigned>(hashLessThan8(x.data, x.size));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * end = pos + size;
|
const char * end = pos + size;
|
||||||
size_t res = -1ULL;
|
unsigned res = -1U;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
UInt64 word = unalignedLoad<UInt64>(pos);
|
UInt64 word = unalignedLoad<UInt64>(pos);
|
||||||
res = _mm_crc32_u64(res, word);
|
res = static_cast<unsigned>(CRC_INT(res, word));
|
||||||
|
|
||||||
pos += 8;
|
pos += 8;
|
||||||
} while (pos + 8 < end);
|
} while (pos + 8 < end);
|
||||||
|
|
||||||
UInt64 word = unalignedLoad<UInt64>(end - 8); /// I'm not sure if this is normal.
|
UInt64 word = unalignedLoad<UInt64>(end - 8); /// I'm not sure if this is normal.
|
||||||
res = _mm_crc32_u64(res, word);
|
res = static_cast<unsigned>(CRC_INT(res, word));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -297,7 +302,7 @@ struct StringRefHash : CRC32Hash {};
|
|||||||
|
|
||||||
struct CRC32Hash
|
struct CRC32Hash
|
||||||
{
|
{
|
||||||
size_t operator() (StringRef /* x */) const
|
unsigned operator() (StringRef /* x */) const
|
||||||
{
|
{
|
||||||
throw std::logic_error{"Not implemented CRC32Hash without SSE"};
|
throw std::logic_error{"Not implemented CRC32Hash without SSE"};
|
||||||
}
|
}
|
||||||
|
44
base/base/TypeList.h
Normal file
44
base/base/TypeList.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <utility>
|
||||||
|
#include "defines.h"
|
||||||
|
#include "TypePair.h"
|
||||||
|
|
||||||
|
/// General-purpose typelist. Easy on compilation times as it does not use recursion.
|
||||||
|
template <typename ...Args>
|
||||||
|
struct TypeList { static constexpr size_t size = sizeof...(Args); };
|
||||||
|
|
||||||
|
namespace TypeListUtils /// In some contexts it's more handy to use functions instead of aliases
|
||||||
|
{
|
||||||
|
template <typename ...LArgs, typename ...RArgs>
|
||||||
|
constexpr TypeList<LArgs..., RArgs...> concat(TypeList<LArgs...>, TypeList<RArgs...>) { return {}; }
|
||||||
|
|
||||||
|
template <typename T, typename ...Args>
|
||||||
|
constexpr TypeList<T, Args...> prepend(TypeList<Args...>) { return {}; }
|
||||||
|
|
||||||
|
template <typename T, typename ...Args>
|
||||||
|
constexpr TypeList<Args..., T> append(TypeList<Args...>) { return {}; }
|
||||||
|
|
||||||
|
template <template <typename> typename F, typename ...Args>
|
||||||
|
constexpr TypeList<F<Args>...> map(TypeList<Args...>) { return {}; }
|
||||||
|
|
||||||
|
template <template <typename...> typename Root, typename ...Args>
|
||||||
|
constexpr Root<Args...> changeRoot(TypeList<Args...>) { return {}; }
|
||||||
|
|
||||||
|
template <typename F, typename ...Args>
|
||||||
|
constexpr void forEach(TypeList<Args...>, F && f) { (std::forward<F>(f)(Id<Args>{}), ...); }
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename TypeListLeft, typename TypeListRight>
|
||||||
|
using TypeListConcat = decltype(TypeListUtils::concat(TypeListLeft{}, TypeListRight{}));
|
||||||
|
|
||||||
|
template <typename T, typename List> using TypeListPrepend = decltype(TypeListUtils::prepend<T>(List{}));
|
||||||
|
template <typename T, typename List> using TypeListAppend = decltype(TypeListUtils::append<T>(List{}));
|
||||||
|
|
||||||
|
template <template <typename> typename F, typename List>
|
||||||
|
using TypeListMap = decltype(TypeListUtils::map<F>(List{}));
|
||||||
|
|
||||||
|
template <template <typename...> typename Root, typename List>
|
||||||
|
using TypeListChangeRoot = decltype(TypeListUtils::changeRoot<Root>(List{}));
|
21
base/base/TypeLists.h
Normal file
21
base/base/TypeLists.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "TypeList.h"
|
||||||
|
#include "extended_types.h"
|
||||||
|
#include "Decimal.h"
|
||||||
|
#include "UUID.h"
|
||||||
|
|
||||||
|
namespace DB
|
||||||
|
{
|
||||||
|
|
||||||
|
using TypeListNativeInt = TypeList<UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64>;
|
||||||
|
using TypeListFloat = TypeList<Float32, Float64>;
|
||||||
|
using TypeListNativeNumber = TypeListConcat<TypeListNativeInt, TypeListFloat>;
|
||||||
|
using TypeListWideInt = TypeList<UInt128, Int128, UInt256, Int256>;
|
||||||
|
using TypeListInt = TypeListConcat<TypeListNativeInt, TypeListWideInt>;
|
||||||
|
using TypeListIntAndFloat = TypeListConcat<TypeListInt, TypeListFloat>;
|
||||||
|
using TypeListDecimal = TypeList<Decimal32, Decimal64, Decimal128, Decimal256>;
|
||||||
|
using TypeListNumber = TypeListConcat<TypeListIntAndFloat, TypeListDecimal>;
|
||||||
|
using TypeListNumberWithUUID = TypeListAppend<UUID, TypeListNumber>;
|
||||||
|
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "Decimal.h"
|
#include "Decimal.h"
|
||||||
#include "UUID.h"
|
#include "UUID.h"
|
||||||
|
#include "IPv4andIPv6.h"
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
@ -35,6 +36,8 @@ TN_MAP(Float32)
|
|||||||
TN_MAP(Float64)
|
TN_MAP(Float64)
|
||||||
TN_MAP(String)
|
TN_MAP(String)
|
||||||
TN_MAP(UUID)
|
TN_MAP(UUID)
|
||||||
|
TN_MAP(IPv4)
|
||||||
|
TN_MAP(IPv6)
|
||||||
TN_MAP(Decimal32)
|
TN_MAP(Decimal32)
|
||||||
TN_MAP(Decimal64)
|
TN_MAP(Decimal64)
|
||||||
TN_MAP(Decimal128)
|
TN_MAP(Decimal128)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
template <class T, class V> struct TypePair { };
|
template <typename T, typename V> struct TypePair {};
|
||||||
template <class T> struct Id { };
|
template <typename T> struct Id {};
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <type_traits>
|
|
||||||
#include <utility>
|
|
||||||
#include "defines.h"
|
|
||||||
#include "TypePair.h"
|
|
||||||
|
|
||||||
/// General-purpose typelist. Easy on compilation times as it does not use recursion.
|
|
||||||
template <class ...Args>
|
|
||||||
struct Typelist { static constexpr size_t size = sizeof...(Args); };
|
|
||||||
|
|
||||||
namespace TLUtils /// In some contexts it's more handy to use functions instead of aliases
|
|
||||||
{
|
|
||||||
template <class ...LArgs, class ...RArgs>
|
|
||||||
constexpr Typelist<LArgs..., RArgs...> concat(Typelist<LArgs...>, Typelist<RArgs...>) { return {}; }
|
|
||||||
|
|
||||||
template <class T, class ...Args>
|
|
||||||
constexpr Typelist<T, Args...> prepend(Typelist<Args...>) { return {}; }
|
|
||||||
|
|
||||||
template <class T, class ...Args>
|
|
||||||
constexpr Typelist<Args..., T> append(Typelist<Args...>) { return {}; }
|
|
||||||
|
|
||||||
template <template<class> class F, class ...Args>
|
|
||||||
constexpr Typelist<F<Args>...> map(Typelist<Args...>) { return {}; }
|
|
||||||
|
|
||||||
template <template<class...> class Root, class ...Args>
|
|
||||||
constexpr Root<Args...> changeRoot(Typelist<Args...>) { return {}; }
|
|
||||||
|
|
||||||
template <class F, class ...Args>
|
|
||||||
constexpr void forEach(Typelist<Args...>, F && f) { (std::forward<F>(f)(Id<Args>{}), ...); }
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class TLLeft, class TLRight>
|
|
||||||
using TLConcat = decltype(TLUtils::concat(TLLeft{}, TLRight{}));
|
|
||||||
|
|
||||||
template <class T, class Typelist> using TLPrepend = decltype(TLUtils::prepend<T>(Typelist{}));
|
|
||||||
template <class T, class Typelist> using TLAppend = decltype(TLUtils::append<T>(Typelist{}));
|
|
||||||
|
|
||||||
template <template<class> class F, class Typelist>
|
|
||||||
using TLMap = decltype(TLUtils::map<F>(Typelist{}));
|
|
||||||
|
|
||||||
template <template<class...> class Root, class Typelist>
|
|
||||||
using TLChangeRoot = decltype(TLUtils::changeRoot<Root>(Typelist{}));
|
|
@ -1,18 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Typelist.h"
|
|
||||||
#include "extended_types.h"
|
|
||||||
#include "Decimal.h"
|
|
||||||
#include "UUID.h"
|
|
||||||
|
|
||||||
namespace DB
|
|
||||||
{
|
|
||||||
using TLIntegral = Typelist<UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64, Float32, Float64>;
|
|
||||||
using TLExtendedIntegral = Typelist<UInt128, Int128, UInt256, Int256>;
|
|
||||||
using TLDecimals = Typelist<Decimal32, Decimal64, Decimal128, Decimal256>;
|
|
||||||
|
|
||||||
using TLIntegralWithExtended = TLConcat<TLIntegral, TLExtendedIntegral>;
|
|
||||||
|
|
||||||
using TLNumbers = TLConcat<TLIntegralWithExtended, TLDecimals>;
|
|
||||||
using TLNumbersWithUUID = TLAppend<UUID, TLNumbers>;
|
|
||||||
}
|
|
@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "strong_typedef.h"
|
#include <base/strong_typedef.h>
|
||||||
#include "extended_types.h"
|
#include <base/extended_types.h>
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
using UUID = StrongTypedef<UInt128, struct UUIDTag>;
|
using UUID = StrongTypedef<UInt128, struct UUIDTag>;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace Poco::Util
|
namespace Poco::Util
|
||||||
{
|
{
|
||||||
class LayeredConfiguration;
|
class LayeredConfiguration; // NOLINT(cppcoreguidelines-virtual-class-destructor)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Import extra command line arguments to configuration. These are command line arguments after --.
|
/// Import extra command line arguments to configuration. These are command line arguments after --.
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <base/extended_types.h>
|
#include <base/extended_types.h>
|
||||||
#include <base/defines.h>
|
#include <base/defines.h>
|
||||||
|
|
||||||
|
// NOLINTBEGIN(google-runtime-int)
|
||||||
|
|
||||||
namespace common
|
namespace common
|
||||||
{
|
{
|
||||||
@ -206,3 +207,5 @@ namespace common
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOLINTEND(google-runtime-int)
|
||||||
|
@ -1,27 +1,32 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
|
||||||
/** \brief Returns value `from` converted to type `To` while retaining bit representation.
|
/** Returns value `from` converted to type `To` while retaining bit representation.
|
||||||
* `To` and `From` must satisfy `CopyConstructible`.
|
* `To` and `From` must satisfy `CopyConstructible`.
|
||||||
|
* In contrast to std::bit_cast can cast types of different width.
|
||||||
*/
|
*/
|
||||||
template <typename To, typename From>
|
template <typename To, typename From>
|
||||||
std::decay_t<To> bit_cast(const From & from)
|
std::decay_t<To> bit_cast(const From & from)
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Assume the source value is 0xAABBCCDD (i.e. sizeof(from) == 4).
|
||||||
|
* Its BE representation is 0xAABBCCDD, the LE representation is 0xDDCCBBAA.
|
||||||
|
* Further assume, sizeof(res) == 8 and that res is initially zeroed out.
|
||||||
|
* With LE, the result after bit_cast will be 0xDDCCBBAA00000000 --> input value == output value.
|
||||||
|
* With BE, the result after bit_cast will be 0x00000000AABBCCDD --> input value == output value.
|
||||||
|
*/
|
||||||
To res {};
|
To res {};
|
||||||
memcpy(static_cast<void*>(&res), &from, std::min(sizeof(res), sizeof(from)));
|
if constexpr (std::endian::native == std::endian::little)
|
||||||
|
memcpy(static_cast<void*>(&res), &from, std::min(sizeof(res), sizeof(from)));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint32_t offset_to = (sizeof(res) > sizeof(from)) ? (sizeof(res) - sizeof(from)) : 0;
|
||||||
|
uint32_t offset_from = (sizeof(from) > sizeof(res)) ? (sizeof(from) - sizeof(res)) : 0;
|
||||||
|
memcpy(reinterpret_cast<char *>(&res) + offset_to, reinterpret_cast<const char *>(&from) + offset_from, std::min(sizeof(res), sizeof(from)));
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Returns value `from` converted to type `To` while retaining bit representation.
|
|
||||||
* `To` and `From` must satisfy `CopyConstructible`.
|
|
||||||
*/
|
|
||||||
template <typename To, typename From>
|
|
||||||
std::decay_t<To> safe_bit_cast(const From & from)
|
|
||||||
{
|
|
||||||
static_assert(sizeof(To) == sizeof(From), "bit cast on types of different width");
|
|
||||||
return bit_cast<To, From>(from);
|
|
||||||
}
|
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
#define NO_INLINE __attribute__((__noinline__))
|
#define NO_INLINE __attribute__((__noinline__))
|
||||||
#define MAY_ALIAS __attribute__((__may_alias__))
|
#define MAY_ALIAS __attribute__((__may_alias__))
|
||||||
|
|
||||||
#if !defined(__x86_64__) && !defined(__aarch64__) && !defined(__PPC__)
|
#if !defined(__x86_64__) && !defined(__aarch64__) && !defined(__PPC__) && !(defined(__riscv) && (__riscv_xlen == 64))
|
||||||
# error "The only supported platforms are x86_64 and AArch64, PowerPC (work in progress)"
|
# error "The only supported platforms are x86_64 and AArch64, PowerPC (work in progress) and RISC-V 64 (experimental)"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Check for presence of address sanitizer
|
/// Check for presence of address sanitizer
|
||||||
@ -100,11 +100,94 @@
|
|||||||
# define ALWAYS_INLINE_NO_SANITIZE_UNDEFINED ALWAYS_INLINE
|
# define ALWAYS_INLINE_NO_SANITIZE_UNDEFINED ALWAYS_INLINE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__clang__) && defined(__clang_major__) && __clang_major__ >= 14
|
||||||
|
# define DISABLE_SANITIZER_INSTRUMENTATION __attribute__((disable_sanitizer_instrumentation))
|
||||||
|
#else
|
||||||
|
# define DISABLE_SANITIZER_INSTRUMENTATION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if !__has_include(<sanitizer/asan_interface.h>) || !defined(ADDRESS_SANITIZER)
|
#if !__has_include(<sanitizer/asan_interface.h>) || !defined(ADDRESS_SANITIZER)
|
||||||
# define ASAN_UNPOISON_MEMORY_REGION(a, b)
|
# define ASAN_UNPOISON_MEMORY_REGION(a, b)
|
||||||
# define ASAN_POISON_MEMORY_REGION(a, b)
|
# define ASAN_POISON_MEMORY_REGION(a, b)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(ABORT_ON_LOGICAL_ERROR)
|
||||||
|
#if !defined(NDEBUG) || defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) || defined(MEMORY_SANITIZER) || defined(UNDEFINED_BEHAVIOR_SANITIZER)
|
||||||
|
#define ABORT_ON_LOGICAL_ERROR
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// chassert(x) is similar to assert(x), but:
|
||||||
|
/// - works in builds with sanitizers, not only in debug builds
|
||||||
|
/// - tries to print failed assertion into server log
|
||||||
|
/// It can be used for all assertions except heavy ones.
|
||||||
|
/// Heavy assertions (that run loops or call complex functions) are allowed in debug builds only.
|
||||||
|
/// Also it makes sense to call abort() instead of __builtin_unreachable() in debug builds,
|
||||||
|
/// because SIGABRT is easier to debug than SIGTRAP (the second one makes gdb crazy)
|
||||||
|
#if !defined(chassert)
|
||||||
|
#if defined(ABORT_ON_LOGICAL_ERROR)
|
||||||
|
#define chassert(x) static_cast<bool>(x) ? void(0) : ::DB::abortOnFailedAssertion(#x)
|
||||||
|
#define UNREACHABLE() abort()
|
||||||
|
#else
|
||||||
|
/// Here sizeof() trick is used to suppress unused warning for result,
|
||||||
|
/// since simple "(void)x" will evaluate the expression, while
|
||||||
|
/// "sizeof(!(x))" will not.
|
||||||
|
#define NIL_EXPRESSION(x) (void)sizeof(!(x))
|
||||||
|
#define chassert(x) NIL_EXPRESSION(x)
|
||||||
|
#define UNREACHABLE() __builtin_unreachable()
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// Macros for Clang Thread Safety Analysis (TSA). They can be safely ignored by other compilers.
|
||||||
|
/// Feel free to extend, but please stay close to https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutexheader
|
||||||
|
#if defined(__clang__)
|
||||||
|
# define TSA_GUARDED_BY(...) __attribute__((guarded_by(__VA_ARGS__))) /// data is protected by given capability
|
||||||
|
# define TSA_PT_GUARDED_BY(...) __attribute__((pt_guarded_by(__VA_ARGS__))) /// pointed-to data is protected by the given capability
|
||||||
|
# define TSA_REQUIRES(...) __attribute__((requires_capability(__VA_ARGS__))) /// thread needs exclusive possession of given capability
|
||||||
|
# define TSA_REQUIRES_SHARED(...) __attribute__((requires_shared_capability(__VA_ARGS__))) /// thread needs shared possession of given capability
|
||||||
|
# define TSA_ACQUIRED_AFTER(...) __attribute__((acquired_after(__VA_ARGS__))) /// annotated lock must be locked after given lock
|
||||||
|
# define TSA_NO_THREAD_SAFETY_ANALYSIS __attribute__((no_thread_safety_analysis)) /// disable TSA for a function
|
||||||
|
# define TSA_CAPABILITY(...) __attribute__((capability(__VA_ARGS__))) /// object of a class can be used as capability
|
||||||
|
# define TSA_ACQUIRE(...) __attribute__((acquire_capability(__VA_ARGS__))) /// function acquires a capability, but does not release it
|
||||||
|
# define TSA_TRY_ACQUIRE(...) __attribute__((try_acquire_capability(__VA_ARGS__))) /// function tries to acquire a capability and returns a boolean value indicating success or failure
|
||||||
|
# define TSA_RELEASE(...) __attribute__((release_capability(__VA_ARGS__))) /// function releases the given capability
|
||||||
|
# define TSA_ACQUIRE_SHARED(...) __attribute__((acquire_shared_capability(__VA_ARGS__))) /// function acquires a shared capability, but does not release it
|
||||||
|
# define TSA_TRY_ACQUIRE_SHARED(...) __attribute__((try_acquire_shared_capability(__VA_ARGS__))) /// function tries to acquire a shared capability and returns a boolean value indicating success or failure
|
||||||
|
# define TSA_RELEASE_SHARED(...) __attribute__((release_shared_capability(__VA_ARGS__))) /// function releases the given shared capability
|
||||||
|
|
||||||
|
/// Macros for suppressing TSA warnings for specific reads/writes (instead of suppressing it for the whole function)
|
||||||
|
/// They use a lambda function to apply function attribute to a single statement. This enable us to suppress warnings locally instead of
|
||||||
|
/// suppressing them in the whole function
|
||||||
|
/// Consider adding a comment when using these macros.
|
||||||
|
# define TSA_SUPPRESS_WARNING_FOR_READ(x) ([&]() TSA_NO_THREAD_SAFETY_ANALYSIS -> const auto & { return (x); }())
|
||||||
|
# define TSA_SUPPRESS_WARNING_FOR_WRITE(x) ([&]() TSA_NO_THREAD_SAFETY_ANALYSIS -> auto & { return (x); }())
|
||||||
|
|
||||||
|
/// This macro is useful when only one thread writes to a member
|
||||||
|
/// and you want to read this member from the same thread without locking a mutex.
|
||||||
|
/// It's safe (because no concurrent writes are possible), but TSA generates a warning.
|
||||||
|
/// (Seems like there's no way to verify it, but it makes sense to distinguish it from TSA_SUPPRESS_WARNING_FOR_READ for readability)
|
||||||
|
# define TSA_READ_ONE_THREAD(x) TSA_SUPPRESS_WARNING_FOR_READ(x)
|
||||||
|
|
||||||
|
#else
|
||||||
|
# define TSA_GUARDED_BY(...)
|
||||||
|
# define TSA_PT_GUARDED_BY(...)
|
||||||
|
# define TSA_REQUIRES(...)
|
||||||
|
# define TSA_REQUIRES_SHARED(...)
|
||||||
|
# define TSA_NO_THREAD_SAFETY_ANALYSIS
|
||||||
|
# define TSA_CAPABILITY(...)
|
||||||
|
# define TSA_ACQUIRE(...)
|
||||||
|
# define TSA_TRY_ACQUIRE(...)
|
||||||
|
# define TSA_RELEASE(...)
|
||||||
|
# define TSA_ACQUIRE_SHARED(...)
|
||||||
|
# define TSA_TRY_ACQUIRE_SHARED(...)
|
||||||
|
# define TSA_RELEASE_SHARED(...)
|
||||||
|
|
||||||
|
# define TSA_SUPPRESS_WARNING_FOR_READ(x) (x)
|
||||||
|
# define TSA_SUPPRESS_WARNING_FOR_WRITE(x) (x)
|
||||||
|
# define TSA_READ_ONE_THREAD(x) TSA_SUPPRESS_WARNING_FOR_READ(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
/// A template function for suppressing warnings about unused variables or function results.
|
/// A template function for suppressing warnings about unused variables or function results.
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
constexpr void UNUSED(Args &&... args [[maybe_unused]])
|
constexpr void UNUSED(Args &&... args [[maybe_unused]])
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <base/demangle.h>
|
#include <base/demangle.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
#include <cxxabi.h>
|
#include <cxxabi.h>
|
||||||
|
|
||||||
static DemangleResult tryDemangle(const char * name, int & status)
|
static DemangleResult tryDemangle(const char * name, int & status)
|
||||||
|
@ -27,6 +27,6 @@ struct FreeingDeleter
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::unique_ptr<char, FreeingDeleter> DemangleResult;
|
using DemangleResult = std::unique_ptr<char, FreeingDeleter>;
|
||||||
|
|
||||||
DemangleResult tryDemangle(const char * name);
|
DemangleResult tryDemangle(const char * name);
|
||||||
|
@ -3,19 +3,20 @@
|
|||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
|
|
||||||
std::string errnoToString(int code, int the_errno)
|
std::string errnoToString(int the_errno)
|
||||||
{
|
{
|
||||||
const size_t buf_size = 128;
|
const size_t buf_size = 128;
|
||||||
char buf[buf_size];
|
char buf[buf_size];
|
||||||
|
|
||||||
#ifndef _GNU_SOURCE
|
#ifndef _GNU_SOURCE
|
||||||
int rc = strerror_r(the_errno, buf, buf_size);
|
int rc = strerror_r(the_errno, buf, buf_size);
|
||||||
#ifdef __APPLE__
|
#ifdef OS_DARWIN
|
||||||
if (rc != 0 && rc != EINVAL)
|
if (rc != 0 && rc != EINVAL)
|
||||||
#else
|
#else
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
std::string tmp = std::to_string(code);
|
std::string tmp = std::to_string(the_errno);
|
||||||
const char * code_str = tmp.c_str();
|
const char * code_str = tmp.c_str();
|
||||||
const char * unknown_message = "Unknown error ";
|
const char * unknown_message = "Unknown error ";
|
||||||
strcpy(buf, unknown_message);
|
strcpy(buf, unknown_message);
|
||||||
@ -23,7 +24,6 @@ std::string errnoToString(int code, int the_errno)
|
|||||||
}
|
}
|
||||||
return fmt::format("errno: {}, strerror: {}", the_errno, buf);
|
return fmt::format("errno: {}, strerror: {}", the_errno, buf);
|
||||||
#else
|
#else
|
||||||
(void)code;
|
|
||||||
return fmt::format("errno: {}, strerror: {}", the_errno, strerror_r(the_errno, buf, sizeof(buf)));
|
return fmt::format("errno: {}, strerror: {}", the_errno, strerror_r(the_errno, buf, sizeof(buf)));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
std::string errnoToString(int code, int the_errno = errno);
|
std::string errnoToString(int the_errno = errno);
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include <base/types.h>
|
#include <base/types.h>
|
||||||
#include <base/wide_integer.h>
|
#include <base/wide_integer.h>
|
||||||
|
|
||||||
|
|
||||||
using Int128 = wide::integer<128, signed>;
|
using Int128 = wide::integer<128, signed>;
|
||||||
using UInt128 = wide::integer<128, unsigned>;
|
using UInt128 = wide::integer<128, unsigned>;
|
||||||
using Int256 = wide::integer<256, signed>;
|
using Int256 = wide::integer<256, signed>;
|
||||||
@ -18,7 +17,7 @@ static_assert(sizeof(UInt256) == 32);
|
|||||||
/// (std::common_type), are "set in stone". Attempting to specialize them causes undefined behavior.
|
/// (std::common_type), are "set in stone". Attempting to specialize them causes undefined behavior.
|
||||||
/// So instead of using the std type_traits, we use our own version which allows extension.
|
/// So instead of using the std type_traits, we use our own version which allows extension.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_signed
|
struct is_signed // NOLINT(readability-identifier-naming)
|
||||||
{
|
{
|
||||||
static constexpr bool value = std::is_signed_v<T>;
|
static constexpr bool value = std::is_signed_v<T>;
|
||||||
};
|
};
|
||||||
@ -30,7 +29,7 @@ template <typename T>
|
|||||||
inline constexpr bool is_signed_v = is_signed<T>::value;
|
inline constexpr bool is_signed_v = is_signed<T>::value;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_unsigned
|
struct is_unsigned // NOLINT(readability-identifier-naming)
|
||||||
{
|
{
|
||||||
static constexpr bool value = std::is_unsigned_v<T>;
|
static constexpr bool value = std::is_unsigned_v<T>;
|
||||||
};
|
};
|
||||||
@ -51,7 +50,7 @@ template <class T> concept is_integer =
|
|||||||
template <class T> concept is_floating_point = std::is_floating_point_v<T>;
|
template <class T> concept is_floating_point = std::is_floating_point_v<T>;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_arithmetic
|
struct is_arithmetic // NOLINT(readability-identifier-naming)
|
||||||
{
|
{
|
||||||
static constexpr bool value = std::is_arithmetic_v<T>;
|
static constexpr bool value = std::is_arithmetic_v<T>;
|
||||||
};
|
};
|
||||||
@ -66,9 +65,9 @@ template <typename T>
|
|||||||
inline constexpr bool is_arithmetic_v = is_arithmetic<T>::value;
|
inline constexpr bool is_arithmetic_v = is_arithmetic<T>::value;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct make_unsigned
|
struct make_unsigned // NOLINT(readability-identifier-naming)
|
||||||
{
|
{
|
||||||
typedef std::make_unsigned_t<T> type;
|
using type = std::make_unsigned_t<T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <> struct make_unsigned<Int128> { using type = UInt128; };
|
template <> struct make_unsigned<Int128> { using type = UInt128; };
|
||||||
@ -79,9 +78,9 @@ template <> struct make_unsigned<UInt256> { using type = UInt256; };
|
|||||||
template <typename T> using make_unsigned_t = typename make_unsigned<T>::type;
|
template <typename T> using make_unsigned_t = typename make_unsigned<T>::type;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct make_signed
|
struct make_signed // NOLINT(readability-identifier-naming)
|
||||||
{
|
{
|
||||||
typedef std::make_signed_t<T> type;
|
using type = std::make_signed_t<T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <> struct make_signed<Int128> { using type = Int128; };
|
template <> struct make_signed<Int128> { using type = Int128; };
|
||||||
@ -92,7 +91,7 @@ template <> struct make_signed<UInt256> { using type = Int256; };
|
|||||||
template <typename T> using make_signed_t = typename make_signed<T>::type;
|
template <typename T> using make_signed_t = typename make_signed<T>::type;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_big_int
|
struct is_big_int // NOLINT(readability-identifier-naming)
|
||||||
{
|
{
|
||||||
static constexpr bool value = false;
|
static constexpr bool value = false;
|
||||||
};
|
};
|
||||||
@ -104,4 +103,3 @@ template <> struct is_big_int<UInt256> { static constexpr bool value = true; };
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline constexpr bool is_big_int_v = is_big_int<T>::value;
|
inline constexpr bool is_big_int_v = is_big_int<T>::value;
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
* Allow to search for next character from the set of 'symbols...' in a string.
|
* Allow to search for next character from the set of 'symbols...' in a string.
|
||||||
* It is similar to 'strpbrk', 'strcspn' (and 'strchr', 'memchr' in the case of one symbol and '\0'),
|
* It is similar to 'strpbrk', 'strcspn' (and 'strchr', 'memchr' in the case of one symbol and '\0'),
|
||||||
* but with the following differencies:
|
* but with the following differences:
|
||||||
* - works with any memory ranges, including containing zero bytes;
|
* - works with any memory ranges, including containing zero bytes;
|
||||||
* - doesn't require terminating zero byte: end of memory range is passed explicitly;
|
* - doesn't require terminating zero byte: end of memory range is passed explicitly;
|
||||||
* - if not found, returns pointer to end instead of nullptr;
|
* - if not found, returns pointer to end instead of nullptr;
|
||||||
|
44
base/base/getAvailableMemoryAmount.cpp
Normal file
44
base/base/getAvailableMemoryAmount.cpp
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#include <stdexcept>
|
||||||
|
#include <fstream>
|
||||||
|
#include <base/getAvailableMemoryAmount.h>
|
||||||
|
#include <base/getPageSize.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#if defined(BSD)
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <sys/vmmeter.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
uint64_t getAvailableMemoryAmountOrZero()
|
||||||
|
{
|
||||||
|
#if defined(_SC_PHYS_PAGES) // linux
|
||||||
|
return getPageSize() * sysconf(_SC_PHYS_PAGES);
|
||||||
|
#elif defined(OS_FREEBSD)
|
||||||
|
struct vmtotal vmt;
|
||||||
|
size_t vmt_size = sizeof(vmt);
|
||||||
|
if (sysctlbyname("vm.vmtotal", &vmt, &vmt_size, NULL, 0) == 0)
|
||||||
|
return getPageSize() * vmt.t_avm;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
#else // darwin
|
||||||
|
unsigned int usermem;
|
||||||
|
size_t len = sizeof(usermem);
|
||||||
|
static int mib[2] = { CTL_HW, HW_USERMEM };
|
||||||
|
if (sysctl(mib, 2, &usermem, &len, nullptr, 0) == 0 && len == sizeof(usermem))
|
||||||
|
return usermem;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint64_t getAvailableMemoryAmount()
|
||||||
|
{
|
||||||
|
auto res = getAvailableMemoryAmountOrZero();
|
||||||
|
if (!res)
|
||||||
|
throw std::runtime_error("Cannot determine available memory amount");
|
||||||
|
return res;
|
||||||
|
}
|
12
base/base/getAvailableMemoryAmount.h
Normal file
12
base/base/getAvailableMemoryAmount.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
/** Returns the size of currently available physical memory (RAM) in bytes.
|
||||||
|
* Returns 0 on unsupported platform or if it cannot determine the size of physical memory.
|
||||||
|
*/
|
||||||
|
uint64_t getAvailableMemoryAmountOrZero();
|
||||||
|
|
||||||
|
/** Throws exception if it cannot determine the size of physical memory.
|
||||||
|
*/
|
||||||
|
uint64_t getAvailableMemoryAmount();
|
@ -16,17 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
uint64_t getMemoryAmountOrZero()
|
uint64_t getMemoryAmountOrZero()
|
||||||
{
|
{
|
||||||
#if defined(OS_LINUX)
|
|
||||||
// Try to lookup at the Cgroup limit
|
|
||||||
std::ifstream cgroup_limit("/sys/fs/cgroup/memory/memory.limit_in_bytes");
|
|
||||||
if (cgroup_limit.is_open())
|
|
||||||
{
|
|
||||||
uint64_t amount = 0; // in case of read error
|
|
||||||
cgroup_limit >> amount;
|
|
||||||
return amount;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int64_t num_pages = sysconf(_SC_PHYS_PAGES);
|
int64_t num_pages = sysconf(_SC_PHYS_PAGES);
|
||||||
if (num_pages <= 0)
|
if (num_pages <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -35,7 +24,22 @@ uint64_t getMemoryAmountOrZero()
|
|||||||
if (page_size <= 0)
|
if (page_size <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return num_pages * page_size;
|
uint64_t memory_amount = num_pages * page_size;
|
||||||
|
|
||||||
|
#if defined(OS_LINUX)
|
||||||
|
// Try to lookup at the Cgroup limit
|
||||||
|
std::ifstream cgroup_limit("/sys/fs/cgroup/memory/memory.limit_in_bytes");
|
||||||
|
if (cgroup_limit.is_open())
|
||||||
|
{
|
||||||
|
uint64_t memory_limit = 0; // in case of read error
|
||||||
|
cgroup_limit >> memory_limit;
|
||||||
|
if (memory_limit > 0 && memory_limit < memory_amount)
|
||||||
|
memory_amount = memory_limit;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return memory_amount;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
#include <base/getPageSize.h>
|
#include <base/getPageSize.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
Int64 getPageSize()
|
Int64 getPageSize()
|
||||||
{
|
{
|
||||||
return sysconf(_SC_PAGESIZE);
|
Int64 page_size = sysconf(_SC_PAGESIZE);
|
||||||
|
if (page_size < 0)
|
||||||
|
abort();
|
||||||
|
return page_size;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ uint64_t getThreadId()
|
|||||||
#if defined(OS_ANDROID)
|
#if defined(OS_ANDROID)
|
||||||
current_tid = gettid();
|
current_tid = gettid();
|
||||||
#elif defined(OS_LINUX)
|
#elif defined(OS_LINUX)
|
||||||
current_tid = syscall(SYS_gettid); /// This call is always successful. - man gettid
|
current_tid = static_cast<uint64_t>(syscall(SYS_gettid)); /// This call is always successful. - man gettid
|
||||||
#elif defined(OS_FREEBSD)
|
#elif defined(OS_FREEBSD)
|
||||||
current_tid = pthread_getthreadid_np();
|
current_tid = pthread_getthreadid_np();
|
||||||
#elif defined(OS_SUNOS)
|
#elif defined(OS_SUNOS)
|
||||||
|
@ -26,3 +26,27 @@ void insertAtEnd(std::vector<T> & dest, std::vector<T> && src)
|
|||||||
dest.insert(dest.end(), std::make_move_iterator(src.begin()), std::make_move_iterator(src.end()));
|
dest.insert(dest.end(), std::make_move_iterator(src.begin()), std::make_move_iterator(src.end()));
|
||||||
src.clear();
|
src.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Container>
|
||||||
|
void insertAtEnd(Container & dest, const Container & src)
|
||||||
|
{
|
||||||
|
if (src.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
dest.insert(dest.end(), src.begin(), src.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Container>
|
||||||
|
void insertAtEnd(Container & dest, Container && src)
|
||||||
|
{
|
||||||
|
if (src.empty())
|
||||||
|
return;
|
||||||
|
if (dest.empty())
|
||||||
|
{
|
||||||
|
dest.swap(src);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dest.insert(dest.end(), std::make_move_iterator(src.begin()), std::make_move_iterator(src.end()));
|
||||||
|
src.clear();
|
||||||
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <magic_enum.hpp>
|
||||||
|
|
||||||
/** Usage:
|
/** Usage:
|
||||||
*
|
*
|
||||||
@ -61,6 +62,13 @@ std::enable_if_t<priority == 2, Out> & dumpImpl(Out & out, T && x, std::decay_t<
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <int priority, typename Out, typename T>
|
||||||
|
std::enable_if_t<priority == 3 && std::is_enum_v<std::decay_t<T>>, Out> &
|
||||||
|
dumpImpl(Out & out, T && x)
|
||||||
|
{
|
||||||
|
return out << magic_enum::enum_name(x);
|
||||||
|
}
|
||||||
|
|
||||||
/// string and const char * - output not as container or pointer.
|
/// string and const char * - output not as container or pointer.
|
||||||
|
|
||||||
template <int priority, typename Out, typename T>
|
template <int priority, typename Out, typename T>
|
||||||
@ -112,6 +120,7 @@ Out & dumpDispatchPriorities(Out & out, T && x, std::decay_t<decltype(dumpImpl<p
|
|||||||
return dumpImpl<priority>(out, x);
|
return dumpImpl<priority>(out, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(google-explicit-constructor)
|
||||||
struct LowPriority { LowPriority(void *) {} };
|
struct LowPriority { LowPriority(void *) {} };
|
||||||
|
|
||||||
template <int priority, typename Out, typename T>
|
template <int priority, typename Out, typename T>
|
||||||
@ -131,15 +140,26 @@ Out & dumpValue(Out & out, T && x)
|
|||||||
template <typename Out, typename T>
|
template <typename Out, typename T>
|
||||||
Out & dump(Out & out, const char * name, T && x)
|
Out & dump(Out & out, const char * name, T && x)
|
||||||
{
|
{
|
||||||
|
// Dumping string literal, printing name and demangled type is irrelevant.
|
||||||
|
if constexpr (std::is_same_v<const char *, std::decay_t<std::remove_reference_t<T>>>)
|
||||||
|
{
|
||||||
|
const auto name_len = strlen(name);
|
||||||
|
const auto value_len = strlen(x);
|
||||||
|
// `name` is the same as quoted `x`
|
||||||
|
if (name_len > 2 && value_len > 0 && name[0] == '"' && name[name_len - 1] == '"'
|
||||||
|
&& strncmp(name + 1, x, std::min(value_len, name_len) - 1) == 0)
|
||||||
|
return out << x;
|
||||||
|
}
|
||||||
|
|
||||||
out << demangle(typeid(x).name()) << " " << name << " = ";
|
out << demangle(typeid(x).name()) << " " << name << " = ";
|
||||||
return dumpValue(out, x);
|
return dumpValue(out, x) << "; ";
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
|
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DUMPVAR(VAR) ::dump(std::cerr, #VAR, (VAR)); std::cerr << "; ";
|
#define DUMPVAR(VAR) ::dump(std::cerr, #VAR, (VAR));
|
||||||
#define DUMPHEAD std::cerr << __FILE__ << ':' << __LINE__ << " [ " << getThreadId() << " ] ";
|
#define DUMPHEAD std::cerr << __FILE__ << ':' << __LINE__ << " [ " << getThreadId() << " ] ";
|
||||||
#define DUMPTAIL std::cerr << '\n';
|
#define DUMPTAIL std::cerr << '\n';
|
||||||
|
|
||||||
|
@ -91,10 +91,10 @@ template <size_t N>
|
|||||||
using DivisionBy10PowN = typename SelectType
|
using DivisionBy10PowN = typename SelectType
|
||||||
<
|
<
|
||||||
N,
|
N,
|
||||||
Division<uint8_t, 0, 205U, 11>, /// divide by 10
|
Division<uint8_t, false, 205U, 11>, /// divide by 10
|
||||||
Division<uint16_t, 1, 41943U, 22>, /// divide by 100
|
Division<uint16_t, true, 41943U, 22>, /// divide by 100
|
||||||
Division<uint32_t, 0, 3518437209U, 45>, /// divide by 10000
|
Division<uint32_t, false, 3518437209U, 45>, /// divide by 10000
|
||||||
Division<uint64_t, 0, 12379400392853802749ULL, 90> /// divide by 100000000
|
Division<uint64_t, false, 12379400392853802749ULL, 90> /// divide by 100000000
|
||||||
>::Result;
|
>::Result;
|
||||||
|
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
@ -122,7 +122,7 @@ QuotientAndRemainder<N> static inline split(UnsignedOfSize<N> value)
|
|||||||
constexpr DivisionBy10PowN<N> division;
|
constexpr DivisionBy10PowN<N> division;
|
||||||
|
|
||||||
UnsignedOfSize<N> quotient = (division.multiplier * (UnsignedOfSize<2 * N>(value) + division.add)) >> division.shift;
|
UnsignedOfSize<N> quotient = (division.multiplier * (UnsignedOfSize<2 * N>(value) + division.add)) >> division.shift;
|
||||||
UnsignedOfSize<N / 2> remainder = value - quotient * pow10<UnsignedOfSize<N / 2>>(N);
|
UnsignedOfSize<N / 2> remainder = static_cast<UnsignedOfSize<N / 2>>(value - quotient * pow10<UnsignedOfSize<N / 2>>(N));
|
||||||
|
|
||||||
return {quotient, remainder};
|
return {quotient, remainder};
|
||||||
}
|
}
|
||||||
@ -352,7 +352,7 @@ static inline char * writeUIntText(T x, char * p)
|
|||||||
static_assert(is_unsigned_v<T>);
|
static_assert(is_unsigned_v<T>);
|
||||||
|
|
||||||
int len = digits10(x);
|
int len = digits10(x);
|
||||||
auto pp = p + len;
|
auto * pp = p + len;
|
||||||
while (x >= 100)
|
while (x >= 100)
|
||||||
{
|
{
|
||||||
const auto i = x % 100;
|
const auto i = x % 100;
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
/// Macros for convenient usage of Poco logger.
|
|
||||||
|
|
||||||
#include <fmt/format.h>
|
|
||||||
#include <Poco/Logger.h>
|
|
||||||
#include <Poco/Message.h>
|
|
||||||
#include <Common/CurrentThread.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
template <typename... Ts> constexpr size_t numArgs(Ts &&...) { return sizeof...(Ts); }
|
|
||||||
template <typename T, typename... Ts> constexpr auto firstArg(T && x, Ts &&...) { return std::forward<T>(x); }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Logs a message to a specified logger with that level.
|
|
||||||
/// If more than one argument is provided,
|
|
||||||
/// the first argument is interpreted as template with {}-substitutions
|
|
||||||
/// and the latter arguments treat as values to substitute.
|
|
||||||
/// If only one argument is provided, it is threat as message without substitutions.
|
|
||||||
|
|
||||||
#define LOG_IMPL(logger, priority, PRIORITY, ...) do \
|
|
||||||
{ \
|
|
||||||
const bool is_clients_log = (DB::CurrentThread::getGroup() != nullptr) && \
|
|
||||||
(DB::CurrentThread::getGroup()->client_logs_level >= (priority)); \
|
|
||||||
if ((logger)->is((PRIORITY)) || is_clients_log) \
|
|
||||||
{ \
|
|
||||||
std::string formatted_message = numArgs(__VA_ARGS__) > 1 ? fmt::format(__VA_ARGS__) : firstArg(__VA_ARGS__); \
|
|
||||||
if (auto channel = (logger)->getChannel()) \
|
|
||||||
{ \
|
|
||||||
std::string file_function; \
|
|
||||||
file_function += __FILE__; \
|
|
||||||
file_function += "; "; \
|
|
||||||
file_function += __PRETTY_FUNCTION__; \
|
|
||||||
Poco::Message poco_message((logger)->name(), formatted_message, \
|
|
||||||
(PRIORITY), file_function.c_str(), __LINE__); \
|
|
||||||
channel->log(poco_message); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
} while (false)
|
|
||||||
|
|
||||||
|
|
||||||
#define LOG_TEST(logger, ...) LOG_IMPL(logger, DB::LogsLevel::test, Poco::Message::PRIO_TEST, __VA_ARGS__)
|
|
||||||
#define LOG_TRACE(logger, ...) LOG_IMPL(logger, DB::LogsLevel::trace, Poco::Message::PRIO_TRACE, __VA_ARGS__)
|
|
||||||
#define LOG_DEBUG(logger, ...) LOG_IMPL(logger, DB::LogsLevel::debug, Poco::Message::PRIO_DEBUG, __VA_ARGS__)
|
|
||||||
#define LOG_INFO(logger, ...) LOG_IMPL(logger, DB::LogsLevel::information, Poco::Message::PRIO_INFORMATION, __VA_ARGS__)
|
|
||||||
#define LOG_WARNING(logger, ...) LOG_IMPL(logger, DB::LogsLevel::warning, Poco::Message::PRIO_WARNING, __VA_ARGS__)
|
|
||||||
#define LOG_ERROR(logger, ...) LOG_IMPL(logger, DB::LogsLevel::error, Poco::Message::PRIO_ERROR, __VA_ARGS__)
|
|
||||||
#define LOG_FATAL(logger, ...) LOG_IMPL(logger, DB::LogsLevel::error, Poco::Message::PRIO_FATAL, __VA_ARGS__)
|
|
@ -3,7 +3,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <errno.h>
|
#include <cerrno>
|
||||||
|
|
||||||
|
|
||||||
void * mremap_fallback(
|
void * mremap_fallback(
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
#pragma clang diagnostic ignored "-Wreserved-identifier"
|
#pragma clang diagnostic ignored "-Wreserved-identifier"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// This code was based on the code by Fedor Korotkiy (prime@yandex-team.ru) for YT product in Yandex.
|
/// This code was based on the code by Fedor Korotkiy https://www.linkedin.com/in/fedor-korotkiy-659a1838/
|
||||||
|
|
||||||
#include <base/defines.h>
|
#include <base/defines.h>
|
||||||
|
|
||||||
#if defined(__linux__) && !defined(THREAD_SANITIZER) && !defined(USE_MUSL)
|
#if defined(OS_LINUX) && !defined(THREAD_SANITIZER) && !defined(USE_MUSL)
|
||||||
#define USE_PHDR_CACHE 1
|
#define USE_PHDR_CACHE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -123,6 +123,12 @@ bool hasPHDRCache()
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
void updatePHDRCache() {}
|
void updatePHDRCache() {}
|
||||||
bool hasPHDRCache() { return false; }
|
|
||||||
|
#if defined(USE_MUSL)
|
||||||
|
/// With statically linked with musl, dl_iterate_phdr is immutable.
|
||||||
|
bool hasPHDRCache() { return true; }
|
||||||
|
#else
|
||||||
|
bool hasPHDRCache() { return false; }
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/// This code was based on the code by Fedor Korotkiy (prime@yandex-team.ru) for YT product in Yandex.
|
/// This code was based on the code by Fedor Korotkiy https://www.linkedin.com/in/fedor-korotkiy-659a1838/
|
||||||
|
|
||||||
/** Collects all dl_phdr_info items and caches them in a static array.
|
/** Collects all dl_phdr_info items and caches them in a static array.
|
||||||
* Also rewrites dl_iterate_phdr with a lock-free version which consults the above cache
|
* Also rewrites dl_iterate_phdr with a lock-free version which consults the above cache
|
||||||
@ -8,6 +8,7 @@
|
|||||||
* As a drawback, this only works if no dynamic object unloading happens after this point.
|
* As a drawback, this only works if no dynamic object unloading happens after this point.
|
||||||
* This function is thread-safe. You should call it to update cache after loading new shared libraries.
|
* This function is thread-safe. You should call it to update cache after loading new shared libraries.
|
||||||
* Otherwise exception handling from dlopened libraries won't work (will call std::terminate immediately).
|
* Otherwise exception handling from dlopened libraries won't work (will call std::terminate immediately).
|
||||||
|
* NOTE: dlopen is forbidden in our code.
|
||||||
*
|
*
|
||||||
* NOTE: It is disabled with Thread Sanitizer because TSan can only use original "dl_iterate_phdr" function.
|
* NOTE: It is disabled with Thread Sanitizer because TSan can only use original "dl_iterate_phdr" function.
|
||||||
*/
|
*/
|
||||||
|
@ -169,9 +169,9 @@ obstacle to adoption, that text has been removed.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <math.h>
|
#include <cmath>
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
|
|
||||||
double preciseExp10(double x)
|
double preciseExp10(double x)
|
||||||
{
|
{
|
||||||
|
19
base/base/safeExit.cpp
Normal file
19
base/base/safeExit.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#if defined(OS_LINUX)
|
||||||
|
# include <sys/syscall.h>
|
||||||
|
#endif
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <base/safeExit.h>
|
||||||
|
#include <base/defines.h> /// for THREAD_SANITIZER
|
||||||
|
|
||||||
|
[[noreturn]] void safeExit(int code)
|
||||||
|
{
|
||||||
|
#if defined(THREAD_SANITIZER) && defined(OS_LINUX)
|
||||||
|
/// Thread sanitizer tries to do something on exit that we don't need if we want to exit immediately,
|
||||||
|
/// while connection handling threads are still run.
|
||||||
|
(void)syscall(SYS_exit_group, code);
|
||||||
|
UNREACHABLE();
|
||||||
|
#else
|
||||||
|
_exit(code);
|
||||||
|
#endif
|
||||||
|
}
|
4
base/base/safeExit.h
Normal file
4
base/base/safeExit.h
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
/// _exit() with a workaround for TSan.
|
||||||
|
[[noreturn]] void safeExit(int code);
|
@ -5,13 +5,13 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
template <class F>
|
template <class F>
|
||||||
class [[nodiscard]] basic_scope_guard
|
class [[nodiscard]] BasicScopeGuard
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
constexpr basic_scope_guard() = default;
|
constexpr BasicScopeGuard() = default;
|
||||||
constexpr basic_scope_guard(basic_scope_guard && src) : function{src.release()} {}
|
constexpr BasicScopeGuard(BasicScopeGuard && src) : function{src.release()} {} // NOLINT(hicpp-noexcept-move, performance-noexcept-move-constructor)
|
||||||
|
|
||||||
constexpr basic_scope_guard & operator=(basic_scope_guard && src)
|
constexpr BasicScopeGuard & operator=(BasicScopeGuard && src) // NOLINT(hicpp-noexcept-move, performance-noexcept-move-constructor)
|
||||||
{
|
{
|
||||||
if (this != &src)
|
if (this != &src)
|
||||||
{
|
{
|
||||||
@ -21,11 +21,13 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename G, typename = std::enable_if_t<std::is_convertible_v<G, F>, void>>
|
template <typename G>
|
||||||
constexpr basic_scope_guard(basic_scope_guard<G> && src) : function{src.release()} {}
|
requires std::is_convertible_v<G, F>
|
||||||
|
constexpr BasicScopeGuard(BasicScopeGuard<G> && src) : function{src.release()} {} // NOLINT(google-explicit-constructor)
|
||||||
|
|
||||||
template <typename G, typename = std::enable_if_t<std::is_convertible_v<G, F>, void>>
|
template <typename G>
|
||||||
constexpr basic_scope_guard & operator=(basic_scope_guard<G> && src)
|
requires std::is_convertible_v<G, F>
|
||||||
|
constexpr BasicScopeGuard & operator=(BasicScopeGuard<G> && src)
|
||||||
{
|
{
|
||||||
if (this != &src)
|
if (this != &src)
|
||||||
{
|
{
|
||||||
@ -35,13 +37,15 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename G, typename = std::enable_if_t<std::is_convertible_v<G, F>, void>>
|
template <typename G>
|
||||||
constexpr basic_scope_guard(const G & function_) : function{function_} {}
|
requires std::is_convertible_v<G, F>
|
||||||
|
constexpr BasicScopeGuard(const G & function_) : function{function_} {} // NOLINT(google-explicit-constructor)
|
||||||
|
|
||||||
template <typename G, typename = std::enable_if_t<std::is_convertible_v<G, F>, void>>
|
template <typename G>
|
||||||
constexpr basic_scope_guard(G && function_) : function{std::move(function_)} {}
|
requires std::is_convertible_v<G, F>
|
||||||
|
constexpr BasicScopeGuard(G && function_) : function{std::move(function_)} {} // NOLINT(google-explicit-constructor, bugprone-forwarding-reference-overload, bugprone-move-forwarding-reference)
|
||||||
|
|
||||||
~basic_scope_guard() { invoke(); }
|
~BasicScopeGuard() { invoke(); }
|
||||||
|
|
||||||
static constexpr bool is_nullable = std::is_constructible_v<bool, F>;
|
static constexpr bool is_nullable = std::is_constructible_v<bool, F>;
|
||||||
|
|
||||||
@ -64,8 +68,9 @@ public:
|
|||||||
return std::exchange(function, {});
|
return std::exchange(function, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename G, typename = std::enable_if_t<std::is_convertible_v<G, F>, void>>
|
template <typename G>
|
||||||
basic_scope_guard<F> & join(basic_scope_guard<G> && other)
|
requires std::is_convertible_v<G, F>
|
||||||
|
BasicScopeGuard<F> & join(BasicScopeGuard<G> && other)
|
||||||
{
|
{
|
||||||
if (other.function)
|
if (other.function)
|
||||||
{
|
{
|
||||||
@ -97,14 +102,13 @@ private:
|
|||||||
F function = F{};
|
F function = F{};
|
||||||
};
|
};
|
||||||
|
|
||||||
using scope_guard = basic_scope_guard<std::function<void(void)>>;
|
using scope_guard = BasicScopeGuard<std::function<void(void)>>;
|
||||||
|
|
||||||
|
|
||||||
template <class F>
|
template <class F>
|
||||||
inline basic_scope_guard<F> make_scope_guard(F && function_) { return std::forward<F>(function_); }
|
inline BasicScopeGuard<F> make_scope_guard(F && function_) { return std::forward<F>(function_); }
|
||||||
|
|
||||||
#define SCOPE_EXIT_CONCAT(n, ...) \
|
#define SCOPE_EXIT_CONCAT(n, ...) \
|
||||||
const auto scope_exit##n = make_scope_guard([&] { __VA_ARGS__; })
|
const auto scope_exit##n = make_scope_guard([&] { __VA_ARGS__; })
|
||||||
#define SCOPE_EXIT_FWD(n, ...) SCOPE_EXIT_CONCAT(n, __VA_ARGS__)
|
#define SCOPE_EXIT_FWD(n, ...) SCOPE_EXIT_CONCAT(n, __VA_ARGS__)
|
||||||
#define SCOPE_EXIT(...) SCOPE_EXIT_FWD(__LINE__, __VA_ARGS__)
|
#define SCOPE_EXIT(...) SCOPE_EXIT_FWD(__LINE__, __VA_ARGS__)
|
||||||
|
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
#include <base/setTerminalEcho.h>
|
|
||||||
#include <base/errnoToString.h>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <cstring>
|
|
||||||
#include <string>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
|
|
||||||
void setTerminalEcho(bool enable)
|
|
||||||
{
|
|
||||||
/// Obtain terminal attributes,
|
|
||||||
/// toggle the ECHO flag
|
|
||||||
/// and set them back.
|
|
||||||
|
|
||||||
struct termios tty{};
|
|
||||||
|
|
||||||
if (0 != tcgetattr(STDIN_FILENO, &tty))
|
|
||||||
throw std::runtime_error(std::string("setTerminalEcho failed get: ") + errnoToString(errno));
|
|
||||||
|
|
||||||
if (enable)
|
|
||||||
tty.c_lflag |= ECHO;
|
|
||||||
else
|
|
||||||
tty.c_lflag &= ~ECHO;
|
|
||||||
|
|
||||||
if (0 != tcsetattr(STDIN_FILENO, TCSANOW, &tty))
|
|
||||||
throw std::runtime_error(std::string("setTerminalEcho failed set: ") + errnoToString(errno));
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
/// Enable or disable echoing of typed characters. Throws std::runtime_error on error.
|
|
||||||
void setTerminalEcho(bool enable);
|
|
@ -1,36 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
|
|
||||||
/** Allows to make std::shared_ptr from T with protected constructor.
|
|
||||||
*
|
|
||||||
* Derive your T class from shared_ptr_helper<T> and add shared_ptr_helper<T> as a friend
|
|
||||||
* and you will have static 'create' method in your class.
|
|
||||||
*/
|
|
||||||
template <typename T>
|
|
||||||
struct shared_ptr_helper
|
|
||||||
{
|
|
||||||
template <typename... TArgs>
|
|
||||||
static std::shared_ptr<T> create(TArgs &&... args)
|
|
||||||
{
|
|
||||||
return std::shared_ptr<T>(new T(std::forward<TArgs>(args)...));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct is_shared_ptr
|
|
||||||
{
|
|
||||||
static constexpr bool value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct is_shared_ptr<std::shared_ptr<T>>
|
|
||||||
{
|
|
||||||
static constexpr bool value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline constexpr bool is_shared_ptr_v = is_shared_ptr<T>::value;
|
|
@ -14,37 +14,37 @@ static T shift10Impl(T x, int exponent)
|
|||||||
static const long double powers10[] =
|
static const long double powers10[] =
|
||||||
{
|
{
|
||||||
1e-323L, 1e-322L, 1e-321L, 1e-320L, 1e-319L, 1e-318L, 1e-317L, 1e-316L, 1e-315L, 1e-314L, 1e-313L, 1e-312L, 1e-311L,
|
1e-323L, 1e-322L, 1e-321L, 1e-320L, 1e-319L, 1e-318L, 1e-317L, 1e-316L, 1e-315L, 1e-314L, 1e-313L, 1e-312L, 1e-311L,
|
||||||
1e-310L,1e-309L,1e-308L,1e-307L,1e-306L,1e-305L,1e-304L,1e-303L,1e-302L,1e-301L,1e-300L,1e-299L,1e-298L,1e-297L,1e-296L,1e-295L,1e-294L,1e-293L,1e-292L,1e-291L,
|
1e-310L, 1e-309L, 1e-308L, 1e-307L, 1e-306L, 1e-305L, 1e-304L, 1e-303L, 1e-302L, 1e-301L, 1e-300L, 1e-299L, 1e-298L, 1e-297L, 1e-296L, 1e-295L, 1e-294L, 1e-293L, 1e-292L, 1e-291L,
|
||||||
1e-290L,1e-289L,1e-288L,1e-287L,1e-286L,1e-285L,1e-284L,1e-283L,1e-282L,1e-281L,1e-280L,1e-279L,1e-278L,1e-277L,1e-276L,1e-275L,1e-274L,1e-273L,1e-272L,1e-271L,
|
1e-290L, 1e-289L, 1e-288L, 1e-287L, 1e-286L, 1e-285L, 1e-284L, 1e-283L, 1e-282L, 1e-281L, 1e-280L, 1e-279L, 1e-278L, 1e-277L, 1e-276L, 1e-275L, 1e-274L, 1e-273L, 1e-272L, 1e-271L,
|
||||||
1e-270L,1e-269L,1e-268L,1e-267L,1e-266L,1e-265L,1e-264L,1e-263L,1e-262L,1e-261L,1e-260L,1e-259L,1e-258L,1e-257L,1e-256L,1e-255L,1e-254L,1e-253L,1e-252L,1e-251L,
|
1e-270L, 1e-269L, 1e-268L, 1e-267L, 1e-266L, 1e-265L, 1e-264L, 1e-263L, 1e-262L, 1e-261L, 1e-260L, 1e-259L, 1e-258L, 1e-257L, 1e-256L, 1e-255L, 1e-254L, 1e-253L, 1e-252L, 1e-251L,
|
||||||
1e-250L,1e-249L,1e-248L,1e-247L,1e-246L,1e-245L,1e-244L,1e-243L,1e-242L,1e-241L,1e-240L,1e-239L,1e-238L,1e-237L,1e-236L,1e-235L,1e-234L,1e-233L,1e-232L,1e-231L,
|
1e-250L, 1e-249L, 1e-248L, 1e-247L, 1e-246L, 1e-245L, 1e-244L, 1e-243L, 1e-242L, 1e-241L, 1e-240L, 1e-239L, 1e-238L, 1e-237L, 1e-236L, 1e-235L, 1e-234L, 1e-233L, 1e-232L, 1e-231L,
|
||||||
1e-230L,1e-229L,1e-228L,1e-227L,1e-226L,1e-225L,1e-224L,1e-223L,1e-222L,1e-221L,1e-220L,1e-219L,1e-218L,1e-217L,1e-216L,1e-215L,1e-214L,1e-213L,1e-212L,1e-211L,
|
1e-230L, 1e-229L, 1e-228L, 1e-227L, 1e-226L, 1e-225L, 1e-224L, 1e-223L, 1e-222L, 1e-221L, 1e-220L, 1e-219L, 1e-218L, 1e-217L, 1e-216L, 1e-215L, 1e-214L, 1e-213L, 1e-212L, 1e-211L,
|
||||||
1e-210L,1e-209L,1e-208L,1e-207L,1e-206L,1e-205L,1e-204L,1e-203L,1e-202L,1e-201L,1e-200L,1e-199L,1e-198L,1e-197L,1e-196L,1e-195L,1e-194L,1e-193L,1e-192L,1e-191L,
|
1e-210L, 1e-209L, 1e-208L, 1e-207L, 1e-206L, 1e-205L, 1e-204L, 1e-203L, 1e-202L, 1e-201L, 1e-200L, 1e-199L, 1e-198L, 1e-197L, 1e-196L, 1e-195L, 1e-194L, 1e-193L, 1e-192L, 1e-191L,
|
||||||
1e-190L,1e-189L,1e-188L,1e-187L,1e-186L,1e-185L,1e-184L,1e-183L,1e-182L,1e-181L,1e-180L,1e-179L,1e-178L,1e-177L,1e-176L,1e-175L,1e-174L,1e-173L,1e-172L,1e-171L,
|
1e-190L, 1e-189L, 1e-188L, 1e-187L, 1e-186L, 1e-185L, 1e-184L, 1e-183L, 1e-182L, 1e-181L, 1e-180L, 1e-179L, 1e-178L, 1e-177L, 1e-176L, 1e-175L, 1e-174L, 1e-173L, 1e-172L, 1e-171L,
|
||||||
1e-170L,1e-169L,1e-168L,1e-167L,1e-166L,1e-165L,1e-164L,1e-163L,1e-162L,1e-161L,1e-160L,1e-159L,1e-158L,1e-157L,1e-156L,1e-155L,1e-154L,1e-153L,1e-152L,1e-151L,
|
1e-170L, 1e-169L, 1e-168L, 1e-167L, 1e-166L, 1e-165L, 1e-164L, 1e-163L, 1e-162L, 1e-161L, 1e-160L, 1e-159L, 1e-158L, 1e-157L, 1e-156L, 1e-155L, 1e-154L, 1e-153L, 1e-152L, 1e-151L,
|
||||||
1e-150L,1e-149L,1e-148L,1e-147L,1e-146L,1e-145L,1e-144L,1e-143L,1e-142L,1e-141L,1e-140L,1e-139L,1e-138L,1e-137L,1e-136L,1e-135L,1e-134L,1e-133L,1e-132L,1e-131L,
|
1e-150L, 1e-149L, 1e-148L, 1e-147L, 1e-146L, 1e-145L, 1e-144L, 1e-143L, 1e-142L, 1e-141L, 1e-140L, 1e-139L, 1e-138L, 1e-137L, 1e-136L, 1e-135L, 1e-134L, 1e-133L, 1e-132L, 1e-131L,
|
||||||
1e-130L,1e-129L,1e-128L,1e-127L,1e-126L,1e-125L,1e-124L,1e-123L,1e-122L,1e-121L,1e-120L,1e-119L,1e-118L,1e-117L,1e-116L,1e-115L,1e-114L,1e-113L,1e-112L,1e-111L,
|
1e-130L, 1e-129L, 1e-128L, 1e-127L, 1e-126L, 1e-125L, 1e-124L, 1e-123L, 1e-122L, 1e-121L, 1e-120L, 1e-119L, 1e-118L, 1e-117L, 1e-116L, 1e-115L, 1e-114L, 1e-113L, 1e-112L, 1e-111L,
|
||||||
1e-110L,1e-109L,1e-108L,1e-107L,1e-106L,1e-105L,1e-104L,1e-103L,1e-102L,1e-101L,1e-100L,1e-99L,1e-98L,1e-97L,1e-96L,1e-95L,1e-94L,1e-93L,1e-92L,1e-91L,1e-90L,
|
1e-110L, 1e-109L, 1e-108L, 1e-107L, 1e-106L, 1e-105L, 1e-104L, 1e-103L, 1e-102L, 1e-101L, 1e-100L, 1e-99L, 1e-98L, 1e-97L, 1e-96L, 1e-95L, 1e-94L, 1e-93L, 1e-92L, 1e-91L, 1e-90L,
|
||||||
1e-89L,1e-88L,1e-87L,1e-86L,1e-85L,1e-84L,1e-83L,1e-82L,1e-81L,1e-80L,1e-79L,1e-78L,1e-77L,1e-76L,1e-75L,1e-74L,1e-73L,1e-72L,1e-71L,1e-70,
|
1e-89L, 1e-88L, 1e-87L, 1e-86L, 1e-85L, 1e-84L, 1e-83L, 1e-82L, 1e-81L, 1e-80L, 1e-79L, 1e-78L, 1e-77L, 1e-76L, 1e-75L, 1e-74L, 1e-73L, 1e-72L, 1e-71L, 1e-70,
|
||||||
1e-69L,1e-68L,1e-67L,1e-66L,1e-65L,1e-64L,1e-63L,1e-62L,1e-61L,1e-60L,1e-59L,1e-58L,1e-57L,1e-56L,1e-55L,1e-54L,1e-53L,1e-52L,1e-51L,1e-50,
|
1e-69L, 1e-68L, 1e-67L, 1e-66L, 1e-65L, 1e-64L, 1e-63L, 1e-62L, 1e-61L, 1e-60L, 1e-59L, 1e-58L, 1e-57L, 1e-56L, 1e-55L, 1e-54L, 1e-53L, 1e-52L, 1e-51L, 1e-50,
|
||||||
1e-49L,1e-48L,1e-47L,1e-46L,1e-45L,1e-44L,1e-43L,1e-42L,1e-41L,1e-40L,1e-39L,1e-38L,1e-37L,1e-36L,1e-35L,1e-34L,1e-33L,1e-32L,1e-31L,1e-30,
|
1e-49L, 1e-48L, 1e-47L, 1e-46L, 1e-45L, 1e-44L, 1e-43L, 1e-42L, 1e-41L, 1e-40L, 1e-39L, 1e-38L, 1e-37L, 1e-36L, 1e-35L, 1e-34L, 1e-33L, 1e-32L, 1e-31L, 1e-30,
|
||||||
1e-29L,1e-28L,1e-27L,1e-26L,1e-25L,1e-24L,1e-23L,1e-22L,1e-21L,1e-20L,1e-19L,1e-18L,1e-17L,1e-16L,1e-15L,1e-14L,1e-13L,1e-12L,1e-11L,1e-10,
|
1e-29L, 1e-28L, 1e-27L, 1e-26L, 1e-25L, 1e-24L, 1e-23L, 1e-22L, 1e-21L, 1e-20L, 1e-19L, 1e-18L, 1e-17L, 1e-16L, 1e-15L, 1e-14L, 1e-13L, 1e-12L, 1e-11L, 1e-10,
|
||||||
1e-9L,1e-8L,1e-7L,1e-6L,1e-5L,1e-4L,1e-3L,1e-2L,1e-1L,1e0L,1e1L,1e2L,1e3L,1e4L,1e5L,1e6L,1e7L,1e8L,1e9L,1e10,
|
1e-9L, 1e-8L, 1e-7L, 1e-6L, 1e-5L, 1e-4L, 1e-3L, 1e-2L, 1e-1L, 1e0L, 1e1L, 1e2L, 1e3L, 1e4L, 1e5L, 1e6L, 1e7L, 1e8L, 1e9L, 1e10,
|
||||||
1e11L,1e12L,1e13L,1e14L,1e15L,1e16L,1e17L,1e18L,1e19L,1e20L,1e21L,1e22L,1e23L,1e24L,1e25L,1e26L,1e27L,1e28L,1e29L,1e30,
|
1e11L, 1e12L, 1e13L, 1e14L, 1e15L, 1e16L, 1e17L, 1e18L, 1e19L, 1e20L, 1e21L, 1e22L, 1e23L, 1e24L, 1e25L, 1e26L, 1e27L, 1e28L, 1e29L, 1e30,
|
||||||
1e31L,1e32L,1e33L,1e34L,1e35L,1e36L,1e37L,1e38L,1e39L,1e40L,1e41L,1e42L,1e43L,1e44L,1e45L,1e46L,1e47L,1e48L,1e49L,1e50,
|
1e31L, 1e32L, 1e33L, 1e34L, 1e35L, 1e36L, 1e37L, 1e38L, 1e39L, 1e40L, 1e41L, 1e42L, 1e43L, 1e44L, 1e45L, 1e46L, 1e47L, 1e48L, 1e49L, 1e50,
|
||||||
1e51L,1e52L,1e53L,1e54L,1e55L,1e56L,1e57L,1e58L,1e59L,1e60L,1e61L,1e62L,1e63L,1e64L,1e65L,1e66L,1e67L,1e68L,1e69L,1e70,
|
1e51L, 1e52L, 1e53L, 1e54L, 1e55L, 1e56L, 1e57L, 1e58L, 1e59L, 1e60L, 1e61L, 1e62L, 1e63L, 1e64L, 1e65L, 1e66L, 1e67L, 1e68L, 1e69L, 1e70,
|
||||||
1e71L,1e72L,1e73L,1e74L,1e75L,1e76L,1e77L,1e78L,1e79L,1e80L,1e81L,1e82L,1e83L,1e84L,1e85L,1e86L,1e87L,1e88L,1e89L,1e90,
|
1e71L, 1e72L, 1e73L, 1e74L, 1e75L, 1e76L, 1e77L, 1e78L, 1e79L, 1e80L, 1e81L, 1e82L, 1e83L, 1e84L, 1e85L, 1e86L, 1e87L, 1e88L, 1e89L, 1e90,
|
||||||
1e91L,1e92L,1e93L,1e94L,1e95L,1e96L,1e97L,1e98L,1e99L,1e100L,1e101L,1e102L,1e103L,1e104L,1e105L,1e106L,1e107L,1e108L,1e109L,1e110,
|
1e91L, 1e92L, 1e93L, 1e94L, 1e95L, 1e96L, 1e97L, 1e98L, 1e99L, 1e100L, 1e101L, 1e102L, 1e103L, 1e104L, 1e105L, 1e106L, 1e107L, 1e108L, 1e109L, 1e110,
|
||||||
1e111L,1e112L,1e113L,1e114L,1e115L,1e116L,1e117L,1e118L,1e119L,1e120L,1e121L,1e122L,1e123L,1e124L,1e125L,1e126L,1e127L,1e128L,1e129L,1e130,
|
1e111L, 1e112L, 1e113L, 1e114L, 1e115L, 1e116L, 1e117L, 1e118L, 1e119L, 1e120L, 1e121L, 1e122L, 1e123L, 1e124L, 1e125L, 1e126L, 1e127L, 1e128L, 1e129L, 1e130,
|
||||||
1e131L,1e132L,1e133L,1e134L,1e135L,1e136L,1e137L,1e138L,1e139L,1e140L,1e141L,1e142L,1e143L,1e144L,1e145L,1e146L,1e147L,1e148L,1e149L,1e150,
|
1e131L, 1e132L, 1e133L, 1e134L, 1e135L, 1e136L, 1e137L, 1e138L, 1e139L, 1e140L, 1e141L, 1e142L, 1e143L, 1e144L, 1e145L, 1e146L, 1e147L, 1e148L, 1e149L, 1e150,
|
||||||
1e151L,1e152L,1e153L,1e154L,1e155L,1e156L,1e157L,1e158L,1e159L,1e160L,1e161L,1e162L,1e163L,1e164L,1e165L,1e166L,1e167L,1e168L,1e169L,1e170,
|
1e151L, 1e152L, 1e153L, 1e154L, 1e155L, 1e156L, 1e157L, 1e158L, 1e159L, 1e160L, 1e161L, 1e162L, 1e163L, 1e164L, 1e165L, 1e166L, 1e167L, 1e168L, 1e169L, 1e170,
|
||||||
1e171L,1e172L,1e173L,1e174L,1e175L,1e176L,1e177L,1e178L,1e179L,1e180L,1e181L,1e182L,1e183L,1e184L,1e185L,1e186L,1e187L,1e188L,1e189L,1e190,
|
1e171L, 1e172L, 1e173L, 1e174L, 1e175L, 1e176L, 1e177L, 1e178L, 1e179L, 1e180L, 1e181L, 1e182L, 1e183L, 1e184L, 1e185L, 1e186L, 1e187L, 1e188L, 1e189L, 1e190,
|
||||||
1e191L,1e192L,1e193L,1e194L,1e195L,1e196L,1e197L,1e198L,1e199L,1e200L,1e201L,1e202L,1e203L,1e204L,1e205L,1e206L,1e207L,1e208L,1e209L,1e210,
|
1e191L, 1e192L, 1e193L, 1e194L, 1e195L, 1e196L, 1e197L, 1e198L, 1e199L, 1e200L, 1e201L, 1e202L, 1e203L, 1e204L, 1e205L, 1e206L, 1e207L, 1e208L, 1e209L, 1e210,
|
||||||
1e211L,1e212L,1e213L,1e214L,1e215L,1e216L,1e217L,1e218L,1e219L,1e220L,1e221L,1e222L,1e223L,1e224L,1e225L,1e226L,1e227L,1e228L,1e229L,1e230,
|
1e211L, 1e212L, 1e213L, 1e214L, 1e215L, 1e216L, 1e217L, 1e218L, 1e219L, 1e220L, 1e221L, 1e222L, 1e223L, 1e224L, 1e225L, 1e226L, 1e227L, 1e228L, 1e229L, 1e230,
|
||||||
1e231L,1e232L,1e233L,1e234L,1e235L,1e236L,1e237L,1e238L,1e239L,1e240L,1e241L,1e242L,1e243L,1e244L,1e245L,1e246L,1e247L,1e248L,1e249L,1e250,
|
1e231L, 1e232L, 1e233L, 1e234L, 1e235L, 1e236L, 1e237L, 1e238L, 1e239L, 1e240L, 1e241L, 1e242L, 1e243L, 1e244L, 1e245L, 1e246L, 1e247L, 1e248L, 1e249L, 1e250,
|
||||||
1e251L,1e252L,1e253L,1e254L,1e255L,1e256L,1e257L,1e258L,1e259L,1e260L,1e261L,1e262L,1e263L,1e264L,1e265L,1e266L,1e267L,1e268L,1e269L,1e270,
|
1e251L, 1e252L, 1e253L, 1e254L, 1e255L, 1e256L, 1e257L, 1e258L, 1e259L, 1e260L, 1e261L, 1e262L, 1e263L, 1e264L, 1e265L, 1e266L, 1e267L, 1e268L, 1e269L, 1e270,
|
||||||
1e271L,1e272L,1e273L,1e274L,1e275L,1e276L,1e277L,1e278L,1e279L,1e280L,1e281L,1e282L,1e283L,1e284L,1e285L,1e286L,1e287L,1e288L,1e289L,1e290,
|
1e271L, 1e272L, 1e273L, 1e274L, 1e275L, 1e276L, 1e277L, 1e278L, 1e279L, 1e280L, 1e281L, 1e282L, 1e283L, 1e284L, 1e285L, 1e286L, 1e287L, 1e288L, 1e289L, 1e290,
|
||||||
1e291L,1e292L,1e293L,1e294L,1e295L,1e296L,1e297L,1e298L,1e299L,1e300L,1e301L,1e302L,1e303L,1e304L,1e305L,1e306L,1e307L,1e308L
|
1e291L, 1e292L, 1e293L, 1e294L, 1e295L, 1e296L, 1e297L, 1e298L, 1e299L, 1e300L, 1e301L, 1e302L, 1e303L, 1e304L, 1e305L, 1e306L, 1e307L, 1e308L
|
||||||
};
|
};
|
||||||
|
|
||||||
if (unlikely(exponent < min_exponent)) /// Note: there are some values below MIN_EXPONENT that is greater than zero.
|
if (unlikely(exponent < min_exponent)) /// Note: there are some values below MIN_EXPONENT that is greater than zero.
|
||||||
@ -52,7 +52,7 @@ static T shift10Impl(T x, int exponent)
|
|||||||
else if (unlikely(exponent > max_exponent))
|
else if (unlikely(exponent > max_exponent))
|
||||||
x *= std::numeric_limits<T>::infinity(); /// Multiplying to keep the sign of infinity.
|
x *= std::numeric_limits<T>::infinity(); /// Multiplying to keep the sign of infinity.
|
||||||
else
|
else
|
||||||
x *= powers10[exponent - min_exponent];
|
x *= static_cast<T>(powers10[exponent - min_exponent]);
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
@ -68,12 +68,12 @@ float shift10(float x, int exponent)
|
|||||||
return shift10Impl(x, exponent);
|
return shift10Impl(x, exponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
double shift10(UInt64 x, int exponent)
|
long double shift10(UInt64 x, int exponent)
|
||||||
{
|
{
|
||||||
return shift10Impl(static_cast<long double>(x), exponent);
|
return shift10Impl(static_cast<long double>(x), exponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
double shift10(Int64 x, int exponent)
|
long double shift10(Int64 x, int exponent)
|
||||||
{
|
{
|
||||||
return shift10Impl(static_cast<long double>(x), exponent);
|
return shift10Impl(static_cast<long double>(x), exponent);
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,5 @@
|
|||||||
double shift10(double x, int exponent);
|
double shift10(double x, int exponent);
|
||||||
float shift10(float x, int exponent);
|
float shift10(float x, int exponent);
|
||||||
|
|
||||||
double shift10(UInt64 x, int exponent);
|
long double shift10(UInt64 x, int exponent);
|
||||||
double shift10(Int64 x, int exponent);
|
long double shift10(Int64 x, int exponent);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <base/sleep.h>
|
#include <base/sleep.h>
|
||||||
|
|
||||||
#include <time.h>
|
#include <ctime>
|
||||||
#include <errno.h>
|
#include <cerrno>
|
||||||
|
|
||||||
#if defined(OS_DARWIN)
|
#if defined(OS_DARWIN)
|
||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user