Re: BUG: pg_stat_statements query normalization issues with combined queries

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: robertmhaas(at)gmail(dot)com
Cc: coelho(at)cri(dot)ensmp(dot)fr, pgsql-hackers(at)postgresql(dot)org
Subject: Re: BUG: pg_stat_statements query normalization issues with combined queries
Date: 2016-12-21 05:19:47
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

At Tue, 20 Dec 2016 22:42:48 -0500, Robert Haas <robertmhaas(at)gmail(dot)com> wrote in <CA+TgmoZT94brLAGK7gCmxB4mO=C-Cdz1N8KN8Xen4sexHozN=Q(at)mail(dot)gmail(dot)com>
> On Tue, Dec 20, 2016 at 6:18 AM, Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> wrote:
> > Would this approach be acceptable, or is modifying Nodes a no-go area?
> >
> > If it is acceptable, I can probably put together a patch and submit it.
> >
> > If not, I suggest to update the documentation to tell that
> > pg_stat_statements does not work properly with combined queries.
> I think you've found a bug, but I'm a little doubtful about your
> proposed fix. However, I haven't studied the code, so I don't know
> what other approach might be better.

That will work and doable, but the more fundamental issue here
seems to be that post_parse_analyze_hook or other similar hooks
are called with a Query incosistent with query_debug_string. It
is very conveniently used but the name seems to me to be
suggesting that such usage is out of purpose. I'm not sure,

A similar behavior is shown in error messages but this harms far
less than the case of pg_stat_statements.

ERROR: column "b" does not exist
LINE 1: ...elect * from t where a = 1; select * from t where b = 2; com...

1. Let all of the parse node have location in
debug_query_string. (The original proposal)

2. Let the parser return once for each statement (like psql
parser) and corresponding query string is stored in a
varialble other than debug_query_string.



Kyotaro Horiguchi
NTT Open Source Software Center

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2016-12-21 05:20:47 Re: Declarative partitioning - another take
Previous Message Dilip Kumar 2016-12-21 05:06:13 Re: Parallel bitmap heap scan