PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
multixact.h
Go to the documentation of this file.
1/*
2 * multixact.h
3 *
4 * PostgreSQL multi-transaction-log manager
5 *
6 * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 * src/include/access/multixact.h
10 */
11#ifndef MULTIXACT_H
12#define MULTIXACT_H
13
14#include "access/xlogreader.h"
15#include "lib/stringinfo.h"
16#include "storage/sync.h"
17
18
19/*
20 * The first two MultiXactId values are reserved to store the truncation Xid
21 * and epoch of the first segment, so we start assigning multixact values from
22 * 2.
23 */
24#define InvalidMultiXactId ((MultiXactId) 0)
25#define FirstMultiXactId ((MultiXactId) 1)
26#define MaxMultiXactId ((MultiXactId) 0xFFFFFFFF)
27
28#define MultiXactIdIsValid(multi) ((multi) != InvalidMultiXactId)
29
30#define MaxMultiXactOffset ((MultiXactOffset) 0xFFFFFFFF)
31
32/*
33 * Possible multixact lock modes ("status"). The first four modes are for
34 * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
35 * next two are used for update and delete modes.
36 */
37typedef enum
38{
43 /* an update that doesn't touch "key" columns */
45 /* other updates, and delete */
48
49#define MaxMultiXactStatus MultiXactStatusUpdate
50
51/* does a status value correspond to a tuple update? */
52#define ISUPDATE_from_mxstatus(status) \
53 ((status) > MultiXactStatusForUpdate)
54
55
56typedef struct MultiXactMember
57{
61
62
63/* ----------------
64 * multixact-related XLOG entries
65 * ----------------
66 */
67
68#define XLOG_MULTIXACT_ZERO_OFF_PAGE 0x00
69#define XLOG_MULTIXACT_ZERO_MEM_PAGE 0x10
70#define XLOG_MULTIXACT_CREATE_ID 0x20
71#define XLOG_MULTIXACT_TRUNCATE_ID 0x30
72
73typedef struct xl_multixact_create
74{
75 MultiXactId mid; /* new MultiXact's ID */
76 MultiXactOffset moff; /* its starting offset in members file */
77 int32 nmembers; /* number of member XIDs */
80
81#define SizeOfMultiXactCreate (offsetof(xl_multixact_create, members))
82
84{
86
87 /* to-be-truncated range of multixact offsets */
88 MultiXactId startTruncOff; /* just for completeness' sake */
90
91 /* to-be-truncated range of multixact members */
95
96#define SizeOfMultiXactTruncate (sizeof(xl_multixact_truncate))
97
98
100 MultiXactStatus status1, TransactionId xid2,
101 MultiXactStatus status2);
103 MultiXactStatus status);
104extern MultiXactId MultiXactIdCreateFromMembers(int nmembers,
105 MultiXactMember *members);
106
108extern void ReadMultiXactIdRange(MultiXactId *oldest, MultiXactId *next);
109extern bool MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly);
110extern void MultiXactIdSetOldestMember(void);
111extern int GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
112 bool from_pgupgrade, bool isLockOnly);
113extern bool MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2);
115 MultiXactId multi2);
116
117extern int multixactoffsetssyncfiletag(const FileTag *ftag, char *path);
118extern int multixactmemberssyncfiletag(const FileTag *ftag, char *path);
119
120extern void AtEOXact_MultiXact(void);
121extern void AtPrepare_MultiXact(void);
122extern void PostPrepare_MultiXact(TransactionId xid);
123
124extern Size MultiXactShmemSize(void);
125extern void MultiXactShmemInit(void);
126extern void BootStrapMultiXact(void);
127extern void StartupMultiXact(void);
128extern void TrimMultiXact(void);
129extern void SetMultiXactIdLimit(MultiXactId oldest_datminmxid,
130 Oid oldest_datoid,
131 bool is_startup);
132extern void MultiXactGetCheckptMulti(bool is_shutdown,
133 MultiXactId *nextMulti,
134 MultiXactOffset *nextMultiOffset,
135 MultiXactId *oldestMulti,
136 Oid *oldestMultiDB);
137extern void CheckPointMultiXact(void);
139extern void TruncateMultiXact(MultiXactId newOldestMulti,
140 Oid newOldestMultiDB);
141extern void MultiXactSetNextMXact(MultiXactId nextMulti,
142 MultiXactOffset nextMultiOffset);
143extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
144 MultiXactOffset minMultiOffset);
145extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
146extern int MultiXactMemberFreezeThreshold(void);
147
149 void *recdata, uint32 len);
151 void *recdata, uint32 len);
153 void *recdata, uint32 len);
154
155extern void multixact_redo(XLogReaderState *record);
156extern void multixact_desc(StringInfo buf, XLogReaderState *record);
157extern const char *multixact_identify(uint8 info);
158extern char *mxid_to_string(MultiXactId multi, int nmembers,
159 MultiXactMember *members);
160
161#endif /* MULTIXACT_H */
static int32 next
Definition: blutils.c:219
uint8_t uint8
Definition: c.h:483
uint32 MultiXactOffset
Definition: c.h:618
TransactionId MultiXactId
Definition: c.h:616
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:417
int32_t int32
Definition: c.h:481
uint16_t uint16
Definition: c.h:484
uint32_t uint32
Definition: c.h:485
uint32 TransactionId
Definition: c.h:606
size_t Size
Definition: c.h:559
void MultiXactShmemInit(void)
Definition: multixact.c:1964
MultiXactId MultiXactIdExpand(MultiXactId multi, TransactionId xid, MultiXactStatus status)
Definition: multixact.c:487
void ReadMultiXactIdRange(MultiXactId *oldest, MultiXactId *next)
Definition: multixact.c:791
bool MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2)
Definition: multixact.c:3317
void multixact_redo(XLogReaderState *record)
Definition: multixact.c:3394
MultiXactStatus
Definition: multixact.h:38
@ MultiXactStatusForShare
Definition: multixact.h:40
@ MultiXactStatusForNoKeyUpdate
Definition: multixact.h:41
@ MultiXactStatusNoKeyUpdate
Definition: multixact.h:44
@ MultiXactStatusUpdate
Definition: multixact.h:46
@ MultiXactStatusForUpdate
Definition: multixact.h:42
@ MultiXactStatusForKeyShare
Definition: multixact.h:39
int multixactoffsetssyncfiletag(const FileTag *ftag, char *path)
Definition: multixact.c:3575
void multixact_twophase_postcommit(TransactionId xid, uint16 info, void *recdata, uint32 len)
Definition: multixact.c:1920
void MultiXactSetNextMXact(MultiXactId nextMulti, MultiXactOffset nextMultiOffset)
Definition: multixact.c:2328
void multixact_twophase_recover(TransactionId xid, uint16 info, void *recdata, uint32 len)
Definition: multixact.c:1899
void AtPrepare_MultiXact(void)
Definition: multixact.c:1836
bool MultiXactIdPrecedesOrEquals(MultiXactId multi1, MultiXactId multi2)
Definition: multixact.c:3331
void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
Definition: multixact.c:2536
bool MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
Definition: multixact.c:599
void MultiXactIdSetOldestMember(void)
Definition: multixact.c:673
void multixact_desc(StringInfo buf, XLogReaderState *record)
Definition: mxactdesc.c:50
void PostPrepare_MultiXact(TransactionId xid)
Definition: multixact.c:1850
Size MultiXactShmemSize(void)
Definition: multixact.c:1947
void multixact_twophase_postabort(TransactionId xid, uint16 info, void *recdata, uint32 len)
Definition: multixact.c:1935
void MultiXactGetCheckptMulti(bool is_shutdown, MultiXactId *nextMulti, MultiXactOffset *nextMultiOffset, MultiXactId *oldestMulti, Oid *oldestMultiDB)
Definition: multixact.c:2282
void SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid, bool is_startup)
Definition: multixact.c:2362
int multixactmemberssyncfiletag(const FileTag *ftag, char *path)
Definition: multixact.c:3584
MultiXactId GetOldestMultiXactId(void)
Definition: multixact.c:2660
void CheckPointMultiXact(void)
Definition: multixact.c:2304
MultiXactId MultiXactIdCreateFromMembers(int nmembers, MultiXactMember *members)
Definition: multixact.c:815
void TrimMultiXact(void)
Definition: multixact.c:2178
char * mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
Definition: multixact.c:1777
int MultiXactMemberFreezeThreshold(void)
Definition: multixact.c:2978
void MultiXactAdvanceNextMXact(MultiXactId minMulti, MultiXactOffset minMultiOffset)
Definition: multixact.c:2511
MultiXactId ReadNextMultiXactId(void)
Definition: multixact.c:771
void BootStrapMultiXact(void)
Definition: multixact.c:2034
MultiXactId MultiXactIdCreate(TransactionId xid1, MultiXactStatus status1, TransactionId xid2, MultiXactStatus status2)
Definition: multixact.c:434
void TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
Definition: multixact.c:3102
struct MultiXactMember MultiXactMember
const char * multixact_identify(uint8 info)
Definition: mxactdesc.c:84
void AtEOXact_MultiXact(void)
Definition: multixact.c:1808
struct xl_multixact_truncate xl_multixact_truncate
void StartupMultiXact(void)
Definition: multixact.c:2153
struct xl_multixact_create xl_multixact_create
int GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members, bool from_pgupgrade, bool isLockOnly)
Definition: multixact.c:1299
const void size_t len
static char * buf
Definition: pg_test_fsync.c:72
unsigned int Oid
Definition: postgres_ext.h:31
Definition: sync.h:51
TransactionId xid
Definition: multixact.h:58
MultiXactStatus status
Definition: multixact.h:59
MultiXactId mid
Definition: multixact.h:75
MultiXactMember members[FLEXIBLE_ARRAY_MEMBER]
Definition: multixact.h:78
MultiXactOffset moff
Definition: multixact.h:76
MultiXactId endTruncOff
Definition: multixact.h:89
MultiXactOffset startTruncMemb
Definition: multixact.h:92
MultiXactOffset endTruncMemb
Definition: multixact.h:93
MultiXactId startTruncOff
Definition: multixact.h:88