Skip to content

Commit

Permalink
Fix mutex on timezone retrieval (#276)
Browse files Browse the repository at this point in the history
* fix mutex contention

* add const ref
  • Loading branch information
ilovesoup2000 authored and zanmato1984 committed Oct 11, 2019
1 parent 22ad2d3 commit a1304ae
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dbms/src/Functions/FunctionsDateTime.h
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,7 @@ class FunctionMyTimeZoneConvertByOffset : public IFunction
}

void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result) override {
static const DateLUTImpl & UTC = DateLUT::instance("UTC");
if (const ColumnVector<FromFieldType> *col_from
= checkAndGetColumn<ColumnVector<FromFieldType>>(block.getByPosition(arguments[0]).column.get())) {
auto col_to = ColumnVector<ToFieldType>::create();
Expand All @@ -1329,7 +1330,7 @@ class FunctionMyTimeZoneConvertByOffset : public IFunction
for (size_t i = 0; i < size; ++i) {
UInt64 result_time = vec_from[i] + offset;
// todo maybe affected by daytime saving, need double check
convertTimeZoneByOffset(vec_from[i], result_time, offset, DateLUT::instance("UTC"));
convertTimeZoneByOffset(vec_from[i], result_time, offset, UTC);
vec_to[i] = result_time;
}

Expand Down Expand Up @@ -1383,7 +1384,7 @@ class FunctionMyTimeZoneConverter : public IFunction
size_t size = vec_from.size();
vec_to.resize(size);

const auto & time_zone_utc = DateLUT::instance("UTC");
static const auto & time_zone_utc = DateLUT::instance("UTC");
const auto & time_zone_other = extractTimeZoneFromFunctionArguments(block, arguments, 1, 0);
for (size_t i = 0; i < size; ++i)
{
Expand Down

0 comments on commit a1304ae

Please sign in to comment.