1/*-------------------------------------------------------------------------
2 *
3 * streamutil.h
4 *
5 * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
6 *
7 * IDENTIFICATION
8 * src/bin/pg_basebackup/streamutil.h
9 *-------------------------------------------------------------------------
10 */
11
12#ifndef STREAMUTIL_H
13#define STREAMUTIL_H
14
15#include "libpq-fe.h"
16
17#include "access/xlogdefs.h"
18#include "datatype/timestamp.h"
19
20extern const char *progname;
21extern char *connection_string;
22extern char *dbhost;
23extern char *dbuser;
24extern char *dbport;
25extern char *dbname;
26extern int dbgetpassword;
27extern uint32 WalSegSz;
28
29/* Connection kept global so we can disconnect easily */
30extern PGconn *conn;
31
32extern PGconn *GetConnection(void);
33
34/* Replication commands */
35extern bool CreateReplicationSlot(PGconn *conn, const char *slot_name,
36 const char *plugin, bool is_temporary,
37 bool is_physical, bool reserve_wal,
38 bool slot_exists_ok);
39extern bool DropReplicationSlot(PGconn *conn, const char *slot_name);
40extern bool RunIdentifySystem(PGconn *conn, char **sysid,
41 TimeLineID *starttli,
42 XLogRecPtr *startpos,
43 char **db_name);
44extern bool RetrieveWalSegSize(PGconn *conn);
45extern TimestampTz feGetCurrentTimestamp(void);
46extern void feTimestampDifference(TimestampTz start_time, TimestampTz stop_time,
47 long *secs, int *microsecs);
48
49extern bool feTimestampDifferenceExceeds(TimestampTz start_time, TimestampTz stop_time,
50 int msec);
51extern void fe_sendint64(int64 i, char *buf);
52extern int64 fe_recvint64(char *buf);
53
54#endif /* STREAMUTIL_H */
55