15
15
*
16
16
*
17
17
* 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 $
19
19
*
20
20
*-------------------------------------------------------------------------
21
21
*/
@@ -47,7 +47,8 @@ static char *modulename = gettext_noop("archiver");
47
47
48
48
static ArchiveHandle * _allocAH (const char * FileSpec ,const ArchiveFormat fmt ,
49
49
const int compression ,ArchiveMode mode );
50
- static void _getObjectDescription (PQExpBuffer buf ,TocEntry * te );
50
+ static void _getObjectDescription (PQExpBuffer buf ,TocEntry * te ,
51
+ ArchiveHandle * AH );
51
52
static void _printTocEntry (ArchiveHandle * AH ,TocEntry * te ,RestoreOptions * ropt ,bool isData ,bool acl_pass );
52
53
53
54
@@ -2373,7 +2374,7 @@ _selectTablespace(ArchiveHandle *AH, const char *tablespace)
2373
2374
* information used is all that's available in older dump files.
2374
2375
*/
2375
2376
static void
2376
- _getObjectDescription (PQExpBuffer buf ,TocEntry * te )
2377
+ _getObjectDescription (PQExpBuffer buf ,TocEntry * te , ArchiveHandle * AH )
2377
2378
{
2378
2379
const char * type = te -> desc ;
2379
2380
@@ -2393,8 +2394,22 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te)
2393
2394
strcmp (type ,"TABLE" )== 0 ||
2394
2395
strcmp (type ,"TYPE" )== 0 )
2395
2396
{
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 ));
2398
2413
return ;
2399
2414
}
2400
2415
@@ -2553,7 +2568,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
2553
2568
PQExpBuffer temp = createPQExpBuffer ();
2554
2569
2555
2570
appendPQExpBuffer (temp ,"ALTER " );
2556
- _getObjectDescription (temp ,te );
2571
+ _getObjectDescription (temp ,te , AH );
2557
2572
appendPQExpBuffer (temp ," OWNER TO %s;" ,fmtId (te -> owner ));
2558
2573
ahprintf (AH ,"%s\n\n" ,temp -> data );
2559
2574
destroyPQExpBuffer (temp );