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 1wVbF3-0024YL-0x for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Jun 2026 20:34:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wVbF2-00Ee53-0a for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Jun 2026 20:34:08 +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 1wVbF1-00Ee4p-2A for pgsql-hackers@lists.postgresql.org; Fri, 05 Jun 2026 20:34:07 +0000 Received: from fhigh-b6-smtp.messagingengine.com ([202.12.124.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wVbEy-00000001UIc-3oSo for pgsql-hackers@lists.postgresql.org; Fri, 05 Jun 2026 20:34:07 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id 720637A011F; Fri, 5 Jun 2026 16:34:02 -0400 (EDT) Received: from phl-imap-15 ([10.202.2.104]) by phl-compute-05.internal (MEProxy); Fri, 05 Jun 2026 16:34:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=partin.io; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1780691642; x=1780778042; bh=+wxPyOtKtNCYeS4YZLVUixIpwZZnvcJjgD/bLoJWSU4=; b= fQWXsU+T7kfUjN1QKqr9El9Gua+StLVXbpcUL07ZJG4Fux6oSaca5LKkdpPecwKe 8DbDyz1NhbRQAUpx10A+K6o5sI1NDftlDM1DG4pyXXrYezrfz06n5ugJttCzfpo+ JS6n7tixqntsR8qHNqVlQlSnepjozgLpZUoM66m/O306tfGNQBUun/JsQamXszkG B57SKZvWcvPvEsMLJzXNMYejToFrNxC75LEZ1WM3nWI91QJPHMM2YzT+EJCPjqIe oIHS3G9t9nOav6ubIm1CngOSw+t88VXIWdVYCXnFpOsF8iWPOvAG908x3NyLj5UK qCc5YzkJtw+DNk2qGqCo1A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1780691642; x= 1780778042; bh=+wxPyOtKtNCYeS4YZLVUixIpwZZnvcJjgD/bLoJWSU4=; b=L dN5laWd1MR0cyxJYepeYqNKSD7H4QnGsXNkIrdXprIB7L+Iil/uolXzD78RIp+5m 1mOyleg3cOZ60oprLatXhLBlyJHUbK6tjkKCR/5qJC2/kyReA6YcUY5YDgX+SHzy KOAi884H16n4vdj0DlPP2iuo+DNQHamLwgazVilh3Q56ewwVCMjEJREofR+ylaRq i2UA4Qiv5jlQnh7rfWQC9Z45+8EI1C2TwiPe9Dyc3aL4WHB2mizAm9Y7bmU+1rFZ IXP32DkgUnOxDekaxqGnwjO8MLVsZByaEQabcLncX8KL6rQX8qttvlGnW7gh1Hue gEAdOx5HDaMoszz2A0PNw== X-ME-Sender: X-ME-Proxy-Cause: dmFkZTEgh6KlGb7FH5zrTNFU7FuMgn6EkQc5FEVk7faZM4EwSAMcw59JJ71+6rge8xxtCE Lr+1/fc75X9B9tDebQecLW/QorsNOfUr7zjhMgEb611F4n2We7GO7UN2Qq6sYQAXhymDbl ddfhrgz4gZFhmuBpxebctfO7R7K5yHdMkaZk/08tXA+Ho+asfOI8nFy/fxtMM73nUsce83 j3XwiG1cNEQozhT6orrH3pqndjzpzwFkBQZFQVt+O/6kwYLLKfb0pMyyDeHsxrxYTwPW4X e3d9I0HJvOgK/MxMBjnl1z885aYdY3f6DUX5oKMgqZ4HNyk7hx0j32q4XwO2eFqq0ONGHa Mm7ebs7l5hbNTi7gjg94WZ7+zT3RamSkSxMs8AjFGa2z/7w/IpvgeGntfx3It0KFhJ1oeD ZBToWB23k+KPcHBBdPG2k4kUyxLOT5drg26lifNBNFYv5mwA1Bo4n8/0NDxl8/ZK2+Q9Ma 6NWZWNHSEtqghfx7ayumOM7xteuCS9TnVwEoab/5cCjnP7saNvD2ve8vCWtIVhQzYs97vM ViTsr6flCZV8OU8Oa8qDCDMUN4dE/EYB+/ehYFOA0qW9N8EN/S84pRmFirraq9M63IRGei LjIC/3kGZD4xTSDzSS+SYpcVZmnYzX6AWaQk19hX9NrQtGFHS6LfO/HQsQGw X-ME-Proxy: Feedback-ID: idd01497b:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 0AF43780070; Fri, 5 Jun 2026 16:34:02 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 05 Jun 2026 20:34:01 +0000 Message-Id: Subject: Re: Prevent remote libpq notices from being sent to clients To: "Chao Li" From: "Tristan Partin" Cc: "Fujii Masao" , "vignesh C" , "Postgres hackers" X-Mailer: aerc 0.21.0 References: <396C3BEE-CD4D-450A-8D28-E708E9AA4075@gmail.com> In-Reply-To: <396C3BEE-CD4D-450A-8D28-E708E9AA4075@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri Jun 5, 2026 at 9:32 AM UTC, Chao Li wrote: > Hi, > > This is another issue with =E2=80=9C[112faf137] Log remote NOTICE, WARNIN= G, and similar messages using ereport()=E2=80=9D. From the commit message, = the intention of the feature is to log remote messages with ereport() to ge= t better formatting: > ``` > Log remote NOTICE, WARNING, and similar messages using ereport(). > > Previously, NOTICE, WARNING, and similar messages received from remot= e > servers over replication, postgres_fdw, or dblink connections were pr= inted > directly to stderr on the local server (e.g., the subscriber). As a r= esult, > these messages lacked log prefixes (e.g., timestamp), making them har= der > to trace and correlate with other log entries. > > This commit addresses the issue by introducing a custom notice receiv= er > for replication, postgres_fdw, and dblink connections. These messages > are now logged via ereport(), ensuring they appear in the logs with p= roper > formatting and context, which improves clarity and aids in debugging. > ``` > > So remote messages should only be output to the server log, but currently= they can leak to the client if client_min_messages is set to log. > > This is a simple repro: > ``` > evantest=3D# set client_min_messages=3Dlog; > SET > evantest=3D# select * from dblink('host=3Dlocalhost dbname=3Dpostgres=E2= =80=99, > 'do $$ begin raise warning ''hello, client!!!''; end $$; select 1=E2=80= =99) > as t(x int); > LOG: received message via remote connection: WARNING: hello, client!!! > x > --- > 1 > (1 row) > ``` > > The one-line fix is straightforward, just change the ereport() level from= LOG to LOG_SERVER_ONLY. I also added a test in the patch. This looks good to me. Do you think we should also copy the test to=20 postgres_fdw? Or, I wonder if there is an even better location for the=20 test outside of either's regression suite. --=20 Tristan Partin PostgreSQL Contributors Team AWS (https://aws.amazon.com)