From: Julien Rouhaud <julien.rouhaud@dalibo.com>
To: pgsql-hackers@postgresql.org
Subject: Preserving param location
Date: Sat, 11 Mar 2017 23:09:32 +0100
Message-ID: <20170311220932.GJ15188@nol.local> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
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
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackersAttachments:fix_param_location-1.diff (text/plain, 995B) downloaddiff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.cindex b19380e1b1..beb0f99144 100644--- a/src/backend/optimizer/util/clauses.c+++ b/src/backend/optimizer/util/clauses.c@@ -2444,6 +2444,7 @@ eval_const_expressions_mutator(Node *node,
int16 typLen;
bool typByVal;
Datum pval;
+ Const *con;
Assert(prm->ptype == param->paramtype);
get_typlenbyval(param->paramtype,
@@ -2452,13 +2453,17 @@ eval_const_expressions_mutator(Node *node,
pval = prm->value;
else
pval = datumCopy(prm->value, typByVal, typLen);
- return (Node *) makeConst(param->paramtype,++ con = makeConst(param->paramtype,
param->paramtypmod,
param->paramcollid,
(int) typLen,
pval,
prm->isnull,
typByVal);
+ con->location = param->location;++ return (Node *) con;
}
}
}
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: julien.rouhaud@dalibo.com
Subject: Re: Preserving param location
In-Reply-To: <20170311220932.GJ15188@nol.local>
References: <20170311220932.GJ15188@nol.local>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox