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

Commit3c2aa0c

Browse files
committed
psql: complain if pg_dump custom-format is detected
Apparently, this is a very common mistake for users to make; it isbetter to have it fail reasonably rather than throw potentially a largenumber of errors. Since we have a magic string at the start of thefile, we can detect the case easily and there's no other possible usefulbehavior anyway.Author: Craig Ringer
1 parentb01a4f6 commit3c2aa0c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎src/bin/psql/mainloop.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,18 @@ MainLoop(FILE *source)
175175
if (pset.lineno==1&&pset.encoding==PG_UTF8&&strncmp(line,"\xef\xbb\xbf",3)==0)
176176
memmove(line,line+3,strlen(line+3)+1);
177177

178+
/* Detect attempts to run custom-format dumps as SQL scripts */
179+
if (pset.lineno==1&& !pset.cur_cmd_interactive&&
180+
strncmp(line,"PGDMP",5)==0)
181+
{
182+
free(line);
183+
puts(_("The input is a PostgreSQL custom-format dump.\n"
184+
"Use the pg_restore command-line client to restore this dump to a database.\n"));
185+
fflush(stdout);
186+
successResult=EXIT_FAILURE;
187+
break;
188+
}
189+
178190
/* nothing left on line? then ignore */
179191
if (line[0]=='\0'&& !psql_scan_in_quote(scan_state))
180192
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp