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

Commit54a622c

Browse files
committed
Suggest use of psql when pg_restore gets a text dump.
1 parentbc2a050 commit54a622c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ typedef struct _parallel_slot
7777

7878
#defineNO_SLOT (-1)
7979

80+
#defineTEXT_DUMP_HEADER "--\n-- PostgreSQL database dump\n--\n\n"
81+
#defineTEXT_DUMPALL_HEADER "--\n-- PostgreSQL database cluster dump\n--\n\n"
82+
8083
/* state needed to save/restore an archive's output target */
8184
typedefstruct_outputContext
8285
{
@@ -1862,12 +1865,20 @@ _discoverArchiveFormat(ArchiveHandle *AH)
18621865
else
18631866
{
18641867
/*
1865-
* *Maybe* we have a tar archive format file... So, read first 512
1866-
* byte header...
1868+
* *Maybe* we have a tar archive format file or a text dump ...
1869+
*So, read first 512byte header...
18671870
*/
18681871
cnt=fread(&AH->lookahead[AH->lookaheadLen],1,512-AH->lookaheadLen,fh);
18691872
AH->lookaheadLen+=cnt;
18701873

1874+
if (AH->lookaheadLen >=strlen(TEXT_DUMPALL_HEADER)&&
1875+
(strncmp(AH->lookahead,TEXT_DUMP_HEADER,strlen(TEXT_DUMP_HEADER))==0||
1876+
strncmp(AH->lookahead,TEXT_DUMPALL_HEADER,strlen(TEXT_DUMPALL_HEADER))==0))
1877+
{
1878+
/* looks like it's probably a text format dump. so suggest they try psql */
1879+
die_horribly(AH,modulename,"input file appears to be a text format dump. Please use psql.\n");
1880+
}
1881+
18711882
if (AH->lookaheadLen!=512)
18721883
die_horribly(AH,modulename,"input file does not appear to be a valid archive (too short?)\n");
18731884

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp