Re: Cleaning up PREPARE query strings?
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Julien Rouhaud <rjuju123@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2025-12-24T16:21:00Z
Lists: pgsql-hackers
Julien Rouhaud <rjuju123@gmail.com> writes: > I'm attaching a POC patch to fix that behavior by teaching PREPARE to clean 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