diff options
Diffstat (limited to 'src/bin/pg_dump/pg_backup_db.c')
-rw-r--r-- | src/bin/pg_dump/pg_backup_db.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c index 4d1d14f19b1..07313f40df5 100644 --- a/src/bin/pg_dump/pg_backup_db.c +++ b/src/bin/pg_dump/pg_backup_db.c @@ -9,11 +9,12 @@ * *------------------------------------------------------------------------- */ +#include "postgres_fe.h" +#include "dumputils.h" +#include "pg_backup_archiver.h" #include "pg_backup_db.h" #include "pg_backup_utils.h" -#include "dumputils.h" -#include "parallel.h" #include <unistd.h> #include <ctype.h> @@ -217,7 +218,7 @@ ConnectDatabase(Archive *AHX, const char *pghost, const char *pgport, const char *username, - enum trivalue prompt_password) + trivalue prompt_password) { ArchiveHandle *AH = (ArchiveHandle *) AHX; char *password = AH->savedPassword; @@ -500,8 +501,10 @@ ExecuteSimpleCommands(ArchiveHandle *AH, const char *buf, size_t bufLen) * Implement ahwrite() for direct-to-DB restore */ int -ExecuteSqlCommandBuf(ArchiveHandle *AH, const char *buf, size_t bufLen) +ExecuteSqlCommandBuf(Archive *AHX, const char *buf, size_t bufLen) { + ArchiveHandle *AH = (ArchiveHandle *) AHX; + if (AH->outputKind == OUTPUT_COPYDATA) { /* @@ -553,8 +556,10 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, const char *buf, size_t bufLen) * Terminate a COPY operation during direct-to-DB restore */ void -EndDBCopyMode(ArchiveHandle *AH, TocEntry *te) +EndDBCopyMode(Archive *AHX, const char *tocEntryTag) { + ArchiveHandle *AH = (ArchiveHandle *) AHX; + if (AH->pgCopyIn) { PGresult *res; @@ -567,7 +572,7 @@ EndDBCopyMode(ArchiveHandle *AH, TocEntry *te) res = PQgetResult(AH->connection); if (PQresultStatus(res) != PGRES_COMMAND_OK) warn_or_exit_horribly(AH, modulename, "COPY failed for table \"%s\": %s", - te->tag, PQerrorMessage(AH->connection)); + tocEntryTag, PQerrorMessage(AH->connection)); PQclear(res); AH->pgCopyIn = false; @@ -575,14 +580,18 @@ EndDBCopyMode(ArchiveHandle *AH, TocEntry *te) } void -StartTransaction(ArchiveHandle *AH) +StartTransaction(Archive *AHX) { + ArchiveHandle *AH = (ArchiveHandle *) AHX; + ExecuteSqlCommand(AH, "BEGIN", "could not start database transaction"); } void -CommitTransaction(ArchiveHandle *AH) +CommitTransaction(Archive *AHX) { + ArchiveHandle *AH = (ArchiveHandle *) AHX; + ExecuteSqlCommand(AH, "COMMIT", "could not commit database transaction"); } |