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 : :
484 alvherre@alvh.no-ip. 21 :CBC 18 : PG_FUNCTION_INFO_V1(test_create_multixact);
22 : 15 : PG_FUNCTION_INFO_V1(test_read_multixact);
23 : :
24 : : /*
25 : : * Produces multixact with 2 current xids
26 : : */
27 : : Datum
484 alvherre@alvh.no-ip. 28 :GBC 16 : test_create_multixact(PG_FUNCTION_ARGS)
29 : : {
30 : : MultiXactId id;
31 : :
32 : 16 : MultiXactIdSetOldestMember();
33 : 16 : id = MultiXactIdCreate(GetCurrentTransactionId(), MultiXactStatusUpdate,
34 : : GetCurrentTransactionId(), MultiXactStatusForShare);
35 : 16 : PG_RETURN_TRANSACTIONID(id);
36 : : }
37 : :
38 : : /*
39 : : * Reads given multixact. Discards local cache to make a real read.
40 : : */
41 : : Datum
42 : 13 : test_read_multixact(PG_FUNCTION_ARGS)
43 : : {
44 : 13 : MultiXactId id = PG_GETARG_TRANSACTIONID(0);
45 : : MultiXactMember *members;
46 : :
47 : : /* discard caches */
48 : 13 : AtEOXact_MultiXact();
49 : :
50 [ - + ]: 13 : if (GetMultiXactIdMembers(id, &members, false, false) == -1)
484 alvherre@alvh.no-ip. 51 [ # # ]:UBC 0 : elog(ERROR, "MultiXactId not found");
52 : :
484 alvherre@alvh.no-ip. 53 :GBC 13 : PG_RETURN_VOID();
54 : : }
|