From 03ba9acd043bbe39ff87a485e39d15daabb09020 Mon Sep 17 00:00:00 2001 From: Anthonin Bonnefoy Date: Tue, 3 Sep 2024 09:34:12 +0200 Subject: [PATCH] Rename hook phase to hook type --- src/pg_tracing.c | 10 +++++----- src/pg_tracing.h | 6 +++--- src/pg_tracing_active_spans.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/pg_tracing.c b/src/pg_tracing.c index d1f3b26..c499b22 100644 --- a/src/pg_tracing.c +++ b/src/pg_tracing.c @@ -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 */ @@ -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; @@ -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; diff --git a/src/pg_tracing.h b/src/pg_tracing.h index c04381b..b7db4d6 100644 --- a/src/pg_tracing.h +++ b/src/pg_tracing.h @@ -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 @@ -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); diff --git a/src/pg_tracing_active_spans.c b/src/pg_tracing_active_spans.c index fd72fcc..9675e67 100644 --- a/src/pg_tracing_active_spans.c +++ b/src/pg_tracing_active_spans.c @@ -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(); @@ -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; /*