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