vVL2-0001-injection_points-extract-condition-header.patch
text/x-patch
Filename: vVL2-0001-injection_points-extract-condition-header.patch
Type: text/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch 0001
Subject: injection_points: extract InjectionPointCondition into a header
| File | + | − |
|---|---|---|
| src/test/modules/injection_points/injection_point_condition.h | 37 | 0 |
| src/test/modules/injection_points/injection_points.c | 2 | 24 |
From f03ed5938323b2a7fbddbd60f33ad8d80e3fc58e Mon Sep 17 00:00:00 2001
From: Vlad Lesin <vladlesin@gmail.com>
Date: Fri, 15 May 2026 09:32:54 +0300
Subject: [PATCH 1/5] injection_points: extract InjectionPointCondition into a
header
Move InjectionPointConditionType and InjectionPointCondition from
injection_points.c into a new injection_point_condition.h, and include
that header from injection_points.c. No functional change.
The struct is the private_data layout used when attaching an injection
point with a scoping condition: the producer fills it in and passes
its address to InjectionPointAttach(); the registered callback
(injection_wait / injection_error / injection_notice in
injection_points.c) receives the pointer back and consults
injection_point_allowed() to decide whether to fire. Having a single
header keeps both sides of that layout contract in one place so a
future field addition lands in exactly one source location.
---
.../injection_point_condition.h | 37 +++++++++++++++++++
.../injection_points/injection_points.c | 26 +------------
2 files changed, 39 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..b469601849b
--- /dev/null
+++ b/src/test/modules/injection_points/injection_point_condition.h
@@ -0,0 +1,37 @@
+/*-------------------------------------------------------------------------
+ *
+ * injection_point_condition.h
+ * Shared layout for the InjectionPointCondition private_data blob
+ *
+ * Used as private_data when attaching an injection_wait callback to scope
+ * the wait to a specific backend. Defined in a header so the producers
+ * (injection_points.c's injection_points_attach() and regress_prockill.c's
+ * prockill_attach_injection_wait_pid()) and the consumer
+ * (injection_points.c's injection_wait via injection_point_allowed())
+ * agree on the layout.
+ *
+ * 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, /* 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;
+
+#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.43.0