| 1 | /* |
| 2 | * xloginsert.h |
| 3 | * |
| 4 | * Functions for generating WAL records |
| 5 | * |
| 6 | * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group |
| 7 | * Portions Copyright (c) 1994, Regents of the University of California |
| 8 | * |
| 9 | * src/include/access/xloginsert.h |
| 10 | */ |
| 11 | #ifndef XLOGINSERT_H |
| 12 | #define XLOGINSERT_H |
| 13 | |
| 14 | #include "access/rmgr.h" |
| 15 | #include "access/xlogdefs.h" |
| 16 | #include "storage/block.h" |
| 17 | #include "storage/buf.h" |
| 18 | #include "storage/relfilenode.h" |
| 19 | #include "utils/relcache.h" |
| 20 | |
| 21 | /* |
| 22 | * The minimum size of the WAL construction working area. If you need to |
| 23 | * register more than XLR_NORMAL_MAX_BLOCK_ID block references or have more |
| 24 | * than XLR_NORMAL_RDATAS data chunks in a single WAL record, you must call |
| 25 | * XLogEnsureRecordSpace() first to allocate more working memory. |
| 26 | */ |
| 27 | #define XLR_NORMAL_MAX_BLOCK_ID 4 |
| 28 | #define XLR_NORMAL_RDATAS 20 |
| 29 | |
| 30 | /* flags for XLogRegisterBuffer */ |
| 31 | #define REGBUF_FORCE_IMAGE 0x01 /* force a full-page image */ |
| 32 | #define REGBUF_NO_IMAGE 0x02 /* don't take a full-page image */ |
| 33 | #define REGBUF_WILL_INIT (0x04 | 0x02) /* page will be re-initialized at |
| 34 | * replay (implies NO_IMAGE) */ |
| 35 | #define REGBUF_STANDARD 0x08 /* page follows "standard" page layout, |
| 36 | * (data between pd_lower and pd_upper |
| 37 | * will be skipped) */ |
| 38 | #define REGBUF_KEEP_DATA 0x10 /* include data even if a full-page image |
| 39 | * is taken */ |
| 40 | |
| 41 | /* prototypes for public functions in xloginsert.c: */ |
| 42 | extern void XLogBeginInsert(void); |
| 43 | extern void XLogSetRecordFlags(uint8 flags); |
| 44 | extern XLogRecPtr XLogInsert(RmgrId rmid, uint8 info); |
| 45 | extern void XLogEnsureRecordSpace(int nbuffers, int ndatas); |
| 46 | extern void XLogRegisterData(char *data, int len); |
| 47 | extern void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags); |
| 48 | extern void XLogRegisterBlock(uint8 block_id, RelFileNode *rnode, |
| 49 | ForkNumber forknum, BlockNumber blknum, char *page, |
| 50 | uint8 flags); |
| 51 | extern void XLogRegisterBufData(uint8 block_id, char *data, int len); |
| 52 | extern void XLogResetInsertion(void); |
| 53 | extern bool XLogCheckBufferNeedsBackup(Buffer buffer); |
| 54 | |
| 55 | extern XLogRecPtr log_newpage(RelFileNode *rnode, ForkNumber forkNum, |
| 56 | BlockNumber blk, char *page, bool page_std); |
| 57 | extern XLogRecPtr log_newpage_buffer(Buffer buffer, bool page_std); |
| 58 | extern void log_newpage_range(Relation rel, ForkNumber forkNum, |
| 59 | BlockNumber startblk, BlockNumber endblk, bool page_std); |
| 60 | extern XLogRecPtr XLogSaveBufferForHint(Buffer buffer, bool buffer_std); |
| 61 | |
| 62 | extern void InitXLogInsert(void); |
| 63 | |
| 64 | #endif /* XLOGINSERT_H */ |
| 65 | |