diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-03-26 14:25:48 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-03-26 14:25:48 -0400 |
commit | b23c9fa9293c54a3829093d207be37a7b42cb630 (patch) | |
tree | 4bc1df3cf95ef9b75c9ac1f85ad57eed32db4889 /src/backend/utils/cache/lsyscache.c | |
parent | 92f4786fa9b730fd12cbfe973eb96addc6e98924 (diff) |
Clean up a few failures to set collation fields in expression nodes.
I'm not sure these have any non-cosmetic implications, but I'm not sure
they don't, either. In particular, ensure the CaseTestExpr generated
by transformAssignmentIndirection to represent the base target column
carries the correct collation, because parse_collate.c won't fix that.
Tweak lsyscache.c API so that we can get the appropriate collation
without an extra syscache lookup.
Diffstat (limited to 'src/backend/utils/cache/lsyscache.c')
-rw-r--r-- | src/backend/utils/cache/lsyscache.c | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index 6bcaf30ffe7..877e50d8737 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -904,44 +904,17 @@ get_atttypmod(Oid relid, AttrNumber attnum) } /* - * get_attcollation + * get_atttypetypmodcoll * - * Given the relation id and the attribute number, - * return the "attcollation" field from the attribute relation. - */ -Oid -get_attcollation(Oid relid, AttrNumber attnum) -{ - HeapTuple tp; - - tp = SearchSysCache2(ATTNUM, - ObjectIdGetDatum(relid), - Int16GetDatum(attnum)); - if (HeapTupleIsValid(tp)) - { - Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp); - Oid result; - - result = att_tup->attcollation; - ReleaseSysCache(tp); - return result; - } - else - return InvalidOid; -} - -/* - * get_atttypetypmod - * - * A two-fer: given the relation id and the attribute number, - * fetch both type OID and atttypmod in a single cache lookup. + * A three-fer: given the relation id and the attribute number, + * fetch atttypid, atttypmod, and attcollation in a single cache lookup. * * Unlike the otherwise-similar get_atttype/get_atttypmod, this routine * raises an error if it can't obtain the information. */ void -get_atttypetypmod(Oid relid, AttrNumber attnum, - Oid *typid, int32 *typmod) +get_atttypetypmodcoll(Oid relid, AttrNumber attnum, + Oid *typid, int32 *typmod, Oid *collid) { HeapTuple tp; Form_pg_attribute att_tup; @@ -956,6 +929,7 @@ get_atttypetypmod(Oid relid, AttrNumber attnum, *typid = att_tup->atttypid; *typmod = att_tup->atttypmod; + *collid = att_tup->attcollation; ReleaseSysCache(tp); } |