From e5329d080b9d8436af8f65aac118745cf1f81ca2 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Wed, 21 Aug 2024 15:09:06 +0900
Subject: [PATCH 3/3] Rework new SLRU test with injection points

Rather than the SQL injection_points_load, this commit makes the test
rely on the two macros to load and run an injection point from the
cache, acting as an example of how to use them.
---
 src/backend/access/transam/multixact.c        | 5 ++++-
 src/test/modules/test_slru/t/001_multixact.pl | 3 +--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 14c2b929e2..d2d0298ac3 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -855,6 +855,9 @@ MultiXactIdCreateFromMembers(int nmembers, MultiXactMember *members)
 		}
 	}
 
+	/* Load the injection point before entering the critical section */
+	INJECTION_POINT_LOAD("multixact-create-from-members");
+
 	/*
 	 * Assign the MXID and offsets range to use, and make sure there is space
 	 * in the OFFSETs and MEMBERs files.  NB: this routine does
@@ -869,7 +872,7 @@ MultiXactIdCreateFromMembers(int nmembers, MultiXactMember *members)
 	 */
 	multi = GetNewMultiXactId(nmembers, &offset);
 
-	INJECTION_POINT("multixact-create-from-members");
+	INJECTION_POINT_CACHED("multixact-create-from-members");
 
 	/* Make an XLOG entry describing the new MXID. */
 	xlrec.mid = multi;
diff --git a/src/test/modules/test_slru/t/001_multixact.pl b/src/test/modules/test_slru/t/001_multixact.pl
index f07406bf9d..882de7cd20 100644
--- a/src/test/modules/test_slru/t/001_multixact.pl
+++ b/src/test/modules/test_slru/t/001_multixact.pl
@@ -24,7 +24,7 @@ my ($node, $result);
 $node = PostgreSQL::Test::Cluster->new('mike');
 $node->init;
 $node->append_conf('postgresql.conf',
-	"shared_preload_libraries = 'test_slru'");
+	"shared_preload_libraries = 'test_slru,injection_points'");
 $node->start;
 $node->safe_psql('postgres', q(CREATE EXTENSION injection_points));
 $node->safe_psql('postgres', q(CREATE EXTENSION test_slru));
@@ -64,7 +64,6 @@ $node->safe_psql('postgres',
 $creator->query_until(
 	qr/start/, q{
 	\echo start
-	SELECT injection_points_load('multixact-create-from-members');
 	SELECT test_create_multixact();
 });
 
-- 
2.45.2

