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