|
| 1 | +/*------------------------------------------------------------------------- |
| 2 | + * |
| 3 | + * walsender_private.h |
| 4 | + * Private definitions from replication/walsender.c. |
| 5 | + * |
| 6 | + * Portions Copyright (c) 2010-2011, PostgreSQL Global Development Group |
| 7 | + * |
| 8 | + * src/include/replication/walsender_private.h |
| 9 | + * |
| 10 | + *------------------------------------------------------------------------- |
| 11 | + */ |
| 12 | +#ifndef_WALSENDER_PRIVATE_H |
| 13 | +#define_WALSENDER_PRIVATE_H |
| 14 | + |
| 15 | +#include"access/xlog.h" |
| 16 | +#include"nodes/nodes.h" |
| 17 | +#include"storage/latch.h" |
| 18 | +#include"storage/shmem.h" |
| 19 | +#include"storage/spin.h" |
| 20 | + |
| 21 | +typedefenumWalSndState |
| 22 | +{ |
| 23 | +WALSNDSTATE_STARTUP=0, |
| 24 | +WALSNDSTATE_BACKUP, |
| 25 | +WALSNDSTATE_CATCHUP, |
| 26 | +WALSNDSTATE_STREAMING |
| 27 | +}WalSndState; |
| 28 | + |
| 29 | +/* |
| 30 | + * Each walsender has a WalSnd struct in shared memory. |
| 31 | + */ |
| 32 | +typedefstructWalSnd |
| 33 | +{ |
| 34 | +pid_tpid;/* this walsender's process id, or 0 */ |
| 35 | +WalSndStatestate;/* this walsender's state */ |
| 36 | +XLogRecPtrsentPtr;/* WAL has been sent up to this point */ |
| 37 | +boolneedreload;/* does currently-open file need to be reloaded? */ |
| 38 | + |
| 39 | +/* |
| 40 | + * The xlog locations that have been written, flushed, and applied by |
| 41 | + * standby-side. These may be invalid if the standby-side has not offered |
| 42 | + * values yet. |
| 43 | + */ |
| 44 | +XLogRecPtrwrite; |
| 45 | +XLogRecPtrflush; |
| 46 | +XLogRecPtrapply; |
| 47 | + |
| 48 | +/* Protects shared variables shown above. */ |
| 49 | +slock_tmutex; |
| 50 | + |
| 51 | +/* |
| 52 | + * Latch used by backends to wake up this walsender when it has work to |
| 53 | + * do. |
| 54 | + */ |
| 55 | +Latchlatch; |
| 56 | + |
| 57 | +/* |
| 58 | + * The priority order of the standby managed by this WALSender, as listed |
| 59 | + * in synchronous_standby_names, or 0 if not-listed. Protected by |
| 60 | + * SyncRepLock. |
| 61 | + */ |
| 62 | +intsync_standby_priority; |
| 63 | +}WalSnd; |
| 64 | + |
| 65 | +externWalSnd*MyWalSnd; |
| 66 | + |
| 67 | +/* There is one WalSndCtl struct for the whole database cluster */ |
| 68 | +typedefstruct |
| 69 | +{ |
| 70 | +/* |
| 71 | + * Synchronous replication queue. Protected by SyncRepLock. |
| 72 | + */ |
| 73 | +SHM_QUEUESyncRepQueue; |
| 74 | + |
| 75 | +/* |
| 76 | + * Current location of the head of the queue. All waiters should have a |
| 77 | + * waitLSN that follows this value. Protected by SyncRepLock. |
| 78 | + */ |
| 79 | +XLogRecPtrlsn; |
| 80 | + |
| 81 | +/* |
| 82 | + * Are any sync standbys defined? Waiting backends can't reload the |
| 83 | + * config file safely, so WAL writer updates this value as needed. |
| 84 | + * Protected by SyncRepLock. |
| 85 | + */ |
| 86 | +boolsync_standbys_defined; |
| 87 | + |
| 88 | +WalSndwalsnds[1];/* VARIABLE LENGTH ARRAY */ |
| 89 | +}WalSndCtlData; |
| 90 | + |
| 91 | +externWalSndCtlData*WalSndCtl; |
| 92 | + |
| 93 | + |
| 94 | +externvoidWalSndSetState(WalSndStatestate); |
| 95 | +externvoidXLogRead(char*buf,XLogRecPtrstartptr,Sizecount); |
| 96 | + |
| 97 | +/* |
| 98 | + * Internal functions for parsing the replication grammar, in repl_gram.y and |
| 99 | + * repl_scanner.l |
| 100 | + */ |
| 101 | +externintreplication_yyparse(void); |
| 102 | +externintreplication_yylex(void); |
| 103 | +externvoidreplication_yyerror(constchar*str); |
| 104 | +externvoidreplication_scanner_init(constchar*query_string); |
| 105 | +externvoidreplication_scanner_finish(void); |
| 106 | + |
| 107 | +externNode*replication_parse_result; |
| 108 | + |
| 109 | +#endif/* _WALSENDER_PRIVATE_H */ |