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.


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to