mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	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.
This commit is contained in:
		@@ -16,7 +16,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * IDENTIFICATION
 | 
					 * IDENTIFICATION
 | 
				
			||||||
 *		$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.49.2.2 2006/06/27 02:56:46 momjian Exp $
 | 
					 *		$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.49.2.3 2006/11/01 15:59:31 tgl Exp $
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *-------------------------------------------------------------------------
 | 
					 *-------------------------------------------------------------------------
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -701,6 +701,7 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
 | 
				
			|||||||
	lclContext *ctx = (lclContext *) AH->formatData;
 | 
						lclContext *ctx = (lclContext *) AH->formatData;
 | 
				
			||||||
	TAR_MEMBER *th;
 | 
						TAR_MEMBER *th;
 | 
				
			||||||
	size_t		cnt;
 | 
						size_t		cnt;
 | 
				
			||||||
 | 
						bool		foundBlob = false;
 | 
				
			||||||
	char		buf[4096];
 | 
						char		buf[4096];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	StartRestoreBlobs(AH);
 | 
						StartRestoreBlobs(AH);
 | 
				
			||||||
@@ -725,10 +726,22 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
 | 
				
			|||||||
					ahwrite(buf, 1, cnt, AH);
 | 
										ahwrite(buf, 1, cnt, AH);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				EndRestoreBlob(AH, oid);
 | 
									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');
 | 
							th = tarOpen(AH, NULL, 'r');
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user