Re: BUG: pg_stat_statements query normalization issues with combined queries

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: BUG: pg_stat_statements query normalization issues with combined queries
Date: 2016-12-20 11:18:16
Message-ID: alpine.DEB.2.20.1612201149590.29821@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello again pgdevs,

More investigations conclude that the information is lost by the parser.

From a ;-separated string raw_parser returns a List<Node> which are
directly the nodes of the statements, with empty statements silently
skipped.

The Node entry of high level statements (*Stmt) does NOT contain any
location information, only some lower level nodes have it.

A possible fix of this would be to add the query string location
information systematically at the head of every high level *Stmt, which
would then share both NodeTag and this information (say location and
length). This would be a new intermediate kind of node of which all these
statements would "inherit", say a "ParseNode" structure.

The actual location information may be filled-in at quite a high level in
the parser, maybe around "stmtmulti" and "stmt" rules, so it would not
necessarily be too intrusive in the overall parser grammar.

Then once the information is available, the query string may be cut where
appropriate to only store the relevant string in pg_stat_statements or
above.

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.

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2016-12-20 11:37:35 Re: pg_authid.rolpassword format (was Re: Password identifiers, protocol aging and SCRAM protocol)
Previous Message Ashutosh Sharma 2016-12-20 10:55:53 Re: pageinspect: Hash index support