PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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 procedure returns result set */
34  PLyTypeInfo result; /* also used to store info for trigger tuple
35  * type */
36  char *src; /* textual procedure code, after mangling */
37  char **argnames; /* Argument names */
39  int nargs;
40  Oid langid; /* OID of plpython pg_language entry */
41  List *trftypes; /* OID list of transform types */
42  PyObject *code; /* compiled procedure code */
43  PyObject *statics; /* data saved across calls, local scope */
44  PyObject *globals; /* data saved across calls, global scope */
45  long calldepth; /* depth of recursive calls of function */
46  PLySavedArgs *argstack; /* stack of outer-level call arguments */
47 } PLyProcedure;
48 
49 /* the procedure cache key */
50 typedef struct PLyProcedureKey
51 {
52  Oid fn_oid; /* function OID */
53  Oid fn_rel; /* triggered-on relation or InvalidOid */
55 
56 /* the procedure cache entry */
57 typedef struct PLyProcedureEntry
58 {
59  PLyProcedureKey key; /* hash key */
62 
63 /* PLyProcedure manipulation */
64 extern char *PLy_procedure_name(PLyProcedure *proc);
65 extern PLyProcedure *PLy_procedure_get(Oid fn_oid, Oid fn_rel, bool is_trigger);
66 extern void PLy_procedure_compile(PLyProcedure *proc, const char *src);
67 extern void PLy_procedure_delete(PLyProcedure *proc);
68 
69 #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)
PLyTypeInfo args[FUNC_MAX_ARGS]
uint32 TransactionId
Definition: c.h:391
PyObject * args
TransactionId fn_xmin
unsigned int Oid
Definition: postgres_ext.h:31
#define FUNC_MAX_ARGS
char ** argnames
PLyTypeInfo result
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)
struct PLyProcedureKey PLyProcedureKey
PLySavedArgs * argstack
PLyProcedure * proc
struct PLyProcedure PLyProcedure
PyObject * globals
Definition: pg_list.h:45
struct PLySavedArgs PLySavedArgs