LCOV - differential code coverage report
Current view: top level - src/include/access - multixact.h (source / functions) Coverage Total Hit CBC
Current: f76c13edadc2b319036e0d238703ed56bb23f934 vs 9e17d25e79d4756be08b4a5521b4b58450217137 Lines: 100.0 % 6 6 6
Current Date: 2026-09-20 14:13:17 +0900 Functions: 100.0 % 2 2 2
Baseline: lcov-20260920-baseline Line coverage date bins:
Baseline Date: 2026-09-20 14:13:13 +0900 [..1] days: 100.0 % 6 6 6
Legend: Lines:     hit not hit Function coverage date bins:
[..1] days: 100.0 % 2 2 2

 Age         Owner                  TLA  Line data    Source code
                                  1                 : /*
                                  2                 :  * multixact.h
                                  3                 :  *
                                  4                 :  * PostgreSQL multi-transaction-log manager
                                  5                 :  *
                                  6                 :  * Portions Copyright (c) 1996-2026, 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/transam.h"
                                 15                 : #include "access/xlogreader.h"
                                 16                 : #include "lib/stringinfo.h"
                                 17                 : #include "storage/sync.h"
                                 18                 : 
                                 19                 : 
                                 20                 : /*
                                 21                 :  * The first two MultiXactId values are reserved to store the truncation Xid
                                 22                 :  * and epoch of the first segment, so we start assigning multixact values from
                                 23                 :  * 2.
                                 24                 :  */
                                 25                 : #define InvalidMultiXactId  ((MultiXactId) 0)
                                 26                 : #define FirstMultiXactId    ((MultiXactId) 1)
                                 27                 : #define MaxMultiXactId      ((MultiXactId) 0xFFFFFFFF)
                                 28                 : 
                                 29                 : #define MultiXactIdIsValid(multi) ((multi) != InvalidMultiXactId)
                                 30                 : 
                                 31                 : /*
                                 32                 :  * Decide which of two MultiXactIds is earlier.
                                 33                 :  *
                                 34                 :  * XXX do we need to do something special for InvalidMultiXactId?
                                 35                 :  * (Doesn't look like it.)
                                 36                 :  */
                                 37                 : static inline bool
    1 heikki.linnakangas@i       38 CBC     1110700 : MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2)
                                 39                 : {
                                 40         1110700 :     int32       diff = (int32) (multi1 - multi2);
                                 41                 : 
                                 42         1110700 :     return (diff < 0);
                                 43                 : }
                                 44                 : 
                                 45                 : /*
                                 46                 :  * MultiXactIdPrecedesOrEquals -- is multi1 logically <= multi2?
                                 47                 :  *
                                 48                 :  * XXX do we need to do something special for InvalidMultiXactId?
                                 49                 :  * (Doesn't look like it.)
                                 50                 :  */
                                 51                 : static inline bool
                                 52            7044 : MultiXactIdPrecedesOrEquals(MultiXactId multi1, MultiXactId multi2)
                                 53                 : {
                                 54            7044 :     int32       diff = (int32) (multi1 - multi2);
                                 55                 : 
                                 56            7044 :     return (diff <= 0);
                                 57                 : }
                                 58                 : 
                                 59                 : /*
                                 60                 :  * Possible multixact lock modes ("status").  The first four modes are for
                                 61                 :  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
                                 62                 :  * next two are used for update and delete modes.
                                 63                 :  */
                                 64                 : typedef enum
                                 65                 : {
                                 66                 :     MultiXactStatusForKeyShare = 0x00,
                                 67                 :     MultiXactStatusForShare = 0x01,
                                 68                 :     MultiXactStatusForNoKeyUpdate = 0x02,
                                 69                 :     MultiXactStatusForUpdate = 0x03,
                                 70                 :     /* an update that doesn't touch "key" columns */
                                 71                 :     MultiXactStatusNoKeyUpdate = 0x04,
                                 72                 :     /* other updates, and delete */
                                 73                 :     MultiXactStatusUpdate = 0x05,
                                 74                 : } MultiXactStatus;
                                 75                 : 
                                 76                 : #define MaxMultiXactStatus MultiXactStatusUpdate
                                 77                 : 
                                 78                 : /* does a status value correspond to a tuple update? */
                                 79                 : #define ISUPDATE_from_mxstatus(status) \
                                 80                 :             ((status) > MultiXactStatusForUpdate)
                                 81                 : 
                                 82                 : 
                                 83                 : typedef struct MultiXactMember
                                 84                 : {
                                 85                 :     TransactionId xid;
                                 86                 :     MultiXactStatus status;
                                 87                 : } MultiXactMember;
                                 88                 : 
                                 89                 : 
                                 90                 : /* ----------------
                                 91                 :  *      multixact-related XLOG entries
                                 92                 :  * ----------------
                                 93                 :  */
                                 94                 : 
                                 95                 : #define XLOG_MULTIXACT_ZERO_OFF_PAGE    0x00
                                 96                 : #define XLOG_MULTIXACT_ZERO_MEM_PAGE    0x10
                                 97                 : #define XLOG_MULTIXACT_CREATE_ID        0x20
                                 98                 : #define XLOG_MULTIXACT_TRUNCATE_ID      0x30
                                 99                 : 
                                100                 : typedef struct xl_multixact_create
                                101                 : {
                                102                 :     MultiXactId mid;            /* new MultiXact's ID */
                                103                 :     MultiXactOffset moff;       /* its starting offset in members file */
                                104                 :     int32       nmembers;       /* number of member XIDs */
                                105                 :     MultiXactMember members[FLEXIBLE_ARRAY_MEMBER];
                                106                 : } xl_multixact_create;
                                107                 : 
                                108                 : #define SizeOfMultiXactCreate (offsetof(xl_multixact_create, members))
                                109                 : 
                                110                 : typedef struct xl_multixact_truncate
                                111                 : {
                                112                 :     Oid         oldestMultiDB;
                                113                 : 
                                114                 :     /* truncate multixact offsets older than this */
                                115                 :     MultiXactId oldestMulti;
                                116                 : 
                                117                 :     /* truncate multixact members older than this */
                                118                 :     MultiXactOffset oldestOffset;
                                119                 : } xl_multixact_truncate;
                                120                 : 
                                121                 : #define SizeOfMultiXactTruncate (sizeof(xl_multixact_truncate))
                                122                 : 
                                123                 : 
                                124                 : extern MultiXactId MultiXactIdCreate(TransactionId xid1,
                                125                 :                                      MultiXactStatus status1, TransactionId xid2,
                                126                 :                                      MultiXactStatus status2);
                                127                 : extern MultiXactId MultiXactIdExpand(MultiXactId multi, TransactionId xid,
                                128                 :                                      MultiXactStatus status);
                                129                 : extern MultiXactId MultiXactIdCreateFromMembers(int nmembers,
                                130                 :                                                 MultiXactMember *members);
                                131                 : 
                                132                 : extern MultiXactId ReadNextMultiXactId(void);
                                133                 : extern void ReadMultiXactIdRange(MultiXactId *oldest, MultiXactId *next);
                                134                 : extern bool MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly);
                                135                 : extern void MultiXactIdSetOldestMember(void);
                                136                 : extern int  GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
                                137                 :                                   bool from_pgupgrade, bool isLockOnly);
                                138                 : extern void GetMultiXactInfo(uint32 *multixacts, MultiXactOffset *nextOffset,
                                139                 :                              MultiXactId *oldestMultiXactId,
                                140                 :                              MultiXactOffset *oldestOffset);
                                141                 : 
                                142                 : extern int  multixactoffsetssyncfiletag(const FileTag *ftag, char *path);
                                143                 : extern int  multixactmemberssyncfiletag(const FileTag *ftag, char *path);
                                144                 : 
                                145                 : extern void AtEOXact_MultiXact(void);
                                146                 : extern void AtPrepare_MultiXact(void);
                                147                 : extern void PostPrepare_MultiXact(FullTransactionId fxid);
                                148                 : 
                                149                 : extern void BootStrapMultiXact(void);
                                150                 : extern void StartupMultiXact(void);
                                151                 : extern void TrimMultiXact(void);
                                152                 : extern void SetMultiXactIdLimit(MultiXactId oldest_datminmxid,
                                153                 :                                 Oid oldest_datoid);
                                154                 : extern void MultiXactGetCheckptMulti(bool is_shutdown,
                                155                 :                                      MultiXactId *nextMulti,
                                156                 :                                      MultiXactOffset *nextMultiOffset,
                                157                 :                                      MultiXactId *oldestMulti,
                                158                 :                                      Oid *oldestMultiDB);
                                159                 : extern void CheckPointMultiXact(void);
                                160                 : extern MultiXactId GetOldestMultiXactId(void);
                                161                 : extern void TruncateMultiXact(MultiXactId newOldestMulti,
                                162                 :                               Oid newOldestMultiDB);
                                163                 : extern void MultiXactSetNextMXact(MultiXactId nextMulti,
                                164                 :                                   MultiXactOffset nextMultiOffset);
                                165                 : extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
                                166                 :                                       MultiXactOffset minMultiOffset);
                                167                 : extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
                                168                 : extern int  MultiXactMemberFreezeThreshold(void);
                                169                 : 
                                170                 : extern void multixact_twophase_recover(FullTransactionId fxid, uint16 info,
                                171                 :                                        void *recdata, uint32 len);
                                172                 : extern void multixact_twophase_postcommit(FullTransactionId fxid, uint16 info,
                                173                 :                                           void *recdata, uint32 len);
                                174                 : extern void multixact_twophase_postabort(FullTransactionId fxid, uint16 info,
                                175                 :                                          void *recdata, uint32 len);
                                176                 : 
                                177                 : extern void multixact_redo(XLogReaderState *record);
                                178                 : extern void multixact_desc(StringInfo buf, XLogReaderState *record);
                                179                 : extern const char *multixact_identify(uint8 info);
                                180                 : extern char *mxid_to_string(MultiXactId multi, int nmembers,
                                181                 :                             MultiXactMember *members);
                                182                 : extern char *mxstatus_to_string(MultiXactStatus status);
                                183                 : 
                                184                 : #endif                          /* MULTIXACT_H */
        

Generated by: LCOV version 2.0-1