PostgreSQL Source Code  git master
pg_proc.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pg_proc.h
4  * definition of the "procedure" system catalog (pg_proc)
5  *
6  * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/include/catalog/pg_proc.h
10  *
11  * NOTES
12  * The Catalog.pm module reads this file and derives schema
13  * information.
14  *
15  *-------------------------------------------------------------------------
16  */
17 #ifndef PG_PROC_H
18 #define PG_PROC_H
19 
20 #include "catalog/genbki.h"
21 #include "catalog/objectaddress.h"
22 #include "catalog/pg_proc_d.h"
23 #include "nodes/pg_list.h"
24 
25 /* ----------------
26  * pg_proc definition. cpp turns this into
27  * typedef struct FormData_pg_proc
28  * ----------------
29  */
30 CATALOG(pg_proc,1255,ProcedureRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81,ProcedureRelation_Rowtype_Id) BKI_SCHEMA_MACRO
31 {
32  Oid oid; /* oid */
33 
34  /* procedure name */
36 
37  /* OID of namespace containing this proc */
38  Oid pronamespace BKI_DEFAULT(PGNSP);
39 
40  /* procedure owner */
41  Oid proowner BKI_DEFAULT(PGUID);
42 
43  /* OID of pg_language entry */
44  Oid prolang BKI_DEFAULT(internal) BKI_LOOKUP(pg_language);
45 
46  /* estimated execution cost */
47  float4 procost BKI_DEFAULT(1);
48 
49  /* estimated # of rows out (if proretset) */
50  float4 prorows BKI_DEFAULT(0);
51 
52  /* element type of variadic array, or 0 */
53  Oid provariadic BKI_DEFAULT(0) BKI_LOOKUP(pg_type);
54 
55  /* planner support function for this function, or 0 if none */
56  regproc prosupport BKI_DEFAULT(0) BKI_LOOKUP(pg_proc);
57 
58  /* see PROKIND_ categories below */
59  char prokind BKI_DEFAULT(f);
60 
61  /* security definer */
62  bool prosecdef BKI_DEFAULT(f);
63 
64  /* is it a leak-proof function? */
65  bool proleakproof BKI_DEFAULT(f);
66 
67  /* strict with respect to NULLs? */
68  bool proisstrict BKI_DEFAULT(t);
69 
70  /* returns a set? */
71  bool proretset BKI_DEFAULT(f);
72 
73  /* see PROVOLATILE_ categories below */
74  char provolatile BKI_DEFAULT(i);
75 
76  /* see PROPARALLEL_ categories below */
77  char proparallel BKI_DEFAULT(s);
78 
79  /* number of arguments */
80  /* Note: need not be given in pg_proc.dat; genbki.pl will compute it */
82 
83  /* number of arguments with defaults */
84  int16 pronargdefaults BKI_DEFAULT(0);
85 
86  /* OID of result type */
87  Oid prorettype BKI_LOOKUP(pg_type);
88 
89  /*
90  * variable-length fields start here, but we allow direct access to
91  * proargtypes
92  */
93 
94  /* parameter types (excludes OUT params of functions) */
95  oidvector proargtypes BKI_LOOKUP(pg_type) BKI_FORCE_NOT_NULL;
96 
97 #ifdef CATALOG_VARLEN
98 
99  /* all param types (NULL if IN only) */
100  Oid proallargtypes[1] BKI_DEFAULT(_null_) BKI_LOOKUP(pg_type);
101 
102  /* parameter modes (NULL if IN only) */
103  char proargmodes[1] BKI_DEFAULT(_null_);
104 
105  /* parameter names (NULL if no names) */
106  text proargnames[1] BKI_DEFAULT(_null_);
107 
108  /* list of expression trees for argument defaults (NULL if none) */
109  pg_node_tree proargdefaults BKI_DEFAULT(_null_);
110 
111  /* types for which to apply transforms */
112  Oid protrftypes[1] BKI_DEFAULT(_null_);
113 
114  /* procedure source text */
115  text prosrc BKI_FORCE_NOT_NULL;
116 
117  /* secondary procedure info (can be NULL) */
118  text probin BKI_DEFAULT(_null_);
119 
120  /* procedure-local GUC settings */
121  text proconfig[1] BKI_DEFAULT(_null_);
122 
123  /* access permissions */
124  aclitem proacl[1] BKI_DEFAULT(_null_);
125 #endif
127 
128 /* ----------------
129  * Form_pg_proc corresponds to a pointer to a tuple with
130  * the format of pg_proc relation.
131  * ----------------
132  */
134 
135 DECLARE_TOAST(pg_proc, 2836, 2837);
136 
137 DECLARE_UNIQUE_INDEX(pg_proc_oid_index, 2690, on pg_proc using btree(oid oid_ops));
138 #define ProcedureOidIndexId 2690
139 DECLARE_UNIQUE_INDEX(pg_proc_proname_args_nsp_index, 2691, on pg_proc using btree(proname name_ops, proargtypes oidvector_ops, pronamespace oid_ops));
140 #define ProcedureNameArgsNspIndexId 2691
141 
142 #ifdef EXPOSE_TO_CLIENT_CODE
143 
144 /*
145  * Symbolic values for prokind column
146  */
147 #define PROKIND_FUNCTION 'f'
148 #define PROKIND_AGGREGATE 'a'
149 #define PROKIND_WINDOW 'w'
150 #define PROKIND_PROCEDURE 'p'
151 
152 /*
153  * Symbolic values for provolatile column: these indicate whether the result
154  * of a function is dependent *only* on the values of its explicit arguments,
155  * or can change due to outside factors (such as parameter variables or
156  * table contents). NOTE: functions having side-effects, such as setval(),
157  * must be labeled volatile to ensure they will not get optimized away,
158  * even if the actual return value is not changeable.
159  */
160 #define PROVOLATILE_IMMUTABLE 'i' /* never changes for given input */
161 #define PROVOLATILE_STABLE 's' /* does not change within a scan */
162 #define PROVOLATILE_VOLATILE 'v' /* can change even within a scan */
163 
164 /*
165  * Symbolic values for proparallel column: these indicate whether a function
166  * can be safely be run in a parallel backend, during parallelism but
167  * necessarily in the leader, or only in non-parallel mode.
168  */
169 #define PROPARALLEL_SAFE 's' /* can run in worker or leader */
170 #define PROPARALLEL_RESTRICTED 'r' /* can run in parallel leader only */
171 #define PROPARALLEL_UNSAFE 'u' /* banned while in parallel mode */
172 
173 /*
174  * Symbolic values for proargmodes column. Note that these must agree with
175  * the FunctionParameterMode enum in parsenodes.h; we declare them here to
176  * be accessible from either header.
177  */
178 #define PROARGMODE_IN 'i'
179 #define PROARGMODE_OUT 'o'
180 #define PROARGMODE_INOUT 'b'
181 #define PROARGMODE_VARIADIC 'v'
182 #define PROARGMODE_TABLE 't'
183 
184 #endif /* EXPOSE_TO_CLIENT_CODE */
185 
186 
187 extern ObjectAddress ProcedureCreate(const char *procedureName,
188  Oid procNamespace,
189  bool replace,
190  bool returnsSet,
191  Oid returnType,
192  Oid proowner,
193  Oid languageObjectId,
194  Oid languageValidator,
195  const char *prosrc,
196  const char *probin,
197  char prokind,
198  bool security_definer,
199  bool isLeakProof,
200  bool isStrict,
201  char volatility,
202  char parallel,
203  oidvector *parameterTypes,
204  Datum allParameterTypes,
205  Datum parameterModes,
206  Datum parameterNames,
207  List *parameterDefaults,
208  Datum trftypes,
209  Datum proconfig,
210  Oid prosupport,
211  float4 procost,
212  float4 prorows);
213 
214 extern bool function_parse_error_transpose(const char *prosrc);
215 
216 extern List *oid_array_to_list(Datum datum);
217 
218 #endif /* PG_PROC_H */
#define BKI_BOOTSTRAP
Definition: genbki.h:26
signed short int16
Definition: c.h:416
Definition: c.h:648
NameData proname
Definition: pg_proc.h:35
List * oid_array_to_list(Datum datum)
Definition: pg_proc.c:1137
ObjectAddress ProcedureCreate(const char *procedureName, Oid procNamespace, bool replace, bool returnsSet, Oid returnType, Oid proowner, Oid languageObjectId, Oid languageValidator, const char *prosrc, const char *probin, char prokind, bool security_definer, bool isLeakProof, bool isStrict, char volatility, char parallel, oidvector *parameterTypes, Datum allParameterTypes, Datum parameterModes, Datum parameterNames, List *parameterDefaults, Datum trftypes, Datum proconfig, Oid prosupport, float4 procost, float4 prorows)
Definition: pg_proc.c:69
int16 pronargs
Definition: pg_proc.h:81
unsigned int Oid
Definition: postgres_ext.h:31
DECLARE_UNIQUE_INDEX(pg_proc_oid_index, 2690, on pg_proc using btree(oid oid_ops))
#define BKI_FORCE_NOT_NULL
Definition: genbki.h:33
ProcedureRelation_Rowtype_Id BKI_SCHEMA_MACRO
Definition: pg_proc.h:31
Definition: c.h:663
CATALOG(pg_proc, 1255, ProcedureRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81
#define BKI_ROWTYPE_OID(oid, oidmacro)
Definition: genbki.h:28
float float4
Definition: c.h:552
uintptr_t Datum
Definition: postgres.h:367
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
Oid pronamespace BKI_DEFAULT(PGNSP)
DECLARE_TOAST(pg_proc, 2836, 2837)
Oid regproc
Definition: c.h:572
int i
Definition: c.h:609
FormData_pg_proc
Definition: pg_proc.h:126
Definition: pg_list.h:50
Oid prorettype BKI_LOOKUP(pg_type)
bool function_parse_error_transpose(const char *prosrc)
Definition: pg_proc.c:965