Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 94a3373

Browse files
committed
Rework new SLRU test with injection points
Rather than the SQL injection_points_load(), this commit changes the injection point test introduced in 768a9fd to rely on the two macros INJECTION_POINT_LOAD() and INJECTION_POINT_CACHED(), that have been originally introduced for the sake of this test. This runs the test as a two-step process: load the injection point, then run its callback directly from the local cache loaded. What the test did originally was also fine, but the point here is to have an example in core of how to use these new macros. While on it, fix the header ordering in multixact.c, as pointed out by Alexander Korotkov. This was an oversight in 768a9fd. Per discussion with Álvaro Herrera. Author: Michael Paquier Discussion: https://postgr.es/m/ZsUnJUlSOBNAzwW1@paquier.xyz Discussion: https://postgr.es/m/CAPpHfduzaBz7KMhwuVOZMTpG=JniPG4aUosXPZCxZydmzq_oEQ@mail.gmail.com
1 parent 2e35c67 commit 94a3373

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/backend/access/transam/multixact.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@
8888
#include "storage/proc.h"
8989
#include "storage/procarray.h"
9090
#include "utils/fmgrprotos.h"
91-
#include "utils/injection_point.h"
9291
#include "utils/guc_hooks.h"
92+
#include "utils/injection_point.h"
9393
#include "utils/memutils.h"
9494

9595

@@ -855,6 +855,9 @@ MultiXactIdCreateFromMembers(int nmembers, MultiXactMember *members)
855855
}
856856
}
857857

858+
/* Load the injection point before entering the critical section */
859+
INJECTION_POINT_LOAD("multixact-create-from-members");
860+
858861
/*
859862
* Assign the MXID and offsets range to use, and make sure there is space
860863
* in the OFFSETs and MEMBERs files. NB: this routine does
@@ -869,7 +872,7 @@ MultiXactIdCreateFromMembers(int nmembers, MultiXactMember *members)
869872
*/
870873
multi = GetNewMultiXactId(nmembers, &offset);
871874

872-
INJECTION_POINT("multixact-create-from-members");
875+
INJECTION_POINT_CACHED("multixact-create-from-members");
873876

874877
/* Make an XLOG entry describing the new MXID. */
875878
xlrec.mid = multi;

src/test/modules/test_slru/t/001_multixact.pl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
$node = PostgreSQL::Test::Cluster->new('mike');
2525
$node->init;
2626
$node->append_conf('postgresql.conf',
27-
"shared_preload_libraries = 'test_slru'");
27+
"shared_preload_libraries = 'test_slru,injection_points'");
2828
$node->start;
2929
$node->safe_psql('postgres', q(CREATE EXTENSION injection_points));
3030
$node->safe_psql('postgres', q(CREATE EXTENSION test_slru));
@@ -64,7 +64,6 @@
6464
$creator->query_until(
6565
qr/start/, q{
6666
\echo start
67-
SELECT injection_points_load('multixact-create-from-members');
6867
SELECT test_create_multixact();
6968
});
7069

0 commit comments

Comments
 (0)