Skip to content

Commit 783acfd

Browse files
committed
Repair incorrect pg_dump labeling for some comments and security labels.
We attached no schema label to comments for procedural languages, casts, transforms, operator classes, operator families, or text search objects. The first three categories of objects don't really have schemas, but pg_dump treats them as if they do, and it seems like the TocEntry fields for their comments had better match the TocEntry fields for the parent objects. (As an example of a possible hazard, the type names in a CAST will be formatted with the assumption of a particular search_path, so failing to ensure that this same path is active for the COMMENT ON command could lead to an error or to attaching the comment to the wrong cast.) In the last six cases, this was a flat-out error --- possibly mine to begin with, but it was a long time ago. The security label for a procedural language was likewise not correctly labeled as to schema, and both the comment and security label for a procedural language were not correctly labeled as to owner. In simple cases the restore would accidentally work correctly anyway, since these comments and security labels would normally get emitted right after the owning object, and so the search path and active user would be correct anyhow. But it could fail in corner cases; for example a schema-selective restore would omit comments it should include. Giuseppe Broccolo noted the oversight, and proposed the correct fix, for text search dictionary objects; I found the rest by cross-checking other dumpComment() calls. These oversights are ancient, so back-patch all the way. Discussion: https://postgr.es/m/CAFzmHiWwwzLjzwM4x5ki5s_PDMR6NrkipZkjNnO3B0xEpBgJaA@mail.gmail.com
1 parent 7f831f0 commit 783acfd

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9561,10 +9561,10 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
95619561

95629562
/* Dump Proc Lang Comments and Security Labels */
95639563
dumpComment(fout, labelq->data,
9564-
NULL, "",
9564+
lanschema, plang->lanowner,
95659565
plang->dobj.catId, 0, plang->dobj.dumpId);
95669566
dumpSecLabel(fout, labelq->data,
9567-
NULL, "",
9567+
lanschema, plang->lanowner,
95689568
plang->dobj.catId, 0, plang->dobj.dumpId);
95699569

95709570
if (plang->lanpltrusted)
@@ -10273,7 +10273,7 @@ dumpCast(Archive *fout, CastInfo *cast)
1027310273

1027410274
/* Dump Cast Comments */
1027510275
dumpComment(fout, labelq->data,
10276-
NULL, "",
10276+
"pg_catalog", "",
1027710277
cast->dobj.catId, 0, cast->dobj.dumpId);
1027810278

1027910279
destroyPQExpBuffer(defqry);
@@ -11012,7 +11012,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
1101211012

1101311013
/* Dump Operator Class Comments */
1101411014
dumpComment(fout, labelq->data,
11015-
NULL, opcinfo->rolname,
11015+
opcinfo->dobj.namespace->dobj.name, opcinfo->rolname,
1101611016
opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId);
1101711017

1101811018
free(amname);
@@ -11282,7 +11282,7 @@ dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo)
1128211282

1128311283
/* Dump Operator Family Comments */
1128411284
dumpComment(fout, labelq->data,
11285-
NULL, opfinfo->rolname,
11285+
opfinfo->dobj.namespace->dobj.name, opfinfo->rolname,
1128611286
opfinfo->dobj.catId, 0, opfinfo->dobj.dumpId);
1128711287

1128811288
free(amname);
@@ -11805,7 +11805,7 @@ dumpTSParser(Archive *fout, TSParserInfo *prsinfo)
1180511805

1180611806
/* Dump Parser Comments */
1180711807
dumpComment(fout, labelq->data,
11808-
NULL, "",
11808+
prsinfo->dobj.namespace->dobj.name, "",
1180911809
prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId);
1181011810

1181111811
destroyPQExpBuffer(q);
@@ -11892,7 +11892,7 @@ dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo)
1189211892

1189311893
/* Dump Dictionary Comments */
1189411894
dumpComment(fout, labelq->data,
11895-
NULL, dictinfo->rolname,
11895+
dictinfo->dobj.namespace->dobj.name, dictinfo->rolname,
1189611896
dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId);
1189711897

1189811898
destroyPQExpBuffer(q);
@@ -11958,7 +11958,7 @@ dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo)
1195811958

1195911959
/* Dump Template Comments */
1196011960
dumpComment(fout, labelq->data,
11961-
NULL, "",
11961+
tmplinfo->dobj.namespace->dobj.name, "",
1196211962
tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId);
1196311963

1196411964
destroyPQExpBuffer(q);
@@ -12086,7 +12086,7 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo)
1208612086

1208712087
/* Dump Configuration Comments */
1208812088
dumpComment(fout, labelq->data,
12089-
NULL, cfginfo->rolname,
12089+
cfginfo->dobj.namespace->dobj.name, cfginfo->rolname,
1209012090
cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId);
1209112091

1209212092
destroyPQExpBuffer(q);

0 commit comments

Comments
 (0)