codekingpro/portable-devtools
114k
1/*2 * xlogdefs.h3 *4 * Postgres write-ahead log manager record pointer and5 * timeline number definitions6 *7 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group8 * Portions Copyright (c) 1994, Regents of the University of California9 *10 * src/include/access/xlogdefs.h11 */12#ifndef XLOG_DEFS_H13#define XLOG_DEFS_H14 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 */21typedef uint64 XLogRecPtr;22 23/*24 * Zero is used indicate an invalid pointer. Bootstrap skips the first possible25 * WAL segment, initializing the first WAL page at WAL segment size, so no XLOG26 * record can begin at zero.27 */28#define InvalidXLogRecPtr 029#define XLogRecPtrIsInvalid(r) ((r) == InvalidXLogRecPtr)30 31/*32 * First LSN to use for "fake" LSNs.33 *34 * Values smaller than this can be used for special per-AM purposes.35 */36#define FirstNormalUnloggedLSN ((XLogRecPtr) 1000)37 38/*39 * Handy macro for printing XLogRecPtr in conventional format, e.g.,40 *41 * printf("%X/%X", LSN_FORMAT_ARGS(lsn));42 */43#define LSN_FORMAT_ARGS(lsn) (AssertVariableIsOfTypeMacro((lsn), XLogRecPtr), (uint32) ((lsn) >> 32)), ((uint32) (lsn))44 45/*46 * XLogSegNo - physical log file sequence number.47 */48typedef uint64 XLogSegNo;49 50/*51 * TimeLineID (TLI) - identifies different database histories to prevent52 * confusion after restoring a prior state of a database installation.53 * TLI does not change in a normal stop/restart of the database (including54 * crash-and-recover cases); but we must assign a new TLI after doing55 * a recovery to a prior state, a/k/a point-in-time recovery. This makes56 * the new WAL logfile sequence we generate distinguishable from the57 * sequence that was generated in the previous incarnation.58 */59typedef uint32 TimeLineID;60 61/*62 * Replication origin id - this is located in this file to avoid having to63 * include origin.h in a bunch of xlog related places.64 */65typedef uint16 RepOriginId;66 67/*68 * This chunk of hackery attempts to determine which file sync methods69 * are available on the current platform, and to choose an appropriate70 * default method.71 *72 * Note that we define our own O_DSYNC on Windows, but not O_SYNC.73 */74#if defined(PLATFORM_DEFAULT_SYNC_METHOD)75#define DEFAULT_SYNC_METHOD PLATFORM_DEFAULT_SYNC_METHOD76#elif defined(O_DSYNC) && (!defined(O_SYNC) || O_DSYNC != O_SYNC)77#define DEFAULT_SYNC_METHOD SYNC_METHOD_OPEN_DSYNC78#else79#define DEFAULT_SYNC_METHOD SYNC_METHOD_FDATASYNC80#endif81 82#endif /* XLOG_DEFS_H */83 