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