Skip to content

Commit 808f8f5

Browse files
committed
pg_dump: avoid schema qualification for ALTER ... OWNER
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.
1 parent 527ea66 commit 808f8f5

File tree

1 file changed

+6
-29
lines changed

1 file changed

+6
-29
lines changed

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,11 +2879,7 @@ _selectTablespace(ArchiveHandle *AH, const char *tablespace)
28792879
/*
28802880
* Extract an object description for a TOC entry, and append it to buf.
28812881
*
2882-
* This is not quite as general as it may seem, since it really only
2883-
* handles constructing the right thing to put into ALTER ... OWNER TO.
2884-
*
2885-
* The whole thing is pretty grotty, but we are kind of stuck since the
2886-
* information used is all that's available in older dump files.
2882+
* This is used for ALTER ... OWNER TO.
28872883
*/
28882884
static void
28892885
_getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH)
@@ -2895,43 +2891,24 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH)
28952891
strcmp(type, "MATERIALIZED VIEW") == 0)
28962892
type = "TABLE";
28972893

2898-
/* objects named by a schema and name */
2894+
/* objects that don't require special decoration */
28992895
if (strcmp(type, "COLLATION") == 0 ||
29002896
strcmp(type, "CONVERSION") == 0 ||
29012897
strcmp(type, "DOMAIN") == 0 ||
29022898
strcmp(type, "TABLE") == 0 ||
29032899
strcmp(type, "TYPE") == 0 ||
29042900
strcmp(type, "FOREIGN TABLE") == 0 ||
29052901
strcmp(type, "TEXT SEARCH DICTIONARY") == 0 ||
2906-
strcmp(type, "TEXT SEARCH CONFIGURATION") == 0)
2907-
{
2908-
appendPQExpBuffer(buf, "%s ", type);
2909-
if (te->namespace && te->namespace[0]) /* is null pre-7.3 */
2910-
appendPQExpBuffer(buf, "%s.", fmtId(te->namespace));
2911-
2912-
/*
2913-
* Pre-7.3 pg_dump would sometimes (not always) put a fmtId'd name
2914-
* into te->tag for an index. This check is heuristic, so make its
2915-
* scope as narrow as possible.
2916-
*/
2917-
if (AH->version < K_VERS_1_7 &&
2918-
te->tag[0] == '"' &&
2919-
te->tag[strlen(te->tag) - 1] == '"' &&
2920-
strcmp(type, "INDEX") == 0)
2921-
appendPQExpBuffer(buf, "%s", te->tag);
2922-
else
2923-
appendPQExpBuffer(buf, "%s", fmtId(te->tag));
2924-
return;
2925-
}
2926-
2927-
/* objects named by just a name */
2928-
if (strcmp(type, "DATABASE") == 0 ||
2902+
strcmp(type, "TEXT SEARCH CONFIGURATION") == 0 ||
2903+
/* non-schema-specified objects */
2904+
strcmp(type, "DATABASE") == 0 ||
29292905
strcmp(type, "PROCEDURAL LANGUAGE") == 0 ||
29302906
strcmp(type, "SCHEMA") == 0 ||
29312907
strcmp(type, "FOREIGN DATA WRAPPER") == 0 ||
29322908
strcmp(type, "SERVER") == 0 ||
29332909
strcmp(type, "USER MAPPING") == 0)
29342910
{
2911+
/* We already know that search_path was set properly */
29352912
appendPQExpBuffer(buf, "%s %s", type, fmtId(te->tag));
29362913
return;
29372914
}

0 commit comments

Comments
 (0)