summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-01-23 00:04:20 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-01-23 00:04:20 +0000
commita9ad4b13bc81e327662c973efb6acccd2a3414b1 (patch)
treee2eb5679cb64c5622bf871082ee9c84103e096c3
parent5be6219bdd857313e667d83bd45cc22b0f85be93 (diff)
downloadpostgresql-a9ad4b13bc81e327662c973efb6acccd2a3414b1.tar.gz
New routine _getObjectDescription() failed to cope with some aspects of
pre-7.3 pg_dump archive files: namespace isn't there, and in some cases te->tag may already be quotified. Per report from Alan Pevec and followup testing.
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 276410742a..cb60e7ff58 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.101 2005/01/11 05:14:10 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.101.4.1 2005/01/23 00:04:20 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -47,7 +47,8 @@ static char *modulename = gettext_noop("archiver");
static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
const int compression, ArchiveMode mode);
-static void _getObjectDescription(PQExpBuffer buf, TocEntry *te);
+static void _getObjectDescription(PQExpBuffer buf, TocEntry *te,
+ ArchiveHandle *AH);
static void _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData, bool acl_pass);
@@ -2373,7 +2374,7 @@ _selectTablespace(ArchiveHandle *AH, const char *tablespace)
* information used is all that's available in older dump files.
*/
static void
-_getObjectDescription(PQExpBuffer buf, TocEntry *te)
+_getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH)
{
const char *type = te->desc;
@@ -2393,8 +2394,22 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te)
strcmp(type, "TABLE") == 0 ||
strcmp(type, "TYPE") == 0)
{
- appendPQExpBuffer(buf, "%s %s", type, fmtId(te->namespace));
- appendPQExpBuffer(buf, ".%s", fmtId(te->tag));
+ appendPQExpBuffer(buf, "%s ", type);
+ if (te->namespace && te->namespace[0]) /* is null pre-7.3 */
+ appendPQExpBuffer(buf, "%s.", fmtId(te->namespace));
+ /*
+ * Pre-7.3 pg_dump would sometimes (not always) put
+ * a fmtId'd name into te->tag for an index.
+ * This check is heuristic, so make its scope as
+ * narrow as possible.
+ */
+ if (AH->version < K_VERS_1_7 &&
+ te->tag[0] == '"' &&
+ te->tag[strlen(te->tag)-1] == '"' &&
+ strcmp(type, "INDEX") == 0)
+ appendPQExpBuffer(buf, "%s", te->tag);
+ else
+ appendPQExpBuffer(buf, "%s", fmtId(te->tag));
return;
}
@@ -2553,7 +2568,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
PQExpBuffer temp = createPQExpBuffer();
appendPQExpBuffer(temp, "ALTER ");
- _getObjectDescription(temp, te);
+ _getObjectDescription(temp, te, AH);
appendPQExpBuffer(temp, " OWNER TO %s;", fmtId(te->owner));
ahprintf(AH, "%s\n\n", temp->data);
destroyPQExpBuffer(temp);