mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
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.
This commit is contained in:
@ -753,6 +753,7 @@ build_coercion_expression(Node *node,
|
||||
/* Pass target typmod as an int4 constant */
|
||||
cons = makeConst(INT4OID,
|
||||
-1,
|
||||
InvalidOid,
|
||||
sizeof(int32),
|
||||
Int32GetDatum(targetTypMod),
|
||||
false,
|
||||
@ -766,6 +767,7 @@ build_coercion_expression(Node *node,
|
||||
/* Pass it a boolean isExplicit parameter, too */
|
||||
cons = makeConst(BOOLOID,
|
||||
-1,
|
||||
InvalidOid,
|
||||
sizeof(bool),
|
||||
BoolGetDatum(isExplicit),
|
||||
false,
|
||||
@ -890,7 +892,8 @@ coerce_record_to_complex(ParseState *pstate, Node *node,
|
||||
* can't use atttypid here, but it doesn't really matter what type
|
||||
* the Const claims to be.
|
||||
*/
|
||||
newargs = lappend(newargs, makeNullConst(INT4OID, -1));
|
||||
newargs = lappend(newargs,
|
||||
makeNullConst(INT4OID, -1, InvalidOid));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -347,6 +347,7 @@ transformArraySubscripts(ParseState *pstate,
|
||||
/* Make a constant 1 */
|
||||
subexpr = (Node *) makeConst(INT4OID,
|
||||
-1,
|
||||
InvalidOid,
|
||||
sizeof(int32),
|
||||
Int32GetDatum(1),
|
||||
false,
|
||||
@ -526,6 +527,7 @@ make_const(ParseState *pstate, Value *value, int location)
|
||||
/* return a null const */
|
||||
con = makeConst(UNKNOWNOID,
|
||||
-1,
|
||||
InvalidOid,
|
||||
-2,
|
||||
(Datum) 0,
|
||||
true,
|
||||
@ -540,6 +542,7 @@ make_const(ParseState *pstate, Value *value, int location)
|
||||
|
||||
con = makeConst(typeid,
|
||||
-1, /* typmod -1 is OK for all cases */
|
||||
InvalidOid, /* all cases are uncollatable types */
|
||||
typelen,
|
||||
val,
|
||||
false,
|
||||
|
@ -1870,7 +1870,8 @@ expandTupleDesc(TupleDesc tupdesc, Alias *eref,
|
||||
* can't use atttypid here, but it doesn't really matter
|
||||
* what type the Const claims to be.
|
||||
*/
|
||||
*colvars = lappend(*colvars, makeNullConst(INT4OID, -1));
|
||||
*colvars = lappend(*colvars,
|
||||
makeNullConst(INT4OID, -1, InvalidOid));
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
@ -434,7 +434,8 @@ transformAssignedExpr(ParseState *pstate,
|
||||
* is not really a source value to work with. Insert a NULL
|
||||
* constant as the source value.
|
||||
*/
|
||||
colVar = (Node *) makeNullConst(attrtype, attrtypmod);
|
||||
colVar = (Node *) makeNullConst(attrtype, attrtypmod,
|
||||
attrcollation);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user