diff --git a/dbms/include/DB/Columns/ColumnConst.h b/dbms/include/DB/Columns/ColumnConst.h index 4d599448b63..3b30d53f0f1 100644 --- a/dbms/include/DB/Columns/ColumnConst.h +++ b/dbms/include/DB/Columns/ColumnConst.h @@ -156,8 +156,9 @@ typedef ColumnConst ColumnConstArray; template ColumnPtr ColumnConst::convertToFullColumn() const { - ColumnVector * res = new ColumnVector; - res->getData().assign(s, data); + ColumnVector * res_ = new ColumnVector; + ColumnPtr res = res_; + res_->getData().assign(s, data); return res; } diff --git a/dbms/include/DB/Functions/FunctionsCoding.h b/dbms/include/DB/Functions/FunctionsCoding.h index 403dd0eaaff..13cd8131e84 100644 --- a/dbms/include/DB/Functions/FunctionsCoding.h +++ b/dbms/include/DB/Functions/FunctionsCoding.h @@ -1324,7 +1324,6 @@ public: if (col_fstr_in) { ColumnString * col_str = new ColumnString; - col_res = col_str; ColumnString::Chars_t & out_vec = col_str->getChars(); diff --git a/dbms/include/DB/Functions/FunctionsDateTime.h b/dbms/include/DB/Functions/FunctionsDateTime.h index 71f4390294b..e35c1051f7d 100644 --- a/dbms/include/DB/Functions/FunctionsDateTime.h +++ b/dbms/include/DB/Functions/FunctionsDateTime.h @@ -408,6 +408,7 @@ public: if (const ColumnUInt32 * times = typeid_cast(&*block.getByPosition(arguments[0]).column)) { ColumnUInt32 * res = new ColumnUInt32; + ColumnPtr res_holder = res; ColumnUInt32::Container_t & res_vec = res->getData(); const ColumnUInt32::Container_t & vec = times->getData(); @@ -417,7 +418,7 @@ public: for (size_t i = 0; i < size; ++i) res_vec[i] = vec[i] / TIME_SLOT_SIZE * TIME_SLOT_SIZE; - block.getByPosition(result).column = res; + block.getByPosition(result).column = res_holder; } else if (const ColumnConstUInt32 * const_times = typeid_cast(&*block.getByPosition(arguments[0]).column)) { @@ -551,22 +552,23 @@ public: const ColumnConstUInt32 * const_durations = typeid_cast(&*block.getByPosition(arguments[1]).column); ColumnArray * res = new ColumnArray(new ColumnUInt32); + ColumnPtr res_holder = res; ColumnUInt32::Container_t & res_values = typeid_cast(res->getData()).getData(); if (starts && durations) { TimeSlotsImpl::vector_vector(starts->getData(), durations->getData(), res_values, res->getOffsets()); - block.getByPosition(result).column = res; + block.getByPosition(result).column = res_holder; } else if (starts && const_durations) { TimeSlotsImpl::vector_constant(starts->getData(), const_durations->getData(), res_values, res->getOffsets()); - block.getByPosition(result).column = res; + block.getByPosition(result).column = res_holder; } else if (const_starts && durations) { TimeSlotsImpl::constant_vector(const_starts->getData(), durations->getData(), res_values, res->getOffsets()); - block.getByPosition(result).column = res; + block.getByPosition(result).column = res_holder; } else if (const_starts && const_durations) { diff --git a/dbms/include/DB/Functions/FunctionsStringArray.h b/dbms/include/DB/Functions/FunctionsStringArray.h index 12f8f994b94..30c1b532f65 100644 --- a/dbms/include/DB/Functions/FunctionsStringArray.h +++ b/dbms/include/DB/Functions/FunctionsStringArray.h @@ -338,6 +338,7 @@ public: typeid_cast(&*block.getByPosition(arrayArgumentPosition).column); ColumnArray * col_res = new ColumnArray(new ColumnString); + ColumnPtr col_res_holder = col_res; ColumnString & res_strings = typeid_cast(col_res->getData()); ColumnArray::Offsets_t & res_offsets = col_res->getOffsets(); ColumnString::Chars_t & res_strings_chars = res_strings.getChars(); @@ -385,7 +386,7 @@ public: res_offsets.push_back(current_dst_offset); } - block.getByPosition(result).column = col_res; + block.getByPosition(result).column = col_res_holder; } else if (col_const_str) { diff --git a/dbms/src/Functions/FunctionsMiscellaneous.cpp b/dbms/src/Functions/FunctionsMiscellaneous.cpp index b8cd2fa1e4f..222ed78c254 100644 --- a/dbms/src/Functions/FunctionsMiscellaneous.cpp +++ b/dbms/src/Functions/FunctionsMiscellaneous.cpp @@ -109,8 +109,8 @@ namespace VisibleWidth if (const ColumnVector * col = typeid_cast *>(&*column)) { ColumnUInt64 * res = new ColumnUInt64(column->size()); - numWidthVector(col->getData(), res->getData()); block.getByPosition(result).column = res; + numWidthVector(col->getData(), res->getData()); return true; } else @@ -158,20 +158,20 @@ void FunctionVisibleWidth::execute(Block & block, const ColumnNumbers & argument else if (const ColumnString * col = typeid_cast(&*column)) { ColumnUInt64 * res = new ColumnUInt64(rows); - stringWidthVector(col->getChars(), col->getOffsets(), res->getData()); block.getByPosition(result).column = res; + stringWidthVector(col->getChars(), col->getOffsets(), res->getData()); } else if (const ColumnFixedString * col = typeid_cast(&*column)) { ColumnUInt64 * res = new ColumnUInt64(rows); - stringWidthFixedVector(col->getChars(), col->getN(), res->getData()); block.getByPosition(result).column = res; + stringWidthFixedVector(col->getChars(), col->getN(), res->getData()); } else if (const ColumnConstString * col = typeid_cast(&*column)) { UInt64 res = 0; - stringWidthConstant(col->getData(), res); block.getByPosition(result).column = new ColumnConstUInt64(rows, res); + stringWidthConstant(col->getData(), res); } else if (const ColumnArray * col = typeid_cast(&*column)) { @@ -191,6 +191,7 @@ void FunctionVisibleWidth::execute(Block & block, const ColumnNumbers & argument /// Теперь суммируем и кладём в результат. ColumnUInt64 * res = new ColumnUInt64(rows); + block.getByPosition(result).column = res; ColumnUInt64::Container_t & vec = res->getData(); size_t additional_symbols = 0; /// Кавычки. @@ -223,8 +224,6 @@ void FunctionVisibleWidth::execute(Block & block, const ColumnNumbers & argument vec[i] = 1 + std::max(static_cast(1), (i == 0 ? col->getOffsets()[0] : (col->getOffsets()[i] - col->getOffsets()[i - 1])) * nested_length); } - - block.getByPosition(result).column = res; } else if (const ColumnTuple * col = typeid_cast(&*column)) {