PostgreSQL Source Code  git master
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-2018, 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
16 #include "access/attnum.h"
17 #include "access/htup.h"
18 #include "nodes/pg_list.h"
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 */
29 /* I/O function selector for get_type_io_data */
30 typedef enum IOFuncSelector
31 {
38 /* Flag bits for get_attstatsslot */
42 /* Result struct for get_attstatsslot */
43 typedef struct AttStatsSlot
44 {
45  /* Always filled: */
46  Oid staop; /* Actual staop for the found slot */
47  /* Filled if ATTSTATSSLOT_VALUES is specified: */
48  Oid valuetype; /* Actual datatype of the values */
49  Datum *values; /* slot's "values" array, or NULL if none */
50  int nvalues; /* length of values[], or 0 */
51  /* Filled if ATTSTATSSLOT_NUMBERS is specified: */
52  float4 *numbers; /* slot's "numbers" array, or NULL if none */
53  int nnumbers; /* length of numbers[], or 0 */
55  /* Remaining fields are private to get_attstatsslot/free_attstatsslot */
56  void *values_arr; /* palloc'd values array, if any */
57  void *numbers_arr; /* palloc'd numbers array, if any */
58 } AttStatsSlot;
60 /* Hook for plugins to get control in get_attavgwidth() */
64 extern bool op_in_opfamily(Oid opno, Oid opfamily);
65 extern int get_op_opfamily_strategy(Oid opno, Oid opfamily);
66 extern Oid get_op_opfamily_sortfamily(Oid opno, Oid opfamily);
67 extern void get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op,
68  int *strategy,
69  Oid *lefttype,
70  Oid *righttype);
71 extern Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype,
72  int16 strategy);
73 extern bool get_ordering_op_properties(Oid opno,
74  Oid *opfamily, Oid *opcintype, int16 *strategy);
75 extern Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse);
76 extern Oid get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type);
77 extern List *get_mergejoin_opfamilies(Oid opno);
78 extern bool get_compatible_hash_operators(Oid opno,
79  Oid *lhs_opno, Oid *rhs_opno);
80 extern bool get_op_hash_functions(Oid opno,
81  RegProcedure *lhs_procno, RegProcedure *rhs_procno);
83 extern bool equality_ops_are_compatible(Oid opno1, Oid opno2);
84 extern Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype,
85  int16 procnum);
86 extern char *get_attname(Oid relid, AttrNumber attnum, bool missing_ok);
87 extern AttrNumber get_attnum(Oid relid, const char *attname);
88 extern char get_attidentity(Oid relid, AttrNumber attnum);
89 extern Oid get_atttype(Oid relid, AttrNumber attnum);
90 extern int32 get_atttypmod(Oid relid, AttrNumber attnum);
91 extern void get_atttypetypmodcoll(Oid relid, AttrNumber attnum,
92  Oid *typid, int32 *typmod, Oid *collid);
93 extern char *get_collation_name(Oid colloid);
94 extern char *get_constraint_name(Oid conoid);
95 extern char *get_language_name(Oid langoid, bool missing_ok);
96 extern Oid get_opclass_family(Oid opclass);
97 extern Oid get_opclass_input_type(Oid opclass);
98 extern RegProcedure get_opcode(Oid opno);
99 extern char *get_opname(Oid opno);
100 extern Oid get_op_rettype(Oid opno);
101 extern void op_input_types(Oid opno, Oid *lefttype, Oid *righttype);
102 extern bool op_mergejoinable(Oid opno, Oid inputtype);
103 extern bool op_hashjoinable(Oid opno, Oid inputtype);
104 extern bool op_strict(Oid opno);
105 extern char op_volatile(Oid opno);
106 extern Oid get_commutator(Oid opno);
107 extern Oid get_negator(Oid opno);
108 extern RegProcedure get_oprrest(Oid opno);
109 extern RegProcedure get_oprjoin(Oid opno);
110 extern char *get_func_name(Oid funcid);
111 extern Oid get_func_namespace(Oid funcid);
112 extern Oid get_func_rettype(Oid funcid);
113 extern int get_func_nargs(Oid funcid);
114 extern Oid get_func_signature(Oid funcid, Oid **argtypes, int *nargs);
115 extern Oid get_func_variadictype(Oid funcid);
116 extern bool get_func_retset(Oid funcid);
117 extern bool func_strict(Oid funcid);
118 extern char func_volatile(Oid funcid);
119 extern char func_parallel(Oid funcid);
120 extern char get_func_prokind(Oid funcid);
121 extern bool get_func_leakproof(Oid funcid);
122 extern float4 get_func_cost(Oid funcid);
123 extern float4 get_func_rows(Oid funcid);
124 extern Oid get_relname_relid(const char *relname, Oid relnamespace);
125 extern char *get_rel_name(Oid relid);
126 extern Oid get_rel_namespace(Oid relid);
127 extern Oid get_rel_type_id(Oid relid);
128 extern char get_rel_relkind(Oid relid);
129 extern Oid get_rel_tablespace(Oid relid);
130 extern char get_rel_persistence(Oid relid);
131 extern Oid get_transform_fromsql(Oid typid, Oid langid, List *trftypes);
132 extern Oid get_transform_tosql(Oid typid, Oid langid, List *trftypes);
133 extern bool get_typisdefined(Oid typid);
134 extern int16 get_typlen(Oid typid);
135 extern bool get_typbyval(Oid typid);
136 extern void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval);
137 extern void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
138  char *typalign);
139 extern Oid getTypeIOParam(HeapTuple typeTuple);
140 extern void get_type_io_data(Oid typid,
141  IOFuncSelector which_func,
142  int16 *typlen,
143  bool *typbyval,
144  char *typalign,
145  char *typdelim,
146  Oid *typioparam,
147  Oid *func);
148 extern char get_typstorage(Oid typid);
149 extern Node *get_typdefault(Oid typid);
150 extern char get_typtype(Oid typid);
151 extern bool type_is_rowtype(Oid typid);
152 extern bool type_is_enum(Oid typid);
153 extern bool type_is_range(Oid typid);
154 extern void get_type_category_preferred(Oid typid,
155  char *typcategory,
156  bool *typispreferred);
157 extern Oid get_typ_typrelid(Oid typid);
158 extern Oid get_element_type(Oid typid);
159 extern Oid get_array_type(Oid typid);
160 extern Oid get_promoted_array_type(Oid typid);
161 extern Oid get_base_element_type(Oid typid);
162 extern void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam);
163 extern void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena);
164 extern void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam);
165 extern void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena);
166 extern Oid get_typmodin(Oid typid);
167 extern Oid get_typcollation(Oid typid);
168 extern bool type_is_collatable(Oid typid);
169 extern Oid getBaseType(Oid typid);
170 extern Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod);
171 extern int32 get_typavgwidth(Oid typid, int32 typmod);
172 extern int32 get_attavgwidth(Oid relid, AttrNumber attnum);
173 extern bool get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple,
174  int reqkind, Oid reqop, int flags);
175 extern void free_attstatsslot(AttStatsSlot *sslot);
176 extern char *get_namespace_name(Oid nspid);
177 extern char *get_namespace_name_or_temp(Oid nspid);
178 extern Oid get_range_subtype(Oid rangeOid);
180 #define type_is_array(typid) (get_element_type(typid) != InvalidOid)
181 /* type_is_array_domain accepts both plain arrays and domains over arrays */
182 #define type_is_array_domain(typid) (get_base_element_type(typid) != InvalidOid)
184 #define TypeIsToastable(typid) (get_typstorage(typid) != 'p')
186 #endif /* LSYSCACHE_H */
char get_attidentity(Oid relid, AttrNumber attnum)
Definition: lsyscache.c:836
signed short int16
Definition: c.h:312
Oid get_promoted_array_type(Oid typid)
Definition: lsyscache.c:2554
char typcategory
Definition: pg_type.h:84
bool get_op_hash_functions(Oid opno, RegProcedure *lhs_procno, RegProcedure *rhs_procno)
Definition: lsyscache.c:507
float4 get_func_rows(Oid funcid)
Definition: lsyscache.c:1664
Oid get_func_namespace(Oid funcid)
Definition: lsyscache.c:1421
Oid relnamespace
Definition: pg_class.h:32
Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod)
Definition: lsyscache.c:2292
int16 typlen
Definition: pg_type.h:55
bool type_is_range(Oid typid)
Definition: lsyscache.c:2442
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
Definition: lsyscache.c:2025
void op_input_types(Oid opno, Oid *lefttype, Oid *righttype)
Definition: lsyscache.c:1152
Oid get_atttype(Oid relid, AttrNumber attnum)
Definition: lsyscache.c:863
Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse)
Definition: lsyscache.c:264
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
Definition: lsyscache.c:2617
Oid get_rel_namespace(Oid relid)
Definition: lsyscache.c:1754
int nnumbers
Definition: lsyscache.h:53
int32 get_attavgwidth(Oid relid, AttrNumber attnum)
Definition: lsyscache.c:2846
int32 get_atttypmod(Oid relid, AttrNumber attnum)
Definition: lsyscache.c:890
bool get_ordering_op_properties(Oid opno, Oid *opfamily, Oid *opcintype, int16 *strategy)
Definition: lsyscache.c:204
void get_type_category_preferred(Oid typid, char *typcategory, bool *typispreferred)
Definition: lsyscache.c:2454
RegProcedure get_oprjoin(Oid opno)
Definition: lsyscache.c:1370
bool op_strict(Oid opno)
Definition: lsyscache.c:1266
regproc RegProcedure
Definition: c.h:472
Oid get_func_rettype(Oid funcid)
Definition: lsyscache.c:1444
char * get_func_name(Oid funcid)
Definition: lsyscache.c:1397
struct AttStatsSlot AttStatsSlot
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
Definition: lsyscache.c:2650
char get_rel_relkind(Oid relid)
Definition: lsyscache.c:1805
Definition: nodes.h:516
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:2079
Oid get_rel_type_id(Oid relid)
Definition: lsyscache.c:1781
bool op_hashjoinable(Oid opno, Oid inputtype)
Definition: lsyscache.c:1231
Definition: lsyscache.h:30
unsigned int Oid
Definition: postgres_ext.h:31
Oid get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type)
Definition: lsyscache.c:302
float4 get_func_cost(Oid funcid)
Definition: lsyscache.c:1645
Oid get_op_opfamily_sortfamily(Oid opno, Oid opfamily)
Definition: lsyscache.c:105
Definition: c.h:1140
signed int int32
Definition: c.h:313
Oid get_negator(Oid opno)
Definition: lsyscache.c:1322
bool equality_ops_are_compatible(Oid opno1, Oid opno2)
Definition: lsyscache.c:695
char typalign
Definition: pg_type.h:168
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2530
char op_volatile(Oid opno)
Definition: lsyscache.c:1282
void * values_arr
Definition: lsyscache.h:56
struct OpBtreeInterpretation OpBtreeInterpretation
NameData attname
Definition: pg_attribute.h:40
Oid get_typmodin(Oid typid)
Definition: lsyscache.c:2749
bool op_mergejoinable(Oid opno, Oid inputtype)
Definition: lsyscache.c:1180
char func_volatile(Oid funcid)
Definition: lsyscache.c:1569
void get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op, int *strategy, Oid *lefttype, Oid *righttype)
Definition: lsyscache.c:133
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2057
char get_typtype(Oid typid)
Definition: lsyscache.c:2383
Oid get_rel_tablespace(Oid relid)
Definition: lsyscache.c:1832
Oid get_commutator(Oid opno)
Definition: lsyscache.c:1298
float4 * numbers
Definition: lsyscache.h:52
List * get_op_btree_interpretation(Oid opno)
Definition: lsyscache.c:598
bool get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple, int reqkind, Oid reqop, int flags)
Definition: lsyscache.c:2913
char * get_opname(Oid opno)
Definition: lsyscache.c:1104
char * get_namespace_name(Oid nspid)
Definition: lsyscache.c:3051
PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook
Definition: lsyscache.c:50
Oid get_func_variadictype(Oid funcid)
Definition: lsyscache.c:1512
Oid get_op_rettype(Oid opno)
Definition: lsyscache.c:1127
AttrNumber get_attnum(Oid relid, const char *attname)
Definition: lsyscache.c:806
char * get_rel_name(Oid relid)
Definition: lsyscache.c:1730
char * get_constraint_name(Oid conoid)
Definition: lsyscache.c:982
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2502
RegProcedure get_oprrest(Oid opno)
Definition: lsyscache.c:1346
void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena)
Definition: lsyscache.c:2716
Oid get_relname_relid(const char *relname, Oid relnamespace)
Definition: lsyscache.c:1687
char get_rel_persistence(Oid relid)
Definition: lsyscache.c:1856
void free_attstatsslot(AttStatsSlot *sslot)
Definition: lsyscache.c:3029
void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
Definition: lsyscache.c:2683
int get_op_opfamily_strategy(Oid opno, Oid opfamily)
Definition: lsyscache.c:80
Node * get_typdefault(Oid typid)
Definition: lsyscache.c:2202
float float4
Definition: c.h:457
Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
Definition: lsyscache.c:744
Oid get_typ_typrelid(Oid typid)
Definition: lsyscache.c:2475
char func_parallel(Oid funcid)
Definition: lsyscache.c:1588
bool op_in_opfamily(Oid opno, Oid opfamily)
Definition: lsyscache.c:63
Oid get_transform_fromsql(Oid typid, Oid langid, List *trftypes)
Definition: lsyscache.c:1876
int32 get_typavgwidth(Oid typid, int32 typmod)
Definition: lsyscache.c:2332
uintptr_t Datum
Definition: postgres.h:367
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1079
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
Definition: lsyscache.c:163
int32(* get_attavgwidth_hook_type)(Oid relid, AttrNumber attnum)
Definition: lsyscache.h:61
bool get_func_retset(Oid funcid)
Definition: lsyscache.c:1531
Oid get_transform_tosql(Oid typid, Oid langid, List *trftypes)
Definition: lsyscache.c:1897
int16 attnum
Definition: pg_attribute.h:79
void get_atttypetypmodcoll(Oid relid, AttrNumber attnum, Oid *typid, int32 *typmod, Oid *collid)
Definition: lsyscache.c:920
Datum * values
Definition: lsyscache.h:49
Oid get_range_subtype(Oid rangeOid)
Definition: lsyscache.c:3092
char get_func_prokind(Oid funcid)
Definition: lsyscache.c:1607
bool get_typbyval(Oid typid)
Definition: lsyscache.c:1976
bool type_is_rowtype(Oid typid)
Definition: lsyscache.c:2409
List * get_mergejoin_opfamilies(Oid opno)
Definition: lsyscache.c:363
Oid getBaseType(Oid typid)
Definition: lsyscache.c:2275
bool get_typisdefined(Oid typid)
Definition: lsyscache.c:1927
char get_typstorage(Oid typid)
Definition: lsyscache.c:2173
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
Definition: lsyscache.c:2005
Oid get_opclass_family(Oid opclass)
Definition: lsyscache.c:1032
Oid get_opclass_input_type(Oid opclass)
Definition: lsyscache.c:1054
int get_func_nargs(Oid funcid)
Definition: lsyscache.c:1463
char * get_language_name(Oid langoid, bool missing_ok)
Definition: lsyscache.c:1003
bool type_is_enum(Oid typid)
Definition: lsyscache.c:2432
char * get_namespace_name_or_temp(Oid nspid)
Definition: lsyscache.c:3075
void * numbers_arr
Definition: lsyscache.h:57
bool get_func_leakproof(Oid funcid)
Definition: lsyscache.c:1626
Oid get_typcollation(Oid typid)
Definition: lsyscache.c:2799
Oid valuetype
Definition: lsyscache.h:48
bool func_strict(Oid funcid)
Definition: lsyscache.c:1550
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
Definition: lsyscache.c:775
char * get_collation_name(Oid colloid)
Definition: lsyscache.c:952
Definition: pg_list.h:45
int16 AttrNumber
Definition: attnum.h:21
Oid get_base_element_type(Oid typid)
Definition: lsyscache.c:2575
int16 get_typlen(Oid typid)
Definition: lsyscache.c:1951
Oid get_func_signature(Oid funcid, Oid **argtypes, int *nargs)
Definition: lsyscache.c:1485
bool type_is_collatable(Oid typid)
Definition: lsyscache.c:2824
bool get_compatible_hash_operators(Oid opno, Oid *lhs_opno, Oid *rhs_opno)
Definition: lsyscache.c:407
bool typbyval
Definition: pg_type.h:65