Skip to content

Commit

Permalink
Filter parent state candidate using exec nested level
Browse files Browse the repository at this point in the history
  • Loading branch information
bonnefoa committed Apr 5, 2024
1 parent eb84d31 commit bdce105
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/pg_tracing.c
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ begin_top_span(pgTracingTraceContext * trace_context, Span * top_span,
parent_id = trace_context->traceparent.parent_id;
else
{
TracedPlanstate *parent_traced_planstate = get_parent_traced_planstate();
TracedPlanstate *parent_traced_planstate = get_parent_traced_planstate(exec_nested_level);
Span *latest_top_span = get_latest_top_span(exec_nested_level - 1);

/*
Expand Down
2 changes: 1 addition & 1 deletion src/pg_tracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ extern void
extern void
cleanup_planstarts(void);
extern TracedPlanstate *
get_parent_traced_planstate(void);
get_parent_traced_planstate(int nested_level);
extern void
drop_traced_planstate(int exec_nested_level);

Expand Down
6 changes: 3 additions & 3 deletions src/pg_tracing_planstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,20 @@ get_traced_planstate(PlanState *planstate)
* Get possible parent traced_planstate
*/
TracedPlanstate *
get_parent_traced_planstate(void)
get_parent_traced_planstate(int nested_level)
{
TracedPlanstate *traced_planstate;

if (index_planstart >= 2)
{
traced_planstate = &traced_planstates[index_planstart - 2];
if (nodeTag(traced_planstate->planstate->plan) == T_ProjectSet)
if (traced_planstate->nested_level == nested_level && nodeTag(traced_planstate->planstate->plan) == T_ProjectSet)
return traced_planstate;
}
if (index_planstart >= 1)
{
traced_planstate = &traced_planstates[index_planstart - 1];
if (nodeTag(traced_planstate->planstate->plan) == T_Result)
if (traced_planstate->nested_level == nested_level && nodeTag(traced_planstate->planstate->plan) == T_Result)
return traced_planstate;
}
return NULL;
Expand Down

0 comments on commit bdce105

Please sign in to comment.