* Fixing bug in StorageLiveView.cpp getHeader() method

that sometimes addressed invalid pointer when getHeader()
  method was called without holding the mutex
This commit is contained in:
Vitaliy Zakaznikov 2019-06-14 16:27:43 -04:00
parent 13978c03f3
commit d6d0404c48

View File

@ -158,11 +158,10 @@ bool StorageLiveView::hasColumn(const String & column_name) const
Block StorageLiveView::getHeader() const
{
if (!sample_block)
{
if (!(*blocks_ptr) || (*blocks_ptr)->empty())
{
auto storage = global_context.getTable(select_database_name, select_table_name);
sample_block = InterpreterSelectQuery(inner_query, global_context, storage, SelectQueryOptions(QueryProcessingStage::Complete)).getSampleBlock();
sample_block = InterpreterSelectQuery(inner_query, global_context, storage,
SelectQueryOptions(QueryProcessingStage::Complete)).getSampleBlock();
sample_block.insert({DataTypeUInt64().createColumnConst(
sample_block.rows(), 0)->convertToFullColumnIfConst(),
std::make_shared<DataTypeUInt64>(),
@ -174,11 +173,6 @@ Block StorageLiveView::getHeader() const
sample_block.safeGetByPosition(i).column = sample_block.safeGetByPosition(i).column->convertToFullColumnIfConst();
}
}
else
{
sample_block = (*blocks_ptr)->front().cloneEmpty();
}
}
return sample_block;
}