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

Commit 1e68029

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 9e3dbc6 commit 1e68029

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
@@ -9089,7 +9089,16 @@ ShowAllGUCConfig(DestReceiver *dest)
90899089
isnull[1] = true;
90909090
}
90919091

9092-
values[2] = PointerGetDatum(cstring_to_text(conf->short_desc));
9092+
if (conf->short_desc)
9093+
{
9094+
values[2] = PointerGetDatum(cstring_to_text(conf->short_desc));
9095+
isnull[2] = false;
9096+
}
9097+
else
9098+
{
9099+
values[2] = PointerGetDatum(NULL);
9100+
isnull[2] = true;
9101+
}
90939102

90949103
/* send it to dest */
90959104
do_tup_output(tstate, values, isnull);
@@ -9101,7 +9110,8 @@ ShowAllGUCConfig(DestReceiver *dest)
91019110
pfree(setting);
91029111
pfree(DatumGetPointer(values[1]));
91039112
}
9104-
pfree(DatumGetPointer(values[2]));
9113+
if (conf->short_desc)
9114+
pfree(DatumGetPointer(values[2]));
91059115
}
91069116

91079117
end_tup_output(tstate);
@@ -9279,7 +9289,7 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
92799289
values[3] = _(config_group_names[conf->group]);
92809290

92819291
/* short_desc */
9282-
values[4] = _(conf->short_desc);
9292+
values[4] = conf->short_desc != NULL ? _(conf->short_desc) : NULL;
92839293

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

0 commit comments

Comments
 (0)