Skip to content

Commit ae236bf

Browse files
committed
Handle NULL for short descriptions of custom GUC variables
If a short description is specified as NULL in one of the various DefineCustomXXXVariable() functions available to external modules to define a custom parameter, SHOW ALL would crash. This change teaches SHOW ALL to properly handle NULL short descriptions, as well as any code paths that manipulate it, to gain in flexibility. Note that help_config.c was already able to do that, when describing a set of GUCs for postgres --describe-config. Author: Steve Chavez Reviewed by: Nathan Bossart, Andres Freund, Michael Paquier, Tom Lane Discussion: https://postgr.es/m/CAGRrpzY6hO-Kmykna_XvsTv8P2DshGiU6G3j8yGao4mk0CqjHA%40mail.gmail.com Backpatch-through: 10
1 parent 01ab9fb commit ae236bf

File tree

1 file changed

+13
-3
lines changed
  • src/backend/utils/misc

1 file changed

+13
-3
lines changed

src/backend/utils/misc/guc.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8858,7 +8858,16 @@ ShowAllGUCConfig(DestReceiver *dest)
88588858
isnull[1] = true;
88598859
}
88608860

8861-
values[2] = PointerGetDatum(cstring_to_text(conf->short_desc));
8861+
if (conf->short_desc)
8862+
{
8863+
values[2] = PointerGetDatum(cstring_to_text(conf->short_desc));
8864+
isnull[2] = false;
8865+
}
8866+
else
8867+
{
8868+
values[2] = PointerGetDatum(NULL);
8869+
isnull[2] = true;
8870+
}
88628871

88638872
/* send it to dest */
88648873
do_tup_output(tstate, values, isnull);
@@ -8870,7 +8879,8 @@ ShowAllGUCConfig(DestReceiver *dest)
88708879
pfree(setting);
88718880
pfree(DatumGetPointer(values[1]));
88728881
}
8873-
pfree(DatumGetPointer(values[2]));
8882+
if (conf->short_desc)
8883+
pfree(DatumGetPointer(values[2]));
88748884
}
88758885

88768886
end_tup_output(tstate);
@@ -9048,7 +9058,7 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
90489058
values[3] = _(config_group_names[conf->group]);
90499059

90509060
/* short_desc */
9051-
values[4] = _(conf->short_desc);
9061+
values[4] = conf->short_desc != NULL ? _(conf->short_desc) : NULL;
90529062

90539063
/* extra_desc */
90549064
values[5] = conf->long_desc != NULL ? _(conf->long_desc) : NULL;

0 commit comments

Comments
 (0)