Subject: Re: log_min_messages per backend type

From: Alvaro Herrera <[email-masked]>
Date: Mon, 9 Feb 2026 13:58:35 +0100

On 2026-Feb-06, Euler Taveira wrote:

> On Fri, Feb 6, 2026, at 8:05 AM, Alvaro Herrera wrote:

> > * I'm not fond of the term "generic", so I changed it to "default",
> > which IMO makes more sense from the user point of view.
> 
> I'm fine with "default" instead of "generic". However, you forgot to replace
> "generic" in a few places. The attached patch fixes them all.

I just pushed this, and somehow I forgot to squash this into the commit.
I don't think it matters terribly much though, so I'm going to hang onto
this for a while in case some bug is found.

I made some more changes though.  Notably, I reworded some things in the
docs that appeared ungrammatical and added a simple example; added the
list of process types to postgresql.conf.sample; and moved the GUC
check/assign hooks to elog.c together with the other elog-affecting
GUCs, as I didn't think they made much sense in variable.c.

Another thing, which is actually quite significant, is that I fixed a
bug I had introduced on Friday without realizing: I had added a "break"
in the loop that searches for process types.  But we mustn't break
there!  Otherwise we fail to set the level for process types that share
the same process "category" with others, such as "backend" and
"autovacuum".  So I removed the break and added a comment about it.
It's sad that no tests broke when I introduced that bug, but I think it
would be difficult to cover this.

Thanks

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"That sort of implies that there are Emacs keystrokes which aren't obscure.
I've been using it daily for 2 years now and have yet to discover any key
sequence which makes any sense."                        (Paul Thomas)

---

From: Alvaro Herrera <[email-masked]>
Date: Mon, 9 Feb 2026 14:03:16 +0100

> this for a while in case some bug is found.

Euler mentioned offlist that I also forgot to remove
log_min_messages_process_types from guc.h.  So that gives us this patch
for now.

diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 129906e2daa..59315e94e3e 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2190,7 +2190,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source)
 	char	   *result;
 	int			newlevel[BACKEND_NUM_TYPES];
 	bool		assigned[BACKEND_NUM_TYPES] = {0};
-	int			genericlevel = -1;	/* -1 means not assigned */
+	int			defaultlevel = -1;	/* -1 means not assigned */
 
 	const char *const process_types[] = {
 #define PG_PROCTYPE(bktype, bkcategory, description, main_func, shmem_attach) \
@@ -2228,8 +2228,8 @@ check_log_min_messages(char **newval, void **extra, GucSource source)
 			const struct config_enum_entry *entry;
 			bool		found;
 
-			/* Reject duplicates for generic log level. */
-			if (genericlevel != -1)
+			/* Reject duplicates for default log level. */
+			if (defaultlevel != -1)
 			{
 				GUC_check_errdetail("Redundant specification of default log level.");
 				goto lmm_fail;
@@ -2241,7 +2241,7 @@ check_log_min_messages(char **newval, void **extra, GucSource source)
 			{
 				if (pg_strcasecmp(entry->name, elem) == 0)
 				{
-					genericlevel = entry->val;
+					defaultlevel = entry->val;
 					found = true;
 					break;
 				}
@@ -2331,9 +2331,9 @@ lmm_fail:
 	}
 
 	/*
-	 * The generic log level must be specified. It is the fallback value.
+	 * The default log level must be specified. It is the fallback value.
 	 */
-	if (genericlevel == -1)
+	if (defaultlevel == -1)
 	{
 		GUC_check_errdetail("Default log level was not defined.");
 		guc_free(rawstring);
@@ -2345,7 +2345,7 @@ lmm_fail:
 	for (int i = 0; i < BACKEND_NUM_TYPES; i++)
 	{
 		if (!assigned[i])
-			newlevel[i] = genericlevel;
+			newlevel[i] = defaultlevel;
 	}
 
 	/*
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h
index 8acbdba7ff5..c46203fabfe 100644
--- a/src/include/utils/guc.h
+++ b/src/include/utils/guc.h
@@ -329,8 +329,6 @@ extern PGDLLIMPORT bool trace_sort;
 extern PGDLLIMPORT bool optimize_bounded_sort;
 #endif
 
-extern PGDLLIMPORT const char *const log_min_messages_process_types[];
-
 /*
  * Declarations for options for enum values
  *

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"I suspect most samba developers are already technically insane...
Of course, since many of them are Australians, you can't tell." (L. Torvalds)