2
0

standbydefs.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*-------------------------------------------------------------------------
  2. *
  3. * standbydefs.h
  4. * Frontend exposed definitions for hot standby mode.
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  8. * Portions Copyright (c) 1994, Regents of the University of California
  9. *
  10. * src/include/storage/standbydefs.h
  11. *
  12. *-------------------------------------------------------------------------
  13. */
  14. #ifndef STANDBYDEFS_H
  15. #define STANDBYDEFS_H
  16. #include "access/xlogreader.h"
  17. #include "lib/stringinfo.h"
  18. #include "storage/lockdefs.h"
  19. #include "storage/sinval.h"
  20. /* Recovery handlers for the Standby Rmgr (RM_STANDBY_ID) */
  21. extern void standby_redo(XLogReaderState *record);
  22. extern void standby_desc(StringInfo buf, XLogReaderState *record);
  23. extern const char *standby_identify(uint8 info);
  24. extern void standby_desc_invalidations(StringInfo buf,
  25. int nmsgs, SharedInvalidationMessage *msgs,
  26. Oid dbId, Oid tsId,
  27. bool relcacheInitFileInval);
  28. /*
  29. * XLOG message types
  30. */
  31. #define XLOG_STANDBY_LOCK 0x00
  32. #define XLOG_RUNNING_XACTS 0x10
  33. #define XLOG_INVALIDATIONS 0x20
  34. typedef struct xl_standby_locks
  35. {
  36. int nlocks; /* number of entries in locks array */
  37. xl_standby_lock locks[FLEXIBLE_ARRAY_MEMBER];
  38. } xl_standby_locks;
  39. /*
  40. * When we write running xact data to WAL, we use this structure.
  41. */
  42. typedef struct xl_running_xacts
  43. {
  44. int xcnt; /* # of xact ids in xids[] */
  45. int subxcnt; /* # of subxact ids in xids[] */
  46. bool subxid_overflow; /* snapshot overflowed, subxids missing */
  47. TransactionId nextXid; /* xid from ShmemVariableCache->nextXid */
  48. TransactionId oldestRunningXid; /* *not* oldestXmin */
  49. TransactionId latestCompletedXid; /* so we can set xmax */
  50. TransactionId xids[FLEXIBLE_ARRAY_MEMBER];
  51. } xl_running_xacts;
  52. /*
  53. * Invalidations for standby, currently only when transactions without an
  54. * assigned xid commit.
  55. */
  56. typedef struct xl_invalidations
  57. {
  58. Oid dbId; /* MyDatabaseId */
  59. Oid tsId; /* MyDatabaseTableSpace */
  60. bool relcacheInitFileInval; /* invalidate relcache init files */
  61. int nmsgs; /* number of shared inval msgs */
  62. SharedInvalidationMessage msgs[FLEXIBLE_ARRAY_MEMBER];
  63. } xl_invalidations;
  64. #define MinSizeOfInvalidations offsetof(xl_invalidations, msgs)
  65. #endif /* STANDBYDEFS_H */