PostgreSQL Source Code  git master
lsyscache.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * lsyscache.h
4  * Convenience routines for common queries in the system catalog cache.
5  *
6  * Portions Copyright (c) 1996-2020, 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 */
28 
29 /* I/O function selector for get_type_io_data */
30 typedef enum IOFuncSelector
31 {
37 
38 /* Flag bits for get_attstatsslot */
39 #define ATTSTATSSLOT_VALUES 0x01
40 #define ATTSTATSSLOT_NUMBERS 0x02
41 
42 /* Result struct for get_attstatsslot */
43 typedef struct AttStatsSlot
44 {
45  /* Always filled: */
46  Oid staop; /* Actual staop for the found slot */
47  Oid stacoll; /* Actual collation for the found slot */
48  /* Filled if ATTSTATSSLOT_VALUES is specified: */
49  Oid valuetype; /* Actual datatype of the values */
50  Datum *values; /* slot's "values" array, or NULL if none */
51  int nvalues; /* length of values[], or 0 */
52  /* Filled if ATTSTATSSLOT_NUMBERS is specified: */
53  float4 *numbers; /* slot's "numbers" array, or NULL if none */
54  int nnumbers; /* length of numbers[], or 0 */
55 
56  /* Remaining fields are private to get_attstatsslot/free_attstatsslot */
57  void *values_arr; /* palloc'd values array, if any */
58  void *numbers_arr; /* palloc'd numbers array, if any */
59 } AttStatsSlot;
60 
61 /* Hook for plugins to get control in get_attavgwidth() */
64 
65 extern bool op_in_opfamily(Oid opno, Oid opfamily);
66 extern int get_op_opfamily_strategy(Oid opno, Oid opfamily);
67 extern Oid get_op_opfamily_sortfamily(Oid opno, Oid opfamily);
68 extern void get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op,
69  int *strategy,
70  Oid *lefttype,
71  Oid *righttype);
72 extern Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype,
73  int16 strategy);
74 extern bool get_ordering_op_properties(Oid opno,
75  Oid *opfamily, Oid *opcintype, int16 *strategy);
76 extern Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse);
77 extern Oid get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type);
78 extern List *get_mergejoin_opfamilies(Oid opno);
79 extern bool get_compatible_hash_operators(Oid opno,
80  Oid *lhs_opno, Oid *rhs_opno);
81 extern bool get_op_hash_functions(Oid opno,
82  RegProcedure *lhs_procno, RegProcedure *rhs_procno);
84 extern bool equality_ops_are_compatible(Oid opno1, Oid opno2);
85 extern bool comparison_ops_are_compatible(Oid opno1, Oid opno2);
86 extern Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype,
87  int16 procnum);
88 extern char *get_attname(Oid relid, AttrNumber attnum, bool missing_ok);
89 extern AttrNumber get_attnum(Oid relid, const char *attname);
90 extern char get_attgenerated(Oid relid, AttrNumber attnum);
91 extern Oid get_atttype(Oid relid, AttrNumber attnum);
92 extern void get_atttypetypmodcoll(Oid relid, AttrNumber attnum,
93  Oid *typid, int32 *typmod, Oid *collid);
94 extern Datum get_attoptions(Oid relid, int16 attnum);
95 extern Oid get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok);
96 extern char *get_collation_name(Oid colloid);
97 extern bool get_collation_isdeterministic(Oid colloid);
98 extern char *get_constraint_name(Oid conoid);
99 extern char *get_language_name(Oid langoid, bool missing_ok);
100 extern Oid get_opclass_family(Oid opclass);
101 extern Oid get_opclass_input_type(Oid opclass);
102 extern bool get_opclass_opfamily_and_input_type(Oid opclass,
103  Oid *opfamily, Oid *opcintype);
104 extern RegProcedure get_opcode(Oid opno);
105 extern char *get_opname(Oid opno);
106 extern Oid get_op_rettype(Oid opno);
107 extern void op_input_types(Oid opno, Oid *lefttype, Oid *righttype);
108 extern bool op_mergejoinable(Oid opno, Oid inputtype);
109 extern bool op_hashjoinable(Oid opno, Oid inputtype);
110 extern bool op_strict(Oid opno);
111 extern char op_volatile(Oid opno);
112 extern Oid get_commutator(Oid opno);
113 extern Oid get_negator(Oid opno);
114 extern RegProcedure get_oprrest(Oid opno);
115 extern RegProcedure get_oprjoin(Oid opno);
116 extern char *get_func_name(Oid funcid);
117 extern Oid get_func_namespace(Oid funcid);
118 extern Oid get_func_rettype(Oid funcid);
119 extern int get_func_nargs(Oid funcid);
120 extern Oid get_func_signature(Oid funcid, Oid **argtypes, int *nargs);
121 extern Oid get_func_variadictype(Oid funcid);
122 extern bool get_func_retset(Oid funcid);
123 extern bool func_strict(Oid funcid);
124 extern char func_volatile(Oid funcid);
125 extern char func_parallel(Oid funcid);
126 extern char get_func_prokind(Oid funcid);
127 extern bool get_func_leakproof(Oid funcid);
128 extern RegProcedure get_func_support(Oid funcid);
129 extern Oid get_relname_relid(const char *relname, Oid relnamespace);
130 extern char *get_rel_name(Oid relid);
131 extern Oid get_rel_namespace(Oid relid);
132 extern Oid get_rel_type_id(Oid relid);
133 extern char get_rel_relkind(Oid relid);
134 extern bool get_rel_relispartition(Oid relid);
135 extern Oid get_rel_tablespace(Oid relid);
136 extern char get_rel_persistence(Oid relid);
137 extern Oid get_transform_fromsql(Oid typid, Oid langid, List *trftypes);
138 extern Oid get_transform_tosql(Oid typid, Oid langid, List *trftypes);
139 extern bool get_typisdefined(Oid typid);
140 extern int16 get_typlen(Oid typid);
141 extern bool get_typbyval(Oid typid);
142 extern void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval);
143 extern void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
144  char *typalign);
145 extern Oid getTypeIOParam(HeapTuple typeTuple);
146 extern void get_type_io_data(Oid typid,
147  IOFuncSelector which_func,
148  int16 *typlen,
149  bool *typbyval,
150  char *typalign,
151  char *typdelim,
152  Oid *typioparam,
153  Oid *func);
154 extern char get_typstorage(Oid typid);
155 extern Node *get_typdefault(Oid typid);
156 extern char get_typtype(Oid typid);
157 extern bool type_is_rowtype(Oid typid);
158 extern bool type_is_enum(Oid typid);
159 extern bool type_is_range(Oid typid);
160 extern void get_type_category_preferred(Oid typid,
161  char *typcategory,
162  bool *typispreferred);
163 extern Oid get_typ_typrelid(Oid typid);
164 extern Oid get_element_type(Oid typid);
165 extern Oid get_array_type(Oid typid);
166 extern Oid get_promoted_array_type(Oid typid);
167 extern Oid get_base_element_type(Oid typid);
168 extern void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam);
169 extern void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena);
170 extern void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam);
171 extern void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena);
172 extern Oid get_typmodin(Oid typid);
173 extern Oid get_typcollation(Oid typid);
174 extern bool type_is_collatable(Oid typid);
175 extern Oid getBaseType(Oid typid);
176 extern Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod);
177 extern int32 get_typavgwidth(Oid typid, int32 typmod);
178 extern int32 get_attavgwidth(Oid relid, AttrNumber attnum);
179 extern bool get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple,
180  int reqkind, Oid reqop, int flags);
181 extern void free_attstatsslot(AttStatsSlot *sslot);
182 extern char *get_namespace_name(Oid nspid);
183 extern char *get_namespace_name_or_temp(Oid nspid);
184 extern Oid get_range_subtype(Oid rangeOid);
185 extern Oid get_range_collation(Oid rangeOid);
186 extern Oid get_index_column_opclass(Oid index_oid, int attno);
187 extern bool get_index_isreplident(Oid index_oid);
188 extern bool get_index_isvalid(Oid index_oid);
189 extern bool get_index_isclustered(Oid index_oid);
190 
191 #define type_is_array(typid) (get_element_type(typid) != InvalidOid)
192 /* type_is_array_domain accepts both plain arrays and domains over arrays */
193 #define type_is_array_domain(typid) (get_base_element_type(typid) != InvalidOid)
194 
195 #define TypeIsToastable(typid) (get_typstorage(typid) != TYPSTORAGE_PLAIN)
196 
197 #endif /* LSYSCACHE_H */
signed short int16
Definition: c.h:361
Oid get_promoted_array_type(Oid typid)
Definition: lsyscache.c:2688
bool get_op_hash_functions(Oid opno, RegProcedure *lhs_procno, RegProcedure *rhs_procno)
Definition: lsyscache.c:508
Oid get_func_namespace(Oid funcid)
Definition: lsyscache.c:1544
Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod)
Definition: lsyscache.c:2426
bool type_is_range(Oid typid)
Definition: lsyscache.c:2576
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
Definition: lsyscache.c:2159
void op_input_types(Oid opno, Oid *lefttype, Oid *righttype)
Definition: lsyscache.c:1275
Oid get_atttype(Oid relid, AttrNumber attnum)
Definition: lsyscache.c:911
Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse)
Definition: lsyscache.c:265
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
Definition: lsyscache.c:2751
Oid get_rel_namespace(Oid relid)
Definition: lsyscache.c:1864
Datum get_attoptions(Oid relid, int16 attnum)
Definition: lsyscache.c:968
int nnumbers
Definition: lsyscache.h:54
int32 get_attavgwidth(Oid relid, AttrNumber attnum)
Definition: lsyscache.c:2980
bool get_ordering_op_properties(Oid opno, Oid *opfamily, Oid *opcintype, int16 *strategy)
Definition: lsyscache.c:205
void get_type_category_preferred(Oid typid, char *typcategory, bool *typispreferred)
Definition: lsyscache.c:2588
RegProcedure get_oprjoin(Oid opno)
Definition: lsyscache.c:1493
bool op_strict(Oid opno)
Definition: lsyscache.c:1389
regproc RegProcedure
Definition: c.h:518
Oid get_func_rettype(Oid funcid)
Definition: lsyscache.c:1567
char * get_func_name(Oid funcid)
Definition: lsyscache.c:1520
struct AttStatsSlot AttStatsSlot
bool get_index_isclustered(Oid index_oid)
Definition: lsyscache.c:3380
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
Definition: lsyscache.c:2784
char get_rel_relkind(Oid relid)
Definition: lsyscache.c:1915
Definition: nodes.h:529
void get_type_io_data(Oid typid, IOFuncSelector which_func, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *func)
Definition: lsyscache.c:2213
Oid get_rel_type_id(Oid relid)
Definition: lsyscache.c:1891
bool op_hashjoinable(Oid opno, Oid inputtype)
Definition: lsyscache.c:1354
IOFuncSelector
Definition: lsyscache.h:30
NameData relname
Definition: pg_class.h:38
unsigned int Oid
Definition: postgres_ext.h:31
Oid get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type)
Definition: lsyscache.c:303
Oid get_op_opfamily_sortfamily(Oid opno, Oid opfamily)
Definition: lsyscache.c:106
#define PGDLLIMPORT
Definition: c.h:1257
signed int int32
Definition: c.h:362
Oid get_negator(Oid opno)
Definition: lsyscache.c:1445
bool equality_ops_are_compatible(Oid opno1, Oid opno2)
Definition: lsyscache.c:696
char get_attgenerated(Oid relid, AttrNumber attnum)
Definition: lsyscache.c:886
bool get_collation_isdeterministic(Oid colloid)
Definition: lsyscache.c:1052
char typalign
Definition: pg_type.h:170
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2664
char op_volatile(Oid opno)
Definition: lsyscache.c:1405
void * values_arr
Definition: lsyscache.h:57
struct OpBtreeInterpretation OpBtreeInterpretation
NameData attname
Definition: pg_attribute.h:40
Oid get_typmodin(Oid typid)
Definition: lsyscache.c:2883
bool op_mergejoinable(Oid opno, Oid inputtype)
Definition: lsyscache.c:1303
char func_volatile(Oid funcid)
Definition: lsyscache.c:1692
void get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op, int *strategy, Oid *lefttype, Oid *righttype)
Definition: lsyscache.c:134
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2191
char get_typtype(Oid typid)
Definition: lsyscache.c:2517
Oid get_rel_tablespace(Oid relid)
Definition: lsyscache.c:1966
Oid get_commutator(Oid opno)
Definition: lsyscache.c:1421
float4 * numbers
Definition: lsyscache.h:53
List * get_op_btree_interpretation(Oid opno)
Definition: lsyscache.c:599
bool get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple, int reqkind, Oid reqop, int flags)
Definition: lsyscache.c:3052
char * get_opname(Oid opno)
Definition: lsyscache.c:1227
char * get_namespace_name(Oid nspid)
Definition: lsyscache.c:3191
PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook
Definition: lsyscache.c:51
Oid get_func_variadictype(Oid funcid)
Definition: lsyscache.c:1635
Oid get_op_rettype(Oid opno)
Definition: lsyscache.c:1250
AttrNumber get_attnum(Oid relid, const char *attname)
Definition: lsyscache.c:856
char * get_rel_name(Oid relid)
Definition: lsyscache.c:1840
char * get_constraint_name(Oid conoid)
Definition: lsyscache.c:1079
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2636
RegProcedure get_oprrest(Oid opno)
Definition: lsyscache.c:1469
void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena)
Definition: lsyscache.c:2850
RegProcedure get_func_support(Oid funcid)
Definition: lsyscache.c:1770
Oid get_relname_relid(const char *relname, Oid relnamespace)
Definition: lsyscache.c:1797
char get_rel_persistence(Oid relid)
Definition: lsyscache.c:1990
void free_attstatsslot(AttStatsSlot *sslot)
Definition: lsyscache.c:3169
bool get_opclass_opfamily_and_input_type(Oid opclass, Oid *opfamily, Oid *opcintype)
Definition: lsyscache.c:1174
void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
Definition: lsyscache.c:2817
int get_op_opfamily_strategy(Oid opno, Oid opfamily)
Definition: lsyscache.c:81
Node * get_typdefault(Oid typid)
Definition: lsyscache.c:2336
float float4
Definition: c.h:497
Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
Definition: lsyscache.c:794
Oid get_typ_typrelid(Oid typid)
Definition: lsyscache.c:2609
char func_parallel(Oid funcid)
Definition: lsyscache.c:1711
bool get_rel_relispartition(Oid relid)
Definition: lsyscache.c:1939
bool op_in_opfamily(Oid opno, Oid opfamily)
Definition: lsyscache.c:64
Oid get_transform_fromsql(Oid typid, Oid langid, List *trftypes)
Definition: lsyscache.c:2010
int32 get_typavgwidth(Oid typid, int32 typmod)
Definition: lsyscache.c:2466
uintptr_t Datum
Definition: postgres.h:367
bool get_index_isreplident(Oid index_oid)
Definition: lsyscache.c:3334
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1202
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
Definition: lsyscache.c:164
int32(* get_attavgwidth_hook_type)(Oid relid, AttrNumber attnum)
Definition: lsyscache.h:62
bool get_func_retset(Oid funcid)
Definition: lsyscache.c:1654
Oid get_transform_tosql(Oid typid, Oid langid, List *trftypes)
Definition: lsyscache.c:2031
int16 attnum
Definition: pg_attribute.h:79
void get_atttypetypmodcoll(Oid relid, AttrNumber attnum, Oid *typid, int32 *typmod, Oid *collid)
Definition: lsyscache.c:941
bool get_index_isvalid(Oid index_oid)
Definition: lsyscache.c:3357
Oid get_range_collation(Oid rangeOid)
Definition: lsyscache.c:3258
Datum * values
Definition: lsyscache.h:50
Oid get_range_subtype(Oid rangeOid)
Definition: lsyscache.c:3232
char get_func_prokind(Oid funcid)
Definition: lsyscache.c:1730
bool get_typbyval(Oid typid)
Definition: lsyscache.c:2110
bool type_is_rowtype(Oid typid)
Definition: lsyscache.c:2543
List * get_mergejoin_opfamilies(Oid opno)
Definition: lsyscache.c:364
Oid get_index_column_opclass(Oid index_oid, int attno)
Definition: lsyscache.c:3287
Oid getBaseType(Oid typid)
Definition: lsyscache.c:2409
bool get_typisdefined(Oid typid)
Definition: lsyscache.c:2061
char get_typstorage(Oid typid)
Definition: lsyscache.c:2307
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
Definition: lsyscache.c:2139
Oid get_opclass_family(Oid opclass)
Definition: lsyscache.c:1129
Oid get_opclass_input_type(Oid opclass)
Definition: lsyscache.c:1151
int get_func_nargs(Oid funcid)
Definition: lsyscache.c:1586
bool comparison_ops_are_compatible(Oid opno1, Oid opno2)
Definition: lsyscache.c:747
char * get_language_name(Oid langoid, bool missing_ok)
Definition: lsyscache.c:1100
bool type_is_enum(Oid typid)
Definition: lsyscache.c:2566
char * get_namespace_name_or_temp(Oid nspid)
Definition: lsyscache.c:3215
void * numbers_arr
Definition: lsyscache.h:58
bool get_func_leakproof(Oid funcid)
Definition: lsyscache.c:1749
Oid get_typcollation(Oid typid)
Definition: lsyscache.c:2933
Oid valuetype
Definition: lsyscache.h:49
bool func_strict(Oid funcid)
Definition: lsyscache.c:1673
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
Definition: lsyscache.c:825
char * get_collation_name(Oid colloid)
Definition: lsyscache.c:1033
Definition: pg_list.h:50
Oid get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok)
Definition: lsyscache.c:1005
int16 AttrNumber
Definition: attnum.h:21
Oid get_base_element_type(Oid typid)
Definition: lsyscache.c:2709
int16 get_typlen(Oid typid)
Definition: lsyscache.c:2085
Oid get_func_signature(Oid funcid, Oid **argtypes, int *nargs)
Definition: lsyscache.c:1608
bool type_is_collatable(Oid typid)
Definition: lsyscache.c:2958
bool get_compatible_hash_operators(Oid opno, Oid *lhs_opno, Oid *rhs_opno)
Definition: lsyscache.c:408