public inbox for [email protected]  
help / color / mirror / Atom feed
From: Michael Paquier <[email protected]>
To: Justin Pryzby <[email protected]>
Cc: Kyotaro Horiguchi <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Subject: Re: GUC flags
Date: Thu, 6 Jan 2022 14:19:08 +0900
Message-ID: <YdZ7zCymonPV4//[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>

On Wed, Jan 05, 2022 at 05:55:17PM -0600, Justin Pryzby wrote:
> pg_settings is currently defined with "SELECT *".  Is it fine to enumerate a
> list of columns instead ?

I'd like to think that this is a better practice when it comes
documenting the columns, but I don't see an actual need for this extra
complication here.

> +	initStringInfo(&ret);
> +	appendStringInfoChar(&ret, '{');
> +
> +	if (flags & GUC_NO_SHOW_ALL)
> +		appendStringInfo(&ret, "NO_SHOW_ALL,");
> +	if (flags & GUC_NO_RESET_ALL)
> +		appendStringInfo(&ret, "NO_RESET_ALL,");
> +	if (flags & GUC_NOT_IN_SAMPLE)
> +		appendStringInfo(&ret, "NOT_IN_SAMPLE,");
> +	if (flags & GUC_EXPLAIN)
> +		appendStringInfo(&ret, "EXPLAIN,");
> +	if (flags & GUC_RUNTIME_COMPUTED)
> +		appendStringInfo(&ret, "RUNTIME_COMPUTED,");
> +
> +	/* Remove trailing comma, if any */
> +	if (ret.len > 1)
> +		ret.data[--ret.len] = '\0';

The way of building the text array is incorrect here.  See
heap_tuple_infomask_flags() in pageinspect as an example with all the
HEAP_* flags.  I think that you should allocate an array of Datums,
use CStringGetTextDatum() to assign each array element, wrapping the
whole with construct_array() to build the final value for the
parameter tuple.
--
Michael


Attachments:

  [application/pgp-signature] signature.asc (833B, ../YdZ7zCymonPV4%2F%[email protected]/2-signature.asc)
  download

view thread (3+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: GUC flags
  In-Reply-To: <YdZ7zCymonPV4//[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox