Line data Source code
1 : /*--------------------------------------------------------------------------
2 : *
3 : * test_multixact.c
4 : * Support code for multixact testing
5 : *
6 : * Portions Copyright (c) 1996-2026, 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 :
21 0 : PG_FUNCTION_INFO_V1(test_create_multixact);
22 0 : PG_FUNCTION_INFO_V1(test_read_multixact);
23 :
24 : /*
25 : * Produces multixact with 2 current xids
26 : */
27 : Datum
28 0 : test_create_multixact(PG_FUNCTION_ARGS)
29 : {
30 0 : MultiXactId id;
31 :
32 0 : MultiXactIdSetOldestMember();
33 0 : id = MultiXactIdCreate(GetCurrentTransactionId(), MultiXactStatusUpdate,
34 0 : GetCurrentTransactionId(), MultiXactStatusForShare);
35 0 : PG_RETURN_TRANSACTIONID(id);
36 0 : }
37 :
38 : /*
39 : * Reads given multixact. Discards local cache to make a real read.
40 : */
41 : Datum
42 0 : test_read_multixact(PG_FUNCTION_ARGS)
43 : {
44 0 : MultiXactId id = PG_GETARG_TRANSACTIONID(0);
45 0 : MultiXactMember *members;
46 :
47 : /* discard caches */
48 0 : AtEOXact_MultiXact();
49 :
50 0 : if (GetMultiXactIdMembers(id, &members, false, false) == -1)
51 0 : elog(ERROR, "MultiXactId not found");
52 :
53 0 : PG_RETURN_VOID();
54 0 : }
|