1/*-------------------------------------------------------------------------
4 * Type cache definitions.
6 * The type cache exists to speed lookup of certain information about data
7 * types that is not directly available from a type's pg_type row.
9 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
10 * Portions Copyright (c) 1994, Regents of the University of California
12 * src/include/utils/typcache.h
14 *-------------------------------------------------------------------------
25/* DomainConstraintCache is an opaque struct known only within typcache.c */
28/* TypeCacheEnumData is an opaque struct known only within typcache.c */
33 /* typeId is the hash lookup key and MUST BE FIRST */
38 /* some subsidiary information copied from the pg_type row */
51 * Information obtained from opfamily entries
53 * These will be InvalidOid if no match could be found, or if the
54 * information hasn't yet been requested. Also note that for array and
55 * composite types, typcache.c checks that the contained types are
56 * comparable or hashable before allowing eq_opr etc to become set.
70 * Pre-set-up fmgr call info for the equality operator, the btree
71 * comparison function, and the hash calculation function. These are kept
72 * in the type cache to avoid problems with memory leaks in repeated calls
73 * to functions such as array_eq, array_cmp, hash_array. There is not
74 * currently a need to maintain call info for the lt_opr or gt_opr.
82 * Tuple descriptor if it's a composite type (row type). NULL if not
83 * composite or information hasn't yet been requested. (NOTE: this is a
84 * reference-counted tupledesc.)
86 * To simplify caching dependent info, tupDesc_identifier is an identifier
87 * for this tupledesc that is unique for the life of the process, and
88 * changes anytime the tupledesc does. Zero if not yet determined.
94 * Fields computed when TYPECACHE_RANGE_INFO is requested. Zeroes if not
95 * a range type or information hasn't yet been requested. Note that
96 * rng_cmp_proc_finfo could be different from the element type's default
97 * btree comparison function.
107 * Fields computed when TYPECACHE_MULTIRANGE_INFO is required.
112 * Domain's base type and typmod if it's a domain type. Zeroes if not
113 * domain, or if information hasn't been requested.
119 * Domain constraint data if it's a domain type. NULL if not domain, or
120 * if domain has no constraints, or if information hasn't been requested.
124 /* Private data, for internal use of typcache.c only */
125 int flags;
/* flags about what we've computed */
128 * Private information about an enum type. NULL if not enum or
129 * information hasn't been requested.
133 /* We also maintain a list of all known domain-type cache entries */
137/* Bit flags to indicate which fields a given caller needs to have set */
138 #define TYPECACHE_EQ_OPR 0x00001
139 #define TYPECACHE_LT_OPR 0x00002
140 #define TYPECACHE_GT_OPR 0x00004
141 #define TYPECACHE_CMP_PROC 0x00008
142 #define TYPECACHE_HASH_PROC 0x00010
143 #define TYPECACHE_EQ_OPR_FINFO 0x00020
144 #define TYPECACHE_CMP_PROC_FINFO 0x00040
145 #define TYPECACHE_HASH_PROC_FINFO 0x00080
146 #define TYPECACHE_TUPDESC 0x00100
147 #define TYPECACHE_BTREE_OPFAMILY 0x00200
148 #define TYPECACHE_HASH_OPFAMILY 0x00400
149 #define TYPECACHE_RANGE_INFO 0x00800
150 #define TYPECACHE_DOMAIN_BASE_INFO 0x01000
151 #define TYPECACHE_DOMAIN_CONSTR_INFO 0x02000
152 #define TYPECACHE_HASH_EXTENDED_PROC 0x04000
153 #define TYPECACHE_HASH_EXTENDED_PROC_FINFO 0x08000
154 #define TYPECACHE_MULTIRANGE_INFO 0x10000
156/* This value will not equal any valid tupledesc identifier, nor 0 */
157 #define INVALID_TUPLEDESC_IDENTIFIER ((uint64) 1)
160 * Callers wishing to maintain a long-lived reference to a domain's constraint
161 * set must store it in one of these. Use InitDomainConstraintRef() and
162 * UpdateDomainConstraintRef() to manage it. Note: DomainConstraintState is
163 * considered an executable expression type, so it's defined in execnodes.h.
172 /* Management data --- treat these fields as private to typcache.c */
215#endif /* TYPCACHE_H */
DomainConstraintCache * dcc
MemoryContextCallback callback
uint64 tupDesc_identifier
FmgrInfo rng_cmp_proc_finfo
struct TypeCacheEntry * rngelemtype
FmgrInfo hash_extended_proc_finfo
DomainConstraintCache * domainData
struct TypeCacheEntry * rngtype
FmgrInfo rng_subdiff_finfo
struct TypeCacheEnumData * enumData
struct TypeCacheEntry * nextDomain
FmgrInfo rng_canonical_finfo
void InitDomainConstraintRef(Oid type_id, DomainConstraintRef *ref, MemoryContext refctx, bool need_exprstate)
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
void AtEOXact_TypeCache(void)
TupleDesc lookup_rowtype_tupdesc_domain(Oid type_id, int32 typmod, bool noError)
TupleDesc lookup_rowtype_tupdesc_noerror(Oid type_id, int32 typmod, bool noError)
void SharedRecordTypmodRegistryInit(SharedRecordTypmodRegistry *, dsm_segment *segment, dsa_area *area)
void SharedRecordTypmodRegistryAttach(SharedRecordTypmodRegistry *)
uint64 assign_record_type_identifier(Oid type_id, int32 typmod)
void AtEOSubXact_TypeCache(void)
bool DomainHasConstraints(Oid type_id)
size_t SharedRecordTypmodRegistryEstimate(void)
int compare_values_of_enum(TypeCacheEntry *tcache, Oid arg1, Oid arg2)
struct TypeCacheEntry TypeCacheEntry
void assign_record_type_typmod(TupleDesc tupDesc)
struct DomainConstraintRef DomainConstraintRef
TupleDesc lookup_rowtype_tupdesc_copy(Oid type_id, int32 typmod)
void UpdateDomainConstraintRef(DomainConstraintRef *ref)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)