Skip to content

Commit

Permalink
Rename hook phase to hook type
Browse files Browse the repository at this point in the history
  • Loading branch information
bonnefoa committed Sep 3, 2024
1 parent e8fe6b5 commit 03ba9ac
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/pg_tracing.c
Original file line number Diff line number Diff line change
Expand Up @@ -1490,14 +1490,14 @@ initialise_span_context(SpanContext * span_context,
}

static bool
should_start_tx_block(const Node *utilityStmt, HookPhase hook_phase)
should_start_tx_block(const Node *utilityStmt, HookType hook_type)
{
TransactionStmt *stmt;

if (hook_phase == HOOK_PARSE && GetCurrentTransactionStartTimestamp() != GetCurrentStatementStartTimestamp())
if (hook_type == HOOK_PARSE && GetCurrentTransactionStartTimestamp() != GetCurrentStatementStartTimestamp())
/* There's an ongoing tx block, we can create the matching span */
return true;
if (hook_phase == HOOK_UTILITY && utilityStmt != NULL && nodeTag(utilityStmt) == T_TransactionStmt)
if (hook_type == HOOK_UTILITY && utilityStmt != NULL && nodeTag(utilityStmt) == T_TransactionStmt)
{
stmt = (TransactionStmt *) utilityStmt;
/* If we have an explicit BEGIN statement, start a tx block */
Expand All @@ -1510,7 +1510,7 @@ should_start_tx_block(const Node *utilityStmt, HookPhase hook_phase)
* Start a tx_block span if we have an explicit BEGIN utility statement
*/
static void
start_tx_block_span(const Node *utilityStmt, SpanContext * span_context, HookPhase hook_phase)
start_tx_block_span(const Node *utilityStmt, SpanContext * span_context, HookType hook_type)
{
if (nested_level > 0)
return;
Expand All @@ -1519,7 +1519,7 @@ start_tx_block_span(const Node *utilityStmt, SpanContext * span_context, HookPha
/* We already have an ongoing tx_block span */
return;

if (!should_start_tx_block(utilityStmt, hook_phase))
if (!should_start_tx_block(utilityStmt, hook_type))
/* Not a candidate to start tx block */
return;

Expand Down
6 changes: 3 additions & 3 deletions src/pg_tracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ typedef struct PlanCounters
/*
* Hook currently called
*/
typedef enum HookPhase
typedef enum HookType
{
HOOK_PARSE,
HOOK_UTILITY,
HOOK_PLANNER,
HOOK_EXECUTOR,
} HookPhase;
} HookType;

/*
* Error code when parsing traceparent field
Expand Down Expand Up @@ -415,7 +415,7 @@ extern Span * pop_and_store_active_span(const TimestampTz end_time);
extern Span * pop_active_span(void);
extern Span * peek_active_span(void);
extern Span * push_active_span(MemoryContext context, const SpanContext * span_context,
SpanType span_type, HookPhase hook_phase);
SpanType span_type, HookType hook_type);
extern Span * push_child_active_span(MemoryContext context, const SpanContext * span_context,
SpanType span_type);

Expand Down
4 changes: 2 additions & 2 deletions src/pg_tracing_active_spans.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ push_child_active_span(MemoryContext context, const SpanContext * span_context,
*/
Span *
push_active_span(MemoryContext context, const SpanContext * span_context, SpanType span_type,
HookPhase hook_phase)
HookType hook_type)
{
Span *span = peek_active_span_for_current_level();
Span *parent_span = peek_active_span();
Expand All @@ -271,7 +271,7 @@ push_active_span(MemoryContext context, const SpanContext * span_context, SpanTy
}
else
{
if (hook_phase != HOOK_PARSE || nested_level > 0)
if (hook_type != HOOK_PARSE || nested_level > 0)
return span;

/*
Expand Down

0 comments on commit 03ba9ac

Please sign in to comment.