PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
streamutil.c File Reference
#include "postgres_fe.h"
#include <sys/time.h>
#include <unistd.h>
#include "access/xlog_internal.h"
#include "common/connect.h"
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
#include "datatype/timestamp.h"
#include "port/pg_bswap.h"
#include "pqexpbuffer.h"
#include "streamutil.h"
Include dependency graph for streamutil.c:

Go to the source code of this file.

Macros

#define ERRCODE_DUPLICATE_OBJECT   "42710"
 
#define MINIMUM_VERSION_FOR_SHOW_CMD   100000
 
#define MINIMUM_VERSION_FOR_GROUP_ACCESS   110000
 

Functions

static bool RetrieveDataDirCreatePerm (PGconn *conn)
 
static char * FindDbnameInConnParams (PQconninfoOption *conn_opts)
 
PGconnGetConnection (void)
 
char * GetDbnameFromConnectionOptions (void)
 
bool RetrieveWalSegSize (PGconn *conn)
 
bool RunIdentifySystem (PGconn *conn, char **sysid, TimeLineID *starttli, XLogRecPtr *startpos, char **db_name)
 
bool GetSlotInformation (PGconn *conn, const char *slot_name, XLogRecPtr *restart_lsn, TimeLineID *restart_tli)
 
bool CreateReplicationSlot (PGconn *conn, const char *slot_name, const char *plugin, bool is_temporary, bool is_physical, bool reserve_wal, bool slot_exists_ok, bool two_phase)
 
bool DropReplicationSlot (PGconn *conn, const char *slot_name)
 
void AppendPlainCommandOption (PQExpBuffer buf, bool use_new_option_syntax, char *option_name)
 
void AppendStringCommandOption (PQExpBuffer buf, bool use_new_option_syntax, char *option_name, char *option_value)
 
void AppendIntegerCommandOption (PQExpBuffer buf, bool use_new_option_syntax, char *option_name, int32 option_value)
 
TimestampTz feGetCurrentTimestamp (void)
 
void feTimestampDifference (TimestampTz start_time, TimestampTz stop_time, long *secs, int *microsecs)
 
bool feTimestampDifferenceExceeds (TimestampTz start_time, TimestampTz stop_time, int msec)
 
void fe_sendint64 (int64 i, char *buf)
 
int64 fe_recvint64 (char *buf)
 

Variables

int WalSegSz
 
const char * progname
 
char * connection_string = NULL
 
char * dbhost = NULL
 
char * dbuser = NULL
 
char * dbport = NULL
 
char * dbname = NULL
 
int dbgetpassword = 0
 
static char * password = NULL
 
PGconnconn = NULL
 

Macro Definition Documentation

◆ ERRCODE_DUPLICATE_OBJECT

#define ERRCODE_DUPLICATE_OBJECT   "42710"

Definition at line 30 of file streamutil.c.

◆ MINIMUM_VERSION_FOR_GROUP_ACCESS

#define MINIMUM_VERSION_FOR_GROUP_ACCESS   110000

Definition at line 43 of file streamutil.c.

◆ MINIMUM_VERSION_FOR_SHOW_CMD

#define MINIMUM_VERSION_FOR_SHOW_CMD   100000

Definition at line 38 of file streamutil.c.

Function Documentation

◆ AppendIntegerCommandOption()

void AppendIntegerCommandOption ( PQExpBuffer  buf,
bool  use_new_option_syntax,
char *  option_name,
int32  option_value 
)

Definition at line 854 of file streamutil.c.

856{
857 AppendPlainCommandOption(buf, use_new_option_syntax, option_name);
858
859 appendPQExpBuffer(buf, " %d", option_value);
860}
static char * buf
Definition: pg_test_fsync.c:72
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
Definition: pqexpbuffer.c:265
void AppendPlainCommandOption(PQExpBuffer buf, bool use_new_option_syntax, char *option_name)
Definition: streamutil.c:810

References AppendPlainCommandOption(), appendPQExpBuffer(), and buf.

Referenced by BaseBackup().

◆ AppendPlainCommandOption()

void AppendPlainCommandOption ( PQExpBuffer  buf,
bool  use_new_option_syntax,
char *  option_name 
)

Definition at line 810 of file streamutil.c.

812{
813 if (buf->len > 0 && buf->data[buf->len - 1] != '(')
814 {
815 if (use_new_option_syntax)
817 else
819 }
820
821 appendPQExpBuffer(buf, " %s", option_name);
822}
void appendPQExpBufferChar(PQExpBuffer str, char ch)
Definition: pqexpbuffer.c:378
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
Definition: pqexpbuffer.c:367

References appendPQExpBuffer(), appendPQExpBufferChar(), appendPQExpBufferStr(), and buf.

Referenced by AppendIntegerCommandOption(), AppendStringCommandOption(), BaseBackup(), and CreateReplicationSlot().

◆ AppendStringCommandOption()

void AppendStringCommandOption ( PQExpBuffer  buf,
bool  use_new_option_syntax,
char *  option_name,
char *  option_value 
)

Definition at line 831 of file streamutil.c.

833{
834 AppendPlainCommandOption(buf, use_new_option_syntax, option_name);
835
836 if (option_value != NULL)
837 {
838 size_t length = strlen(option_value);
839 char *escaped_value = palloc(1 + 2 * length);
840
841 PQescapeStringConn(conn, escaped_value, option_value, length, NULL);
842 appendPQExpBuffer(buf, " '%s'", escaped_value);
843 pfree(escaped_value);
844 }
845}
size_t PQescapeStringConn(PGconn *conn, char *to, const char *from, size_t length, int *error)
Definition: fe-exec.c:4145
void pfree(void *pointer)
Definition: mcxt.c:1521
void * palloc(Size size)
Definition: mcxt.c:1317
PGconn * conn
Definition: streamutil.c:53

References AppendPlainCommandOption(), appendPQExpBuffer(), buf, conn, palloc(), pfree(), and PQescapeStringConn().

Referenced by BaseBackup(), and CreateReplicationSlot().

◆ CreateReplicationSlot()

bool CreateReplicationSlot ( PGconn conn,
const char *  slot_name,
const char *  plugin,
bool  is_temporary,
bool  is_physical,
bool  reserve_wal,
bool  slot_exists_ok,
bool  two_phase 
)

Definition at line 653 of file streamutil.c.

