Improve GetConfigOptionValues function

2023-01-17 Thread Nitin Jadhav
Hi, GetConfigOptionValues function extracts the config parameters for the given variable irrespective of whether it results in noshow or not. But the parent function show_all_settings ignores the values parameter if it results in noshow. It's unnecessary to fetch all the values during noshow. So a

Re: Improve GetConfigOptionValues function

2023-01-17 Thread Nitin Jadhav
Attaching the patch. On Wed, Jan 18, 2023 at 1:21 PM Nitin Jadhav wrote: > > Hi, > > GetConfigOptionValues function extracts the config parameters for the > given variable irrespective of whether it results in noshow or not. > But the parent function show_all_settings ignores the values parameter

Re: Improve GetConfigOptionValues function

2023-01-18 Thread Bharath Rupireddy
On Wed, Jan 18, 2023 at 1:24 PM Nitin Jadhav wrote: > > Attaching the patch. > > On Wed, Jan 18, 2023 at 1:21 PM Nitin Jadhav > wrote: > > > > Hi, > > > > GetConfigOptionValues function extracts the config parameters for the > > given variable irrespective of whether it results in noshow or not.

Re: Improve GetConfigOptionValues function

2023-01-18 Thread Tom Lane
Nitin Jadhav writes: > GetConfigOptionValues function extracts the config parameters for the > given variable irrespective of whether it results in noshow or not. > But the parent function show_all_settings ignores the values parameter > if it results in noshow. It's unnecessary to fetch all the v

Re: Improve GetConfigOptionValues function

2023-01-18 Thread Bharath Rupireddy
On Wed, Jan 18, 2023 at 9:44 PM Tom Lane wrote: > > Possibly a better answer is to refactor into separate functions, > along the lines of > > static bool > ConfigOptionIsShowable(struct config_generic *conf) > > static void > GetConfigOptionValues(struct config_generic *conf, const char **values)

Re: Improve GetConfigOptionValues function

2023-01-19 Thread Nitin Jadhav
> Yes, the existing caller isn't using the fetched values when noshow is > set to true. However, I think returning from GetConfigOptionValues() > when noshow is set to true without fetching values limits the use of > the function. What if someother caller wants to use the function to > get the valu

Re: Improve GetConfigOptionValues function

2023-01-19 Thread Nitin Jadhav
> Possibly a better answer is to refactor into separate functions, > along the lines of > > static bool > ConfigOptionIsShowable(struct config_generic *conf) > > static void > GetConfigOptionValues(struct config_generic *conf, const char **values) Nice suggestion. Attached a patch for the same. Pl

Re: Improve GetConfigOptionValues function

2023-01-22 Thread Bharath Rupireddy
On Thu, Jan 19, 2023 at 3:27 PM Nitin Jadhav wrote: > > > Possibly a better answer is to refactor into separate functions, > > along the lines of > > > > static bool > > ConfigOptionIsShowable(struct config_generic *conf) > > > > static void > > GetConfigOptionValues(struct config_generic *conf, c

Re: Improve GetConfigOptionValues function

2023-01-23 Thread Nitin Jadhav
> The v2 patch looks good to me except the comment around > ConfigOptionIsShowable() which is too verbose. How about just "Return > whether the GUC variable is visible or not."? Sounds good. Updated in the v3 patch attached. > I think you can add it to CF, if not done, to not lose track of it.

Re: Improve GetConfigOptionValues function

2023-01-23 Thread Bharath Rupireddy
On Mon, Jan 23, 2023 at 3:29 PM Nitin Jadhav wrote: > > > The v2 patch looks good to me except the comment around > > ConfigOptionIsShowable() which is too verbose. How about just "Return > > whether the GUC variable is visible or not."? > > Sounds good. Updated in the v3 patch attached. > > > I t

Re: Improve GetConfigOptionValues function

2023-01-23 Thread Tom Lane
Bharath Rupireddy writes: > LGTM. I've marked it RfC. After looking at this, it seemed to me that the factorization wasn't quite right after all: specifically, the new function could be used in several more places if it confines itself to being a privilege check and doesn't consider GUC_NO_SHOW_A

Re: Improve GetConfigOptionValues function

2023-01-24 Thread Bharath Rupireddy
On Mon, Jan 23, 2023 at 9:51 PM Tom Lane wrote: > > Bharath Rupireddy writes: > > LGTM. I've marked it RfC. > > After looking at this, it seemed to me that the factorization > wasn't quite right after all: specifically, the new function > could be used in several more places if it confines itself

Re: Improve GetConfigOptionValues function

2023-01-24 Thread Tom Lane
Bharath Rupireddy writes: > On Mon, Jan 23, 2023 at 9:51 PM Tom Lane wrote: >> Also, I intentionally dropped the GUC_NO_SHOW_ALL check in >> get_explain_guc_options, because it seems redundant given >> the preceding GUC_EXPLAIN check. It's unlikely we'd ever have >> a variable that's marked both

Re: Improve GetConfigOptionValues function

2023-01-25 Thread Nitin Jadhav
> After looking at this, it seemed to me that the factorization > wasn't quite right after all: specifically, the new function > could be used in several more places if it confines itself to > being a privilege check and doesn't consider GUC_NO_SHOW_ALL. > So more like the attached. > > You could a

Re: Improve GetConfigOptionValues function

2023-01-25 Thread Nitin Jadhav
>>> Also, I intentionally dropped the GUC_NO_SHOW_ALL check in >>> get_explain_guc_options, because it seems redundant given >>> the preceding GUC_EXPLAIN check. It's unlikely we'd ever have >>> a variable that's marked both GUC_EXPLAIN and GUC_NO_SHOW_ALL ... >>> but if we did, shouldn't the form

Re: Improve GetConfigOptionValues function

2023-01-25 Thread Tom Lane
Nitin Jadhav writes: > I agree that the developer can use both GUC_NO_SHOW_ALL and > GUC_EXPLAIN knowingly or unknowingly for a single GUC. If used by > mistake then according to the existing code (without patch), > GUC_NO_SHOW_ALL takes higher precedence whether it is marked first or > last in th

Re: Improve GetConfigOptionValues function

2023-01-26 Thread Bharath Rupireddy
On Tue, Jan 24, 2023 at 8:43 PM Tom Lane wrote: > > Bharath Rupireddy writes: > > On Mon, Jan 23, 2023 at 9:51 PM Tom Lane wrote: > >> Also, I intentionally dropped the GUC_NO_SHOW_ALL check in > >> get_explain_guc_options, because it seems redundant given > >> the preceding GUC_EXPLAIN check.

Re: Improve GetConfigOptionValues function

2023-01-27 Thread Nitin Jadhav
> Both of you are arguing as though GUC_NO_SHOW_ALL is a security > property. It is not, or at least it's so trivially bypassable > that it's useless to consider it one. All it is is a de-clutter > mechanism. Understood. If that is the case, then I am ok with the patch. Thanks & Regards, Nitin

Re: Improve GetConfigOptionValues function

2023-01-27 Thread Tom Lane
Nitin Jadhav writes: >> Both of you are arguing as though GUC_NO_SHOW_ALL is a security >> property. It is not, or at least it's so trivially bypassable >> that it's useless to consider it one. All it is is a de-clutter >> mechanism. > Understood. If that is the case, then I am ok with the patc