gooderp18绿色标准版
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

110 líneas
3.3KB

  1. /*
  2. * xlogdefs.h
  3. *
  4. * Postgres write-ahead log manager record pointer and
  5. * timeline number definitions
  6. *
  7. * Portions Copyright (c) 1996-2019, 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. #include <fcntl.h> /* need open() flags */
  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. typedef uint64 XLogRecPtr;
  20. /*
  21. * Zero is used indicate an invalid pointer. Bootstrap skips the first possible
  22. * WAL segment, initializing the first WAL page at WAL segment size, so no XLOG
  23. * record can begin at zero.
  24. */
  25. #define InvalidXLogRecPtr 0
  26. #define XLogRecPtrIsInvalid(r) ((r) == InvalidXLogRecPtr)
  27. /*
  28. * First LSN to use for "fake" LSNs.
  29. *
  30. * Values smaller than this can be used for special per-AM purposes.
  31. */
  32. #define FirstNormalUnloggedLSN ((XLogRecPtr) 1000)
  33. /*
  34. * XLogSegNo - physical log file sequence number.
  35. */
  36. typedef uint64 XLogSegNo;
  37. /*
  38. * TimeLineID (TLI) - identifies different database histories to prevent
  39. * confusion after restoring a prior state of a database installation.
  40. * TLI does not change in a normal stop/restart of the database (including
  41. * crash-and-recover cases); but we must assign a new TLI after doing
  42. * a recovery to a prior state, a/k/a point-in-time recovery. This makes
  43. * the new WAL logfile sequence we generate distinguishable from the
  44. * sequence that was generated in the previous incarnation.
  45. */
  46. typedef uint32 TimeLineID;
  47. /*
  48. * Replication origin id - this is located in this file to avoid having to
  49. * include origin.h in a bunch of xlog related places.
  50. */
  51. typedef uint16 RepOriginId;
  52. /*
  53. * Because O_DIRECT bypasses the kernel buffers, and because we never
  54. * read those buffers except during crash recovery or if wal_level != minimal,
  55. * it is a win to use it in all cases where we sync on each write(). We could
  56. * allow O_DIRECT with fsync(), but it is unclear if fsync() could process
  57. * writes not buffered in the kernel. Also, O_DIRECT is never enough to force
  58. * data to the drives, it merely tries to bypass the kernel cache, so we still
  59. * need O_SYNC/O_DSYNC.
  60. */
  61. #ifdef O_DIRECT
  62. #define PG_O_DIRECT O_DIRECT
  63. #else
  64. #define PG_O_DIRECT 0
  65. #endif
  66. /*
  67. * This chunk of hackery attempts to determine which file sync methods
  68. * are available on the current platform, and to choose an appropriate
  69. * default method. We assume that fsync() is always available, and that
  70. * configure determined whether fdatasync() is.
  71. */
  72. #if defined(O_SYNC)
  73. #define OPEN_SYNC_FLAG O_SYNC
  74. #elif defined(O_FSYNC)
  75. #define OPEN_SYNC_FLAG O_FSYNC
  76. #endif
  77. #if defined(O_DSYNC)
  78. #if defined(OPEN_SYNC_FLAG)
  79. /* O_DSYNC is distinct? */
  80. #if O_DSYNC != OPEN_SYNC_FLAG
  81. #define OPEN_DATASYNC_FLAG O_DSYNC
  82. #endif
  83. #else /* !defined(OPEN_SYNC_FLAG) */
  84. /* Win32 only has O_DSYNC */
  85. #define OPEN_DATASYNC_FLAG O_DSYNC
  86. #endif
  87. #endif
  88. #if defined(PLATFORM_DEFAULT_SYNC_METHOD)
  89. #define DEFAULT_SYNC_METHOD PLATFORM_DEFAULT_SYNC_METHOD
  90. #elif defined(OPEN_DATASYNC_FLAG)
  91. #define DEFAULT_SYNC_METHOD SYNC_METHOD_OPEN_DSYNC
  92. #elif defined(HAVE_FDATASYNC)
  93. #define DEFAULT_SYNC_METHOD SYNC_METHOD_FDATASYNC
  94. #else
  95. #define DEFAULT_SYNC_METHOD SYNC_METHOD_FSYNC
  96. #endif
  97. #endif /* XLOG_DEFS_H */
上海开阖软件有限公司 沪ICP备12045867号-1