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

Commit04ace17

Browse files
committed
Tighten pg_restore's recognition of its -F (format) option values.
Instead of checking just the first letter, match the whole stringusing pg_strcasecmp. Per the documentation, we allow either justthe first letter (e.g. "c") or the whole name ("custom"); but wewill no longer accept random variations such as "chump". Thismatches pg_dump's longstanding parsing code for the same option.Also for consistency with pg_dump, recognize "p"/"plain". We don'tsupport it, but we can give a more helpful error message than"unrecognized archive format".Author: Srinath Reddy <srinath2133@gmail.com>Discussion:https://postgr.es/m/CAFC+b6pfK-BGcWW1kQmtxVrCh-JGjB2X02rLPQs_ZFaDGjZDsQ@mail.gmail.com
1 parentd2ca16b commit04ace17

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

‎src/bin/pg_dump/pg_restore.c

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -383,27 +383,25 @@ main(int argc, char **argv)
383383

384384
if (opts->formatName)
385385
{
386-
switch (opts->formatName[0])
386+
if (pg_strcasecmp(opts->formatName,"c")==0||
387+
pg_strcasecmp(opts->formatName,"custom")==0)
388+
opts->format=archCustom;
389+
elseif (pg_strcasecmp(opts->formatName,"d")==0||
390+
pg_strcasecmp(opts->formatName,"directory")==0)
391+
opts->format=archDirectory;
392+
elseif (pg_strcasecmp(opts->formatName,"t")==0||
393+
pg_strcasecmp(opts->formatName,"tar")==0)
394+
opts->format=archTar;
395+
elseif (pg_strcasecmp(opts->formatName,"p")==0||
396+
pg_strcasecmp(opts->formatName,"plain")==0)
387397
{
388-
case'c':
389-
case'C':
390-
opts->format=archCustom;
391-
break;
392-
393-
case'd':
394-
case'D':
395-
opts->format=archDirectory;
396-
break;
397-
398-
case't':
399-
case'T':
400-
opts->format=archTar;
401-
break;
402-
403-
default:
404-
pg_fatal("unrecognized archive format \"%s\"; please specify \"c\", \"d\", or \"t\"",
405-
opts->formatName);
398+
/* recognize this for consistency with pg_dump */
399+
pg_fatal("archive format \"%s\" is not supported; please use psql",
400+
opts->formatName);
406401
}
402+
else
403+
pg_fatal("unrecognized archive format \"%s\"; please specify \"c\", \"d\", or \"t\"",
404+
opts->formatName);
407405
}
408406

409407
AH=OpenArchive(inputFileSpec,opts->format);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp