1
/*-------------------------------------------------------------------------
4
* Exports from replication/walreceiverfuncs.c.
6
* Portions Copyright (c) 2010-2011, PostgreSQL Global Development Group
8
* src/include/replication/walreceiver.h
10
*-------------------------------------------------------------------------
12
#ifndef _WALRECEIVER_H
13
#define _WALRECEIVER_H
15
#include "access/xlogdefs.h"
16
#include "storage/spin.h"
19
extern bool am_walreceiver;
20
extern int wal_receiver_status_interval;
21
extern bool hot_standby_feedback;
24
* MAXCONNINFO: maximum size of a connection string.
26
* XXX: Should this move to pg_config_manual.h?
28
#define MAXCONNINFO 1024
31
* Values for WalRcv->walRcvState.
35
WALRCV_STOPPED, /* stopped and mustn't start up again */
36
WALRCV_STARTING, /* launched, but the process hasn't
38
WALRCV_RUNNING, /* walreceiver is running */
39
WALRCV_STOPPING /* requested to stop, but still running */
42
/* Shared memory area for management of walreceiver process */
46
* PID of currently active walreceiver process, its current state and
47
* start time (actually, the time at which it was requested to be
51
WalRcvState walRcvState;
55
* receiveStart is the first byte position that will be received. When
56
* startup process starts the walreceiver, it sets receiveStart to the
57
* point where it wants the streaming to begin.
59
XLogRecPtr receiveStart;
62
* receivedUpto-1 is the last byte position that has already been
63
* received. At the first startup of walreceiver, receivedUpto is set to
64
* receiveStart. After that, walreceiver updates this whenever it flushes
65
* the received WAL to disk.
67
XLogRecPtr receivedUpto;
70
* latestChunkStart is the starting byte position of the current "batch"
71
* of received WAL. It's actually the same as the previous value of
72
* receivedUpto before the last flush to disk. Startup process can use
73
* this to detect whether it's keeping up or not.
75
XLogRecPtr latestChunkStart;
78
* connection string; is used for walreceiver to connect with the primary.
80
char conninfo[MAXCONNINFO];
82
slock_t mutex; /* locks shared variables shown above */
85
extern WalRcvData *WalRcv;
87
/* libpqwalreceiver hooks */
88
typedef bool (*walrcv_connect_type) (char *conninfo, XLogRecPtr startpoint);
89
extern PGDLLIMPORT walrcv_connect_type walrcv_connect;
91
typedef bool (*walrcv_receive_type) (int timeout, unsigned char *type,
92
char **buffer, int *len);
93
extern PGDLLIMPORT walrcv_receive_type walrcv_receive;
95
typedef void (*walrcv_send_type) (const char *buffer, int nbytes);
96
extern PGDLLIMPORT walrcv_send_type walrcv_send;
98
typedef void (*walrcv_disconnect_type) (void);
99
extern PGDLLIMPORT walrcv_disconnect_type walrcv_disconnect;
101
/* prototypes for functions in walreceiver.c */
102
extern void WalReceiverMain(void);
104
/* prototypes for functions in walreceiverfuncs.c */
105
extern Size WalRcvShmemSize(void);
106
extern void WalRcvShmemInit(void);
107
extern void ShutdownWalRcv(void);
108
extern bool WalRcvInProgress(void);
109
extern void RequestXLogStreaming(XLogRecPtr recptr, const char *conninfo);
110
extern XLogRecPtr GetWalRcvWriteRecPtr(XLogRecPtr *latestChunkStart);
112
#endif /* _WALRECEIVER_H */