diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-11-01 15:59:26 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-11-01 15:59:26 +0000 |
commit | 19d0c46def867119219e8362aecd3ba2fa745ee2 (patch) | |
tree | 377f6b011e4dcb4e89712c3d6fdf528d9962ce6b /src | |
parent | c1fdbba49f2bfb6bf7dc3523025601a775b6b41b (diff) | |
download | postgresql-19d0c46def867119219e8362aecd3ba2fa745ee2.tar.gz postgresql-19d0c46def867119219e8362aecd3ba2fa745ee2.zip |
pg_restore failed on tar-format archives if they contained large objects
(blobs) with comments, per bug #2727 from Konstantin Pelepelin.
Mea culpa for not having tested this case.
Back-patch to 8.1; prior branches don't dump blob comments at all.
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_dump/pg_backup_tar.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c index 51d783b1a51..71bf13c5296 100644 --- a/src/bin/pg_dump/pg_backup_tar.c +++ b/src/bin/pg_dump/pg_backup_tar.c @@ -16,7 +16,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.55 2006/10/04 00:30:05 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.56 2006/11/01 15:59:26 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -701,6 +701,7 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt) lclContext *ctx = (lclContext *) AH->formatData; TAR_MEMBER *th; size_t cnt; + bool foundBlob = false; char buf[4096]; StartRestoreBlobs(AH); @@ -725,10 +726,22 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt) ahwrite(buf, 1, cnt, AH); } EndRestoreBlob(AH, oid); + foundBlob = true; } + tarClose(AH, th); + } + else + { + tarClose(AH, th); + /* + * Once we have found the first blob, stop at the first + * non-blob entry (which will be 'blobs.toc'). This coding would + * eat all the rest of the archive if there are no blobs ... but + * this function shouldn't be called at all in that case. + */ + if (foundBlob) + break; } - - tarClose(AH, th); th = tarOpen(AH, NULL, 'r'); } |