Skip to content

Commit be850f1

Browse files
committed
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
1 parent c203dcd commit be850f1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/backend/optimizer/util/clauses.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,20 +2329,23 @@ eval_const_expressions_mutator(Node *node,
23292329
int16 typLen;
23302330
bool typByVal;
23312331
Datum pval;
2332+
Const *con;
23322333

23332334
get_typlenbyval(param->paramtype,
23342335
&typLen, &typByVal);
23352336
if (prm->isnull || typByVal)
23362337
pval = prm->value;
23372338
else
23382339
pval = datumCopy(prm->value, typByVal, typLen);
2339-
return (Node *) makeConst(param->paramtype,
2340-
param->paramtypmod,
2341-
param->paramcollid,
2342-
(int) typLen,
2343-
pval,
2344-
prm->isnull,
2345-
typByVal);
2340+
con = makeConst(param->paramtype,
2341+
param->paramtypmod,
2342+
param->paramcollid,
2343+
(int) typLen,
2344+
pval,
2345+
prm->isnull,
2346+
typByVal);
2347+
con->location = param->location;
2348+
return (Node *) con;
23462349
}
23472350
}
23482351
}

0 commit comments

Comments
 (0)