PostgreSQL Source Code
git master
xlogdefs.h
Go to the documentation of this file.
1
/*
2
* xlogdefs.h
3
*
4
* Postgres write-ahead log manager record pointer and
5
* timeline number definitions
6
*
7
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
8
* Portions Copyright (c) 1994, Regents of the University of California
9
*
10
* src/include/access/xlogdefs.h
11
*/
12
#ifndef XLOG_DEFS_H
13
#define XLOG_DEFS_H
14
15
#include <fcntl.h>
/* need open() flags */
16
17
/*
18
* Pointer to a location in the XLOG. These pointers are 64 bits wide,
19
* because we don't want them ever to overflow.
20
*/
21
typedef
uint64
XLogRecPtr
;
22
23
/*
24
* Zero is used indicate an invalid pointer. Bootstrap skips the first possible
25
* WAL segment, initializing the first WAL page at WAL segment size, so no XLOG
26
* record can begin at zero.
27
*/
28
#define InvalidXLogRecPtr 0
29
#define XLogRecPtrIsValid(r) ((r) != InvalidXLogRecPtr)
30
#define XLogRecPtrIsInvalid(r) ((r) == InvalidXLogRecPtr)
31
32
/*
33
* First LSN to use for "fake" LSNs.
34
*
35
* Values smaller than this can be used for special per-AM purposes.
36
*/
37
#define FirstNormalUnloggedLSN ((XLogRecPtr) 1000)
38
39
/*
40
* Handy macro for printing XLogRecPtr in conventional format, e.g.,
41
*
42
* printf("%X/%08X", LSN_FORMAT_ARGS(lsn));
43
*
44
* To avoid breaking translatable messages, we're directly applying the
45
* LSN format instead of using a macro.
46
*/
47
#define LSN_FORMAT_ARGS(lsn) (AssertVariableIsOfTypeMacro((lsn), XLogRecPtr), (uint32) ((lsn) >> 32)), ((uint32) (lsn))
48
49
/*
50
* XLogSegNo - physical log file sequence number.
51
*/
52
typedef
uint64
XLogSegNo
;
53
54
/*
55
* TimeLineID (TLI) - identifies different database histories to prevent
56
* confusion after restoring a prior state of a database installation.
57
* TLI does not change in a normal stop/restart of the database (including
58
* crash-and-recover cases); but we must assign a new TLI after doing
59
* a recovery to a prior state, a/k/a point-in-time recovery. This makes
60
* the new WAL logfile sequence we generate distinguishable from the
61
* sequence that was generated in the previous incarnation.
62
*/
63
typedef
uint32
TimeLineID
;
64
65
/*
66
* Replication origin id - this is located in this file to avoid having to
67
* include origin.h in a bunch of xlog related places.
68
*/
69
typedef
uint16
RepOriginId
;
70
71
/*
72
* This chunk of hackery attempts to determine which file sync methods
73
* are available on the current platform, and to choose an appropriate
74
* default method.
75
*
76
* Note that we define our own O_DSYNC on Windows, but not O_SYNC.
77
*/
78
#if defined(PLATFORM_DEFAULT_WAL_SYNC_METHOD)
79
#define DEFAULT_WAL_SYNC_METHOD PLATFORM_DEFAULT_WAL_SYNC_METHOD
80
#elif defined(O_DSYNC) && (!defined(O_SYNC) || O_DSYNC != O_SYNC)
81
#define DEFAULT_WAL_SYNC_METHOD WAL_SYNC_METHOD_OPEN_DSYNC
82
#else
83
#define DEFAULT_WAL_SYNC_METHOD WAL_SYNC_METHOD_FDATASYNC
84
#endif
85
86
#endif
/* XLOG_DEFS_H */
uint64
uint64_t uint64
Definition:
c.h:544
uint16
uint16_t uint16
Definition:
c.h:542
uint32
uint32_t uint32
Definition:
c.h:543
RepOriginId
uint16 RepOriginId
Definition:
xlogdefs.h:69
XLogRecPtr
uint64 XLogRecPtr
Definition:
xlogdefs.h:21
TimeLineID
uint32 TimeLineID
Definition:
xlogdefs.h:63
XLogSegNo
uint64 XLogSegNo
Definition:
xlogdefs.h:52
src
include
access
xlogdefs.h
Generated on Sat Nov 22 2025 06:13:15 for PostgreSQL Source Code by
1.9.4