Age Owner Branch data TLA Line data Source code
1 : : /*--------------------------------------------------------------------------
2 : : *
3 : : * test_multixact.c
4 : : * Support code for multixact testing
5 : : *
6 : : * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7 : : * Portions Copyright (c) 1994, Regents of the University of California
8 : : *
9 : : * IDENTIFICATION
10 : : * src/test/modules/test_slru/test_multixact.c
11 : : *
12 : : * -------------------------------------------------------------------------
13 : : */
14 : :
15 : : #include "postgres.h"
16 : :
17 : : #include "access/multixact.h"
18 : : #include "access/xact.h"
19 : : #include "fmgr.h"
20 : : #include "utils/injection_point.h"
21 : :
382 alvherre@alvh.no-ip. 22 :CBC 1 : PG_FUNCTION_INFO_V1(test_create_multixact);
23 : 1 : PG_FUNCTION_INFO_V1(test_read_multixact);
24 : :
25 : : /*
26 : : * Produces multixact with 2 current xids
27 : : */
28 : : Datum
382 alvherre@alvh.no-ip. 29 :UBC 0 : test_create_multixact(PG_FUNCTION_ARGS)
30 : : {
31 : : MultiXactId id;
32 : :
33 : 0 : MultiXactIdSetOldestMember();
34 : 0 : id = MultiXactIdCreate(GetCurrentTransactionId(), MultiXactStatusUpdate,
35 : : GetCurrentTransactionId(), MultiXactStatusForShare);
36 : 0 : PG_RETURN_TRANSACTIONID(id);
37 : : }
38 : :
39 : : /*
40 : : * Reads given multixact after running an injection point. Discards local cache
41 : : * to make a real read. Tailored for multixact testing.
42 : : */
43 : : Datum
44 : 0 : test_read_multixact(PG_FUNCTION_ARGS)
45 : : {
46 : 0 : MultiXactId id = PG_GETARG_TRANSACTIONID(0);
47 : : MultiXactMember *members;
48 : :
49 : : INJECTION_POINT("test-multixact-read", NULL);
50 : : /* discard caches */
51 : 0 : AtEOXact_MultiXact();
52 : :
53 [ # # ]: 0 : if (GetMultiXactIdMembers(id, &members, false, false) == -1)
54 [ # # ]: 0 : elog(ERROR, "MultiXactId not found");
55 : :
56 : 0 : PG_RETURN_VOID();
57 : : }
|