From 588fdcffdf4f1883063db4f896d6a536291c072b Mon Sep 17 00:00:00 2001 From: vdimir Date: Wed, 29 Mar 2023 09:42:32 +0000 Subject: [PATCH] comment child_plans in ReadFromMerge --- src/Storages/StorageMerge.cpp | 2 ++ src/Storages/StorageMerge.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Storages/StorageMerge.cpp b/src/Storages/StorageMerge.cpp index 40ad4ab0f26..00ccfebff25 100644 --- a/src/Storages/StorageMerge.cpp +++ b/src/Storages/StorageMerge.cpp @@ -655,6 +655,8 @@ QueryPipelineBuilderPtr ReadFromMerge::createSources( if (real_column_names.empty()) real_column_names.push_back(ExpressionActions::getSmallestColumn(storage_snapshot->metadata->getColumns().getAllPhysical()).name); + /// Steps for reading from child tables should have the same lifetime as the current step + /// because `builder` can have references to them (mainly for EXPLAIN PIPELINE). QueryPlan & plan = child_plans.emplace_back(); StorageView * view = dynamic_cast(storage.get()); diff --git a/src/Storages/StorageMerge.h b/src/Storages/StorageMerge.h index 602da045dfb..d53dcd34f5f 100644 --- a/src/Storages/StorageMerge.h +++ b/src/Storages/StorageMerge.h @@ -159,6 +159,8 @@ private: StoragePtr storage_merge; StorageSnapshotPtr merge_storage_snapshot; + /// Store read plan for each child table. + /// It's needed to guarantee lifetime for child steps to be the same as for this step. std::vector child_plans; SelectQueryInfo query_info;