]> granicus.if.org Git - postgresql/blob - src/include/utils/lsyscache.h
Create a "sort support" interface API for faster sorting.
[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-2011, 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/htup.h"
17
18 /* Result list element for get_op_btree_interpretation */
19 typedef struct OpBtreeInterpretation
20 {
21         Oid                     opfamily_id;            /* btree opfamily containing operator */
22         int                     strategy;                       /* its strategy number */
23         Oid                     oplefttype;                     /* declared left input datatype */
24         Oid                     oprighttype;            /* declared right input datatype */
25 } OpBtreeInterpretation;
26
27 /* I/O function selector for get_type_io_data */
28 typedef enum IOFuncSelector
29 {
30         IOFunc_input,
31         IOFunc_output,
32         IOFunc_receive,
33         IOFunc_send
34 } IOFuncSelector;
35
36 /* Hook for plugins to get control in get_attavgwidth() */
37 typedef int32 (*get_attavgwidth_hook_type) (Oid relid, AttrNumber attnum);
38 extern PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook;
39
40 extern bool op_in_opfamily(Oid opno, Oid opfamily);
41 extern int      get_op_opfamily_strategy(Oid opno, Oid opfamily);
42 extern Oid      get_op_opfamily_sortfamily(Oid opno, Oid opfamily);
43 extern void get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op,
44                                                    int *strategy,
45                                                    Oid *lefttype,
46                                                    Oid *righttype);
47 extern Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype,
48                                         int16 strategy);
49 extern bool get_ordering_op_properties(Oid opno,
50                                                    Oid *opfamily, Oid *opcintype, int16 *strategy);
51 extern bool get_sort_function_for_ordering_op(Oid opno, Oid *sortfunc,
52                                                                   bool *issupport, bool *reverse);
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);
60 extern List *get_op_btree_interpretation(Oid opno);
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 Oid      get_atttype(Oid relid, AttrNumber attnum);
68 extern int32 get_atttypmod(Oid relid, AttrNumber attnum);
69 extern void get_atttypetypmodcoll(Oid relid, AttrNumber attnum,
70                                           Oid *typid, int32 *typmod, Oid *collid);
71 extern char *get_collation_name(Oid colloid);
72 extern char *get_constraint_name(Oid conoid);
73 extern Oid      get_opclass_family(Oid opclass);
74 extern Oid      get_opclass_input_type(Oid opclass);
75 extern RegProcedure get_opcode(Oid opno);
76 extern char *get_opname(Oid opno);
77 extern void op_input_types(Oid opno, Oid *lefttype, Oid *righttype);
78 extern bool op_mergejoinable(Oid opno, Oid inputtype);
79 extern bool op_hashjoinable(Oid opno, Oid inputtype);
80 extern bool op_strict(Oid opno);
81 extern char op_volatile(Oid opno);
82 extern Oid      get_commutator(Oid opno);
83 extern Oid      get_negator(Oid opno);
84 extern RegProcedure get_oprrest(Oid opno);
85 extern RegProcedure get_oprjoin(Oid opno);
86 extern char *get_func_name(Oid funcid);
87 extern Oid      get_func_namespace(Oid funcid);
88 extern Oid      get_func_rettype(Oid funcid);
89 extern int      get_func_nargs(Oid funcid);
90 extern Oid      get_func_signature(Oid funcid, Oid **argtypes, int *nargs);
91 extern bool get_func_retset(Oid funcid);
92 extern bool func_strict(Oid funcid);
93 extern char func_volatile(Oid funcid);
94 extern float4 get_func_cost(Oid funcid);
95 extern float4 get_func_rows(Oid funcid);
96 extern Oid      get_relname_relid(const char *relname, Oid relnamespace);
97 extern char *get_rel_name(Oid relid);
98 extern Oid      get_rel_namespace(Oid relid);
99 extern Oid      get_rel_type_id(Oid relid);
100 extern char get_rel_relkind(Oid relid);
101 extern Oid      get_rel_tablespace(Oid relid);
102 extern bool get_typisdefined(Oid typid);
103 extern int16 get_typlen(Oid typid);
104 extern bool get_typbyval(Oid typid);
105 extern void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval);
106 extern void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
107                                          char *typalign);
108 extern Oid      getTypeIOParam(HeapTuple typeTuple);
109 extern void get_type_io_data(Oid typid,
110                                  IOFuncSelector which_func,
111                                  int16 *typlen,
112                                  bool *typbyval,
113                                  char *typalign,
114                                  char *typdelim,
115                                  Oid *typioparam,
116                                  Oid *func);
117 extern char get_typstorage(Oid typid);
118 extern Node *get_typdefault(Oid typid);
119 extern char get_typtype(Oid typid);
120 extern bool type_is_rowtype(Oid typid);
121 extern bool type_is_enum(Oid typid);
122 extern bool type_is_range(Oid typid);
123 extern void get_type_category_preferred(Oid typid,
124                                                         char *typcategory,
125                                                         bool *typispreferred);
126 extern Oid      get_typ_typrelid(Oid typid);
127 extern Oid      get_element_type(Oid typid);
128 extern Oid      get_array_type(Oid typid);
129 extern Oid      get_base_element_type(Oid typid);
130 extern void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam);
131 extern void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena);
132 extern void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam);
133 extern void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena);
134 extern Oid      get_typmodin(Oid typid);
135 extern Oid      get_typcollation(Oid typid);
136 extern bool type_is_collatable(Oid typid);
137 extern Oid      getBaseType(Oid typid);
138 extern Oid      getBaseTypeAndTypmod(Oid typid, int32 *typmod);
139 extern int32 get_typavgwidth(Oid typid, int32 typmod);
140 extern int32 get_attavgwidth(Oid relid, AttrNumber attnum);
141 extern bool get_attstatsslot(HeapTuple statstuple,
142                                  Oid atttype, int32 atttypmod,
143                                  int reqkind, Oid reqop,
144                                  Oid *actualop,
145                                  Datum **values, int *nvalues,
146                                  float4 **numbers, int *nnumbers);
147 extern void free_attstatsslot(Oid atttype,
148                                   Datum *values, int nvalues,
149                                   float4 *numbers, int nnumbers);
150 extern char *get_namespace_name(Oid nspid);
151 extern Oid get_range_subtype(Oid rangeOid);
152
153 #define type_is_array(typid)  (get_element_type(typid) != InvalidOid)
154 /* type_is_array_domain accepts both plain arrays and domains over arrays */
155 #define type_is_array_domain(typid)  (get_base_element_type(typid) != InvalidOid)
156
157 #define TypeIsToastable(typid)  (get_typstorage(typid) != 'p')
158
159 #endif   /* LSYSCACHE_H */