clog.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * clog.h
  3. *
  4. * PostgreSQL transaction-commit-log manager
  5. *
  6. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  7. * Portions Copyright (c) 1994, Regents of the University of California
  8. *
  9. * src/include/access/clog.h
  10. */
  11. #ifndef CLOG_H
  12. #define CLOG_H
  13. #include "access/xlogreader.h"
  14. #include "storage/sync.h"
  15. #include "lib/stringinfo.h"
  16. /*
  17. * Possible transaction statuses --- note that all-zeroes is the initial
  18. * state.
  19. *
  20. * A "subcommitted" transaction is a committed subtransaction whose parent
  21. * hasn't committed or aborted yet.
  22. */
  23. typedef int XidStatus;
  24. #define TRANSACTION_STATUS_IN_PROGRESS 0x00
  25. #define TRANSACTION_STATUS_COMMITTED 0x01
  26. #define TRANSACTION_STATUS_ABORTED 0x02
  27. #define TRANSACTION_STATUS_SUB_COMMITTED 0x03
  28. typedef struct xl_clog_truncate
  29. {
  30. int pageno;
  31. TransactionId oldestXact;
  32. Oid oldestXactDb;
  33. } xl_clog_truncate;
  34. extern void TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
  35. TransactionId *subxids, XidStatus status, XLogRecPtr lsn);
  36. extern XidStatus TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn);
  37. extern Size CLOGShmemBuffers(void);
  38. extern Size CLOGShmemSize(void);
  39. extern void CLOGShmemInit(void);
  40. extern void BootStrapCLOG(void);
  41. extern void StartupCLOG(void);
  42. extern void TrimCLOG(void);
  43. extern void CheckPointCLOG(void);
  44. extern void ExtendCLOG(TransactionId newestXact);
  45. extern void TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid);
  46. extern int clogsyncfiletag(const FileTag *ftag, char *path);
  47. /* XLOG stuff */
  48. #define CLOG_ZEROPAGE 0x00
  49. #define CLOG_TRUNCATE 0x10
  50. extern void clog_redo(XLogReaderState *record);
  51. extern void clog_desc(StringInfo buf, XLogReaderState *record);
  52. extern const char *clog_identify(uint8 info);
  53. #endif /* CLOG_H */