MCPcopy Create free account
hub / github.com/apache/cloudberry / getBaseTypeAndTypmod

Function getBaseTypeAndTypmod

src/backend/utils/cache/lsyscache.c:3138–3168  ·  view source on GitHub ↗

* getBaseTypeAndTypmod * If the given type is a domain, return its base type and typmod; * otherwise return the type's own OID, and leave *typmod unchanged. * * Note that the "applied typmod" should be -1 for every domain level * above the bottommost; therefore, if the passed-in typid is indeed * a domain, *typmod should be -1. */

Source from the content-addressed store, hash-verified

3136 * a domain, *typmod should be -1.
3137 */
3138Oid
3139getBaseTypeAndTypmod(Oid typid, int32 *typmod)
3140{
3141 /*
3142 * We loop to find the bottom base type in a stack of domains.
3143 */
3144 for (;;)
3145 {
3146 HeapTuple tup;
3147 Form_pg_type typTup;
3148
3149 tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
3150 if (!HeapTupleIsValid(tup))
3151 elog(ERROR, "cache lookup failed for type %u", typid);
3152 typTup = (Form_pg_type) GETSTRUCT(tup);
3153 if (typTup->typtype != TYPTYPE_DOMAIN)
3154 {
3155 /* Not a domain, so done */
3156 ReleaseSysCache(tup);
3157 break;
3158 }
3159
3160 Assert(*typmod == -1);
3161 typid = typTup->typbasetype;
3162 *typmod = typTup->typtypmod;
3163
3164 ReleaseSysCache(tup);
3165 }
3166
3167 return typid;
3168}
3169
3170/*
3171 * get_typavgwidth

Callers 14

getBaseTypeFunction · 0.85
lookup_type_cacheFunction · 0.85
prepare_column_cacheFunction · 0.85
ATExecAddColumnFunction · 0.85
coerce_typeFunction · 0.85
coerce_to_domainFunction · 0.85
coerce_record_to_complexFunction · 0.85
transformContainerTypeFunction · 0.85
transformTypeCastFunction · 0.85

Calls 3

SearchSysCache1Function · 0.85
ObjectIdGetDatumFunction · 0.85
ReleaseSysCacheFunction · 0.85

Tested by

no test coverage detected