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