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 "common/connect.h"
21 #include "common/string.h"
22 #include "dumputils.h"
23 #include "fe_utils/string_utils.h"
24 #include "parallel.h"
25 #include "pg_backup_archiver.h"
26 #include "pg_backup_db.h"
27 #include "pg_backup_utils.h"
28 
29 static void _check_database_version(ArchiveHandle *AH);
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.
76  */
77 void
79 {
80  PGconn *oldConn = AH->connection;
81  RestoreOptions *ropt = AH->public.ropt;
82 
83  /*
84  * Save the dbname, if given, in override_dbname so that it will also
85  * affect any later reconnection attempt.
86  */
87  if (dbname)
88  ropt->cparams.override_dbname = pg_strdup(dbname);
89 
90  /*
91  * Note: we want to establish the new connection, and in particular update
92  * ArchiveHandle's connCancel, before closing old connection. Otherwise
93  * an ill-timed SIGINT could try to access a dead connection.
94  */
95  AH->connection = NULL; /* dodge error check in ConnectDatabase */
96 
97  ConnectDatabase((Archive *) AH, &ropt->cparams, true);
98 
99  PQfinish(oldConn);
100 }
101 
102 /*
103  * Make, or remake, a database connection with the given parameters.
104  *
105  * The resulting connection handle is stored in AHX->connection.
106  *
107  * An interactive password prompt is automatically issued if required.
108  * We store the results of that in AHX->savedPassword.
109  * Note: it's not really all that sensible to use a single-entry password
110  * cache if the username keeps changing. In current usage, however, the
111  * username never does change, so one savedPassword is sufficient.
112  */
113 void
115  const ConnParams *cparams,
116  bool isReconnect)
117 {
118  ArchiveHandle *AH = (ArchiveHandle *) AHX;
119  trivalue prompt_password;
120  char *password;
121  bool new_pass;
122 
123  if (AH->connection)
124  fatal("already connected to a database");
125 
126  /* Never prompt for a password during a reconnection */
127  prompt_password = isReconnect ? TRI_NO : cparams->promptPassword;
128 
129  password = AH->savedPassword;
130 
131  if (prompt_password == TRI_YES && password == NULL)
132  password = simple_prompt("Password: ", false);
133 
134  /*
135  * Start the connection. Loop until we have a password if requested by
136  * backend.
137  */
138  do
139  {
140  const char *keywords[8];
141  const char *values[8];
142  int i = 0;
143 
144  /*
145  * If dbname is a connstring, its entries can override the other
146  * values obtained from cparams; but in turn, override_dbname can
147  * override the dbname component of it.
148  */
149  keywords[i] = "host";
150  values[i++] = cparams->pghost;
151  keywords[i] = "port";
152  values[i++] = cparams->pgport;
153  keywords[i] = "user";
154  values[i++] = cparams->username;
155  keywords[i] = "password";
156  values[i++] = password;
157  keywords[i] = "dbname";
158  values[i++] = cparams->dbname;
159  if (cparams->override_dbname)
160  {
161  keywords[i] = "dbname";
162  values[i++] = cparams->override_dbname;
163  }
164  keywords[i] = "fallback_application_name";
165  values[i++] = progname;
166  keywords[i] = NULL;
167  values[i++] = NULL;
168  Assert(i <= lengthof(keywords));
169 
170  new_pass = false;
171  AH->connection = PQconnectdbParams(keywords, values, true);
172 
173  if (!AH->connection)
174  fatal("could not connect to database");
175 
176  if (PQstatus(AH->connection) == CONNECTION_BAD &&
178  password == NULL &&
179  prompt_password != TRI_NO)
180  {
181  PQfinish(AH->connection);
182  password = simple_prompt("Password: ", false);
183  new_pass = true;
184  }
185  } while (new_pass);
186 
187  /* check to see that the backend connection was successfully made */
188  if (PQstatus(AH->connection) == CONNECTION_BAD)
189  {
190  if (isReconnect)
191  fatal("reconnection to database \"%s\" failed: %s",
192  PQdb(AH->connection) ? PQdb(AH->connection) : "",
194  else
195  fatal("connection to database \"%s\" failed: %s",
196  PQdb(AH->connection) ? PQdb(AH->connection) : "",
198  }
199 
200  /* Start strict; later phases may override this. */
203 
204  if (password && password != AH->savedPassword)
205  free(password);
206 
207  /*
208  * We want to remember connection's actual password, whether or not we got
209  * it by prompting. So we don't just store the password variable.
210  */
211  if (PQconnectionUsedPassword(AH->connection))
212  {
213  if (AH->savedPassword)
214  free(AH->savedPassword);
215  AH->savedPassword = pg_strdup(PQpass(AH->connection));
216  }
217 
218  /* check for version mismatch */
220 
221  PQsetNoticeProcessor(AH->connection, notice_processor, NULL);
222 
223  /* arrange for SIGINT to issue a query cancel on this connection */
224  set_archive_cancel_info(AH, AH->connection);
225 }
226 
227 /*
228  * Close the connection to the database and also cancel off the query if we
229  * have one running.
230  */
231 void
233 {
234  ArchiveHandle *AH = (ArchiveHandle *) AHX;
235  char errbuf[1];
236 
237  if (!AH->connection)
238  return;
239 
240  if (AH->connCancel)
241  {
242  /*
243  * If we have an active query, send a cancel before closing, ignoring
244  * any errors. This is of no use for a normal exit, but might be
245  * helpful during fatal().
246  */
248  (void) PQcancel(AH->connCancel, errbuf, sizeof(errbuf));
249 
250  /*
251  * Prevent signal handler from sending a cancel after this.
252  */
253  set_archive_cancel_info(AH, NULL);
254  }
255 
256  PQfinish(AH->connection);
257  AH->connection = NULL;
258 }
259 
260 PGconn *
262 {
263  ArchiveHandle *AH = (ArchiveHandle *) AHX;
264 
265  return AH->connection;
266 }
267 
268 static void
269 notice_processor(void *arg, const char *message)
270 {
271  pg_log_generic(PG_LOG_INFO, "%s", message);
272 }
273 
274 /* Like fatal(), but with a complaint about a particular query. */
275 static void
276 die_on_query_failure(ArchiveHandle *AH, const char *query)
277 {
278  pg_log_error("query failed: %s",
280  fatal("query was: %s", query);
281 }
282 
283 void
284 ExecuteSqlStatement(Archive *AHX, const char *query)
285 {
286  ArchiveHandle *AH = (ArchiveHandle *) AHX;
287  PGresult *res;
288 
289  res = PQexec(AH->connection, query);
290  if (PQresultStatus(res) != PGRES_COMMAND_OK)
291  die_on_query_failure(AH, query);
292  PQclear(res);
293 }
294 
295 PGresult *
296 ExecuteSqlQuery(Archive *AHX, const char *query, ExecStatusType status)
297 {
298  ArchiveHandle *AH = (ArchiveHandle *) AHX;
299  PGresult *res;
300 
301  res = PQexec(AH->connection, query);
302  if (PQresultStatus(res) != status)
303  die_on_query_failure(AH, query);
304  return res;
305 }
306 
307 /*
308  * Execute an SQL query and verify that we got exactly one row back.
309  */
310 PGresult *
311 ExecuteSqlQueryForSingleRow(Archive *fout, const char *query)
312 {
313  PGresult *res;
314  int ntups;
315 
316  res = ExecuteSqlQuery(fout, query, PGRES_TUPLES_OK);
317 
318  /* Expecting a single result only */
319  ntups = PQntuples(res);
320  if (ntups != 1)
321  fatal(ngettext("query returned %d row instead of one: %s",
322  "query returned %d rows instead of one: %s",
323  ntups),
324  ntups, query);
325 
326  return res;
327 }
328 
329 /*
330  * Convenience function to send a query.
331  * Monitors result to detect COPY statements
332  */
333 static void
334 ExecuteSqlCommand(ArchiveHandle *AH, const char *qry, const char *desc)
335 {
336  PGconn *conn = AH->connection;
337  PGresult *res;
338 
339 #ifdef NOT_USED
340  fprintf(stderr, "Executing: '%s'\n\n", qry);
341 #endif
342  res = PQexec(conn, qry);
343 
344  switch (PQresultStatus(res))
345  {
346  case PGRES_COMMAND_OK:
347  case PGRES_TUPLES_OK:
348  case PGRES_EMPTY_QUERY:
349  /* A-OK */
350  break;
351  case PGRES_COPY_IN:
352  /* Assume this is an expected result */
353  AH->pgCopyIn = true;
354  break;
355  default:
356  /* trouble */
357  warn_or_exit_horribly(AH, "%s: %sCommand was: %s",
358  desc, PQerrorMessage(conn), qry);
359  break;
360  }
361 
362  PQclear(res);
363 }
364 
365 
366 /*
367  * Process non-COPY table data (that is, INSERT commands).
368  *
369  * The commands have been run together as one long string for compressibility,
370  * and we are receiving them in bufferloads with arbitrary boundaries, so we
371  * have to locate command boundaries and save partial commands across calls.
372  * All state must be kept in AH->sqlparse, not in local variables of this
373  * routine. We assume that AH->sqlparse was filled with zeroes when created.
374  *
375  * We have to lex the data to the extent of identifying literals and quoted
376  * identifiers, so that we can recognize statement-terminating semicolons.
377  * We assume that INSERT data will not contain SQL comments, E'' literals,
378  * or dollar-quoted strings, so this is much simpler than a full SQL lexer.
379  *
380  * Note: when restoring from a pre-9.0 dump file, this code is also used to
381  * process BLOB COMMENTS data, which has the same problem of containing
382  * multiple SQL commands that might be split across bufferloads. Fortunately,
383  * that data won't contain anything complicated to lex either.
384  */
385 static void
386 ExecuteSimpleCommands(ArchiveHandle *AH, const char *buf, size_t bufLen)
387 {
388  const char *qry = buf;
389  const char *eos = buf + bufLen;
390 
391  /* initialize command buffer if first time through */
392  if (AH->sqlparse.curCmd == NULL)
394 
395  for (; qry < eos; qry++)
396  {
397  char ch = *qry;
398 
399  /* For neatness, we skip any newlines between commands */
400  if (!(ch == '\n' && AH->sqlparse.curCmd->len == 0))
402 
403  switch (AH->sqlparse.state)
404  {
405  case SQL_SCAN: /* Default state == 0, set in _allocAH */
406  if (ch == ';')
407  {
408  /*
409  * We've found the end of a statement. Send it and reset
410  * the buffer.
411  */
413  "could not execute query");
415  }
416  else if (ch == '\'')
417  {
419  AH->sqlparse.backSlash = false;
420  }
421  else if (ch == '"')
422  {
424  }
425  break;
426 
427  case SQL_IN_SINGLE_QUOTE:
428  /* We needn't handle '' specially */
429  if (ch == '\'' && !AH->sqlparse.backSlash)
430  AH->sqlparse.state = SQL_SCAN;
431  else if (ch == '\\' && !AH->public.std_strings)
433  else
434  AH->sqlparse.backSlash = false;
435  break;
436 
437  case SQL_IN_DOUBLE_QUOTE:
438  /* We needn't handle "" specially */
439  if (ch == '"')
440  AH->sqlparse.state = SQL_SCAN;
441  break;
442  }
443  }
444 }
445 
446 
447 /*
448  * Implement ahwrite() for direct-to-DB restore
449  */
450 int
451 ExecuteSqlCommandBuf(Archive *AHX, const char *buf, size_t bufLen)
452 {
453  ArchiveHandle *AH = (ArchiveHandle *) AHX;
454 
455  if (AH->outputKind == OUTPUT_COPYDATA)
456  {
457  /*
458  * COPY data.
459  *
460  * We drop the data on the floor if libpq has failed to enter COPY
461  * mode; this allows us to behave reasonably when trying to continue
462  * after an error in a COPY command.
463  */
464  if (AH->pgCopyIn &&
465  PQputCopyData(AH->connection, buf, bufLen) <= 0)
466  fatal("error returned by PQputCopyData: %s",
468  }
469  else if (AH->outputKind == OUTPUT_OTHERDATA)
470  {
471  /*
472  * Table data expressed as INSERT commands; or, in old dump files,
473  * BLOB COMMENTS data (which is expressed as COMMENT ON commands).
474  */
475  ExecuteSimpleCommands(AH, buf, bufLen);
476  }
477  else
478  {
479  /*
480  * General SQL commands; we assume that commands will not be split
481  * across calls.
482  *
483  * In most cases the data passed to us will be a null-terminated
484  * string, but if it's not, we have to add a trailing null.
485  */
486  if (buf[bufLen] == '\0')
487  ExecuteSqlCommand(AH, buf, "could not execute query");
488  else
489  {
490  char *str = (char *) pg_malloc(bufLen + 1);
491 
492  memcpy(str, buf, bufLen);
493  str[bufLen] = '\0';
494  ExecuteSqlCommand(AH, str, "could not execute query");
495  free(str);
496  }
497  }
498 
499  return bufLen;
500 }
501 
502 /*
503  * Terminate a COPY operation during direct-to-DB restore
504  */
505 void
506 EndDBCopyMode(Archive *AHX, const char *tocEntryTag)
507 {
508  ArchiveHandle *AH = (ArchiveHandle *) AHX;
509 
510  if (AH->pgCopyIn)
511  {
512  PGresult *res;
513 
514  if (PQputCopyEnd(AH->connection, NULL) <= 0)
515  fatal("error returned by PQputCopyEnd: %s",
517 
518  /* Check command status and return to normal libpq state */
519  res = PQgetResult(AH->connection);
520  if (PQresultStatus(res) != PGRES_COMMAND_OK)
521  warn_or_exit_horribly(AH, "COPY failed for table \"%s\": %s",
522  tocEntryTag, PQerrorMessage(AH->connection));
523  PQclear(res);
524 
525  /* Do this to ensure we've pumped libpq back to idle state */
526  if (PQgetResult(AH->connection) != NULL)
527  pg_log_warning("unexpected extra results during COPY of table \"%s\"",
528  tocEntryTag);
529 
530  AH->pgCopyIn = false;
531  }
532 }
533 
534 /*
535  * Does LOCK TABLE work on non-table relations on this server?
536  *
537  * Note: assumes it is called out of any transaction
538  */
539 bool
541 {
542  ArchiveHandle *AH = (ArchiveHandle *) AHX;
543  PGresult *res;
544  char *sqlstate;
545  bool retval;
546 
547  if (AHX->remoteVersion >= 140000)
548  return true;
549  else if (AHX->remoteVersion < 90500)
550  return false;
551 
552  StartTransaction(AHX);
553 
554  /*
555  * Try a LOCK TABLE on a well-known non-table catalog; WRONG_OBJECT_TYPE
556  * tells us that this server doesn't support locking non-table rels, while
557  * LOCK_NOT_AVAILABLE and INSUFFICIENT_PRIVILEGE tell us that it does.
558  * Report anything else as a fatal problem.
559  */
560 #define ERRCODE_INSUFFICIENT_PRIVILEGE "42501"
561 #define ERRCODE_WRONG_OBJECT_TYPE "42809"
562 #define ERRCODE_LOCK_NOT_AVAILABLE "55P03"
563  res = PQexec(AH->connection,
564  "LOCK TABLE pg_catalog.pg_class_tblspc_relfilenode_index IN ACCESS SHARE MODE NOWAIT");
565  switch (PQresultStatus(res))
566  {
567  case PGRES_COMMAND_OK:
568  retval = true;
569  break;
570  case PGRES_FATAL_ERROR:
571  sqlstate = PQresultErrorField(res, PG_DIAG_SQLSTATE);
572  if (strcmp(sqlstate, ERRCODE_WRONG_OBJECT_TYPE) == 0)
573  {
574  retval = false;
575  break;
576  }
577  else if (strcmp(sqlstate, ERRCODE_LOCK_NOT_AVAILABLE) == 0 ||
578  strcmp(sqlstate, ERRCODE_INSUFFICIENT_PRIVILEGE) == 0)
579  {
580  retval = true;
581  break;
582  }
583  /* else, falls through */
584  default:
585  warn_or_exit_horribly(AH, "LOCK TABLE failed for \"%s\": %s",
586  "pg_catalog.pg_class_tblspc_relfilenode_index",
588  retval = false; /* not reached */
589  break;
590  }
591  PQclear(res);
592 
593  CommitTransaction(AHX);
594 
595  return retval;
596 }
597 
598 void
600 {
601  ArchiveHandle *AH = (ArchiveHandle *) AHX;
602 
603  ExecuteSqlCommand(AH, "BEGIN", "could not start database transaction");
604 }
605 
606 void
608 {
609  ArchiveHandle *AH = (ArchiveHandle *) AHX;
610 
611  ExecuteSqlCommand(AH, "COMMIT", "could not commit database transaction");
612 }
613 
614 void
616 {
617  /*
618  * If we are not restoring to a direct database connection, we have to
619  * guess about how to detect whether the blob exists. Assume new-style.
620  */
621  if (AH->connection == NULL ||
622  PQserverVersion(AH->connection) >= 90000)
623  {
624  ahprintf(AH,
625  "SELECT pg_catalog.lo_unlink(oid) "
626  "FROM pg_catalog.pg_largeobject_metadata "
627  "WHERE oid = '%u';\n",
628  oid);
629  }
630  else
631  {
632  /* Restoring to pre-9.0 server, so do it the old way */
633  ahprintf(AH,
634  "SELECT CASE WHEN EXISTS("
635  "SELECT 1 FROM pg_catalog.pg_largeobject WHERE loid = '%u'"
636  ") THEN pg_catalog.lo_unlink('%u') END;\n",
637  oid, oid);
638  }
639 }
int PQputCopyData(PGconn *conn, const char *buffer, int nbytes)
Definition: fe-exec.c:2317
void ReconnectToServer(ArchiveHandle *AH, const char *dbname)
Definition: pg_backup_db.c:78
PQExpBuffer curCmd
void EndDBCopyMode(Archive *AHX, const char *tocEntryTag)
Definition: pg_backup_db.c:506
char * PQerrorMessage(const PGconn *conn)
Definition: fe-connect.c:6669
sqlparseState state
int ExecuteSqlCommandBuf(Archive *AHX, const char *buf, size_t bufLen)
Definition: pg_backup_db.c:451
PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)
Definition: fe-connect.c:6845
char * pgport
Definition: pg_backup.h:66
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:6634
void * pg_malloc(size_t size)
Definition: fe_memutils.c:47
RestoreOptions * ropt
Definition: pg_backup.h:191
#define pg_log_error(...)
Definition: logging.h:80
static void ExecuteSqlCommand(ArchiveHandle *AH, const char *qry, const char *desc)
Definition: pg_backup_db.c:334
void DisconnectDatabase(Archive *AHX)
Definition: pg_backup_db.c:232
void warn_or_exit_horribly(ArchiveHandle *AH, const char *fmt,...)
void CommitTransaction(Archive *AHX)
Definition: pg_backup_db.c:607
void StartTransaction(Archive *AHX)
Definition: pg_backup_db.c:599
void PQfinish(PGconn *conn)
Definition: fe-connect.c:4174
int PQputCopyEnd(PGconn *conn, const char *errormsg)
Definition: fe-exec.c:2384
char * simple_prompt(const char *prompt, bool echo)
Definition: sprompt.c:38
ExecStatusType
Definition: libpq-fe.h:84
#define lengthof(array)
Definition: c.h:676
PGcancel *volatile connCancel
unsigned int Oid
Definition: postgres_ext.h:31
int PQserverVersion(const PGconn *conn)
Definition: fe-connect.c:6659
const char * progname
Definition: pg_standby.c:36
int PQntuples(const PGresult *res)
Definition: fe-exec.c:2769
#define PG_DIAG_SQLSTATE
Definition: postgres_ext.h:57
#define fprintf
Definition: port.h:219
PGconn * GetConnection(Archive *AHX)
Definition: pg_backup_db.c:261
ExecStatusType PQresultStatus(const PGresult *res)
Definition: fe-exec.c:2692
int maxRemoteVersion
Definition: pg_backup.h:199
PGconn * PQconnectdbParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition: fe-connect.c:647
static void die_on_query_failure(ArchiveHandle *AH, const char *query)
Definition: pg_backup_db.c:276
trivalue promptPassword
Definition: pg_backup.h:69
#define ERRCODE_LOCK_NOT_AVAILABLE
char * dbname
Definition: pg_backup.h:65
PGresult * ExecuteSqlQueryForSingleRow(Archive *fout, const char *query)
Definition: pg_backup_db.c:311
bool isStandby
Definition: pg_backup.h:196
#define ERRCODE_WRONG_OBJECT_TYPE
#define ERRCODE_INSUFFICIENT_PRIVILEGE
PGconn * conn
Definition: streamutil.c:54
static char * buf
Definition: pg_test_fsync.c:68
char * pg_strdup(const char *in)
Definition: fe_memutils.c:85
char * PQpass(const PGconn *conn)
Definition: fe-connect.c:6535
static char * password
Definition: streamutil.c:53
static void notice_processor(void *arg, const char *message)
Definition: pg_backup_db.c:269
sqlparseInfo sqlparse
char * override_dbname
Definition: pg_backup.h:72
ConnParams cparams
Definition: pg_backup.h:124
int ahprintf(ArchiveHandle *AH, const char *fmt,...)
char * pghost
Definition: pg_backup.h:67
PGTransactionStatusType PQtransactionStatus(const PGconn *conn)
Definition: fe-connect.c:6624
char * username
Definition: pg_backup.h:68
trivalue
Definition: vacuumlo.c:34
#define ngettext(s, p, n)
Definition: c.h:1124
PQExpBuffer createPQExpBuffer(void)
Definition: pqexpbuffer.c:74
void ConnectDatabase(Archive *AHX, const ConnParams *cparams, bool isReconnect)
Definition: pg_backup_db.c:114
void appendPQExpBufferChar(PQExpBuffer str, char ch)
Definition: pqexpbuffer.c:380
static void ExecuteSimpleCommands(ArchiveHandle *AH, const char *buf, size_t bufLen)
Definition: pg_backup_db.c:386
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:197
#define free(a)
Definition: header.h:65
char * PQdb(const PGconn *conn)
Definition: fe-connect.c:6519
char * PQresultErrorField(const PGresult *res, int fieldcode)
Definition: fe-exec.c:2754
void ExecuteSqlStatement(Archive *AHX, const char *query)
Definition: pg_backup_db.c:284
#define Assert(condition)
Definition: c.h:746
char * dbname
Definition: streamutil.c:51
#define fatal(...)
#define ALWAYS_SECURE_SEARCH_PATH_SQL
Definition: connect.h:25
ArchiverOutput outputKind
bool IsLockTableGeneric(Archive *AHX)
Definition: pg_backup_db.c:540
static Datum values[MAXATTR]
Definition: bootstrap.c:165
static void _check_database_version(ArchiveHandle *AH)
Definition: pg_backup_db.c:33
int PQconnectionUsedPassword(const PGconn *conn)
Definition: fe-connect.c:6718
int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)
Definition: fe-connect.c:4450
char * remoteVersionStr
Definition: pg_backup.h:194
int PQconnectionNeedsPassword(const PGconn *conn)
Definition: fe-connect.c:6703
void set_archive_cancel_info(ArchiveHandle *AH, PGconn *conn)
Definition: parallel.c:735
int i
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:615
#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:227
ConnStatusType PQstatus(const PGconn *conn)
Definition: fe-connect.c:6616
PGresult * PQgetResult(PGconn *conn)
Definition: fe-exec.c:1778
bool std_strings
Definition: pg_backup.h:208
PGresult * ExecuteSqlQuery(Archive *AHX, const char *query, ExecStatusType status)
Definition: pg_backup_db.c:296
int remoteVersion
Definition: pg_backup.h:195