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-2008, PostgreSQL Global Development Group
10 * Portions Copyright (c) 1994, Regents of the University of California
14 *-------------------------------------------------------------------------
19 #include "access/tupdesc.h"
23 typedef struct TypeCacheEntry
25 /* typeId is the hash lookup key and MUST BE FIRST */
26 Oid type_id
; /* OID of the data type */
28 /* some subsidiary information copied from the pg_type row */
36 * Information obtained from opfamily entries
38 * These will be InvalidOid if no match could be found, or if the
39 * information hasn't yet been requested.
41 Oid btree_opf
; /* the default btree opclass' family */
42 Oid btree_opintype
; /* the default btree opclass' opcintype */
43 Oid hash_opf
; /* the default hash opclass' family */
44 Oid hash_opintype
; /* the default hash opclass' opcintype */
45 Oid eq_opr
; /* the equality operator */
46 Oid lt_opr
; /* the less-than operator */
47 Oid gt_opr
; /* the greater-than operator */
48 Oid cmp_proc
; /* the btree comparison function */
51 * Pre-set-up fmgr call info for the equality operator and the btree
52 * comparison function. These are kept in the type cache to avoid
53 * problems with memory leaks in repeated calls to array_eq and array_cmp.
54 * There is not currently a need to maintain call info for the lt_opr or
57 FmgrInfo eq_opr_finfo
;
58 FmgrInfo cmp_proc_finfo
;
61 * Tuple descriptor if it's a composite type (row type). NULL if not
62 * composite or information hasn't yet been requested. (NOTE: this is a
63 * reference-counted tupledesc.)
68 /* Bit flags to indicate which fields a given caller needs to have set */
69 #define TYPECACHE_EQ_OPR 0x0001
70 #define TYPECACHE_LT_OPR 0x0002
71 #define TYPECACHE_GT_OPR 0x0004
72 #define TYPECACHE_CMP_PROC 0x0008
73 #define TYPECACHE_EQ_OPR_FINFO 0x0010
74 #define TYPECACHE_CMP_PROC_FINFO 0x0020
75 #define TYPECACHE_TUPDESC 0x0040
76 #define TYPECACHE_BTREE_OPFAMILY 0x0080
78 extern TypeCacheEntry
*lookup_type_cache(Oid type_id
, int flags
);
80 extern TupleDesc
lookup_rowtype_tupdesc(Oid type_id
, int32 typmod
);
82 extern TupleDesc
lookup_rowtype_tupdesc_noerror(Oid type_id
, int32 typmod
,
85 extern TupleDesc
lookup_rowtype_tupdesc_copy(Oid type_id
, int32 typmod
);
87 extern void assign_record_type_typmod(TupleDesc tupDesc
);
89 extern void flush_rowtype_cache(Oid type_id
);
91 #endif /* TYPCACHE_H */