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 1vYRbs-003beA-0R for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Dec 2025 16:21:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vYRbp-0056dO-21 for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Dec 2025 16:21:10 +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 1vYRbp-0056dF-0o for pgsql-hackers@lists.postgresql.org; Wed, 24 Dec 2025 16:21:10 +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 1vYRbk-002Xvv-12 for pgsql-hackers@lists.postgresql.org; Wed, 24 Dec 2025 16:21:09 +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 5BOGL0Em928502; Wed, 24 Dec 2025 11:21:00 -0500 From: Tom Lane To: Julien Rouhaud cc: pgsql-hackers@lists.postgresql.org Subject: Re: Cleaning up PREPARE query strings? In-reply-to: References: Comments: In-reply-to Julien Rouhaud message dated "Wed, 24 Dec 2025 23:43:13 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <928500.1766593260.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 24 Dec 2025 11:21:00 -0500 Message-ID: <928501.1766593260@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Julien Rouhaud writes: > I'm attaching a POC patch to fix that behavior by teaching PREPARE to cl= ean the > passed query text the same way as pg_stat_statements. This patch invalidates all the location fields in the parsed query: they could not be used to generate sane error cursors referencing the truncated string. I'm not sure how many places try to generate such errors post-parsing, but it's more than zero, and I've long had ambitions of trying to extend that substantially (e.g, allowing execution-time errors from functions to point at the relevant function call). Certainly the patch could be extended to update all those fields, but that increases its complexity very significantly. I doubt that it's worth it. My reaction to your example is more like "if that bothers you, don't do it that way". regards, tom lane