summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-07-14 14:15:12 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2021-07-14 14:15:12 -0400
commitbe850f1822e4b54d1d570eefa8a7242788011634 (patch)
tree199a03addd1c9a15f3b542cdd13d44eba1ef1812
parentc203dcddf997180000bc574a60313f3437e35af9 (diff)
Copy a Param's location field when replacing it with a Const.
This allows Param substitution to produce just the same result as writing a constant value literally would have done. While it hardly matters so far as the current core code is concerned, extensions might take more interest in node location fields. Julien Rouhaud Discussion: https://postgr.es/m/20170311220932.GJ15188@nol.local
-rw-r--r--src/backend/optimizer/util/clauses.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index 8506165d683..7187f17da57 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -2329,6 +2329,7 @@ eval_const_expressions_mutator(Node *node,
int16 typLen;
bool typByVal;
Datum pval;
+ Const *con;
get_typlenbyval(param->paramtype,
&typLen, &typByVal);
@@ -2336,13 +2337,15 @@ eval_const_expressions_mutator(Node *node,
pval = prm->value;
else
pval = datumCopy(prm->value, typByVal, typLen);
- return (Node *) makeConst(param->paramtype,
- param->paramtypmod,
- param->paramcollid,
- (int) typLen,
- pval,
- prm->isnull,
- typByVal);
+ con = makeConst(param->paramtype,
+ param->paramtypmod,
+ param->paramcollid,
+ (int) typLen,
+ pval,
+ prm->isnull,
+ typByVal);
+ con->location = param->location;
+ return (Node *) con;
}
}
}