2 * src/pl/plpython/plpy_procedure.h
5 #ifndef PLPY_PROCEDURE_H
6 #define PLPY_PROCEDURE_H
8 #include "plpy_typeio.h"
11 extern void init_procedure_caches(void);
14 /* saved arguments for outer recursion level or set-returning function */
15 typedef struct PLySavedArgs
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 */
24 /* cached procedure data */
25 typedef struct PLyProcedure
27 MemoryContext mcxt
; /* context holding this PLyProcedure and its
29 char *proname
; /* SQL name of procedure */
30 char *pyname
; /* Python name of procedure */
31 TransactionId fn_xmin
;
32 ItemPointerData fn_tid
;
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 */
52 /* the procedure cache key */
53 typedef struct PLyProcedureKey
55 Oid fn_oid
; /* function OID */
56 Oid fn_rel
; /* triggered-on relation or InvalidOid */
59 /* the procedure cache entry */
60 typedef struct PLyProcedureEntry
62 PLyProcedureKey key
; /* hash key */
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
);
72 #endif /* PLPY_PROCEDURE_H */