PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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-2017, 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 /* Hook for plugins to get control in get_attavgwidth() */
39 typedef int32 (*get_attavgwidth_hook_type) (Oid relid, AttrNumber attnum);
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 Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse);
54 extern Oid get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type);
55 extern List *get_mergejoin_opfamilies(Oid opno);
56 extern bool get_compatible_hash_operators(Oid opno,
57  Oid *lhs_opno, Oid *rhs_opno);
58 extern bool get_op_hash_functions(Oid opno,
59  RegProcedure *lhs_procno, RegProcedure *rhs_procno);
61 extern bool equality_ops_are_compatible(Oid opno1, Oid opno2);
62 extern Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype,
63  int16 procnum);
64 extern char *get_attname(Oid relid, AttrNumber attnum);
65 extern char *get_relid_attribute_name(Oid relid, AttrNumber attnum);
66 extern AttrNumber get_attnum(Oid relid, const char *attname);
67 extern char get_attidentity(Oid relid, AttrNumber attnum);
68 extern Oid get_atttype(Oid relid, AttrNumber attnum);
69 extern int32 get_atttypmod(Oid relid, AttrNumber attnum);
70 extern void get_atttypetypmodcoll(Oid relid, AttrNumber attnum,
71  Oid *typid, int32 *typmod, Oid *collid);
72 extern char *get_collation_name(Oid colloid);
73 extern char *get_constraint_name(Oid conoid);
74 extern char *get_language_name(Oid langoid, bool missing_ok);
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 Oid get_op_rettype(Oid opno);
80 extern void op_input_types(Oid opno, Oid *lefttype, Oid *righttype);
81 extern bool op_mergejoinable(Oid opno, Oid inputtype);
82 extern bool op_hashjoinable(Oid opno, Oid inputtype);
83 extern bool op_strict(Oid opno);
84 extern char op_volatile(Oid opno);
85 extern Oid get_commutator(Oid opno);
86 extern Oid get_negator(Oid opno);
87 extern RegProcedure get_oprrest(Oid opno);
88 extern RegProcedure get_oprjoin(Oid opno);
89 extern char *get_func_name(Oid funcid);
90 extern Oid get_func_namespace(Oid funcid);
91 extern Oid get_func_rettype(Oid funcid);
92 extern int get_func_nargs(Oid funcid);
93 extern Oid get_func_signature(Oid funcid, Oid **argtypes, int *nargs);
94 extern Oid get_func_variadictype(Oid funcid);
95 extern bool get_func_retset(Oid funcid);
96 extern bool func_strict(Oid funcid);
97 extern char func_volatile(Oid funcid);
98 extern char func_parallel(Oid funcid);
99 extern bool get_func_leakproof(Oid funcid);
100 extern float4 get_func_cost(Oid funcid);
101 extern float4 get_func_rows(Oid funcid);
102 extern Oid get_relname_relid(const char *relname, Oid relnamespace);
103 extern char *get_rel_name(Oid relid);
104 extern Oid get_rel_namespace(Oid relid);
105 extern Oid get_rel_type_id(Oid relid);
106 extern char get_rel_relkind(Oid relid);
107 extern Oid get_rel_tablespace(Oid relid);
108 extern char get_rel_persistence(Oid relid);
109 extern Oid get_transform_fromsql(Oid typid, Oid langid, List *trftypes);
110 extern Oid get_transform_tosql(Oid typid, Oid langid, List *trftypes);
111 extern bool get_typisdefined(Oid typid);
112 extern int16 get_typlen(Oid typid);
113 extern bool get_typbyval(Oid typid);
114 extern void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval);
115 extern void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
116  char *typalign);
117 extern Oid getTypeIOParam(HeapTuple typeTuple);
118 extern void get_type_io_data(Oid typid,
119  IOFuncSelector which_func,
120  int16 *typlen,
121  bool *typbyval,
122  char *typalign,
123  char *typdelim,
124  Oid *typioparam,
125  Oid *func);
126 extern char get_typstorage(Oid typid);
127 extern Node *get_typdefault(Oid typid);
128 extern char get_typtype(Oid typid);
129 extern bool type_is_rowtype(Oid typid);
130 extern bool type_is_enum(Oid typid);
131 extern bool type_is_range(Oid typid);
132 extern void get_type_category_preferred(Oid typid,
133  char *typcategory,
134  bool *typispreferred);
135 extern Oid get_typ_typrelid(Oid typid);
136 extern Oid get_element_type(Oid typid);
137 extern Oid get_array_type(Oid typid);
138 extern Oid get_promoted_array_type(Oid typid);
139 extern Oid get_base_element_type(Oid typid);
140 extern void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam);
141 extern void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena);
142 extern void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam);
143 extern void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena);
144 extern Oid get_typmodin(Oid typid);
145 extern Oid get_typcollation(Oid typid);
146 extern bool type_is_collatable(Oid typid);
147 extern Oid getBaseType(Oid typid);
148 extern Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod);
149 extern int32 get_typavgwidth(Oid typid, int32 typmod);
150 extern int32 get_attavgwidth(Oid relid, AttrNumber attnum);
151 extern bool get_attstatsslot(HeapTuple statstuple,
152  Oid atttype, int32 atttypmod,
153  int reqkind, Oid reqop,
154  Oid *actualop,
155  Datum **values, int *nvalues,
156  float4 **numbers, int *nnumbers);
157 extern void free_attstatsslot(Oid atttype,
158  Datum *values, int nvalues,
159  float4 *numbers, int nnumbers);
160 extern char *get_namespace_name(Oid nspid);
161 extern char *get_namespace_name_or_temp(Oid nspid);
162 extern Oid get_range_subtype(Oid rangeOid);
164 #define type_is_array(typid) (get_element_type(typid) != InvalidOid)
165 /* type_is_array_domain accepts both plain arrays and domains over arrays */
166 #define type_is_array_domain(typid) (get_base_element_type(typid) != InvalidOid)
168 #define TypeIsToastable(typid) (get_typstorage(typid) != 'p')
170 #endif /* LSYSCACHE_H */
char get_attidentity(Oid relid, AttrNumber attnum)
Definition: lsyscache.c:851
signed short int16
Definition: c.h:255
Oid get_promoted_array_type(Oid typid)
Definition: lsyscache.c:2536
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:1660
Oid get_func_namespace(Oid funcid)
Definition: lsyscache.c:1436
Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod)
Definition: lsyscache.c:2288
void free_attstatsslot(Oid atttype, Datum *values, int nvalues, float4 *numbers, int nnumbers)
Definition: lsyscache.c:3010
bool type_is_range(Oid typid)
Definition: lsyscache.c:2424
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
Definition: lsyscache.c:2021
void op_input_types(Oid opno, Oid *lefttype, Oid *righttype)
Definition: lsyscache.c:1167
Oid get_atttype(Oid relid, AttrNumber attnum)
Definition: lsyscache.c:878
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:2599
Oid get_rel_namespace(Oid relid)
Definition: lsyscache.c:1750
int32 get_attavgwidth(Oid relid, AttrNumber attnum)
Definition: lsyscache.c:2828
int32 get_atttypmod(Oid relid, AttrNumber attnum)
Definition: lsyscache.c:905
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:2436
RegProcedure get_oprjoin(Oid opno)
Definition: lsyscache.c:1385
bool op_strict(Oid opno)
Definition: lsyscache.c:1281
regproc RegProcedure
Definition: c.h:395
Oid get_func_rettype(Oid funcid)
Definition: lsyscache.c:1459
char * get_func_name(Oid funcid)
Definition: lsyscache.c:1412
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
Definition: lsyscache.c:2632
char get_rel_relkind(Oid relid)
Definition: lsyscache.c:1801
Definition: nodes.h:509
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:2075
Oid get_rel_type_id(Oid relid)
Definition: lsyscache.c:1777
bool op_hashjoinable(Oid opno, Oid inputtype)
Definition: lsyscache.c:1246
Definition: lsyscache.h:30
unsigned int Oid
Definition: postgres_ext.h:31
char * get_attname(Oid relid, AttrNumber attnum)
Definition: lsyscache.c:774
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:1641
Oid get_op_opfamily_sortfamily(Oid opno, Oid opfamily)
Definition: lsyscache.c:105
Definition: c.h:1063
signed int int32
Definition: c.h:256
Oid get_negator(Oid opno)
Definition: lsyscache.c:1337
bool equality_ops_are_compatible(Oid opno1, Oid opno2)
Definition: lsyscache.c:695
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2512
char op_volatile(Oid opno)
Definition: lsyscache.c:1297
struct OpBtreeInterpretation OpBtreeInterpretation
Oid get_typmodin(Oid typid)
Definition: lsyscache.c:2731
bool op_mergejoinable(Oid opno, Oid inputtype)
Definition: lsyscache.c:1195
char func_volatile(Oid funcid)
Definition: lsyscache.c:1584
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:2053
char get_typtype(Oid typid)
Definition: lsyscache.c:2379
Oid get_rel_tablespace(Oid relid)
Definition: lsyscache.c:1828
Oid get_commutator(Oid opno)
Definition: lsyscache.c:1313
List * get_op_btree_interpretation(Oid opno)
Definition: lsyscache.c:598
bool get_attstatsslot(HeapTuple statstuple, Oid atttype, int32 atttypmod, int reqkind, Oid reqop, Oid *actualop, Datum **values, int *nvalues, float4 **numbers, int *nnumbers)
Definition: lsyscache.c:2886
char * get_opname(Oid opno)
Definition: lsyscache.c:1119
char * get_namespace_name(Oid nspid)
Definition: lsyscache.c:3038
PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook
Definition: lsyscache.c:50
Oid get_func_variadictype(Oid funcid)
Definition: lsyscache.c:1527
Oid get_op_rettype(Oid opno)
Definition: lsyscache.c:1142
AttrNumber get_attnum(Oid relid, const char *attname)
Definition: lsyscache.c:821
char * get_rel_name(Oid relid)
Definition: lsyscache.c:1726
char * get_constraint_name(Oid conoid)
Definition: lsyscache.c:997
char * get_relid_attribute_name(Oid relid, AttrNumber attnum)
Definition: lsyscache.c:801
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2484
RegProcedure get_oprrest(Oid opno)
Definition: lsyscache.c:1361
void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena)
Definition: lsyscache.c:2698
Oid get_relname_relid(const char *relname, Oid relnamespace)
Definition: lsyscache.c:1683
char get_rel_persistence(Oid relid)
Definition: lsyscache.c:1852
void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
Definition: lsyscache.c:2665
int get_op_opfamily_strategy(Oid opno, Oid opfamily)
Definition: lsyscache.c:80
Node * get_typdefault(Oid typid)
Definition: lsyscache.c:2198
float float4
Definition: c.h:380
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:2457
char func_parallel(Oid funcid)
Definition: lsyscache.c:1603
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:1872
int32 get_typavgwidth(Oid typid, int32 typmod)
Definition: lsyscache.c:2328
uintptr_t Datum
Definition: postgres.h:372
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1094
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
Definition: lsyscache.c:163
bool get_func_retset(Oid funcid)
Definition: lsyscache.c:1546
Oid get_transform_tosql(Oid typid, Oid langid, List *trftypes)
Definition: lsyscache.c:1893
void get_atttypetypmodcoll(Oid relid, AttrNumber attnum, Oid *typid, int32 *typmod, Oid *collid)
Definition: lsyscache.c:935
Oid get_range_subtype(Oid rangeOid)
Definition: lsyscache.c:3079
bool get_typbyval(Oid typid)
Definition: lsyscache.c:1972
bool type_is_rowtype(Oid typid)
Definition: lsyscache.c:2404
List * get_mergejoin_opfamilies(Oid opno)
Definition: lsyscache.c:363
Oid getBaseType(Oid typid)
Definition: lsyscache.c:2271
bool get_typisdefined(Oid typid)
Definition: lsyscache.c:1923
char get_typstorage(Oid typid)
Definition: lsyscache.c:2169
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
Definition: lsyscache.c:2001
static Datum values[MAXATTR]
Definition: bootstrap.c:163
Oid get_opclass_family(Oid opclass)
Definition: lsyscache.c:1047
Oid get_opclass_input_type(Oid opclass)
Definition: lsyscache.c:1069
int get_func_nargs(Oid funcid)
Definition: lsyscache.c:1478
char * get_language_name(Oid langoid, bool missing_ok)
Definition: lsyscache.c:1018
int32(* get_attavgwidth_hook_type)(Oid relid, AttrNumber attnum)
Definition: lsyscache.h:39
bool type_is_enum(Oid typid)
Definition: lsyscache.c:2414
char * get_namespace_name_or_temp(Oid nspid)
Definition: lsyscache.c:3062
bool get_func_leakproof(Oid funcid)
Definition: lsyscache.c:1622
Oid get_typcollation(Oid typid)
Definition: lsyscache.c:2781
bool func_strict(Oid funcid)
Definition: lsyscache.c:1565
char * get_collation_name(Oid colloid)
Definition: lsyscache.c:967
Definition: pg_list.h:45
int16 AttrNumber
Definition: attnum.h:21
Oid get_base_element_type(Oid typid)
Definition: lsyscache.c:2557
int16 get_typlen(Oid typid)
Definition: lsyscache.c:1947
Oid get_func_signature(Oid funcid, Oid **argtypes, int *nargs)
Definition: lsyscache.c:1500
bool type_is_collatable(Oid typid)
Definition: lsyscache.c:2806
bool get_compatible_hash_operators(Oid opno, Oid *lhs_opno, Oid *rhs_opno)
Definition: lsyscache.c:407