OSDN Git Service

Introduce Streaming Replication.
[pg-rex/syncrep.git] / src / include / replication / walreceiver.h
1 /*-------------------------------------------------------------------------
2  *
3  * walreceiver.h
4  *        Exports from replication/walreceiverfuncs.c.
5  *
6  * Portions Copyright (c) 2010-2010, PostgreSQL Global Development Group
7  *
8  * $PostgreSQL: pgsql/src/include/replication/walreceiver.h,v 1.1 2010/01/15 09:19:09 heikki Exp $
9  *
10  *-------------------------------------------------------------------------
11  */
12 #ifndef _WALRECEIVER_H
13 #define _WALRECEIVER_H
14
15 #include "storage/spin.h"
16
17 /*
18  * MAXCONNINFO: maximum size of a connection string.
19  *
20  * XXX: Should this move to pg_config_manual.h?
21  */
22 #define MAXCONNINFO             1024
23
24 /*
25  * Values for WalRcv->walRcvState.
26  */
27 typedef enum
28 {
29         WALRCV_NOT_STARTED,
30         WALRCV_RUNNING,         /* walreceiver has been started */
31         WALRCV_STOPPING,        /* requested to stop, but still running */
32         WALRCV_STOPPED          /* stopped and mustn't start up again */
33 } WalRcvState;
34
35 /* Shared memory area for management of walreceiver process */
36 typedef struct
37 {
38         /*
39          * connection string; is used for walreceiver to connect with
40          * the primary.
41          */
42         char    conninfo[MAXCONNINFO];
43
44         /*
45          * PID of currently active walreceiver process, and the current state.
46          */
47         pid_t   pid;
48         WalRcvState walRcvState;
49
50         /*
51          * receivedUpto-1 is the last byte position that has been already
52          * received. When startup process starts the walreceiver, it sets this
53          * to the point where it wants the streaming to begin. After that,
54          * walreceiver updates this whenever it flushes the received WAL.
55          */
56         XLogRecPtr      receivedUpto;
57
58         slock_t mutex;          /* locks shared variables shown above */
59 } WalRcvData;
60
61 extern WalRcvData *WalRcv;
62
63 extern Size WalRcvShmemSize(void);
64 extern void WalRcvShmemInit(void);
65 extern bool WalRcvInProgress(void);
66 extern XLogRecPtr WaitNextXLogAvailable(XLogRecPtr recptr, bool *finished);
67 extern void RequestXLogStreaming(XLogRecPtr recptr, const char *conninfo);
68 extern XLogRecPtr GetWalRcvWriteRecPtr(void);
69
70 #endif   /* _WALRECEIVER_H */