PostgreSQL Source Code  git master
pg_backup_db.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pg_backup_db.c
4  *
5  * Implements the basic DB functions used by the archiver.
6  *
7  * IDENTIFICATION
8  * src/bin/pg_dump/pg_backup_db.c
9  *
10  *-------------------------------------------------------------------------
11  */
12 #include "postgres_fe.h"
13 
14 #include <unistd.h>
15 #include <ctype.h>
16 #ifdef HAVE_TERMIOS_H
17 #include <termios.h>
18 #endif
19 
20 #include "dumputils.h"
21 #include "fe_utils/connect.h"
22 #include "fe_utils/string_utils.h"
23 #include "parallel.h"
24 #include "pg_backup_archiver.h"
25 #include "pg_backup_db.h"
26 #include "pg_backup_utils.h"
27 
28 static void _check_database_version(ArchiveHandle *AH);
29 static PGconn *_connectDB(ArchiveHandle *AH, const char *newdbname, const char *newUser);
30 static void notice_processor(void *arg, const char *message);
31 
32 static void
34 {
35  const char *remoteversion_str;
36  int remoteversion;
37  PGresult *res;
38 
39  remoteversion_str = PQparameterStatus(AH->connection, "server_version");
40  remoteversion = PQserverVersion(AH->connection);
41  if (remoteversion == 0 || !remoteversion_str)
42  fatal("could not get server_version from libpq");
43 
44  AH->public.remoteVersionStr = pg_strdup(remoteversion_str);
45  AH->public.remoteVersion = remoteversion;
46  if (!AH->archiveRemoteVersion)
48 
49  if (remoteversion != PG_VERSION_NUM
50  && (remoteversion < AH->public.minRemoteVersion ||
51  remoteversion > AH->public.maxRemoteVersion))
52  {
53  pg_log_error("server version: %s; %s version: %s",
54  remoteversion_str, progname, PG_VERSION);
55  fatal("aborting because of server version mismatch");
56  }
57 
58  /*
59  * When running against 9.0 or later, check if we are in recovery mode,
60  * which means we are on a hot standby.
61  */
62  if (remoteversion >= 90000)
63  {
64  res = ExecuteSqlQueryForSingleRow((Archive *) AH, "SELECT pg_catalog.pg_is_in_recovery()");
65 
66  AH->public.isStandby = (strcmp(PQgetvalue(res, 0, 0), "t") == 0);
67  PQclear(res);
68  }
69  else
70  AH->public.isStandby = false;
71 }
72 
73 /*
74  * Reconnect to the server. If dbname is not NULL, use that database,
75  * else the one associated with the archive handle. If username is
76  * not NULL, use that user name, else the one from the handle.
77  */
78 void
79 ReconnectToServer(ArchiveHandle *AH, const char *dbname, const char *username)
80 {
81  PGconn *newConn;
82  const char *newdbname;
83  const char *newusername;
84 
85  if (!dbname)
86  newdbname = PQdb(AH->connection);
87  else
88  newdbname = dbname;
89 
90  if (!username)
91  newusername = PQuser(AH->connection);
92  else
93  newusername = username;
94 
95  newConn = _connectDB(AH, newdbname, newusername);
96 
97  /* Update ArchiveHandle's connCancel before closing old connection */
98  set_archive_cancel_info(AH, newConn);
99 
100  PQfinish(AH->connection);
101  AH->connection = newConn;
102 
103  /* Start strict; later phases may override this. */
106 }
107 
108 /*
109  * Connect to the db again.
110  *
111  * Note: it's not really all that sensible to use a single-entry password
112  * cache if the username keeps changing. In current usage, however, the
113  * username never does change, so one savedPassword is sufficient. We do
114  * update the cache on the off chance that the password has changed since the
115  * start of the run.
116  */
117 static PGconn *
118 _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser)
119 {
121  PGconn *newConn;
122  const char *newdb;
123  const char *newuser;
124  char *password;
125  char passbuf[100];
126  bool new_pass;
127 
128  if (!reqdb)
129  newdb = PQdb(AH->connection);
130  else
131  newdb = reqdb;
132 
133  if (!requser || strlen(requser) == 0)
134  newuser = PQuser(AH->connection);
135  else
136  newuser = requser;
137 
138  pg_log_info("connecting to database \"%s\" as user \"%s\"",
139  newdb, newuser);
140 
141  password = AH->savedPassword;
142 
143  if (AH->promptPassword == TRI_YES && password == NULL)
144  {
145  simple_prompt("Password: ", passbuf, sizeof(passbuf), false);
146  password = passbuf;
147  }
148 
149  initPQExpBuffer(&connstr);
150  appendPQExpBufferStr(&connstr, "dbname=");
151  appendConnStrVal(&connstr, newdb);
152 
153  do
154  {
155  const char *keywords[7];
156  const char *values[7];
157 
158  keywords[0] = "host";
159  values[0] = PQhost(AH->connection);
160  keywords[1] = "port";
161  values[1] = PQport(AH->connection);
162  keywords[2] = "user";
163  values[2] = newuser;
164  keywords[3] = "password";
165  values[3] = password;
166  keywords[4] = "dbname";
167  values[4] = connstr.data;
168  keywords[5] = "fallback_application_name";
169  values[5] = progname;
170  keywords[6] = NULL;
171  values[6] = NULL;
172 
173  new_pass = false;
174  newConn = PQconnectdbParams(keywords, values, true);
175 
176  if (!newConn)
177  fatal("could not reconnect to database");
178 
179  if (PQstatus(newConn) == CONNECTION_BAD)
180  {
181  if (!PQconnectionNeedsPassword(newConn))
182  fatal("could not reconnect to database: %s",
183  PQerrorMessage(newConn));
184  PQfinish(newConn);
185 
186  if (password)
187  fprintf(stderr, "Password incorrect\n");
188 
189  fprintf(stderr, "Connecting to %s as %s\n",
190  newdb, newuser);
191 
192  if (AH->promptPassword != TRI_NO)
193  {
194  simple_prompt("Password: ", passbuf, sizeof(passbuf), false);
195  password = passbuf;
196  }
197  else
198  fatal("connection needs password");
199 
200  new_pass = true;
201  }
202  } while (new_pass);
203 
204  /*
205  * We want to remember connection's actual password, whether or not we got
206  * it by prompting. So we don't just store the password variable.
207  */
208  if (PQconnectionUsedPassword(newConn))
209  {
210  if (AH->savedPassword)
211  free(AH->savedPassword);
212  AH->savedPassword = pg_strdup(PQpass(newConn));
213  }
214 
215  termPQExpBuffer(&connstr);
216 
217  /* check for version mismatch */
219 
220  PQsetNoticeProcessor(newConn, notice_processor, NULL);
221 
222  return newConn;
223 }
224 
225 
226 /*
227  * Make a database connection with the given parameters. The
228  * connection handle is returned, the parameters are stored in AHX.
229  * An interactive password prompt is automatically issued if required.
230  *
231  * Note: it's not really all that sensible to use a single-entry password
232  * cache if the username keeps changing. In current usage, however, the
233  * username never does change, so one savedPassword is sufficient.
234  */
235 void
237  const char *dbname,
238  const char *pghost,
239  const char *pgport,
240  const char *username,
241  trivalue prompt_password)
242 {
243  ArchiveHandle *AH = (ArchiveHandle *) AHX;
244  char *password;
245  char passbuf[100];
246  bool new_pass;
247 
248  if (AH->connection)
249  fatal("already connected to a database");
250 
251  password = AH->savedPassword;
252 
253  if (prompt_password == TRI_YES && password == NULL)
254  {
255  simple_prompt("Password: ", passbuf, sizeof(passbuf), false);
256  password = passbuf;
257  }
258  AH->promptPassword = prompt_password;
259 
260  /*
261  * Start the connection. Loop until we have a password if requested by
262  * backend.
263  */
264  do
265  {
266  const char *keywords[7];
267  const char *values[7];
268 
269  keywords[0] = "host";
270  values[0] = pghost;
271  keywords[1] = "port";
272  values[1] = pgport;
273  keywords[2] = "user";
274  values[2] = username;
275  keywords[3] = "password";
276  values[3] = password;
277  keywords[4] = "dbname";
278  values[4] = dbname;
279  keywords[5] = "fallback_application_name";
280  values[5] = progname;
281  keywords[6] = NULL;
282  values[6] = NULL;
283 
284  new_pass = false;
285  AH->connection = PQconnectdbParams(keywords, values, true);
286 
287  if (!AH->connection)
288  fatal("could not connect to database");
289 
290  if (PQstatus(AH->connection) == CONNECTION_BAD &&
292  password == NULL &&
293  prompt_password != TRI_NO)
294  {
295  PQfinish(AH->connection);
296  simple_prompt("Password: ", passbuf, sizeof(passbuf), false);
297  password = passbuf;
298  new_pass = true;
299  }
300  } while (new_pass);
301 
302  /* check to see that the backend connection was successfully made */
303  if (PQstatus(AH->connection) == CONNECTION_BAD)
304  fatal("connection to database \"%s\" failed: %s",
305  PQdb(AH->connection) ? PQdb(AH->connection) : "",
307 
308  /* Start strict; later phases may override this. */
311 
312  /*
313  * We want to remember connection's actual password, whether or not we got
314  * it by prompting. So we don't just store the password variable.
315  */
316  if (PQconnectionUsedPassword(AH->connection))
317  {
318  if (AH->savedPassword)
319  free(AH->savedPassword);
320  AH->savedPassword = pg_strdup(PQpass(AH->connection));
321  }
322 
323  /* check for version mismatch */
325 
326  PQsetNoticeProcessor(AH->connection, notice_processor, NULL);
327 
328  /* arrange for SIGINT to issue a query cancel on this connection */
329  set_archive_cancel_info(AH, AH->connection);
330 }
331 
332 /*
333  * Close the connection to the database and also cancel off the query if we
334  * have one running.
335  */
336 void
338 {
339  ArchiveHandle *AH = (ArchiveHandle *) AHX;
340  char errbuf[1];
341 
342  if (!AH->connection)
343  return;
344 
345  if (AH->connCancel)
346  {
347  /*
348  * If we have an active query, send a cancel before closing, ignoring
349  * any errors. This is of no use for a normal exit, but might be
350  * helpful during fatal().
351  */
353  (void) PQcancel(AH->connCancel, errbuf, sizeof(errbuf));
354 
355  /*
356  * Prevent signal handler from sending a cancel after this.
357  */
358  set_archive_cancel_info(AH, NULL);
359  }
360 
361  PQfinish(AH->connection);
362  AH->connection = NULL;
363 }
364 
365 PGconn *
367 {
368  ArchiveHandle *AH = (ArchiveHandle *) AHX;
369 
370  return AH->connection;
371 }
372 
373 static void
374 notice_processor(void *arg, const char *message)
375 {
376  pg_log_generic(PG_LOG_INFO, "%s", message);
377 }
378 
379 /* Like fatal(), but with a complaint about a particular query. */
380 static void
381 die_on_query_failure(ArchiveHandle *AH, const char *query)
382 {
383  pg_log_error("query failed: %s",
385  fatal("query was: %s", query);
386 }
387 
388 void
389 ExecuteSqlStatement(Archive *AHX, const char *query)
390 {
391  ArchiveHandle *AH = (ArchiveHandle *) AHX;
392  PGresult *res;
393 
394  res = PQexec(AH->connection, query);
395  if (PQresultStatus(res) != PGRES_COMMAND_OK)
396  die_on_query_failure(AH, query);
397  PQclear(res);
398 }
399 
400 PGresult *
401 ExecuteSqlQuery(Archive *AHX, const char *query, ExecStatusType status)
402 {
403  ArchiveHandle *AH = (ArchiveHandle *) AHX;
404  PGresult *res;
405 
406  res = PQexec(AH->connection, query);
407  if (PQresultStatus(res) != status)
408  die_on_query_failure(AH, query);
409  return res;
410 }
411 
412 /*
413  * Execute an SQL query and verify that we got exactly one row back.
414  */
415 PGresult *
416 ExecuteSqlQueryForSingleRow(Archive *fout, const char *query)
417 {
418  PGresult *res;
419  int ntups;
420 
421  res = ExecuteSqlQuery(fout, query, PGRES_TUPLES_OK);
422 
423  /* Expecting a single result only */
424  ntups = PQntuples(res);
425  if (ntups != 1)
426  fatal(ngettext("query returned %d row instead of one: %s",
427  "query returned %d rows instead of one: %s",
428  ntups),
429  ntups, query);
430 
431  return res;
432 }
433 
434 /*
435  * Convenience function to send a query.
436  * Monitors result to detect COPY statements
437  */
438 static void
439 ExecuteSqlCommand(ArchiveHandle *AH, const char *qry, const char *desc)
440 {
441  PGconn *conn = AH->connection;
442  PGresult *res;
443 
444 #ifdef NOT_USED
445  fprintf(stderr, "Executing: '%s'\n\n", qry);
446 #endif
447  res = PQexec(conn, qry);
448 
449  switch (PQresultStatus(res))
450  {
451  case PGRES_COMMAND_OK:
452  case PGRES_TUPLES_OK:
453  case PGRES_EMPTY_QUERY:
454  /* A-OK */
455  break;
456  case PGRES_COPY_IN:
457  /* Assume this is an expected result */
458  AH->pgCopyIn = true;
459  break;
460  default:
461  /* trouble */
462  warn_or_exit_horribly(AH, "%s: %sCommand was: %s",
463  desc, PQerrorMessage(conn), qry);
464  break;
465  }
466 
467  PQclear(res);
468 }
469 
470 
471 /*
472  * Process non-COPY table data (that is, INSERT commands).
473  *
474  * The commands have been run together as one long string for compressibility,
475  * and we are receiving them in bufferloads with arbitrary boundaries, so we
476  * have to locate command boundaries and save partial commands across calls.
477  * All state must be kept in AH->sqlparse, not in local variables of this
478  * routine. We assume that AH->sqlparse was filled with zeroes when created.
479  *
480  * We have to lex the data to the extent of identifying literals and quoted
481  * identifiers, so that we can recognize statement-terminating semicolons.
482  * We assume that INSERT data will not contain SQL comments, E'' literals,
483  * or dollar-quoted strings, so this is much simpler than a full SQL lexer.
484  *
485  * Note: when restoring from a pre-9.0 dump file, this code is also used to
486  * process BLOB COMMENTS data, which has the same problem of containing
487  * multiple SQL commands that might be split across bufferloads. Fortunately,
488  * that data won't contain anything complicated to lex either.
489  */
490 static void
491 ExecuteSimpleCommands(ArchiveHandle *AH, const char *buf, size_t bufLen)
492 {
493  const char *qry = buf;
494  const char *eos = buf + bufLen;
495 
496  /* initialize command buffer if first time through */
497  if (AH->sqlparse.curCmd == NULL)
499 
500  for (; qry < eos; qry++)
501  {
502  char ch = *qry;
503 
504  /* For neatness, we skip any newlines between commands */
505  if (!(ch == '\n' && AH->sqlparse.curCmd->len == 0))
507 
508  switch (AH->sqlparse.state)
509  {
510  case SQL_SCAN: /* Default state == 0, set in _allocAH */
511  if (ch == ';')
512  {
513  /*
514  * We've found the end of a statement. Send it and reset
515  * the buffer.
516  */
518  "could not execute query");
520  }
521  else if (ch == '\'')
522  {
524  AH->sqlparse.backSlash = false;
525  }
526  else if (ch == '"')
527  {
529  }
530  break;
531 
532  case SQL_IN_SINGLE_QUOTE:
533  /* We needn't handle '' specially */
534  if (ch == '\'' && !AH->sqlparse.backSlash)
535  AH->sqlparse.state = SQL_SCAN;
536  else if (ch == '\\' && !AH->public.std_strings)
538  else
539  AH->sqlparse.backSlash = false;
540  break;
541 
542  case SQL_IN_DOUBLE_QUOTE:
543  /* We needn't handle "" specially */
544  if (ch == '"')
545  AH->sqlparse.state = SQL_SCAN;
546  break;
547  }
548  }
549 }
550 
551 
552 /*
553  * Implement ahwrite() for direct-to-DB restore
554  */
555 int
556 ExecuteSqlCommandBuf(Archive *AHX, const char *buf, size_t bufLen)
557 {
558  ArchiveHandle *AH = (ArchiveHandle *) AHX;
559 
560  if (AH->outputKind == OUTPUT_COPYDATA)
561  {
562  /*
563  * COPY data.
564  *
565  * We drop the data on the floor if libpq has failed to enter COPY
566  * mode; this allows us to behave reasonably when trying to continue
567  * after an error in a COPY command.
568  */
569  if (AH->pgCopyIn &&
570  PQputCopyData(AH->connection, buf, bufLen) <= 0)
571  fatal("error returned by PQputCopyData: %s",
573  }
574  else if (AH->outputKind == OUTPUT_OTHERDATA)
575  {
576  /*
577  * Table data expressed as INSERT commands; or, in old dump files,
578  * BLOB COMMENTS data (which is expressed as COMMENT ON commands).
579  */
580  ExecuteSimpleCommands(AH, buf, bufLen);
581  }
582  else
583  {
584  /*
585  * General SQL commands; we assume that commands will not be split
586  * across calls.
587  *
588  * In most cases the data passed to us will be a null-terminated
589  * string, but if it's not, we have to add a trailing null.
590  */
591  if (buf[bufLen] == '\0')
592  ExecuteSqlCommand(AH, buf, "could not execute query");
593  else
594  {
595  char *str = (char *) pg_malloc(bufLen + 1);
596 
597  memcpy(str, buf, bufLen);
598  str[bufLen] = '\0';
599  ExecuteSqlCommand(AH, str, "could not execute query");
600  free(str);
601  }
602  }
603 
604  return bufLen;
605 }
606 
607 /*
608  * Terminate a COPY operation during direct-to-DB restore
609  */
610 void
611 EndDBCopyMode(Archive *AHX, const char *tocEntryTag)
612 {
613  ArchiveHandle *AH = (ArchiveHandle *) AHX;
614 
615  if (AH->pgCopyIn)
616  {
617  PGresult *res;
618 
619  if (PQputCopyEnd(AH->connection, NULL) <= 0)
620  fatal("error returned by PQputCopyEnd: %s",
622 
623  /* Check command status and return to normal libpq state */
624  res = PQgetResult(AH->connection);
625  if (PQresultStatus(res) != PGRES_COMMAND_OK)
626  warn_or_exit_horribly(AH, "COPY failed for table \"%s\": %s",
627  tocEntryTag, PQerrorMessage(AH->connection));
628  PQclear(res);
629 
630  /* Do this to ensure we've pumped libpq back to idle state */
631  if (PQgetResult(AH->connection) != NULL)
632  pg_log_warning("unexpected extra results during COPY of table \"%s\"",
633  tocEntryTag);
634 
635  AH->pgCopyIn = false;
636  }
637 }
638 
639 void
641 {
642  ArchiveHandle *AH = (ArchiveHandle *) AHX;
643 
644  ExecuteSqlCommand(AH, "BEGIN", "could not start database transaction");
645 }
646 
647 void
649 {
650  ArchiveHandle *AH = (ArchiveHandle *) AHX;
651 
652  ExecuteSqlCommand(AH, "COMMIT", "could not commit database transaction");
653 }
654 
655 void
657 {
658  /*
659  * If we are not restoring to a direct database connection, we have to
660  * guess about how to detect whether the blob exists. Assume new-style.
661  */
662  if (AH->connection == NULL ||
663  PQserverVersion(AH->connection) >= 90000)
664  {
665  ahprintf(AH,
666  "SELECT pg_catalog.lo_unlink(oid) "
667  "FROM pg_catalog.pg_largeobject_metadata "
668  "WHERE oid = '%u';\n",
669  oid);
670  }
671  else
672  {
673  /* Restoring to pre-9.0 server, so do it the old way */
674  ahprintf(AH,
675  "SELECT CASE WHEN EXISTS("
676  "SELECT 1 FROM pg_catalog.pg_largeobject WHERE loid = '%u'"
677  ") THEN pg_catalog.lo_unlink('%u') END;\n",
678  oid, oid);
679  }
680 }
int PQputCopyData(PGconn *conn, const char *buffer, int nbytes)
Definition: fe-exec.c:2317
static char password[100]
Definition: streamutil.c:53
PQExpBuffer curCmd
void EndDBCopyMode(Archive *AHX, const char *tocEntryTag)
Definition: pg_backup_db.c:611
char * PQerrorMessage(const PGconn *conn)
Definition: fe-connect.c:6623
sqlparseState state
int ExecuteSqlCommandBuf(Archive *AHX, const char *buf, size_t bufLen)
Definition: pg_backup_db.c:556
PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)
Definition: fe-connect.c:6799
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3163
const char * PQparameterStatus(const PGconn *conn, const char *paramName)
Definition: fe-connect.c:6588
void * pg_malloc(size_t size)
Definition: fe_memutils.c:47
void termPQExpBuffer(PQExpBuffer str)
Definition: pqexpbuffer.c:131
#define pg_log_error(...)
Definition: logging.h:79
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
Definition: pqexpbuffer.c:369
static void ExecuteSqlCommand(ArchiveHandle *AH, const char *qry, const char *desc)
Definition: pg_backup_db.c:439
void DisconnectDatabase(Archive *AHX)
Definition: pg_backup_db.c:337
static PGconn * _connectDB(ArchiveHandle *AH, const char *newdbname, const char *newUser)
Definition: pg_backup_db.c:118
void warn_or_exit_horribly(ArchiveHandle *AH, const char *fmt,...)
void CommitTransaction(Archive *AHX)
Definition: pg_backup_db.c:648
void appendConnStrVal(PQExpBuffer buf, const char *str)
Definition: string_utils.c:545
void StartTransaction(Archive *AHX)
Definition: pg_backup_db.c:640
void PQfinish(PGconn *conn)
Definition: fe-connect.c:4125
char * PQport(const PGconn *conn)
Definition: fe-connect.c:6542
int PQputCopyEnd(PGconn *conn, const char *errormsg)
Definition: fe-exec.c:2384
ExecStatusType
Definition: libpq-fe.h:84
PGcancel *volatile connCancel
unsigned int Oid
Definition: postgres_ext.h:31
int PQserverVersion(const PGconn *conn)
Definition: fe-connect.c:6613
const char * progname
Definition: pg_standby.c:36
int PQntuples(const PGresult *res)
Definition: fe-exec.c:2769
#define fprintf
Definition: port.h:196
PGconn * GetConnection(Archive *AHX)
Definition: pg_backup_db.c:366
ExecStatusType PQresultStatus(const PGresult *res)
Definition: fe-exec.c:2692
int maxRemoteVersion
Definition: pg_backup.h:191
PGconn * PQconnectdbParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition: fe-connect.c:624
static void die_on_query_failure(ArchiveHandle *AH, const char *query)
Definition: pg_backup_db.c:381
char * PQuser(const PGconn *conn)
Definition: fe-connect.c:6481
PGresult * ExecuteSqlQueryForSingleRow(Archive *fout, const char *query)
Definition: pg_backup_db.c:416
void ConnectDatabase(Archive *AHX, const char *dbname, const char *pghost, const char *pgport, const char *username, trivalue prompt_password)
Definition: pg_backup_db.c:236
bool isStandby
Definition: pg_backup.h:188
PGconn * conn
Definition: streamutil.c:54
static char * buf
Definition: pg_test_fsync.c:67
void simple_prompt(const char *prompt, char *destination, size_t destlen, bool echo)
Definition: sprompt.c:37
char * pg_strdup(const char *in)
Definition: fe_memutils.c:85
char * PQpass(const PGconn *conn)
Definition: fe-connect.c:6489
static void notice_processor(void *arg, const char *message)
Definition: pg_backup_db.c:374
sqlparseInfo sqlparse
int ahprintf(ArchiveHandle *AH, const char *fmt,...)
PGTransactionStatusType PQtransactionStatus(const PGconn *conn)
Definition: fe-connect.c:6578
char * pghost
Definition: pgbench.c:243
trivalue
Definition: vacuumlo.c:33
#define ngettext(s, p, n)
Definition: c.h:1134
PQExpBuffer createPQExpBuffer(void)
Definition: pqexpbuffer.c:74
void appendPQExpBufferChar(PQExpBuffer str, char ch)
Definition: pqexpbuffer.c:380
static char * username
Definition: initdb.c:133
static void ExecuteSimpleCommands(ArchiveHandle *AH, const char *buf, size_t bufLen)
Definition: pg_backup_db.c:491
char * PQhost(const PGconn *conn)
Definition: fe-connect.c:6506
void PQclear(PGresult *res)
Definition: fe-exec.c:694
void pg_log_generic(enum pg_log_level level, const char *pg_restrict fmt,...)
Definition: logging.c:126
#define free(a)
Definition: header.h:65
void ReconnectToServer(ArchiveHandle *AH, const char *dbname, const char *username)
Definition: pg_backup_db.c:79
char * PQdb(const PGconn *conn)
Definition: fe-connect.c:6473
void ExecuteSqlStatement(Archive *AHX, const char *query)
Definition: pg_backup_db.c:389
char * dbname
Definition: streamutil.c:50
#define fatal(...)
#define ALWAYS_SECURE_SEARCH_PATH_SQL
Definition: connect.h:25
ArchiverOutput outputKind
static Datum values[MAXATTR]
Definition: bootstrap.c:167
static void _check_database_version(ArchiveHandle *AH)
Definition: pg_backup_db.c:33
int PQconnectionUsedPassword(const PGconn *conn)
Definition: fe-connect.c:6672
int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)
Definition: fe-connect.c:4401
char * remoteVersionStr
Definition: pg_backup.h:186
int PQconnectionNeedsPassword(const PGconn *conn)
Definition: fe-connect.c:6657
void set_archive_cancel_info(ArchiveHandle *AH, PGconn *conn)
Definition: parallel.c:739
PGresult * PQexec(PGconn *conn, const char *query)
Definition: fe-exec.c:1939
void * arg
void DropBlobIfExists(ArchiveHandle *AH, Oid oid)
Definition: pg_backup_db.c:656
#define pg_log_warning(...)
Definition: pgfnames.c:24
void resetPQExpBuffer(PQExpBuffer str)
Definition: pqexpbuffer.c:148
static void static void status(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:226
ConnStatusType PQstatus(const PGconn *conn)
Definition: fe-connect.c:6570
char * pgport
Definition: pgbench.c:244
PGresult * PQgetResult(PGconn *conn)
Definition: fe-exec.c:1778
void initPQExpBuffer(PQExpBuffer str)
Definition: pqexpbuffer.c:92
#define pg_log_info(...)
Definition: logging.h:87
bool std_strings
Definition: pg_backup.h:198
PGresult * ExecuteSqlQuery(Archive *AHX, const char *query, ExecStatusType status)
Definition: pg_backup_db.c:401
int remoteVersion
Definition: pg_backup.h:187
static char * connstr
Definition: pg_dumpall.c:61