PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
plpy_procedure.h
Go to the documentation of this file.
1 /*
2  * src/pl/plpython/plpy_procedure.h
3  */
4 
5 #ifndef PLPY_PROCEDURE_H
6 #define PLPY_PROCEDURE_H
7 
8 #include "plpy_typeio.h"
9 
10 
11 extern void init_procedure_caches(void);
12 
13 
14 /* saved arguments for outer recursion level or set-returning function */
15 typedef struct PLySavedArgs
16 {
17  struct PLySavedArgs *next; /* linked-list pointer */
18  PyObject *args; /* "args" element of globals dict */
19  PyObject *td; /* "TD" element of globals dict, if trigger */
20  int nargs; /* length of namedargs array */
21  PyObject *namedargs[FLEXIBLE_ARRAY_MEMBER]; /* named args */
23 
24 /* cached procedure data */
25 typedef struct PLyProcedure
26 {
27  MemoryContext mcxt; /* context holding this PLyProcedure and its
28  * subsidiary data */
29  char *proname; /* SQL name of procedure */
30  char *pyname; /* Python name of procedure */
34  bool is_setof; /* true, if function returns result set */
36  bool is_trigger; /* called as trigger? */
37  PLyObToDatum result; /* Function result output conversion info */
38  PLyDatumToOb result_in; /* For converting input tuples in a trigger */
39  char *src; /* textual procedure code, after mangling */
40  char **argnames; /* Argument names */
41  PLyDatumToOb *args; /* Argument input conversion info */
42  int nargs; /* Number of elements in above arrays */
43  Oid langid; /* OID of plpython pg_language entry */
44  List *trftypes; /* OID list of transform types */
45  PyObject *code; /* compiled procedure code */
46  PyObject *statics; /* data saved across calls, local scope */
47  PyObject *globals; /* data saved across calls, global scope */
48  long calldepth; /* depth of recursive calls of function */
49  PLySavedArgs *argstack; /* stack of outer-level call arguments */
51 
52 /* the procedure cache key */
53 typedef struct PLyProcedureKey
54 {
55  Oid fn_oid; /* function OID */
56  Oid fn_rel; /* triggered-on relation or InvalidOid */
58 
59 /* the procedure cache entry */
60 typedef struct PLyProcedureEntry
61 {
62  PLyProcedureKey key; /* hash key */
65 
66 /* PLyProcedure manipulation */
67 extern char *PLy_procedure_name(PLyProcedure *proc);
68 extern PLyProcedure *PLy_procedure_get(Oid fn_oid, Oid fn_rel, bool is_trigger);
69 extern void PLy_procedure_compile(PLyProcedure *proc, const char *src);
70 extern void PLy_procedure_delete(PLyProcedure *proc);
71 
72 #endif /* PLPY_PROCEDURE_H */
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:413
uint32 TransactionId
Definition: c.h:631
struct PLySavedArgs PLySavedArgs
void init_procedure_caches(void)
struct PLyProcedureKey PLyProcedureKey
char * PLy_procedure_name(PLyProcedure *proc)
PLyProcedure * PLy_procedure_get(Oid fn_oid, Oid fn_rel, bool is_trigger)
struct PLyProcedure PLyProcedure
void PLy_procedure_compile(PLyProcedure *proc, const char *src)
void PLy_procedure_delete(PLyProcedure *proc)
struct PLyProcedureEntry PLyProcedureEntry
unsigned int Oid
Definition: postgres_ext.h:31
Definition: pg_list.h:54
PLyProcedure * proc
PLyProcedureKey key
PLyDatumToOb * args
PLyObToDatum result
PyObject * code
PLyDatumToOb result_in
PLySavedArgs * argstack
MemoryContext mcxt
char ** argnames
PyObject * globals
ItemPointerData fn_tid
TransactionId fn_xmin
PyObject * statics
PyObject * args
struct PLySavedArgs * next
PyObject * namedargs[FLEXIBLE_ARRAY_MEMBER]
PyObject * td