Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit79e3710

Browse files
committed
Add strerror to pg_dump error messages where missing.
1 parente9cc530 commit79e3710

File tree

6 files changed

+51
-42
lines changed

6 files changed

+51
-42
lines changed

‎src/bin/pg_dump/common.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.89 2006/03/05 15:58:50 momjian Exp $
14+
* $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.90 2006/05/22 11:21:54 petere Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -768,7 +768,7 @@ parseOidArray(const char *str, Oid *array, int arraysize)
768768
{
769769
if (argNum >=arraysize)
770770
{
771-
write_msg(NULL,"could not parse numeric array: too many numbers\n");
771+
write_msg(NULL,"could not parse numeric array \"%s\": too many numbers\n",str);
772772
exit_nicely();
773773
}
774774
temp[j]='\0';
@@ -783,7 +783,7 @@ parseOidArray(const char *str, Oid *array, int arraysize)
783783
if (!(isdigit((unsignedchar)s)||s=='-')||
784784
j >=sizeof(temp)-1)
785785
{
786-
write_msg(NULL,"could not parse numeric array: invalid character in number\n");
786+
write_msg(NULL,"could not parse numeric array \"%s\": invalid character in number\n",str);
787787
exit_nicely();
788788
}
789789
temp[j++]=s;

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.127 2006/04/19 16:02:17 tgl Exp $
18+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.128 2006/05/22 11:21:54 petere Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -122,7 +122,8 @@ CloseArchive(Archive *AHX)
122122
res=fclose(AH->OF);
123123

124124
if (res!=0)
125-
die_horribly(AH,modulename,"could not close output archive file\n");
125+
die_horribly(AH,modulename,"could not close output file: %s\n",
126+
strerror(errno));
126127
}
127128

128129
/* Public */
@@ -306,7 +307,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
306307
{
307308
#ifndefHAVE_LIBZ
308309
if (AH->compression!=0)
309-
die_horribly(AH,modulename,"cannot restore from compressed archive (notconfigured for compression support)\n");
310+
die_horribly(AH,modulename,"cannot restore from compressed archive (compressionnotsupported in this installation)\n");
310311
#endif
311312

312313
_printTocEntry(AH,te,ropt, true, false);
@@ -774,7 +775,8 @@ SortTocFromFile(Archive *AHX, RestoreOptions *ropt)
774775
/* Setup the file */
775776
fh=fopen(ropt->tocFile,PG_BINARY_R);
776777
if (!fh)
777-
die_horribly(AH,modulename,"could not open TOC file\n");
778+
die_horribly(AH,modulename,"could not open TOC file: %s\n",
779+
strerror(errno));
778780

779781
while (fgets(buf,sizeof(buf),fh)!=NULL)
780782
{
@@ -1066,7 +1068,7 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
10661068
{
10671069
res=GZWRITE((void*)ptr,size,nmemb,AH->OF);
10681070
if (res!= (nmemb*size))
1069-
die_horribly(AH,modulename,"could not write tocompressed archive\n");
1071+
die_horribly(AH,modulename,"could not write tooutput file: %s\n",strerror(errno));
10701072
returnres;
10711073
}
10721074
elseif (AH->CustomOutPtr)
@@ -1089,8 +1091,8 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
10891091
{
10901092
res=fwrite((void*)ptr,size,nmemb,AH->OF);
10911093
if (res!=nmemb)
1092-
die_horribly(AH,modulename,"could not write to output file (%lu != %lu)\n",
1093-
(unsigned long)res, (unsigned long)nmemb);
1094+
die_horribly(AH,modulename,"could not write to output file: %s\n",
1095+
strerror(errno));
10941096
returnres;
10951097
}
10961098
}
@@ -1321,7 +1323,7 @@ ReadOffset(ArchiveHandle *AH, off_t *o)
13211323
break;
13221324

13231325
default:
1324-
die_horribly(AH,modulename,"Unexpected data offset flag %d\n",offsetFlg);
1326+
die_horribly(AH,modulename,"unexpected data offset flag %d\n",offsetFlg);
13251327
}
13261328

13271329
/*
@@ -1556,7 +1558,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
15561558
/* Close the file */
15571559
if (wantClose)
15581560
if (fclose(fh)!=0)
1559-
die_horribly(AH,modulename,"could not closetheinput file after reading header: %s\n",
1561+
die_horribly(AH,modulename,"could not close input file: %s\n",
15601562
strerror(errno));
15611563

15621564
returnAH->format;

‎src/bin/pg_dump/pg_backup_custom.c

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
*
2121
* 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 $
2323
*
2424
*-------------------------------------------------------------------------
2525
*/
@@ -175,7 +175,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
175175
AH->FH=stdout;
176176

177177
if (!AH->FH)
178-
die_horribly(AH,modulename,"could not openarchive file \"%s\": %s\n",AH->fSpec,strerror(errno));
178+
die_horribly(AH,modulename,"could not openoutput file \"%s\": %s\n",AH->fSpec,strerror(errno));
179179

180180
ctx->hasSeek=checkSeek(AH->FH);
181181
}
@@ -186,7 +186,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
186186
else
187187
AH->FH=stdin;
188188
if (!AH->FH)
189-
die_horribly(AH,modulename,"could not openarchive file \"%s\": %s\n",AH->fSpec,strerror(errno));
189+
die_horribly(AH,modulename,"could not openinput file \"%s\": %s\n",AH->fSpec,strerror(errno));
190190

191191
ctx->hasSeek=checkSeek(AH->FH);
192192

@@ -438,7 +438,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
438438
{
439439
if ((TocIDRequired(AH,id,ropt)&REQ_DATA)!=0)
440440
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"
442442
" without ID on this input stream (fseek required)\n");
443443

444444
switch (blkType)
@@ -540,9 +540,14 @@ _PrintData(ArchiveHandle *AH)
540540

541541
cnt=fread(in,1,blkLen,AH->FH);
542542
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+
}
546551

547552
ctx->filePos+=blkLen;
548553

@@ -663,9 +668,14 @@ _skipData(ArchiveHandle *AH)
663668
}
664669
cnt=fread(in,1,blkLen,AH->FH);
665670
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+
}
669679

670680
ctx->filePos+=blkLen;
671681

@@ -736,8 +746,7 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
736746

737747
if (res!=len)
738748
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));
741750

742751
ctx->filePos+=res;
743752
returnres;
@@ -929,7 +938,7 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
929938
*/
930939
WriteInt(AH,zlibOutSize-zp->avail_out);
931940
if (fwrite(out,1,zlibOutSize-zp->avail_out,AH->FH)!= (zlibOutSize-zp->avail_out))
932-
die_horribly(AH,modulename,"could not writecompressed chunk\n");
941+
die_horribly(AH,modulename,"could not writeto output file: %s\n",strerror(errno));
933942
ctx->filePos+=zlibOutSize-zp->avail_out;
934943
}
935944
zp->next_out= (void*)out;
@@ -943,7 +952,7 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
943952
{
944953
WriteInt(AH,zp->avail_in);
945954
if (fwrite(zp->next_in,1,zp->avail_in,AH->FH)!=zp->avail_in)
946-
die_horribly(AH,modulename,"could not writeuncompressed chunk\n");
955+
die_horribly(AH,modulename,"could not writeto output file: %s\n",strerror(errno));
947956
ctx->filePos+=zp->avail_in;
948957
zp->avail_in=0;
949958
}

‎src/bin/pg_dump/pg_backup_files.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
*
2222
* IDENTIFICATION
23-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.27 2005/10/15 02:49:38 momjian Exp $
23+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.28 2006/05/22 11:21:54 petere Exp $
2424
*
2525
*-------------------------------------------------------------------------
2626
*/
@@ -243,7 +243,7 @@ _StartData(ArchiveHandle *AH, TocEntry *te)
243243
#endif
244244

245245
if (tctx->FH==NULL)
246-
die_horribly(AH,modulename,"could not opendata file for output\n");
246+
die_horribly(AH,modulename,"could not openoutput file: %s\n",strerror(errno));
247247
}
248248

249249
staticsize_t
@@ -287,7 +287,7 @@ _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
287287
#endif
288288

289289
if (AH->FH==NULL)
290-
die_horribly(AH,modulename,"could not opendata file for input\n");
290+
die_horribly(AH,modulename,"could not openinput file: %s\n",strerror(errno));
291291

292292
while ((cnt=GZREAD(buf,1,4095,AH->FH))>0)
293293
{
@@ -411,7 +411,7 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
411411

412412
res=fwrite(buf,1,len,AH->FH);
413413
if (res!=len)
414-
die_horribly(AH,modulename,"write error in _WriteBuf (%lu != %lu)\n",(unsigned long)res, (unsigned long)len);
414+
die_horribly(AH,modulename,"could not write to output file: %s\n",strerror(errno));
415415

416416
ctx->filePos+=res;
417417
returnres;
@@ -508,7 +508,7 @@ _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid)
508508
#endif
509509

510510
if (tctx->FH==NULL)
511-
die_horribly(AH,modulename,"could not open large object file\n");
511+
die_horribly(AH,modulename,"could not open large object file for input: %s\n",strerror(errno));
512512
}
513513

514514
/*

‎src/bin/pg_dump/pg_backup_tar.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*
1818
* IDENTIFICATION
19-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.50 2006/02/12 06:11:50 momjian Exp $
19+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.51 2006/05/2211:21:54 petere Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -546,8 +546,7 @@ tarWrite(const void *buf, size_t len, TAR_MEMBER *th)
546546

547547
if (res!=len)
548548
die_horribly(th->AH,modulename,
549-
"could not write to tar member (wrote %lu, attempted %lu)\n",
550-
(unsigned long)res, (unsigned long)len);
549+
"could not write to output file: %s\n",strerror(errno));
551550

552551
th->pos+=res;
553552
returnres;
@@ -1035,13 +1034,12 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
10351034
res=fwrite(&buf[0],1,cnt,th->tarFH);
10361035
if (res!=cnt)
10371036
die_horribly(AH,modulename,
1038-
"write error appending to tar archive (wrote %lu, attempted %lu)\n",
1039-
(unsigned long)res, (unsigned long)cnt);
1037+
"could not write to output file: %s\n",strerror(errno));
10401038
len+=res;
10411039
}
10421040

10431041
if (fclose(tmp)!=0)/* This *should* delete it... */
1044-
die_horribly(AH,modulename,"could not closetar member: %s\n",strerror(errno));
1042+
die_horribly(AH,modulename,"could not closetemporary file: %s\n",strerror(errno));
10451043

10461044
if (len!=th->fileLen)
10471045
{
@@ -1327,6 +1325,6 @@ _tarWriteHeader(TAR_MEMBER *th)
13271325
}
13281326

13291327
if (fwrite(h,1,512,th->tarFH)!=512)
1330-
die_horribly(th->AH,modulename,"could not writetar header\n");
1328+
die_horribly(th->AH,modulename,"could not writeto output file: %s\n",strerror(errno));
13311329

13321330
}

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.74 2006/04/0721:26:29 tgl Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.75 2006/05/22 11:21:54 petere Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -38,8 +38,8 @@ intoptreset;
3838
#include"pqexpbuffer.h"
3939

4040

41-
/* version string we expect back frompostgres */
42-
#definePG_VERSIONSTR "pg_dump (PostgreSQL) " PG_VERSION "\n"
41+
/* version string we expect back frompg_dump */
42+
#definePGDUMP_VERSIONSTR "pg_dump (PostgreSQL) " PG_VERSION "\n"
4343

4444

4545
staticconstchar*progname;
@@ -142,7 +142,7 @@ main(int argc, char *argv[])
142142
}
143143
}
144144

145-
if ((ret=find_other_exec(argv[0],"pg_dump",PG_VERSIONSTR,
145+
if ((ret=find_other_exec(argv[0],"pg_dump",PGDUMP_VERSIONSTR,
146146
pg_dump_bin))<0)
147147
{
148148
charfull_path[MAXPGPATH];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp