pg_proc.h 6.5 KB

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