Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
multixact.h166 linesDownload Raw Back to access
1/*2 * multixact.h3 *4 * PostgreSQL multi-transaction-log manager5 *6 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group7 * Portions Copyright (c) 1994, Regents of the University of California8 *9 * src/include/access/multixact.h10 */11#ifndef MULTIXACT_H12#define MULTIXACT_H13 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 Xid21 * and epoch of the first segment, so we start assigning multixact values from22 * 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/* Number of SLRU buffers to use for multixact */33#define NUM_MULTIXACTOFFSET_BUFFERS		834#define NUM_MULTIXACTMEMBER_BUFFERS		1635 36/*37 * Possible multixact lock modes ("status").  The first four modes are for38 * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the39 * next two are used for update and delete modes.40 */41typedef enum42{43	MultiXactStatusForKeyShare = 0x00,44	MultiXactStatusForShare = 0x01,45	MultiXactStatusForNoKeyUpdate = 0x02,46	MultiXactStatusForUpdate = 0x03,47	/* an update that doesn't touch "key" columns */48	MultiXactStatusNoKeyUpdate = 0x04,49	/* other updates, and delete */50	MultiXactStatusUpdate = 0x0551} MultiXactStatus;52 53#define MaxMultiXactStatus MultiXactStatusUpdate54 55/* does a status value correspond to a tuple update? */56#define ISUPDATE_from_mxstatus(status) \57			((status) > MultiXactStatusForUpdate)58 59 60typedef struct MultiXactMember61{62	TransactionId xid;63	MultiXactStatus status;64} MultiXactMember;65 66 67/* ----------------68 *		multixact-related XLOG entries69 * ----------------70 */71 72#define XLOG_MULTIXACT_ZERO_OFF_PAGE	0x0073#define XLOG_MULTIXACT_ZERO_MEM_PAGE	0x1074#define XLOG_MULTIXACT_CREATE_ID		0x2075#define XLOG_MULTIXACT_TRUNCATE_ID		0x3076 77typedef struct xl_multixact_create78{79	MultiXactId mid;			/* new MultiXact's ID */80	MultiXactOffset moff;		/* its starting offset in members file */81	int32		nmembers;		/* number of member XIDs */82	MultiXactMember members[FLEXIBLE_ARRAY_MEMBER];83} xl_multixact_create;84 85#define SizeOfMultiXactCreate (offsetof(xl_multixact_create, members))86 87typedef struct xl_multixact_truncate88{89	Oid			oldestMultiDB;90 91	/* to-be-truncated range of multixact offsets */92	MultiXactId startTruncOff;	/* just for completeness' sake */93	MultiXactId endTruncOff;94 95	/* to-be-truncated range of multixact members */96	MultiXactOffset startTruncMemb;97	MultiXactOffset endTruncMemb;98} xl_multixact_truncate;99 100#define SizeOfMultiXactTruncate (sizeof(xl_multixact_truncate))101 102 103extern MultiXactId MultiXactIdCreate(TransactionId xid1,104									 MultiXactStatus status1, TransactionId xid2,105									 MultiXactStatus status2);106extern MultiXactId MultiXactIdExpand(MultiXactId multi, TransactionId xid,107									 MultiXactStatus status);108extern MultiXactId MultiXactIdCreateFromMembers(int nmembers,109												MultiXactMember *members);110 111extern MultiXactId ReadNextMultiXactId(void);112extern void ReadMultiXactIdRange(MultiXactId *oldest, MultiXactId *next);113extern bool MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly);114extern void MultiXactIdSetOldestMember(void);115extern int	GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,116								  bool from_pgupgrade, bool isLockOnly);117extern bool MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2);118extern bool MultiXactIdPrecedesOrEquals(MultiXactId multi1,119										MultiXactId multi2);120 121extern int	multixactoffsetssyncfiletag(const FileTag *ftag, char *path);122extern int	multixactmemberssyncfiletag(const FileTag *ftag, char *path);123 124extern void AtEOXact_MultiXact(void);125extern void AtPrepare_MultiXact(void);126extern void PostPrepare_MultiXact(TransactionId xid);127 128extern Size MultiXactShmemSize(void);129extern void MultiXactShmemInit(void);130extern void BootStrapMultiXact(void);131extern void StartupMultiXact(void);132extern void TrimMultiXact(void);133extern void SetMultiXactIdLimit(MultiXactId oldest_datminmxid,134								Oid oldest_datoid,135								bool is_startup);136extern void MultiXactGetCheckptMulti(bool is_shutdown,137									 MultiXactId *nextMulti,138									 MultiXactOffset *nextMultiOffset,139									 MultiXactId *oldestMulti,140									 Oid *oldestMultiDB);141extern void CheckPointMultiXact(void);142extern MultiXactId GetOldestMultiXactId(void);143extern void TruncateMultiXact(MultiXactId newOldestMulti,144							  Oid newOldestMultiDB);145extern void MultiXactSetNextMXact(MultiXactId nextMulti,146								  MultiXactOffset nextMultiOffset);147extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,148									  MultiXactOffset minMultiOffset);149extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);150extern int	MultiXactMemberFreezeThreshold(void);151 152extern void multixact_twophase_recover(TransactionId xid, uint16 info,153									   void *recdata, uint32 len);154extern void multixact_twophase_postcommit(TransactionId xid, uint16 info,155										  void *recdata, uint32 len);156extern void multixact_twophase_postabort(TransactionId xid, uint16 info,157										 void *recdata, uint32 len);158 159extern void multixact_redo(XLogReaderState *record);160extern void multixact_desc(StringInfo buf, XLogReaderState *record);161extern const char *multixact_identify(uint8 info);162extern char *mxid_to_string(MultiXactId multi, int nmembers,163							MultiXactMember *members);164 165#endif							/* MULTIXACT_H */166 
codekingpro/portable-devtools · Team Ai