PostgreSQL Source Code  git master
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  int nargs; /* length of namedargs array */
20  PyObject *namedargs[FLEXIBLE_ARRAY_MEMBER]; /* named args */
21 } PLySavedArgs;
22 
23 /* cached procedure data */
24 typedef struct PLyProcedure
25 {
26  MemoryContext mcxt; /* context holding this PLyProcedure and its
27  * subsidiary data */
28  char *proname; /* SQL name of procedure */
29  char *pyname; /* Python name of procedure */
33  bool is_setof; /* true, if function returns result set */
35  PLyObToDatum result; /* Function result output conversion info */
36  PLyDatumToOb result_in; /* For converting input tuples in a trigger */
37  char *src; /* textual procedure code, after mangling */
38  char **argnames; /* Argument names */
39  PLyDatumToOb *args; /* Argument input conversion info */
40  int nargs; /* Number of elements in above arrays */
41  Oid langid; /* OID of plpython pg_language entry */
42  List *trftypes; /* OID list of transform types */
43  PyObject *code; /* compiled procedure code */
44  PyObject *statics; /* data saved across calls, local scope */
45  PyObject *globals; /* data saved across calls, global scope */
46  long calldepth; /* depth of recursive calls of function */
47  PLySavedArgs *argstack; /* stack of outer-level call arguments */
48 } PLyProcedure;
49 
50 /* the procedure cache key */
51 typedef struct PLyProcedureKey
52 {
53  Oid fn_oid; /* function OID */
54  Oid fn_rel; /* triggered-on relation or InvalidOid */
56 
57 /* the procedure cache entry */
58 typedef struct PLyProcedureEntry
59 {
60  PLyProcedureKey key; /* hash key */
63 
64 /* PLyProcedure manipulation */
65 extern char *PLy_procedure_name(PLyProcedure *proc);
66 extern PLyProcedure *PLy_procedure_get(Oid fn_oid, Oid fn_rel, bool is_trigger);
67 extern void PLy_procedure_compile(PLyProcedure *proc, const char *src);
68 extern void PLy_procedure_delete(PLyProcedure *proc);
69 
70 #endif /* PLPY_PROCEDURE_H */
struct PLySavedArgs * next
PLyProcedure * PLy_procedure_get(Oid fn_oid, Oid fn_rel, bool is_trigger)
ItemPointerData fn_tid
void PLy_procedure_delete(PLyProcedure *proc)
void PLy_procedure_compile(PLyProcedure *proc, const char *src)
uint32 TransactionId
Definition: c.h:463
PyObject * args
TransactionId fn_xmin
unsigned int Oid
Definition: postgres_ext.h:31
PLyDatumToOb * args
char ** argnames
struct PLyProcedureEntry PLyProcedureEntry
MemoryContext mcxt
PyObject * statics
PyObject * namedargs[FLEXIBLE_ARRAY_MEMBER]
PyObject * code
PLyProcedureKey key
void init_procedure_caches(void)
char * PLy_procedure_name(PLyProcedure *proc)
PLyDatumToOb result_in
struct PLyProcedureKey PLyProcedureKey
PLySavedArgs * argstack
PLyProcedure * proc
PLyObToDatum result
struct PLyProcedure PLyProcedure
PyObject * globals
Definition: pg_list.h:45
struct PLySavedArgs PLySavedArgs