656{
657 PQExpBuffer query;
658 PGresult *res;
659 bool use_new_option_syntax = (PQserverVersion(conn) >= 150000);
660
661 query = createPQExpBuffer();
662
663 Assert((is_physical && plugin == NULL) ||
664 (!is_physical && plugin != NULL));
665 Assert(!(two_phase && is_physical));
666 Assert(slot_name != NULL);
667
668 /* Build base portion of query */
669 appendPQExpBuffer(query, "CREATE_REPLICATION_SLOT \"%s\"", slot_name);
670 if (is_temporary)
671 appendPQExpBufferStr(query, " TEMPORARY");
672 if (is_physical)
673 appendPQExpBufferStr(query, " PHYSICAL");
674 else
675 appendPQExpBuffer(query, " LOGICAL \"%s\"", plugin);
676
677 /* Add any requested options */
678 if (use_new_option_syntax)
679 appendPQExpBufferStr(query, " (");
680 if (is_physical)
681 {
682 if (reserve_wal)
683 AppendPlainCommandOption(query, use_new_option_syntax,
684 "RESERVE_WAL");
685 }
686 else
687 {
688 if (two_phase && PQserverVersion(conn) >= 150000)
689 AppendPlainCommandOption(query, use_new_option_syntax,
690 "TWO_PHASE");
691
692 if (PQserverVersion(conn) >= 100000)
693 {
694 /* pg_recvlogical doesn't use an exported snapshot, so suppress */
695 if (use_new_option_syntax)
696 AppendStringCommandOption(query, use_new_option_syntax,
697 "SNAPSHOT", "nothing");
698 else
699 AppendPlainCommandOption(query, use_new_option_syntax,
700 "NOEXPORT_SNAPSHOT");
701 }
702 }
703 if (use_new_option_syntax)
704 {
705 /* Suppress option list if it would be empty, otherwise terminate */
706 if (query->data[query->len - 1] == '(')
707 {
708 query->len -= 2;
709 query->data[query->len] = '\0';
710 }
711 else
712 appendPQExpBufferChar(query, ')');
713 }
714
715 /* Now run the query */
716 res = PQexec(conn, query->data);
718 {
719 const char *sqlstate = PQresultErrorField(res, PG_DIAG_SQLSTATE);
720
721 if (slot_exists_ok &&
722 sqlstate &&
723 strcmp(sqlstate, ERRCODE_DUPLICATE_OBJECT) == 0)
724 {
725 destroyPQExpBuffer(query);
726 PQclear(res);
727 return true;
728 }
729 else
730 {
731 pg_log_error("could not send replication command \"%s\": %s",
732 query->data, PQerrorMessage(conn));
733
734 destroyPQExpBuffer(query);
735 PQclear(res);
736 return false;
737 }
738 }
739
740 if (PQntuples(res) != 1 || PQnfields(res) != 4)
741 {
742 pg_log_error("could not create replication slot \"%s\": got %d rows and %d fields, expected %d rows and %d fields",
743 slot_name,
744 PQntuples(res), PQnfields(res), 1, 4);
745
746 destroyPQExpBuffer(query);
747 PQclear(res);
748 return false;
749 }
750
751 destroyPQExpBuffer(query);
752 PQclear(res);
753 return true;
754}
#define Assert(condition)
Definition: c.h:812
int PQserverVersion(const PGconn *conn)
Definition: fe-connect.c:7199
char * PQerrorMessage(const PGconn *conn)
Definition: fe-connect.c:7209
ExecStatusType PQresultStatus(const PGresult *res)
Definition: fe-exec.c:3411
int PQntuples(const PGresult *res)
Definition: fe-exec.c:3481
char * PQresultErrorField(const PGresult *res, int fieldcode)
Definition: fe-exec.c:3466
PGresult * PQexec(PGconn *conn, const char *query)
Definition: fe-exec.c:2262
int PQnfields(const PGresult *res)
Definition: fe-exec.c:3489
@ PGRES_TUPLES_OK
Definition: libpq-fe.h:123
#define pg_log_error(...)
Definition: logging.h:106
static bool slot_exists_ok
Definition: pg_receivewal.c:50
static bool two_phase
static const char * plugin
#define PG_DIAG_SQLSTATE
Definition: postgres_ext.h:56
PQExpBuffer createPQExpBuffer(void)
Definition: pqexpbuffer.c:72
void destroyPQExpBuffer(PQExpBuffer str)
Definition: pqexpbuffer.c:114
#define ERRCODE_DUPLICATE_OBJECT
Definition: streamutil.c:30
void AppendStringCommandOption(PQExpBuffer buf, bool use_new_option_syntax, char *option_name, char *option_value)
Definition: streamutil.c:831

References AppendPlainCommandOption(), appendPQExpBuffer(), appendPQExpBufferChar(), appendPQExpBufferStr(), AppendStringCommandOption(), Assert, conn, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), ERRCODE_DUPLICATE_OBJECT, PQExpBufferData::len, PG_DIAG_SQLSTATE, pg_log_error, PGRES_TUPLES_OK, plugin, PQclear(), PQerrorMessage(), PQexec(), PQnfields(), PQntuples(), PQresultErrorField(), PQresultStatus(), PQserverVersion(), res, slot_exists_ok, and two_phase.

◆ DropReplicationSlot()

bool DropReplicationSlot ( PGconn conn,
const char *  slot_name 
)

Definition at line 761 of file streamutil.c.

762{
763 PQExpBuffer query;
764 PGresult *res;
765
766 Assert(slot_name != NULL);
767
768 query = createPQExpBuffer();
769
770 /* Build query */
771 appendPQExpBuffer(query, "DROP_REPLICATION_SLOT \"%s\"",
772 slot_name);
773 res = PQexec(conn, query->data);
775 {
776 pg_log_error("could not send replication command \"%s\": %s",
777 query->data, PQerrorMessage(conn));
778
779 destroyPQExpBuffer(query);
780 PQclear(res);
781 return false;
782 }
783
784 if (PQntuples(res) != 0 || PQnfields(res) != 0)
785 {
786 pg_log_error("could not drop replication slot \"%s\": got %d rows and %d fields, expected %d rows and %d fields",
787 slot_name,
788 PQntuples(res), PQnfields(res), 0, 0);
789
790 destroyPQExpBuffer(query);
791 PQclear(res);
792 return false;
793 }
794
795 destroyPQExpBuffer(query);
796 PQclear(res);
797 return true;
798}
@ PGRES_COMMAND_OK
Definition: libpq-fe.h:120

References appendPQExpBuffer(), Assert, conn, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), pg_log_error, PGRES_COMMAND_OK, PQclear(), PQerrorMessage(), PQexec(), PQnfields(), PQntuples(), PQresultStatus(), and res.

◆ fe_recvint64()

