Re: How to get the content of Bind variables

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: ROS Didier <didier(dot)ros(at)edf(dot)fr>
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us, pgsql-performance(at)postgresql(dot)org, legrand_legrand(at)hotmail(dot)com
Subject: Re: How to get the content of Bind variables
Date: 2019-03-02 15:56:38
Message-ID: 20190302155638.GA29584@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, Mar 01, 2019 at 06:47:06PM +0000, ROS Didier wrote:
> log_line_prefix = '%t [%p]: [%l-1] [%x] user=%u,db=%d,client=%h'

On Sat, Mar 02, 2019 at 01:14:44PM +0000, ROS Didier wrote:
> 2019-03-01 14:53:37 CET [24803]: [129-1] [3686] user=pgbd_preint_sg2,db=pgbd_preint_sg2 LOG: process 24803 still waiting for ShareLock on transaction 3711 after 1000.476 ms
> 2019-03-01 14:53:37 CET [24803]: [130-1] [3686] user=pgbd_preint_sg2,db=pgbd_preint_sg2 DETAIL: Process holding the lock: 24786. Wait queue: 24803.
> 2019-03-01 14:53:37 CET [24803]: [131-1] [3686] user=pgbd_preint_sg2,db=pgbd_preint_sg2 CONTEXT: while rechecking updated tuple (3,33) in relation "t_shared_liste_valeurs"
> 2019-03-01 14:53:37 CET [24803]: [132-1] [3686] user=pgbd_preint_sg2,db=pgbd_preint_sg2 STATEMENT: update t_shared_liste_valeurs set deletion_date=$1, deletion_login=$2, modification_date=$3, modification_login=$4, administrable=$5, libelle=$6, niveau=$7 where code=$8

I just realized that your log is showing "STATEMENT: [...]" which I think
means that's using libpq PQexec (simple query protocol), which means it doesn't
use or support bind parameters at all. If it were using PQexecParams (protocol
2.0 "extended" query), it would show "execute <unnamed>: [...]", with any bind
params in DETAIL. And if you were using PQexecPrepared, it'd show "execute
FOO: [...]" where FOO is the name of the statement "prepared" by PQprepare
(plus bind params).

https://www.postgresql.org/docs/current/libpq-exec.html
https://www.postgresql.org/docs/current/protocol.html

What client application is this ? It looks like it's going to set
deletion_date to the literal string "$1" .. except that it's not quoted, so the
statement will just cause an error. Am I wrong ?

Could you grep the entire logfile for pid 24803 and post the output on dropbox
or pastebin or show 10 lines of context by email ?

I've just used my messages and test cases on this patch as a reference to check
what I wrote above is accurate.
https://www.postgresql.org/message-id/flat/20190210015707.GQ31721%40telsasoft.com#037d17567f4c84a5f436960ef1ed8c49

On Fri, Mar 01, 2019 at 06:47:06PM +0000, ROS Didier wrote:
> *) -> suggestion : It would be nice to have the content of bind variable of a query in a table of pg_catalog. (cf ORACLE)

As I mentioned, you can set log_destination=csvlog,stderr and import them with
COPY (and add indices and analysis and monitoring..). It look like DETAILs are
being logged, so that's not the issue, but CSV also has the nice benefit of
being easily imported to SQL where escaping and linebreaks and similar are not
confusing the issue, which I think can be the case for text logs.

Justin

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2019-03-02 16:33:19 Re: How to get the content of Bind variables
Previous Message legrand legrand 2019-03-02 14:10:11 RE: How to get the content of Bind variables