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
11extern void init_procedure_caches(void);
12
13
14/*
15 * Trigger type
16 */
17typedef enum PLyTrigType
18{
23
24/* saved arguments for outer recursion level or set-returning function */
25typedef struct PLySavedArgs
26{
27 struct PLySavedArgs *next; /* linked-list pointer */
28 PyObject *args; /* "args" element of globals dict */
29 PyObject *td; /* "TD" element of globals dict, if trigger */
30 int nargs; /* length of namedargs array */
31 PyObject *namedargs[FLEXIBLE_ARRAY_MEMBER]; /* named args */
33
34/* cached procedure data */
35typedef struct PLyProcedure
36{
37 MemoryContext mcxt; /* context holding this PLyProcedure and its
38 * subsidiary data */
39 char *proname; /* SQL name of procedure */
40 char *pyname; /* Python name of procedure */
44 bool is_setof; /* true, if function returns result set */
46 PLyTrigType is_trigger; /* called as trigger? */
47 PLyObToDatum result; /* Function result output conversion info */
48 PLyDatumToOb result_in; /* For converting input tuples in a trigger */
49 char *src; /* textual procedure code, after mangling */
50 char **argnames; /* Argument names */
51 PLyDatumToOb *args; /* Argument input conversion info */
52 int nargs; /* Number of elements in above arrays */
53 Oid langid; /* OID of plpython pg_language entry */
54 List *trftypes; /* OID list of transform types */
55 PyObject *code; /* compiled procedure code */
56 PyObject *statics; /* data saved across calls, local scope */
57 PyObject *globals; /* data saved across calls, global scope */
58 long calldepth; /* depth of recursive calls of function */
59 PLySavedArgs *argstack; /* stack of outer-level call arguments */
61
62/* the procedure cache key */
63typedef struct PLyProcedureKey
64{
65 Oid fn_oid; /* function OID */
66 Oid fn_rel; /* triggered-on relation or InvalidOid */
68
69/* the procedure cache entry */
70typedef struct PLyProcedureEntry
71{
72 PLyProcedureKey key; /* hash key */
75
76/* PLyProcedure manipulation */
77extern char *PLy_procedure_name(PLyProcedure *proc);
78extern PLyProcedure *PLy_procedure_get(Oid fn_oid, Oid fn_rel, PLyTrigType is_trigger);
79extern void PLy_procedure_compile(PLyProcedure *proc, const char *src);
80extern void PLy_procedure_delete(PLyProcedure *proc);
81
82#endif /* PLPY_PROCEDURE_H */
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:470
uint32 TransactionId
Definition: c.h:657
char * PLy_procedure_name(PLyProcedure *proc)
PLyTrigType
@ PLPY_EVENT_TRIGGER
@ PLPY_TRIGGER
@ PLPY_NOT_TRIGGER
struct PLySavedArgs PLySavedArgs
void init_procedure_caches(void)
struct PLyProcedureKey PLyProcedureKey
PLyProcedure * PLy_procedure_get(Oid fn_oid, Oid fn_rel, PLyTrigType 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:32
Definition: pg_list.h:54
PLyProcedure * proc
PLyProcedureKey key
PLyDatumToOb * args
PLyTrigType is_trigger
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