19
19
*
20
20
*
21
21
* IDENTIFICATION
22
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.33 2005/10/15 02:49:38 momjian Exp $
22
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.34 2006/05/22 11:21:54 petere Exp $
23
23
*
24
24
*-------------------------------------------------------------------------
25
25
*/
@@ -175,7 +175,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
175
175
AH -> FH = stdout ;
176
176
177
177
if (!AH -> FH )
178
- die_horribly (AH , modulename , "could not open archive file \"%s\": %s\n" , AH -> fSpec , strerror (errno ));
178
+ die_horribly (AH , modulename , "could not open output file \"%s\": %s\n" , AH -> fSpec , strerror (errno ));
179
179
180
180
ctx -> hasSeek = checkSeek (AH -> FH );
181
181
}
@@ -186,7 +186,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
186
186
else
187
187
AH -> FH = stdin ;
188
188
if (!AH -> FH )
189
- die_horribly (AH , modulename , "could not open archive file \"%s\": %s\n" , AH -> fSpec , strerror (errno ));
189
+ die_horribly (AH , modulename , "could not open input file \"%s\": %s\n" , AH -> fSpec , strerror (errno ));
190
190
191
191
ctx -> hasSeek = checkSeek (AH -> FH );
192
192
@@ -438,7 +438,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
438
438
{
439
439
if ((TocIDRequired (AH , id , ropt ) & REQ_DATA ) != 0 )
440
440
die_horribly (AH , modulename ,
441
- "Dumping a specific TOC data block out of order is not supported"
441
+ "dumping a specific TOC data block out of order is not supported"
442
442
" without ID on this input stream (fseek required)\n" );
443
443
444
444
switch (blkType )
@@ -540,9 +540,14 @@ _PrintData(ArchiveHandle *AH)
540
540
541
541
cnt = fread (in , 1 , blkLen , AH -> FH );
542
542
if (cnt != blkLen )
543
- die_horribly (AH , modulename ,
544
- "could not read data block -- expected %lu, got %lu\n" ,
545
- (unsigned long ) blkLen , (unsigned long ) cnt );
543
+ {
544
+ if (feof (AH -> FH ))
545
+ die_horribly (AH , modulename ,
546
+ "could not read from input file: end of file\n" );
547
+ else
548
+ die_horribly (AH , modulename ,
549
+ "could not read from input file: %s\n" , strerror (errno ));
550
+ }
546
551
547
552
ctx -> filePos += blkLen ;
548
553
@@ -663,9 +668,14 @@ _skipData(ArchiveHandle *AH)
663
668
}
664
669
cnt = fread (in , 1 , blkLen , AH -> FH );
665
670
if (cnt != blkLen )
666
- die_horribly (AH , modulename ,
667
- "could not read data block -- expected %lu, got %lu\n" ,
668
- (unsigned long ) blkLen , (unsigned long ) cnt );
671
+ {
672
+ if (feof (AH -> FH ))
673
+ die_horribly (AH , modulename ,
674
+ "could not read from input file: end of file\n" );
675
+ else
676
+ die_horribly (AH , modulename ,
677
+ "could not read from input file: %s\n" , strerror (errno ));
678
+ }
669
679
670
680
ctx -> filePos += blkLen ;
671
681
@@ -736,8 +746,7 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
736
746
737
747
if (res != len )
738
748
die_horribly (AH , modulename ,
739
- "write error in _WriteBuf (%lu != %lu)\n" ,
740
- (unsigned long ) res , (unsigned long ) len );
749
+ "could not write to output file: %s\n" , strerror (errno ));
741
750
742
751
ctx -> filePos += res ;
743
752
return res ;
@@ -929,7 +938,7 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
929
938
*/
930
939
WriteInt (AH , zlibOutSize - zp -> avail_out );
931
940
if (fwrite (out , 1 , zlibOutSize - zp -> avail_out , AH -> FH ) != (zlibOutSize - zp -> avail_out ))
932
- die_horribly (AH , modulename , "could not write compressed chunk \n" );
941
+ die_horribly (AH , modulename , "could not write to output file: %s \n" , strerror ( errno ) );
933
942
ctx -> filePos += zlibOutSize - zp -> avail_out ;
934
943
}
935
944
zp -> next_out = (void * ) out ;
@@ -943,7 +952,7 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
943
952
{
944
953
WriteInt (AH , zp -> avail_in );
945
954
if (fwrite (zp -> next_in , 1 , zp -> avail_in , AH -> FH ) != zp -> avail_in )
946
- die_horribly (AH , modulename , "could not write uncompressed chunk \n" );
955
+ die_horribly (AH , modulename , "could not write to output file: %s \n" , strerror ( errno ) );
947
956
ctx -> filePos += zp -> avail_in ;
948
957
zp -> avail_in = 0 ;
949
958
}
0 commit comments