Skip to content

Commit fe441a0

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 b4be4a0 commit fe441a0

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
@@ -9415,7 +9415,16 @@ ShowAllGUCConfig(DestReceiver *dest)
94159415
isnull[1] = true;
94169416
}
94179417

9418-
values[2] = PointerGetDatum(cstring_to_text(conf->short_desc));
9418+
if (conf->short_desc)
9419+
{
9420+
values[2] = PointerGetDatum(cstring_to_text(conf->short_desc));
9421+
isnull[2] = false;
9422+
}
9423+
else
9424+
{
9425+
values[2] = PointerGetDatum(NULL);
9426+
isnull[2] = true;
9427+
}
94199428

94209429
/* send it to dest */
94219430
do_tup_output(tstate, values, isnull);
@@ -9427,7 +9436,8 @@ ShowAllGUCConfig(DestReceiver *dest)
94279436
pfree(setting);
94289437
pfree(DatumGetPointer(values[1]));
94299438
}
9430-
pfree(DatumGetPointer(values[2]));
9439+
if (conf->short_desc)
9440+
pfree(DatumGetPointer(values[2]));
94319441
}
94329442

94339443
end_tup_output(tstate);
@@ -9598,7 +9608,7 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
95989608
values[3] = _(config_group_names[conf->group]);
95999609

96009610
/* short_desc */
9601-
values[4] = _(conf->short_desc);
9611+
values[4] = conf->short_desc != NULL ? _(conf->short_desc) : NULL;
96029612

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

0 commit comments

Comments
 (0)