aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/pg_dump/pg_dump.c13
-rw-r--r--src/bin/pg_dump/pg_dump.h6
2 files changed, 15 insertions, 4 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index d181946ad7a..9aae8f8f55c 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -4981,6 +4981,7 @@ getTypes(Archive *fout, int *numTypes)
tyinfo[i].dobj.namespace =
findNamespace(fout,
atooid(PQgetvalue(res, i, i_typnamespace)));
+ tyinfo[i].ftypname = NULL; /* may get filled later */
tyinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname));
tyinfo[i].typacl = pg_strdup(PQgetvalue(res, i, i_typacl));
tyinfo[i].rtypacl = pg_strdup(PQgetvalue(res, i, i_rtypacl));
@@ -18611,12 +18612,11 @@ findDumpableDependencies(ArchiveHandle *AH, DumpableObject *dobj,
*
* This does not guarantee to schema-qualify the output, so it should not
* be used to create the target object name for CREATE or ALTER commands.
- *
- * TODO: there might be some value in caching the results.
*/
static char *
getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts)
{
+ TypeInfo *typeInfo;
char *result;
PQExpBuffer query;
PGresult *res;
@@ -18633,6 +18633,11 @@ getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts)
return pg_strdup("NONE");
}
+ /* see if we have the result cached in the type's TypeInfo record */
+ typeInfo = findTypeByOid(oid);
+ if (typeInfo && typeInfo->ftypname)
+ return pg_strdup(typeInfo->ftypname);
+
query = createPQExpBuffer();
appendPQExpBuffer(query, "SELECT pg_catalog.format_type('%u'::pg_catalog.oid, NULL)",
oid);
@@ -18645,6 +18650,10 @@ getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts)
PQclear(res);
destroyPQExpBuffer(query);
+ /* cache a copy for later requests */
+ if (typeInfo)
+ typeInfo->ftypname = pg_strdup(result);
+
return result;
}
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index 162a524303d..0a29919c13c 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -167,9 +167,11 @@ typedef struct _typeInfo
DumpableObject dobj;
/*
- * Note: dobj.name is the pg_type.typname entry. format_type() might
- * produce something different than typname
+ * Note: dobj.name is the raw pg_type.typname entry. ftypname is the
+ * result of format_type(), which will be quoted if needed, and might be
+ * schema-qualified too.
*/
+ char *ftypname;
char *rolname; /* name of owner, or empty string */
char *typacl;
char *rtypacl;