int64 fe_recvint64 ( char *  buf)

Definition at line 932 of file streamutil.c.

933{
934 uint64 n64;
935
936 memcpy(&n64, buf, sizeof(n64));
937
938 return pg_ntoh64(n64);
939}
uint64_t uint64
Definition: c.h:486
#define pg_ntoh64(x)
Definition: pg_bswap.h:126

References buf, and pg_ntoh64.

Referenced by ProcessXLogDataMsg(), and StreamLogicalLog().

◆ fe_sendint64()

void fe_sendint64 ( int64  i,
char *  buf 
)

Definition at line 921 of file streamutil.c.

922{
923 uint64 n64 = pg_hton64(i);
924
925 memcpy(buf, &n64, sizeof(n64));
926}
int i
Definition: isn.c:72
#define pg_hton64(x)
Definition: pg_bswap.h:122

References buf, i, and pg_hton64.

Referenced by sendFeedback().

◆ feGetCurrentTimestamp()

TimestampTz feGetCurrentTimestamp ( void  )

Definition at line 867 of file streamutil.c.

868{
869 TimestampTz result;
870 struct timeval tp;
871
872 gettimeofday(&tp, NULL);
873
874 result = (TimestampTz) tp.tv_sec -
876 result = (result * USECS_PER_SEC) + tp.tv_usec;
877
878 return result;
879}
int64 TimestampTz
Definition: timestamp.h:39
#define USECS_PER_SEC
Definition: timestamp.h:134
#define UNIX_EPOCH_JDATE
Definition: timestamp.h:234
#define SECS_PER_DAY
Definition: timestamp.h:126
#define POSTGRES_EPOCH_JDATE
Definition: timestamp.h:235
int gettimeofday(struct timeval *tp, void *tzp)

References gettimeofday(), POSTGRES_EPOCH_JDATE, SECS_PER_DAY, UNIX_EPOCH_JDATE, and USECS_PER_SEC.

Referenced by flushAndSendFeedback(), HandleCopyStream(), ProcessKeepaliveMsg(), and StreamLogicalLog().

◆ feTimestampDifference()

void feTimestampDifference ( TimestampTz  start_time,
TimestampTz  stop_time,
long *  secs,
int *  microsecs 
)

Definition at line 886 of file streamutil.c.

888{
889 TimestampTz diff = stop_time - start_time;
890
891 if (diff <= 0)
892 {
893 *secs = 0;
894 *microsecs = 0;
895 }
896 else
897 {
898 *secs = (long) (diff / USECS_PER_SEC);
899 *microsecs = (int) (diff % USECS_PER_SEC);
900 }
901}
static time_t start_time
Definition: pg_ctl.c:95

References start_time, and USECS_PER_SEC.

Referenced by CalculateCopyStreamSleeptime(), and StreamLogicalLog().

◆ feTimestampDifferenceExceeds()

bool feTimestampDifferenceExceeds ( TimestampTz  start_time,
TimestampTz  stop_time,
int  msec 
)

Definition at line 908 of file streamutil.c.

911{
912 TimestampTz diff = stop_time - start_time;
913
914 return (diff >= msec * INT64CONST(1000));
915}
#define INT64CONST(x)
Definition: c.h:499

References INT64CONST, and start_time.

Referenced by HandleCopyStream(), and StreamLogicalLog().

◆ FindDbnameInConnParams()

static char * FindDbnameInConnParams ( PQconninfoOption conn_opts)
static

Definition at line 280 of file streamutil.c.

281{
282 PQconninfoOption *conn_opt;
283
284 for (conn_opt = conn_opts; conn_opt->keyword != NULL; conn_opt++)
285 {
286 if (strcmp(conn_opt->keyword, "dbname") == 0 &&
287 conn_opt->val != NULL && conn_opt->val[0] != '\0')
288 return pg_strdup(conn_opt->val);
289 }
290 return NULL;
291}
char * pg_strdup(const char *in)
Definition: fe_memutils.c:85

References _PQconninfoOption::keyword, pg_strdup(), and _PQconninfoOption::val.

Referenced by GetDbnameFromConnectionOptions().

◆ GetConnection()

PGconn * GetConnection ( void  )

Definition at line 61 of file streamutil.c.

