Re: log_min_messages per backend type
Alvaro Herrera <alvherre@alvh.no-ip.org>
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Euler Taveira <euler@eulerto.com>
Cc: japin <japinli@hotmail.com>, Andres Freund <andres@anarazel.de>, pgsql-hackers@lists.postgresql.org, Chao Li <li.evan.chao@gmail.com>
Date: 2026-01-17T22:02:47Z
Lists: pgsql-hackers
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)
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Cleanup for log_min_messages changes in 38e0190ced71
- 1efdd7cc630a 19 (unreleased) landed
-
Allow log_min_messages to be set per process type
- 38e0190ced71 19 (unreleased) landed
-
Assign "backend" type earlier during process start-up
- 0c8e082fba8d 19 (unreleased) landed
-
Use integer backend type when exec'ing a postmaster child
- f1cd34f95272 19 (unreleased) landed
-
Sort guc_parameters.dat alphabetically by name
- fce7c73fba4e 19 (unreleased) cited
-
Create a separate file listing backend types
- dbf8cfb4f02e 19 (unreleased) cited
-
Replace postmaster.c's own backend type codes with BackendType
- 18d67a8d7d30 18.0 cited