diff options
Diffstat (limited to 'src/backend/utils')
| -rw-r--r-- | src/backend/utils/adt/ruleutils.c | 6 | ||||
| -rw-r--r-- | src/backend/utils/cache/lsyscache.c | 38 |
2 files changed, 10 insertions, 34 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 621f1eb24a..326079a75b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -912,12 +912,14 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, { /* Simple index column */ char *attname; + int32 keycoltypmod; attname = get_relid_attribute_name(indrelid, attnum); if (!colno || colno == keyno + 1) appendStringInfoString(&buf, quote_identifier(attname)); - keycoltype = get_atttype(indrelid, attnum); - keycolcollation = get_attcollation(indrelid, attnum); + get_atttypetypmodcoll(indrelid, attnum, + &keycoltype, &keycoltypmod, + &keycolcollation); } else { diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index 6bcaf30ffe..877e50d873 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); } |
