]> granicus.if.org Git - postgresql/blob - src/include/utils/lsyscache.h
Clean up jsonb code.
[postgresql] / src / include / utils / lsyscache.h
1 /*-------------------------------------------------------------------------
2  *
3  * lsyscache.h
4  *        Convenience routines for common queries in the system catalog cache.
5  *
6  * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/include/utils/lsyscache.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef LSYSCACHE_H
14 #define LSYSCACHE_H
15
16 #include "access/attnum.h"
17 #include "access/htup.h"
18 #include "nodes/pg_list.h"
19
20 /* Result list element for get_op_btree_interpretation */
21 typedef struct OpBtreeInterpretation
22 {
23         Oid                     opfamily_id;    /* btree opfamily containing operator */
24         int                     strategy;               /* its strategy number */
25         Oid                     oplefttype;             /* declared left input datatype */
26         Oid                     oprighttype;    /* declared right input datatype */
27 } OpBtreeInterpretation;
28
29 /* I/O function selector for get_type_io_data */
30 typedef enum IOFuncSelector
31 {
32         IOFunc_input,
33         IOFunc_output,
34         IOFunc_receive,
35         IOFunc_send
36 } IOFuncSelector;
37
38 /* Hook for plugins to get control in get_attavgwidth() */
39 typedef int32 (*get_attavgwidth_hook_type) (Oid relid, AttrNumber attnum);
40 extern PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook;
41
42 extern bool op_in_opfamily(Oid opno, Oid opfamily);
43 extern int      get_op_opfamily_strategy(Oid opno, Oid opfamily);
44 extern Oid      get_op_opfamily_sortfamily(Oid opno, Oid opfamily);
45 extern void get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op,
46                                                    int *strategy,
47                                                    Oid *lefttype,
48                                                    Oid *righttype);
49 extern Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype,
50                                         int16 strategy);
51 extern bool get_ordering_op_properties(Oid opno,
52                                                    Oid *opfamily, Oid *opcintype, int16 *strategy);
53 extern bool get_sort_function_for_ordering_op(Oid opno, Oid *sortfunc,
54                                                                   bool *issupport, bool *reverse);
55 extern Oid      get_equality_op_for_ordering_op(Oid opno, bool *reverse);
56 extern Oid      get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type);
57 extern List *get_mergejoin_opfamilies(Oid opno);
58 extern bool get_compatible_hash_operators(Oid opno,
59                                                           Oid *lhs_opno, Oid *rhs_opno);
60 extern bool get_op_hash_functions(Oid opno,
61                                           RegProcedure *lhs_procno, RegProcedure *rhs_procno);
62 extern List *get_op_btree_interpretation(Oid opno);
63 extern bool equality_ops_are_compatible(Oid opno1, Oid opno2);
64 extern Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype,
65                                   int16 procnum);
66 extern char *get_attname(Oid relid, AttrNumber attnum);
67 extern char *get_relid_attribute_name(Oid relid, AttrNumber attnum);
68 extern AttrNumber get_attnum(Oid relid, const char *attname);
69 extern Oid      get_atttype(Oid relid, AttrNumber attnum);
70 extern int32 get_atttypmod(Oid relid, AttrNumber attnum);
71 extern void get_atttypetypmodcoll(Oid relid, AttrNumber attnum,
72                                           Oid *typid, int32 *typmod, Oid *collid);
73 extern char *get_collation_name(Oid colloid);
74 extern char *get_constraint_name(Oid conoid);
75 extern Oid      get_opclass_family(Oid opclass);
76 extern Oid      get_opclass_input_type(Oid opclass);
77 extern RegProcedure get_opcode(Oid opno);
78 extern char *get_opname(Oid opno);
79 extern void op_input_types(Oid opno, Oid *lefttype, Oid *righttype);
80 extern bool op_mergejoinable(Oid opno, Oid inputtype);
81 extern bool op_hashjoinable(Oid opno, Oid inputtype);
82 extern bool op_strict(Oid opno);
83 extern char op_volatile(Oid opno);
84 extern Oid      get_commutator(Oid opno);
85 extern Oid      get_negator(Oid opno);
86 extern RegProcedure get_oprrest(Oid opno);
87 extern RegProcedure get_oprjoin(Oid opno);
88 extern char *get_func_name(Oid funcid);
89 extern Oid      get_func_namespace(Oid funcid);
90 extern Oid      get_func_rettype(Oid funcid);
91 extern int      get_func_nargs(Oid funcid);
92 extern Oid      get_func_signature(Oid funcid, Oid **argtypes, int *nargs);
93 extern Oid      get_func_variadictype(Oid funcid);
94 extern bool get_func_retset(Oid funcid);
95 extern bool func_strict(Oid funcid);
96 extern char func_volatile(Oid funcid);
97 extern bool get_func_leakproof(Oid funcid);
98 extern float4 get_func_cost(Oid funcid);
99 extern float4 get_func_rows(Oid funcid);
100 extern Oid      get_relname_relid(const char *relname, Oid relnamespace);
101 extern char *get_rel_name(Oid relid);
102 extern Oid      get_rel_namespace(Oid relid);
103 extern Oid      get_rel_type_id(Oid relid);
104 extern char get_rel_relkind(Oid relid);
105 extern Oid      get_rel_tablespace(Oid relid);
106 extern bool get_typisdefined(Oid typid);
107 extern int16 get_typlen(Oid typid);
108 extern bool get_typbyval(Oid typid);
109 extern void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval);
110 extern void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
111                                          char *typalign);
112 extern Oid      getTypeIOParam(HeapTuple typeTuple);
113 extern void get_type_io_data(Oid typid,
114                                  IOFuncSelector which_func,
115                                  int16 *typlen,
116                                  bool *typbyval,
117                                  char *typalign,
118                                  char *typdelim,
119                                  Oid *typioparam,
120                                  Oid *func);
121 extern char get_typstorage(Oid typid);
122 extern Node *get_typdefault(Oid typid);
123 extern char get_typtype(Oid typid);
124 extern bool type_is_rowtype(Oid typid);
125 extern bool type_is_enum(Oid typid);
126 extern bool type_is_range(Oid typid);
127 extern void get_type_category_preferred(Oid typid,
128                                                         char *typcategory,
129                                                         bool *typispreferred);
130 extern Oid      get_typ_typrelid(Oid typid);
131 extern Oid      get_element_type(Oid typid);
132 extern Oid      get_array_type(Oid typid);
133 extern Oid      get_base_element_type(Oid typid);
134 extern void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam);
135 extern void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena);
136 extern void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam);
137 extern void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena);
138 extern Oid      get_typmodin(Oid typid);
139 extern Oid      get_typcollation(Oid typid);
140 extern bool type_is_collatable(Oid typid);
141 extern Oid      getBaseType(Oid typid);
142 extern Oid      getBaseTypeAndTypmod(Oid typid, int32 *typmod);
143 extern int32 get_typavgwidth(Oid typid, int32 typmod);
144 extern int32 get_attavgwidth(Oid relid, AttrNumber attnum);
145 extern bool get_attstatsslot(HeapTuple statstuple,
146                                  Oid atttype, int32 atttypmod,
147                                  int reqkind, Oid reqop,
148                                  Oid *actualop,
149                                  Datum **values, int *nvalues,
150                                  float4 **numbers, int *nnumbers);
151 extern void free_attstatsslot(Oid atttype,
152                                   Datum *values, int nvalues,
153                                   float4 *numbers, int nnumbers);
154 extern char *get_namespace_name(Oid nspid);
155 extern Oid      get_range_subtype(Oid rangeOid);
156
157 #define type_is_array(typid)  (get_element_type(typid) != InvalidOid)
158 /* type_is_array_domain accepts both plain arrays and domains over arrays */
159 #define type_is_array_domain(typid)  (get_base_element_type(typid) != InvalidOid)
160
161 #define TypeIsToastable(typid)  (get_typstorage(typid) != 'p')
162
163 #endif   /* LSYSCACHE_H */