]> granicus.if.org Git - postgresql/blob - src/include/access/xlogdefs.h
XLOG (and related) changes:
[postgresql] / src / include / access / xlogdefs.h
1 /*
2  * xlogdefs.h
3  *
4  * Postgres transaction log manager record pointer and
5  * system startup number definitions
6  *
7  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $Id: xlogdefs.h,v 1.2 2001/03/13 01:17:06 tgl Exp $
11  */
12 #ifndef XLOG_DEFS_H
13 #define XLOG_DEFS_H
14
15 /*
16  * Pointer to a location in the XLOG.  These pointers are 64 bits wide,
17  * because we don't want them ever to overflow.
18  *
19  * NOTE: xrecoff == 0 is used to indicate an invalid pointer.  This is OK
20  * because we use page headers in the XLOG, so no XLOG record can start
21  * right at the beginning of a file.
22  *
23  * NOTE: the "log file number" is somewhat misnamed, since the actual files
24  * making up the XLOG are much smaller than 4Gb.  Each actual file is an
25  * XLogSegSize-byte "segment" of a logical log file having the indicated
26  * xlogid.  The log file number and segment number together identify a
27  * physical XLOG file.  Segment number and offset within the physical file
28  * are computed from xrecoff div and mod XLogSegSize.
29  */
30 typedef struct XLogRecPtr
31 {
32         uint32          xlogid;                 /* log file #, 0 based */
33         uint32          xrecoff;                /* byte offset of location in log file */
34 } XLogRecPtr;
35
36 /*
37  * Macros for comparing XLogRecPtrs
38  *
39  * Beware of passing expressions with side-effects to these macros,
40  * since the arguments may be evaluated multiple times.
41  */
42 #define XLByteLT(a, b)          \
43                         ((a).xlogid < (b).xlogid || \
44                          ((a).xlogid == (b).xlogid && (a).xrecoff < (b).xrecoff))
45
46 #define XLByteLE(a, b)          \
47                         ((a).xlogid < (b).xlogid || \
48                          ((a).xlogid == (b).xlogid && (a).xrecoff <= (b).xrecoff))
49
50 #define XLByteEQ(a, b)          \
51                         ((a).xlogid == (b).xlogid && (a).xrecoff == (b).xrecoff)
52
53 /*
54  * StartUpID (SUI) - system startups counter. It's to allow removing
55  * pg_log after shutdown, in future.
56  */
57 typedef uint32          StartUpID;
58
59 #endif   /* XLOG_DEFS_H */