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 */
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 */
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 */
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:398
uint32 TransactionId
Definition: c.h:652
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]