Header And Logo

PostgreSQL
| The world's most advanced open source database.

multixact.h

Go to the documentation of this file.
00001 /*
00002  * multixact.h
00003  *
00004  * PostgreSQL multi-transaction-log manager
00005  *
00006  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00007  * Portions Copyright (c) 1994, Regents of the University of California
00008  *
00009  * src/include/access/multixact.h
00010  */
00011 #ifndef MULTIXACT_H
00012 #define MULTIXACT_H
00013 
00014 #include "access/xlog.h"
00015 
00016 
00017 /*
00018  * The first two MultiXactId values are reserved to store the truncation Xid
00019  * and epoch of the first segment, so we start assigning multixact values from
00020  * 2.
00021  */
00022 #define InvalidMultiXactId  ((MultiXactId) 0)
00023 #define FirstMultiXactId    ((MultiXactId) 1)
00024 #define MaxMultiXactId      ((MultiXactId) 0xFFFFFFFF)
00025 
00026 #define MultiXactIdIsValid(multi) ((multi) != InvalidMultiXactId)
00027 
00028 /* Number of SLRU buffers to use for multixact */
00029 #define NUM_MXACTOFFSET_BUFFERS     8
00030 #define NUM_MXACTMEMBER_BUFFERS     16
00031 
00032 /*
00033  * Possible multixact lock modes ("status").  The first four modes are for
00034  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
00035  * next two are used for update and delete modes.
00036  */
00037 typedef enum
00038 {
00039     MultiXactStatusForKeyShare = 0x00,
00040     MultiXactStatusForShare = 0x01,
00041     MultiXactStatusForNoKeyUpdate = 0x02,
00042     MultiXactStatusForUpdate = 0x03,
00043     /* an update that doesn't touch "key" columns */
00044     MultiXactStatusNoKeyUpdate = 0x04,
00045     /* other updates, and delete */
00046     MultiXactStatusUpdate = 0x05
00047 } MultiXactStatus;
00048 
00049 #define MaxMultiXactStatus MultiXactStatusUpdate
00050 
00051 
00052 typedef struct MultiXactMember
00053 {
00054     TransactionId   xid;
00055     MultiXactStatus status;
00056 } MultiXactMember;
00057 
00058 
00059 /* ----------------
00060  *      multixact-related XLOG entries
00061  * ----------------
00062  */
00063 
00064 #define XLOG_MULTIXACT_ZERO_OFF_PAGE    0x00
00065 #define XLOG_MULTIXACT_ZERO_MEM_PAGE    0x10
00066 #define XLOG_MULTIXACT_CREATE_ID        0x20
00067 
00068 typedef struct xl_multixact_create
00069 {
00070     MultiXactId mid;            /* new MultiXact's ID */
00071     MultiXactOffset moff;       /* its starting offset in members file */
00072     int32       nmembers;       /* number of member XIDs */
00073     MultiXactMember members[FLEXIBLE_ARRAY_MEMBER];
00074 } xl_multixact_create;
00075 
00076 #define SizeOfMultiXactCreate (offsetof(xl_multixact_create, members))
00077 
00078 
00079 extern MultiXactId MultiXactIdCreate(TransactionId xid1,
00080                   MultiXactStatus status1, TransactionId xid2,
00081                   MultiXactStatus status2);
00082 extern MultiXactId MultiXactIdExpand(MultiXactId multi, TransactionId xid,
00083                   MultiXactStatus status);
00084 extern MultiXactId ReadNextMultiXactId(void);
00085 extern bool MultiXactIdIsRunning(MultiXactId multi);
00086 extern void MultiXactIdSetOldestMember(void);
00087 extern int  GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **xids,
00088                       bool allow_old);
00089 extern bool MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2);
00090 
00091 extern void AtEOXact_MultiXact(void);
00092 extern void AtPrepare_MultiXact(void);
00093 extern void PostPrepare_MultiXact(TransactionId xid);
00094 
00095 extern Size MultiXactShmemSize(void);
00096 extern void MultiXactShmemInit(void);
00097 extern void BootStrapMultiXact(void);
00098 extern void StartupMultiXact(void);
00099 extern void ShutdownMultiXact(void);
00100 extern void SetMultiXactIdLimit(MultiXactId oldest_datminmxid,
00101                     Oid oldest_datoid);
00102 extern void MultiXactGetCheckptMulti(bool is_shutdown,
00103                          MultiXactId *nextMulti,
00104                          MultiXactOffset *nextMultiOffset,
00105                          MultiXactId *oldestMulti,
00106                          Oid *oldestMultiDB);
00107 extern void CheckPointMultiXact(void);
00108 extern MultiXactId GetOldestMultiXactId(void);
00109 extern void TruncateMultiXact(MultiXactId cutoff_multi);
00110 extern void MultiXactSetNextMXact(MultiXactId nextMulti,
00111                       MultiXactOffset nextMultiOffset);
00112 extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
00113                           MultiXactOffset minMultiOffset);
00114 extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
00115 
00116 extern void multixact_twophase_recover(TransactionId xid, uint16 info,
00117                            void *recdata, uint32 len);
00118 extern void multixact_twophase_postcommit(TransactionId xid, uint16 info,
00119                               void *recdata, uint32 len);
00120 extern void multixact_twophase_postabort(TransactionId xid, uint16 info,
00121                              void *recdata, uint32 len);
00122 
00123 extern void multixact_redo(XLogRecPtr lsn, XLogRecord *record);
00124 extern void multixact_desc(StringInfo buf, uint8 xl_info, char *rec);
00125 extern char *mxid_to_string(MultiXactId multi, int nmembers,
00126                MultiXactMember *members);
00127 
00128 #endif   /* MULTIXACT_H */