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-20T17:12:00Z
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)



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Cleanup for log_min_messages changes in 38e0190ced71

  2. Allow log_min_messages to be set per process type

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

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

  5. Sort guc_parameters.dat alphabetically by name

  6. Create a separate file listing backend types

  7. Replace postmaster.c's own backend type codes with BackendType