Repair --single-transaction patch so it handles blobs correctly.

Simon Riggs
This commit is contained in:
Tom Lane 2006-02-14 23:30:43 +00:00
parent 2d7f694729
commit 0ad14ebc8d
1 changed files with 27 additions and 11 deletions

View File

@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.124 2006/02/13 21:30:19 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.125 2006/02/14 23:30:43 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -214,7 +214,12 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
dumpTimestamp(AH, "Started on", AH->createDate); dumpTimestamp(AH, "Started on", AH->createDate);
if (ropt->single_txn) if (ropt->single_txn)
ahprintf(AH, "BEGIN;\n\n"); {
if (AH->connection)
StartTransaction(AH);
else
ahprintf(AH, "BEGIN;\n\n");
}
/* /*
* Establish important parameter values right away. * Establish important parameter values right away.
@ -377,7 +382,12 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
} }
if (ropt->single_txn) if (ropt->single_txn)
ahprintf(AH, "COMMIT;\n\n"); {
if (AH->connection)
CommitTransaction(AH);
else
ahprintf(AH, "COMMIT;\n\n");
}
if (AH->public.verbose) if (AH->public.verbose)
dumpTimestamp(AH, "Completed on", time(NULL)); dumpTimestamp(AH, "Completed on", time(NULL));
@ -652,10 +662,13 @@ EndBlob(Archive *AHX, Oid oid)
void void
StartRestoreBlobs(ArchiveHandle *AH) StartRestoreBlobs(ArchiveHandle *AH)
{ {
if (AH->connection) if (!AH->ropt->single_txn)
StartTransaction(AH); {
else if (AH->connection)
ahprintf(AH, "BEGIN;\n\n"); StartTransaction(AH);
else
ahprintf(AH, "BEGIN;\n\n");
}
AH->blobCount = 0; AH->blobCount = 0;
} }
@ -666,10 +679,13 @@ StartRestoreBlobs(ArchiveHandle *AH)
void void
EndRestoreBlobs(ArchiveHandle *AH) EndRestoreBlobs(ArchiveHandle *AH)
{ {
if (AH->connection) if (!AH->ropt->single_txn)
CommitTransaction(AH); {
else if (AH->connection)
ahprintf(AH, "COMMIT;\n\n"); CommitTransaction(AH);
else
ahprintf(AH, "COMMIT;\n\n");
}
ahlog(AH, 1, "restored %d large objects\n", AH->blobCount); ahlog(AH, 1, "restored %d large objects\n", AH->blobCount);
} }