pg_dump: avoid schema qualification for ALTER ... OWNER
authorBruce Momjian <[email protected]>
Tue, 13 Aug 2013 15:45:56 +0000 (11:45 -0400)
committerBruce Momjian <[email protected]>
Tue, 13 Aug 2013 15:45:56 +0000 (11:45 -0400)
We already use search_path to specify the schema, so there is no need
for pg_dump to schema-qualify the name.  Also remove dead code.

src/bin/pg_dump/pg_backup_archiver.c

index cd7669b5eb2cae5743da4341faaef6274ab7eb4b..5204ceb96430d7f635eab4b2dc4fb876e9791a76 100644 (file)
@@ -2879,11 +2879,7 @@ _selectTablespace(ArchiveHandle *AH, const char *tablespace)
 /*
  * Extract an object description for a TOC entry, and append it to buf.
  *
- * This is not quite as general as it may seem, since it really only
- * handles constructing the right thing to put into ALTER ... OWNER TO.
- *
- * The whole thing is pretty grotty, but we are kind of stuck since the
- * information used is all that's available in older dump files.
+ * This is used for ALTER ... OWNER TO.
  */
 static void
 _getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH)
@@ -2895,7 +2891,7 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH)
                strcmp(type, "MATERIALIZED VIEW") == 0)
                type = "TABLE";
 
-       /* objects named by a schema and name */
+       /* objects that don't require special decoration */
        if (strcmp(type, "COLLATION") == 0 ||
                strcmp(type, "CONVERSION") == 0 ||
                strcmp(type, "DOMAIN") == 0 ||
@@ -2903,35 +2899,16 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH)
                strcmp(type, "TYPE") == 0 ||
                strcmp(type, "FOREIGN TABLE") == 0 ||
                strcmp(type, "TEXT SEARCH DICTIONARY") == 0 ||
-               strcmp(type, "TEXT SEARCH CONFIGURATION") == 0)
-       {
-               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;
-       }
-
-       /* objects named by just a name */
-       if (strcmp(type, "DATABASE") == 0 ||
+               strcmp(type, "TEXT SEARCH CONFIGURATION") == 0 ||
+               /* non-schema-specified objects */
+               strcmp(type, "DATABASE") == 0 ||
                strcmp(type, "PROCEDURAL LANGUAGE") == 0 ||
                strcmp(type, "SCHEMA") == 0 ||
                strcmp(type, "FOREIGN DATA WRAPPER") == 0 ||
                strcmp(type, "SERVER") == 0 ||
                strcmp(type, "USER MAPPING") == 0)
        {
+               /* We already know that search_path was set properly */
                appendPQExpBuffer(buf, "%s %s", type, fmtId(te->tag));
                return;
        }