62{
63 PGconn *tmpconn;
64 int argcount = 7; /* dbname, replication, fallback_app_name,
65 * host, user, port, password */
66 int i;
67 const char **keywords;
68 const char **values;
69 const char *tmpparam;
70 bool need_password;
71 PQconninfoOption *conn_opts = NULL;
72 PQconninfoOption *conn_opt;
73 char *err_msg = NULL;
74
75 /*
76 * pg_recvlogical uses dbname only; others use connection_string only.
77 * (Note: both variables will be NULL if there's no command line options.)
78 */
79 Assert(dbname == NULL || connection_string == NULL);
80
81 /*
82 * Merge the connection info inputs given in form of connection string,
83 * options and default values (dbname=replication, replication=true, etc.)
84 */
85 i = 0;
87 {
88 conn_opts = PQconninfoParse(connection_string, &err_msg);
89 if (conn_opts == NULL)
90 pg_fatal("%s", err_msg);
91
92 for (conn_opt = conn_opts; conn_opt->keyword != NULL; conn_opt++)
93 {
94 if (conn_opt->val != NULL && conn_opt->val[0] != '\0')
95 argcount++;
96 }
97
98 keywords = pg_malloc0((argcount + 1) * sizeof(*keywords));
99 values = pg_malloc0((argcount + 1) * sizeof(*values));
100
101 /*
102 * Set dbname here already, so it can be overridden by a dbname in the
103 * connection string.
104 */
105 keywords[i] = "dbname";
106 values[i] = "replication";
107 i++;
108
109 for (conn_opt = conn_opts; conn_opt->keyword != NULL; conn_opt++)
110 {
111 if (conn_opt->val != NULL && conn_opt->val[0] != '\0')
112 {
113 keywords[i] = conn_opt->keyword;
114 values[i] = conn_opt->val;
115 i++;
116 }
117 }
118 }
119 else
120 {
121 keywords = pg_malloc0((argcount + 1) * sizeof(*keywords));
122 values = pg_malloc0((argcount + 1) * sizeof(*values));
123 keywords[i] = "dbname";
124 values[i] = (dbname == NULL) ? "replication" : dbname;
125 i++;
126 }
127
128 keywords[i] = "replication";
129 values[i] = (dbname == NULL) ? "true" : "database";
130 i++;
131 keywords[i] = "fallback_application_name";
132 values[i] = progname;
133 i++;
134
135 if (dbhost)
136 {
137 keywords[i] = "host";
138 values[i] = dbhost;
139 i++;
140 }
141 if (dbuser)
142 {
143 keywords[i] = "user";
144 values[i] = dbuser;
145 i++;
146 }
147 if (dbport)
148 {
149 keywords[i] = "port";
150 values[i] = dbport;
151 i++;
152 }
153
154 /* If -W was given, force prompt for password, but only the first time */
155 need_password = (dbgetpassword == 1 && !password);
156
157 do
158 {
159 /* Get a new password if appropriate */
160 if (need_password)
161 {
162 free(password);
163 password = simple_prompt("Password: ", false);
164 need_password = false;
165 }
166
167 /* Use (or reuse, on a subsequent connection) password if we have it */
168 if (password)
169 {
170 keywords[i] = "password";
171 values[i] = password;
172 }
173 else
174 {
175 keywords[i] = NULL;
176 values[i] = NULL;
177 }
178
179 /*
180 * Only expand dbname when we did not already parse the argument as a
181 * connection string ourselves.
182 */
184
185 /*
186 * If there is too little memory even to allocate the PGconn object
187 * and PQconnectdbParams returns NULL, we call exit(1) directly.
188 */
189 if (!tmpconn)
190 pg_fatal("could not connect to server");
191
192 /* If we need a password and -w wasn't given, loop back and get one */
193 if (PQstatus(tmpconn) == CONNECTION_BAD &&
194 PQconnectionNeedsPassword(tmpconn) &&
195 dbgetpassword != -1)
196 {
197 PQfinish(tmpconn);
198 need_password = true;
199 }
200 }
201 while (need_password);
202
203 if (PQstatus(tmpconn) != CONNECTION_OK)
204 {
205 pg_log_error("%s", PQerrorMessage(tmpconn));
206 PQfinish(tmpconn);
207 free(values);
208 free(keywords);
209 PQconninfoFree(conn_opts);
210 return NULL;
211 }
212
213 /* Connection ok! */
214 free(values);
215 free(keywords);
216 PQconninfoFree(conn_opts);
217
218 /*
219 * Set always-secure search path, so malicious users can't get control.
220 * The capacity to run normal SQL queries was added in PostgreSQL 10, so
221 * the search path cannot be changed (by us or attackers) on earlier
222 * versions.
223 */
224 if (dbname != NULL && PQserverVersion(tmpconn) >= 100000)
225 {
226 PGresult *res;
227
230 {
231 pg_log_error("could not clear \"search_path\": %s",
232 PQerrorMessage(tmpconn));
233 PQclear(res);
234 PQfinish(tmpconn);
235 exit(1);
236 }
237 PQclear(res);
238 }
239
240 /*
241 * Ensure we have the same value of integer_datetimes (now always "on") as
242 * the server we are connecting to.
243 */
244 tmpparam = PQparameterStatus(tmpconn, "integer_datetimes");
245 if (!tmpparam)
246 {
247 pg_log_error("could not determine server setting for \"integer_datetimes\"");
248 PQfinish(tmpconn);
249 exit(1);
250 }
251
252 if (strcmp(tmpparam, "on") != 0)
253 {
254 pg_log_error("\"integer_datetimes\" compile flag does not match server");
255 PQfinish(tmpconn);
256 exit(1);
257 }
258
259 /*
260 * Retrieve the source data directory mode and use it to construct a umask
261 * for creating directories and files.
262 */
263 if (!RetrieveDataDirCreatePerm(tmpconn))
264 {
265 PQfinish(tmpconn);
266 exit(1);
267 }
268
269 return tmpconn;
270}
static Datum values[MAXATTR]
Definition: bootstrap.c:151
#define ALWAYS_SECURE_SEARCH_PATH_SQL
Definition: connect.h:25
void PQconninfoFree(PQconninfoOption *connOptions)
Definition: fe-connect.c:7024
PQconninfoOption * PQconninfoParse(const char *conninfo, char **errmsg)
Definition: fe-connect.c:5740
const char * PQparameterStatus(const PGconn *conn, const char *paramName)
Definition: fe-connect.c:7164
int PQconnectionNeedsPassword(const PGconn *conn)
Definition: fe-connect.c:7260
ConnStatusType PQstatus(const PGconn *conn)
Definition: fe-connect.c:7146
void PQfinish(PGconn *conn)
Definition: fe-connect.c:4880
PGconn * PQconnectdbParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition: fe-connect.c:691
void * pg_malloc0(size_t size)
Definition: fe_memutils.c:53
#define free(a)
Definition: header.h:65
static const JsonPathKeyword keywords[]
@ CONNECTION_BAD
Definition: libpq-fe.h:82
@ CONNECTION_OK
Definition: libpq-fe.h:81
exit(1)
#define pg_fatal(...)
char * simple_prompt(const char *prompt, bool echo)
Definition: sprompt.c:38
int dbgetpassword
Definition: streamutil.c:51
char * dbhost
Definition: streamutil.c:47
static char * password
Definition: streamutil.c:52
char * dbport
Definition: streamutil.c:49
char * connection_string
Definition: streamutil.c:46
const char * progname
Definition: streamutil.c:45
static bool RetrieveDataDirCreatePerm(PGconn *conn)
Definition: streamutil.c:424
char * dbname
Definition: streamutil.c:50
char * dbuser
Definition: streamutil.c:48

References ALWAYS_SECURE_SEARCH_PATH_SQL, Assert, CONNECTION_BAD, CONNECTION_OK, connection_string, dbgetpassword, dbhost, dbname, dbport, dbuser, exit(), free, i, _PQconninfoOption::keyword, keywords, password, pg_fatal, pg_log_error, pg_malloc0(), PGRES_TUPLES_OK, PQclear(), PQconnectdbParams(), PQconnectionNeedsPassword(), PQconninfoFree(), PQconninfoParse(), PQerrorMessage(), PQexec(), PQfinish(), PQparameterStatus(), PQresultStatus(), PQserverVersion(), PQstatus(), progname, res, RetrieveDataDirCreatePerm(), simple_prompt(), _PQconninfoOption::val, and values.

◆ GetDbnameFromConnectionOptions()

char * GetDbnameFromConnectionOptions ( void  )

Definition at line 306 of file streamutil.c.

