Preserving param location

Julien Rouhaud <julien.rouhaud@dalibo.com>

From: Julien Rouhaud <julien.rouhaud@dalibo.com>
To: pgsql-hackers@postgresql.org
Date: 2017-03-11T22:09:32Z
Lists: pgsql-hackers

Attachments

Hello,

When a query contains parameters, the original param node contains the token
location.  However, this information is lost when the Const node is generated,
this one will only contain position -1 (unknown).

FWIW, we do have a use case for this (custom extension that tracks quals
statistics, which among other thing is used to regenerate query string from a
pgss normalized query, thus needing the original param location).

Is this something we want to get fixed? If yes, attached is a simple patch for
that.

Regards.

--
Julien Rouhaud
http://dalibo.com - http://dalibo.org

Commits

  1. Copy a Param's location field when replacing it with a Const.