Thank you for the reviews Nathan, Michael. I agree with handling NULL in ShowAllGUCConfig() instead.
I've attached the updated patch. -- Steve Chavez Engineering at https://supabase.com/ On Tue, 24 May 2022 at 20:21, Michael Paquier <mich...@paquier.xyz> wrote: > On Tue, May 24, 2022 at 11:41:49AM -0700, Nathan Bossart wrote: > > I would actually ERROR on this so that we aren't relying on > > --enable-cassert builds to catch it. That being said, if there's no > strong > > reason to enforce that a short description be provided, then why not > adjust > > ShowAllGUCConfig() to set that column to NULL when short_desc is missing? > > Well, issuing an ERROR on the stable branches would be troublesome for > extension developers when reloading after a minor update if they did > not set their short_desc in a custom GUC. So, while I'd like to > encourage the use of short_desc, using your suggestion to make the > code more flexible with NULL is fine by me. GetConfigOptionByNum() > does that for long_desc by the way, meaning that we also have a > problem there on a build with --enable-nls for short_desc, no? > -- > Michael >
From 7b3d1451938f37d08e692a1f252b2f71c1ae5279 Mon Sep 17 00:00:00 2001 From: Steve Chavez <st...@supabase.io> Date: Tue, 24 May 2022 23:46:40 -0500 Subject: [PATCH] Handle a NULL short_desc in ShowAllGUCConfig Prevent a segfault when using a SHOW ALL, in case a DefineCustomXXXVariable() was defined with a NULL short_desc. --- src/backend/utils/misc/guc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8e9b71375c..d7dd727d45 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -9780,7 +9780,16 @@ ShowAllGUCConfig(DestReceiver *dest) isnull[1] = true; } - values[2] = PointerGetDatum(cstring_to_text(conf->short_desc)); + if (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 */ do_tup_output(tstate, values, isnull); @@ -9792,7 +9801,10 @@ ShowAllGUCConfig(DestReceiver *dest) pfree(setting); pfree(DatumGetPointer(values[1])); } - pfree(DatumGetPointer(values[2])); + if (conf->short_desc) + { + pfree(DatumGetPointer(values[2])); + } } end_tup_output(tstate); -- 2.32.0