aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_dump.c
diff options
context:
space:
mode:
authorJeff Davis <jdavis@postgresql.org>2025-03-25 11:16:06 -0700
committerJeff Davis <jdavis@postgresql.org>2025-03-25 11:16:06 -0700
commit650ab8aaf1957863ae14c80265e79f5d903b49fd (patch)
tree6ea530310dc773d82160cc6cc6d66893ab8ec910 /src/bin/pg_dump/pg_dump.c
parent2a420f7995e415f4813fccf1c42ab29a3a32182f (diff)
downloadpostgresql-650ab8aaf1957863ae14c80265e79f5d903b49fd.tar.gz
postgresql-650ab8aaf1957863ae14c80265e79f5d903b49fd.zip
Stats: use schemaname/relname instead of regclass.
For import and export, use schemaname/relname rather than regclass. This is more natural during export, fits with the other arguments better, and it gives better control over error handling in case we need to downgrade more errors to warnings. Also, use text for the argument types for schemaname, relname, and attname so that casts to "name" are not required. Author: Corey Huinker <corey.huinker@gmail.com> Discussion: https://postgr.es/m/CADkLM=ceOSsx_=oe73QQ-BxUFR2Cwqum7-UP_fPe22DBY0NerA@mail.gmail.com
Diffstat (limited to 'src/bin/pg_dump/pg_dump.c')
-rw-r--r--src/bin/pg_dump/pg_dump.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 428ed2d60fc..239664c459d 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -10498,7 +10498,6 @@ dumpRelationStats(Archive *fout, const RelStatsInfo *rsinfo)
PQExpBuffer out;
DumpId *deps = NULL;
int ndeps = 0;
- char *qualified_name;
int i_attname;
int i_inherited;
int i_null_frac;
@@ -10563,15 +10562,16 @@ dumpRelationStats(Archive *fout, const RelStatsInfo *rsinfo)
out = createPQExpBuffer();
- qualified_name = pg_strdup(fmtQualifiedDumpable(rsinfo));
-
/* restore relation stats */
appendPQExpBufferStr(out, "SELECT * FROM pg_catalog.pg_restore_relation_stats(\n");
appendPQExpBuffer(out, "\t'version', '%u'::integer,\n",
fout->remoteVersion);
- appendPQExpBufferStr(out, "\t'relation', ");
- appendStringLiteralAH(out, qualified_name, fout);
- appendPQExpBufferStr(out, "::regclass,\n");
+ appendPQExpBufferStr(out, "\t'schemaname', ");
+ appendStringLiteralAH(out, rsinfo->dobj.namespace->dobj.name, fout);
+ appendPQExpBufferStr(out, ",\n");
+ appendPQExpBufferStr(out, "\t'relname', ");
+ appendStringLiteralAH(out, rsinfo->dobj.name, fout);
+ appendPQExpBufferStr(out, ",\n");
appendPQExpBuffer(out, "\t'relpages', '%d'::integer,\n", rsinfo->relpages);
appendPQExpBuffer(out, "\t'reltuples', '%s'::real,\n", rsinfo->reltuples);
appendPQExpBuffer(out, "\t'relallvisible', '%d'::integer\n);\n",
@@ -10610,9 +10610,10 @@ dumpRelationStats(Archive *fout, const RelStatsInfo *rsinfo)
appendPQExpBufferStr(out, "SELECT * FROM pg_catalog.pg_restore_attribute_stats(\n");
appendPQExpBuffer(out, "\t'version', '%u'::integer,\n",
fout->remoteVersion);
- appendPQExpBufferStr(out, "\t'relation', ");
- appendStringLiteralAH(out, qualified_name, fout);
- appendPQExpBufferStr(out, "::regclass");
+ appendPQExpBufferStr(out, "\t'schemaname', ");
+ appendStringLiteralAH(out, rsinfo->dobj.namespace->dobj.name, fout);
+ appendPQExpBufferStr(out, ",\n\t'relname', ");
+ appendStringLiteralAH(out, rsinfo->dobj.name, fout);
if (PQgetisnull(res, rownum, i_attname))
pg_fatal("attname cannot be NULL");
@@ -10624,7 +10625,10 @@ dumpRelationStats(Archive *fout, const RelStatsInfo *rsinfo)
* their attnames are not necessarily stable across dump/reload.
*/
if (rsinfo->nindAttNames == 0)
- appendNamedArgument(out, fout, "attname", "name", attname);
+ {
+ appendPQExpBuffer(out, ",\n\t'attname', ");
+ appendStringLiteralAH(out, attname, fout);
+ }
else
{
bool found = false;
@@ -10704,7 +10708,6 @@ dumpRelationStats(Archive *fout, const RelStatsInfo *rsinfo)
.deps = deps,
.nDeps = ndeps));
- free(qualified_name);
destroyPQExpBuffer(out);
destroyPQExpBuffer(query);
}