307{
308 PQconninfoOption *conn_opts;
309 char *err_msg = NULL;
310 char *dbname;
311
312 /* First try to get the dbname from connection string. */
314 {
315 conn_opts = PQconninfoParse(connection_string, &err_msg);
316 if (conn_opts == NULL)
317 pg_fatal("%s", err_msg);
318
319 dbname = FindDbnameInConnParams(conn_opts);
320
321 PQconninfoFree(conn_opts);
322 if (dbname)
323 return dbname;
324 }
325
326 /*
327 * Next try to get the dbname from default values that are available from
328 * the environment.
329 */
330 conn_opts = PQconndefaults();
331 if (conn_opts == NULL)
332 pg_fatal("out of memory");
333
334 dbname = FindDbnameInConnParams(conn_opts);
335
336 PQconninfoFree(conn_opts);
337 return dbname;
338}
PQconninfoOption * PQconndefaults(void)
Definition: fe-connect.c:1883
static char * FindDbnameInConnParams(PQconninfoOption *conn_opts)
Definition: streamutil.c:280

References connection_string, dbname, FindDbnameInConnParams(), pg_fatal, PQconndefaults(), PQconninfoFree(), and PQconninfoParse().

Referenced by BaseBackup().

◆ GetSlotInformation()

bool GetSlotInformation ( PGconn conn,
const char *  slot_name,
XLogRecPtr restart_lsn,
TimeLineID restart_tli 
)

Definition at line 559 of file streamutil.c.

561{
562 PGresult *res;
563 PQExpBuffer query;
565 TimeLineID tli_loc = 0;
566
567 if (restart_lsn)
568 *restart_lsn = lsn_loc;
569 if (restart_tli)
570 *restart_tli = tli_loc;
571
572 query = createPQExpBuffer();
573 appendPQExpBuffer(query, "READ_REPLICATION_SLOT %s", slot_name);
574 res = PQexec(conn, query->data);
575 destroyPQExpBuffer(query);
576
578 {
579 pg_log_error("could not send replication command \"%s\": %s",
580 "READ_REPLICATION_SLOT", PQerrorMessage(conn));
581 PQclear(res);
582 return false;
583 }
584
585 /* The command should always return precisely one tuple and three fields */
586 if (PQntuples(res) != 1 || PQnfields(res) != 3)
587 {
588 pg_log_error("could not read replication slot \"%s\": got %d rows and %d fields, expected %d rows and %d fields",
589 slot_name, PQntuples(res), PQnfields(res), 1, 3);
590 PQclear(res);
591 return false;
592 }
593
594 /*
595 * When the slot doesn't exist, the command returns a tuple with NULL
596 * values. This checks only the slot type field.
597 */
598 if (PQgetisnull(res, 0, 0))
599 {
600 pg_log_error("replication slot \"%s\" does not exist", slot_name);
601 PQclear(res);
602 return false;
603 }
604
605 /*
606 * Note that this cannot happen as READ_REPLICATION_SLOT supports only
607 * physical slots, but play it safe.
608 */
609 if (strcmp(PQgetvalue(res, 0, 0), "physical") != 0)
610 {
611 pg_log_error("expected a physical replication slot, got type \"%s\" instead",
612 PQgetvalue(res, 0, 0));
613 PQclear(res);
614 return false;
615 }
616
617 /* restart LSN */
618 if (!PQgetisnull(res, 0, 1))
619 {
620 uint32 hi,
621 lo;
622
623 if (sscanf(PQgetvalue(res, 0, 1), "%X/%X", &hi, &lo) != 2)
624 {
625 pg_log_error("could not parse restart_lsn \"%s\" for replication slot \"%s\"",
626 PQgetvalue(res, 0, 1), slot_name);
627 PQclear(res);
628 return false;
629 }
630 lsn_loc = ((uint64) hi) << 32 | lo;
631 }
632
633 /* current TLI */
634 if (!PQgetisnull(res, 0, 2))
635 tli_loc = (TimeLineID) atoll(PQgetvalue(res, 0, 2));
636
637 PQclear(res);
638
639 /* Assign results if requested */
640 if (restart_lsn)
641 *restart_lsn = lsn_loc;
642 if (restart_tli)
643 *restart_tli = tli_loc;
644
645 return true;
646}
uint32_t uint32
Definition: c.h:485
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3876
int PQgetisnull(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3901
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28
uint32 TimeLineID
Definition: xlogdefs.h:59

References appendPQExpBuffer(), conn, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), InvalidXLogRecPtr, pg_log_error, PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQexec(), PQgetisnull(), PQgetvalue(), PQnfields(), PQntuples(), PQresultStatus(), and res.

Referenced by StreamLog().

◆ RetrieveDataDirCreatePerm()

static bool RetrieveDataDirCreatePerm ( PGconn conn)
static

Definition at line 424 of file streamutil.c.

425{
426 PGresult *res;
428
429 /* check connection existence */
430 Assert(conn != NULL);
431
432 /* for previous versions leave the default group access */
434 return true;
435
436 res = PQexec(conn, "SHOW data_directory_mode");
438 {
439 pg_log_error("could not send replication command \"%s\": %s",
440 "SHOW data_directory_mode", PQerrorMessage(conn));
441
442 PQclear(res);
443 return false;
444 }
445 if (PQntuples(res) != 1 || PQnfields(res) < 1)
446 {
447 pg_log_error("could not fetch group access flag: got %d rows and %d fields, expected %d rows and %d or more fields",
448 PQntuples(res), PQnfields(res), 1, 1);
449
450 PQclear(res);
451 return false;
452 }
453
454 if (sscanf(PQgetvalue(res, 0, 0), "%o", &data_directory_mode) != 1)
455 {
456 pg_log_error("group access flag could not be parsed: %s",
457 PQgetvalue(res, 0, 0));
458
459 PQclear(res);
460 return false;
461 }
462
464
465 PQclear(res);
466 return true;
467}
void SetDataDirectoryCreatePerm(int dataDirMode)
Definition: file_perm.c:34
int data_directory_mode
Definition: globals.c:76
#define MINIMUM_VERSION_FOR_GROUP_ACCESS
Definition: streamutil.c:43

References Assert, conn, data_directory_mode, MINIMUM_VERSION_FOR_GROUP_ACCESS, pg_log_error, PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQexec(), PQgetvalue(), PQnfields(), PQntuples(), PQresultStatus(), PQserverVersion(), res, and SetDataDirectoryCreatePerm().

Referenced by GetConnection().

◆ RetrieveWalSegSize()

bool RetrieveWalSegSize ( PGconn conn)

Definition at line 345 of file streamutil.c.

