Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1b40cee

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 ef54a65 commit 1b40cee

File tree

1 file changed

+12
-2
lines changed
  • src/backend/utils/misc

1 file changed

+12
-2
lines changed

src/backend/utils/misc/guc.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8079,7 +8079,16 @@ ShowAllGUCConfig(DestReceiver *dest)
80798079
isnull[1] = true;
80808080
}
80818081

8082-
values[2] = PointerGetDatum(cstring_to_text(conf->short_desc));
8082+
if (conf->short_desc)
8083+
{
8084+
values[2] = PointerGetDatum(cstring_to_text(conf->short_desc));
8085+
isnull[2] = false;
8086+
}
8087+
else
8088+
{
8089+
values[2] = PointerGetDatum(NULL);
8090+
isnull[2] = true;
8091+
}
80838092

80848093
/* send it to dest */
80858094
do_tup_output(tstate, values, isnull);
@@ -8091,7 +8100,8 @@ ShowAllGUCConfig(DestReceiver *dest)
80918100
pfree(setting);
80928101
pfree(DatumGetPointer(values[1]));
80938102
}
8094-
pfree(DatumGetPointer(values[2]));
8103+
if (conf->short_desc)
8104+
pfree(DatumGetPointer(values[2]));
80958105
}
80968106

80978107
end_tup_output(tstate);

0 commit comments

Comments
 (0)