0001-Extend-injection_points_attach-function.patch
application/octet-stream
Filename: 0001-Extend-injection_points_attach-function.patch
Type: application/octet-stream
Part: 0
From b86b552fb5a465c23ce845971d371e9552cb552c Mon Sep 17 00:00:00 2001
From: Rahila Syed <rahilasyed.90@gmail.com>
Date: Tue, 28 Oct 2025 16:44:20 +0530
Subject: [PATCH] Extend injection_points_attach function
Add a new action called "func" which will assign
a user defined function to a given injection point.
This requires user to specify module name and function
name in addition to injection point name and action.
---
.../injection_points--1.0.sql | 4 ++--
.../injection_points/injection_points.c | 19 +++++++++++++++++--
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/src/test/modules/injection_points/injection_points--1.0.sql b/src/test/modules/injection_points/injection_points--1.0.sql
index a7b61fbdfe6..da5ba0a40fa 100644
--- a/src/test/modules/injection_points/injection_points--1.0.sql
+++ b/src/test/modules/injection_points/injection_points--1.0.sql
@@ -9,10 +9,10 @@
-- Attaches the action to the given injection point.
--
CREATE FUNCTION injection_points_attach(IN point_name TEXT,
- IN action text)
+ IN action text, IN func TEXT default NULL, IN module TEXT default NULL)
RETURNS void
AS 'MODULE_PATHNAME', 'injection_points_attach'
-LANGUAGE C STRICT PARALLEL UNSAFE;
+LANGUAGE C PARALLEL UNSAFE;
--
-- injection_points_load()
diff --git a/src/test/modules/injection_points/injection_points.c b/src/test/modules/injection_points/injection_points.c
index 31138301117..087d2b11a90 100644
--- a/src/test/modules/injection_points/injection_points.c
+++ b/src/test/modules/injection_points/injection_points.c
@@ -354,6 +354,7 @@ injection_points_attach(PG_FUNCTION_ARGS)
char *name = text_to_cstring(PG_GETARG_TEXT_PP(0));
char *action = text_to_cstring(PG_GETARG_TEXT_PP(1));
char *function;
+ char *mod_name;
InjectionPointCondition condition = {0};
if (strcmp(action, "error") == 0)
@@ -362,6 +363,15 @@ injection_points_attach(PG_FUNCTION_ARGS)
function = "injection_notice";
else if (strcmp(action, "wait") == 0)
function = "injection_wait";
+ else if (strcmp(action, "func") == 0)
+ {
+ if (PG_ARGISNULL(2))
+ elog(ERROR, "function name cannot be null for \"%s\" action", action);
+ function = text_to_cstring(PG_GETARG_TEXT_PP(2));
+ if (PG_ARGISNULL(3))
+ elog(ERROR, "module name cannot be null for \"%s\" action", action);
+ mod_name = text_to_cstring(PG_GETARG_TEXT_PP(3));
+ }
else
elog(ERROR, "incorrect action \"%s\" for injection point creation", action);
@@ -372,8 +382,13 @@ injection_points_attach(PG_FUNCTION_ARGS)
}
pgstat_report_inj_fixed(1, 0, 0, 0, 0);
- InjectionPointAttach(name, "injection_points", function, &condition,
- sizeof(InjectionPointCondition));
+
+ if (strcmp(action, "func") == 0)
+ InjectionPointAttach(name, mod_name, function, &condition,
+ sizeof(InjectionPointCondition));
+ else
+ InjectionPointAttach(name, "injection_points", function, &condition,
+ sizeof(InjectionPointCondition));
if (injection_point_local)
{
--
2.34.1