346{
347 PGresult *res;
348 char xlog_unit[3];
349 int xlog_val,
350 multiplier = 1;
351
352 /* check connection existence */
353 Assert(conn != NULL);
354
355 /* for previous versions set the default xlog seg size */
357 {
359 return true;
360 }
361
362 res = PQexec(conn, "SHOW wal_segment_size");
364 {
365 pg_log_error("could not send replication command \"%s\": %s",
366 "SHOW wal_segment_size", PQerrorMessage(conn));
367
368 PQclear(res);
369 return false;
370 }
371 if (PQntuples(res) != 1 || PQnfields(res) < 1)
372 {
373 pg_log_error("could not fetch WAL segment size: got %d rows and %d fields, expected %d rows and %d or more fields",
374 PQntuples(res), PQnfields(res), 1, 1);
375
376 PQclear(res);
377 return false;
378 }
379
380 /* fetch xlog value and unit from the result */
381 if (sscanf(PQgetvalue(res, 0, 0), "%d%2s", &xlog_val, xlog_unit) != 2)
382 {
383 pg_log_error("WAL segment size could not be parsed");
384 PQclear(res);
385 return false;
386 }
387
388 PQclear(res);
389
390 /* set the multiplier based on unit to convert xlog_val to bytes */
391 if (strcmp(xlog_unit, "MB") == 0)
392 multiplier = 1024 * 1024;
393 else if (strcmp(xlog_unit, "GB") == 0)
394 multiplier = 1024 * 1024 * 1024;
395
396 /* convert and set WalSegSz */
397 WalSegSz = xlog_val * multiplier;
398
400 {
401 pg_log_error(ngettext("remote server reported invalid WAL segment size (%d byte)",
402 "remote server reported invalid WAL segment size (%d bytes)",
403 WalSegSz),
404 WalSegSz);
405 pg_log_error_detail("The WAL segment size must be a power of two between 1 MB and 1 GB.");
406 return false;
407 }
408
409 return true;
410}
#define ngettext(s, p, n)
Definition: c.h:1135
#define pg_log_error_detail(...)
Definition: logging.h:109
#define DEFAULT_XLOG_SEG_SIZE
int WalSegSz
Definition: streamutil.c:32
#define MINIMUM_VERSION_FOR_SHOW_CMD
Definition: streamutil.c:38
#define IsValidWalSegSize(size)
Definition: xlog_internal.h:96

References Assert, conn, DEFAULT_XLOG_SEG_SIZE, IsValidWalSegSize, MINIMUM_VERSION_FOR_SHOW_CMD, ngettext, pg_log_error, pg_log_error_detail, PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQexec(), PQgetvalue(), PQnfields(), PQntuples(), PQresultStatus(), PQserverVersion(), res, and WalSegSz.

Referenced by main().

◆ RunIdentifySystem()

bool RunIdentifySystem ( PGconn conn,
char **  sysid,
TimeLineID starttli,
XLogRecPtr startpos,
char **  db_name 
)

Definition at line 478 of file streamutil.c.

480{
481 PGresult *res;
482 uint32 hi,
483 lo;
484
485 /* Check connection existence */
486 Assert(conn != NULL);
487
488 res = PQexec(conn, "IDENTIFY_SYSTEM");
490 {
491 pg_log_error("could not send replication command \"%s\": %s",
492 "IDENTIFY_SYSTEM", PQerrorMessage(conn));
493
494 PQclear(res);
495 return false;
496 }
497 if (PQntuples(res) != 1 || PQnfields(res) < 3)
498 {
499 pg_log_error("could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields",
500 PQntuples(res), PQnfields(res), 1, 3);
501
502 PQclear(res);
503 return false;
504 }
505
506 /* Get system identifier */
507 if (sysid != NULL)
508 *sysid = pg_strdup(PQgetvalue(res, 0, 0));
509
510 /* Get timeline ID to start streaming from */
511 if (starttli != NULL)
512 *starttli = atoi(PQgetvalue(res, 0, 1));
513
514 /* Get LSN start position if necessary */
515 if (startpos != NULL)
516 {
517 if (sscanf(PQgetvalue(res, 0, 2), "%X/%X", &hi, &lo) != 2)
518 {
519 pg_log_error("could not parse write-ahead log location \"%s\"",
520 PQgetvalue(res, 0, 2));
521
522 PQclear(res);
523 return false;
524 }
525 *startpos = ((uint64) hi) << 32 | lo;
526 }
527
528 /* Get database name, only available in 9.4 and newer versions */
529 if (db_name != NULL)
530 {
531 *db_name = NULL;
532 if (PQserverVersion(conn) >= 90400)
533 {
534 if (PQnfields(res) < 4)
535 {
536 pg_log_error("could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields",
537 PQntuples(res), PQnfields(res), 1, 4);
538
539 PQclear(res);
540 return false;
541 }
542 if (!PQgetisnull(res, 0, 3))
543 *db_name = pg_strdup(PQgetvalue(res, 0, 3));
544 }
545 }
546
547 PQclear(res);
548 return true;
549}
static XLogRecPtr startpos

References Assert, conn, pg_log_error, pg_strdup(), PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQexec(), PQgetisnull(), PQgetvalue(), PQnfields(), PQntuples(), PQresultStatus(), PQserverVersion(), res, and startpos.

Referenced by BaseBackup(), main(), ReceiveXlogStream(), and StreamLog().

Variable Documentation

◆ conn

PGconn* conn = NULL

Definition at line 53 of file streamutil.c.

