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
diff --git a/src/backend/optimizer/util/clauses.c
b/src/backend/optimizer/util/clauses.c
index 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;
}
}
}
-- Sent via pgsql-hackers mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
