Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vT9W4-00E9El-2j for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Dec 2025 02:01:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vT9W3-0092ZL-13 for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Dec 2025 02:01:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vT9W2-0092ZC-2z for pgsql-hackers@lists.postgresql.org; Wed, 10 Dec 2025 02:01:19 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vT9W0-004Ap3-2o for pgsql-hackers@lists.postgresql.org; Wed, 10 Dec 2025 02:01:18 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2981f9ce15cso83280845ad.1 for ; Tue, 09 Dec 2025 18:01:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765332073; x=1765936873; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LzErUb+opkgqTvH5JY54Ghku3xYBtbHZcuo/XjAiORE=; b=VNlo6Tx8BbC9Bei9cY6xr4912bUwvb8LAbtdzyF/JY/1xYr9yamG/HymdhoqZhiK8f 60pYLrsmKNfUWoaWsKexfnTt7e1O0qnPxPsjUIrEOcfl6G1K35InRgRchg5Vm1tnmRoq xIiwcfC+Qj32fAMUsv47p4RXIfct5iNNVjuRPaE4OBUHnyIG5uRmWqIyszCZ3yJ5jZhn oZuEgqWjFVfYxe5aTL+0ngv77e17P6jiPQA+LeCZW6eBHEbV2f0PFeb4X3GQBtoBMlPq GwiQcJywNnCuoQ3WSbLUql5bcevD3+KiM57JUEhjezAmiXKwjBDQUKEg1/sSE2ZFikob HHog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765332073; x=1765936873; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=LzErUb+opkgqTvH5JY54Ghku3xYBtbHZcuo/XjAiORE=; b=DcthFOsl8sGqwTjjrGXPWLCYk5gc9D5ch8k2xJLuBBb+CfMB2jvnC+KIIvn3a3+5Kt U5D3T1YYzWlzGOR8N8AKBBp0ZzaVDIa6bWgT1JIZrNDENTdl2s/caAdeU9x5/2/e3GXO K9SSHCJTMlLCa/vEPvONJJnCeCFc71C17Hz1Pz/cT7gjfCaBrLPBWzoOf8soQzSJwpd7 Ah5vzhlmbHatpLnwyposRnxPDGGwqpocRYj2qwN2Oinghl2qTcTtZy2IPcWH/mzuRH+e MxHZhP8aCikrVN8anIcy5GWtXVcYxz4LhD8oc70ELsLAGPDWbOWOpZ7WvtOmb4NRuaPT kk9w== X-Forwarded-Encrypted: i=1; AJvYcCUURmJT7BYdysuFhGDae3DWFamoZOtAk3vZ1tt6MVV6vPXhjmJFyj1kXp1VLu5/vS27MCthDMvmKlrc8B5E@lists.postgresql.org X-Gm-Message-State: AOJu0YxQxWq/dSlvnLNTNJ1/XFugvqNl4oXH3SG5X3tiljbIzZBZK+ma LB/b2HGzk090p5eP+363+T5pvqtZtdT8pEK3q7InzxG6mjBaG5kJj5VQ X-Gm-Gg: AY/fxX43wvjCmKSCyIH261loeg0NwsNfMqPC5od1V4/RkktOCqK8WUT+w8cMNPPrHGl qgmNHKsxy2UHm7Ib24nG05pI1efH6Ak6IVpyYPJTOBoQzEUdbDezURjL05pn0T3/cgLmht9NG6T Gc8O++jo/HjrAqBWXAgxvf1aBbF9FmEiLEnriAAJLITPN3u8+l9UoQ5i56m/tYdapzA8NSeFSFz W2gyA9iRw9rEVp3ztYggfEIeQBqwMqgjC0GmCnBb/pEk9ibcXhGDsxxBPJNk4P9CdR8rlbcoJ7D aK4MYUN09mJL7miDxGt8VYrfSkW5wp9VW9EgzOKaIjbl7JGvNZcGNfUejH81WU2nzgefr07mvfw 697KeZxU87UtmDew1uYXC9dkkPKnA6Lyqoe4bDYkOttR5o0lrhiGTeodXvuq9oboYYGY2jkmSZr NA9HEloTyean+yL5jktnZnHxs2f0Z0pg== X-Google-Smtp-Source: AGHT+IFNGl5LvHjsxVHsv+6Aa5olr/AlSwE4ym5p5KbCW33OR0TS/RAHvApCbZxykmxh2XmldZhc/w== X-Received: by 2002:a17:902:e551:b0:295:592e:7633 with SMTP id d9443c01a7336-29ec2d3c3c4mr7726655ad.29.1765332073179; Tue, 09 Dec 2025 18:01:13 -0800 (PST) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29dae99f052sm164765575ad.47.2025.12.09.18.01.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Dec 2025 18:01:12 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: log_min_messages per backend type From: Chao Li In-Reply-To: <202512091806.bsugq2l4wz7f@alvherre.pgsql> Date: Wed, 10 Dec 2025 10:00:36 +0800 Cc: Euler Taveira , japin , Andres Freund , pgsql-hackers@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <1130A10B-E7AE-49F3-9E13-2CD69B3F9DFD@gmail.com> References: <202512091806.bsugq2l4wz7f@alvherre.pgsql> To: Alvaro Herrera X-Mailer: Apple Mail (2.3826.700.81) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Dec 10, 2025, at 02:24, Alvaro Herrera = wrote: >=20 > On 2025-Dec-09, Alvaro Herrera wrote: >=20 >> So here's your v6 again with those fixes as 0003 -- let's see what CI >> thinks of this. I haven't looked at your doc changes yet. >=20 > This passed CI, so I have marked it as Ready for Committer. Further > comments are still welcome, of course, but if there are none, I intend > to get it committed in a few days. >=20 >=20 > I'm not really happy with our usage of the translatable description > field for things such as %b in log_line_prefix or the ps display; I > think we should use the shorter names there instead. Otherwise, you = end > up with log lines that look something like this (visible in a server > with %b in log_line_prefix, which the TAP tests as well as pg_regress > have): >=20 > 2025-12-08 21:38:04.304 CET autovacuum launcher[2452437] DEBUG: = autovacuum launcher started >=20 > where the bit before the PID is marked for translation. I think it > should rather be >=20 > 2025-12-08 21:38:04.304 CET autovacuum[2452437] DEBUG: autovacuum = launcher started >=20 > where that name (the same we'll use in log_min_messages) is not > translated. >=20 > However, this issue is rather independent of the patch in this thread, > so I'm going to discuss it in another thread; the name string though = is > added by this patch. >=20 > --=20 > =C3=81lvaro Herrera Breisgau, Deutschland =E2=80=94 = https://www.EnterpriseDB.com/ > "Java is clearly an example of money oriented programming" (A. = Stepanov) Overall the patch is solid, I just have a couple of suggestions: 1 - user experience ``` evantest=3D# show log_min_messages; log_min_messages --------------------- warning,backend:log (1 row) ``` Now =E2=80=9Cshow log_min_messages=E2=80=9D prints the raw string the = user set, in above example, there is not a white-space between the two = log levels, and =E2=80=9Cshow=E2=80=9D result doesn=E2=80=99t have a = white-space between the two log levels either. IMO, =E2=80=9CSHOW = log_min_messages=E2=80=9D should display a stable result, in other = words, say =E2=80=9Cfatal, backend:log=E2=80=9D and =E2=80=9Cbackend:log, = fatal=E2=80=9D 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. 2 - refactoring for 0001 ``` + sep =3D strchr(tok, ':'); + if (sep =3D=3D NULL) + { + bool found =3D false; + + /* Reject duplicates for generic log level. */ + if (genericlevel !=3D -1) + { + GUC_check_errdetail("Generic log level = was already assigned."); + guc_free(rawstring); + list_free(elemlist); + return false; + } + + /* Is the log level valid? */ + for (entry =3D server_message_level_options; = entry && entry->name; entry++) + { + if (pg_strcasecmp(entry->name, tok) =3D=3D= 0) + { + genericlevel =3D entry->val; + found =3D true; + break; + } + } + + if (!found) + { + GUC_check_errdetail("Unrecognized log = level: \"%s\".", tok); + guc_free(rawstring); + list_free(elemlist); + return false; + } + } + else + { + char *loglevel; + char *ptype; + bool found =3D false; + + ptype =3D guc_malloc(LOG, (sep - tok) + 1); + if (!ptype) + { + guc_free(rawstring); + list_free(elemlist); + return false; + } + memcpy(ptype, tok, sep - tok); + ptype[sep - tok] =3D '\0'; + loglevel =3D sep + 1; + + /* Is the log level valid? */ + for (entry =3D server_message_level_options; = entry && entry->name; entry++) + { + if (pg_strcasecmp(entry->name, loglevel) = =3D=3D 0) + { + found =3D true; + break; + } + } + + if (!found) + { + GUC_check_errdetail("Unrecognized log = level: \"%s\".", loglevel); + guc_free(ptype); + guc_free(rawstring); + list_free(elemlist); + return false; + } ``` In the =E2=80=9Cif=E2=80=9D and =E2=80=9Celse=E2=80=9D clauses, there = are duplicate code to valid log levels. We should refactor the code to = avoid the duplication. For example, pull up =E2=80=9Cloglevel=E2=80=9D = to the =E2=80=9Cfor=E2=80=9D loop level, then we can valid it after the = =E2=80=9Cif-else=E2=80=9D. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/