From bb60b4e85935f4444e7973b775db58ffd069638e Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 7 Oct 2014 22:42:35 +0400 Subject: [PATCH] dbms: fixed bad code [#METR-12726]. --- dbms/src/Common/VirtualColumnUtils.cpp | 1 + dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp | 2 +- dbms/src/Storages/StorageChunkMerger.cpp | 2 +- dbms/src/Storages/StorageChunks.cpp | 2 +- dbms/src/Storages/StorageMerge.cpp | 2 +- dbms/src/Storages/StorageReplicatedMergeTree.cpp | 2 +- dbms/src/Storages/StorageSystemParts.cpp | 4 ++-- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dbms/src/Common/VirtualColumnUtils.cpp b/dbms/src/Common/VirtualColumnUtils.cpp index 553505e6c01..bec2bca6787 100644 --- a/dbms/src/Common/VirtualColumnUtils.cpp +++ b/dbms/src/Common/VirtualColumnUtils.cpp @@ -136,6 +136,7 @@ static ASTPtr buildWhereExpression(const ASTs & functions) bool filterBlockWithQuery(ASTPtr query, Block & block, const Context & context) { + query = query->clone(); const ASTSelectQuery & select = typeid_cast(*query); if (!select.where_expression && !select.prewhere_expression) return false; diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp b/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp index f83537bc78e..8ff94be69f7 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp @@ -74,7 +74,7 @@ BlockInputStreams MergeTreeDataSelectExecutor::read( /// Если запрошен хотя бы один виртуальный столбец, пробуем индексировать if (!virt_column_names.empty()) - VirtualColumnUtils::filterBlockWithQuery(query->clone(), virtual_columns_block, data.context); + VirtualColumnUtils::filterBlockWithQuery(query, virtual_columns_block, data.context); std::multiset values = VirtualColumnUtils::extractSingleValueFromBlock(virtual_columns_block, "_part"); diff --git a/dbms/src/Storages/StorageChunkMerger.cpp b/dbms/src/Storages/StorageChunkMerger.cpp index 53fbee18c83..f88751c5740 100644 --- a/dbms/src/Storages/StorageChunkMerger.cpp +++ b/dbms/src/Storages/StorageChunkMerger.cpp @@ -134,7 +134,7 @@ BlockInputStreams StorageChunkMerger::read( /// Если запрошен хотя бы один виртуальный столбец, пробуем индексировать if (has_virtual_column) - VirtualColumnUtils::filterBlockWithQuery(query->clone(), virtual_columns_block, context); + VirtualColumnUtils::filterBlockWithQuery(query, virtual_columns_block, context); std::multiset values = VirtualColumnUtils::extractSingleValueFromBlock(virtual_columns_block, _table_column_name); diff --git a/dbms/src/Storages/StorageChunks.cpp b/dbms/src/Storages/StorageChunks.cpp index a94a63bcb7f..0d00c20e38c 100644 --- a/dbms/src/Storages/StorageChunks.cpp +++ b/dbms/src/Storages/StorageChunks.cpp @@ -55,7 +55,7 @@ BlockInputStreams StorageChunks::read( return read(0, std::numeric_limits::max(), column_names, query, settings, processed_stage, max_block_size, threads); Block virtual_columns_block = getBlockWithVirtualColumns(); - if (!VirtualColumnUtils::filterBlockWithQuery(query->clone(), virtual_columns_block, context)) + if (!VirtualColumnUtils::filterBlockWithQuery(query, virtual_columns_block, context)) return read(0, std::numeric_limits::max(), column_names, query, settings, processed_stage, max_block_size, threads); std::multiset values = VirtualColumnUtils::extractSingleValueFromBlock(virtual_columns_block, _table_column_name); diff --git a/dbms/src/Storages/StorageMerge.cpp b/dbms/src/Storages/StorageMerge.cpp index dadbce9e086..de241a5614e 100644 --- a/dbms/src/Storages/StorageMerge.cpp +++ b/dbms/src/Storages/StorageMerge.cpp @@ -85,7 +85,7 @@ BlockInputStreams StorageMerge::read( /// Если запрошен хотя бы один виртуальный столбец, пробуем индексировать if (!virt_column_names.empty()) - VirtualColumnUtils::filterBlockWithQuery(query->clone(), virtual_columns_block, context); + VirtualColumnUtils::filterBlockWithQuery(query, virtual_columns_block, context); std::multiset values = VirtualColumnUtils::extractSingleValueFromBlock(virtual_columns_block, "_table"); diff --git a/dbms/src/Storages/StorageReplicatedMergeTree.cpp b/dbms/src/Storages/StorageReplicatedMergeTree.cpp index 6328bb79194..1cdf5d0147c 100644 --- a/dbms/src/Storages/StorageReplicatedMergeTree.cpp +++ b/dbms/src/Storages/StorageReplicatedMergeTree.cpp @@ -2208,7 +2208,7 @@ BlockInputStreams StorageReplicatedMergeTree::read( /// Если запрошен хотя бы один виртуальный столбец, пробуем индексировать if (!virt_column_names.empty()) - VirtualColumnUtils::filterBlockWithQuery(query->clone(), virtual_columns_block, context); + VirtualColumnUtils::filterBlockWithQuery(query, virtual_columns_block, context); std::multiset values = VirtualColumnUtils::extractSingleValueFromBlock(virtual_columns_block, "_replicated"); diff --git a/dbms/src/Storages/StorageSystemParts.cpp b/dbms/src/Storages/StorageSystemParts.cpp index 8cc06946e0d..df96795ae5d 100644 --- a/dbms/src/Storages/StorageSystemParts.cpp +++ b/dbms/src/Storages/StorageSystemParts.cpp @@ -62,7 +62,7 @@ BlockInputStreams StorageSystemParts::read( block.insert(ColumnWithNameAndType(database_column, new DataTypeString, "database")); /// Отфильтруем блок со столбцом database. - VirtualColumnUtils::filterBlockWithQuery(query->clone(), block, context); + VirtualColumnUtils::filterBlockWithQuery(query, block, context); if (!block.rows()) return BlockInputStreams(); @@ -129,7 +129,7 @@ BlockInputStreams StorageSystemParts::read( } /// Отфильтруем блок со столбцами database, table, engine, replicated и active. - VirtualColumnUtils::filterBlockWithQuery(query->clone(), block, context); + VirtualColumnUtils::filterBlockWithQuery(query, block, context); if (!block.rows()) return BlockInputStreams();