From 089d1a3a549d7694a6b093e4dc6321a711331dec Mon Sep 17 00:00:00 2001
From: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
Date: Thu, 18 Jan 2024 10:32:29 +0530
Subject: [PATCH 4/6] Comment and documentation suggestions.

... reflecting a user's point of view.

Ashutosh Bapat
---
 .../modules/injection_points/injection_points--1.0.sql |  9 ++++-----
 src/test/modules/injection_points/injection_points.c   | 10 +++++-----
 2 files changed, 9 insertions(+), 10 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 64ff69bd7f..5944c41716 100644
--- a/src/test/modules/injection_points/injection_points--1.0.sql
+++ b/src/test/modules/injection_points/injection_points--1.0.sql
@@ -6,11 +6,10 @@
 --
 -- injection_points_attach()
 --
--- Attaches an injection point using callbacks from one of the predefined
--- modes.
+-- Attaches the action to the given injection point.
 --
 CREATE FUNCTION injection_points_attach(IN point_name TEXT,
-    IN mode text)
+    IN action text)
 RETURNS void
 AS 'MODULE_PATHNAME', 'injection_points_attach'
 LANGUAGE C STRICT PARALLEL UNSAFE;
@@ -18,7 +17,7 @@ LANGUAGE C STRICT PARALLEL UNSAFE;
 --
 -- injection_points_run()
 --
--- Executes an injection point.
+-- Executes the action attached to the injection point.
 --
 CREATE FUNCTION injection_points_run(IN point_name TEXT)
 RETURNS void
@@ -28,7 +27,7 @@ LANGUAGE C STRICT PARALLEL UNSAFE;
 --
 -- injection_points_detach()
 --
--- Detaches an injection point.
+-- Detaches the current action, if any, from the given injection point.
 --
 CREATE FUNCTION injection_points_detach(IN point_name TEXT)
 RETURNS void
diff --git a/src/test/modules/injection_points/injection_points.c b/src/test/modules/injection_points/injection_points.c
index 47e7522faf..bf947de0b7 100644
--- a/src/test/modules/injection_points/injection_points.c
+++ b/src/test/modules/injection_points/injection_points.c
@@ -30,7 +30,7 @@ extern PGDLLEXPORT void injection_error(const char *name);
 extern PGDLLEXPORT void injection_notice(const char *name);
 
 
-/* Set of callbacks available at point creation */
+/* Set of callbacks available to be attached to an injection point. */
 void
 injection_error(const char *name)
 {
@@ -51,15 +51,15 @@ Datum
 injection_points_attach(PG_FUNCTION_ARGS)
 {
 	char	   *name = text_to_cstring(PG_GETARG_TEXT_PP(0));
-	char	   *mode = text_to_cstring(PG_GETARG_TEXT_PP(1));
+	char	   *action = text_to_cstring(PG_GETARG_TEXT_PP(1));
 	char	   *function;
 
-	if (strcmp(mode, "error") == 0)
+	if (strcmp(action, "error") == 0)
 		function = "injection_error";
-	else if (strcmp(mode, "notice") == 0)
+	else if (strcmp(action, "notice") == 0)
 		function = "injection_notice";
 	else
-		elog(ERROR, "incorrect mode \"%s\" for injection point creation", mode);
+		elog(ERROR, "incorrect action \"%s\" for injection point creation", action);
 
 	InjectionPointAttach(name, "injection_points", function);
 
-- 
2.25.1

