OSDN Git Service

Update copyright for 2009.
[pg-rex/syncrep.git] / 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-2009, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.127 2009/01/01 17:24:02 momjian Exp $
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 /* I/O function selector for get_type_io_data */
21 typedef enum IOFuncSelector
22 {
23         IOFunc_input,
24         IOFunc_output,
25         IOFunc_receive,
26         IOFunc_send
27 } IOFuncSelector;
28
29 /* Hook for plugins to get control in get_attavgwidth() */
30 typedef int32 (*get_attavgwidth_hook_type) (Oid relid, AttrNumber attnum);
31 extern PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook;
32
33 extern bool op_in_opfamily(Oid opno, Oid opfamily);
34 extern int      get_op_opfamily_strategy(Oid opno, Oid opfamily);
35 extern void get_op_opfamily_properties(Oid opno, Oid opfamily,
36                                                    int *strategy,
37                                                    Oid *lefttype,
38                                                    Oid *righttype);
39 extern Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype,
40                                         int16 strategy);
41 extern bool get_ordering_op_properties(Oid opno,
42                                                    Oid *opfamily, Oid *opcintype, int16 *strategy);
43 extern bool get_compare_function_for_ordering_op(Oid opno,
44                                                                          Oid *cmpfunc, bool *reverse);
45 extern Oid      get_equality_op_for_ordering_op(Oid opno, bool *reverse);
46 extern Oid      get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type);
47 extern List *get_mergejoin_opfamilies(Oid opno);
48 extern bool get_compatible_hash_operators(Oid opno,
49                                                           Oid *lhs_opno, Oid *rhs_opno);
50 extern bool get_op_hash_functions(Oid opno,
51                                           RegProcedure *lhs_procno, RegProcedure *rhs_procno);
52 extern void get_op_btree_interpretation(Oid opno,
53                                                         List **opfamilies, List **opstrats);
54 extern bool equality_ops_are_compatible(Oid opno1, Oid opno2);
55 extern Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype,
56                                   int16 procnum);
57 extern char *get_attname(Oid relid, AttrNumber attnum);
58 extern char *get_relid_attribute_name(Oid relid, AttrNumber attnum);
59 extern AttrNumber get_attnum(Oid relid, const char *attname);
60 extern Oid      get_atttype(Oid relid, AttrNumber attnum);
61 extern int32 get_atttypmod(Oid relid, AttrNumber attnum);
62 extern void get_atttypetypmod(Oid relid, AttrNumber attnum,
63                                   Oid *typid, int32 *typmod);
64 extern char *get_constraint_name(Oid conoid);
65 extern Oid      get_opclass_family(Oid opclass);
66 extern Oid      get_opclass_input_type(Oid opclass);
67 extern RegProcedure get_opcode(Oid opno);
68 extern char *get_opname(Oid opno);
69 extern void op_input_types(Oid opno, Oid *lefttype, Oid *righttype);
70 extern bool op_mergejoinable(Oid opno);
71 extern bool op_hashjoinable(Oid opno);
72 extern bool op_strict(Oid opno);
73 extern char op_volatile(Oid opno);
74 extern Oid      get_commutator(Oid opno);
75 extern Oid      get_negator(Oid opno);
76 extern RegProcedure get_oprrest(Oid opno);
77 extern RegProcedure get_oprjoin(Oid opno);
78 extern char *get_func_name(Oid funcid);
79 extern Oid      get_func_rettype(Oid funcid);
80 extern int      get_func_nargs(Oid funcid);
81 extern Oid      get_func_signature(Oid funcid, Oid **argtypes, int *nargs);
82 extern bool get_func_retset(Oid funcid);
83 extern bool func_strict(Oid funcid);
84 extern char func_volatile(Oid funcid);
85 extern float4 get_func_cost(Oid funcid);
86 extern float4 get_func_rows(Oid funcid);
87 extern Oid      get_relname_relid(const char *relname, Oid relnamespace);
88 extern char *get_rel_name(Oid relid);
89 extern Oid      get_rel_namespace(Oid relid);
90 extern Oid      get_rel_type_id(Oid relid);
91 extern char get_rel_relkind(Oid relid);
92 extern Oid      get_rel_tablespace(Oid relid);
93 extern bool get_typisdefined(Oid typid);
94 extern int16 get_typlen(Oid typid);
95 extern bool get_typbyval(Oid typid);
96 extern void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval);
97 extern void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
98                                          char *typalign);
99 extern Oid      getTypeIOParam(HeapTuple typeTuple);
100 extern void get_type_io_data(Oid typid,
101                                  IOFuncSelector which_func,
102                                  int16 *typlen,
103                                  bool *typbyval,
104                                  char *typalign,
105                                  char *typdelim,
106                                  Oid *typioparam,
107                                  Oid *func);
108 extern char get_typstorage(Oid typid);
109 extern Node *get_typdefault(Oid typid);
110 extern char get_typtype(Oid typid);
111 extern bool type_is_rowtype(Oid typid);
112 extern bool type_is_enum(Oid typid);
113 extern void get_type_category_preferred(Oid typid,
114                                                                                 char *typcategory,
115                                                                                 bool *typispreferred);
116 extern Oid      get_typ_typrelid(Oid typid);
117 extern Oid      get_element_type(Oid typid);
118 extern Oid      get_array_type(Oid typid);
119 extern void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam);
120 extern void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena);
121 extern void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam);
122 extern void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena);
123 extern Oid      get_typmodin(Oid typid);
124 extern Oid      getBaseType(Oid typid);
125 extern Oid      getBaseTypeAndTypmod(Oid typid, int32 *typmod);
126 extern int32 get_typavgwidth(Oid typid, int32 typmod);
127 extern int32 get_attavgwidth(Oid relid, AttrNumber attnum);
128 extern bool get_attstatsslot(HeapTuple statstuple,
129                                  Oid atttype, int32 atttypmod,
130                                  int reqkind, Oid reqop,
131                                  Datum **values, int *nvalues,
132                                  float4 **numbers, int *nnumbers);
133 extern void free_attstatsslot(Oid atttype,
134                                   Datum *values, int nvalues,
135                                   float4 *numbers, int nnumbers);
136 extern char *get_namespace_name(Oid nspid);
137 extern Oid      get_roleid(const char *rolname);
138 extern Oid      get_roleid_checked(const char *rolname);
139
140 #define type_is_array(typid)  (get_element_type(typid) != InvalidOid)
141
142 #define TypeIsToastable(typid)  (get_typstorage(typid) != 'p')
143
144 #endif   /* LSYSCACHE_H */