Re: log_min_messages per backend type

Euler Taveira <euler@eulerto.com>

From: "Euler Taveira" <euler@eulerto.com>
To: "Chao Li" <li.evan.chao@gmail.com>, "Alvaro Herrera" <alvherre@alvh.no-ip.org>
Cc: japin <japinli@hotmail.com>, "Andres Freund" <andres@anarazel.de>, pgsql-hackers@lists.postgresql.org
Date: 2025-12-11T01:57:51Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Allow log_min_messages to be set per process type

  2. Assign "backend" type earlier during process start-up

  3. Use integer backend type when exec'ing a postmaster child

  4. Sort guc_parameters.dat alphabetically by name

  5. Create a separate file listing backend types

On Tue, Dec 9, 2025, at 11:00 PM, Chao Li wrote:
> Now “show log_min_messages” prints the raw string the user set, in 
> above example, there is not a white-space between the two log levels, 
> and “show” result doesn’t have a white-space between the two log levels 
> either. IMO, “SHOW log_min_messages” should display a stable result, in 
> other words, say “fatal, backend:log” and “backend:log, fatal” should 
> show the same result as they are actually meaning the same. So, I would 
> suggest normalize the raw string: put the general level in the first 
> place and sort others by process type, then SHOW returns the normalized 
> string.
>

I thought about it but leave it alone because (a) it would increase this patch
footprint and (b) the input might be different from the output. I could also be
done in another patch but under reflection an unstable output can break tests
or whatever uses the SHOW log_min_messages output. I thought this change would
require a new show_log_min_messages to manipulate the input again but we can
reassign the GUC value after sorting the existing list and creating a new string
list.

> In the “if” and “else” clauses, there are duplicate code to valid log 
> levels. We should refactor the code to avoid the duplication. For 
> example, pull up “loglevel” to the “for” loop level, then we can valid 
> it after the “if-else”.
>

The for loop is duplicate but if you create a separate function for it but the
result is:

 src/backend/commands/variable.c | 43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)


I'll post a patch in a couple of hours after spend more time in it.


-- 
Euler Taveira
EDB   https://www.enterprisedb.com/