~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to src/include/replication/walreceiver.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * walreceiver.h
 
4
 *        Exports from replication/walreceiverfuncs.c.
 
5
 *
 
6
 * Portions Copyright (c) 2010-2011, PostgreSQL Global Development Group
 
7
 *
 
8
 * src/include/replication/walreceiver.h
 
9
 *
 
10
 *-------------------------------------------------------------------------
 
11
 */
 
12
#ifndef _WALRECEIVER_H
 
13
#define _WALRECEIVER_H
 
14
 
 
15
#include "access/xlogdefs.h"
 
16
#include "storage/spin.h"
 
17
#include "pgtime.h"
 
18
 
 
19
extern bool am_walreceiver;
 
20
extern int      wal_receiver_status_interval;
 
21
extern bool hot_standby_feedback;
 
22
 
 
23
/*
 
24
 * MAXCONNINFO: maximum size of a connection string.
 
25
 *
 
26
 * XXX: Should this move to pg_config_manual.h?
 
27
 */
 
28
#define MAXCONNINFO             1024
 
29
 
 
30
/*
 
31
 * Values for WalRcv->walRcvState.
 
32
 */
 
33
typedef enum
 
34
{
 
35
        WALRCV_STOPPED,                         /* stopped and mustn't start up again */
 
36
        WALRCV_STARTING,                        /* launched, but the process hasn't
 
37
                                                                 * initialized yet */
 
38
        WALRCV_RUNNING,                         /* walreceiver is running */
 
39
        WALRCV_STOPPING                         /* requested to stop, but still running */
 
40
} WalRcvState;
 
41
 
 
42
/* Shared memory area for management of walreceiver process */
 
43
typedef struct
 
44
{
 
45
        /*
 
46
         * PID of currently active walreceiver process, its current state and
 
47
         * start time (actually, the time at which it was requested to be
 
48
         * started).
 
49
         */
 
50
        pid_t           pid;
 
51
        WalRcvState walRcvState;
 
52
        pg_time_t       startTime;
 
53
 
 
54
        /*
 
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.
 
58
         */
 
59
        XLogRecPtr      receiveStart;
 
60
 
 
61
        /*
 
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.
 
66
         */
 
67
        XLogRecPtr      receivedUpto;
 
68
 
 
69
        /*
 
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.
 
74
         */
 
75
        XLogRecPtr      latestChunkStart;
 
76
 
 
77
        /*
 
78
         * connection string; is used for walreceiver to connect with the primary.
 
79
         */
 
80
        char            conninfo[MAXCONNINFO];
 
81
 
 
82
        slock_t         mutex;                  /* locks shared variables shown above */
 
83
} WalRcvData;
 
84
 
 
85
extern WalRcvData *WalRcv;
 
86
 
 
87
/* libpqwalreceiver hooks */
 
88
typedef bool (*walrcv_connect_type) (char *conninfo, XLogRecPtr startpoint);
 
89
extern PGDLLIMPORT walrcv_connect_type walrcv_connect;
 
90
 
 
91
typedef bool (*walrcv_receive_type) (int timeout, unsigned char *type,
 
92
                                                                                                 char **buffer, int *len);
 
93
extern PGDLLIMPORT walrcv_receive_type walrcv_receive;
 
94
 
 
95
typedef void (*walrcv_send_type) (const char *buffer, int nbytes);
 
96
extern PGDLLIMPORT walrcv_send_type walrcv_send;
 
97
 
 
98
typedef void (*walrcv_disconnect_type) (void);
 
99
extern PGDLLIMPORT walrcv_disconnect_type walrcv_disconnect;
 
100
 
 
101
/* prototypes for functions in walreceiver.c */
 
102
extern void WalReceiverMain(void);
 
103
 
 
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);
 
111
 
 
112
#endif   /* _WALRECEIVER_H */