35 const char *remoteversion_str;
41 if (remoteversion == 0 || !remoteversion_str)
42 pg_fatal(
"could not get \"server_version\" from libpq");
49 if (remoteversion != PG_VERSION_NUM
50 && (remoteversion < AH->
public.minRemoteVersion ||
53 pg_log_error(
"aborting because of server version mismatch");
55 remoteversion_str,
progname, PG_VERSION);
64 "SELECT pg_catalog.pg_is_in_recovery()");
120 pg_fatal(
"already connected to a database");
136 const char *keywords[8];
145 keywords[
i] =
"host";
147 keywords[
i] =
"port";
149 keywords[
i] =
"user";
151 keywords[
i] =
"password";
153 keywords[
i] =
"dbname";
157 keywords[
i] =
"dbname";
160 keywords[
i] =
"fallback_application_name";
170 pg_fatal(
"could not connect to database");
175 prompt_password !=
TRI_NO)
316 "query returned %d rows instead of one: %s",
334 fprintf(stderr,
"Executing: '%s'\n\n", qry);
382 const char *qry =
buf;
383 const char *eos =
buf + bufLen;
389 for (; qry < eos; qry++)
407 "could not execute query");
460 pg_fatal(
"error returned by PQputCopyData: %s",
480 if (
buf[bufLen] ==
'\0')
509 pg_fatal(
"error returned by PQputCopyEnd: %s",
521 pg_log_warning(
"unexpected extra results during COPY of table \"%s\"",
553 const char *cmdBegin,
const char *cmdEnd)
562 while ((en = strchr(st,
'\n')) != NULL)
565 ahprintf(AH,
"%s%s%s;\n", cmdBegin, st, cmdEnd);
578 ahprintf(AH,
"COMMIT;\nBEGIN;\n\n");
610 Assert(strcmp(blobte->
desc,
"BLOB METADATA") == 0);
631 inquotes = !inquotes;
638 if (strncmp(en,
"LARGE OBJECT ", 13) == 0)
642 Assert(isdigit((
unsigned char) *en));
645 while (isdigit((
unsigned char) *en))
660 while (isspace((
unsigned char) *en))
676 "SELECT pg_catalog.lo_unlink(oid) "
677 "FROM pg_catalog.pg_largeobject_metadata "
678 "WHERE oid = '%u';\n",
void set_archive_cancel_info(ArchiveHandle *AH, PGconn *conn)
static Datum values[MAXATTR]
#define ngettext(s, p, n)
#define Assert(condition)
#define ALWAYS_SECURE_SEARCH_PATH_SQL
static void PGresult * res
int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)
const char * PQparameterStatus(const PGconn *conn, const char *paramName)
int PQserverVersion(const PGconn *conn)
PGconn * PQconnectdbParams(const char *const *keywords, const char *const *values, int expand_dbname)
PGTransactionStatusType PQtransactionStatus(const PGconn *conn)
int PQconnectionUsedPassword(const PGconn *conn)
int PQconnectionNeedsPassword(const PGconn *conn)
char * PQerrorMessage(const PGconn *conn)
ConnStatusType PQstatus(const PGconn *conn)
void PQfinish(PGconn *conn)
char * PQpass(const PGconn *conn)
PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)
ExecStatusType PQresultStatus(const PGresult *res)
int PQputCopyEnd(PGconn *conn, const char *errormsg)
int PQntuples(const PGresult *res)
int PQputCopyData(PGconn *conn, const char *buffer, int nbytes)
PGresult * PQexec(PGconn *conn, const char *query)
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
PGresult * PQgetResult(PGconn *conn)
char * pg_strdup(const char *in)
void * pg_malloc(size_t size)
#define pg_log_error(...)
#define pg_log_error_detail(...)
void warn_or_exit_horribly(ArchiveHandle *AH, const char *fmt,...)
TocEntry * getTocEntryByDumpId(ArchiveHandle *AH, DumpId id)
int ahprintf(ArchiveHandle *AH, const char *fmt,...)
void ConnectDatabase(Archive *AHX, const ConnParams *cparams, bool isReconnect)
void ExecuteSqlStatement(Archive *AHX, const char *query)
void IssueACLPerBlob(ArchiveHandle *AH, TocEntry *te)
void EndDBCopyMode(Archive *AHX, const char *tocEntryTag)
static void die_on_query_failure(ArchiveHandle *AH, const char *query)
PGresult * ExecuteSqlQuery(Archive *AHX, const char *query, ExecStatusType status)
static void _check_database_version(ArchiveHandle *AH)
PGconn * GetConnection(Archive *AHX)
void DropLOIfExists(ArchiveHandle *AH, Oid oid)
void ReconnectToServer(ArchiveHandle *AH, const char *dbname)
static void ExecuteSimpleCommands(ArchiveHandle *AH, const char *buf, size_t bufLen)
void StartTransaction(Archive *AHX)
void IssueCommandPerBlob(ArchiveHandle *AH, TocEntry *te, const char *cmdBegin, const char *cmdEnd)
int ExecuteSqlCommandBuf(Archive *AHX, const char *buf, size_t bufLen)
static void ExecuteSqlCommand(ArchiveHandle *AH, const char *qry, const char *desc)
static void notice_processor(void *arg, const char *message)
void DisconnectDatabase(Archive *AHX)
void CommitTransaction(Archive *AHX)
PGresult * ExecuteSqlQueryForSingleRow(Archive *fout, const char *query)
#define pg_log_warning(...)
PQExpBuffer createPQExpBuffer(void)
void resetPQExpBuffer(PQExpBuffer str)
void appendPQExpBufferChar(PQExpBuffer str, char ch)
char * simple_prompt(const char *prompt, bool echo)
PGcancel *volatile connCancel
ArchiverOutput outputKind
char * archiveRemoteVersion