From d523218aef1001d9ee7697e1a60bad1979206b70 Mon Sep 17 00:00:00 2001 From: Andrey Borodin Date: Wed, 6 May 2026 11:17:05 +0500 Subject: [PATCH vAB2 1/3] Extract InjectionPointCondition to injection_point_condition.h Move InjectionPointCondition and InjectionPointConditionType from injection_points.c into a small header so other test modules can build the same private_data layout passed to injection_wait without copying the definition. Discussion: https://www.postgresql.org/message-id/d2983796-2603-41b7-a66e-fc8489ddb954@gmail.com Author: Vlad Lesin Reviewed-by: Andrey Borodin --- .../injection_point_condition.h | 25 ++++++++++++++++++ .../injection_points/injection_points.c | 26 ++----------------- 2 files changed, 27 insertions(+), 24 deletions(-) create mode 100644 src/test/modules/injection_points/injection_point_condition.h diff --git a/src/test/modules/injection_points/injection_point_condition.h b/src/test/modules/injection_points/injection_point_condition.h new file mode 100644 index 00000000000..fc926196c65 --- /dev/null +++ b/src/test/modules/injection_points/injection_point_condition.h @@ -0,0 +1,25 @@ +/*------------------------------------------------------------------------- + * injection_point_condition.h + * Shared condition payload for injection_points module callbacks + * + * Copyright (c) 2025-2026, PostgreSQL Global Development Group + * + * src/test/modules/injection_points/injection_point_condition.h + *------------------------------------------------------------------------- + */ +#ifndef INJECTION_POINT_CONDITION_H +#define INJECTION_POINT_CONDITION_H + +typedef enum InjectionPointConditionType +{ + INJ_CONDITION_ALWAYS = 0, + INJ_CONDITION_PID, +} InjectionPointConditionType; + +typedef struct InjectionPointCondition +{ + InjectionPointConditionType type; + int pid; +} InjectionPointCondition; + +#endif /* INJECTION_POINT_CONDITION_H */ diff --git a/src/test/modules/injection_points/injection_points.c b/src/test/modules/injection_points/injection_points.c index 0f1af513673..fb7a7d477cc 100644 --- a/src/test/modules/injection_points/injection_points.c +++ b/src/test/modules/injection_points/injection_points.c @@ -34,36 +34,14 @@ #include "utils/tuplestore.h" #include "utils/wait_event.h" +#include "injection_point_condition.h" + PG_MODULE_MAGIC; /* Maximum number of waits usable in injection points at once */ #define INJ_MAX_WAIT 8 #define INJ_NAME_MAXLEN 64 -/* - * Conditions related to injection points. This tracks in shared memory the - * runtime conditions under which an injection point is allowed to run, - * stored as private_data when an injection point is attached, and passed as - * argument to the callback. - * - * If more types of runtime conditions need to be tracked, this structure - * should be expanded. - */ -typedef enum InjectionPointConditionType -{ - INJ_CONDITION_ALWAYS = 0, /* always run */ - INJ_CONDITION_PID, /* PID restriction */ -} InjectionPointConditionType; - -typedef struct InjectionPointCondition -{ - /* Type of the condition */ - InjectionPointConditionType type; - - /* ID of the process where the injection point is allowed to run */ - int pid; -} InjectionPointCondition; - /* * List of injection points stored in TopMemoryContext attached * locally to this process. -- 2.50.1 (Apple Git-155)