1/*-------------------------------------------------------------------------
2 *
3 * walsender.h
4 * Exports from replication/walsender.c.
5 *
6 * Portions Copyright (c) 2010-2019, PostgreSQL Global Development Group
7 *
8 * src/include/replication/walsender.h
9 *
10 *-------------------------------------------------------------------------
11 */
12#ifndef _WALSENDER_H
13#define _WALSENDER_H
14
15#include <signal.h>
16
17#include "fmgr.h"
18
19/*
20 * What to do with a snapshot in create replication slot command.
21 */
22typedef enum
23{
24 CRS_EXPORT_SNAPSHOT,
25 CRS_NOEXPORT_SNAPSHOT,
26 CRS_USE_SNAPSHOT
27} CRSSnapshotAction;
28
29/* global state */
30extern bool am_walsender;
31extern bool am_cascading_walsender;
32extern bool am_db_walsender;
33extern bool wake_wal_senders;
34
35/* user-settable parameters */
36extern int max_wal_senders;
37extern int wal_sender_timeout;
38extern bool log_replication_commands;
39
40extern void InitWalSender(void);
41extern bool exec_replication_command(const char *query_string);
42extern void WalSndErrorCleanup(void);
43extern void WalSndSignals(void);
44extern Size WalSndShmemSize(void);
45extern void WalSndShmemInit(void);
46extern void WalSndWakeup(void);
47extern void WalSndInitStopping(void);
48extern void WalSndWaitStopping(void);
49extern void HandleWalSndInitStopping(void);
50extern void WalSndRqstFileReload(void);
51
52/*
53 * Remember that we want to wakeup walsenders later
54 *
55 * This is separated from doing the actual wakeup because the writeout is done
56 * while holding contended locks.
57 */
58#define WalSndWakeupRequest() \
59 do { wake_wal_senders = true; } while (0)
60
61/*
62 * wakeup walsenders if there is work to be done
63 */
64#define WalSndWakeupProcessRequests() \
65 do \
66 { \
67 if (wake_wal_senders) \
68 { \
69 wake_wal_senders = false; \
70 if (max_wal_senders > 0) \
71 WalSndWakeup(); \
72 } \
73 } while (0)
74
75#endif /* _WALSENDER_H */
76