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.94.2) (envelope-from ) id 1ucP8U-00CYpb-1p for pgsql-bugs@arkaria.postgresql.org; Thu, 17 Jul 2025 13:58:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ucP8Q-0031SV-P7 for pgsql-bugs@arkaria.postgresql.org; Thu, 17 Jul 2025 13:58:55 +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.94.2) (envelope-from ) id 1ucP8Q-0031SN-GQ for pgsql-bugs@lists.postgresql.org; Thu, 17 Jul 2025 13:58:55 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ucP8P-008GMe-0B for pgsql-bugs@lists.postgresql.org; Thu, 17 Jul 2025 13:58:54 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 56HDwiPa1402671; Thu, 17 Jul 2025 09:58:44 -0400 From: Tom Lane To: tim.colles@ed.ac.uk cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18989: Output of \sf does not match original source for E quoted strings (unlike \df+ used to) In-reply-to: <18989-48eab8ec8ff535fd@postgresql.org> References: <18989-48eab8ec8ff535fd@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Thu, 17 Jul 2025 10:15:47 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1402669.1752760724.1@sss.pgh.pa.us> Date: Thu, 17 Jul 2025 09:58:44 -0400 Message-ID: <1402670.1752760724@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > testdb=# create function test() returns text language sql begin atomic > select E'\x12' || 'Hello World' || E'\x12'; end; > CREATE FUNCTION > testdb=# \sf test > CREATE OR REPLACE FUNCTION public.test() > RETURNS text > LANGUAGE sql > BEGIN ATOMIC > SELECT ((''::text || 'Hello World'::text) || ''::text); > END > Hence if the output of \sf is used as the source to make some amendment to > the function the result could easily end up unintentionally different to the > original. [ shrug... ] I do not see a bug here. The control characters are there; if your editor mangles them, that's your editor's fault. There are a ton of related scenarios where you could fear that non-ASCII characters might get mangled during query editing. If we tried to prevent them all, we'd make the editing experience less pleasant not more so. Personally I'd probably write chr(12) instead of what you did here. regards, tom lane