Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8ea8178

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 65a3f23 commit 8ea8178

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/bin/pg_dump/pg_dump.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -11237,12 +11237,12 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
1123711237
/* Dump Proc Lang Comments and Security Labels */
1123811238
if (plang->dobj.dump & DUMP_COMPONENT_COMMENT)
1123911239
dumpComment(fout, labelq->data,
11240-
NULL, "",
11240+
lanschema, plang->lanowner,
1124111241
plang->dobj.catId, 0, plang->dobj.dumpId);
1124211242

1124311243
if (plang->dobj.dump & DUMP_COMPONENT_SECLABEL)
1124411244
dumpSecLabel(fout, labelq->data,
11245-
NULL, "",
11245+
lanschema, plang->lanowner,
1124611246
plang->dobj.catId, 0, plang->dobj.dumpId);
1124711247

1124811248
if (plang->lanpltrusted && plang->dobj.dump & DUMP_COMPONENT_ACL)
@@ -12044,7 +12044,7 @@ dumpCast(Archive *fout, CastInfo *cast)
1204412044
/* Dump Cast Comments */
1204512045
if (cast->dobj.dump & DUMP_COMPONENT_COMMENT)
1204612046
dumpComment(fout, labelq->data,
12047-
NULL, "",
12047+
"pg_catalog", "",
1204812048
cast->dobj.catId, 0, cast->dobj.dumpId);
1204912049

1205012050
free(sourceType);
@@ -12168,7 +12168,7 @@ dumpTransform(Archive *fout, TransformInfo *transform)
1216812168
/* Dump Transform Comments */
1216912169
if (transform->dobj.dump & DUMP_COMPONENT_COMMENT)
1217012170
dumpComment(fout, labelq->data,
12171-
NULL, "",
12171+
"pg_catalog", "",
1217212172
transform->dobj.catId, 0, transform->dobj.dumpId);
1217312173

1217412174
free(lanname);
@@ -13009,7 +13009,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
1300913009
/* Dump Operator Class Comments */
1301013010
if (opcinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
1301113011
dumpComment(fout, labelq->data,
13012-
NULL, opcinfo->rolname,
13012+
opcinfo->dobj.namespace->dobj.name, opcinfo->rolname,
1301313013
opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId);
1301413014

1301513015
free(amname);
@@ -13282,7 +13282,7 @@ dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo)
1328213282
/* Dump Operator Family Comments */
1328313283
if (opfinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
1328413284
dumpComment(fout, labelq->data,
13285-
NULL, opfinfo->rolname,
13285+
opfinfo->dobj.namespace->dobj.name, opfinfo->rolname,
1328613286
opfinfo->dobj.catId, 0, opfinfo->dobj.dumpId);
1328713287

1328813288
free(amname);
@@ -14054,7 +14054,7 @@ dumpTSParser(Archive *fout, TSParserInfo *prsinfo)
1405414054
/* Dump Parser Comments */
1405514055
if (prsinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
1405614056
dumpComment(fout, labelq->data,
14057-
NULL, "",
14057+
prsinfo->dobj.namespace->dobj.name, "",
1405814058
prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId);
1405914059

1406014060
destroyPQExpBuffer(q);
@@ -14144,7 +14144,7 @@ dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo)
1414414144
/* Dump Dictionary Comments */
1414514145
if (dictinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
1414614146
dumpComment(fout, labelq->data,
14147-
NULL, dictinfo->rolname,
14147+
dictinfo->dobj.namespace->dobj.name, dictinfo->rolname,
1414814148
dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId);
1414914149

1415014150
destroyPQExpBuffer(q);
@@ -14213,7 +14213,7 @@ dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo)
1421314213
/* Dump Template Comments */
1421414214
if (tmplinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
1421514215
dumpComment(fout, labelq->data,
14216-
NULL, "",
14216+
tmplinfo->dobj.namespace->dobj.name, "",
1421714217
tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId);
1421814218

1421914219
destroyPQExpBuffer(q);
@@ -14344,7 +14344,7 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo)
1434414344
/* Dump Configuration Comments */
1434514345
if (cfginfo->dobj.dump & DUMP_COMPONENT_COMMENT)
1434614346
dumpComment(fout, labelq->data,
14347-
NULL, cfginfo->rolname,
14347+
cfginfo->dobj.namespace->dobj.name, cfginfo->rolname,
1434814348
cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId);
1434914349

1435014350
destroyPQExpBuffer(q);

0 commit comments

Comments
 (0)