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

Commit3e2e58b

Browse files
committed
New routine _getObjectDescription() failed to cope with some aspects of
pre-7.3 pg_dump archive files: namespace isn't there, and in some caseste->tag may already be quotified. Per report from Alan Pevec andfollowup testing.
1 parent112654c commit3e2e58b

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 21 additions & 6 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.101 2005/01/11 05:14:10 tgl Exp $
18+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.102 2005/01/23 00:03:54 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -47,7 +47,8 @@ static char *modulename = gettext_noop("archiver");
4747

4848
staticArchiveHandle*_allocAH(constchar*FileSpec,constArchiveFormatfmt,
4949
constintcompression,ArchiveModemode);
50-
staticvoid_getObjectDescription(PQExpBufferbuf,TocEntry*te);
50+
staticvoid_getObjectDescription(PQExpBufferbuf,TocEntry*te,
51+
ArchiveHandle*AH);
5152
staticvoid_printTocEntry(ArchiveHandle*AH,TocEntry*te,RestoreOptions*ropt,boolisData,boolacl_pass);
5253

5354

@@ -2373,7 +2374,7 @@ _selectTablespace(ArchiveHandle *AH, const char *tablespace)
23732374
* information used is all that's available in older dump files.
23742375
*/
23752376
staticvoid
2376-
_getObjectDescription(PQExpBufferbuf,TocEntry*te)
2377+
_getObjectDescription(PQExpBufferbuf,TocEntry*te,ArchiveHandle*AH)
23772378
{
23782379
constchar*type=te->desc;
23792380

@@ -2393,8 +2394,22 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te)
23932394
strcmp(type,"TABLE")==0||
23942395
strcmp(type,"TYPE")==0)
23952396
{
2396-
appendPQExpBuffer(buf,"%s %s",type,fmtId(te->namespace));
2397-
appendPQExpBuffer(buf,".%s",fmtId(te->tag));
2397+
appendPQExpBuffer(buf,"%s ",type);
2398+
if (te->namespace&&te->namespace[0])/* is null pre-7.3 */
2399+
appendPQExpBuffer(buf,"%s.",fmtId(te->namespace));
2400+
/*
2401+
* Pre-7.3 pg_dump would sometimes (not always) put
2402+
* a fmtId'd name into te->tag for an index.
2403+
* This check is heuristic, so make its scope as
2404+
* narrow as possible.
2405+
*/
2406+
if (AH->version<K_VERS_1_7&&
2407+
te->tag[0]=='"'&&
2408+
te->tag[strlen(te->tag)-1]=='"'&&
2409+
strcmp(type,"INDEX")==0)
2410+
appendPQExpBuffer(buf,"%s",te->tag);
2411+
else
2412+
appendPQExpBuffer(buf,"%s",fmtId(te->tag));
23982413
return;
23992414
}
24002415

@@ -2553,7 +2568,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
25532568
PQExpBuffertemp=createPQExpBuffer();
25542569

25552570
appendPQExpBuffer(temp,"ALTER ");
2556-
_getObjectDescription(temp,te);
2571+
_getObjectDescription(temp,te,AH);
25572572
appendPQExpBuffer(temp," OWNER TO %s;",fmtId(te->owner));
25582573
ahprintf(AH,"%s\n\n",temp->data);
25592574
destroyPQExpBuffer(temp);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp