From: | Hugo Sousa <hugos(dot)18(at)hotmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Tracing in PostgreSQL with Extended Query Protocol |
Date: | 2025-02-18 10:04:04 |
Message-ID: | D2BD0215-75E5-4E2D-8E6C-7306C28014F9@hotmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
From my understanding when we use the Extended Query Protocol we are parsing a query only once and then we bind them to specific parameter values to them execute aka prepared statements. To use a standard like SQLCommenter, for my purpose we would need to pass specific trace values for every execution of the query as every query execution is correlated to a different trace (a static comment should work).
Most documentation and examples I can find validate that it’s not possible to pass tracing data if the underlying sql command is done using a prepared statement.
To validate this I tried creating a prepared statement that would allow a dynamic trace id in a comment:
PREPARE example_statement AS /* trace=$1::text */ SELECT * FROM users WHERE id=$2;
But I got the following error "ERROR: could not determine data type of parameter $1" and other variations of the prepared statement ended in similar problems.
We wouldn’t want to lose the performance benefits and the added security of using prepared statements, but this ability to trace all the way to the database layer and reverse would be very beneficial to us (and I hope to more people). I just want to know is this possible, if yes can I help in any way to add this capability?
> On 18 Feb 2025, at 04:45, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Hugo Sousa <hugos(dot)18(at)hotmail(dot)com> writes:
>> However, we make heavy use of the extended query protocol, and from
>> my understanding, SQL comments don’t work in that context.
>
> Why do you think that?
>
> regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Hall, Michael H. (GSFC-423.0)[RAYTHEON COMPANY] | 2025-02-21 15:02:34 | Configuration example for a repmgr "witness host" |
Previous Message | Tom Lane | 2025-02-18 04:45:27 | Re: Tracing in PostgreSQL with Extended Query Protocol |