public inbox for [email protected]  
help / color / mirror / Atom feed
From: Alvaro Herrera <[email protected]>
To: Euler Taveira <[email protected]>
Cc: japin <[email protected]>
Cc: Andres Freund <[email protected]>
Cc: [email protected]
Cc: Chao Li <[email protected]>
Subject: Re: log_min_messages per backend type
Date: Sat, 17 Jan 2026 23:02:47 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 2026-Jan-15, Euler Taveira wrote:

> +	/*
> +	 * Use a stable representation of log_min_messages. The generic level is
> +	 * always the first element and the other elements (type:level) are sorted
> +	 * by process type.
> +	 */
> +	list_sort(elemlist, string_cmp);
> +	foreach(l, elemlist)
> +	{
> +		char	   *tok = (char *) lfirst(l);
> +
> +		if (strchr(tok, ':') == NULL)
> +		{
> +			elemlist = list_delete(elemlist, tok);
> +			elemlist = lcons(tok, elemlist);
> +			break;
> +		}
> +	}

> +static int
> +string_cmp(const ListCell *a, const ListCell *b)
> +{
> +	const char *s = lfirst(a);
> +	const char *t = lfirst(b);
> +
> +	return strcmp(s, t);
> +}

I'm not opposed to this idea, but I think it should be implemented not
by sorting and then moving the first element to the top of the list, but
instead by modifying the cmp function so that the desired order is
achieved directly.  So the cmp() should return -1 if element a has no
colon, or 1 if element b has no colon, otherwise return per strcmp.
That way you can remove the foreach() block above, which is icky.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"Computing is too important to be left to men." (Karen Spärck Jones)






view thread (4+ messages)  latest in thread

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]
  Subject: Re: log_min_messages per backend type
  In-Reply-To: <[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