diff --git a/docker/test/fuzzer/run-fuzzer.sh b/docker/test/fuzzer/run-fuzzer.sh index 626bedb453c..670fc9e58b3 100755 --- a/docker/test/fuzzer/run-fuzzer.sh +++ b/docker/test/fuzzer/run-fuzzer.sh @@ -56,17 +56,19 @@ function watchdog sleep 3600 echo "Fuzzing run has timed out" - killall clickhouse-client ||: for _ in {1..10} do - if ! pgrep -f clickhouse-client + # Only kill by pid the particular client that runs the fuzzing, or else + # we can kill some clickhouse-client processes this script starts later, + # e.g. for checking server liveness. + if ! kill $fuzzer_pid then break fi sleep 1 done - killall -9 clickhouse-client ||: + kill -9 -- $fuzzer_pid ||: } function filter_exists @@ -85,7 +87,7 @@ function fuzz { # Obtain the list of newly added tests. They will be fuzzed in more extreme way than other tests. # Don't overwrite the NEW_TESTS_OPT so that it can be set from the environment. - NEW_TESTS="$(grep -P 'tests/queries/0_stateless/.*\.sql' ci-changed-files.txt | sed -r -e 's!^!ch/!' | sort -R)" + NEW_TESTS="$(sed -n 's!\(^tests/queries/0_stateless/.*\.sql\)$!ch/\1!p' ci-changed-files.txt | sort -R)" # ci-changed-files.txt contains also files that has been deleted/renamed, filter them out. NEW_TESTS="$(filter_exists $NEW_TESTS)" if [[ -n "$NEW_TESTS" ]] @@ -115,17 +117,49 @@ continue gdb -batch -command script.gdb -p "$(pidof clickhouse-server)" & - fuzzer_exit_code=0 # SC2012: Use find instead of ls to better handle non-alphanumeric filenames. They are all alphanumeric. # SC2046: Quote this to prevent word splitting. Actually I need word splitting. # shellcheck disable=SC2012,SC2046 clickhouse-client --query-fuzzer-runs=1000 --queries-file $(ls -1 ch/tests/queries/0_stateless/*.sql | sort -R) $NEW_TESTS_OPT \ > >(tail -n 100000 > fuzzer.log) \ - 2>&1 \ - || fuzzer_exit_code=$? + 2>&1 & + fuzzer_pid=$! + echo "Fuzzer pid is $fuzzer_pid" + # Start a watchdog that should kill the fuzzer on timeout. + # The shell won't kill the child sleep when we kill it, so we have to put it + # into a separate process group so that we can kill them all. + set -m + watchdog & + watchdog_pid=$! + set +m + # Check that the watchdog has started. + kill -0 $watchdog_pid + + # Wait for the fuzzer to complete. + # Note that the 'wait || ...' thing is required so that the script doesn't + # exit because of 'set -e' when 'wait' returns nonzero code. + fuzzer_exit_code=0 + wait "$fuzzer_pid" || fuzzer_exit_code=$? echo "Fuzzer exit code is $fuzzer_exit_code" + kill -- -$watchdog_pid ||: + + # If the server dies, most often the fuzzer returns code 210: connetion + # refused, and sometimes also code 32: attempt to read after eof. For + # simplicity, check again whether the server is accepting connections, using + # clickhouse-client. We don't check for existence of server process, because + # the process is still present while the server is terminating and not + # accepting the connections anymore. + if clickhouse-client --query "select 1 format Null" + then + server_died=0 + else + echo "Server live check returns $?" + server_died=1 + fi + + # Stop the server. clickhouse-client --query "select elapsed, query from system.processes" ||: killall clickhouse-server ||: for _ in {1..10} @@ -137,6 +171,41 @@ continue sleep 1 done killall -9 clickhouse-server ||: + + # Debug. + date + sleep 10 + jobs + pstree -aspgT + + # Make files with status and description we'll show for this check on Github. + task_exit_code=$fuzzer_exit_code + if [ "$server_died" == 1 ] + then + # The server has died. + task_exit_code=210 + echo "failure" > status.txt + if ! grep -ao "Received signal.*\|Logical error.*\|Assertion.*failed\|Failed assertion.*\|.*runtime error: .*\|.*is located.*\|SUMMARY: AddressSanitizer:.*\|SUMMARY: MemorySanitizer:.*\|SUMMARY: ThreadSanitizer:.*\|.*_LIBCPP_ASSERT.*" server.log > description.txt + then + echo "Lost connection to server. See the logs." > description.txt + fi + elif [ "$fuzzer_exit_code" == "143" ] || [ "$fuzzer_exit_code" == "0" ] + then + # Variants of a normal run: + # 0 -- fuzzing ended earlier than timeout. + # 143 -- SIGTERM -- the fuzzer was killed by timeout. + task_exit_code=0 + echo "success" > status.txt + echo "OK" > description.txt + else + # The server was alive, but the fuzzer returned some error. Probably this + # is a problem in the fuzzer itself. Don't grep the server log in this + # case, because we will find a message about normal server termination + # (Received signal 15), which is confusing. + task_exit_code=$fuzzer_exit_code + echo "failure" > status.txt + echo "Fuzzer failed ($fuzzer_exit_code). See the logs." > description.txt + fi } case "$stage" in @@ -165,50 +234,7 @@ case "$stage" in time configure ;& "fuzz") - # Start a watchdog that should kill the fuzzer on timeout. - # The shell won't kill the child sleep when we kill it, so we have to put it - # into a separate process group so that we can kill them all. - set -m - watchdog & - watchdog_pid=$! - set +m - # Check that the watchdog has started - kill -0 $watchdog_pid - - fuzzer_exit_code=0 - time fuzz || fuzzer_exit_code=$? - kill -- -$watchdog_pid ||: - - # Debug - date - sleep 10 - jobs - pstree -aspgT - - # Make files with status and description we'll show for this check on Github - task_exit_code=$fuzzer_exit_code - if [ "$fuzzer_exit_code" == 143 ] - then - # SIGTERM -- the fuzzer was killed by timeout, which means a normal run. - echo "success" > status.txt - echo "OK" > description.txt - task_exit_code=0 - elif [ "$fuzzer_exit_code" == 210 ] - then - # Lost connection to the server. This probably means that the server died - # with abort. - echo "failure" > status.txt - if ! grep -ao "Received signal.*\|Logical error.*\|Assertion.*failed\|Failed assertion.*\|.*runtime error: .*\|.*is located.*\|SUMMARY: AddressSanitizer:.*\|SUMMARY: MemorySanitizer:.*\|SUMMARY: ThreadSanitizer:.*\|.*_LIBCPP_ASSERT.*" server.log > description.txt - then - echo "Lost connection to server. See the logs." > description.txt - fi - else - # Something different -- maybe the fuzzer itself died? Don't grep the - # server log in this case, because we will find a message about normal - # server termination (Received signal 15), which is confusing. - echo "failure" > status.txt - echo "Fuzzer failed ($fuzzer_exit_code). See the logs." > description.txt - fi + time fuzz ;& "report") cat > report.html < diff --git a/docs/en/sql-reference/aggregate-functions/reference/rankCorr.md b/docs/en/sql-reference/aggregate-functions/reference/rankCorr.md index 55ee1b8289b..b364317c22b 100644 --- a/docs/en/sql-reference/aggregate-functions/reference/rankCorr.md +++ b/docs/en/sql-reference/aggregate-functions/reference/rankCorr.md @@ -1,4 +1,8 @@ -## rankCorr {#agg_function-rankcorr} +--- +toc_priority: 145 +--- + +# rankCorr {#agg_function-rankcorr} Computes a rank correlation coefficient. diff --git a/docs/en/sql-reference/aggregate-functions/reference/sumcount.md b/docs/en/sql-reference/aggregate-functions/reference/sumcount.md new file mode 100644 index 00000000000..80e87663f89 --- /dev/null +++ b/docs/en/sql-reference/aggregate-functions/reference/sumcount.md @@ -0,0 +1,46 @@ +--- +toc_priority: 144 +--- + +# sumCount {#agg_function-sumCount} + +Calculates the sum of the numbers and counts the number of rows at the same time. + +**Syntax** + +``` sql +sumCount(x) +``` + +**Arguments** + +- `x` — Input value, must be [Integer](../../../sql-reference/data-types/int-uint.md), [Float](../../../sql-reference/data-types/float.md), or [Decimal](../../../sql-reference/data-types/decimal.md). + +**Returned value** + +- Tuple `(sum, count)`, where `sum` is the sum of numbers and `count` is the number of rows with not-NULL values. + +Type: [Tuple](../../../sql-reference/data-types/tuple.md). + +**Example** + +Query: + +``` sql +CREATE TABLE s_table (x Int8) Engine = Log; +INSERT INTO s_table SELECT number FROM numbers(0, 20); +INSERT INTO s_table VALUES (NULL); +SELECT sumCount(x) from s_table; +``` + +Result: + +``` text +┌─sumCount(x)─┐ +│ (190,20) │ +└─────────────┘ +``` + +**See also** + +- [optimize_fuse_sum_count_avg](../../../operations/settings/settings.md#optimize_fuse_sum_count_avg) setting. diff --git a/docs/en/sql-reference/functions/ext-dict-functions.md b/docs/en/sql-reference/functions/ext-dict-functions.md index 5b94c61c3d2..e54e3f7d4cc 100644 --- a/docs/en/sql-reference/functions/ext-dict-functions.md +++ b/docs/en/sql-reference/functions/ext-dict-functions.md @@ -4,7 +4,7 @@ toc_title: External Dictionaries --- !!! attention "Attention" - `dict_name` parameter must be fully qualified for dictionaries created with DDL queries. Eg. `.`. + For dictionaries, created with [DDL queries](../../sql-reference/statements/create/dictionary.md), the `dict_name` parameter must be fully specified, like `.`. Otherwise, the current database is used. # Functions for Working with External Dictionaries {#ext_dict_functions} diff --git a/docs/ru/operations/settings/settings.md b/docs/ru/operations/settings/settings.md index aa235625cfe..ada8ee91293 100644 --- a/docs/ru/operations/settings/settings.md +++ b/docs/ru/operations/settings/settings.md @@ -2924,4 +2924,36 @@ SELECT * FROM test LIMIT 10 OFFSET 100; Значение по умолчанию: `1800`. +## optimize_fuse_sum_count_avg {#optimize_fuse_sum_count_avg} + +Позволяет объединить агрегатные функции с одинаковым аргументом. Запрос, содержащий по крайней мере две агрегатные функции: [sum](../../sql-reference/aggregate-functions/reference/sum.md#agg_function-sum), [count](../../sql-reference/aggregate-functions/reference/count.md#agg_function-count) или [avg](../../sql-reference/aggregate-functions/reference/avg.md#agg_function-avg) с одинаковым аргументом, перезаписывается как [sumCount](../../sql-reference/aggregate-functions/reference/sumcount.md#agg_function-sumCount). + +Возможные значения: + +- 0 — функции с одинаковым аргументом не объединяются. +- 1 — функции с одинаковым аргументом объединяются. + +Значение по умолчанию: `0`. + +**Пример** + +Запрос: + +``` sql +CREATE TABLE fuse_tbl(a Int8, b Int8) Engine = Log; +SET optimize_fuse_sum_count_avg = 1; +EXPLAIN SYNTAX SELECT sum(a), sum(b), count(b), avg(b) from fuse_tbl FORMAT TSV; +``` + +Результат: + +``` text +SELECT + sum(a), + sumCount(b).1, + sumCount(b).2, + (sumCount(b).1) / (sumCount(b).2) +FROM fuse_tbl +``` + [Оригинальная статья](https://clickhouse.tech/docs/ru/operations/settings/settings/) diff --git a/docs/ru/sql-reference/aggregate-functions/reference/rankCorr.md b/docs/ru/sql-reference/aggregate-functions/reference/rankCorr.md index c98e7b88bcf..73d0552fc6f 100644 --- a/docs/ru/sql-reference/aggregate-functions/reference/rankCorr.md +++ b/docs/ru/sql-reference/aggregate-functions/reference/rankCorr.md @@ -1,4 +1,8 @@ -## rankCorr {#agg_function-rankcorr} +--- +toc_priority: 145 +--- + +# rankCorr {#agg_function-rankcorr} Вычисляет коэффициент ранговой корреляции. diff --git a/docs/ru/sql-reference/aggregate-functions/reference/sumcount.md b/docs/ru/sql-reference/aggregate-functions/reference/sumcount.md new file mode 100644 index 00000000000..0606b06fba0 --- /dev/null +++ b/docs/ru/sql-reference/aggregate-functions/reference/sumcount.md @@ -0,0 +1,46 @@ +--- +toc_priority: 144 +--- + +# sumCount {#agg_function-sumCount} + +Вычисляет сумму чисел и одновременно подсчитывает количество строк. + +**Синтаксис** + +``` sql +sumCount(x) +``` + +**Аргументы** + +- `x` — Входное значение типа [Integer](../../../sql-reference/data-types/int-uint.md), [Float](../../../sql-reference/data-types/float.md), или [Decimal](../../../sql-reference/data-types/decimal.md). + +**Возвращаемое значение** + +- Кортеж из элементов `(sum, count)`, где `sum` — это сумма чисел и `count` — количество строк со значениями, отличными от `NULL`. + +Тип: [Tuple](../../../sql-reference/data-types/tuple.md). + +**Пример** + +Запрос: + +``` sql +CREATE TABLE s_table (x Nullable(Int8)) Engine = Log; +INSERT INTO s_table SELECT number FROM numbers(0, 20); +INSERT INTO s_table VALUES (NULL); +SELECT sumCount(x) from s_table; +``` + +Результат: + +``` text +┌─sumCount(x)─┐ +│ (190,20) │ +└─────────────┘ +``` + +**Смотрите также** + +- Настройка [optimize_fuse_sum_count_avg](../../../operations/settings/settings.md#optimize_fuse_sum_count_avg) diff --git a/docs/ru/sql-reference/functions/ext-dict-functions.md b/docs/ru/sql-reference/functions/ext-dict-functions.md index be91145659e..04b04104042 100644 --- a/docs/ru/sql-reference/functions/ext-dict-functions.md +++ b/docs/ru/sql-reference/functions/ext-dict-functions.md @@ -3,6 +3,9 @@ toc_priority: 58 toc_title: "Функции для работы с внешними словарями" --- +!!! attention "Внимание" + Для словарей, созданных с помощью [DDL-запросов](../../sql-reference/statements/create/dictionary.md), в параметре `dict_name` указывается полное имя словаря вместе с базой данных, например: `.`. Если база данных не указана, используется текущая. + # Функции для работы с внешними словарями {#ext_dict_functions} Информацию о подключении и настройке внешних словарей смотрите в разделе [Внешние словари](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md). diff --git a/src/AggregateFunctions/AggregateFunctionFactory.cpp b/src/AggregateFunctions/AggregateFunctionFactory.cpp index c84a04cc872..bdc057817c9 100644 --- a/src/AggregateFunctions/AggregateFunctionFactory.cpp +++ b/src/AggregateFunctions/AggregateFunctionFactory.cpp @@ -89,6 +89,17 @@ AggregateFunctionPtr AggregateFunctionFactory::get( AggregateFunctionPtr nested_function = getImpl( name, nested_types, nested_parameters, out_properties, has_null_arguments); + + // Pure window functions are not real aggregate functions. Applying + // combinators doesn't make sense for them, they must handle the + // nullability themselves. Another special case is functions from Nothing + // that are rewritten to AggregateFunctionNothing, in this case + // nested_function is nullptr. + if (nested_function && nested_function->asWindowFunction()) + { + return nested_function; + } + return combinator->transformAggregateFunction(nested_function, out_properties, type_without_low_cardinality, parameters); } @@ -122,7 +133,7 @@ AggregateFunctionPtr AggregateFunctionFactory::getImpl( is_case_insensitive = true; } - ContextPtr query_context; + ContextConstPtr query_context; if (CurrentThread::isInitialized()) query_context = CurrentThread::get().getQueryContext(); diff --git a/src/AggregateFunctions/AggregateFunctionMLMethod.cpp b/src/AggregateFunctions/AggregateFunctionMLMethod.cpp index 0b6764960fb..e7f79c276ed 100644 --- a/src/AggregateFunctions/AggregateFunctionMLMethod.cpp +++ b/src/AggregateFunctions/AggregateFunctionMLMethod.cpp @@ -148,7 +148,7 @@ void LinearModelData::predict( const ColumnsWithTypeAndName & arguments, size_t offset, size_t limit, - ContextPtr context) const + ContextConstPtr context) const { gradient_computer->predict(container, arguments, offset, limit, weights, bias, context); } @@ -455,7 +455,7 @@ void LogisticRegression::predict( size_t limit, const std::vector & weights, Float64 bias, - ContextPtr /*context*/) const + ContextConstPtr /*context*/) const { size_t rows_num = arguments.front().column->size(); @@ -523,7 +523,7 @@ void LinearRegression::predict( size_t limit, const std::vector & weights, Float64 bias, - ContextPtr /*context*/) const + ContextConstPtr /*context*/) const { if (weights.size() + 1 != arguments.size()) { diff --git a/src/AggregateFunctions/AggregateFunctionMLMethod.h b/src/AggregateFunctions/AggregateFunctionMLMethod.h index 91302269759..a97b565eed3 100644 --- a/src/AggregateFunctions/AggregateFunctionMLMethod.h +++ b/src/AggregateFunctions/AggregateFunctionMLMethod.h @@ -46,7 +46,7 @@ public: size_t limit, const std::vector & weights, Float64 bias, - ContextPtr context) const = 0; + ContextConstPtr context) const = 0; }; @@ -71,7 +71,7 @@ public: size_t limit, const std::vector & weights, Float64 bias, - ContextPtr context) const override; + ContextConstPtr context) const override; }; @@ -96,7 +96,7 @@ public: size_t limit, const std::vector & weights, Float64 bias, - ContextPtr context) const override; + ContextConstPtr context) const override; }; @@ -266,7 +266,7 @@ public: const ColumnsWithTypeAndName & arguments, size_t offset, size_t limit, - ContextPtr context) const; + ContextConstPtr context) const; void returnWeights(IColumn & to) const; private: @@ -367,7 +367,7 @@ public: const ColumnsWithTypeAndName & arguments, size_t offset, size_t limit, - ContextPtr context) const override + ContextConstPtr context) const override { if (arguments.size() != param_num + 1) throw Exception( diff --git a/src/AggregateFunctions/IAggregateFunction.h b/src/AggregateFunctions/IAggregateFunction.h index a05f71a61c8..2d47a1e7fe0 100644 --- a/src/AggregateFunctions/IAggregateFunction.h +++ b/src/AggregateFunctions/IAggregateFunction.h @@ -123,7 +123,7 @@ public: const ColumnsWithTypeAndName & /*arguments*/, size_t /*offset*/, size_t /*limit*/, - ContextPtr /*context*/) const + ContextConstPtr /*context*/) const { throw Exception("Method predictValues is not supported for " + getName(), ErrorCodes::NOT_IMPLEMENTED); } diff --git a/src/Bridge/IBridgeHelper.h b/src/Bridge/IBridgeHelper.h index caaf031b7d8..34be69a7db7 100644 --- a/src/Bridge/IBridgeHelper.h +++ b/src/Bridge/IBridgeHelper.h @@ -14,7 +14,7 @@ namespace DB /// Common base class for XDBC and Library bridge helpers. /// Contains helper methods to check/start bridge sync. -class IBridgeHelper: protected WithContext +class IBridgeHelper: protected WithConstContext { public: @@ -27,7 +27,7 @@ public: static const inline std::string PING_METHOD = Poco::Net::HTTPRequest::HTTP_GET; static const inline std::string MAIN_METHOD = Poco::Net::HTTPRequest::HTTP_POST; - explicit IBridgeHelper(ContextPtr context_) : WithContext(context_) {} + explicit IBridgeHelper(ContextConstPtr context_) : WithConstContext(context_) {} virtual ~IBridgeHelper() = default; void startBridgeSync() const; diff --git a/src/Bridge/LibraryBridgeHelper.cpp b/src/Bridge/LibraryBridgeHelper.cpp index c589d0ce09e..8234b5d755f 100644 --- a/src/Bridge/LibraryBridgeHelper.cpp +++ b/src/Bridge/LibraryBridgeHelper.cpp @@ -21,7 +21,7 @@ namespace DB { LibraryBridgeHelper::LibraryBridgeHelper( - ContextPtr context_, + ContextConstPtr context_, const Block & sample_block_, const Field & dictionary_id_) : IBridgeHelper(context_->getGlobalContext()) diff --git a/src/Bridge/LibraryBridgeHelper.h b/src/Bridge/LibraryBridgeHelper.h index 12fe0c33363..c3c42e85f93 100644 --- a/src/Bridge/LibraryBridgeHelper.h +++ b/src/Bridge/LibraryBridgeHelper.h @@ -17,7 +17,7 @@ class LibraryBridgeHelper : public IBridgeHelper public: static constexpr inline size_t DEFAULT_PORT = 9012; - LibraryBridgeHelper(ContextPtr context_, const Block & sample_block, const Field & dictionary_id_); + LibraryBridgeHelper(ContextConstPtr context_, const Block & sample_block, const Field & dictionary_id_); bool initLibrary(const std::string & library_path, std::string library_settings, std::string attributes_names); diff --git a/src/Bridge/XDBCBridgeHelper.h b/src/Bridge/XDBCBridgeHelper.h index 299df6ff888..ee6a178037d 100644 --- a/src/Bridge/XDBCBridgeHelper.h +++ b/src/Bridge/XDBCBridgeHelper.h @@ -62,7 +62,7 @@ public: static constexpr inline auto SCHEMA_ALLOWED_HANDLER = "/schema_allowed"; XDBCBridgeHelper( - ContextPtr context_, + ContextConstPtr context_, Poco::Timespan http_timeout_, const std::string & connection_string_) : IXDBCBridgeHelper(context_->getGlobalContext()) diff --git a/src/Columns/ColumnAggregateFunction.cpp b/src/Columns/ColumnAggregateFunction.cpp index 8178802f3bd..a5bfcae05e4 100644 --- a/src/Columns/ColumnAggregateFunction.cpp +++ b/src/Columns/ColumnAggregateFunction.cpp @@ -162,7 +162,7 @@ MutableColumnPtr ColumnAggregateFunction::convertToValues(MutableColumnPtr colum return res; } -MutableColumnPtr ColumnAggregateFunction::predictValues(const ColumnsWithTypeAndName & arguments, ContextPtr context) const +MutableColumnPtr ColumnAggregateFunction::predictValues(const ColumnsWithTypeAndName & arguments, ContextConstPtr context) const { MutableColumnPtr res = func->getReturnTypeToPredict()->createColumn(); res->reserve(data.size()); diff --git a/src/Columns/ColumnAggregateFunction.h b/src/Columns/ColumnAggregateFunction.h index 8eb1a04b174..e75af280ed5 100644 --- a/src/Columns/ColumnAggregateFunction.h +++ b/src/Columns/ColumnAggregateFunction.h @@ -119,7 +119,7 @@ public: const char * getFamilyName() const override { return "AggregateFunction"; } TypeIndex getDataType() const override { return TypeIndex::AggregateFunction; } - MutableColumnPtr predictValues(const ColumnsWithTypeAndName & arguments, ContextPtr context) const; + MutableColumnPtr predictValues(const ColumnsWithTypeAndName & arguments, ContextConstPtr context) const; size_t size() const override { diff --git a/src/Common/FileChecker.cpp b/src/Common/FileChecker.cpp index e7fcc8cadb7..173c4bd8a3a 100644 --- a/src/Common/FileChecker.cpp +++ b/src/Common/FileChecker.cpp @@ -21,7 +21,15 @@ namespace ErrorCodes FileChecker::FileChecker(DiskPtr disk_, const String & file_info_path_) : disk(std::move(disk_)) { setPath(file_info_path_); - load(); + try + { + load(); + } + catch (DB::Exception & e) + { + e.addMessage("Error loading file {}", files_info_path); + throw; + } } void FileChecker::setPath(const String & file_info_path_) diff --git a/src/Common/MemoryTracker.cpp b/src/Common/MemoryTracker.cpp index e9ad40075e6..a05fa3b5ad5 100644 --- a/src/Common/MemoryTracker.cpp +++ b/src/Common/MemoryTracker.cpp @@ -173,7 +173,7 @@ void MemoryTracker::allocImpl(Int64 size, bool throw_if_memory_exceeded) } #ifdef MEMORY_TRACKER_DEBUG_CHECKS - if (unlikely(_memory_tracker_always_throw_logical_error_on_allocation) && throw_if_memory_exceeded) + if (unlikely(_memory_tracker_always_throw_logical_error_on_allocation)) { _memory_tracker_always_throw_logical_error_on_allocation = false; throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "Memory tracker: allocations not allowed."); diff --git a/src/DataTypes/DataTypeDecimalBase.cpp b/src/DataTypes/DataTypeDecimalBase.cpp index 683710b8880..830b22b5943 100644 --- a/src/DataTypes/DataTypeDecimalBase.cpp +++ b/src/DataTypes/DataTypeDecimalBase.cpp @@ -19,11 +19,11 @@ namespace ErrorCodes { } -bool decimalCheckComparisonOverflow(ContextPtr context) +bool decimalCheckComparisonOverflow(ContextConstPtr context) { return context->getSettingsRef().decimal_check_overflow; } -bool decimalCheckArithmeticOverflow(ContextPtr context) +bool decimalCheckArithmeticOverflow(ContextConstPtr context) { return context->getSettingsRef().decimal_check_overflow; } diff --git a/src/DataTypes/DataTypeDecimalBase.h b/src/DataTypes/DataTypeDecimalBase.h index aea837f890f..17b73a8e3d6 100644 --- a/src/DataTypes/DataTypeDecimalBase.h +++ b/src/DataTypes/DataTypeDecimalBase.h @@ -18,8 +18,8 @@ namespace ErrorCodes extern const int ARGUMENT_OUT_OF_BOUND; } -bool decimalCheckComparisonOverflow(ContextPtr context); -bool decimalCheckArithmeticOverflow(ContextPtr context); +bool decimalCheckComparisonOverflow(ContextConstPtr context); +bool decimalCheckArithmeticOverflow(ContextConstPtr context); inline UInt32 leastDecimalPrecisionFor(TypeIndex int_type) { diff --git a/src/Dictionaries/CassandraDictionarySource.cpp b/src/Dictionaries/CassandraDictionarySource.cpp index 7605b86ef90..b91ce6c82c9 100644 --- a/src/Dictionaries/CassandraDictionarySource.cpp +++ b/src/Dictionaries/CassandraDictionarySource.cpp @@ -17,7 +17,7 @@ void registerDictionarySourceCassandra(DictionarySourceFactory & factory) [[maybe_unused]] const Poco::Util::AbstractConfiguration & config, [[maybe_unused]] const std::string & config_prefix, [[maybe_unused]] Block & sample_block, - ContextPtr /* context */, + ContextConstPtr /* context */, const std::string & /* default_database */, bool /*created_from_ddl*/) -> DictionarySourcePtr { diff --git a/src/Dictionaries/ClickHouseDictionarySource.cpp b/src/Dictionaries/ClickHouseDictionarySource.cpp index 776e74672b4..9e44a7b442d 100644 --- a/src/Dictionaries/ClickHouseDictionarySource.cpp +++ b/src/Dictionaries/ClickHouseDictionarySource.cpp @@ -27,7 +27,7 @@ namespace { constexpr size_t MAX_CONNECTIONS = 16; - inline UInt16 getPortFromContext(ContextPtr context, bool secure) + inline UInt16 getPortFromContext(ContextConstPtr context, bool secure) { return secure ? context->getTCPPortSecure().value_or(0) : context->getTCPPort(); } @@ -60,7 +60,7 @@ ClickHouseDictionarySource::ClickHouseDictionarySource( const DictionaryStructure & dict_struct_, const Configuration & configuration_, const Block & sample_block_, - ContextPtr context_) + ContextConstPtr context_) : update_time{std::chrono::system_clock::from_time_t(0)} , dict_struct{dict_struct_} , configuration{configuration_} @@ -209,7 +209,7 @@ void registerDictionarySourceClickHouse(DictionarySourceFactory & factory) const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, Block & sample_block, - ContextPtr context, + ContextConstPtr context, const std::string & default_database [[maybe_unused]], bool /* created_from_ddl */) -> DictionarySourcePtr { diff --git a/src/Dictionaries/ClickHouseDictionarySource.h b/src/Dictionaries/ClickHouseDictionarySource.h index d96330f9bdb..a16b2f18680 100644 --- a/src/Dictionaries/ClickHouseDictionarySource.h +++ b/src/Dictionaries/ClickHouseDictionarySource.h @@ -37,7 +37,7 @@ public: const DictionaryStructure & dict_struct_, const Configuration & configuration_, const Block & sample_block_, - ContextPtr context); + ContextConstPtr context); /// copy-constructor is provided in order to support cloneability ClickHouseDictionarySource(const ClickHouseDictionarySource & other); diff --git a/src/Dictionaries/DictionaryFactory.cpp b/src/Dictionaries/DictionaryFactory.cpp index 62b28ed7d14..1f23200a745 100644 --- a/src/Dictionaries/DictionaryFactory.cpp +++ b/src/Dictionaries/DictionaryFactory.cpp @@ -31,7 +31,7 @@ DictionaryPtr DictionaryFactory::create( const std::string & name, const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, - ContextPtr context, + ContextConstPtr context, bool created_from_ddl) const { Poco::Util::AbstractConfiguration::Keys keys; @@ -68,7 +68,7 @@ DictionaryPtr DictionaryFactory::create( layout_type); } -DictionaryPtr DictionaryFactory::create(const std::string & name, const ASTCreateQuery & ast, ContextPtr context) const +DictionaryPtr DictionaryFactory::create(const std::string & name, const ASTCreateQuery & ast, ContextConstPtr context) const { auto configuration = getDictionaryConfigurationFromAST(ast, context); return DictionaryFactory::create(name, *configuration, "dictionary", context, true); diff --git a/src/Dictionaries/DictionaryFactory.h b/src/Dictionaries/DictionaryFactory.h index b717009aa8a..a261c377cad 100644 --- a/src/Dictionaries/DictionaryFactory.h +++ b/src/Dictionaries/DictionaryFactory.h @@ -36,13 +36,13 @@ public: const std::string & name, const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, - ContextPtr context, + ContextConstPtr context, bool created_from_ddl) const; /// Create dictionary from DDL-query DictionaryPtr create(const std::string & name, const ASTCreateQuery & ast, - ContextPtr context) const; + ContextConstPtr context) const; using LayoutCreateFunction = std::function; bool isComplex(const std::string & layout_type) const; diff --git a/src/Dictionaries/DictionarySourceFactory.cpp b/src/Dictionaries/DictionarySourceFactory.cpp index 50ba6405074..507d11eba8e 100644 --- a/src/Dictionaries/DictionarySourceFactory.cpp +++ b/src/Dictionaries/DictionarySourceFactory.cpp @@ -79,7 +79,7 @@ DictionarySourcePtr DictionarySourceFactory::create( const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, const DictionaryStructure & dict_struct, - ContextPtr context, + ContextConstPtr context, const std::string & default_database, bool check_config) const { diff --git a/src/Dictionaries/DictionarySourceFactory.h b/src/Dictionaries/DictionarySourceFactory.h index bb583927ac4..9a0235a5eb0 100644 --- a/src/Dictionaries/DictionarySourceFactory.h +++ b/src/Dictionaries/DictionarySourceFactory.h @@ -35,7 +35,7 @@ public: const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, Block & sample_block, - ContextPtr context, + ContextConstPtr context, const std::string & default_database, bool check_config)>; @@ -48,7 +48,7 @@ public: const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, const DictionaryStructure & dict_struct, - ContextPtr context, + ContextConstPtr context, const std::string & default_database, bool check_config) const; diff --git a/src/Dictionaries/DictionarySourceHelpers.cpp b/src/Dictionaries/DictionarySourceHelpers.cpp index e175c6c3eae..6ba4f63be66 100644 --- a/src/Dictionaries/DictionarySourceHelpers.cpp +++ b/src/Dictionaries/DictionarySourceHelpers.cpp @@ -69,7 +69,7 @@ Block blockForKeys( ContextPtr copyContextAndApplySettings( const std::string & config_prefix, - ContextPtr context, + ContextConstPtr context, const Poco::Util::AbstractConfiguration & config) { auto local_context = Context::createCopy(context); diff --git a/src/Dictionaries/DictionarySourceHelpers.h b/src/Dictionaries/DictionarySourceHelpers.h index 1febf921e07..aa0219449e3 100644 --- a/src/Dictionaries/DictionarySourceHelpers.h +++ b/src/Dictionaries/DictionarySourceHelpers.h @@ -39,12 +39,7 @@ Block blockForKeys( /// Used for applying settings to copied context in some register[...]Source functions ContextPtr copyContextAndApplySettings( const std::string & config_prefix, - ContextPtr context, - const Poco::Util::AbstractConfiguration & config); - -void applySettingsToContext( - const std::string & config_prefix, - ContextPtr context, + ContextConstPtr context, const Poco::Util::AbstractConfiguration & config); /** A stream, adds additional columns to each block that it will read from inner stream. diff --git a/src/Dictionaries/DirectDictionary.cpp b/src/Dictionaries/DirectDictionary.cpp index 0508a0d70ad..2cc1d6caf5f 100644 --- a/src/Dictionaries/DirectDictionary.cpp +++ b/src/Dictionaries/DirectDictionary.cpp @@ -306,7 +306,7 @@ namespace const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, DictionarySourcePtr source_ptr, - ContextPtr /* context */, + ContextConstPtr /* context */, bool /* created_from_ddl */) { const auto * layout_name = dictionary_key_type == DictionaryKeyType::simple ? "direct" : "complex_key_direct"; diff --git a/src/Dictionaries/ExecutableDictionarySource.cpp b/src/Dictionaries/ExecutableDictionarySource.cpp index 55d06984df4..2fb1bcf89ac 100644 --- a/src/Dictionaries/ExecutableDictionarySource.cpp +++ b/src/Dictionaries/ExecutableDictionarySource.cpp @@ -63,7 +63,7 @@ ExecutableDictionarySource::ExecutableDictionarySource( const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, Block & sample_block_, - ContextPtr context_) + ContextConstPtr context_) : log(&Poco::Logger::get("ExecutableDictionarySource")) , dict_struct{dict_struct_} , implicit_key{config.getBool(config_prefix + ".implicit_key", false)} @@ -140,7 +140,7 @@ namespace { public: BlockInputStreamWithBackgroundThread( - ContextPtr context, + ContextConstPtr context, const std::string & format, const Block & sample_block, const std::string & command_str, @@ -265,7 +265,7 @@ void registerDictionarySourceExecutable(DictionarySourceFactory & factory) const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, Block & sample_block, - ContextPtr context, + ContextConstPtr context, const std::string & /* default_database */, bool created_from_ddl) -> DictionarySourcePtr { diff --git a/src/Dictionaries/ExecutableDictionarySource.h b/src/Dictionaries/ExecutableDictionarySource.h index 878cb086873..4b2326b2a58 100644 --- a/src/Dictionaries/ExecutableDictionarySource.h +++ b/src/Dictionaries/ExecutableDictionarySource.h @@ -20,7 +20,7 @@ public: const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, Block & sample_block_, - ContextPtr context_); + ContextConstPtr context_); ExecutableDictionarySource(const ExecutableDictionarySource & other); ExecutableDictionarySource & operator=(const ExecutableDictionarySource &) = delete; @@ -58,7 +58,7 @@ private: const std::string update_field; const std::string format; Block sample_block; - ContextPtr context; + ContextConstPtr context; }; } diff --git a/src/Dictionaries/ExecutablePoolDictionarySource.cpp b/src/Dictionaries/ExecutablePoolDictionarySource.cpp index 2e01c75234c..21818baa658 100644 --- a/src/Dictionaries/ExecutablePoolDictionarySource.cpp +++ b/src/Dictionaries/ExecutablePoolDictionarySource.cpp @@ -32,7 +32,7 @@ ExecutablePoolDictionarySource::ExecutablePoolDictionarySource( const DictionaryStructure & dict_struct_, const Configuration & configuration_, Block & sample_block_, - ContextPtr context_) + ContextConstPtr context_) : log(&Poco::Logger::get("ExecutablePoolDictionarySource")) , dict_struct{dict_struct_} , configuration{configuration_} @@ -273,7 +273,7 @@ void registerDictionarySourceExecutablePool(DictionarySourceFactory & factory) const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, Block & sample_block, - ContextPtr context, + ContextConstPtr context, const std::string & /* default_database */, bool created_from_ddl) -> DictionarySourcePtr { diff --git a/src/Dictionaries/ExecutablePoolDictionarySource.h b/src/Dictionaries/ExecutablePoolDictionarySource.h index 7a0b8681a21..9bf6e89c1f0 100644 --- a/src/Dictionaries/ExecutablePoolDictionarySource.h +++ b/src/Dictionaries/ExecutablePoolDictionarySource.h @@ -42,7 +42,7 @@ public: const DictionaryStructure & dict_struct_, const Configuration & configuration_, Block & sample_block_, - ContextPtr context_); + ContextConstPtr context_); ExecutablePoolDictionarySource(const ExecutablePoolDictionarySource & other); ExecutablePoolDictionarySource & operator=(const ExecutablePoolDictionarySource &) = delete; @@ -78,7 +78,7 @@ private: const Configuration configuration; Block sample_block; - ContextPtr context; + ContextConstPtr context; std::shared_ptr process_pool; }; diff --git a/src/Dictionaries/FileDictionarySource.cpp b/src/Dictionaries/FileDictionarySource.cpp index a32bd081dd7..cf722aba68f 100644 --- a/src/Dictionaries/FileDictionarySource.cpp +++ b/src/Dictionaries/FileDictionarySource.cpp @@ -28,7 +28,7 @@ namespace ErrorCodes FileDictionarySource::FileDictionarySource( const std::string & filepath_, const std::string & format_, - Block & sample_block_, ContextPtr context_, bool created_from_ddl) + Block & sample_block_, ContextConstPtr context_, bool created_from_ddl) : filepath{filepath_} , format{format_} , sample_block{sample_block_} @@ -77,7 +77,7 @@ void registerDictionarySourceFile(DictionarySourceFactory & factory) const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, Block & sample_block, - ContextPtr context, + ContextConstPtr context, const std::string & /* default_database */, bool created_from_ddl) -> DictionarySourcePtr { diff --git a/src/Dictionaries/FileDictionarySource.h b/src/Dictionaries/FileDictionarySource.h index ffc29374f4f..d31a6dedb7f 100644 --- a/src/Dictionaries/FileDictionarySource.h +++ b/src/Dictionaries/FileDictionarySource.h @@ -17,7 +17,7 @@ class FileDictionarySource final : public IDictionarySource { public: FileDictionarySource(const std::string & filepath_, const std::string & format_, - Block & sample_block_, ContextPtr context_, bool created_from_ddl); + Block & sample_block_, ContextConstPtr context_, bool created_from_ddl); FileDictionarySource(const FileDictionarySource & other); @@ -61,7 +61,7 @@ private: const std::string filepath; const std::string format; Block sample_block; - ContextPtr context; + ContextConstPtr context; Poco::Timestamp last_modification; }; diff --git a/src/Dictionaries/FlatDictionary.cpp b/src/Dictionaries/FlatDictionary.cpp index 1c7fd076e6e..f58384a3b8e 100644 --- a/src/Dictionaries/FlatDictionary.cpp +++ b/src/Dictionaries/FlatDictionary.cpp @@ -506,7 +506,7 @@ void registerDictionaryFlat(DictionaryFactory & factory) const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, DictionarySourcePtr source_ptr, - ContextPtr /* context */, + ContextConstPtr /* context */, bool /* created_from_ddl */) -> DictionaryPtr { if (dict_struct.key) diff --git a/src/Dictionaries/HTTPDictionarySource.cpp b/src/Dictionaries/HTTPDictionarySource.cpp index 7fc1778545c..b3527b06117 100644 --- a/src/Dictionaries/HTTPDictionarySource.cpp +++ b/src/Dictionaries/HTTPDictionarySource.cpp @@ -31,7 +31,7 @@ HTTPDictionarySource::HTTPDictionarySource( const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, Block & sample_block_, - ContextPtr context_, + ContextConstPtr context_, bool created_from_ddl) : log(&Poco::Logger::get("HTTPDictionarySource")) , update_time{std::chrono::system_clock::from_time_t(0)} @@ -231,7 +231,7 @@ void registerDictionarySourceHTTP(DictionarySourceFactory & factory) const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, Block & sample_block, - ContextPtr context, + ContextConstPtr context, const std::string & /* default_database */, bool created_from_ddl) -> DictionarySourcePtr { if (dict_struct.has_expressions) diff --git a/src/Dictionaries/HTTPDictionarySource.h b/src/Dictionaries/HTTPDictionarySource.h index e348075edc3..9b93856a6bc 100644 --- a/src/Dictionaries/HTTPDictionarySource.h +++ b/src/Dictionaries/HTTPDictionarySource.h @@ -27,7 +27,7 @@ public: const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, Block & sample_block_, - ContextPtr context_, + ContextConstPtr context_, bool created_from_ddl); HTTPDictionarySource(const HTTPDictionarySource & other); @@ -69,7 +69,7 @@ private: std::string update_field; const std::string format; Block sample_block; - ContextPtr context; + ContextConstPtr context; ConnectionTimeouts timeouts; }; diff --git a/src/Dictionaries/HashedDictionary.cpp b/src/Dictionaries/HashedDictionary.cpp index 24450b87274..0de28f18006 100644 --- a/src/Dictionaries/HashedDictionary.cpp +++ b/src/Dictionaries/HashedDictionary.cpp @@ -751,13 +751,13 @@ void registerDictionaryHashed(DictionaryFactory & factory) using namespace std::placeholders; factory.registerLayout("hashed", - [=](auto && a, auto && b, auto && c, auto && d, DictionarySourcePtr e, ContextPtr /* context */, bool /*created_from_ddl*/){ return create_layout(a, b, c, d, std::move(e), DictionaryKeyType::simple, /* sparse = */ false); }, false); + [=](auto && a, auto && b, auto && c, auto && d, DictionarySourcePtr e, ContextConstPtr /* context */, bool /*created_from_ddl*/){ return create_layout(a, b, c, d, std::move(e), DictionaryKeyType::simple, /* sparse = */ false); }, false); factory.registerLayout("sparse_hashed", - [=](auto && a, auto && b, auto && c, auto && d, DictionarySourcePtr e, ContextPtr /* context */, bool /*created_from_ddl*/){ return create_layout(a, b, c, d, std::move(e), DictionaryKeyType::simple, /* sparse = */ true); }, false); + [=](auto && a, auto && b, auto && c, auto && d, DictionarySourcePtr e, ContextConstPtr /* context */, bool /*created_from_ddl*/){ return create_layout(a, b, c, d, std::move(e), DictionaryKeyType::simple, /* sparse = */ true); }, false); factory.registerLayout("complex_key_hashed", - [=](auto && a, auto && b, auto && c, auto && d, DictionarySourcePtr e, ContextPtr /* context */, bool /*created_from_ddl*/){ return create_layout(a, b, c, d, std::move(e), DictionaryKeyType::complex, /* sparse = */ false); }, true); + [=](auto && a, auto && b, auto && c, auto && d, DictionarySourcePtr e, ContextConstPtr /* context */, bool /*created_from_ddl*/){ return create_layout(a, b, c, d, std::move(e), DictionaryKeyType::complex, /* sparse = */ false); }, true); factory.registerLayout("complex_key_sparse_hashed", - [=](auto && a, auto && b, auto && c, auto && d, DictionarySourcePtr e, ContextPtr /* context */, bool /*created_from_ddl*/){ return create_layout(a, b, c, d, std::move(e), DictionaryKeyType::complex, /* sparse = */ true); }, true); + [=](auto && a, auto && b, auto && c, auto && d, DictionarySourcePtr e, ContextConstPtr /* context */, bool /*created_from_ddl*/){ return create_layout(a, b, c, d, std::move(e), DictionaryKeyType::complex, /* sparse = */ true); }, true); } diff --git a/src/Dictionaries/IPAddressDictionary.cpp b/src/Dictionaries/IPAddressDictionary.cpp index 648e756e9a7..a0630ab324c 100644 --- a/src/Dictionaries/IPAddressDictionary.cpp +++ b/src/Dictionaries/IPAddressDictionary.cpp @@ -935,7 +935,7 @@ void registerDictionaryTrie(DictionaryFactory & factory) const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, DictionarySourcePtr source_ptr, - ContextPtr /* context */, + ContextConstPtr /* context */, bool /*created_from_ddl*/) -> DictionaryPtr { if (!dict_struct.key || dict_struct.key->size() != 1) diff --git a/src/Dictionaries/LibraryDictionarySource.cpp b/src/Dictionaries/LibraryDictionarySource.cpp index f51c4908942..3fa61408ba1 100644 --- a/src/Dictionaries/LibraryDictionarySource.cpp +++ b/src/Dictionaries/LibraryDictionarySource.cpp @@ -31,7 +31,7 @@ LibraryDictionarySource::LibraryDictionarySource( const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix_, Block & sample_block_, - ContextPtr context_, + ContextConstPtr context_, bool created_from_ddl) : log(&Poco::Logger::get("LibraryDictionarySource")) , dict_struct{dict_struct_} @@ -172,7 +172,7 @@ void registerDictionarySourceLibrary(DictionarySourceFactory & factory) const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, Block & sample_block, - ContextPtr context, + ContextConstPtr context, const std::string & /* default_database */, bool created_from_ddl) -> DictionarySourcePtr { diff --git a/src/Dictionaries/LibraryDictionarySource.h b/src/Dictionaries/LibraryDictionarySource.h index 88e133666e6..eb346d09fab 100644 --- a/src/Dictionaries/LibraryDictionarySource.h +++ b/src/Dictionaries/LibraryDictionarySource.h @@ -39,7 +39,7 @@ public: const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix_, Block & sample_block_, - ContextPtr context_, + ContextConstPtr context_, bool created_from_ddl); LibraryDictionarySource(const LibraryDictionarySource & other); @@ -86,7 +86,7 @@ private: const Field dictionary_id; Block sample_block; - ContextPtr context; + ContextConstPtr context; LibraryBridgeHelperPtr bridge_helper; ExternalResultDescription description; diff --git a/src/Dictionaries/MongoDBDictionarySource.cpp b/src/Dictionaries/MongoDBDictionarySource.cpp index 2a809f52817..c0780616191 100644 --- a/src/Dictionaries/MongoDBDictionarySource.cpp +++ b/src/Dictionaries/MongoDBDictionarySource.cpp @@ -13,7 +13,7 @@ void registerDictionarySourceMongoDB(DictionarySourceFactory & factory) const Poco::Util::AbstractConfiguration & config, const std::string & root_config_prefix, Block & sample_block, - ContextPtr, + ContextConstPtr, const std::string & /* default_database */, bool /* created_from_ddl */) { diff --git a/src/Dictionaries/MySQLDictionarySource.cpp b/src/Dictionaries/MySQLDictionarySource.cpp index afda8241b38..40398a7ba42 100644 --- a/src/Dictionaries/MySQLDictionarySource.cpp +++ b/src/Dictionaries/MySQLDictionarySource.cpp @@ -24,7 +24,7 @@ void registerDictionarySourceMysql(DictionarySourceFactory & factory) [[maybe_unused]] const Poco::Util::AbstractConfiguration & config, [[maybe_unused]] const std::string & config_prefix, [[maybe_unused]] Block & sample_block, - [[maybe_unused]] ContextPtr context, + [[maybe_unused]] ContextConstPtr context, const std::string & /* default_database */, bool /* created_from_ddl */) -> DictionarySourcePtr { #if USE_MYSQL diff --git a/src/Dictionaries/PolygonDictionaryImplementations.cpp b/src/Dictionaries/PolygonDictionaryImplementations.cpp index 7c3eb421a4a..fd3b9efd532 100644 --- a/src/Dictionaries/PolygonDictionaryImplementations.cpp +++ b/src/Dictionaries/PolygonDictionaryImplementations.cpp @@ -167,7 +167,7 @@ DictionaryPtr createLayout(const std::string & , const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, DictionarySourcePtr source_ptr, - ContextPtr /* context */, + ContextConstPtr /* context */, bool /*created_from_ddl*/) { const String database = config.getString(config_prefix + ".database", ""); diff --git a/src/Dictionaries/PostgreSQLDictionarySource.cpp b/src/Dictionaries/PostgreSQLDictionarySource.cpp index d23c9a7e725..c563f9aab45 100644 --- a/src/Dictionaries/PostgreSQLDictionarySource.cpp +++ b/src/Dictionaries/PostgreSQLDictionarySource.cpp @@ -188,7 +188,7 @@ void registerDictionarySourcePostgreSQL(DictionarySourceFactory & factory) const Poco::Util::AbstractConfiguration & config, const std::string & root_config_prefix, Block & sample_block, - ContextPtr context, + ContextConstPtr context, const std::string & /* default_database */, bool /* created_from_ddl */) -> DictionarySourcePtr { diff --git a/src/Dictionaries/RangeHashedDictionary.cpp b/src/Dictionaries/RangeHashedDictionary.cpp index 4049bd3a027..b771bca068f 100644 --- a/src/Dictionaries/RangeHashedDictionary.cpp +++ b/src/Dictionaries/RangeHashedDictionary.cpp @@ -637,7 +637,7 @@ void registerDictionaryRangeHashed(DictionaryFactory & factory) const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, DictionarySourcePtr source_ptr, - ContextPtr /* context */, + ContextConstPtr /* context */, bool /*created_from_ddl*/) -> DictionaryPtr { if (dict_struct.key) diff --git a/src/Dictionaries/RedisDictionarySource.cpp b/src/Dictionaries/RedisDictionarySource.cpp index 4e79a75c1d4..ce979462a36 100644 --- a/src/Dictionaries/RedisDictionarySource.cpp +++ b/src/Dictionaries/RedisDictionarySource.cpp @@ -12,7 +12,7 @@ void registerDictionarySourceRedis(DictionarySourceFactory & factory) const Poco::Util::AbstractConfiguration & config, const String & config_prefix, Block & sample_block, - ContextPtr /* context */, + ContextConstPtr /* context */, const std::string & /* default_database */, bool /* created_from_ddl */) -> DictionarySourcePtr { return std::make_unique(dict_struct, config, config_prefix + ".redis", sample_block); diff --git a/src/Dictionaries/XDBCDictionarySource.cpp b/src/Dictionaries/XDBCDictionarySource.cpp index 0ebd15ff515..fa7138348c1 100644 --- a/src/Dictionaries/XDBCDictionarySource.cpp +++ b/src/Dictionaries/XDBCDictionarySource.cpp @@ -37,7 +37,7 @@ namespace const Poco::URI & uri, std::function callback, const Block & sample_block, - ContextPtr context, + ContextConstPtr context, UInt64 max_block_size, const ConnectionTimeouts & timeouts, const String name_) @@ -102,7 +102,7 @@ XDBCDictionarySource::XDBCDictionarySource( const Poco::Util::AbstractConfiguration & config_, const std::string & config_prefix_, const Block & sample_block_, - ContextPtr context_, + ContextConstPtr context_, const BridgeHelperPtr bridge_) : WithContext(context_->getGlobalContext()) , log(&Poco::Logger::get(bridge_->getName() + "DictionarySource")) @@ -278,7 +278,7 @@ void registerDictionarySourceXDBC(DictionarySourceFactory & factory) const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, Block & sample_block, - ContextPtr context, + ContextConstPtr context, const std::string & /* default_database */, bool /* check_config */) -> DictionarySourcePtr { #if USE_ODBC @@ -305,7 +305,7 @@ void registerDictionarySourceJDBC(DictionarySourceFactory & factory) const Poco::Util::AbstractConfiguration & /* config */, const std::string & /* config_prefix */, Block & /* sample_block */, - ContextPtr /* context */, + ContextConstPtr /* context */, const std::string & /* default_database */, bool /* created_from_ddl */) -> DictionarySourcePtr { throw Exception(ErrorCodes::SUPPORT_IS_DISABLED, diff --git a/src/Dictionaries/XDBCDictionarySource.h b/src/Dictionaries/XDBCDictionarySource.h index bd473e0db8a..4a6f226102b 100644 --- a/src/Dictionaries/XDBCDictionarySource.h +++ b/src/Dictionaries/XDBCDictionarySource.h @@ -31,7 +31,7 @@ public: const Poco::Util::AbstractConfiguration & config_, const std::string & config_prefix_, const Block & sample_block_, - ContextPtr context_, + ContextConstPtr context_, BridgeHelperPtr bridge); /// copy-constructor is provided in order to support cloneability diff --git a/src/Dictionaries/getDictionaryConfigurationFromAST.cpp b/src/Dictionaries/getDictionaryConfigurationFromAST.cpp index 2063ebcbf79..4816c6fd6b8 100644 --- a/src/Dictionaries/getDictionaryConfigurationFromAST.cpp +++ b/src/Dictionaries/getDictionaryConfigurationFromAST.cpp @@ -397,7 +397,7 @@ void buildConfigurationFromFunctionWithKeyValueArguments( AutoPtr doc, AutoPtr root, const ASTExpressionList * ast_expr_list, - ContextPtr context) + ContextConstPtr context) { const auto & children = ast_expr_list->children; for (size_t i = 0; i != children.size(); ++i) @@ -464,7 +464,7 @@ void buildSourceConfiguration( AutoPtr root, const ASTFunctionWithKeyValueArguments * source, const ASTDictionarySettings * settings, - ContextPtr context) + ContextConstPtr context) { AutoPtr outer_element(doc->createElement("source")); root->appendChild(outer_element); @@ -525,7 +525,7 @@ void checkPrimaryKey(const NamesToTypeNames & all_attrs, const Names & key_attrs DictionaryConfigurationPtr -getDictionaryConfigurationFromAST(const ASTCreateQuery & query, ContextPtr context, const std::string & database_) +getDictionaryConfigurationFromAST(const ASTCreateQuery & query, ContextConstPtr context, const std::string & database_) { checkAST(query); diff --git a/src/Dictionaries/getDictionaryConfigurationFromAST.h b/src/Dictionaries/getDictionaryConfigurationFromAST.h index de8659e4d7b..01f13ab4030 100644 --- a/src/Dictionaries/getDictionaryConfigurationFromAST.h +++ b/src/Dictionaries/getDictionaryConfigurationFromAST.h @@ -12,5 +12,5 @@ using DictionaryConfigurationPtr = Poco::AutoPtr DictionaryPtr { return createCacheDictionaryLayout(full_name, dict_struct, config, config_prefix, std::move(source_ptr)); @@ -278,7 +278,7 @@ void registerDictionaryCache(DictionaryFactory & factory) const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, DictionarySourcePtr source_ptr, - ContextPtr /* context */, + ContextConstPtr /* context */, bool /* created_from_ddl */) -> DictionaryPtr { return createCacheDictionaryLayout(full_name, dict_struct, config, config_prefix, std::move(source_ptr)); @@ -293,7 +293,7 @@ void registerDictionaryCache(DictionaryFactory & factory) const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, DictionarySourcePtr source_ptr, - ContextPtr context, + ContextConstPtr context, bool created_from_ddl) -> DictionaryPtr { return createSSDCacheDictionaryLayout(full_name, dict_struct, config, config_prefix, std::move(source_ptr), context, created_from_ddl); @@ -306,7 +306,7 @@ void registerDictionaryCache(DictionaryFactory & factory) const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, DictionarySourcePtr source_ptr, - ContextPtr context, + ContextConstPtr context, bool created_from_ddl) -> DictionaryPtr { return createSSDCacheDictionaryLayout(full_name, dict_struct, config, config_prefix, std::move(source_ptr), context, created_from_ddl); }; diff --git a/src/Functions/FunctionBase64Conversion.h b/src/Functions/FunctionBase64Conversion.h index 29aa5913b83..6a8e3d2d94a 100644 --- a/src/Functions/FunctionBase64Conversion.h +++ b/src/Functions/FunctionBase64Conversion.h @@ -61,7 +61,7 @@ class FunctionBase64Conversion : public IFunction public: static constexpr auto name = Func::name; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/FunctionBinaryArithmetic.h b/src/Functions/FunctionBinaryArithmetic.h index 927b870891f..4ad876fc461 100644 --- a/src/Functions/FunctionBinaryArithmetic.h +++ b/src/Functions/FunctionBinaryArithmetic.h @@ -514,7 +514,7 @@ class FunctionBinaryArithmetic : public IFunction static constexpr const bool is_multiply = IsOperation::multiply; static constexpr const bool is_division = IsOperation::division; - ContextPtr context; + ContextConstPtr context; bool check_decimal_overflow = true; template @@ -597,7 +597,7 @@ class FunctionBinaryArithmetic : public IFunction } static FunctionOverloadResolverPtr - getFunctionForIntervalArithmetic(const DataTypePtr & type0, const DataTypePtr & type1, ContextPtr context) + getFunctionForIntervalArithmetic(const DataTypePtr & type0, const DataTypePtr & type1, ContextConstPtr context) { bool first_is_date_or_datetime = isDateOrDateTime(type0); bool second_is_date_or_datetime = isDateOrDateTime(type1); @@ -945,9 +945,9 @@ class FunctionBinaryArithmetic : public IFunction public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr context) { return std::make_shared(context); } + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } - explicit FunctionBinaryArithmetic(ContextPtr context_) + explicit FunctionBinaryArithmetic(ContextConstPtr context_) : context(context_), check_decimal_overflow(decimalCheckArithmeticOverflow(context)) {} @@ -961,7 +961,7 @@ public: return getReturnTypeImplStatic(arguments, context); } - static DataTypePtr getReturnTypeImplStatic(const DataTypes & arguments, ContextPtr context) + static DataTypePtr getReturnTypeImplStatic(const DataTypes & arguments, ContextConstPtr context) { /// Special case when multiply aggregate function state if (isAggregateMultiply(arguments[0], arguments[1])) @@ -1373,7 +1373,7 @@ public: const ColumnWithTypeAndName & left_, const ColumnWithTypeAndName & right_, const DataTypePtr & return_type_, - ContextPtr context) + ContextConstPtr context) { return std::make_shared(left_, right_, return_type_, context); } @@ -1382,7 +1382,7 @@ public: const ColumnWithTypeAndName & left_, const ColumnWithTypeAndName & right_, const DataTypePtr & return_type_, - ContextPtr context_) + ContextConstPtr context_) : Base(context_), left(left_), right(right_), return_type(return_type_) { } @@ -1536,12 +1536,12 @@ class BinaryArithmeticOverloadResolver : public IFunctionOverloadResolver { public: static constexpr auto name = Name::name; - static FunctionOverloadResolverPtr create(ContextPtr context) + static FunctionOverloadResolverPtr create(ContextConstPtr context) { return std::make_unique(context); } - explicit BinaryArithmeticOverloadResolver(ContextPtr context_) : context(context_) {} + explicit BinaryArithmeticOverloadResolver(ContextConstPtr context_) : context(context_) {} String getName() const override { return name; } size_t getNumberOfArguments() const override { return 2; } @@ -1577,6 +1577,6 @@ public: } private: - ContextPtr context; + ContextConstPtr context; }; } diff --git a/src/Functions/FunctionBitTestMany.h b/src/Functions/FunctionBitTestMany.h index 567be37cda8..030919e8836 100644 --- a/src/Functions/FunctionBitTestMany.h +++ b/src/Functions/FunctionBitTestMany.h @@ -24,7 +24,7 @@ struct FunctionBitTestMany : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/FunctionCustomWeekToSomething.h b/src/Functions/FunctionCustomWeekToSomething.h index 84ecd4d7a5a..d30ce7b5c86 100644 --- a/src/Functions/FunctionCustomWeekToSomething.h +++ b/src/Functions/FunctionCustomWeekToSomething.h @@ -24,7 +24,7 @@ class FunctionCustomWeekToSomething : public IFunction { public: static constexpr auto name = Transform::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/FunctionDateOrDateTimeAddInterval.h b/src/Functions/FunctionDateOrDateTimeAddInterval.h index 14ab9f00452..4418f6e4b4b 100644 --- a/src/Functions/FunctionDateOrDateTimeAddInterval.h +++ b/src/Functions/FunctionDateOrDateTimeAddInterval.h @@ -352,7 +352,7 @@ class FunctionDateOrDateTimeAddInterval : public IFunction { public: static constexpr auto name = Transform::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/FunctionDateOrDateTimeToSomething.h b/src/Functions/FunctionDateOrDateTimeToSomething.h index 8b8f1b483c8..bdf3f425a0b 100644 --- a/src/Functions/FunctionDateOrDateTimeToSomething.h +++ b/src/Functions/FunctionDateOrDateTimeToSomething.h @@ -24,7 +24,7 @@ class FunctionDateOrDateTimeToSomething : public IFunction { public: static constexpr auto name = Transform::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/FunctionFQDN.cpp b/src/Functions/FunctionFQDN.cpp index 304aad17d22..36fcdfacc99 100644 --- a/src/Functions/FunctionFQDN.cpp +++ b/src/Functions/FunctionFQDN.cpp @@ -12,7 +12,7 @@ class FunctionFQDN : public IFunction { public: static constexpr auto name = "FQDN"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/FunctionFactory.cpp b/src/Functions/FunctionFactory.cpp index b1437d58c09..1bb78ead872 100644 --- a/src/Functions/FunctionFactory.cpp +++ b/src/Functions/FunctionFactory.cpp @@ -52,7 +52,7 @@ void FunctionFactory::registerFunction(const FunctionOverloadResolverPtr FunctionFactory::getImpl( const std::string & name, - ContextPtr context) const + ContextConstPtr context) const { auto res = tryGetImpl(name, context); if (!res) @@ -82,14 +82,14 @@ std::vector FunctionFactory::getAllNames() const FunctionOverloadResolverPtr FunctionFactory::get( const std::string & name, - ContextPtr context) const + ContextConstPtr context) const { return getImpl(name, context); } FunctionOverloadResolverPtr FunctionFactory::tryGetImpl( const std::string & name_param, - ContextPtr context) const + ContextConstPtr context) const { String name = getAliasToOrName(name_param); FunctionOverloadResolverPtr res; @@ -120,7 +120,7 @@ FunctionOverloadResolverPtr FunctionFactory::tryGetImpl( FunctionOverloadResolverPtr FunctionFactory::tryGet( const std::string & name, - ContextPtr context) const + ContextConstPtr context) const { auto impl = tryGetImpl(name, context); return impl ? std::move(impl) : nullptr; diff --git a/src/Functions/FunctionFactory.h b/src/Functions/FunctionFactory.h index bac55dade16..bf380d51312 100644 --- a/src/Functions/FunctionFactory.h +++ b/src/Functions/FunctionFactory.h @@ -19,7 +19,7 @@ namespace DB * some dictionaries from Context. */ class FunctionFactory : private boost::noncopyable, - public IFactoryWithAliases> + public IFactoryWithAliases> { public: static FunctionFactory & instance(); @@ -44,14 +44,14 @@ public: std::vector getAllNames() const; /// Throws an exception if not found. - FunctionOverloadResolverPtr get(const std::string & name, ContextPtr context) const; + FunctionOverloadResolverPtr get(const std::string & name, ContextConstPtr context) const; /// Returns nullptr if not found. - FunctionOverloadResolverPtr tryGet(const std::string & name, ContextPtr context) const; + FunctionOverloadResolverPtr tryGet(const std::string & name, ContextConstPtr context) const; /// The same methods to get developer interface implementation. - FunctionOverloadResolverPtr getImpl(const std::string & name, ContextPtr context) const; - FunctionOverloadResolverPtr tryGetImpl(const std::string & name, ContextPtr context) const; + FunctionOverloadResolverPtr getImpl(const std::string & name, ContextConstPtr context) const; + FunctionOverloadResolverPtr tryGetImpl(const std::string & name, ContextConstPtr context) const; /// Register a function by its name. /// No locking, you must register all functions before usage of get. @@ -67,7 +67,7 @@ private: Functions case_insensitive_functions; template - static FunctionOverloadResolverPtr adaptFunctionToOverloadResolver(ContextPtr context) + static FunctionOverloadResolverPtr adaptFunctionToOverloadResolver(ContextConstPtr context) { return std::make_unique(Function::create(context)); } diff --git a/src/Functions/FunctionFile.cpp b/src/Functions/FunctionFile.cpp index 9247152367b..4e81a4497b7 100644 --- a/src/Functions/FunctionFile.cpp +++ b/src/Functions/FunctionFile.cpp @@ -21,12 +21,12 @@ namespace ErrorCodes } /// A function to read file as a string. -class FunctionFile : public IFunction, WithContext +class FunctionFile : public IFunction, WithConstContext { public: static constexpr auto name = "file"; - static FunctionPtr create(ContextPtr context_) { return std::make_shared(context_); } - explicit FunctionFile(ContextPtr context_) : WithContext(context_) {} + static FunctionPtr create(ContextConstPtr context_) { return std::make_shared(context_); } + explicit FunctionFile(ContextConstPtr context_) : WithConstContext(context_) {} String getName() const override { return name; } diff --git a/src/Functions/FunctionJoinGet.cpp b/src/Functions/FunctionJoinGet.cpp index 81545143839..3a17d049099 100644 --- a/src/Functions/FunctionJoinGet.cpp +++ b/src/Functions/FunctionJoinGet.cpp @@ -36,7 +36,7 @@ ExecutableFunctionPtr FunctionJoinGet::prepare(const ColumnsWithTypeAnd } static std::pair, String> -getJoin(const ColumnsWithTypeAndName & arguments, ContextPtr context) +getJoin(const ColumnsWithTypeAndName & arguments, ContextConstPtr context) { String join_name; if (const auto * name_col = checkAndGetColumnConst(arguments[0].column.get())) @@ -63,7 +63,7 @@ getJoin(const ColumnsWithTypeAndName & arguments, ContextPtr context) String table_name = join_name.substr(dot); if (table_name.empty()) throw Exception("joinGet does not allow empty table name", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); - auto table = DatabaseCatalog::instance().getTable({database_name, table_name}, context); + auto table = DatabaseCatalog::instance().getTable({database_name, table_name}, std::const_pointer_cast(context)); auto storage_join = std::dynamic_pointer_cast(table); if (!storage_join) throw Exception("Table " + join_name + " should have engine StorageJoin", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); diff --git a/src/Functions/FunctionJoinGet.h b/src/Functions/FunctionJoinGet.h index 2250fa3ccf0..0328d1a16e1 100644 --- a/src/Functions/FunctionJoinGet.h +++ b/src/Functions/FunctionJoinGet.h @@ -74,13 +74,13 @@ private: }; template -class JoinGetOverloadResolver final : public IFunctionOverloadResolver, WithContext +class JoinGetOverloadResolver final : public IFunctionOverloadResolver, WithConstContext { public: static constexpr auto name = or_null ? "joinGetOrNull" : "joinGet"; - static FunctionOverloadResolverPtr create(ContextPtr context_) { return std::make_unique(context_); } + static FunctionOverloadResolverPtr create(ContextConstPtr context_) { return std::make_unique(context_); } - explicit JoinGetOverloadResolver(ContextPtr context_) : WithContext(context_) {} + explicit JoinGetOverloadResolver(ContextConstPtr context_) : WithConstContext(context_) {} String getName() const override { return name; } diff --git a/src/Functions/FunctionMathBinaryFloat64.h b/src/Functions/FunctionMathBinaryFloat64.h index 8cc012d3ab2..340470fa0b8 100644 --- a/src/Functions/FunctionMathBinaryFloat64.h +++ b/src/Functions/FunctionMathBinaryFloat64.h @@ -28,7 +28,7 @@ class FunctionMathBinaryFloat64 : public IFunction { public: static constexpr auto name = Impl::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } static_assert(Impl::rows_per_iteration > 0, "Impl must process at least one row per iteration"); bool useDefaultImplementationForConstants() const override { return true; } diff --git a/src/Functions/FunctionMathConstFloat64.h b/src/Functions/FunctionMathConstFloat64.h index ab7d401e99e..b85b65fc43d 100644 --- a/src/Functions/FunctionMathConstFloat64.h +++ b/src/Functions/FunctionMathConstFloat64.h @@ -13,7 +13,7 @@ class FunctionMathConstFloat64 : public IFunction { public: static constexpr auto name = Impl::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } private: String getName() const override { return name; } diff --git a/src/Functions/FunctionMathUnary.h b/src/Functions/FunctionMathUnary.h index a637bbe3bd8..d7804af4f7a 100644 --- a/src/Functions/FunctionMathUnary.h +++ b/src/Functions/FunctionMathUnary.h @@ -35,7 +35,7 @@ class FunctionMathUnary : public IFunction { public: static constexpr auto name = Impl::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } private: String getName() const override { return name; } diff --git a/src/Functions/FunctionNumericPredicate.h b/src/Functions/FunctionNumericPredicate.h index d5fa9f03aba..006f74f531a 100644 --- a/src/Functions/FunctionNumericPredicate.h +++ b/src/Functions/FunctionNumericPredicate.h @@ -23,7 +23,7 @@ class FunctionNumericPredicate : public IFunction { public: static constexpr auto name = Impl::name; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/FunctionStartsEndsWith.h b/src/Functions/FunctionStartsEndsWith.h index 65dbf393290..cf3a406498a 100644 --- a/src/Functions/FunctionStartsEndsWith.h +++ b/src/Functions/FunctionStartsEndsWith.h @@ -142,7 +142,7 @@ template class FunctionStartsEndsWith : public TargetSpecific::Default::FunctionStartsEndsWith { public: - explicit FunctionStartsEndsWith(ContextPtr context) : selector(context) + explicit FunctionStartsEndsWith(ContextConstPtr context) : selector(context) { selector.registerImplementation>(); @@ -164,7 +164,7 @@ public: return selector.selectAndExecute(arguments, result_type, input_rows_count); } - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared>(context); } diff --git a/src/Functions/FunctionStringOrArrayToT.h b/src/Functions/FunctionStringOrArrayToT.h index 158179fffe9..ceb58a5f7f6 100644 --- a/src/Functions/FunctionStringOrArrayToT.h +++ b/src/Functions/FunctionStringOrArrayToT.h @@ -25,7 +25,7 @@ class FunctionStringOrArrayToT : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/FunctionStringReplace.h b/src/Functions/FunctionStringReplace.h index 2e99f58531a..2ff09f79f9e 100644 --- a/src/Functions/FunctionStringReplace.h +++ b/src/Functions/FunctionStringReplace.h @@ -23,7 +23,7 @@ class FunctionStringReplace : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/FunctionStringToString.h b/src/Functions/FunctionStringToString.h index 26480a83995..9b63eec4a60 100644 --- a/src/Functions/FunctionStringToString.h +++ b/src/Functions/FunctionStringToString.h @@ -23,7 +23,7 @@ class FunctionStringToString : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/FunctionUnaryArithmetic.h b/src/Functions/FunctionUnaryArithmetic.h index 68fcfadfb84..4b5fdf86078 100644 --- a/src/Functions/FunctionUnaryArithmetic.h +++ b/src/Functions/FunctionUnaryArithmetic.h @@ -111,7 +111,7 @@ class FunctionUnaryArithmetic : public IFunction public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/FunctionsAES.h b/src/Functions/FunctionsAES.h index b76b454fd77..4dfe5cdea91 100644 --- a/src/Functions/FunctionsAES.h +++ b/src/Functions/FunctionsAES.h @@ -141,7 +141,7 @@ class FunctionEncrypt : public IFunction public: static constexpr OpenSSLDetails::CompatibilityMode compatibility_mode = Impl::compatibility_mode; static constexpr auto name = Impl::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } private: using CipherMode = OpenSSLDetails::CipherMode; @@ -416,7 +416,7 @@ class FunctionDecrypt : public IFunction public: static constexpr OpenSSLDetails::CompatibilityMode compatibility_mode = Impl::compatibility_mode; static constexpr auto name = Impl::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } private: using CipherMode = OpenSSLDetails::CipherMode; diff --git a/src/Functions/FunctionsBitmap.h b/src/Functions/FunctionsBitmap.h index bbdc53c3006..368e5bccbd1 100644 --- a/src/Functions/FunctionsBitmap.h +++ b/src/Functions/FunctionsBitmap.h @@ -93,7 +93,7 @@ class FunctionBitmapBuildImpl : public IFunction public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } @@ -221,7 +221,7 @@ class FunctionBitmapToArrayImpl : public IFunction public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } @@ -311,7 +311,7 @@ class FunctionBitmapSubset : public IFunction public: static constexpr auto name = Impl::name; - static FunctionPtr create(ContextPtr) { return std::make_shared>(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared>(); } String getName() const override { return name; } @@ -469,7 +469,7 @@ class FunctionBitmapTransform : public IFunction public: static constexpr auto name = "bitmapTransform"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } @@ -635,7 +635,7 @@ class FunctionBitmapSelfCardinalityImpl : public IFunction public: static constexpr auto name = Impl::name; - static FunctionPtr create(ContextPtr) { return std::make_shared>(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared>(); } String getName() const override { return name; } @@ -807,7 +807,7 @@ class FunctionBitmapContains : public IFunction public: static constexpr auto name = "bitmapContains"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } @@ -911,7 +911,7 @@ class FunctionBitmapCardinality : public IFunction public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } @@ -1054,7 +1054,7 @@ class FunctionBitmap : public IFunction public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/FunctionsCoding.h b/src/Functions/FunctionsCoding.h index 01602cf1175..6c9cd6d333b 100644 --- a/src/Functions/FunctionsCoding.h +++ b/src/Functions/FunctionsCoding.h @@ -69,7 +69,7 @@ class FunctionIPv6NumToString : public IFunction { public: static constexpr auto name = "IPv6NumToString"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } @@ -139,7 +139,7 @@ class FunctionCutIPv6 : public IFunction { public: static constexpr auto name = "cutIPv6"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } @@ -262,7 +262,7 @@ class FunctionIPv6StringToNum : public IFunction { public: static constexpr auto name = "IPv6StringToNum"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } static inline bool tryParseIPv4(const char * pos) { @@ -340,7 +340,7 @@ class FunctionIPv4NumToString : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared>(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared>(); } String getName() const override { @@ -401,7 +401,7 @@ class FunctionIPv4StringToNum : public IFunction { public: static constexpr auto name = "IPv4StringToNum"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { @@ -464,7 +464,7 @@ class FunctionIPv4ToIPv6 : public IFunction { public: static constexpr auto name = "IPv4ToIPv6"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } @@ -519,7 +519,7 @@ class FunctionToIPv4 : public FunctionIPv4StringToNum { public: static constexpr auto name = "toIPv4"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { @@ -542,7 +542,7 @@ class FunctionToIPv6 : public FunctionIPv6StringToNum { public: static constexpr auto name = "toIPv6"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } @@ -560,7 +560,7 @@ class FunctionMACNumToString : public IFunction { public: static constexpr auto name = "MACNumToString"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { @@ -690,7 +690,7 @@ class FunctionMACStringTo : public IFunction { public: static constexpr auto name = Impl::name; - static FunctionPtr create(ContextPtr) { return std::make_shared>(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared>(); } String getName() const override { @@ -753,7 +753,7 @@ class FunctionUUIDNumToString : public IFunction public: static constexpr auto name = "UUIDNumToString"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { @@ -851,7 +851,7 @@ private: public: static constexpr auto name = "UUIDStringToNum"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { @@ -955,7 +955,7 @@ class FunctionHex : public IFunction { public: static constexpr auto name = "hex"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { @@ -1238,7 +1238,7 @@ class FunctionUnhex : public IFunction { public: static constexpr auto name = "unhex"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { @@ -1327,7 +1327,7 @@ class FunctionChar : public IFunction { public: static constexpr auto name = "char"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { @@ -1422,7 +1422,7 @@ class FunctionBitmaskToArray : public IFunction { public: static constexpr auto name = "bitmaskToArray"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { @@ -1508,7 +1508,7 @@ class FunctionToStringCutToZero : public IFunction { public: static constexpr auto name = "toStringCutToZero"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { @@ -1673,7 +1673,7 @@ private: public: static constexpr auto name = "IPv6CIDRToRange"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } size_t getNumberOfArguments() const override { return 2; } @@ -1787,7 +1787,7 @@ private: public: static constexpr auto name = "IPv4CIDRToRange"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } size_t getNumberOfArguments() const override { return 2; } @@ -1868,7 +1868,7 @@ class FunctionIsIPv4String : public FunctionIPv4StringToNum public: static constexpr auto name = "isIPv4String"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } @@ -1914,7 +1914,7 @@ class FunctionIsIPv6String : public FunctionIPv6StringToNum public: static constexpr auto name = "isIPv6String"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/FunctionsComparison.h b/src/Functions/FunctionsComparison.h index 9ffb0cd0fc3..0696b0fd335 100644 --- a/src/Functions/FunctionsComparison.h +++ b/src/Functions/FunctionsComparison.h @@ -557,13 +557,13 @@ class FunctionComparison : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr context) { return std::make_shared(context); } + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } - explicit FunctionComparison(ContextPtr context_) + explicit FunctionComparison(ContextConstPtr context_) : context(context_), check_decimal_overflow(decimalCheckComparisonOverflow(context)) {} private: - ContextPtr context; + ContextConstPtr context; bool check_decimal_overflow = true; template diff --git a/src/Functions/FunctionsConsistentHashing.h b/src/Functions/FunctionsConsistentHashing.h index 4c393f6ee01..69163917430 100644 --- a/src/Functions/FunctionsConsistentHashing.h +++ b/src/Functions/FunctionsConsistentHashing.h @@ -24,7 +24,7 @@ class FunctionConsistentHashImpl : public IFunction public: static constexpr auto name = Impl::name; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared>(); } diff --git a/src/Functions/FunctionsConversion.h b/src/Functions/FunctionsConversion.h index 589bd4cc16e..5af86d9ff8b 100644 --- a/src/Functions/FunctionsConversion.h +++ b/src/Functions/FunctionsConversion.h @@ -1277,7 +1277,7 @@ public: static constexpr bool to_string_or_fixed_string = std::is_same_v || std::is_same_v; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } static FunctionPtr create() { return std::make_shared(); } String getName() const override @@ -1592,7 +1592,7 @@ public: static constexpr bool to_datetime64 = std::is_same_v; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } static FunctionPtr create() { return std::make_shared(); } String getName() const override @@ -3196,7 +3196,7 @@ public: ? accurate_cast_name : (cast_type == CastType::accurateOrNull ? accurate_cast_or_null_name : cast_name); - static FunctionOverloadResolverPtr create(ContextPtr context) + static FunctionOverloadResolverPtr create(ContextConstPtr context) { return createImpl(context->getSettingsRef().cast_keep_nullable); } diff --git a/src/Functions/FunctionsEmbeddedDictionaries.h b/src/Functions/FunctionsEmbeddedDictionaries.h index 884f53125eb..a19c6226f91 100644 --- a/src/Functions/FunctionsEmbeddedDictionaries.h +++ b/src/Functions/FunctionsEmbeddedDictionaries.h @@ -483,7 +483,7 @@ struct NameRegionIn { static constexpr auto name = "regionIn" struct FunctionRegionToCity : public FunctionTransformWithDictionary { - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context->getEmbeddedDictionaries().getRegionsHierarchies()); } @@ -492,7 +492,7 @@ struct FunctionRegionToCity : struct FunctionRegionToArea : public FunctionTransformWithDictionary { - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context->getEmbeddedDictionaries().getRegionsHierarchies()); } @@ -501,7 +501,7 @@ struct FunctionRegionToArea : struct FunctionRegionToDistrict : public FunctionTransformWithDictionary { - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context->getEmbeddedDictionaries().getRegionsHierarchies()); } @@ -510,7 +510,7 @@ struct FunctionRegionToDistrict : struct FunctionRegionToCountry : public FunctionTransformWithDictionary { - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context->getEmbeddedDictionaries().getRegionsHierarchies()); } @@ -519,7 +519,7 @@ struct FunctionRegionToCountry : struct FunctionRegionToContinent : public FunctionTransformWithDictionary { - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context->getEmbeddedDictionaries().getRegionsHierarchies()); } @@ -528,7 +528,7 @@ struct FunctionRegionToContinent : struct FunctionRegionToTopContinent : public FunctionTransformWithDictionary { - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context->getEmbeddedDictionaries().getRegionsHierarchies()); } @@ -537,7 +537,7 @@ struct FunctionRegionToTopContinent : struct FunctionRegionToPopulation : public FunctionTransformWithDictionary { - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context->getEmbeddedDictionaries().getRegionsHierarchies()); } @@ -546,7 +546,7 @@ struct FunctionRegionToPopulation : struct FunctionRegionIn : public FunctionIsInWithDictionary { - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context->getEmbeddedDictionaries().getRegionsHierarchies()); } @@ -555,7 +555,7 @@ struct FunctionRegionIn : struct FunctionRegionHierarchy : public FunctionHierarchyWithDictionary { - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context->getEmbeddedDictionaries().getRegionsHierarchies()); } @@ -567,7 +567,7 @@ class FunctionRegionToName : public IFunction { public: static constexpr auto name = "regionToName"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context->getEmbeddedDictionaries().getRegionsNames()); } diff --git a/src/Functions/FunctionsExternalDictionaries.h b/src/Functions/FunctionsExternalDictionaries.h index 6d9e4ce6768..89c76f93061 100644 --- a/src/Functions/FunctionsExternalDictionaries.h +++ b/src/Functions/FunctionsExternalDictionaries.h @@ -62,10 +62,10 @@ namespace ErrorCodes */ -class FunctionDictHelper : WithContext +class FunctionDictHelper : WithConstContext { public: - explicit FunctionDictHelper(ContextPtr context_) : WithContext(context_) {} + explicit FunctionDictHelper(ContextConstPtr context_) : WithConstContext(context_) {} std::shared_ptr getDictionary(const String & dictionary_name) { @@ -132,12 +132,12 @@ class FunctionDictHas final : public IFunction public: static constexpr auto name = "dictHas"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } - explicit FunctionDictHas(ContextPtr context_) : helper(context_) {} + explicit FunctionDictHas(ContextConstPtr context_) : helper(context_) {} String getName() const override { return name; } @@ -270,12 +270,12 @@ class FunctionDictGetNoType final : public IFunction public: static constexpr auto name = dictionary_get_function_type == DictionaryGetFunctionType::get ? "dictGet" : "dictGetOrDefault"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } - explicit FunctionDictGetNoType(ContextPtr context_) : helper(context_) {} + explicit FunctionDictGetNoType(ContextConstPtr context_) : helper(context_) {} String getName() const override { return name; } @@ -604,12 +604,12 @@ class FunctionDictGetImpl final : public IFunction public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } - explicit FunctionDictGetImpl(ContextPtr context_) : impl(context_) {} + explicit FunctionDictGetImpl(ContextConstPtr context_) : impl(context_) {} String getName() const override { return name; } @@ -743,12 +743,12 @@ class FunctionDictGetOrNull final : public IFunction public: static constexpr auto name = "dictGetOrNull"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } - explicit FunctionDictGetOrNull(ContextPtr context_) + explicit FunctionDictGetOrNull(ContextConstPtr context_) : dictionary_get_func_impl(context_) , dictionary_has_func_impl(context_) {} @@ -906,12 +906,12 @@ class FunctionDictGetHierarchy final : public IFunction public: static constexpr auto name = "dictGetHierarchy"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } - explicit FunctionDictGetHierarchy(ContextPtr context_) : helper(context_) {} + explicit FunctionDictGetHierarchy(ContextConstPtr context_) : helper(context_) {} String getName() const override { return name; } @@ -966,12 +966,12 @@ class FunctionDictIsIn final : public IFunction public: static constexpr auto name = "dictIsIn"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } - explicit FunctionDictIsIn(ContextPtr context_) + explicit FunctionDictIsIn(ContextConstPtr context_) : helper(context_) {} String getName() const override { return name; } @@ -1032,12 +1032,12 @@ class FunctionDictGetChildren final : public IFunction public: static constexpr auto name = "dictGetChildren"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } - explicit FunctionDictGetChildren(ContextPtr context_) + explicit FunctionDictGetChildren(ContextConstPtr context_) : helper(context_) {} String getName() const override { return name; } @@ -1091,12 +1091,12 @@ class FunctionDictGetDescendants final : public IFunction public: static constexpr auto name = "dictGetDescendants"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } - explicit FunctionDictGetDescendants(ContextPtr context_) + explicit FunctionDictGetDescendants(ContextConstPtr context_) : helper(context_) {} String getName() const override { return name; } diff --git a/src/Functions/FunctionsExternalModels.cpp b/src/Functions/FunctionsExternalModels.cpp index da46f7fcb38..6bcaf13cd69 100644 --- a/src/Functions/FunctionsExternalModels.cpp +++ b/src/Functions/FunctionsExternalModels.cpp @@ -18,7 +18,7 @@ namespace DB { -FunctionPtr FunctionModelEvaluate::create(ContextPtr context) +FunctionPtr FunctionModelEvaluate::create(ContextConstPtr context) { return std::make_shared(context->getExternalModelsLoader()); } diff --git a/src/Functions/FunctionsExternalModels.h b/src/Functions/FunctionsExternalModels.h index 8f8b0e0c860..b9d611934e6 100644 --- a/src/Functions/FunctionsExternalModels.h +++ b/src/Functions/FunctionsExternalModels.h @@ -17,7 +17,7 @@ class FunctionModelEvaluate final : public IFunction public: static constexpr auto name = "modelEvaluate"; - static FunctionPtr create(ContextPtr context); + static FunctionPtr create(ContextConstPtr context); explicit FunctionModelEvaluate(const ExternalModelsLoader & models_loader_) : models_loader(models_loader_) {} diff --git a/src/Functions/FunctionsHashing.h b/src/Functions/FunctionsHashing.h index 690991759a3..25f57e06f2e 100644 --- a/src/Functions/FunctionsHashing.h +++ b/src/Functions/FunctionsHashing.h @@ -535,7 +535,7 @@ class FunctionStringHashFixedString : public IFunction { public: static constexpr auto name = Impl::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { @@ -700,7 +700,7 @@ template class FunctionIntHash : public TargetSpecific::Default::FunctionIntHash { public: - explicit FunctionIntHash(ContextPtr context) : selector(context) + explicit FunctionIntHash(ContextConstPtr context) : selector(context) { selector.registerImplementation>(); @@ -718,7 +718,7 @@ public: return selector.selectAndExecute(arguments, result_type, input_rows_count); } - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } @@ -1077,7 +1077,7 @@ template class FunctionAnyHash : public TargetSpecific::Default::FunctionAnyHash { public: - explicit FunctionAnyHash(ContextPtr context) : selector(context) + explicit FunctionAnyHash(ContextConstPtr context) : selector(context) { selector.registerImplementation>(); @@ -1095,7 +1095,7 @@ public: return selector.selectAndExecute(arguments, result_type, input_rows_count); } - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } @@ -1182,7 +1182,7 @@ class FunctionURLHash : public IFunction { public: static constexpr auto name = "URLHash"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/FunctionsJSON.h b/src/Functions/FunctionsJSON.h index 2b49d01de2c..6024658dd6f 100644 --- a/src/Functions/FunctionsJSON.h +++ b/src/Functions/FunctionsJSON.h @@ -270,11 +270,11 @@ private: template typename Impl> -class FunctionJSON : public IFunction, WithContext +class FunctionJSON : public IFunction, WithConstContext { public: - static FunctionPtr create(ContextPtr context_) { return std::make_shared(context_); } - FunctionJSON(ContextPtr context_) : WithContext(context_) {} + static FunctionPtr create(ContextConstPtr context_) { return std::make_shared(context_); } + FunctionJSON(ContextConstPtr context_) : WithConstContext(context_) {} static constexpr auto name = Name::name; String getName() const override { return Name::name; } diff --git a/src/Functions/FunctionsLogical.h b/src/Functions/FunctionsLogical.h index 264eeeef0fe..339cc25510d 100644 --- a/src/Functions/FunctionsLogical.h +++ b/src/Functions/FunctionsLogical.h @@ -139,7 +139,7 @@ class FunctionAnyArityLogical : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } public: String getName() const override @@ -206,7 +206,7 @@ class FunctionUnaryLogical : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } public: String getName() const override diff --git a/src/Functions/FunctionsMultiStringFuzzySearch.h b/src/Functions/FunctionsMultiStringFuzzySearch.h index 209efb0fc2f..3c6e67c1546 100644 --- a/src/Functions/FunctionsMultiStringFuzzySearch.h +++ b/src/Functions/FunctionsMultiStringFuzzySearch.h @@ -34,7 +34,7 @@ class FunctionsMultiStringFuzzySearch : public IFunction public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { if (Impl::is_using_hyperscan && !context->getSettingsRef().allow_hyperscan) throw Exception( diff --git a/src/Functions/FunctionsMultiStringPosition.h b/src/Functions/FunctionsMultiStringPosition.h index f36f7639ccd..68c658c0aa7 100644 --- a/src/Functions/FunctionsMultiStringPosition.h +++ b/src/Functions/FunctionsMultiStringPosition.h @@ -51,7 +51,7 @@ class FunctionsMultiStringPosition : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/FunctionsMultiStringSearch.h b/src/Functions/FunctionsMultiStringSearch.h index 08b4668940e..4d391124de9 100644 --- a/src/Functions/FunctionsMultiStringSearch.h +++ b/src/Functions/FunctionsMultiStringSearch.h @@ -47,7 +47,7 @@ class FunctionsMultiStringSearch : public IFunction public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { if (Impl::is_using_hyperscan && !context->getSettingsRef().allow_hyperscan) throw Exception( diff --git a/src/Functions/FunctionsRandom.h b/src/Functions/FunctionsRandom.h index 75037d02a2d..0eae9ef183f 100644 --- a/src/Functions/FunctionsRandom.h +++ b/src/Functions/FunctionsRandom.h @@ -91,7 +91,7 @@ template class FunctionRandom : public FunctionRandomImpl { public: - explicit FunctionRandom(ContextPtr context) : selector(context) + explicit FunctionRandom(ContextConstPtr context) : selector(context) { selector.registerImplementation>(); @@ -107,7 +107,7 @@ public: return selector.selectAndExecute(arguments, result_type, input_rows_count); } - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared>(context); } diff --git a/src/Functions/FunctionsRound.h b/src/Functions/FunctionsRound.h index f56b92d6db5..98f35e52a4c 100644 --- a/src/Functions/FunctionsRound.h +++ b/src/Functions/FunctionsRound.h @@ -520,7 +520,7 @@ class FunctionRounding : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { @@ -629,7 +629,7 @@ class FunctionRoundDown : public IFunction { public: static constexpr auto name = "roundDown"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/FunctionsStringArray.h b/src/Functions/FunctionsStringArray.h index 27f10797651..2141adbc72f 100644 --- a/src/Functions/FunctionsStringArray.h +++ b/src/Functions/FunctionsStringArray.h @@ -427,7 +427,7 @@ class FunctionTokens : public IFunction { public: static constexpr auto name = Generator::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { @@ -590,7 +590,7 @@ private: public: static constexpr auto name = "arrayStringConcat"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/FunctionsStringHash.h b/src/Functions/FunctionsStringHash.h index 37fa7d618b9..8336a4ee85f 100644 --- a/src/Functions/FunctionsStringHash.h +++ b/src/Functions/FunctionsStringHash.h @@ -35,7 +35,7 @@ public: static constexpr size_t max_shingle_size = 25; static constexpr size_t max_num_hashes = 25; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/FunctionsStringSearch.h b/src/Functions/FunctionsStringSearch.h index 0789247e2d4..524fe43f42f 100644 --- a/src/Functions/FunctionsStringSearch.h +++ b/src/Functions/FunctionsStringSearch.h @@ -51,7 +51,7 @@ class FunctionsStringSearch : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/FunctionsStringSearchToString.h b/src/Functions/FunctionsStringSearchToString.h index af91a9511e1..3b3383cf162 100644 --- a/src/Functions/FunctionsStringSearchToString.h +++ b/src/Functions/FunctionsStringSearchToString.h @@ -36,7 +36,7 @@ class FunctionsStringSearchToString : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/FunctionsStringSimilarity.h b/src/Functions/FunctionsStringSimilarity.h index 6efb373aace..49fc8a21129 100644 --- a/src/Functions/FunctionsStringSimilarity.h +++ b/src/Functions/FunctionsStringSimilarity.h @@ -33,7 +33,7 @@ class FunctionsStringSimilarity : public IFunction public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/FunctionsWindow.h b/src/Functions/FunctionsWindow.h index 5e5ec9db825..9e0957c7cdc 100644 --- a/src/Functions/FunctionsWindow.h +++ b/src/Functions/FunctionsWindow.h @@ -746,7 +746,7 @@ class FunctionWindow : public IFunction { public: static constexpr auto name = WindowImpl::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } bool isVariadic() const override { return true; } size_t getNumberOfArguments() const override { return 0; } diff --git a/src/Functions/LeastGreatestGeneric.h b/src/Functions/LeastGreatestGeneric.h index 51564ad7cdc..f33bda801cb 100644 --- a/src/Functions/LeastGreatestGeneric.h +++ b/src/Functions/LeastGreatestGeneric.h @@ -30,7 +30,7 @@ class FunctionLeastGreatestGeneric : public IFunction { public: static constexpr auto name = kind == LeastGreatest::Least ? "least" : "greatest"; - static FunctionPtr create(ContextPtr) { return std::make_shared>(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared>(); } private: String getName() const override { return name; } @@ -92,12 +92,12 @@ class LeastGreatestOverloadResolver : public IFunctionOverloadResolver public: static constexpr auto name = kind == LeastGreatest::Least ? "least" : "greatest"; - static FunctionOverloadResolverPtr create(ContextPtr context) + static FunctionOverloadResolverPtr create(ContextConstPtr context) { return std::make_unique>(context); } - explicit LeastGreatestOverloadResolver(ContextPtr context_) : context(context_) {} + explicit LeastGreatestOverloadResolver(ContextConstPtr context_) : context(context_) {} String getName() const override { return name; } size_t getNumberOfArguments() const override { return 0; } @@ -127,7 +127,7 @@ public: } private: - ContextPtr context; + ContextConstPtr context; }; } diff --git a/src/Functions/PerformanceAdaptors.h b/src/Functions/PerformanceAdaptors.h index 9ef6454d085..04bf19bbd88 100644 --- a/src/Functions/PerformanceAdaptors.h +++ b/src/Functions/PerformanceAdaptors.h @@ -172,7 +172,7 @@ namespace detail * /// default implementation. * class MyFunction : public MyDefaultImpl * { - * MyFunction(ContextPtr context) : selector(context) { + * MyFunction(ContextConstPtr context) : selector(context) { * /// Register all implementations in constructor. * /// There could be as many implementation for every target as you want. * selector.registerImplementation(); @@ -185,7 +185,7 @@ namespace detail * selector.selectAndExecute(...); * } * - * static FunctionPtr create(ContextPtr context) { + * static FunctionPtr create(ContextConstPtr context) { * return std::make_shared(context); * } * private: @@ -193,12 +193,12 @@ namespace detail * }; */ template -class ImplementationSelector : WithContext +class ImplementationSelector : WithConstContext { public: using ImplementationPtr = std::shared_ptr; - ImplementationSelector(ContextPtr context_) : WithContext(context_) {} + ImplementationSelector(ContextConstPtr context_) : WithConstContext(context_) {} /* Select the best implementation based on previous runs. * If FunctionInterface is IFunction, then "executeImpl" method of the implementation will be called diff --git a/src/Functions/URL/FirstSignificantSubdomainCustomImpl.h b/src/Functions/URL/FirstSignificantSubdomainCustomImpl.h index 4670d610725..fa985f194f3 100644 --- a/src/Functions/URL/FirstSignificantSubdomainCustomImpl.h +++ b/src/Functions/URL/FirstSignificantSubdomainCustomImpl.h @@ -36,7 +36,7 @@ class FunctionCutToFirstSignificantSubdomainCustomImpl : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } size_t getNumberOfArguments() const override { return 2; } diff --git a/src/Functions/URL/port.cpp b/src/Functions/URL/port.cpp index 179a2be4471..6f277de45a5 100644 --- a/src/Functions/URL/port.cpp +++ b/src/Functions/URL/port.cpp @@ -21,7 +21,7 @@ namespace ErrorCodes struct FunctionPort : public IFunction { static constexpr auto name = "port"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } bool isVariadic() const override { return true; } diff --git a/src/Functions/abtesting.cpp b/src/Functions/abtesting.cpp index 871357fe450..fa0e5e8a6bd 100644 --- a/src/Functions/abtesting.cpp +++ b/src/Functions/abtesting.cpp @@ -168,7 +168,7 @@ class FunctionBayesAB : public IFunction public: static constexpr auto name = "bayesAB"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/addressToLine.cpp b/src/Functions/addressToLine.cpp index aabf388b428..1ae8d9126bb 100644 --- a/src/Functions/addressToLine.cpp +++ b/src/Functions/addressToLine.cpp @@ -36,7 +36,7 @@ class FunctionAddressToLine : public IFunction { public: static constexpr auto name = "addressToLine"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { context->checkAccess(AccessType::addressToLine); return std::make_shared(); diff --git a/src/Functions/addressToSymbol.cpp b/src/Functions/addressToSymbol.cpp index 7ffdc6d4260..1c744a11755 100644 --- a/src/Functions/addressToSymbol.cpp +++ b/src/Functions/addressToSymbol.cpp @@ -28,7 +28,7 @@ class FunctionAddressToSymbol : public IFunction { public: static constexpr auto name = "addressToSymbol"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { context->checkAccess(AccessType::addressToSymbol); return std::make_shared(); diff --git a/src/Functions/appendTrailingCharIfAbsent.cpp b/src/Functions/appendTrailingCharIfAbsent.cpp index 266b2a44f4a..89d7f12f780 100644 --- a/src/Functions/appendTrailingCharIfAbsent.cpp +++ b/src/Functions/appendTrailingCharIfAbsent.cpp @@ -24,7 +24,7 @@ class FunctionAppendTrailingCharIfAbsent : public IFunction { public: static constexpr auto name = "appendTrailingCharIfAbsent"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/array/FunctionArrayMapped.h b/src/Functions/array/FunctionArrayMapped.h index 3609398bc3f..9b51000144f 100644 --- a/src/Functions/array/FunctionArrayMapped.h +++ b/src/Functions/array/FunctionArrayMapped.h @@ -44,7 +44,7 @@ class FunctionArrayMapped : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/array/array.cpp b/src/Functions/array/array.cpp index 1f513defc6f..62ae0b4f2d8 100644 --- a/src/Functions/array/array.cpp +++ b/src/Functions/array/array.cpp @@ -14,7 +14,7 @@ class FunctionArray : public IFunction { public: static constexpr auto name = "array"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/array/arrayConcat.cpp b/src/Functions/array/arrayConcat.cpp index 57a783a3244..23193e28816 100644 --- a/src/Functions/array/arrayConcat.cpp +++ b/src/Functions/array/arrayConcat.cpp @@ -26,7 +26,7 @@ class FunctionArrayConcat : public IFunction { public: static constexpr auto name = "arrayConcat"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/array/arrayDistinct.cpp b/src/Functions/array/arrayDistinct.cpp index 916af560c8f..164e3b19c83 100644 --- a/src/Functions/array/arrayDistinct.cpp +++ b/src/Functions/array/arrayDistinct.cpp @@ -26,7 +26,7 @@ class FunctionArrayDistinct : public IFunction public: static constexpr auto name = "arrayDistinct"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/array/arrayElement.cpp b/src/Functions/array/arrayElement.cpp index f3d3f558d7b..5ec5c4d4213 100644 --- a/src/Functions/array/arrayElement.cpp +++ b/src/Functions/array/arrayElement.cpp @@ -41,7 +41,7 @@ class FunctionArrayElement : public IFunction { public: static constexpr auto name = "arrayElement"; - static FunctionPtr create(ContextPtr context); + static FunctionPtr create(ContextConstPtr context); String getName() const override; @@ -449,7 +449,7 @@ struct ArrayElementGenericImpl } -FunctionPtr FunctionArrayElement::create(ContextPtr) +FunctionPtr FunctionArrayElement::create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/array/arrayEnumerate.cpp b/src/Functions/array/arrayEnumerate.cpp index 6d59a2c3805..a80e4f9e016 100644 --- a/src/Functions/array/arrayEnumerate.cpp +++ b/src/Functions/array/arrayEnumerate.cpp @@ -22,7 +22,7 @@ class FunctionArrayEnumerate : public IFunction public: static constexpr auto name = "arrayEnumerate"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/array/arrayEnumerateExtended.h b/src/Functions/array/arrayEnumerateExtended.h index 7e4fe24873a..921a0f0c75d 100644 --- a/src/Functions/array/arrayEnumerateExtended.h +++ b/src/Functions/array/arrayEnumerateExtended.h @@ -30,7 +30,7 @@ template class FunctionArrayEnumerateExtended : public IFunction { public: - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return Derived::name; } diff --git a/src/Functions/array/arrayEnumerateRanked.h b/src/Functions/array/arrayEnumerateRanked.h index 2c999415f33..3dbb2d2d0c9 100644 --- a/src/Functions/array/arrayEnumerateRanked.h +++ b/src/Functions/array/arrayEnumerateRanked.h @@ -90,7 +90,7 @@ template class FunctionArrayEnumerateRankedExtended : public IFunction { public: - static FunctionPtr create(ContextPtr /* context */) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr /* context */) { return std::make_shared(); } String getName() const override { return Derived::name; } diff --git a/src/Functions/array/arrayFlatten.cpp b/src/Functions/array/arrayFlatten.cpp index 3d286aa0bb4..dfd1811d91d 100644 --- a/src/Functions/array/arrayFlatten.cpp +++ b/src/Functions/array/arrayFlatten.cpp @@ -20,7 +20,7 @@ class ArrayFlatten : public IFunction public: static constexpr auto name = "arrayFlatten"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } size_t getNumberOfArguments() const override { return 1; } bool useDefaultImplementationForConstants() const override { return true; } diff --git a/src/Functions/array/arrayIndex.h b/src/Functions/array/arrayIndex.h index f3b279faaef..fbd3501298e 100644 --- a/src/Functions/array/arrayIndex.h +++ b/src/Functions/array/arrayIndex.h @@ -355,7 +355,7 @@ class FunctionArrayIndex : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } /// Get function name. String getName() const override { return name; } diff --git a/src/Functions/array/arrayIntersect.cpp b/src/Functions/array/arrayIntersect.cpp index 93c1ee06403..1d3bcdd6fcc 100644 --- a/src/Functions/array/arrayIntersect.cpp +++ b/src/Functions/array/arrayIntersect.cpp @@ -38,8 +38,8 @@ class FunctionArrayIntersect : public IFunction { public: static constexpr auto name = "arrayIntersect"; - static FunctionPtr create(ContextPtr context) { return std::make_shared(context); } - explicit FunctionArrayIntersect(ContextPtr context_) : context(context_) {} + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } + explicit FunctionArrayIntersect(ContextConstPtr context_) : context(context_) {} String getName() const override { return name; } @@ -53,7 +53,7 @@ public: bool useDefaultImplementationForConstants() const override { return true; } private: - ContextPtr context; + ContextConstPtr context; /// Initially allocate a piece of memory for 64 elements. NOTE: This is just a guess. static constexpr size_t INITIAL_SIZE_DEGREE = 6; @@ -281,7 +281,7 @@ FunctionArrayIntersect::CastArgumentsResult FunctionArrayIntersect::castColumns( return {.initial = initial_columns, .casted = casted_columns}; } -static ColumnPtr callFunctionNotEquals(ColumnWithTypeAndName first, ColumnWithTypeAndName second, ContextPtr context) +static ColumnPtr callFunctionNotEquals(ColumnWithTypeAndName first, ColumnWithTypeAndName second, ContextConstPtr context) { ColumnsWithTypeAndName args{first, second}; auto eq_func = FunctionFactory::instance().get("notEquals", context)->build(args); diff --git a/src/Functions/array/arrayJoin.cpp b/src/Functions/array/arrayJoin.cpp index da8c4e6e80b..953c29ae67d 100644 --- a/src/Functions/array/arrayJoin.cpp +++ b/src/Functions/array/arrayJoin.cpp @@ -20,7 +20,7 @@ class FunctionArrayJoin : public IFunction { public: static constexpr auto name = "arrayJoin"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/array/arrayPopBack.cpp b/src/Functions/array/arrayPopBack.cpp index 0b532c22661..dea16c228fb 100644 --- a/src/Functions/array/arrayPopBack.cpp +++ b/src/Functions/array/arrayPopBack.cpp @@ -9,7 +9,7 @@ class FunctionArrayPopBack : public FunctionArrayPop { public: static constexpr auto name = "arrayPopBack"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } FunctionArrayPopBack() : FunctionArrayPop(false, name) {} }; diff --git a/src/Functions/array/arrayPopFront.cpp b/src/Functions/array/arrayPopFront.cpp index 57eedf9b44a..14a2d5f583e 100644 --- a/src/Functions/array/arrayPopFront.cpp +++ b/src/Functions/array/arrayPopFront.cpp @@ -9,7 +9,7 @@ class FunctionArrayPopFront : public FunctionArrayPop { public: static constexpr auto name = "arrayPopFront"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } FunctionArrayPopFront() : FunctionArrayPop(true, name) {} }; diff --git a/src/Functions/array/arrayPushBack.cpp b/src/Functions/array/arrayPushBack.cpp index 3171bca9d2c..1e12bf72d87 100644 --- a/src/Functions/array/arrayPushBack.cpp +++ b/src/Functions/array/arrayPushBack.cpp @@ -9,7 +9,7 @@ class FunctionArrayPushBack : public FunctionArrayPush { public: static constexpr auto name = "arrayPushBack"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } FunctionArrayPushBack() : FunctionArrayPush(false, name) {} }; diff --git a/src/Functions/array/arrayPushFront.cpp b/src/Functions/array/arrayPushFront.cpp index d12dfe02af1..08b4efa207e 100644 --- a/src/Functions/array/arrayPushFront.cpp +++ b/src/Functions/array/arrayPushFront.cpp @@ -10,7 +10,7 @@ class FunctionArrayPushFront : public FunctionArrayPush { public: static constexpr auto name = "arrayPushFront"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } FunctionArrayPushFront() : FunctionArrayPush(true, name) {} }; diff --git a/src/Functions/array/arrayReduce.cpp b/src/Functions/array/arrayReduce.cpp index bbdd142c062..3126554c127 100644 --- a/src/Functions/array/arrayReduce.cpp +++ b/src/Functions/array/arrayReduce.cpp @@ -37,7 +37,7 @@ class FunctionArrayReduce : public IFunction { public: static constexpr auto name = "arrayReduce"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/array/arrayReduceInRanges.cpp b/src/Functions/array/arrayReduceInRanges.cpp index bcb34385d17..dfeb79027f2 100644 --- a/src/Functions/array/arrayReduceInRanges.cpp +++ b/src/Functions/array/arrayReduceInRanges.cpp @@ -40,7 +40,7 @@ class FunctionArrayReduceInRanges : public IFunction public: static const size_t minimum_step = 64; static constexpr auto name = "arrayReduceInRanges"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/array/arrayResize.cpp b/src/Functions/array/arrayResize.cpp index f8eea06335b..03b0430d6ec 100644 --- a/src/Functions/array/arrayResize.cpp +++ b/src/Functions/array/arrayResize.cpp @@ -25,7 +25,7 @@ class FunctionArrayResize : public IFunction { public: static constexpr auto name = "arrayResize"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/array/arrayReverse.cpp b/src/Functions/array/arrayReverse.cpp index fb4a559b37f..2a2e24828ac 100644 --- a/src/Functions/array/arrayReverse.cpp +++ b/src/Functions/array/arrayReverse.cpp @@ -24,7 +24,7 @@ class FunctionArrayReverse : public IFunction { public: static constexpr auto name = "arrayReverse"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/array/arrayScalarProduct.h b/src/Functions/array/arrayScalarProduct.h index 6a23d6a45d8..0d35157d133 100644 --- a/src/Functions/array/arrayScalarProduct.h +++ b/src/Functions/array/arrayScalarProduct.h @@ -25,7 +25,7 @@ class FunctionArrayScalarProduct : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } private: using ResultColumnType = ColumnVector; diff --git a/src/Functions/array/arraySlice.cpp b/src/Functions/array/arraySlice.cpp index 567135de884..4fc32bfa981 100644 --- a/src/Functions/array/arraySlice.cpp +++ b/src/Functions/array/arraySlice.cpp @@ -34,7 +34,7 @@ class FunctionArraySlice : public IFunction { public: static constexpr auto name = "arraySlice"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/array/arrayUniq.cpp b/src/Functions/array/arrayUniq.cpp index 62de746f136..6d461206f38 100644 --- a/src/Functions/array/arrayUniq.cpp +++ b/src/Functions/array/arrayUniq.cpp @@ -31,7 +31,7 @@ class FunctionArrayUniq : public IFunction public: static constexpr auto name = "arrayUniq"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/array/arrayWithConstant.cpp b/src/Functions/array/arrayWithConstant.cpp index 578e8bf2296..7d00c2227ee 100644 --- a/src/Functions/array/arrayWithConstant.cpp +++ b/src/Functions/array/arrayWithConstant.cpp @@ -30,7 +30,7 @@ class FunctionArrayWithConstant : public IFunction public: static constexpr auto name = "arrayWithConstant"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } size_t getNumberOfArguments() const override { return 2; } diff --git a/src/Functions/array/arrayZip.cpp b/src/Functions/array/arrayZip.cpp index f77b4f6dfe9..8e4d41ffca2 100644 --- a/src/Functions/array/arrayZip.cpp +++ b/src/Functions/array/arrayZip.cpp @@ -23,7 +23,7 @@ class FunctionArrayZip : public IFunction { public: static constexpr auto name = "arrayZip"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/array/emptyArray.cpp b/src/Functions/array/emptyArray.cpp index 370c51f3e8d..38b68043628 100644 --- a/src/Functions/array/emptyArray.cpp +++ b/src/Functions/array/emptyArray.cpp @@ -22,7 +22,7 @@ class FunctionEmptyArray : public IFunction { public: static String getNameImpl() { return "emptyArray" + DataType().getName(); } - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } private: String getName() const override diff --git a/src/Functions/array/emptyArrayToSingle.cpp b/src/Functions/array/emptyArrayToSingle.cpp index be387620e60..a116adca4e7 100644 --- a/src/Functions/array/emptyArrayToSingle.cpp +++ b/src/Functions/array/emptyArrayToSingle.cpp @@ -27,7 +27,7 @@ class FunctionEmptyArrayToSingle : public IFunction { public: static constexpr auto name = "emptyArrayToSingle"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/array/hasAll.cpp b/src/Functions/array/hasAll.cpp index c1959515e9f..7b5b83334b9 100644 --- a/src/Functions/array/hasAll.cpp +++ b/src/Functions/array/hasAll.cpp @@ -10,7 +10,7 @@ class FunctionArrayHasAll : public FunctionArrayHasAllAny { public: static constexpr auto name = "hasAll"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } FunctionArrayHasAll() : FunctionArrayHasAllAny(GatherUtils::ArraySearchType::All, name) {} }; diff --git a/src/Functions/array/hasAny.cpp b/src/Functions/array/hasAny.cpp index fac810c7ba1..94d429d6c0e 100644 --- a/src/Functions/array/hasAny.cpp +++ b/src/Functions/array/hasAny.cpp @@ -10,7 +10,7 @@ class FunctionArrayHasAny : public FunctionArrayHasAllAny { public: static constexpr auto name = "hasAny"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } FunctionArrayHasAny() : FunctionArrayHasAllAny(GatherUtils::ArraySearchType::Any, name) {} }; diff --git a/src/Functions/array/hasSubstr.cpp b/src/Functions/array/hasSubstr.cpp index 886f82f577b..f304e8bc3ba 100644 --- a/src/Functions/array/hasSubstr.cpp +++ b/src/Functions/array/hasSubstr.cpp @@ -10,7 +10,7 @@ class FunctionArrayHasSubstr : public FunctionArrayHasAllAny { public: static constexpr auto name = "hasSubstr"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } FunctionArrayHasSubstr() : FunctionArrayHasAllAny(GatherUtils::ArraySearchType::Substr, name) {} }; diff --git a/src/Functions/array/mapOp.cpp b/src/Functions/array/mapOp.cpp index 1a19ee41d2f..0709c1f2664 100644 --- a/src/Functions/array/mapOp.cpp +++ b/src/Functions/array/mapOp.cpp @@ -43,7 +43,7 @@ class FunctionMapOp : public IFunction { public: static constexpr auto name = (op_type == OpTypes::ADD) ? "mapAdd" : "mapSubtract"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } private: String getName() const override { return name; } diff --git a/src/Functions/array/mapPopulateSeries.cpp b/src/Functions/array/mapPopulateSeries.cpp index eb2f6192346..7e05eb81150 100644 --- a/src/Functions/array/mapPopulateSeries.cpp +++ b/src/Functions/array/mapPopulateSeries.cpp @@ -23,7 +23,7 @@ class FunctionMapPopulateSeries : public IFunction { public: static constexpr auto name = "mapPopulateSeries"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } private: String getName() const override { return name; } diff --git a/src/Functions/array/range.cpp b/src/Functions/array/range.cpp index 5b9886580dc..9f4c9fb0676 100644 --- a/src/Functions/array/range.cpp +++ b/src/Functions/array/range.cpp @@ -32,7 +32,7 @@ class FunctionRange : public IFunction public: static constexpr auto name = "range"; static constexpr size_t max_elements = 100'000'000; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } private: String getName() const override { return name; } diff --git a/src/Functions/assumeNotNull.cpp b/src/Functions/assumeNotNull.cpp index 019c637e50c..2b8743b1507 100644 --- a/src/Functions/assumeNotNull.cpp +++ b/src/Functions/assumeNotNull.cpp @@ -19,7 +19,7 @@ class FunctionAssumeNotNull : public IFunction public: static constexpr auto name = "assumeNotNull"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/bar.cpp b/src/Functions/bar.cpp index 2e26f7af0bb..49f3be46d60 100644 --- a/src/Functions/bar.cpp +++ b/src/Functions/bar.cpp @@ -28,7 +28,7 @@ class FunctionBar : public IFunction { public: static constexpr auto name = "bar"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/bitHammingDistance.cpp b/src/Functions/bitHammingDistance.cpp index 25b902b8bd5..a89ffa16010 100644 --- a/src/Functions/bitHammingDistance.cpp +++ b/src/Functions/bitHammingDistance.cpp @@ -74,7 +74,7 @@ class FunctionBitHammingDistance : public IFunction public: static constexpr auto name = "bitHammingDistance"; using ResultType = UInt8; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/bitmaskToList.cpp b/src/Functions/bitmaskToList.cpp index 8c3105724ac..0f3362aa031 100644 --- a/src/Functions/bitmaskToList.cpp +++ b/src/Functions/bitmaskToList.cpp @@ -30,7 +30,7 @@ class FunctionBitmaskToList : public IFunction { public: static constexpr auto name = "bitmaskToList"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/blockNumber.cpp b/src/Functions/blockNumber.cpp index 9a57f8a96b0..6998c02b3b6 100644 --- a/src/Functions/blockNumber.cpp +++ b/src/Functions/blockNumber.cpp @@ -18,7 +18,7 @@ private: public: static constexpr auto name = "blockNumber"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/blockSerializedSize.cpp b/src/Functions/blockSerializedSize.cpp index 30f77bbf627..bd65f6dd084 100644 --- a/src/Functions/blockSerializedSize.cpp +++ b/src/Functions/blockSerializedSize.cpp @@ -15,7 +15,7 @@ class FunctionBlockSerializedSize : public IFunction public: static constexpr auto name = "blockSerializedSize"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/blockSize.cpp b/src/Functions/blockSize.cpp index 294686054f0..481a89b1b82 100644 --- a/src/Functions/blockSize.cpp +++ b/src/Functions/blockSize.cpp @@ -15,7 +15,7 @@ class FunctionBlockSize : public IFunction { public: static constexpr auto name = "blockSize"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/buildId.cpp b/src/Functions/buildId.cpp index cc0c21350ca..4f452ac38a2 100644 --- a/src/Functions/buildId.cpp +++ b/src/Functions/buildId.cpp @@ -18,7 +18,7 @@ class FunctionBuildId : public IFunction { public: static constexpr auto name = "buildId"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/byteSize.cpp b/src/Functions/byteSize.cpp index 54a7da59b9c..5d43ddb2929 100644 --- a/src/Functions/byteSize.cpp +++ b/src/Functions/byteSize.cpp @@ -17,7 +17,7 @@ class FunctionByteSize : public IFunction { public: static constexpr auto name = "byteSize"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/caseWithExpression.cpp b/src/Functions/caseWithExpression.cpp index 24b5855cc5b..95c06ee683a 100644 --- a/src/Functions/caseWithExpression.cpp +++ b/src/Functions/caseWithExpression.cpp @@ -20,9 +20,9 @@ class FunctionCaseWithExpression : public IFunction { public: static constexpr auto name = "caseWithExpression"; - static FunctionPtr create(ContextPtr context_) { return std::make_shared(context_); } + static FunctionPtr create(ContextConstPtr context_) { return std::make_shared(context_); } - explicit FunctionCaseWithExpression(ContextPtr context_) : context(context_) {} + explicit FunctionCaseWithExpression(ContextConstPtr context_) : context(context_) {} bool isVariadic() const override { return true; } size_t getNumberOfArguments() const override { return 0; } String getName() const override { return name; } @@ -98,7 +98,7 @@ public: } private: - ContextPtr context; + ContextConstPtr context; }; } diff --git a/src/Functions/coalesce.cpp b/src/Functions/coalesce.cpp index 791b9d993b4..69b69b7d3f1 100644 --- a/src/Functions/coalesce.cpp +++ b/src/Functions/coalesce.cpp @@ -24,12 +24,12 @@ class FunctionCoalesce : public IFunction public: static constexpr auto name = "coalesce"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } - explicit FunctionCoalesce(ContextPtr context_) : context(context_) {} + explicit FunctionCoalesce(ContextConstPtr context_) : context(context_) {} std::string getName() const override { @@ -160,7 +160,7 @@ public: } private: - ContextPtr context; + ContextConstPtr context; }; } diff --git a/src/Functions/concat.cpp b/src/Functions/concat.cpp index c1b9f8e7967..cc5636ffb5f 100644 --- a/src/Functions/concat.cpp +++ b/src/Functions/concat.cpp @@ -33,8 +33,8 @@ class ConcatImpl : public IFunction { public: static constexpr auto name = Name::name; - explicit ConcatImpl(ContextPtr context_) : context(context_) {} - static FunctionPtr create(ContextPtr context) { return std::make_shared(context); } + explicit ConcatImpl(ContextConstPtr context_) : context(context_) {} + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } String getName() const override { return name; } @@ -85,7 +85,7 @@ public: } private: - ContextWeakPtr context; + ContextWeakConstPtr context; ColumnPtr executeBinary(const ColumnsWithTypeAndName & arguments, size_t input_rows_count) const { @@ -191,9 +191,9 @@ class ConcatOverloadResolver : public IFunctionOverloadResolver { public: static constexpr auto name = "concat"; - static FunctionOverloadResolverPtr create(ContextPtr context) { return std::make_unique(context); } + static FunctionOverloadResolverPtr create(ContextConstPtr context) { return std::make_unique(context); } - explicit ConcatOverloadResolver(ContextPtr context_) : context(context_) {} + explicit ConcatOverloadResolver(ContextConstPtr context_) : context(context_) {} String getName() const override { return name; } size_t getNumberOfArguments() const override { return 0; } @@ -223,7 +223,7 @@ public: } private: - ContextPtr context; + ContextConstPtr context; }; } diff --git a/src/Functions/connectionId.cpp b/src/Functions/connectionId.cpp index ae04cfd1af6..4d22bb6ffad 100644 --- a/src/Functions/connectionId.cpp +++ b/src/Functions/connectionId.cpp @@ -8,14 +8,14 @@ namespace DB { /// Get the connection Id. It's used for MySQL handler only. -class FunctionConnectionId : public IFunction, WithContext +class FunctionConnectionId : public IFunction, WithConstContext { public: static constexpr auto name = "connectionId"; - explicit FunctionConnectionId(ContextPtr context_) : WithContext(context_) {} + explicit FunctionConnectionId(ContextConstPtr context_) : WithConstContext(context_) {} - static FunctionPtr create(ContextPtr context_) { return std::make_shared(context_); } + static FunctionPtr create(ContextConstPtr context_) { return std::make_shared(context_); } String getName() const override { return name; } diff --git a/src/Functions/convertCharset.cpp b/src/Functions/convertCharset.cpp index b204875b4ff..e7a43e73a80 100644 --- a/src/Functions/convertCharset.cpp +++ b/src/Functions/convertCharset.cpp @@ -162,7 +162,7 @@ private: public: static constexpr auto name = "convertCharset"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/countDigits.cpp b/src/Functions/countDigits.cpp index 597a2c625b9..76038a88d41 100644 --- a/src/Functions/countDigits.cpp +++ b/src/Functions/countDigits.cpp @@ -28,7 +28,7 @@ class FunctionCountDigits : public IFunction public: static constexpr auto name = "countDigits"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/countMatches.h b/src/Functions/countMatches.h index 6ae69520cb9..0c6a95a94ea 100644 --- a/src/Functions/countMatches.h +++ b/src/Functions/countMatches.h @@ -27,7 +27,7 @@ class FunctionCountMatches : public IFunction { public: static constexpr auto name = CountMatchesBase::name; - static FunctionPtr create(ContextPtr) { return std::make_shared>(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared>(); } String getName() const override { return name; } size_t getNumberOfArguments() const override { return 2; } diff --git a/src/Functions/currentDatabase.cpp b/src/Functions/currentDatabase.cpp index 16eff20cfd5..efb98260e02 100644 --- a/src/Functions/currentDatabase.cpp +++ b/src/Functions/currentDatabase.cpp @@ -16,7 +16,7 @@ class FunctionCurrentDatabase : public IFunction public: static constexpr auto name = "currentDatabase"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context->getCurrentDatabase()); } diff --git a/src/Functions/currentUser.cpp b/src/Functions/currentUser.cpp index 22ad49fb29d..ea9943b3647 100644 --- a/src/Functions/currentUser.cpp +++ b/src/Functions/currentUser.cpp @@ -16,7 +16,7 @@ class FunctionCurrentUser : public IFunction public: static constexpr auto name = "currentUser"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context->getClientInfo().initial_user); } diff --git a/src/Functions/dateDiff.cpp b/src/Functions/dateDiff.cpp index cbad9dc1ce4..9d8b98aab41 100644 --- a/src/Functions/dateDiff.cpp +++ b/src/Functions/dateDiff.cpp @@ -47,7 +47,7 @@ class FunctionDateDiff : public IFunction using ColumnDateTime64 = ColumnDecimal; public: static constexpr auto name = "dateDiff"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/date_trunc.cpp b/src/Functions/date_trunc.cpp index 7952eda4f2b..d90586d6703 100644 --- a/src/Functions/date_trunc.cpp +++ b/src/Functions/date_trunc.cpp @@ -25,9 +25,9 @@ class FunctionDateTrunc : public IFunction public: static constexpr auto name = "date_trunc"; - explicit FunctionDateTrunc(ContextPtr context_) : context(context_) {} + explicit FunctionDateTrunc(ContextConstPtr context_) : context(context_) {} - static FunctionPtr create(ContextPtr context) { return std::make_shared(context); } + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } String getName() const override { return name; } @@ -146,7 +146,7 @@ public: } private: - ContextPtr context; + ContextConstPtr context; mutable IntervalKind::Kind datepart_kind = IntervalKind::Kind::Second; }; diff --git a/src/Functions/defaultValueOfArgumentType.cpp b/src/Functions/defaultValueOfArgumentType.cpp index c0abe1b63d9..d7f6be1b55f 100644 --- a/src/Functions/defaultValueOfArgumentType.cpp +++ b/src/Functions/defaultValueOfArgumentType.cpp @@ -13,7 +13,7 @@ class FunctionDefaultValueOfArgumentType : public IFunction { public: static constexpr auto name = "defaultValueOfArgumentType"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/defaultValueOfTypeName.cpp b/src/Functions/defaultValueOfTypeName.cpp index 1bf978ab17b..fec72067069 100644 --- a/src/Functions/defaultValueOfTypeName.cpp +++ b/src/Functions/defaultValueOfTypeName.cpp @@ -21,7 +21,7 @@ class FunctionDefaultValueOfTypeName : public IFunction { public: static constexpr auto name = "defaultValueOfTypeName"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/demange.cpp b/src/Functions/demange.cpp index 755a50dccbb..b2df742b30a 100644 --- a/src/Functions/demange.cpp +++ b/src/Functions/demange.cpp @@ -25,7 +25,7 @@ class FunctionDemangle : public IFunction { public: static constexpr auto name = "demangle"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { context->checkAccess(AccessType::demangle); return std::make_shared(); diff --git a/src/Functions/dumpColumnStructure.cpp b/src/Functions/dumpColumnStructure.cpp index 3189e343beb..28e1b874f3e 100644 --- a/src/Functions/dumpColumnStructure.cpp +++ b/src/Functions/dumpColumnStructure.cpp @@ -14,7 +14,7 @@ class FunctionDumpColumnStructure : public IFunction { public: static constexpr auto name = "dumpColumnStructure"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/errorCodeToName.cpp b/src/Functions/errorCodeToName.cpp index d8e8e0f0d29..617731ba78c 100644 --- a/src/Functions/errorCodeToName.cpp +++ b/src/Functions/errorCodeToName.cpp @@ -19,7 +19,7 @@ class FunctionErrorCodeToName : public IFunction { public: static constexpr auto name = "errorCodeToName"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/evalMLMethod.cpp b/src/Functions/evalMLMethod.cpp index a69a6f0f550..1ad5d10df92 100644 --- a/src/Functions/evalMLMethod.cpp +++ b/src/Functions/evalMLMethod.cpp @@ -28,11 +28,11 @@ class FunctionEvalMLMethod : public IFunction { public: static constexpr auto name = "evalMLMethod"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } - explicit FunctionEvalMLMethod(ContextPtr context_) : context(context_) + explicit FunctionEvalMLMethod(ContextConstPtr context_) : context(context_) {} String getName() const override @@ -81,7 +81,7 @@ public: return agg_function->predictValues(arguments, context); } - ContextPtr context; + ContextConstPtr context; }; } diff --git a/src/Functions/extractAllGroups.h b/src/Functions/extractAllGroups.h index 864a788cf18..866a900f6a7 100644 --- a/src/Functions/extractAllGroups.h +++ b/src/Functions/extractAllGroups.h @@ -51,7 +51,7 @@ public: static constexpr auto Kind = Impl::Kind; static constexpr auto name = Impl::Name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/extractGroups.cpp b/src/Functions/extractGroups.cpp index f1d728ee3f6..981382828bd 100644 --- a/src/Functions/extractGroups.cpp +++ b/src/Functions/extractGroups.cpp @@ -31,7 +31,7 @@ class FunctionExtractGroups : public IFunction { public: static constexpr auto name = "extractGroups"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/extractTextFromHTML.cpp b/src/Functions/extractTextFromHTML.cpp index 6a7bdbeaba9..aa7c208904e 100644 --- a/src/Functions/extractTextFromHTML.cpp +++ b/src/Functions/extractTextFromHTML.cpp @@ -296,7 +296,7 @@ class FunctionExtractTextFromHTML : public IFunction public: static constexpr auto name = "extractTextFromHTML"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } size_t getNumberOfArguments() const override { return 1; } bool useDefaultImplementationForConstants() const override { return true; } diff --git a/src/Functions/filesystem.cpp b/src/Functions/filesystem.cpp index d264c972656..d60b2133813 100644 --- a/src/Functions/filesystem.cpp +++ b/src/Functions/filesystem.cpp @@ -34,7 +34,7 @@ class FilesystemImpl : public IFunction public: static constexpr auto name = Impl::name; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared>(std::filesystem::space(context->getConfigRef().getString("path"))); } diff --git a/src/Functions/finalizeAggregation.cpp b/src/Functions/finalizeAggregation.cpp index b3dfbc0aa15..c8379e6a66f 100644 --- a/src/Functions/finalizeAggregation.cpp +++ b/src/Functions/finalizeAggregation.cpp @@ -24,7 +24,7 @@ class FunctionFinalizeAggregation : public IFunction { public: static constexpr auto name = "finalizeAggregation"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/formatDateTime.cpp b/src/Functions/formatDateTime.cpp index d16985b5b34..c64c182baf6 100644 --- a/src/Functions/formatDateTime.cpp +++ b/src/Functions/formatDateTime.cpp @@ -281,7 +281,7 @@ private: public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/formatReadable.h b/src/Functions/formatReadable.h index 6cf4fadbf05..fc8f5afe764 100644 --- a/src/Functions/formatReadable.h +++ b/src/Functions/formatReadable.h @@ -28,7 +28,7 @@ class FunctionFormatReadable : public IFunction { public: static constexpr auto name = Impl::name; - static FunctionPtr create(ContextPtr) { return std::make_shared>(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared>(); } String getName() const override { diff --git a/src/Functions/formatReadableTimeDelta.cpp b/src/Functions/formatReadableTimeDelta.cpp index 69dbaa71041..1be6fdf36c5 100644 --- a/src/Functions/formatReadableTimeDelta.cpp +++ b/src/Functions/formatReadableTimeDelta.cpp @@ -38,7 +38,7 @@ class FunctionFormatReadableTimeDelta : public IFunction { public: static constexpr auto name = "formatReadableTimeDelta"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/formatRow.cpp b/src/Functions/formatRow.cpp index 2d7739a02d6..60ed6be1351 100644 --- a/src/Functions/formatRow.cpp +++ b/src/Functions/formatRow.cpp @@ -35,7 +35,7 @@ class FunctionFormatRow : public IFunction public: static constexpr auto name = no_newline ? "formatRowNoNewline" : "formatRow"; - FunctionFormatRow(const String & format_name_, ContextPtr context_) : format_name(format_name_), context(context_) + FunctionFormatRow(const String & format_name_, ContextConstPtr context_) : format_name(format_name_), context(context_) { if (!FormatFactory::instance().getAllFormats().count(format_name)) throw Exception("Unknown format " + format_name, ErrorCodes::UNKNOWN_FORMAT); @@ -76,7 +76,7 @@ public: private: String format_name; - ContextPtr context; + ContextConstPtr context; }; template @@ -84,8 +84,8 @@ class FormatRowOverloadResolver : public IFunctionOverloadResolver { public: static constexpr auto name = no_newline ? "formatRowNoNewline" : "formatRow"; - static FunctionOverloadResolverPtr create(ContextPtr context) { return std::make_unique(context); } - explicit FormatRowOverloadResolver(ContextPtr context_) : context(context_) { } + static FunctionOverloadResolverPtr create(ContextConstPtr context) { return std::make_unique(context); } + explicit FormatRowOverloadResolver(ContextConstPtr context_) : context(context_) { } String getName() const override { return name; } bool isVariadic() const override { return true; } size_t getNumberOfArguments() const override { return 0; } @@ -111,7 +111,7 @@ public: DataTypePtr getReturnTypeImpl(const DataTypes &) const override { return std::make_shared(); } private: - ContextPtr context; + ContextConstPtr context; }; } diff --git a/src/Functions/formatString.cpp b/src/Functions/formatString.cpp index 4a3b04aaa05..9c222d085c2 100644 --- a/src/Functions/formatString.cpp +++ b/src/Functions/formatString.cpp @@ -31,7 +31,7 @@ class FormatFunction : public IFunction public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/fromModifiedJulianDay.cpp b/src/Functions/fromModifiedJulianDay.cpp index bdd8b9b6bd4..277d876e42f 100644 --- a/src/Functions/fromModifiedJulianDay.cpp +++ b/src/Functions/fromModifiedJulianDay.cpp @@ -151,7 +151,7 @@ namespace DB public: static constexpr auto name = Name::name; - static FunctionOverloadResolverPtr create(ContextPtr) + static FunctionOverloadResolverPtr create(ContextConstPtr) { return std::make_unique>(); } diff --git a/src/Functions/fromUnixTimestamp64Micro.cpp b/src/Functions/fromUnixTimestamp64Micro.cpp index 1fd98e6e673..7eb9e41474b 100644 --- a/src/Functions/fromUnixTimestamp64Micro.cpp +++ b/src/Functions/fromUnixTimestamp64Micro.cpp @@ -7,7 +7,7 @@ namespace DB void registerFromUnixTimestamp64Micro(FunctionFactory & factory) { factory.registerFunction("fromUnixTimestamp64Micro", - [](ContextPtr){ return std::make_unique( + [](ContextConstPtr){ return std::make_unique( std::make_shared(6, "fromUnixTimestamp64Micro")); }); } diff --git a/src/Functions/fromUnixTimestamp64Milli.cpp b/src/Functions/fromUnixTimestamp64Milli.cpp index 90f18699e5d..68ee1ed4078 100644 --- a/src/Functions/fromUnixTimestamp64Milli.cpp +++ b/src/Functions/fromUnixTimestamp64Milli.cpp @@ -7,7 +7,7 @@ namespace DB void registerFromUnixTimestamp64Milli(FunctionFactory & factory) { factory.registerFunction("fromUnixTimestamp64Milli", - [](ContextPtr){ return std::make_unique( + [](ContextConstPtr){ return std::make_unique( std::make_shared(3, "fromUnixTimestamp64Milli")); }); } diff --git a/src/Functions/fromUnixTimestamp64Nano.cpp b/src/Functions/fromUnixTimestamp64Nano.cpp index c489b48fb6e..19fe8524b78 100644 --- a/src/Functions/fromUnixTimestamp64Nano.cpp +++ b/src/Functions/fromUnixTimestamp64Nano.cpp @@ -7,7 +7,7 @@ namespace DB void registerFromUnixTimestamp64Nano(FunctionFactory & factory) { factory.registerFunction("fromUnixTimestamp64Nano", - [](ContextPtr){ return std::make_unique( + [](ContextConstPtr){ return std::make_unique( std::make_shared(9, "fromUnixTimestamp64Nano")); }); } diff --git a/src/Functions/fuzzBits.cpp b/src/Functions/fuzzBits.cpp index 0884f586082..b4110eae32a 100644 --- a/src/Functions/fuzzBits.cpp +++ b/src/Functions/fuzzBits.cpp @@ -53,7 +53,7 @@ class FunctionFuzzBits : public IFunction public: static constexpr auto name = "fuzzBits"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/generateUUIDv4.cpp b/src/Functions/generateUUIDv4.cpp index 7ca127857df..7d3f80d9096 100644 --- a/src/Functions/generateUUIDv4.cpp +++ b/src/Functions/generateUUIDv4.cpp @@ -60,7 +60,7 @@ public: class FunctionGenerateUUIDv4 : public TargetSpecific::Default::FunctionGenerateUUIDv4 { public: - explicit FunctionGenerateUUIDv4(ContextPtr context) : selector(context) + explicit FunctionGenerateUUIDv4(ContextConstPtr context) : selector(context) { selector.registerImplementation(); @@ -76,7 +76,7 @@ public: return selector.selectAndExecute(arguments, result_type, input_rows_count); } - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } diff --git a/src/Functions/geoToH3.cpp b/src/Functions/geoToH3.cpp index 6030cbeea65..45e6e06d114 100644 --- a/src/Functions/geoToH3.cpp +++ b/src/Functions/geoToH3.cpp @@ -33,7 +33,7 @@ class FunctionGeoToH3 : public IFunction public: static constexpr auto name = "geoToH3"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } std::string getName() const override { return name; } diff --git a/src/Functions/geohashDecode.cpp b/src/Functions/geohashDecode.cpp index bf774905868..89e8d40402a 100644 --- a/src/Functions/geohashDecode.cpp +++ b/src/Functions/geohashDecode.cpp @@ -27,7 +27,7 @@ class FunctionGeohashDecode : public IFunction { public: static constexpr auto name = "geohashDecode"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/geohashEncode.cpp b/src/Functions/geohashEncode.cpp index 15abe96e3e5..fbee2047ed2 100644 --- a/src/Functions/geohashEncode.cpp +++ b/src/Functions/geohashEncode.cpp @@ -28,7 +28,7 @@ class FunctionGeohashEncode : public IFunction { public: static constexpr auto name = "geohashEncode"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/geohashesInBox.cpp b/src/Functions/geohashesInBox.cpp index c0629ab9655..fdccc97879f 100644 --- a/src/Functions/geohashesInBox.cpp +++ b/src/Functions/geohashesInBox.cpp @@ -29,7 +29,7 @@ class FunctionGeohashesInBox : public IFunction { public: static constexpr auto name = "geohashesInBox"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/getMacro.cpp b/src/Functions/getMacro.cpp index c869685af42..a2fda60623f 100644 --- a/src/Functions/getMacro.cpp +++ b/src/Functions/getMacro.cpp @@ -30,7 +30,7 @@ private: public: static constexpr auto name = "getMacro"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context->getMacros()); } diff --git a/src/Functions/getScalar.cpp b/src/Functions/getScalar.cpp index a29abd257e7..d74d881473f 100644 --- a/src/Functions/getScalar.cpp +++ b/src/Functions/getScalar.cpp @@ -20,16 +20,16 @@ namespace /** Get scalar value of sub queries from query context via IAST::Hash. */ -class FunctionGetScalar : public IFunction, WithContext +class FunctionGetScalar : public IFunction, WithConstContext { public: static constexpr auto name = "__getScalar"; - static FunctionPtr create(ContextPtr context_) + static FunctionPtr create(ContextConstPtr context_) { return std::make_shared(context_); } - explicit FunctionGetScalar(ContextPtr context_) : WithContext(context_) {} + explicit FunctionGetScalar(ContextConstPtr context_) : WithConstContext(context_) {} String getName() const override { @@ -46,7 +46,7 @@ public: if (arguments.size() != 1 || !isString(arguments[0].type) || !arguments[0].column || !isColumnConst(*arguments[0].column)) throw Exception("Function " + getName() + " accepts one const string argument", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); auto scalar_name = assert_cast(*arguments[0].column).getValue(); - ContextPtr query_context = getContext()->hasQueryContext() ? getContext()->getQueryContext() : getContext(); + ContextConstPtr query_context = getContext()->hasQueryContext() ? getContext()->getQueryContext() : getContext(); scalar = query_context->getScalar(scalar_name).getByPosition(0); return scalar.type; } diff --git a/src/Functions/getSetting.cpp b/src/Functions/getSetting.cpp index 0206de33125..7c6592faf57 100644 --- a/src/Functions/getSetting.cpp +++ b/src/Functions/getSetting.cpp @@ -19,13 +19,13 @@ namespace { /// Get the value of a setting. -class FunctionGetSetting : public IFunction, WithContext +class FunctionGetSetting : public IFunction, WithConstContext { public: static constexpr auto name = "getSetting"; - static FunctionPtr create(ContextPtr context_) { return std::make_shared(context_); } - explicit FunctionGetSetting(ContextPtr context_) : WithContext(context_) {} + static FunctionPtr create(ContextConstPtr context_) { return std::make_shared(context_); } + explicit FunctionGetSetting(ContextConstPtr context_) : WithConstContext(context_) {} String getName() const override { return name; } bool isDeterministic() const override { return false; } diff --git a/src/Functions/getSizeOfEnumType.cpp b/src/Functions/getSizeOfEnumType.cpp index 504c088a737..61f4d7efced 100644 --- a/src/Functions/getSizeOfEnumType.cpp +++ b/src/Functions/getSizeOfEnumType.cpp @@ -20,7 +20,7 @@ class FunctionGetSizeOfEnumType : public IFunction { public: static constexpr auto name = "getSizeOfEnumType"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/globalVariable.cpp b/src/Functions/globalVariable.cpp index c141ceb2692..be2d4488daa 100644 --- a/src/Functions/globalVariable.cpp +++ b/src/Functions/globalVariable.cpp @@ -30,7 +30,7 @@ class FunctionGlobalVariable : public IFunction { public: static constexpr auto name = "globalVariable"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/greatCircleDistance.cpp b/src/Functions/greatCircleDistance.cpp index 756b76859ae..e160b72740e 100644 --- a/src/Functions/greatCircleDistance.cpp +++ b/src/Functions/greatCircleDistance.cpp @@ -287,7 +287,7 @@ template class FunctionGeoDistance : public TargetSpecific::Default::FunctionGeoDistance { public: - explicit FunctionGeoDistance(ContextPtr context) : selector(context) + explicit FunctionGeoDistance(ContextConstPtr context) : selector(context) { selector.registerImplementation>(); @@ -307,7 +307,7 @@ public: return selector.selectAndExecute(arguments, result_type, input_rows_count); } - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared>(context); } diff --git a/src/Functions/h3EdgeAngle.cpp b/src/Functions/h3EdgeAngle.cpp index ad8d1ee441f..4a0f69ab139 100644 --- a/src/Functions/h3EdgeAngle.cpp +++ b/src/Functions/h3EdgeAngle.cpp @@ -32,7 +32,7 @@ class FunctionH3EdgeAngle : public IFunction public: static constexpr auto name = "h3EdgeAngle"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } std::string getName() const override { return name; } diff --git a/src/Functions/h3EdgeLengthM.cpp b/src/Functions/h3EdgeLengthM.cpp index 85d307e1da3..523c4bde061 100644 --- a/src/Functions/h3EdgeLengthM.cpp +++ b/src/Functions/h3EdgeLengthM.cpp @@ -37,7 +37,7 @@ class FunctionH3EdgeLengthM : public IFunction public: static constexpr auto name = "h3EdgeLengthM"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } std::string getName() const override { return name; } diff --git a/src/Functions/h3GetBaseCell.cpp b/src/Functions/h3GetBaseCell.cpp index fcad82098e6..83d3064a023 100644 --- a/src/Functions/h3GetBaseCell.cpp +++ b/src/Functions/h3GetBaseCell.cpp @@ -29,7 +29,7 @@ class FunctionH3GetBaseCell : public IFunction public: static constexpr auto name = "h3GetBaseCell"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } std::string getName() const override { return name; } diff --git a/src/Functions/h3GetResolution.cpp b/src/Functions/h3GetResolution.cpp index d1bfd899150..197b0516da9 100644 --- a/src/Functions/h3GetResolution.cpp +++ b/src/Functions/h3GetResolution.cpp @@ -29,7 +29,7 @@ class FunctionH3GetResolution : public IFunction public: static constexpr auto name = "h3GetResolution"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } std::string getName() const override { return name; } diff --git a/src/Functions/h3HexAreaM2.cpp b/src/Functions/h3HexAreaM2.cpp index e44bf660333..c7eca3396bc 100644 --- a/src/Functions/h3HexAreaM2.cpp +++ b/src/Functions/h3HexAreaM2.cpp @@ -32,7 +32,7 @@ class FunctionH3HexAreaM2 : public IFunction public: static constexpr auto name = "h3HexAreaM2"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } std::string getName() const override { return name; } diff --git a/src/Functions/h3IndexesAreNeighbors.cpp b/src/Functions/h3IndexesAreNeighbors.cpp index 56c69ed0a8b..d2873f954e8 100644 --- a/src/Functions/h3IndexesAreNeighbors.cpp +++ b/src/Functions/h3IndexesAreNeighbors.cpp @@ -29,7 +29,7 @@ class FunctionH3IndexesAreNeighbors : public IFunction public: static constexpr auto name = "h3IndexesAreNeighbors"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } std::string getName() const override { return name; } diff --git a/src/Functions/h3IsValid.cpp b/src/Functions/h3IsValid.cpp index 1e4840b3537..930b1d3c4a7 100644 --- a/src/Functions/h3IsValid.cpp +++ b/src/Functions/h3IsValid.cpp @@ -29,7 +29,7 @@ class FunctionH3IsValid : public IFunction public: static constexpr auto name = "h3IsValid"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } std::string getName() const override { return name; } diff --git a/src/Functions/h3ToChildren.cpp b/src/Functions/h3ToChildren.cpp index 9730aefe3d4..3b09b5a1866 100644 --- a/src/Functions/h3ToChildren.cpp +++ b/src/Functions/h3ToChildren.cpp @@ -38,7 +38,7 @@ class FunctionH3ToChildren : public IFunction public: static constexpr auto name = "h3ToChildren"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } std::string getName() const override { return name; } diff --git a/src/Functions/h3ToParent.cpp b/src/Functions/h3ToParent.cpp index 4baf9527301..b5c49d4c253 100644 --- a/src/Functions/h3ToParent.cpp +++ b/src/Functions/h3ToParent.cpp @@ -32,7 +32,7 @@ class FunctionH3ToParent : public IFunction public: static constexpr auto name = "h3ToParent"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } std::string getName() const override { return name; } diff --git a/src/Functions/h3ToString.cpp b/src/Functions/h3ToString.cpp index dcd0951f67f..f2a777580d0 100644 --- a/src/Functions/h3ToString.cpp +++ b/src/Functions/h3ToString.cpp @@ -29,7 +29,7 @@ class FunctionH3ToString : public IFunction public: static constexpr auto name = "h3ToString"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } std::string getName() const override { return name; } diff --git a/src/Functions/h3kRing.cpp b/src/Functions/h3kRing.cpp index 40e73f9dea2..e616c253c58 100644 --- a/src/Functions/h3kRing.cpp +++ b/src/Functions/h3kRing.cpp @@ -35,7 +35,7 @@ class FunctionH3KRing : public IFunction public: static constexpr auto name = "h3kRing"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } std::string getName() const override { return name; } diff --git a/src/Functions/hasColumnInTable.cpp b/src/Functions/hasColumnInTable.cpp index da7e59d69e3..941ffa48e74 100644 --- a/src/Functions/hasColumnInTable.cpp +++ b/src/Functions/hasColumnInTable.cpp @@ -25,16 +25,16 @@ namespace /** Usage: * hasColumnInTable(['hostname'[, 'username'[, 'password']],] 'database', 'table', 'column') */ -class FunctionHasColumnInTable : public IFunction, WithContext +class FunctionHasColumnInTable : public IFunction, WithConstContext { public: static constexpr auto name = "hasColumnInTable"; - static FunctionPtr create(ContextPtr context_) + static FunctionPtr create(ContextConstPtr context_) { return std::make_shared(context_->getGlobalContext()); } - explicit FunctionHasColumnInTable(ContextPtr global_context_) : WithContext(global_context_) + explicit FunctionHasColumnInTable(ContextConstPtr global_context_) : WithConstContext(global_context_) { } @@ -114,7 +114,12 @@ ColumnPtr FunctionHasColumnInTable::executeImpl(const ColumnsWithTypeAndName & a bool has_column; if (host_name.empty()) { - const StoragePtr & table = DatabaseCatalog::instance().getTable({database_name, table_name}, getContext()); + // FIXME this (probably) needs a non-constant access to query context, + // because it might initialized a storage. Ideally, the tables required + // by the query should be initialized at an earlier stage. + const StoragePtr & table = DatabaseCatalog::instance().getTable( + {database_name, table_name}, + const_pointer_cast(getContext())); auto table_metadata = table->getInMemoryMetadataPtr(); has_column = table_metadata->getColumns().hasPhysical(column_name); } @@ -130,7 +135,13 @@ ColumnPtr FunctionHasColumnInTable::executeImpl(const ColumnsWithTypeAndName & a getContext()->getTCPPort(), false); - auto remote_columns = getStructureOfRemoteTable(*cluster, {database_name, table_name}, getContext()); + // FIXME this (probably) needs a non-constant access to query context, + // because it might initialized a storage. Ideally, the tables required + // by the query should be initialized at an earlier stage. + auto remote_columns = getStructureOfRemoteTable(*cluster, + {database_name, table_name}, + const_pointer_cast(getContext())); + has_column = remote_columns.hasPhysical(column_name); } diff --git a/src/Functions/hasThreadFuzzer.cpp b/src/Functions/hasThreadFuzzer.cpp index e9b48aa70f9..fb7014a49b1 100644 --- a/src/Functions/hasThreadFuzzer.cpp +++ b/src/Functions/hasThreadFuzzer.cpp @@ -16,7 +16,7 @@ class FunctionHasThreadFuzzer : public IFunction { public: static constexpr auto name = "hasThreadFuzzer"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/hostName.cpp b/src/Functions/hostName.cpp index 0aba155bb36..1fdc039be96 100644 --- a/src/Functions/hostName.cpp +++ b/src/Functions/hostName.cpp @@ -15,7 +15,7 @@ class FunctionHostName : public IFunction { public: static constexpr auto name = "hostName"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/identity.cpp b/src/Functions/identity.cpp index d15d9e1f710..7889a17f05a 100644 --- a/src/Functions/identity.cpp +++ b/src/Functions/identity.cpp @@ -11,7 +11,7 @@ class FunctionIdentity : public IFunction { public: static constexpr auto name = "identity"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/if.cpp b/src/Functions/if.cpp index ec3447ffb81..dbe36d4c728 100644 --- a/src/Functions/if.cpp +++ b/src/Functions/if.cpp @@ -173,7 +173,7 @@ class FunctionIf : public FunctionIfBase { public: static constexpr auto name = "if"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } private: template diff --git a/src/Functions/ifNotFinite.cpp b/src/Functions/ifNotFinite.cpp index a5e3131117e..be975f28ee1 100644 --- a/src/Functions/ifNotFinite.cpp +++ b/src/Functions/ifNotFinite.cpp @@ -17,9 +17,9 @@ class FunctionIfNotFinite : public IFunction public: static constexpr auto name = "ifNotFinite"; - explicit FunctionIfNotFinite(ContextPtr context_) : context(context_) {} + explicit FunctionIfNotFinite(ContextConstPtr context_) : context(context_) {} - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } @@ -59,7 +59,7 @@ public: } private: - ContextPtr context; + ContextConstPtr context; }; } diff --git a/src/Functions/ifNull.cpp b/src/Functions/ifNull.cpp index 82b63f4dbda..69c7e9346f2 100644 --- a/src/Functions/ifNull.cpp +++ b/src/Functions/ifNull.cpp @@ -21,9 +21,9 @@ class FunctionIfNull : public IFunction public: static constexpr auto name = "ifNull"; - explicit FunctionIfNull(ContextPtr context_) : context(context_) {} + explicit FunctionIfNull(ContextConstPtr context_) : context(context_) {} - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } @@ -83,7 +83,7 @@ public: } private: - ContextPtr context; + ContextConstPtr context; }; } diff --git a/src/Functions/ignore.cpp b/src/Functions/ignore.cpp index 176bc9afee2..819cd9a0b52 100644 --- a/src/Functions/ignore.cpp +++ b/src/Functions/ignore.cpp @@ -14,7 +14,7 @@ class FunctionIgnore : public IFunction { public: static constexpr auto name = "ignore"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/in.cpp b/src/Functions/in.cpp index 827e0212396..b1686e2a15a 100644 --- a/src/Functions/in.cpp +++ b/src/Functions/in.cpp @@ -52,7 +52,7 @@ public: /// It is needed to perform type analysis without creation of set. static constexpr auto name = FunctionInName::name; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/indexHint.cpp b/src/Functions/indexHint.cpp index f3c856c38ce..6fd41a910d3 100644 --- a/src/Functions/indexHint.cpp +++ b/src/Functions/indexHint.cpp @@ -23,7 +23,7 @@ class FunctionIndexHint : public IFunction { public: static constexpr auto name = "indexHint"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/initializeAggregation.cpp b/src/Functions/initializeAggregation.cpp index aea97a48037..e3d79c41f5b 100644 --- a/src/Functions/initializeAggregation.cpp +++ b/src/Functions/initializeAggregation.cpp @@ -29,7 +29,7 @@ class FunctionInitializeAggregation : public IFunction { public: static constexpr auto name = "initializeAggregation"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/isConstant.cpp b/src/Functions/isConstant.cpp index 3069ec79ae1..474fb46eed3 100644 --- a/src/Functions/isConstant.cpp +++ b/src/Functions/isConstant.cpp @@ -15,7 +15,7 @@ class FunctionIsConstant : public IFunction { public: static constexpr auto name = "isConstant"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/isDecimalOverflow.cpp b/src/Functions/isDecimalOverflow.cpp index d409afaf234..c82845b7cb8 100644 --- a/src/Functions/isDecimalOverflow.cpp +++ b/src/Functions/isDecimalOverflow.cpp @@ -28,7 +28,7 @@ class FunctionIsDecimalOverflow : public IFunction public: static constexpr auto name = "isDecimalOverflow"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/isIPAddressContainedIn.cpp b/src/Functions/isIPAddressContainedIn.cpp index 0886ef55e7b..439bf0a893e 100644 --- a/src/Functions/isIPAddressContainedIn.cpp +++ b/src/Functions/isIPAddressContainedIn.cpp @@ -125,7 +125,7 @@ namespace DB public: static constexpr auto name = "isIPAddressInRange"; String getName() const override { return name; } - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr & /* return_type */, size_t input_rows_count) const override { diff --git a/src/Functions/isNotNull.cpp b/src/Functions/isNotNull.cpp index 81c870a6303..a0119bb48c2 100644 --- a/src/Functions/isNotNull.cpp +++ b/src/Functions/isNotNull.cpp @@ -19,7 +19,7 @@ class FunctionIsNotNull : public IFunction public: static constexpr auto name = "isNotNull"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/isNull.cpp b/src/Functions/isNull.cpp index de840dab2bf..36da85dcdd3 100644 --- a/src/Functions/isNull.cpp +++ b/src/Functions/isNull.cpp @@ -18,7 +18,7 @@ class FunctionIsNull : public IFunction public: static constexpr auto name = "isNull"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/isZeroOrNull.cpp b/src/Functions/isZeroOrNull.cpp index a2a06af7569..4b863871629 100644 --- a/src/Functions/isZeroOrNull.cpp +++ b/src/Functions/isZeroOrNull.cpp @@ -26,7 +26,7 @@ class FunctionIsZeroOrNull : public IFunction public: static constexpr auto name = "isZeroOrNull"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/logTrace.cpp b/src/Functions/logTrace.cpp index 2ccc4d2ffd2..a291a59504f 100644 --- a/src/Functions/logTrace.cpp +++ b/src/Functions/logTrace.cpp @@ -21,7 +21,7 @@ namespace { public: static constexpr auto name = "logTrace"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/lowCardinalityIndices.cpp b/src/Functions/lowCardinalityIndices.cpp index 580e7381955..ac7fd45e7b6 100644 --- a/src/Functions/lowCardinalityIndices.cpp +++ b/src/Functions/lowCardinalityIndices.cpp @@ -21,7 +21,7 @@ class FunctionLowCardinalityIndices: public IFunction { public: static constexpr auto name = "lowCardinalityIndices"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/lowCardinalityKeys.cpp b/src/Functions/lowCardinalityKeys.cpp index 46128267871..2781248d15a 100644 --- a/src/Functions/lowCardinalityKeys.cpp +++ b/src/Functions/lowCardinalityKeys.cpp @@ -19,7 +19,7 @@ class FunctionLowCardinalityKeys: public IFunction { public: static constexpr auto name = "lowCardinalityKeys"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/map.cpp b/src/Functions/map.cpp index f1b08dc75b7..76b57d596cc 100644 --- a/src/Functions/map.cpp +++ b/src/Functions/map.cpp @@ -34,7 +34,7 @@ class FunctionMap : public IFunction public: static constexpr auto name = "map"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } @@ -146,7 +146,7 @@ class FunctionMapContains : public IFunction { public: static constexpr auto name = NameMapContains::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { @@ -209,7 +209,7 @@ class FunctionMapKeys : public IFunction { public: static constexpr auto name = "mapKeys"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { @@ -256,7 +256,7 @@ class FunctionMapValues : public IFunction { public: static constexpr auto name = "mapValues"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/materialize.h b/src/Functions/materialize.h index 4676b263f39..99b556dfff5 100644 --- a/src/Functions/materialize.h +++ b/src/Functions/materialize.h @@ -11,7 +11,7 @@ class FunctionMaterialize : public IFunction { public: static constexpr auto name = "materialize"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/multiIf.cpp b/src/Functions/multiIf.cpp index 92f05df472b..56399a7f056 100644 --- a/src/Functions/multiIf.cpp +++ b/src/Functions/multiIf.cpp @@ -35,7 +35,7 @@ class FunctionMultiIf final : public FunctionIfBase { public: static constexpr auto name = "multiIf"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } bool isVariadic() const override { return true; } diff --git a/src/Functions/neighbor.cpp b/src/Functions/neighbor.cpp index 785c5817176..53c47d3972d 100644 --- a/src/Functions/neighbor.cpp +++ b/src/Functions/neighbor.cpp @@ -31,7 +31,7 @@ class FunctionNeighbor : public IFunction { public: static constexpr auto name = "neighbor"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } /// Get the name of the function. String getName() const override { return name; } diff --git a/src/Functions/normalizedQueryHash.cpp b/src/Functions/normalizedQueryHash.cpp index e08680518c1..5cfd5ff4904 100644 --- a/src/Functions/normalizedQueryHash.cpp +++ b/src/Functions/normalizedQueryHash.cpp @@ -51,7 +51,7 @@ class FunctionNormalizedQueryHash : public IFunction { public: static constexpr auto name = keep_names ? "normalizedQueryHashKeepNames" : "normalizedQueryHash"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/now.cpp b/src/Functions/now.cpp index 673484b2ad2..9d6569fd5df 100644 --- a/src/Functions/now.cpp +++ b/src/Functions/now.cpp @@ -83,7 +83,7 @@ public: bool isVariadic() const override { return true; } size_t getNumberOfArguments() const override { return 0; } - static FunctionOverloadResolverPtr create(ContextPtr) { return std::make_unique(); } + static FunctionOverloadResolverPtr create(ContextConstPtr) { return std::make_unique(); } DataTypePtr getReturnTypeImpl(const ColumnsWithTypeAndName & arguments) const override { diff --git a/src/Functions/now64.cpp b/src/Functions/now64.cpp index cccfb9de6b6..b31a78bf0a7 100644 --- a/src/Functions/now64.cpp +++ b/src/Functions/now64.cpp @@ -107,7 +107,7 @@ public: bool isVariadic() const override { return true; } size_t getNumberOfArguments() const override { return 0; } - static FunctionOverloadResolverPtr create(ContextPtr) { return std::make_unique(); } + static FunctionOverloadResolverPtr create(ContextConstPtr) { return std::make_unique(); } DataTypePtr getReturnTypeImpl(const ColumnsWithTypeAndName & arguments) const override { diff --git a/src/Functions/nullIf.cpp b/src/Functions/nullIf.cpp index 14f2f72fe61..8f69ef4f550 100644 --- a/src/Functions/nullIf.cpp +++ b/src/Functions/nullIf.cpp @@ -18,16 +18,16 @@ namespace class FunctionNullIf : public IFunction { private: - ContextPtr context; + ContextConstPtr context; public: static constexpr auto name = "nullIf"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } - explicit FunctionNullIf(ContextPtr context_) : context(context_) {} + explicit FunctionNullIf(ContextConstPtr context_) : context(context_) {} std::string getName() const override { diff --git a/src/Functions/partitionId.cpp b/src/Functions/partitionId.cpp index cf679452da1..f33467e6752 100644 --- a/src/Functions/partitionId.cpp +++ b/src/Functions/partitionId.cpp @@ -23,7 +23,7 @@ class FunctionPartitionId : public IFunction public: static constexpr auto name = "partitionId"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/pointInEllipses.cpp b/src/Functions/pointInEllipses.cpp index f7bfc24559c..06eae802864 100644 --- a/src/Functions/pointInEllipses.cpp +++ b/src/Functions/pointInEllipses.cpp @@ -39,7 +39,7 @@ class FunctionPointInEllipses : public IFunction { public: static constexpr auto name = "pointInEllipses"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } private: diff --git a/src/Functions/pointInPolygon.cpp b/src/Functions/pointInPolygon.cpp index 842a5010190..82e69c468cc 100644 --- a/src/Functions/pointInPolygon.cpp +++ b/src/Functions/pointInPolygon.cpp @@ -60,7 +60,7 @@ public: explicit FunctionPointInPolygon(bool validate_) : validate(validate_) {} - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared>( context->getSettingsRef().validate_polygons); diff --git a/src/Functions/polygonArea.cpp b/src/Functions/polygonArea.cpp index 9a36b71d5b1..07e0f922ae0 100644 --- a/src/Functions/polygonArea.cpp +++ b/src/Functions/polygonArea.cpp @@ -34,7 +34,7 @@ public: explicit FunctionPolygonArea() = default; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/polygonConvexHull.cpp b/src/Functions/polygonConvexHull.cpp index 5bce3c5bbdd..b84e327ac81 100644 --- a/src/Functions/polygonConvexHull.cpp +++ b/src/Functions/polygonConvexHull.cpp @@ -33,7 +33,7 @@ public: explicit FunctionPolygonConvexHull() = default; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/polygonPerimeter.cpp b/src/Functions/polygonPerimeter.cpp index 5a6e293630e..11bb5488fd9 100644 --- a/src/Functions/polygonPerimeter.cpp +++ b/src/Functions/polygonPerimeter.cpp @@ -33,7 +33,7 @@ public: explicit FunctionPolygonPerimeter() = default; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/polygonsDistance.cpp b/src/Functions/polygonsDistance.cpp index d6c4ff36e4d..d92a1931f2b 100644 --- a/src/Functions/polygonsDistance.cpp +++ b/src/Functions/polygonsDistance.cpp @@ -35,7 +35,7 @@ public: explicit FunctionPolygonsDistance() = default; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/polygonsEquals.cpp b/src/Functions/polygonsEquals.cpp index 9e2902d0528..c14f9a18980 100644 --- a/src/Functions/polygonsEquals.cpp +++ b/src/Functions/polygonsEquals.cpp @@ -34,7 +34,7 @@ public: explicit FunctionPolygonsEquals() = default; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/polygonsIntersection.cpp b/src/Functions/polygonsIntersection.cpp index 699488abab1..5676323a08a 100644 --- a/src/Functions/polygonsIntersection.cpp +++ b/src/Functions/polygonsIntersection.cpp @@ -34,7 +34,7 @@ public: explicit FunctionPolygonsIntersection() = default; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/polygonsSymDifference.cpp b/src/Functions/polygonsSymDifference.cpp index 129e553f060..991d66a2802 100644 --- a/src/Functions/polygonsSymDifference.cpp +++ b/src/Functions/polygonsSymDifference.cpp @@ -34,7 +34,7 @@ public: explicit FunctionPolygonsSymDifference() = default; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/polygonsUnion.cpp b/src/Functions/polygonsUnion.cpp index e7281c299d0..9a9bfc9acfe 100644 --- a/src/Functions/polygonsUnion.cpp +++ b/src/Functions/polygonsUnion.cpp @@ -34,7 +34,7 @@ public: explicit FunctionPolygonsUnion() = default; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/polygonsWithin.cpp b/src/Functions/polygonsWithin.cpp index 2fd5b7e2225..45fc06d4fbe 100644 --- a/src/Functions/polygonsWithin.cpp +++ b/src/Functions/polygonsWithin.cpp @@ -36,7 +36,7 @@ public: explicit FunctionPolygonsWithin() = default; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/randConstant.cpp b/src/Functions/randConstant.cpp index 77d8e1f2a33..13a07050717 100644 --- a/src/Functions/randConstant.cpp +++ b/src/Functions/randConstant.cpp @@ -79,7 +79,7 @@ public: bool isVariadic() const override { return true; } size_t getNumberOfArguments() const override { return 0; } - static FunctionOverloadResolverPtr create(ContextPtr) + static FunctionOverloadResolverPtr create(ContextConstPtr) { return std::make_unique>(); } diff --git a/src/Functions/randomFixedString.cpp b/src/Functions/randomFixedString.cpp index 13996eee677..2a60f8dd88d 100644 --- a/src/Functions/randomFixedString.cpp +++ b/src/Functions/randomFixedString.cpp @@ -77,7 +77,7 @@ public: class FunctionRandomFixedString : public FunctionRandomFixedStringImpl { public: - explicit FunctionRandomFixedString(ContextPtr context) : selector(context) + explicit FunctionRandomFixedString(ContextConstPtr context) : selector(context) { selector.registerImplementation>(); @@ -93,7 +93,7 @@ public: return selector.selectAndExecute(arguments, result_type, input_rows_count); } - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } diff --git a/src/Functions/randomPrintableASCII.cpp b/src/Functions/randomPrintableASCII.cpp index ba8c16aa689..d27772e28fb 100644 --- a/src/Functions/randomPrintableASCII.cpp +++ b/src/Functions/randomPrintableASCII.cpp @@ -27,7 +27,7 @@ class FunctionRandomPrintableASCII : public IFunction { public: static constexpr auto name = "randomPrintableASCII"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/randomString.cpp b/src/Functions/randomString.cpp index 10795626326..680b01b9d08 100644 --- a/src/Functions/randomString.cpp +++ b/src/Functions/randomString.cpp @@ -97,7 +97,7 @@ public: class FunctionRandomString : public FunctionRandomStringImpl { public: - explicit FunctionRandomString(ContextPtr context) : selector(context) + explicit FunctionRandomString(ContextConstPtr context) : selector(context) { selector.registerImplementation>(); @@ -113,7 +113,7 @@ public: return selector.selectAndExecute(arguments, result_type, input_rows_count); } - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } diff --git a/src/Functions/randomStringUTF8.cpp b/src/Functions/randomStringUTF8.cpp index 018c591a1fe..48c828d2444 100644 --- a/src/Functions/randomStringUTF8.cpp +++ b/src/Functions/randomStringUTF8.cpp @@ -30,7 +30,7 @@ class FunctionRandomStringUTF8 : public IFunction public: static constexpr auto name = "randomStringUTF8"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/readWkt.cpp b/src/Functions/readWkt.cpp index 2ce4becb01c..26bb13a2e93 100644 --- a/src/Functions/readWkt.cpp +++ b/src/Functions/readWkt.cpp @@ -68,7 +68,7 @@ public: return true; } - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared>(); } diff --git a/src/Functions/regexpQuoteMeta.cpp b/src/Functions/regexpQuoteMeta.cpp index 0f1ec476a3b..cae2fdc1323 100644 --- a/src/Functions/regexpQuoteMeta.cpp +++ b/src/Functions/regexpQuoteMeta.cpp @@ -21,7 +21,7 @@ class FunctionRegexpQuoteMeta : public IFunction public: static constexpr auto name = "regexpQuoteMeta"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/reinterpretAs.cpp b/src/Functions/reinterpretAs.cpp index 94c9eec5868..d007e479c04 100644 --- a/src/Functions/reinterpretAs.cpp +++ b/src/Functions/reinterpretAs.cpp @@ -47,7 +47,7 @@ class FunctionReinterpret : public IFunction public: static constexpr auto name = "reinterpret"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } @@ -349,7 +349,7 @@ class FunctionReinterpretAs : public IFunction { public: static constexpr auto name = Name::name; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/repeat.cpp b/src/Functions/repeat.cpp index 423ed53c53f..e87a51b807d 100644 --- a/src/Functions/repeat.cpp +++ b/src/Functions/repeat.cpp @@ -173,7 +173,7 @@ class FunctionRepeat : public IFunction public: static constexpr auto name = "repeat"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/replicate.h b/src/Functions/replicate.h index 71b39e9e60e..4493d132002 100644 --- a/src/Functions/replicate.h +++ b/src/Functions/replicate.h @@ -13,7 +13,7 @@ class FunctionReplicate : public IFunction public: static constexpr auto name = "replicate"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/reverse.cpp b/src/Functions/reverse.cpp index f9701af75da..49ce3a214e3 100644 --- a/src/Functions/reverse.cpp +++ b/src/Functions/reverse.cpp @@ -57,7 +57,7 @@ class FunctionReverse : public IFunction { public: static constexpr auto name = "reverse"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } @@ -117,9 +117,9 @@ class ReverseOverloadResolver : public IFunctionOverloadResolver { public: static constexpr auto name = "reverse"; - static FunctionOverloadResolverPtr create(ContextPtr context) { return std::make_unique(context); } + static FunctionOverloadResolverPtr create(ContextConstPtr context) { return std::make_unique(context); } - explicit ReverseOverloadResolver(ContextPtr context_) : context(context_) {} + explicit ReverseOverloadResolver(ContextConstPtr context_) : context(context_) {} String getName() const override { return name; } size_t getNumberOfArguments() const override { return 1; } @@ -141,7 +141,7 @@ public: } private: - ContextPtr context; + ContextConstPtr context; }; } diff --git a/src/Functions/rowNumberInAllBlocks.cpp b/src/Functions/rowNumberInAllBlocks.cpp index 9c358aec8f0..85211d9e740 100644 --- a/src/Functions/rowNumberInAllBlocks.cpp +++ b/src/Functions/rowNumberInAllBlocks.cpp @@ -18,7 +18,7 @@ private: public: static constexpr auto name = "rowNumberInAllBlocks"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/rowNumberInBlock.cpp b/src/Functions/rowNumberInBlock.cpp index 48fa472e1dd..e924207a6d1 100644 --- a/src/Functions/rowNumberInBlock.cpp +++ b/src/Functions/rowNumberInBlock.cpp @@ -13,7 +13,7 @@ class FunctionRowNumberInBlock : public IFunction { public: static constexpr auto name = "rowNumberInBlock"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/runningAccumulate.cpp b/src/Functions/runningAccumulate.cpp index 1eab573b046..b17faf9c031 100644 --- a/src/Functions/runningAccumulate.cpp +++ b/src/Functions/runningAccumulate.cpp @@ -33,7 +33,7 @@ class FunctionRunningAccumulate : public IFunction { public: static constexpr auto name = "runningAccumulate"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/runningConcurrency.cpp b/src/Functions/runningConcurrency.cpp index 022e2be5f6c..6f842bcc342 100644 --- a/src/Functions/runningConcurrency.cpp +++ b/src/Functions/runningConcurrency.cpp @@ -154,7 +154,7 @@ namespace DB public: static constexpr auto name = Name::name; - static FunctionOverloadResolverPtr create(ContextPtr) + static FunctionOverloadResolverPtr create(ContextConstPtr) { return std::make_unique>(); } diff --git a/src/Functions/runningDifference.h b/src/Functions/runningDifference.h index f87c57af043..41a418b9b58 100644 --- a/src/Functions/runningDifference.h +++ b/src/Functions/runningDifference.h @@ -124,7 +124,7 @@ private: public: static constexpr auto name = FunctionRunningDifferenceName::name; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared>(); } diff --git a/src/Functions/sleep.h b/src/Functions/sleep.h index c0aad0b3820..16b3973cdc2 100644 --- a/src/Functions/sleep.h +++ b/src/Functions/sleep.h @@ -36,7 +36,7 @@ class FunctionSleep : public IFunction { public: static constexpr auto name = variant == FunctionSleepVariant::PerBlock ? "sleep" : "sleepEachRow"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared>(); } diff --git a/src/Functions/stringToH3.cpp b/src/Functions/stringToH3.cpp index 9b02711db50..97f9ba3f2ab 100644 --- a/src/Functions/stringToH3.cpp +++ b/src/Functions/stringToH3.cpp @@ -34,7 +34,7 @@ class FunctionStringToH3 : public IFunction public: static constexpr auto name = "stringToH3"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } std::string getName() const override { return name; } diff --git a/src/Functions/substring.cpp b/src/Functions/substring.cpp index 5ce75035475..13f0e296602 100644 --- a/src/Functions/substring.cpp +++ b/src/Functions/substring.cpp @@ -36,7 +36,7 @@ class FunctionSubstring : public IFunction { public: static constexpr auto name = is_utf8 ? "substringUTF8" : "substring"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/svg.cpp b/src/Functions/svg.cpp index 39473816c8c..4d0edaf004b 100644 --- a/src/Functions/svg.cpp +++ b/src/Functions/svg.cpp @@ -24,7 +24,7 @@ public: explicit FunctionSvg() = default; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/tcpPort.cpp b/src/Functions/tcpPort.cpp index 484843ced3f..baacdb0a335 100644 --- a/src/Functions/tcpPort.cpp +++ b/src/Functions/tcpPort.cpp @@ -14,7 +14,7 @@ class FunctionTcpPort : public IFunction public: static constexpr auto name = "tcpPort"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context->getTCPPort()); } diff --git a/src/Functions/throwIf.cpp b/src/Functions/throwIf.cpp index 1b56cc0d188..a3285f64c73 100644 --- a/src/Functions/throwIf.cpp +++ b/src/Functions/throwIf.cpp @@ -26,7 +26,7 @@ class FunctionThrowIf : public IFunction { public: static constexpr auto name = "throwIf"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/tid.cpp b/src/Functions/tid.cpp index 404eff862b3..6f2eb3cc595 100644 --- a/src/Functions/tid.cpp +++ b/src/Functions/tid.cpp @@ -13,7 +13,7 @@ namespace { public: static constexpr auto name = "tid"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/timeSlots.cpp b/src/Functions/timeSlots.cpp index b64d2687b05..4f8882a83ad 100644 --- a/src/Functions/timeSlots.cpp +++ b/src/Functions/timeSlots.cpp @@ -109,7 +109,7 @@ class FunctionTimeSlots : public IFunction public: static constexpr auto name = "timeSlots"; static constexpr UInt32 TIME_SLOT_SIZE = 1800; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/timezone.cpp b/src/Functions/timezone.cpp index 67f7462fc95..c0d136ab7d4 100644 --- a/src/Functions/timezone.cpp +++ b/src/Functions/timezone.cpp @@ -16,7 +16,7 @@ class FunctionTimezone : public IFunction { public: static constexpr auto name = "timezone"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/timezoneOf.cpp b/src/Functions/timezoneOf.cpp index 3dc72424a4f..f768722a284 100644 --- a/src/Functions/timezoneOf.cpp +++ b/src/Functions/timezoneOf.cpp @@ -28,7 +28,7 @@ class FunctionTimezoneOf : public IFunction public: static constexpr auto name = "timezoneOf"; String getName() const override { return name; } - static FunctionPtr create(ContextPtr) { return std::make_unique(); } + static FunctionPtr create(ContextConstPtr) { return std::make_unique(); } size_t getNumberOfArguments() const override { return 1; } diff --git a/src/Functions/toColumnTypeName.cpp b/src/Functions/toColumnTypeName.cpp index d64fa12604e..2d3635f4ed1 100644 --- a/src/Functions/toColumnTypeName.cpp +++ b/src/Functions/toColumnTypeName.cpp @@ -14,7 +14,7 @@ class FunctionToColumnTypeName : public IFunction { public: static constexpr auto name = "toColumnTypeName"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/toFixedString.h b/src/Functions/toFixedString.h index fe437a24303..303d51f41ad 100644 --- a/src/Functions/toFixedString.h +++ b/src/Functions/toFixedString.h @@ -32,7 +32,7 @@ class FunctionToFixedString : public IFunction { public: static constexpr auto name = "toFixedString"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } static FunctionPtr create() { return std::make_shared(); } String getName() const override diff --git a/src/Functions/toLowCardinality.cpp b/src/Functions/toLowCardinality.cpp index 983e66d1007..8f102d5db9c 100644 --- a/src/Functions/toLowCardinality.cpp +++ b/src/Functions/toLowCardinality.cpp @@ -14,7 +14,7 @@ class FunctionToLowCardinality: public IFunction { public: static constexpr auto name = "toLowCardinality"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } diff --git a/src/Functions/toModifiedJulianDay.cpp b/src/Functions/toModifiedJulianDay.cpp index a44979b52ff..c76b158baa8 100644 --- a/src/Functions/toModifiedJulianDay.cpp +++ b/src/Functions/toModifiedJulianDay.cpp @@ -172,7 +172,7 @@ namespace DB public: static constexpr auto name = Name::name; - static FunctionOverloadResolverPtr create(ContextPtr) + static FunctionOverloadResolverPtr create(ContextConstPtr) { return std::make_unique>(); } diff --git a/src/Functions/toNullable.cpp b/src/Functions/toNullable.cpp index 5e383893476..12d23e59f49 100644 --- a/src/Functions/toNullable.cpp +++ b/src/Functions/toNullable.cpp @@ -16,7 +16,7 @@ class FunctionToNullable : public IFunction public: static constexpr auto name = "toNullable"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/toStartOfInterval.cpp b/src/Functions/toStartOfInterval.cpp index ee592fbb1e3..97d2d65b67a 100644 --- a/src/Functions/toStartOfInterval.cpp +++ b/src/Functions/toStartOfInterval.cpp @@ -184,7 +184,7 @@ namespace class FunctionToStartOfInterval : public IFunction { public: - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } static constexpr auto name = function_name; String getName() const override { return name; } diff --git a/src/Functions/toTimezone.cpp b/src/Functions/toTimezone.cpp index 551e07a8354..ef80c2f0849 100644 --- a/src/Functions/toTimezone.cpp +++ b/src/Functions/toTimezone.cpp @@ -25,7 +25,7 @@ class FunctionToTimezone : public IFunction { public: static constexpr auto name = "toTimezone"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/toTypeName.cpp b/src/Functions/toTypeName.cpp index 3c733fb3ea7..f369ff1ccef 100644 --- a/src/Functions/toTypeName.cpp +++ b/src/Functions/toTypeName.cpp @@ -18,7 +18,7 @@ public: static constexpr auto name = "toTypeName"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/toUnixTimestamp64Micro.cpp b/src/Functions/toUnixTimestamp64Micro.cpp index c5b841a1a81..bd13f753802 100644 --- a/src/Functions/toUnixTimestamp64Micro.cpp +++ b/src/Functions/toUnixTimestamp64Micro.cpp @@ -7,7 +7,7 @@ namespace DB void registerToUnixTimestamp64Micro(FunctionFactory & factory) { factory.registerFunction("toUnixTimestamp64Micro", - [](ContextPtr){ return std::make_unique( + [](ContextConstPtr){ return std::make_unique( std::make_shared(6, "toUnixTimestamp64Micro")); }); } diff --git a/src/Functions/toUnixTimestamp64Milli.cpp b/src/Functions/toUnixTimestamp64Milli.cpp index bfceb3708d3..088cd2011c5 100644 --- a/src/Functions/toUnixTimestamp64Milli.cpp +++ b/src/Functions/toUnixTimestamp64Milli.cpp @@ -7,7 +7,7 @@ namespace DB void registerToUnixTimestamp64Milli(FunctionFactory & factory) { factory.registerFunction("toUnixTimestamp64Milli", - [](ContextPtr){ return std::make_unique( + [](ContextConstPtr){ return std::make_unique( std::make_shared(3, "toUnixTimestamp64Milli")); }); } diff --git a/src/Functions/toUnixTimestamp64Nano.cpp b/src/Functions/toUnixTimestamp64Nano.cpp index 2256dc369b9..3961b9630ba 100644 --- a/src/Functions/toUnixTimestamp64Nano.cpp +++ b/src/Functions/toUnixTimestamp64Nano.cpp @@ -7,7 +7,7 @@ namespace DB void registerToUnixTimestamp64Nano(FunctionFactory & factory) { factory.registerFunction("toUnixTimestamp64Nano", - [](ContextPtr){ return std::make_unique( + [](ContextConstPtr){ return std::make_unique( std::make_shared(9, "toUnixTimestamp64Nano")); }); } diff --git a/src/Functions/today.cpp b/src/Functions/today.cpp index 43be4c4582a..9d04bd3a84d 100644 --- a/src/Functions/today.cpp +++ b/src/Functions/today.cpp @@ -71,7 +71,7 @@ public: size_t getNumberOfArguments() const override { return 0; } - static FunctionOverloadResolverPtr create(ContextPtr) { return std::make_unique(); } + static FunctionOverloadResolverPtr create(ContextConstPtr) { return std::make_unique(); } DataTypePtr getReturnTypeImpl(const DataTypes &) const override { return std::make_shared(); } diff --git a/src/Functions/transform.cpp b/src/Functions/transform.cpp index 1debc2cb6a0..e9305304ac0 100644 --- a/src/Functions/transform.cpp +++ b/src/Functions/transform.cpp @@ -58,7 +58,7 @@ class FunctionTransform : public IFunction { public: static constexpr auto name = "transform"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { diff --git a/src/Functions/trap.cpp b/src/Functions/trap.cpp index f946a7fabfb..c7f935bac3e 100644 --- a/src/Functions/trap.cpp +++ b/src/Functions/trap.cpp @@ -32,16 +32,16 @@ namespace ErrorCodes class FunctionTrap : public IFunction { private: - ContextPtr context; + ContextConstPtr context; public: static constexpr auto name = "trap"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } - FunctionTrap(ContextPtr context_) : context(context_) {} + FunctionTrap(ContextConstPtr context_) : context(context_) {} String getName() const override { diff --git a/src/Functions/tuple.cpp b/src/Functions/tuple.cpp index dda034ee911..8c1ad90070e 100644 --- a/src/Functions/tuple.cpp +++ b/src/Functions/tuple.cpp @@ -24,7 +24,7 @@ class FunctionTuple : public IFunction public: static constexpr auto name = "tuple"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/tupleElement.cpp b/src/Functions/tupleElement.cpp index 97e2f70fccf..7f71e9d93e9 100644 --- a/src/Functions/tupleElement.cpp +++ b/src/Functions/tupleElement.cpp @@ -30,7 +30,7 @@ class FunctionTupleElement : public IFunction { public: static constexpr auto name = "tupleElement"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/tupleHammingDistance.cpp b/src/Functions/tupleHammingDistance.cpp index 9d660e388cb..a4ad7e9a5ba 100644 --- a/src/Functions/tupleHammingDistance.cpp +++ b/src/Functions/tupleHammingDistance.cpp @@ -19,14 +19,14 @@ namespace ErrorCodes class FunctionTupleHammingDistance : public IFunction { private: - ContextPtr context; + ContextConstPtr context; public: static constexpr auto name = "tupleHammingDistance"; using ResultType = UInt8; - explicit FunctionTupleHammingDistance(ContextPtr context_) : context(context_) {} - static FunctionPtr create(ContextPtr context) { return std::make_shared(context); } + explicit FunctionTupleHammingDistance(ContextConstPtr context_) : context(context_) {} + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context); } String getName() const override { return name; } diff --git a/src/Functions/uptime.cpp b/src/Functions/uptime.cpp index 02454df4de5..7e2165318a3 100644 --- a/src/Functions/uptime.cpp +++ b/src/Functions/uptime.cpp @@ -13,7 +13,7 @@ class FunctionUptime : public IFunction { public: static constexpr auto name = "uptime"; - static FunctionPtr create(ContextPtr context) + static FunctionPtr create(ContextConstPtr context) { return std::make_shared(context->getUptimeSeconds()); } diff --git a/src/Functions/validateNestedArraySizes.cpp b/src/Functions/validateNestedArraySizes.cpp index 1d96f988690..f3327479844 100644 --- a/src/Functions/validateNestedArraySizes.cpp +++ b/src/Functions/validateNestedArraySizes.cpp @@ -24,7 +24,7 @@ class FunctionValidateNestedArraySizes : public IFunction { public: static constexpr auto name = "validateNestedArraySizes"; - static FunctionPtr create(ContextPtr) { return std::make_shared(); } + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } String getName() const override { return name; } bool isVariadic() const override { return true; } diff --git a/src/Functions/version.cpp b/src/Functions/version.cpp index 4e0ddf60975..6181999e2f5 100644 --- a/src/Functions/version.cpp +++ b/src/Functions/version.cpp @@ -16,7 +16,7 @@ class FunctionVersion : public IFunction { public: static constexpr auto name = "version"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/visibleWidth.cpp b/src/Functions/visibleWidth.cpp index 6e96a4844ce..f6a79a82df6 100644 --- a/src/Functions/visibleWidth.cpp +++ b/src/Functions/visibleWidth.cpp @@ -19,7 +19,7 @@ class FunctionVisibleWidth : public IFunction { public: static constexpr auto name = "visibleWidth"; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/wkt.cpp b/src/Functions/wkt.cpp index b5567a19e89..888f6a4ea5f 100644 --- a/src/Functions/wkt.cpp +++ b/src/Functions/wkt.cpp @@ -16,7 +16,7 @@ public: explicit FunctionWkt() = default; - static FunctionPtr create(ContextPtr) + static FunctionPtr create(ContextConstPtr) { return std::make_shared(); } diff --git a/src/Functions/yesterday.cpp b/src/Functions/yesterday.cpp index 737552e192e..0b3ac6d2a8e 100644 --- a/src/Functions/yesterday.cpp +++ b/src/Functions/yesterday.cpp @@ -69,7 +69,7 @@ public: size_t getNumberOfArguments() const override { return 0; } - static FunctionOverloadResolverPtr create(ContextPtr) { return std::make_unique(); } + static FunctionOverloadResolverPtr create(ContextConstPtr) { return std::make_unique(); } DataTypePtr getReturnTypeImpl(const DataTypes &) const override { return std::make_shared(); } diff --git a/src/IO/ConnectionTimeouts.h b/src/IO/ConnectionTimeouts.h index 42b800f15d0..160566c0f8d 100644 --- a/src/IO/ConnectionTimeouts.h +++ b/src/IO/ConnectionTimeouts.h @@ -111,7 +111,7 @@ struct ConnectionTimeouts static ConnectionTimeouts getTCPTimeoutsWithoutFailover(const Settings & settings); /// Timeouts for the case when we will try many addresses in a loop. static ConnectionTimeouts getTCPTimeoutsWithFailover(const Settings & settings); - static ConnectionTimeouts getHTTPTimeouts(ContextPtr context); + static ConnectionTimeouts getHTTPTimeouts(ContextConstPtr context); }; } diff --git a/src/IO/ConnectionTimeoutsContext.h b/src/IO/ConnectionTimeoutsContext.h index 8d6f96b82a3..909ccff8ef0 100644 --- a/src/IO/ConnectionTimeoutsContext.h +++ b/src/IO/ConnectionTimeoutsContext.h @@ -27,7 +27,7 @@ inline ConnectionTimeouts ConnectionTimeouts::getTCPTimeoutsWithFailover(const S settings.receive_data_timeout_ms); } -inline ConnectionTimeouts ConnectionTimeouts::getHTTPTimeouts(ContextPtr context) +inline ConnectionTimeouts ConnectionTimeouts::getHTTPTimeouts(ContextConstPtr context) { const auto & settings = context->getSettingsRef(); const auto & config = context->getConfigRef(); diff --git a/src/IO/ReadHelpers.h b/src/IO/ReadHelpers.h index 9003ec2d9ed..a772d4ccd69 100644 --- a/src/IO/ReadHelpers.h +++ b/src/IO/ReadHelpers.h @@ -270,16 +270,37 @@ ReturnType readIntTextImpl(T & x, ReadBuffer & buf) } const size_t initial_pos = buf.count(); + bool has_sign = false; + bool has_number = false; while (!buf.eof()) { switch (*buf.position()) { case '+': { + if (has_sign || has_number) + { + if constexpr (throw_exception) + throw ParsingException( + "Cannot parse number with multiple sign (+/-) characters or intermediate sign character", + ErrorCodes::CANNOT_PARSE_NUMBER); + else + return ReturnType(false); + } + has_sign = true; break; } case '-': { + if (has_sign || has_number) + { + if constexpr (throw_exception) + throw ParsingException( + "Cannot parse number with multiple sign (+/-) characters or intermediate sign character", + ErrorCodes::CANNOT_PARSE_NUMBER); + else + return ReturnType(false); + } if constexpr (is_signed_v) negative = true; else @@ -289,6 +310,7 @@ ReturnType readIntTextImpl(T & x, ReadBuffer & buf) else return ReturnType(false); } + has_sign = true; break; } case '0': [[fallthrough]]; @@ -302,6 +324,7 @@ ReturnType readIntTextImpl(T & x, ReadBuffer & buf) case '8': [[fallthrough]]; case '9': { + has_number = true; if constexpr (check_overflow == ReadIntTextCheckOverflow::CHECK_OVERFLOW && !is_big_int_v) { /// Perform relativelly slow overflow check only when @@ -330,6 +353,14 @@ ReturnType readIntTextImpl(T & x, ReadBuffer & buf) } end: + if (has_sign && !has_number) + { + if constexpr (throw_exception) + throw ParsingException( + "Cannot parse number with a sign character but without any numeric character", ErrorCodes::CANNOT_PARSE_NUMBER); + else + return ReturnType(false); + } x = res; if constexpr (is_signed_v) { diff --git a/src/Interpreters/ColumnAliasesVisitor.h b/src/Interpreters/ColumnAliasesVisitor.h index a1f8e79f64c..6b89c1a086f 100644 --- a/src/Interpreters/ColumnAliasesVisitor.h +++ b/src/Interpreters/ColumnAliasesVisitor.h @@ -56,12 +56,12 @@ public: /// Do not analyze joined columns. /// They may have aliases and come to description as is. const NameSet & forbidden_columns; - ContextPtr context; + ContextConstPtr context; /// private_aliases are from lambda, so these are local names. NameSet private_aliases; - Data(const ColumnsDescription & columns_, const NameSet & forbidden_columns_, ContextPtr context_) + Data(const ColumnsDescription & columns_, const NameSet & forbidden_columns_, ContextConstPtr context_) : columns(columns_) , forbidden_columns(forbidden_columns_) , context(context_) diff --git a/src/Interpreters/DuplicateOrderByVisitor.h b/src/Interpreters/DuplicateOrderByVisitor.h index 4231b2600af..bd8652ff298 100644 --- a/src/Interpreters/DuplicateOrderByVisitor.h +++ b/src/Interpreters/DuplicateOrderByVisitor.h @@ -21,7 +21,7 @@ class ASTFunctionStatefulData public: using TypeToVisit = ASTFunction; - ContextPtr context; + ContextConstPtr context; bool & is_stateful; void visit(ASTFunction & ast_function, ASTPtr &) { @@ -80,7 +80,7 @@ class DuplicateOrderByData public: using TypeToVisit = ASTSelectQuery; - ContextPtr context; + ContextConstPtr context; void visit(ASTSelectQuery & select_query, ASTPtr &) { diff --git a/src/Interpreters/ExecuteScalarSubqueriesVisitor.cpp b/src/Interpreters/ExecuteScalarSubqueriesVisitor.cpp index 97ad191289c..1c947e62e69 100644 --- a/src/Interpreters/ExecuteScalarSubqueriesVisitor.cpp +++ b/src/Interpreters/ExecuteScalarSubqueriesVisitor.cpp @@ -25,7 +25,6 @@ namespace DB namespace ErrorCodes { extern const int INCORRECT_RESULT_OF_SCALAR_SUBQUERY; - extern const int TOO_MANY_ROWS; } @@ -116,36 +115,26 @@ void ExecuteScalarSubqueriesMatcher::visit(const ASTSubquery & subquery, ASTPtr { auto io = interpreter.execute(); - try + PullingAsyncPipelineExecutor executor(io.pipeline); + while (block.rows() == 0 && executor.pull(block)); + + if (block.rows() == 0) { - PullingAsyncPipelineExecutor executor(io.pipeline); - while (block.rows() == 0 && executor.pull(block)); - - if (block.rows() == 0) - { - /// Interpret subquery with empty result as Null literal - auto ast_new = std::make_unique(Null()); - ast_new->setAlias(ast->tryGetAlias()); - ast = std::move(ast_new); - return; - } - - if (block.rows() != 1) - throw Exception("Scalar subquery returned more than one row", ErrorCodes::INCORRECT_RESULT_OF_SCALAR_SUBQUERY); - - Block tmp_block; - while (tmp_block.rows() == 0 && executor.pull(tmp_block)); - - if (tmp_block.rows() != 0) - throw Exception("Scalar subquery returned more than one row", ErrorCodes::INCORRECT_RESULT_OF_SCALAR_SUBQUERY); - } - catch (const Exception & e) - { - if (e.code() == ErrorCodes::TOO_MANY_ROWS) - throw Exception("Scalar subquery returned more than one row", ErrorCodes::INCORRECT_RESULT_OF_SCALAR_SUBQUERY); - else - throw; + /// Interpret subquery with empty result as Null literal + auto ast_new = std::make_unique(Null()); + ast_new->setAlias(ast->tryGetAlias()); + ast = std::move(ast_new); + return; } + + if (block.rows() != 1) + throw Exception("Scalar subquery returned more than one row", ErrorCodes::INCORRECT_RESULT_OF_SCALAR_SUBQUERY); + + Block tmp_block; + while (tmp_block.rows() == 0 && executor.pull(tmp_block)); + + if (tmp_block.rows() != 0) + throw Exception("Scalar subquery returned more than one row", ErrorCodes::INCORRECT_RESULT_OF_SCALAR_SUBQUERY); } block = materializeBlock(block); diff --git a/src/Interpreters/ExecuteScalarSubqueriesVisitor.h b/src/Interpreters/ExecuteScalarSubqueriesVisitor.h index c230f346779..aa404f2c622 100644 --- a/src/Interpreters/ExecuteScalarSubqueriesVisitor.h +++ b/src/Interpreters/ExecuteScalarSubqueriesVisitor.h @@ -33,7 +33,7 @@ class ExecuteScalarSubqueriesMatcher public: using Visitor = InDepthNodeVisitor; - struct Data : public WithContext + struct Data : public WithConstContext { size_t subquery_depth; Scalars & scalars; diff --git a/src/Interpreters/ExpressionAnalyzer.cpp b/src/Interpreters/ExpressionAnalyzer.cpp index 766b0523c81..f7fdc87f0e9 100644 --- a/src/Interpreters/ExpressionAnalyzer.cpp +++ b/src/Interpreters/ExpressionAnalyzer.cpp @@ -474,10 +474,58 @@ bool ExpressionAnalyzer::makeAggregateDescriptions(ActionsDAGPtr & actions) return !aggregates().empty(); } -void makeWindowDescriptionFromAST(WindowDescription & desc, const IAST * ast) +void makeWindowDescriptionFromAST(const WindowDescriptions & existing_descriptions, + WindowDescription & desc, const IAST * ast) { const auto & definition = ast->as(); + if (!definition.parent_window_name.empty()) + { + auto it = existing_descriptions.find(definition.parent_window_name); + if (it == existing_descriptions.end()) + { + throw Exception(ErrorCodes::BAD_ARGUMENTS, + "Window definition '{}' references an unknown window '{}'", + definition.formatForErrorMessage(), + definition.parent_window_name); + } + + const auto & parent = it->second; + desc.partition_by = parent.partition_by; + desc.order_by = parent.order_by; + desc.frame = parent.frame; + + // If an existing_window_name is specified it must refer to an earlier + // entry in the WINDOW list; the new window copies its partitioning clause + // from that entry, as well as its ordering clause if any. In this case + // the new window cannot specify its own PARTITION BY clause, and it can + // specify ORDER BY only if the copied window does not have one. The new + // window always uses its own frame clause; the copied window must not + // specify a frame clause. + // -- https://www.postgresql.org/docs/current/sql-select.html + if (definition.partition_by) + { + throw Exception(ErrorCodes::BAD_ARGUMENTS, + "Derived window definition '{}' is not allowed to override PARTITION BY", + definition.formatForErrorMessage()); + } + + if (definition.order_by && !parent.order_by.empty()) + { + throw Exception(ErrorCodes::BAD_ARGUMENTS, + "Derived window definition '{}' is not allowed to override a non-empty ORDER BY", + definition.formatForErrorMessage()); + } + + if (!parent.frame.is_default) + { + throw Exception(ErrorCodes::BAD_ARGUMENTS, + "Parent window '{}' is not allowed to define a frame: while processing derived window definition '{}'", + definition.parent_window_name, + definition.formatForErrorMessage()); + } + } + if (definition.partition_by) { for (const auto & column_ast : definition.partition_by->children) @@ -557,7 +605,7 @@ void ExpressionAnalyzer::makeWindowDescriptions(ActionsDAGPtr actions) const auto & elem = ptr->as(); WindowDescription desc; desc.window_name = elem.name; - makeWindowDescriptionFromAST(desc, elem.definition.get()); + makeWindowDescriptionFromAST(window_descriptions, desc, elem.definition.get()); auto [it, inserted] = window_descriptions.insert( {desc.window_name, desc}); @@ -642,7 +690,7 @@ void ExpressionAnalyzer::makeWindowDescriptions(ActionsDAGPtr actions) const ASTWindowDefinition &>(); WindowDescription desc; desc.window_name = definition.getDefaultWindowName(); - makeWindowDescriptionFromAST(desc, &definition); + makeWindowDescriptionFromAST(window_descriptions, desc, &definition); auto [it, inserted] = window_descriptions.insert( {desc.window_name, desc}); diff --git a/src/Interpreters/ExternalDictionariesLoader.cpp b/src/Interpreters/ExternalDictionariesLoader.cpp index 5c6da033396..e6414474817 100644 --- a/src/Interpreters/ExternalDictionariesLoader.cpp +++ b/src/Interpreters/ExternalDictionariesLoader.cpp @@ -23,9 +23,9 @@ namespace ErrorCodes } /// Must not acquire Context lock in constructor to avoid possibility of deadlocks. -ExternalDictionariesLoader::ExternalDictionariesLoader(ContextPtr global_context_) +ExternalDictionariesLoader::ExternalDictionariesLoader(ContextConstPtr global_context_) : ExternalLoader("external dictionary", &Poco::Logger::get("ExternalDictionariesLoader")) - , WithContext(global_context_) + , WithConstContext(global_context_) { setConfigSettings({"dictionary", "name", "database", "uuid"}); enableAsyncLoading(true); @@ -42,26 +42,26 @@ ExternalLoader::LoadablePtr ExternalDictionariesLoader::create( return DictionaryFactory::instance().create(name, config, key_in_config, getContext(), created_from_ddl); } -ExternalDictionariesLoader::DictPtr ExternalDictionariesLoader::getDictionary(const std::string & dictionary_name, ContextPtr local_context) const +ExternalDictionariesLoader::DictPtr ExternalDictionariesLoader::getDictionary(const std::string & dictionary_name, ContextConstPtr local_context) const { std::string resolved_dictionary_name = resolveDictionaryName(dictionary_name, local_context->getCurrentDatabase()); return std::static_pointer_cast(load(resolved_dictionary_name)); } -ExternalDictionariesLoader::DictPtr ExternalDictionariesLoader::tryGetDictionary(const std::string & dictionary_name, ContextPtr local_context) const +ExternalDictionariesLoader::DictPtr ExternalDictionariesLoader::tryGetDictionary(const std::string & dictionary_name, ContextConstPtr local_context) const { std::string resolved_dictionary_name = resolveDictionaryName(dictionary_name, local_context->getCurrentDatabase()); return std::static_pointer_cast(tryLoad(resolved_dictionary_name)); } -void ExternalDictionariesLoader::reloadDictionary(const std::string & dictionary_name, ContextPtr local_context) const +void ExternalDictionariesLoader::reloadDictionary(const std::string & dictionary_name, ContextConstPtr local_context) const { std::string resolved_dictionary_name = resolveDictionaryName(dictionary_name, local_context->getCurrentDatabase()); loadOrReload(resolved_dictionary_name); } -DictionaryStructure ExternalDictionariesLoader::getDictionaryStructure(const std::string & dictionary_name, ContextPtr query_context) const +DictionaryStructure ExternalDictionariesLoader::getDictionaryStructure(const std::string & dictionary_name, ContextConstPtr query_context) const { std::string resolved_name = resolveDictionaryName(dictionary_name, query_context->getCurrentDatabase()); @@ -109,7 +109,10 @@ std::string ExternalDictionariesLoader::resolveDictionaryNameFromDatabaseCatalog std::string maybe_database_name = name.substr(0, pos); std::string maybe_table_name = name.substr(pos + 1); - auto [db, table] = DatabaseCatalog::instance().tryGetDatabaseAndTable({maybe_database_name, maybe_table_name}, getContext()); + auto [db, table] = DatabaseCatalog::instance().tryGetDatabaseAndTable( + {maybe_database_name, maybe_table_name}, + const_pointer_cast(getContext())); + if (!db) return name; assert(table); diff --git a/src/Interpreters/ExternalDictionariesLoader.h b/src/Interpreters/ExternalDictionariesLoader.h index 06f64ef30c5..1182e96573c 100644 --- a/src/Interpreters/ExternalDictionariesLoader.h +++ b/src/Interpreters/ExternalDictionariesLoader.h @@ -13,21 +13,21 @@ namespace DB class IExternalLoaderConfigRepository; /// Manages user-defined dictionaries. -class ExternalDictionariesLoader : public ExternalLoader, WithContext +class ExternalDictionariesLoader : public ExternalLoader, WithConstContext { public: using DictPtr = std::shared_ptr; /// Dictionaries will be loaded immediately and then will be updated in separate thread, each 'reload_period' seconds. - explicit ExternalDictionariesLoader(ContextPtr global_context_); + explicit ExternalDictionariesLoader(ContextConstPtr global_context_); - DictPtr getDictionary(const std::string & dictionary_name, ContextPtr context) const; + DictPtr getDictionary(const std::string & dictionary_name, ContextConstPtr context) const; - DictPtr tryGetDictionary(const std::string & dictionary_name, ContextPtr context) const; + DictPtr tryGetDictionary(const std::string & dictionary_name, ContextConstPtr context) const; - void reloadDictionary(const std::string & dictionary_name, ContextPtr context) const; + void reloadDictionary(const std::string & dictionary_name, ContextConstPtr context) const; - DictionaryStructure getDictionaryStructure(const std::string & dictionary_name, ContextPtr context) const; + DictionaryStructure getDictionaryStructure(const std::string & dictionary_name, ContextConstPtr context) const; static DictionaryStructure getDictionaryStructure(const Poco::Util::AbstractConfiguration & config, const std::string & key_in_config = "dictionary"); diff --git a/src/Interpreters/ExtractExpressionInfoVisitor.cpp b/src/Interpreters/ExtractExpressionInfoVisitor.cpp index 2d46fe08e95..34632a96bda 100644 --- a/src/Interpreters/ExtractExpressionInfoVisitor.cpp +++ b/src/Interpreters/ExtractExpressionInfoVisitor.cpp @@ -82,12 +82,12 @@ bool ExpressionInfoMatcher::needChildVisit(const ASTPtr & node, const ASTPtr &) return !node->as(); } -bool hasNonRewritableFunction(const ASTPtr & node, ContextPtr context) +bool hasNonRewritableFunction(const ASTPtr & node, ContextConstPtr context) { for (const auto & select_expression : node->children) { TablesWithColumns tables; - ExpressionInfoVisitor::Data expression_info{WithContext{context}, tables}; + ExpressionInfoVisitor::Data expression_info{WithConstContext{context}, tables}; ExpressionInfoVisitor(expression_info).visit(select_expression); if (expression_info.is_stateful_function diff --git a/src/Interpreters/ExtractExpressionInfoVisitor.h b/src/Interpreters/ExtractExpressionInfoVisitor.h index c84e243ce2e..bfb414e8601 100644 --- a/src/Interpreters/ExtractExpressionInfoVisitor.h +++ b/src/Interpreters/ExtractExpressionInfoVisitor.h @@ -13,7 +13,7 @@ namespace DB struct ExpressionInfoMatcher { - struct Data : public WithContext + struct Data : public WithConstContext { const TablesWithColumns & tables; @@ -36,6 +36,6 @@ struct ExpressionInfoMatcher using ExpressionInfoVisitor = ConstInDepthNodeVisitor; -bool hasNonRewritableFunction(const ASTPtr & node, ContextPtr context); +bool hasNonRewritableFunction(const ASTPtr & node, ContextConstPtr context); } diff --git a/src/Interpreters/InterpreterSelectQuery.cpp b/src/Interpreters/InterpreterSelectQuery.cpp index 61740284f1b..7407088ba60 100644 --- a/src/Interpreters/InterpreterSelectQuery.cpp +++ b/src/Interpreters/InterpreterSelectQuery.cpp @@ -1296,9 +1296,12 @@ void InterpreterSelectQuery::executeImpl(QueryPlan & query_plan, const BlockInpu */ if (from_aggregation_stage) - executeMergeSorted(query_plan, "for ORDER BY"); - else if (!expressions.first_stage && !expressions.need_aggregate && !(query.group_by_with_totals && !aggregate_final)) - executeMergeSorted(query_plan, "for ORDER BY"); + executeMergeSorted(query_plan, "after aggregation stage for ORDER BY"); + else if (!expressions.first_stage + && !expressions.need_aggregate + && !expressions.has_window + && !(query.group_by_with_totals && !aggregate_final)) + executeMergeSorted(query_plan, "for ORDER BY, without aggregation"); else /// Otherwise, just sort. executeOrder( query_plan, diff --git a/src/Interpreters/MonotonicityCheckVisitor.h b/src/Interpreters/MonotonicityCheckVisitor.h index 350318047c7..f0698b27426 100644 --- a/src/Interpreters/MonotonicityCheckVisitor.h +++ b/src/Interpreters/MonotonicityCheckVisitor.h @@ -26,7 +26,7 @@ public: struct Data { const TablesWithColumns & tables; - ContextPtr context; + ContextConstPtr context; const std::unordered_set & group_by_function_hashes; Monotonicity monotonicity{true, true, true}; ASTIdentifier * identifier = nullptr; diff --git a/src/Interpreters/PredicateExpressionsOptimizer.cpp b/src/Interpreters/PredicateExpressionsOptimizer.cpp index f2e55441fb6..b3ef2e42e4a 100644 --- a/src/Interpreters/PredicateExpressionsOptimizer.cpp +++ b/src/Interpreters/PredicateExpressionsOptimizer.cpp @@ -19,8 +19,8 @@ namespace ErrorCodes } PredicateExpressionsOptimizer::PredicateExpressionsOptimizer( - ContextPtr context_, const TablesWithColumns & tables_with_columns_, const Settings & settings) - : WithContext(context_) + ContextConstPtr context_, const TablesWithColumns & tables_with_columns_, const Settings & settings) + : WithConstContext(context_) , enable_optimize_predicate_expression(settings.enable_optimize_predicate_expression) , enable_optimize_predicate_expression_to_final_subquery(settings.enable_optimize_predicate_expression_to_final_subquery) , allow_push_predicate_when_subquery_contains_with(settings.allow_push_predicate_when_subquery_contains_with) @@ -87,7 +87,7 @@ std::vector PredicateExpressionsOptimizer::extractTablesPredicates(const A for (const auto & predicate_expression : splitConjunctionPredicate({where, prewhere})) { - ExpressionInfoVisitor::Data expression_info{WithContext{getContext()}, tables_with_columns}; + ExpressionInfoVisitor::Data expression_info{WithConstContext{getContext()}, tables_with_columns}; ExpressionInfoVisitor(expression_info).visit(predicate_expression); if (expression_info.is_stateful_function @@ -188,7 +188,7 @@ bool PredicateExpressionsOptimizer::tryMovePredicatesFromHavingToWhere(ASTSelect for (const auto & moving_predicate: splitConjunctionPredicate({select_query.having()})) { TablesWithColumns tables; - ExpressionInfoVisitor::Data expression_info{WithContext{getContext()}, tables}; + ExpressionInfoVisitor::Data expression_info{WithConstContext{getContext()}, tables}; ExpressionInfoVisitor(expression_info).visit(moving_predicate); /// TODO: If there is no group by, where, and prewhere expression, we can push down the stateful function diff --git a/src/Interpreters/PredicateExpressionsOptimizer.h b/src/Interpreters/PredicateExpressionsOptimizer.h index a31b9907da6..db580032f73 100644 --- a/src/Interpreters/PredicateExpressionsOptimizer.h +++ b/src/Interpreters/PredicateExpressionsOptimizer.h @@ -15,10 +15,10 @@ struct Settings; * - Move predicates from having to where * - Push the predicate down from the current query to the having of the subquery */ -class PredicateExpressionsOptimizer : WithContext +class PredicateExpressionsOptimizer : WithConstContext { public: - PredicateExpressionsOptimizer(ContextPtr context_, const TablesWithColumns & tables_with_columns_, const Settings & settings_); + PredicateExpressionsOptimizer(ContextConstPtr context_, const TablesWithColumns & tables_with_columns_, const Settings & settings_); bool optimize(ASTSelectQuery & select_query); diff --git a/src/Interpreters/PredicateRewriteVisitor.cpp b/src/Interpreters/PredicateRewriteVisitor.cpp index 092d37d78dd..3dda066c4ac 100644 --- a/src/Interpreters/PredicateRewriteVisitor.cpp +++ b/src/Interpreters/PredicateRewriteVisitor.cpp @@ -17,12 +17,12 @@ namespace DB { PredicateRewriteVisitorData::PredicateRewriteVisitorData( - ContextPtr context_, + ContextConstPtr context_, const ASTs & predicates_, const TableWithColumnNamesAndTypes & table_columns_, bool optimize_final_, bool optimize_with_) - : WithContext(context_) + : WithConstContext(context_) , predicates(predicates_) , table_columns(table_columns_) , optimize_final(optimize_final_) @@ -72,7 +72,9 @@ void PredicateRewriteVisitorData::visitOtherInternalSelect(ASTSelectQuery & sele } const Names & internal_columns = InterpreterSelectQuery( - temp_internal_select, getContext(), SelectQueryOptions().analyze()).getSampleBlock().getNames(); + temp_internal_select, + const_pointer_cast(getContext()), + SelectQueryOptions().analyze()).getSampleBlock().getNames(); if (rewriteSubquery(*temp_select_query, internal_columns)) { diff --git a/src/Interpreters/PredicateRewriteVisitor.h b/src/Interpreters/PredicateRewriteVisitor.h index fc076464925..b4ff063c954 100644 --- a/src/Interpreters/PredicateRewriteVisitor.h +++ b/src/Interpreters/PredicateRewriteVisitor.h @@ -10,7 +10,7 @@ namespace DB { -class PredicateRewriteVisitorData : WithContext +class PredicateRewriteVisitorData : WithConstContext { public: bool is_rewrite = false; @@ -24,7 +24,7 @@ public: } PredicateRewriteVisitorData( - ContextPtr context_, + ContextConstPtr context_, const ASTs & predicates_, const TableWithColumnNamesAndTypes & table_columns_, bool optimize_final_, diff --git a/src/Interpreters/RedundantFunctionsInOrderByVisitor.h b/src/Interpreters/RedundantFunctionsInOrderByVisitor.h index f807849fb86..04ac1607b60 100644 --- a/src/Interpreters/RedundantFunctionsInOrderByVisitor.h +++ b/src/Interpreters/RedundantFunctionsInOrderByVisitor.h @@ -16,7 +16,7 @@ public: struct Data { std::unordered_set & keys; - ContextPtr context; + ContextConstPtr context; bool redundant = true; bool done = false; diff --git a/src/Interpreters/RemoveInjectiveFunctionsVisitor.cpp b/src/Interpreters/RemoveInjectiveFunctionsVisitor.cpp index 8d030379909..e242eab919a 100644 --- a/src/Interpreters/RemoveInjectiveFunctionsVisitor.cpp +++ b/src/Interpreters/RemoveInjectiveFunctionsVisitor.cpp @@ -17,7 +17,7 @@ static bool isUniq(const ASTFunction & func) } /// Remove injective functions of one argument: replace with a child -static bool removeInjectiveFunction(ASTPtr & ast, ContextPtr context, const FunctionFactory & function_factory) +static bool removeInjectiveFunction(ASTPtr & ast, ContextConstPtr context, const FunctionFactory & function_factory) { const ASTFunction * func = ast->as(); if (!func) diff --git a/src/Interpreters/RemoveInjectiveFunctionsVisitor.h b/src/Interpreters/RemoveInjectiveFunctionsVisitor.h index a3bbd562407..29fd9bb0af5 100644 --- a/src/Interpreters/RemoveInjectiveFunctionsVisitor.h +++ b/src/Interpreters/RemoveInjectiveFunctionsVisitor.h @@ -13,9 +13,9 @@ class ASTFunction; class RemoveInjectiveFunctionsMatcher { public: - struct Data : public WithContext + struct Data : public WithConstContext { - explicit Data(ContextPtr context_) : WithContext(context_) {} + explicit Data(ContextConstPtr context_) : WithConstContext(context_) {} }; static void visit(ASTPtr & ast, const Data & data); diff --git a/src/Interpreters/TreeOptimizer.cpp b/src/Interpreters/TreeOptimizer.cpp index 5b06c00435a..a2725f2506e 100644 --- a/src/Interpreters/TreeOptimizer.cpp +++ b/src/Interpreters/TreeOptimizer.cpp @@ -81,7 +81,7 @@ void appendUnusedGroupByColumn(ASTSelectQuery * select_query, const NameSet & so } /// Eliminates injective function calls and constant expressions from group by statement. -void optimizeGroupBy(ASTSelectQuery * select_query, const NameSet & source_columns, ContextPtr context) +void optimizeGroupBy(ASTSelectQuery * select_query, const NameSet & source_columns, ContextConstPtr context) { const FunctionFactory & function_factory = FunctionFactory::instance(); @@ -270,7 +270,7 @@ void optimizeDuplicatesInOrderBy(const ASTSelectQuery * select_query) } /// Optimize duplicate ORDER BY -void optimizeDuplicateOrderBy(ASTPtr & query, ContextPtr context) +void optimizeDuplicateOrderBy(ASTPtr & query, ContextConstPtr context) { DuplicateOrderByVisitor::Data order_by_data{context}; DuplicateOrderByVisitor(order_by_data).visit(query); @@ -396,7 +396,7 @@ void optimizeDuplicateDistinct(ASTSelectQuery & select) /// Replace monotonous functions in ORDER BY if they don't participate in GROUP BY expression, /// has a single argument and not an aggregate functions. -void optimizeMonotonousFunctionsInOrderBy(ASTSelectQuery * select_query, ContextPtr context, +void optimizeMonotonousFunctionsInOrderBy(ASTSelectQuery * select_query, ContextConstPtr context, const TablesWithColumns & tables_with_columns, const Names & sorting_key_columns) { @@ -448,7 +448,7 @@ void optimizeMonotonousFunctionsInOrderBy(ASTSelectQuery * select_query, Context /// Optimize ORDER BY x, y, f(x), g(x, y), f(h(x)), t(f(x), g(x)) into ORDER BY x, y /// in case if f(), g(), h(), t() are deterministic (in scope of query). /// Don't optimize ORDER BY f(x), g(x), x even if f(x) is bijection for x or g(x). -void optimizeRedundantFunctionsInOrderBy(const ASTSelectQuery * select_query, ContextPtr context) +void optimizeRedundantFunctionsInOrderBy(const ASTSelectQuery * select_query, ContextConstPtr context) { const auto & order_by = select_query->orderBy(); if (!order_by) @@ -561,7 +561,7 @@ void optimizeCountConstantAndSumOne(ASTPtr & query) } -void optimizeInjectiveFunctionsInsideUniq(ASTPtr & query, ContextPtr context) +void optimizeInjectiveFunctionsInsideUniq(ASTPtr & query, ContextConstPtr context) { RemoveInjectiveFunctionsVisitor::Data data(context); RemoveInjectiveFunctionsVisitor(data).visit(query); @@ -592,7 +592,7 @@ void TreeOptimizer::optimizeIf(ASTPtr & query, Aliases & aliases, bool if_chain_ void TreeOptimizer::apply(ASTPtr & query, Aliases & aliases, const NameSet & source_columns_set, const std::vector & tables_with_columns, - ContextPtr context, const StorageMetadataPtr & metadata_snapshot, + ContextConstPtr context, const StorageMetadataPtr & metadata_snapshot, bool & rewrite_subqueries) { const auto & settings = context->getSettingsRef(); diff --git a/src/Interpreters/TreeOptimizer.h b/src/Interpreters/TreeOptimizer.h index b268b230f4e..706f030e620 100644 --- a/src/Interpreters/TreeOptimizer.h +++ b/src/Interpreters/TreeOptimizer.h @@ -21,7 +21,7 @@ public: Aliases & aliases, const NameSet & source_columns_set, const std::vector & tables_with_columns, - ContextPtr context, + ContextConstPtr context, const StorageMetadataPtr & metadata_snapshot, bool & rewrite_subqueries); diff --git a/src/Interpreters/TreeRewriter.cpp b/src/Interpreters/TreeRewriter.cpp index 92cfba1bcb1..5b4a869d44b 100644 --- a/src/Interpreters/TreeRewriter.cpp +++ b/src/Interpreters/TreeRewriter.cpp @@ -413,10 +413,10 @@ void removeUnneededColumnsFromSelectClause(const ASTSelectQuery * select_query, } /// Replacing scalar subqueries with constant values. -void executeScalarSubqueries(ASTPtr & query, ContextPtr context, size_t subquery_depth, Scalars & scalars, bool only_analyze) +void executeScalarSubqueries(ASTPtr & query, ContextConstPtr context, size_t subquery_depth, Scalars & scalars, bool only_analyze) { LogAST log; - ExecuteScalarSubqueriesVisitor::Data visitor_data{WithContext{context}, subquery_depth, scalars, only_analyze}; + ExecuteScalarSubqueriesVisitor::Data visitor_data{WithConstContext{context}, subquery_depth, scalars, only_analyze}; ExecuteScalarSubqueriesVisitor(visitor_data, log.stream()).visit(query); } diff --git a/src/Interpreters/TreeRewriter.h b/src/Interpreters/TreeRewriter.h index 32826bcc61d..1f535325666 100644 --- a/src/Interpreters/TreeRewriter.h +++ b/src/Interpreters/TreeRewriter.h @@ -92,10 +92,10 @@ using TreeRewriterResultPtr = std::shared_ptr; /// * scalar subqueries are executed replaced with constants /// * unneeded columns are removed from SELECT clause /// * duplicated columns are removed from ORDER BY, LIMIT BY, USING(...). -class TreeRewriter : WithContext +class TreeRewriter : WithConstContext { public: - explicit TreeRewriter(ContextPtr context_) : WithContext(context_) {} + explicit TreeRewriter(ContextConstPtr context_) : WithConstContext(context_) {} /// Analyze and rewrite not select query TreeRewriterResultPtr analyze( diff --git a/src/Interpreters/addTypeConversionToAST.cpp b/src/Interpreters/addTypeConversionToAST.cpp index 73c95bd9a8c..86fd7926e78 100644 --- a/src/Interpreters/addTypeConversionToAST.cpp +++ b/src/Interpreters/addTypeConversionToAST.cpp @@ -32,10 +32,12 @@ ASTPtr addTypeConversionToAST(ASTPtr && ast, const String & type_name) return func; } -ASTPtr addTypeConversionToAST(ASTPtr && ast, const String & type_name, const NamesAndTypesList & all_columns, ContextPtr context) +ASTPtr addTypeConversionToAST(ASTPtr && ast, const String & type_name, const NamesAndTypesList & all_columns, ContextConstPtr context) { auto syntax_analyzer_result = TreeRewriter(context).analyze(ast, all_columns); - const auto actions = ExpressionAnalyzer(ast, syntax_analyzer_result, context).getActions(true); + const auto actions = ExpressionAnalyzer(ast, + syntax_analyzer_result, + const_pointer_cast(context)).getActions(true); for (const auto & action : actions->getActions()) if (action.node->type == ActionsDAG::ActionType::ARRAY_JOIN) diff --git a/src/Interpreters/addTypeConversionToAST.h b/src/Interpreters/addTypeConversionToAST.h index eb391b2c749..7a4d879dc61 100644 --- a/src/Interpreters/addTypeConversionToAST.h +++ b/src/Interpreters/addTypeConversionToAST.h @@ -14,6 +14,6 @@ class NamesAndTypesList; ASTPtr addTypeConversionToAST(ASTPtr && ast, const String & type_name); // If same type, then ignore the wrapper of CAST function -ASTPtr addTypeConversionToAST(ASTPtr && ast, const String & type_name, const NamesAndTypesList & all_columns, ContextPtr context); +ASTPtr addTypeConversionToAST(ASTPtr && ast, const String & type_name, const NamesAndTypesList & all_columns, ContextConstPtr context); } diff --git a/src/Interpreters/replaceAliasColumnsInQuery.cpp b/src/Interpreters/replaceAliasColumnsInQuery.cpp index 4c8367b269a..d85c1b23c2f 100644 --- a/src/Interpreters/replaceAliasColumnsInQuery.cpp +++ b/src/Interpreters/replaceAliasColumnsInQuery.cpp @@ -6,11 +6,11 @@ namespace DB { -void replaceAliasColumnsInQuery(ASTPtr & ast, const ColumnsDescription & columns, const NameSet & forbidden_columns, ContextPtr context) +void replaceAliasColumnsInQuery(ASTPtr & ast, const ColumnsDescription & columns, const NameSet & forbidden_columns, ContextConstPtr context) { - ColumnAliasesVisitor::Data aliase_column_data(columns, forbidden_columns, context); - ColumnAliasesVisitor aliase_column_visitor(aliase_column_data); - aliase_column_visitor.visit(ast); + ColumnAliasesVisitor::Data aliases_column_data(columns, forbidden_columns, context); + ColumnAliasesVisitor aliases_column_visitor(aliases_column_data); + aliases_column_visitor.visit(ast); } } diff --git a/src/Interpreters/replaceAliasColumnsInQuery.h b/src/Interpreters/replaceAliasColumnsInQuery.h index 92d2686b45b..90963ea167b 100644 --- a/src/Interpreters/replaceAliasColumnsInQuery.h +++ b/src/Interpreters/replaceAliasColumnsInQuery.h @@ -10,6 +10,6 @@ namespace DB class ColumnsDescription; -void replaceAliasColumnsInQuery(ASTPtr & ast, const ColumnsDescription & columns, const NameSet & forbidden_columns, ContextPtr context); +void replaceAliasColumnsInQuery(ASTPtr & ast, const ColumnsDescription & columns, const NameSet & forbidden_columns, ContextConstPtr context); } diff --git a/src/Parsers/ASTWindowDefinition.cpp b/src/Parsers/ASTWindowDefinition.cpp index 37b27b22c7d..376df5bc80c 100644 --- a/src/Parsers/ASTWindowDefinition.cpp +++ b/src/Parsers/ASTWindowDefinition.cpp @@ -12,6 +12,8 @@ ASTPtr ASTWindowDefinition::clone() const { auto result = std::make_shared(); + result->parent_window_name = parent_window_name; + if (partition_by) { result->partition_by = partition_by->clone(); @@ -38,31 +40,48 @@ void ASTWindowDefinition::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked format_frame) const { format_frame.expression_list_prepend_whitespace = false; + bool need_space = false; + + if (!parent_window_name.empty()) + { + settings.ostr << backQuoteIfNeed(parent_window_name); + + need_space = true; + } if (partition_by) { + if (need_space) + { + settings.ostr << " "; + } + settings.ostr << "PARTITION BY "; partition_by->formatImpl(settings, state, format_frame); - } - if (partition_by && order_by) - { - settings.ostr << " "; + need_space = true; } if (order_by) { + if (need_space) + { + settings.ostr << " "; + } + settings.ostr << "ORDER BY "; order_by->formatImpl(settings, state, format_frame); - } - if ((partition_by || order_by) && !frame.is_default) - { - settings.ostr << " "; + need_space = true; } if (!frame.is_default) { + if (need_space) + { + settings.ostr << " "; + } + settings.ostr << WindowFrame::toString(frame.type) << " BETWEEN "; if (frame.begin_type == WindowFrame::BoundaryType::Current) { diff --git a/src/Parsers/ASTWindowDefinition.h b/src/Parsers/ASTWindowDefinition.h index b57c1094e42..7547f1527f2 100644 --- a/src/Parsers/ASTWindowDefinition.h +++ b/src/Parsers/ASTWindowDefinition.h @@ -10,6 +10,8 @@ namespace DB struct ASTWindowDefinition : public IAST { + std::string parent_window_name; + ASTPtr partition_by; ASTPtr order_by; diff --git a/src/Parsers/ExpressionElementParsers.cpp b/src/Parsers/ExpressionElementParsers.cpp index cde75396180..75a341a543d 100644 --- a/src/Parsers/ExpressionElementParsers.cpp +++ b/src/Parsers/ExpressionElementParsers.cpp @@ -502,9 +502,6 @@ bool ParserWindowReference::parseImpl(Pos & pos, ASTPtr & node, Expected & expec // Variant 1: // function_name ( * ) OVER window_name - // FIXME doesn't work anyway for now -- never used anywhere, window names - // can't be defined, and TreeRewriter thinks the window name is a column so - // the query fails. if (pos->type != TokenType::OpeningRoundBracket) { ASTPtr window_name_ast; @@ -662,16 +659,10 @@ static bool tryParseFrameDefinition(ASTWindowDefinition * node, IParser::Pos & p return true; } -bool ParserWindowDefinition::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) +// All except parent window name. +static bool parseWindowDefinitionParts(IParser::Pos & pos, + ASTWindowDefinition & node, Expected & expected) { - auto result = std::make_shared(); - - ParserToken parser_openging_bracket(TokenType::OpeningRoundBracket); - if (!parser_openging_bracket.ignore(pos, expected)) - { - return false; - } - ParserKeyword keyword_partition_by("PARTITION BY"); ParserNotEmptyExpressionList columns_partition_by( false /* we don't allow declaring aliases here*/); @@ -683,8 +674,8 @@ bool ParserWindowDefinition::parseImpl(Pos & pos, ASTPtr & node, Expected & expe ASTPtr partition_by_ast; if (columns_partition_by.parse(pos, partition_by_ast, expected)) { - result->children.push_back(partition_by_ast); - result->partition_by = partition_by_ast; + node.children.push_back(partition_by_ast); + node.partition_by = partition_by_ast; } else { @@ -697,8 +688,8 @@ bool ParserWindowDefinition::parseImpl(Pos & pos, ASTPtr & node, Expected & expe ASTPtr order_by_ast; if (columns_order_by.parse(pos, order_by_ast, expected)) { - result->children.push_back(order_by_ast); - result->order_by = order_by_ast; + node.children.push_back(order_by_ast); + node.order_by = order_by_ast; } else { @@ -706,9 +697,45 @@ bool ParserWindowDefinition::parseImpl(Pos & pos, ASTPtr & node, Expected & expe } } - if (!tryParseFrameDefinition(result.get(), pos, expected)) + return tryParseFrameDefinition(&node, pos, expected); +} + +bool ParserWindowDefinition::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) +{ + auto result = std::make_shared(); + + ParserToken parser_openging_bracket(TokenType::OpeningRoundBracket); + if (!parser_openging_bracket.ignore(pos, expected)) + { + return false; + } + + // We can have a parent window name specified before all other things. No + // easy way to distinguish identifier from keywords, so just try to parse it + // both ways. + if (parseWindowDefinitionParts(pos, *result, expected)) + { + // Successfully parsed without parent window specifier. It can be empty, + // so check that it is followed by the closing bracket. + ParserToken parser_closing_bracket(TokenType::ClosingRoundBracket); + if (parser_closing_bracket.ignore(pos, expected)) + { + node = result; + return true; + } + } + + // Try to parse with parent window specifier. + ParserIdentifier parser_parent_window; + ASTPtr window_name_identifier; + if (!parser_parent_window.parse(pos, window_name_identifier, expected)) + { + return false; + } + result->parent_window_name = window_name_identifier->as().name(); + + if (!parseWindowDefinitionParts(pos, *result, expected)) { - /* Broken frame definition. */ return false; } diff --git a/src/Processors/Formats/Impl/BinaryRowInputFormat.cpp b/src/Processors/Formats/Impl/BinaryRowInputFormat.cpp index 36b57e242d7..2d820a5985f 100644 --- a/src/Processors/Formats/Impl/BinaryRowInputFormat.cpp +++ b/src/Processors/Formats/Impl/BinaryRowInputFormat.cpp @@ -28,7 +28,7 @@ bool BinaryRowInputFormat::readRow(MutableColumns & columns, RowReadExtension &) void BinaryRowInputFormat::readPrefix() { - /// NOTE The header is completely ignored. This can be easily improved. + /// NOTE: The header is completely ignored. This can be easily improved. UInt64 columns = 0; String tmp; diff --git a/src/Server/HTTP/HTMLForm.cpp b/src/Server/HTTP/HTMLForm.cpp index 7a87f484b5c..9e0f74dcc33 100644 --- a/src/Server/HTTP/HTMLForm.cpp +++ b/src/Server/HTTP/HTMLForm.cpp @@ -244,7 +244,7 @@ bool HTMLForm::MultipartReadBuffer::skipToNextBoundary() while (!in.eof()) { - auto line = readLine(); + auto line = readLine(true); if (startsWith(line, boundary)) { set(in.position(), 0); @@ -256,29 +256,36 @@ bool HTMLForm::MultipartReadBuffer::skipToNextBoundary() throw Poco::Net::HTMLFormException("No boundary line found"); } -std::string HTMLForm::MultipartReadBuffer::readLine(bool strict) +std::string HTMLForm::MultipartReadBuffer::readLine(bool append_crlf) { std::string line; char ch = 0; // silence "uninitialized" warning from gcc-* - while (in.read(ch) && ch != '\r' && ch != '\n') + /// If we don't append CRLF, it means that we may have to prepend CRLF from previous content line, which wasn't the boundary. + if (in.read(ch)) line += ch; - - if (in.eof()) - { - if (strict) - throw Poco::Net::HTMLFormException("Unexpected end of message"); + if (in.read(ch)) + line += ch; + if (append_crlf && line == "\r\n") return line; - } - line += ch; - - if (ch == '\r') + while (!in.eof()) { - if (!in.read(ch) || ch != '\n') - throw Poco::Net::HTMLFormException("No CRLF found"); - else + while (in.read(ch) && ch != '\r') line += ch; + + if (in.eof()) break; + + assert(ch == '\r'); + + if (in.peek(ch) && ch == '\n') + { + in.ignore(); + if (append_crlf) line += "\r\n"; + break; + } + + line += ch; } return line; @@ -300,19 +307,12 @@ bool HTMLForm::MultipartReadBuffer::nextImpl() /// FIXME: there is an extra copy because we cannot traverse PeekableBuffer from checkpoint to position() /// since it may store different data parts in different sub-buffers, /// anyway calling makeContinuousMemoryFromCheckpointToPos() will also make an extra copy. - std::string line = readLine(false); - /// According to RFC2046 the preceding CRLF is a part of boundary line. - if (line == "\r\n") - { - line = readLine(false); - boundary_hit = startsWith(line, boundary); - if (!boundary_hit) line = "\r\n"; - } - else - boundary_hit = startsWith(line, boundary); + std::string line = readLine(false); + boundary_hit = startsWith(line, "\r\n" + boundary); + bool has_next = !boundary_hit && !line.empty(); - if (!line.empty()) + if (has_next) /// If we don't make sure that memory is contiguous then situation may happen, when part of the line is inside internal memory /// and other part is inside sub-buffer, thus we'll be unable to setup our working buffer properly. in.makeContinuousMemoryFromCheckpointToPos(); @@ -323,7 +323,7 @@ bool HTMLForm::MultipartReadBuffer::nextImpl() /// Limit readable data to a single line. BufferBase::set(in.position(), line.size(), 0); - return !boundary_hit && !line.empty(); + return has_next; } } diff --git a/src/Server/HTTP/HTMLForm.h b/src/Server/HTTP/HTMLForm.h index 8d8fb0d1719..ca6bb9048f1 100644 --- a/src/Server/HTTP/HTMLForm.h +++ b/src/Server/HTTP/HTMLForm.h @@ -118,7 +118,7 @@ private: const std::string boundary; bool boundary_hit = true; - std::string readLine(bool strict = true); + std::string readLine(bool append_crlf); bool nextImpl() override; }; diff --git a/tests/executable_pool_dictionary.xml b/tests/executable_pool_dictionary.xml new file mode 120000 index 00000000000..83f18b95f20 --- /dev/null +++ b/tests/executable_pool_dictionary.xml @@ -0,0 +1 @@ +config/executable_pool_dictionary.xml \ No newline at end of file diff --git a/tests/performance/string_to_int.xml b/tests/performance/string_to_int.xml new file mode 100644 index 00000000000..f231a4554d4 --- /dev/null +++ b/tests/performance/string_to_int.xml @@ -0,0 +1,12 @@ + + DROP TABLE IF EXISTS numeric_strings + CREATE TABLE numeric_strings(num String) ENGINE Memory + + + INSERT INTO numeric_strings SELECT number FROM numbers(30000000) + + + SELECT count(num::Int64) FROM numeric_strings FORMAT Null + + DROP TABLE IF EXISTS numeric_strings + diff --git a/tests/queries/0_stateless/00304_http_external_data.reference b/tests/queries/0_stateless/00304_http_external_data.reference index 93428f8768e..85909107584 100644 --- a/tests/queries/0_stateless/00304_http_external_data.reference +++ b/tests/queries/0_stateless/00304_http_external_data.reference @@ -2,3 +2,5 @@ 2 World 1 Hello 2 World +1 +2 diff --git a/tests/queries/0_stateless/00304_http_external_data.sh b/tests/queries/0_stateless/00304_http_external_data.sh index 41a9dea1ebb..4a097249cca 100755 --- a/tests/queries/0_stateless/00304_http_external_data.sh +++ b/tests/queries/0_stateless/00304_http_external_data.sh @@ -6,3 +6,4 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) echo -ne '1,Hello\n2,World\n' | ${CLICKHOUSE_CURL} -sSF 'file=@-' "${CLICKHOUSE_URL}&query=SELECT+*+FROM+file&file_format=CSV&file_types=UInt8,String"; echo -ne '1@Hello\n2@World\n' | ${CLICKHOUSE_CURL} -sSF 'file=@-' "${CLICKHOUSE_URL}&query=SELECT+*+FROM+file&file_format=CSV&file_types=UInt8,String&format_csv_delimiter=@"; +echo -ne '\x01\x00\x00\x00\x02\x00\x00\x00' | ${CLICKHOUSE_CURL} -sSF "tmp=@-" "${CLICKHOUSE_URL}&query=SELECT+*+FROM+tmp&tmp_structure=TaskID+UInt32&tmp_format=RowBinary"; diff --git a/tests/queries/0_stateless/00574_empty_strings_deserialization.sh b/tests/queries/0_stateless/00574_empty_strings_deserialization.sh index 1cbc9456ab0..fecb6ee17e6 100755 --- a/tests/queries/0_stateless/00574_empty_strings_deserialization.sh +++ b/tests/queries/0_stateless/00574_empty_strings_deserialization.sh @@ -8,8 +8,8 @@ $CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS empty_strings_deserialization" $CLICKHOUSE_CLIENT -q "CREATE TABLE empty_strings_deserialization(s String, i Int32, f Float32) ENGINE Memory" echo ',,' | $CLICKHOUSE_CLIENT -q "INSERT INTO empty_strings_deserialization FORMAT CSV" -echo 'aaa,-,' | $CLICKHOUSE_CLIENT -q "INSERT INTO empty_strings_deserialization FORMAT CSV" -echo 'bbb,,-' | $CLICKHOUSE_CLIENT -q "INSERT INTO empty_strings_deserialization FORMAT CSV" +echo 'aaa,,' | $CLICKHOUSE_CLIENT -q "INSERT INTO empty_strings_deserialization FORMAT CSV" +echo 'bbb,,-0' | $CLICKHOUSE_CLIENT -q "INSERT INTO empty_strings_deserialization FORMAT CSV" $CLICKHOUSE_CLIENT -q "SELECT * FROM empty_strings_deserialization ORDER BY s" diff --git a/tests/queries/0_stateless/01425_decimal_parse_big_negative_exponent.sql b/tests/queries/0_stateless/01425_decimal_parse_big_negative_exponent.sql index 7f276d1f8d4..7d0993c1bfc 100644 --- a/tests/queries/0_stateless/01425_decimal_parse_big_negative_exponent.sql +++ b/tests/queries/0_stateless/01425_decimal_parse_big_negative_exponent.sql @@ -1,4 +1,4 @@ -SELECT '-1E9-1E9-1E9-1E9' AS x, toDecimal32(x, 0); -- { serverError 6 } +SELECT '-1E9-1E9-1E9-1E9' AS x, toDecimal32(x, 0); -- { serverError 72 } SELECT '-1E9' AS x, toDecimal32(x, 0); -- { serverError 69 } SELECT '1E-9' AS x, toDecimal32(x, 0); SELECT '1E-8' AS x, toDecimal32(x, 0); diff --git a/tests/queries/0_stateless/01568_window_functions_distributed.reference b/tests/queries/0_stateless/01568_window_functions_distributed.reference index 7d5a95046f7..483e84a2bee 100644 --- a/tests/queries/0_stateless/01568_window_functions_distributed.reference +++ b/tests/queries/0_stateless/01568_window_functions_distributed.reference @@ -10,7 +10,9 @@ select max(identity(dummy + 1)) over () from remote('127.0.0.{1,2}', system, one 1 1 drop table if exists t_01568; -create table t_01568 engine Memory as select intDiv(number, 3) p, number from numbers(9); +create table t_01568 engine Memory as +select intDiv(number, 3) p, modulo(number, 3) o, number +from numbers(9); select sum(number) over w, max(number) over w from t_01568 window w as (partition by p); 3 2 3 2 @@ -57,4 +59,26 @@ select groupArray(groupArray(number)) over (rows unbounded preceding) from remot [[0,3,6],[1,4,7]] [[0,3,6],[1,4,7],[2,5,8]] select groupArray(groupArray(number)) over (rows unbounded preceding) from remote('127.0.0.{1,2}', '', t_01568) group by mod(number, 3) settings distributed_group_by_no_merge=2; -- { serverError 48 } +-- proper ORDER BY w/window functions +select p, o, count() over (partition by p) +from remote('127.0.0.{1,2}', '', t_01568) +order by p, o; +0 0 6 +0 0 6 +0 1 6 +0 1 6 +0 2 6 +0 2 6 +1 0 6 +1 0 6 +1 1 6 +1 1 6 +1 2 6 +1 2 6 +2 0 6 +2 0 6 +2 1 6 +2 1 6 +2 2 6 +2 2 6 drop table t_01568; diff --git a/tests/queries/0_stateless/01568_window_functions_distributed.sql b/tests/queries/0_stateless/01568_window_functions_distributed.sql index bc82e1ed6ac..6f38597a7a3 100644 --- a/tests/queries/0_stateless/01568_window_functions_distributed.sql +++ b/tests/queries/0_stateless/01568_window_functions_distributed.sql @@ -9,7 +9,9 @@ select max(identity(dummy + 1)) over () from remote('127.0.0.{1,2}', system, one drop table if exists t_01568; -create table t_01568 engine Memory as select intDiv(number, 3) p, number from numbers(9); +create table t_01568 engine Memory as +select intDiv(number, 3) p, modulo(number, 3) o, number +from numbers(9); select sum(number) over w, max(number) over w from t_01568 window w as (partition by p); @@ -22,4 +24,9 @@ select groupArray(groupArray(number)) over (rows unbounded preceding) from remot select groupArray(groupArray(number)) over (rows unbounded preceding) from remote('127.0.0.{1,2}', '', t_01568) group by mod(number, 3) settings distributed_group_by_no_merge=1; select groupArray(groupArray(number)) over (rows unbounded preceding) from remote('127.0.0.{1,2}', '', t_01568) group by mod(number, 3) settings distributed_group_by_no_merge=2; -- { serverError 48 } +-- proper ORDER BY w/window functions +select p, o, count() over (partition by p) +from remote('127.0.0.{1,2}', '', t_01568) +order by p, o; + drop table t_01568; diff --git a/tests/queries/0_stateless/01591_window_functions.reference b/tests/queries/0_stateless/01591_window_functions.reference index 2b54328688d..fa909972678 100644 --- a/tests/queries/0_stateless/01591_window_functions.reference +++ b/tests/queries/0_stateless/01591_window_functions.reference @@ -1054,6 +1054,12 @@ settings max_block_size = 3; 13 2 10 12 10 10 143 14 2 10 13 10 10 154 15 3 15 0 15 15 15 +-- careful with auto-application of Null combinator +select lagInFrame(toNullable(1)) over (); +0 +select lagInFrameOrNull(1) over (); -- { serverError 36 } +select intDiv(1, NULL) x, toTypeName(x), max(x) over (); +\N Nullable(Nothing) \N -- case-insensitive SQL-standard synonyms for any and anyLast select number, @@ -1114,3 +1120,31 @@ select count() over (rows between 2147483648 preceding and 2147493648 following) select count() over () from (select 1 a) l inner join (select 2 a) r using a; -- This case works as expected, one empty input chunk marked as input end. select count() over () where null; +-- Inheriting another window. +select number, count() over (w1 rows unbounded preceding) from numbers(10) +window + w0 as (partition by intDiv(number, 5) as p), + w1 as (w0 order by mod(number, 3) as o) +order by p, o, number +; +0 1 +3 2 +1 3 +4 4 +2 5 +6 1 +9 2 +7 3 +5 4 +8 5 +-- can't redefine PARTITION BY +select count() over (w partition by number) from numbers(1) window w as (partition by intDiv(number, 5)); -- { serverError 36 } +-- can't redefine existing ORDER BY +select count() over (w order by number) from numbers(1) window w as (partition by intDiv(number, 5) order by mod(number, 3)); -- { serverError 36 } +-- parent window can't have frame +select count() over (w range unbounded preceding) from numbers(1) window w as (partition by intDiv(number, 5) order by mod(number, 3) rows unbounded preceding); -- { serverError 36 } +-- looks weird but probably should work -- this is a window that inherits and changes nothing +select count() over (w) from numbers(1) window w as (); +1 +-- nonexistent parent window +select count() over (w2 rows unbounded preceding); -- { serverError 36 } diff --git a/tests/queries/0_stateless/01591_window_functions.sql b/tests/queries/0_stateless/01591_window_functions.sql index 9c6f1a7401c..05f4cb49252 100644 --- a/tests/queries/0_stateless/01591_window_functions.sql +++ b/tests/queries/0_stateless/01591_window_functions.sql @@ -376,6 +376,11 @@ order by number settings max_block_size = 3; ; +-- careful with auto-application of Null combinator +select lagInFrame(toNullable(1)) over (); +select lagInFrameOrNull(1) over (); -- { serverError 36 } +select intDiv(1, NULL) x, toTypeName(x), max(x) over (); + -- case-insensitive SQL-standard synonyms for any and anyLast select number, @@ -422,3 +427,26 @@ select count() over (rows between 2147483648 preceding and 2147493648 following) select count() over () from (select 1 a) l inner join (select 2 a) r using a; -- This case works as expected, one empty input chunk marked as input end. select count() over () where null; + +-- Inheriting another window. +select number, count() over (w1 rows unbounded preceding) from numbers(10) +window + w0 as (partition by intDiv(number, 5) as p), + w1 as (w0 order by mod(number, 3) as o) +order by p, o, number +; + +-- can't redefine PARTITION BY +select count() over (w partition by number) from numbers(1) window w as (partition by intDiv(number, 5)); -- { serverError 36 } + +-- can't redefine existing ORDER BY +select count() over (w order by number) from numbers(1) window w as (partition by intDiv(number, 5) order by mod(number, 3)); -- { serverError 36 } + +-- parent window can't have frame +select count() over (w range unbounded preceding) from numbers(1) window w as (partition by intDiv(number, 5) order by mod(number, 3) rows unbounded preceding); -- { serverError 36 } + +-- looks weird but probably should work -- this is a window that inherits and changes nothing +select count() over (w) from numbers(1) window w as (); + +-- nonexistent parent window +select count() over (w2 rows unbounded preceding); -- { serverError 36 } diff --git a/tests/queries/0_stateless/01882_scalar_subquery_exception.reference b/tests/queries/0_stateless/01882_scalar_subquery_exception.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/queries/0_stateless/01882_scalar_subquery_exception.sql b/tests/queries/0_stateless/01882_scalar_subquery_exception.sql new file mode 100644 index 00000000000..c7a4555d876 --- /dev/null +++ b/tests/queries/0_stateless/01882_scalar_subquery_exception.sql @@ -0,0 +1,16 @@ +drop table if exists nums_in_mem; +drop table if exists nums_in_mem_dist; + +create table nums_in_mem(v UInt64) engine=Memory; +insert into nums_in_mem select * from system.numbers limit 1000000; + +create table nums_in_mem_dist as nums_in_mem engine=Distributed('test_shard_localhost', currentDatabase(), nums_in_mem); + +set prefer_localhost_replica = 0; +set max_rows_to_read = 100; + +select + count() + / + (select count() from nums_in_mem_dist where rand() > 0) +from system.one; -- { serverError 158 } diff --git a/tests/queries/0_stateless/01888_read_int_safe.reference b/tests/queries/0_stateless/01888_read_int_safe.reference new file mode 100644 index 00000000000..94d36aad185 --- /dev/null +++ b/tests/queries/0_stateless/01888_read_int_safe.reference @@ -0,0 +1,2 @@ +1 +-1 diff --git a/tests/queries/0_stateless/01888_read_int_safe.sql b/tests/queries/0_stateless/01888_read_int_safe.sql new file mode 100644 index 00000000000..3caa4878aba --- /dev/null +++ b/tests/queries/0_stateless/01888_read_int_safe.sql @@ -0,0 +1,10 @@ +select toInt64('--1'); -- { serverError 72; } +select toInt64('+-1'); -- { serverError 72; } +select toInt64('++1'); -- { serverError 72; } +select toInt64('++'); -- { serverError 72; } +select toInt64('+'); -- { serverError 72; } +select toInt64('1+1'); -- { serverError 72; } +select toInt64('1-1'); -- { serverError 72; } +select toInt64(''); -- { serverError 32; } +select toInt64('1'); +select toInt64('-1'); diff --git a/tests/queries/0_stateless/arcadia_skip_list.txt b/tests/queries/0_stateless/arcadia_skip_list.txt index 2b03f32dccc..a59c1a72a52 100644 --- a/tests/queries/0_stateless/arcadia_skip_list.txt +++ b/tests/queries/0_stateless/arcadia_skip_list.txt @@ -238,4 +238,5 @@ 01850_dist_INSERT_preserve_error 01870_modulo_partition_key 01880_remote_ipv6 +01882_scalar_subquery_exception 01882_check_max_parts_to_merge_at_once