Referenced by append_db_pattern_cte(), append_rel_pattern_filtered_cte(), append_rel_pattern_raw_cte(), appendQualifiedRelation(), AppendStringCommandOption(), appendStringLiteralConn(), applyRemoteGucs(), BaseBackup(), build_client_final_message(), build_client_first_message(), build_startup_packet(), buildShSecLabels(), canChangeResultMode(), check_and_drop_existing_subscriptions(), check_expected_areq(), check_for_pg_role_prefix(), check_for_prepared_transactions(), check_is_install_user(), check_loadable_libraries(), check_new_cluster_logical_replication_slots(), check_new_cluster_subscription_configuration(), check_old_cluster_subscription_state(), check_prepare_conn(), check_publisher(), check_subscriber(), CheckCopyStreamStop(), CheckServerVersionForStreaming(), cleanup_objects_atexit(), close_cursor(), cluster_all_databases(), cluster_one_database(), compile_database_list(), compile_relation_list_one_db(), configure_remote_session(), confirm_query_canceled_impl(), connect_database(), connect_pg_server(), connectDatabase(), connectFailureMessage(), connection_failed(), connectMaintenanceDatabase(), connectNoDelay(), connectOptions1(), connectToServer(), copy_connection(), CopyStreamPoll(), CopyStreamReceive(), create_cursor(), create_logical_replication_slot(), create_logical_replication_slots(), create_publication(), create_subscription(), CreateReplicationSlot(), dblink_cancel_query(), dblink_close(), dblink_connect(), dblink_disconnect(), dblink_error_message(), dblink_exec(), dblink_fetch(), dblink_get_conn(), dblink_get_notify(), dblink_is_busy(), dblink_open(), dblink_record_internal(), dblink_res_error(), dblink_security_check(), dblink_send_query(), disconnect_atexit(), disconnect_database(), disconnectDatabase(), do_sql_command(), do_sql_command_begin(), do_sql_command_end(), doConnect(), drop_existing_subscriptions(), drop_failover_replication_slots(), drop_primary_replication_slot(), drop_publication(), drop_replication_slot(), dropDBs(), DropReplicationSlot(), dropRoles(), dropTablespaces(), dumpDatabase(), dumpDatabaseConfig(), dumpDatabases(), dumpLOs(), dumpRoleGUCPrivs(), dumpRoleMembership(), dumpRoles(), dumpTableData_copy(), dumpTablespaces(), dumpUserConfig(), ecpg_raise_backend(), emitHostIdentityInfo(), emitShSecLabels(), enable_subscription(), estimate_path_cost_size(), executeCommand(), executeMaintenanceCommand(), executeQuery(), executeQueryOrDie(), ExecuteSqlCommand(), exit_nicely(), expand_dbname_patterns(), exportFile(), fetch_more_data(), fillPGconn(), flushAndSendFeedback(), freePGconn(), generate_object_name(), get_db_conn(), get_db_infos(), get_parallel_object_list(), get_primary_sysid(), get_remote_estimate(), get_subscription_count(), get_tablespace_paths(), get_template0_info(), getAnotherTuple(), getCopyDataMessage(), getCopyResult(), getCopyStart(), getHostaddr(), getNotify(), getParamDescriptions(), getParameterStatus(), getReadyForQuery(), getRowDescriptions(), GetSlotInformation(), gss_read(), handleCopyIn(), handleCopyOut(), HandleCopyStream(), HandleEndOfCopyStream(), handleSyncLoss(), importFile(), init_allowed_encryption_methods(), init_libpq_conn(), init_libpq_source(), initialize_SSL(), internal_ping(), libpq_append_conn_error(), libpq_fetch_file(), libpq_get_current_wal_insert_lsn(), libpq_prng_init(), libpq_traverse_files(), libpqrcv_alter_slot(), libpqrcv_connect(), libpqrcv_create_slot(), libpqrcv_disconnect(), libpqrcv_endstreaming(), libpqrcv_exec(), libpqrcv_get_backend_pid(), libpqrcv_get_conninfo(), libpqrcv_get_senderinfo(), libpqrcv_identify_system(), libpqrcv_readtimelinehistoryfile(), libpqrcv_receive(), libpqrcv_send(), libpqrcv_server_version(), libpqrcv_startstreaming(), libpqsrv_cancel(), libpqsrv_connect(), libpqsrv_connect_internal(), libpqsrv_connect_params(), libpqsrv_disconnect(), libpqsrv_exec(), libpqsrv_exec_params(), libpqsrv_get_result(), libpqsrv_get_result_last(), lo_close(), lo_creat(), lo_create(), lo_export(), lo_import(), lo_import_internal(), lo_import_with_oid(), lo_initialize(), lo_lseek(), lo_lseek64(), lo_open(), lo_read(), lo_tell(), lo_tell64(), lo_truncate(), lo_truncate64(), lo_unlink(), lo_write(), main(), makeAlterConfigCommand(), materializeResult(), my_truncate(), old_9_6_invalidate_hash_indexes(), open_client_SSL(), openssl_verify_peer_name_matches_certificate_ip(), openssl_verify_peer_name_matches_certificate_name(), overwrite(), ParallelSlotsAdoptConn(), ParallelSlotsTerminate(), parseInput(), pg_fe_sendauth(), pg_GSS_error(), pg_GSS_load_servicename(), pg_GSS_read(), pg_GSS_write(), pg_password_sendauth(), pg_SASL_continue(), pg_SASL_init(), pgconn_bio_ctrl(), pgconn_bio_read(), pgfdw_cancel_query(), pgfdw_cancel_query_begin(), pgfdw_cancel_query_end(), pgfdw_conn_check(), pgfdw_exec_cleanup_query(), pgfdw_exec_cleanup_query_begin(), pgfdw_exec_cleanup_query_end(), pgfdw_exec_query(), pgfdw_get_cleanup_result(), pgfdw_get_result(), pgfdw_report_error(), pgfdw_security_check(), pgpassfileWarning(), pgtls_close(), pgtls_get_peer_certificate_hash(), pgtls_open_client(), pgtls_read(), pgtls_read_pending(), pgtls_verify_peer_name_matches_certificate_guts(), pgtls_write(), pickout(), postgresAcquireSampleRowsFunc(), postgresAnalyzeForeignTable(), postgresExecForeignTruncate(), postgresGetAnalyzeInfoForForeignTable(), postgresImportForeignSchema(), pq_verify_peer_name_matches_certificate(), pq_verify_peer_name_matches_certificate_ip(), pq_verify_peer_name_matches_certificate_name(), pqAllocCmdQueueEntry(), pqAppendCmdQueueEntry(), PQbackendPID(), pqBuildStartupPacket3(), PQcancelCreate(), PQcancelPoll(), PQchangePassword(), pqCheckInBufferSpace(), pqCheckOutBufferSpace(), pqClearAsyncResult(), PQclientEncoding(), pqClosePGconn(), PQclosePortal(), PQclosePrepared(), pqCommandQueueAdvance(), PQconnectdb(), pqConnectDBComplete(), PQconnectdbParams(), pqConnectDBStart(), PQconnectionNeedsPassword(), PQconnectionUsedGSSAPI(), PQconnectionUsedPassword(), pqConnectOptions2(), PQconnectPoll(), PQconnectStart(), PQconnectStartParams(), PQconninfo(), PQconsumeInput(), PQdb(), PQdefaultSSLKeyPassHook_OpenSSL(), PQdescribePortal(), PQdescribePrepared(), pqDropConnection(), pqDropServerData(), PQencryptPasswordConn(), PQendcopy(), pqEndcopy3(), PQenterPipelineMode(), PQerrorMessage(), PQescapeByteaConn(), PQescapeByteaInternal(), PQescapeIdentifier(), PQescapeInternal(), PQescapeLiteral(), PQescapeStringConn(), PQescapeStringInternal(), PQexec(), PQexecFinish(), PQexecParams(), PQexecPrepared(), PQexecStart(), PQexitPipelineMode(), PQfinish(), PQfireResultCreateEvents(), PQflush(), pqFlush(), PQfn(), PQfullProtocolVersion(), pqFunctionCall3(), pqGetc(), PQgetCancel(), PQgetCopyData(), pqGetCopyData3(), pqGetErrorNotice3(), PQgetgssctx(), pqGetInt(), PQgetline(), pqGetline3(), PQgetlineAsync(), pqGetlineAsync3(), pqGetnchar(), pqGetNegotiateProtocolVersion3(), PQgetResult(), pqGets(), pqGets_append(), pqGets_internal(), PQgetssl(), PQgssEncInUse(), PQhost(), PQhostaddr(), PQinstanceData(), PQisBusy(), PQisnonblocking(), pqMakeEmptyPGconn(), PQmakeEmptyPGresult(), PQnotifies(), PQoptions(), pqPacketSend(), PQparameterStatus(), pqParseDone(), pqParseInput3(), pqParseIntParam(), PQpass(), PQping(), PQpingParams(), pqPipelineFlush(), pqPipelineProcessQueue(), PQpipelineStatus(), PQpipelineSync(), pqPipelineSyncInternal(), PQport(), PQprepare(), pqPrepareAsyncResult(), PQprotocolVersion(), pqPutc(), PQputCopyData(), PQputCopyEnd(), pqPutInt(), PQputline(), pqPutMsgBytes(), pqPutMsgEnd(), pqPutMsgStart(), PQputnbytes(), pqPutnchar(), pqPuts(), pqReadData(), pqReadReady(), pqRecycleCmdQueueEntry(), PQregisterEventProc(), pqReleaseConnHosts(), PQrequestCancel(), PQreset(), PQresetPoll(), PQresetStart(), pqRowProcessor(), pqSaveErrorResult(), pqSaveParameterStatus(), pqSaveWriteError(), pqsecure_close(), pqsecure_open_client(), pqsecure_open_gss(), pqsecure_raw_read(), pqsecure_raw_write(), pqsecure_read(), pqsecure_write(), PQsendClosePortal(), PQsendClosePrepared(), PQsendDescribePortal(), PQsendDescribePrepared(), PQsendFlushRequest(), PQsendPipelineSync(), PQsendPrepare(), PQsendQuery(), PQsendQueryContinue(), PQsendQueryGuts(), PQsendQueryInternal(), PQsendQueryParams(), PQsendQueryPrepared(), PQsendQueryStart(), pqSendSome(), PQsendTypedCommand(), PQserverVersion(), PQservice(), PQsetChunkedRowsMode(), PQsetClientEncoding(), PQsetdbLogin(), PQsetErrorContextVisibility(), PQsetErrorVerbosity(), PQsetInstanceData(), PQsetnonblocking(), PQsetNoticeProcessor(), PQsetNoticeReceiver(), PQsetSingleRowMode(), PQsetTraceFlags(), pqSkipnchar(), PQsocket(), pqSocketCheck(), PQssl_passwd_cb(), PQsslAttribute(), PQsslAttributeNames(), PQsslInUse(), PQsslStruct(), PQstatus(), PQtrace(), pqTraceOutputCharResponse(), pqTraceOutputMessage(), pqTraceOutputNoTypeByteMessage(), PQtransactionStatus(), PQtty(), PQuntrace(), PQuser(), pqWait(), pqWaitTimed(), pqWriteReady(), prepareToTerminate(), process_result(), ProcessKeepaliveMsg(), processSQLNamePattern(), ProcessXLogDataMsg(), prohibit_crossdb_refs(), read_server_final_message(), read_server_first_message(), ReceiveArchiveStream(), ReceiveBackupManifest(), ReceiveBackupManifestInMemory(), ReceiveCopyData(), ReceiveTarFile(), ReceiveXlogStream(), reindex_all_databases(), reindex_one_database(), release_conn_addrinfo(), RetrieveDataDirCreatePerm(), RetrieveWalSegSize(), run_permutation(), run_reindex_command(), run_simple_command(), run_simple_query(), run_vacuum_command(), RunIdentifySystem(), scram_exchange(), scram_init(), select_next_encryption_method(), send_cancellable_query_impl(), sendFeedback(), sendTerminateConn(), server_is_in_recovery(), set_archive_cancel_info(), set_frozenxids(), set_replication_progress(), SetCancelConn(), setKeepalivesCount(), setKeepalivesIdle(), setKeepalivesInterval(), setTCPUserTimeout(), setup_connection(), setup_publisher(), setup_recovery(), setup_subscriber(), sql_conn(), sql_exec(), sql_exec_dumpalldbs(), sql_exec_dumpalltables(), sql_exec_dumpalltbspc(), sql_exec_searchtables(), ssl_set_pgconn_bio(), start_postmaster(), StartLogStreamer(), store_conn_addrinfo(), storeQueryResult(), StreamLog(), StreamLogicalLog(), stringlist_to_identifierstr(), TableCommandResultHandler(), test_cancel(), test_disallowed_in_pipeline(), test_multi_pipelines(), test_nosync(), test_pipeline_abort(), test_pipeline_idle(), test_pipelined_insert(), test_prepared(), test_simple_pipeline(), test_singlerowmode(), test_transaction(), test_uniqviol(), try_complete_step(), useKeepalives(), vacuum_all_databases(), vacuum_one_database(), vacuumlo(), verify_btree_slot_handler(), verify_heap_slot_handler(), wait_for_end_recovery(), wait_on_slots(), and wait_until_connected().

◆ connection_string

char* connection_string = NULL

Definition at line 46 of file streamutil.c.

Referenced by connectDatabase(), GetConnection(), GetDbnameFromConnectionOptions(), and main().

◆ dbgetpassword

int dbgetpassword = 0

Definition at line 51 of file streamutil.c.

Referenced by GetConnection(), and main().

◆ dbhost

char* dbhost = NULL

Definition at line 47 of file streamutil.c.

Referenced by GetConnection(), and main().

◆ dbname

◆ dbport

char* dbport = NULL

Definition at line 49 of file streamutil.c.

Referenced by GetConnection(), and main().

◆ dbuser

char* dbuser = NULL

Definition at line 48 of file streamutil.c.

Referenced by GetConnection(), and main().

◆ password

◆ progname

const char* progname

Definition at line 45 of file streamutil.c.

Referenced by GetConnection().

◆ WalSegSz