This is an automated email from the ASF dual-hosted git repository.

djwang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit d2d9d2b906bc0827c0def9c7ea9556a350dc4698
Author: Maxim Smyatkin <[email protected]>
AuthorDate: Tue Mar 28 17:07:23 2023 +0300

    [yagp_hooks_collector] Fix segfault in plan text generator
    
    Guard against NULL plan state when generating EXPLAIN output.
---
 src/EventSender.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/EventSender.cpp b/src/EventSender.cpp
index bb4765adeb1..b1815a22bf8 100644
--- a/src/EventSender.cpp
+++ b/src/EventSender.cpp
@@ -130,10 +130,13 @@ void set_query_info(yagpcc::QueryInfo *qi, QueryDesc 
*queryDesc)
         qi->set_generator(queryDesc->plannedstmt->planGen == PLANGEN_OPTIMIZER
                                 ? 
yagpcc::PlanGenerator::PLAN_GENERATOR_OPTIMIZER
                                 : 
yagpcc::PlanGenerator::PLAN_GENERATOR_PLANNER);
-        set_plan_text(qi->mutable_plantext(), queryDesc);
-        qi->set_plan_id(get_plan_id(queryDesc));
-        qi->set_query_id(queryDesc->plannedstmt->queryId);
+        if (queryDesc->planstate)
+        {
+            set_plan_text(qi->mutable_plantext(), queryDesc);
+            qi->set_plan_id(get_plan_id(queryDesc));
+        }
     }
+    qi->set_query_id(queryDesc->plannedstmt->queryId);
 }
 } // namespace
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to