| From: | Sami Imseih <samimseih(at)gmail(dot)com> |
|---|---|
| To: | Julien Rouhaud <rjuju123(at)gmail(dot)com> |
| Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Cleaning up PREPARE query strings? |
| Date: | 2026-03-04 21:33:13 |
| Message-ID: | CAA5RZ0saD=0w7K6HubXRBDfqKO4wBG=N=_n5kNLN0fFMs-BjOg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> It's hard to know what changed exactly as you show the diff against master
Here it is as a v4
> rather than against the patch, but IIUC the problem will be for execution time
> error location reporting, as reported before. I think that it will still be
> wrong, but may now also point to an offset that isn't in the query text.
> I still haven't been able to hit that code path,
From what I can tell, executor_errposition is difficult to trigger in
practice due to
commit 0436f6bde8 and the related discussion in [1]. Most errors now occur
during parsing analysis rather than execution.
Therefore, in the attached v4 patch, I propose NOT passing the cleaned
up text to
pg_analyze_and_rewrite_varparams() as v3 does:
- query_list = pg_analyze_and_rewrite_varparams(rawstmt,
pstate->p_sourcetext,
+ query_list = pg_analyze_and_rewrite_varparams(rawstmt, new_query,
Instead, continue passing the original source text (pstate->p_sourcetext).
This ensures that parser_errposition() uses cursor marker position relative
to the original multi-statement string.
Also, from what I can see, in the cases where executor_errposition()
is triggered
(though I don't have a test case), those will use the cleaned-up source text
from the plan cache. However, the prepared statement must be executed
via EXECUTE, so the cursor marker position is not a concern in this case.
[1] [https://www.postgresql.org/message-id/27103.1496979469%40sss.pgh.pa.us]
--
Sami Imseih
Amazon Web Services (AWS)
| Attachment | Content-Type | Size |
|---|---|---|
| v4-0001-Clean-up-PREPARE-query-strings-in-multi-statement.patch | application/octet-stream | 14.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrew Dunstan | 2026-03-04 21:50:30 | Re: pg_waldump: support decoding of WAL inside tarfile |
| Previous Message | Andrew Dunstan | 2026-03-04 20:54:48 | Re: Non-text mode for pg_dumpall |