aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/makefuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-03-25 20:10:42 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-03-25 20:10:42 -0400
commitbfa4440ca5d948c4d4f0ab5bb82d433200c35288 (patch)
tree729b839f5f03c46773250ce3d33fc351f394e63e /src/backend/nodes/makefuncs.c
parentc8e993503d0f1a0cb8f187a136fb64cead9ba591 (diff)
downloadpostgresql-bfa4440ca5d948c4d4f0ab5bb82d433200c35288.tar.gz
postgresql-bfa4440ca5d948c4d4f0ab5bb82d433200c35288.zip
Pass collation to makeConst() instead of looking it up internally.
In nearly all cases, the caller already knows the correct collation, and in a number of places, the value the caller has handy is more correct than the default for the type would be. (In particular, this patch makes it significantly less likely that eval_const_expressions will result in changing the exposed collation of an expression.) So an internal lookup is both expensive and wrong.
Diffstat (limited to 'src/backend/nodes/makefuncs.c')
-rw-r--r--src/backend/nodes/makefuncs.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/backend/nodes/makefuncs.c b/src/backend/nodes/makefuncs.c
index 41e597cfffb..4d2eccf8179 100644
--- a/src/backend/nodes/makefuncs.c
+++ b/src/backend/nodes/makefuncs.c
@@ -271,6 +271,7 @@ makeFromExpr(List *fromlist, Node *quals)
Const *
makeConst(Oid consttype,
int32 consttypmod,
+ Oid constcollid,
int constlen,
Datum constvalue,
bool constisnull,
@@ -280,7 +281,7 @@ makeConst(Oid consttype,
cnst->consttype = consttype;
cnst->consttypmod = consttypmod;
- cnst->constcollid = get_typcollation(consttype);
+ cnst->constcollid = constcollid;
cnst->constlen = constlen;
cnst->constvalue = constvalue;
cnst->constisnull = constisnull;
@@ -298,7 +299,7 @@ makeConst(Oid consttype,
* storage properties.
*/
Const *
-makeNullConst(Oid consttype, int32 consttypmod)
+makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid)
{
int16 typLen;
bool typByVal;
@@ -306,6 +307,7 @@ makeNullConst(Oid consttype, int32 consttypmod)
get_typlenbyval(consttype, &typLen, &typByVal);
return makeConst(consttype,
consttypmod,
+ constcollid,
(int) typLen,
(Datum) 0,
true,
@@ -320,7 +322,7 @@ Node *
makeBoolConst(bool value, bool isnull)
{
/* note that pg_type.h hardwires size of bool as 1 ... duplicate it */
- return (Node *) makeConst(BOOLOID, -1, 1,
+ return (Node *) makeConst(BOOLOID, -1, InvalidOid, 1,
BoolGetDatum(value), isnull, true);
}