diff --git a/src/Functions/transform.cpp b/src/Functions/transform.cpp index b7582b37017..f1d2b60f1f4 100644 --- a/src/Functions/transform.cpp +++ b/src/Functions/transform.cpp @@ -154,7 +154,7 @@ namespace ColumnPtr executeImpl( const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, size_t input_rows_count) const override { - initialize(arguments, result_type); + std::call_once(once, [&] { initialize(arguments, result_type); }); const auto * in = arguments[0].column.get(); @@ -672,11 +672,9 @@ namespace ColumnPtr default_column; bool is_empty = false; - bool initialized = false; - - std::mutex mutex; }; + mutable std::once_flag once; mutable Cache cache; @@ -706,10 +704,6 @@ namespace /// Can be called from different threads. It works only on the first call. void initialize(const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type) const { - std::lock_guard lock(cache.mutex); - if (cache.initialized) - return; - const DataTypePtr & from_type = arguments[0].type; if (from_type->onlyNull()) @@ -824,8 +818,6 @@ namespace } } } - - cache.initialized = true; } };