Re: log_min_messages per backend type

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Euler Taveira <euler(at)eulerto(dot)com>
Cc: japin <japinli(at)hotmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Subject: Re: log_min_messages per backend type
Date: 2026-01-20 17:12:00
Message-ID: 202601201708.p3kmnsdyqdhq@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2026-Jan-15, Euler Taveira wrote:

> @@ -1275,10 +1279,16 @@ check_log_min_messages(char **newval, void **extra, GucSource source)
> char *rawstring;
> List *elemlist;
> ListCell *l;
> + char *result;
> + bool first = true;
> int newlevel[BACKEND_NUM_TYPES];
> bool assigned[BACKEND_NUM_TYPES];
> int genericlevel = -1; /* -1 means not assigned */
>
> + result = (char *) guc_malloc(LOG, MAX_LMM_STR_LEN);
> + if (!result)
> + return false;
...
> + foreach(l, elemlist)
> + {
> + char *tok = (char *) lfirst(l);
> +
> + if (first)
> + {
> + strncpy(result, tok, MAX_LMM_STR_LEN);
> + first = false;
> + }
> + else
> + {
> + strlcat(result, ", ", MAX_LMM_STR_LEN);
> + strlcat(result, tok, MAX_LMM_STR_LEN);
> + }
> + }

BTW I think this whole MAX_LMM_STR_LEN thing is unnecessary. It is
probably easy enough to use a StringInfo to create the value
iteratively, then once you know its final length do a guc_malloc() and
strcpy the value there.

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"The Gord often wonders why people threaten never to come back after they've
been told never to return" (www.actsofgord.com)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2026-01-20 17:46:19 Re: Speed up transaction completion faster after many relations are accessed in a transaction
Previous Message Vitaly Davydov 2026-01-20 17:03:55 Re: Exit walsender before confirming remote flush in logical replication