Commit 0ad14ebc authored by Tom Lane's avatar Tom Lane

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

Simon Riggs
parent 2d7f6947
...@@ -15,7 +15,7 @@ ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment