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

Commite788883

Browse files
Fix bug in TOC file error message printing
If the blob TOC file cannot be parsed, the error message was failingto print the filename as the variable holding it was shadowed by thedestination buffer for parsing. When the filename fails to parse,the error will print an empty string: ./pg_restore -d foo -F d dump pg_restore: error: invalid line in large object TOC file "": ....instead of the intended error message: ./pg_restore -d foo -F d dump pg_restore: error: invalid line in large object TOC file "dump/blobs.toc": ..Fix by renaming both variables as the shared name was too generic tostore either and still convey what the variable held.Backpatch all the way down to 9.6.Reviewed-by: Tom LaneDiscussion:https://postgr.es/m/A2B151F5-B32B-4F2C-BA4A-6870856D9BDE@yesql.seBackpatch-through: 9.6
1 parent57bf8f7 commite788883

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

‎src/bin/pg_dump/pg_backup_directory.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -435,42 +435,42 @@ _LoadBlobs(ArchiveHandle *AH)
435435
{
436436
Oidoid;
437437
lclContext*ctx= (lclContext*)AH->formatData;
438-
charfname[MAXPGPATH];
438+
chartocfname[MAXPGPATH];
439439
charline[MAXPGPATH];
440440

441441
StartRestoreBlobs(AH);
442442

443-
setFilePath(AH,fname,"blobs.toc");
443+
setFilePath(AH,tocfname,"blobs.toc");
444444

445-
ctx->blobsTocFH=cfopen_read(fname,PG_BINARY_R);
445+
ctx->blobsTocFH=cfopen_read(tocfname,PG_BINARY_R);
446446

447447
if (ctx->blobsTocFH==NULL)
448448
fatal("could not open large object TOC file \"%s\" for input: %m",
449-
fname);
449+
tocfname);
450450

451451
/* Read the blobs TOC file line-by-line, and process each blob */
452452
while ((cfgets(ctx->blobsTocFH,line,MAXPGPATH))!=NULL)
453453
{
454-
charfname[MAXPGPATH+1];
454+
charblobfname[MAXPGPATH+1];
455455
charpath[MAXPGPATH];
456456

457-
/* Can't overflow because line andfname are the same length. */
458-
if (sscanf(line,"%u %"CppAsString2(MAXPGPATH)"s\n",&oid,fname)!=2)
457+
/* Can't overflow because line andblobfname are the same length */
458+
if (sscanf(line,"%u %"CppAsString2(MAXPGPATH)"s\n",&oid,blobfname)!=2)
459459
fatal("invalid line in large object TOC file \"%s\": \"%s\"",
460-
fname,line);
460+
tocfname,line);
461461

462462
StartRestoreBlob(AH,oid,AH->public.ropt->dropSchema);
463-
snprintf(path,MAXPGPATH,"%s/%s",ctx->directory,fname);
463+
snprintf(path,MAXPGPATH,"%s/%s",ctx->directory,blobfname);
464464
_PrintFileData(AH,path);
465465
EndRestoreBlob(AH,oid);
466466
}
467467
if (!cfeof(ctx->blobsTocFH))
468468
fatal("error reading large object TOC file \"%s\"",
469-
fname);
469+
tocfname);
470470

471471
if (cfclose(ctx->blobsTocFH)!=0)
472472
fatal("could not close large object TOC file \"%s\": %m",
473-
fname);
473+
tocfname);
474474

475475
ctx->blobsTocFH=NULL;
476476

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp