Commit fe441a03 authored by Michael Paquier's avatar Michael Paquier

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
parent b4be4a08
...@@ -9415,7 +9415,16 @@ ShowAllGUCConfig(DestReceiver *dest) ...@@ -9415,7 +9415,16 @@ ShowAllGUCConfig(DestReceiver *dest)
isnull[1] = true; isnull[1] = true;
} }
if (conf->short_desc)
{
values[2] = PointerGetDatum(cstring_to_text(conf->short_desc)); values[2] = PointerGetDatum(cstring_to_text(conf->short_desc));
isnull[2] = false;
}
else
{
values[2] = PointerGetDatum(NULL);
isnull[2] = true;
}
/* send it to dest */ /* send it to dest */
do_tup_output(tstate, values, isnull); do_tup_output(tstate, values, isnull);
...@@ -9427,6 +9436,7 @@ ShowAllGUCConfig(DestReceiver *dest) ...@@ -9427,6 +9436,7 @@ ShowAllGUCConfig(DestReceiver *dest)
pfree(setting); pfree(setting);
pfree(DatumGetPointer(values[1])); pfree(DatumGetPointer(values[1]));
} }
if (conf->short_desc)
pfree(DatumGetPointer(values[2])); pfree(DatumGetPointer(values[2]));
} }
...@@ -9598,7 +9608,7 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow) ...@@ -9598,7 +9608,7 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
values[3] = _(config_group_names[conf->group]); values[3] = _(config_group_names[conf->group]);
/* short_desc */ /* short_desc */
values[4] = _(conf->short_desc); values[4] = conf->short_desc != NULL ? _(conf->short_desc) : NULL;
/* extra_desc */ /* extra_desc */
values[5] = conf->long_desc != NULL ? _(conf->long_desc) : NULL; values[5] = conf->long_desc != NULL ? _(conf->long_desc) : NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment