postgres.git / summary / log / commit / refs

commit    be850f1822e4b54d1d570eefa8a7242788011634
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Wed Jul 14 18:15:12 2021 +0000
First released in: 15.0

    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


src/backend/optimizer/util/clauses.c | 17 ++++++++++------- 1 file 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; } } } [parent: c203dcddf997]