1/*-------------------------------------------------------------------------
2 *
3 * receivelog.h
4 *
5 * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
6 *
7 * IDENTIFICATION
8 * src/bin/pg_basebackup/receivelog.h
9 *-------------------------------------------------------------------------
10 */
11
12#ifndef RECEIVELOG_H
13#define RECEIVELOG_H
14
15#include "libpq-fe.h"
16#include "walmethods.h"
17
18#include "access/xlogdefs.h"
19
20/*
21 * Called before trying to read more data or when a segment is
22 * finished. Return true to stop streaming.
23 */
24typedef bool (*stream_stop_callback) (XLogRecPtr segendpos, uint32 timeline, bool segment_finished);
25
26/*
27 * Global parameters when receiving xlog stream. For details about the individual fields,
28 * see the function comment for ReceiveXlogStream().
29 */
30typedef struct StreamCtl
31{
32 XLogRecPtr startpos; /* Start position for streaming */
33 TimeLineID timeline; /* Timeline to stream data from */
34 char *sysidentifier; /* Validate this system identifier and
35 * timeline */
36 int standby_message_timeout; /* Send status messages this often */
37 bool synchronous; /* Flush immediately WAL data on write */
38 bool mark_done; /* Mark segment as done in generated archive */
39 bool do_sync; /* Flush to disk to ensure consistent state of
40 * data */
41
42 stream_stop_callback stream_stop; /* Stop streaming when returns true */
43
44 pgsocket stop_socket; /* if valid, watch for input on this socket
45 * and check stream_stop() when there is any */
46
47 WalWriteMethod *walmethod; /* How to write the WAL */
48 char *partial_suffix; /* Suffix appended to partially received files */
49 char *replication_slot; /* Replication slot to use, or NULL */
50} StreamCtl;
51
52
53
54extern bool CheckServerVersionForStreaming(PGconn *conn);
55extern bool ReceiveXlogStream(PGconn *conn,
56 StreamCtl *stream);
57
58#endif /* RECEIVELOG_H */
59