mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +03:00
plpython tried to use a single cache entry for a trigger function, but it
needs a separate cache entry for each table the trigger is applied to,
because there is table-dependent data in there. This was done correctly
before 9.1, but commit 46211da1b8
broke it
by simplifying the lookup key from "function OID and triggered table OID"
to "function OID and is-trigger boolean". Go back to using both OIDs
as the lookup key. Per bug report from Sandro Santilli.
Andres Freund
56 lines
1.6 KiB
C
56 lines
1.6 KiB
C
/*
|
|
* src/pl/plpython/plpy_procedure.h
|
|
*/
|
|
|
|
#ifndef PLPY_PROCEDURE_H
|
|
#define PLPY_PROCEDURE_H
|
|
|
|
#include "plpy_typeio.h"
|
|
|
|
|
|
extern void init_procedure_caches(void);
|
|
|
|
|
|
/* cached procedure data */
|
|
typedef struct PLyProcedure
|
|
{
|
|
char *proname; /* SQL name of procedure */
|
|
char *pyname; /* Python name of procedure */
|
|
TransactionId fn_xmin;
|
|
ItemPointerData fn_tid;
|
|
bool fn_readonly;
|
|
PLyTypeInfo result; /* also used to store info for trigger tuple
|
|
* type */
|
|
bool is_setof; /* true, if procedure returns result set */
|
|
PyObject *setof; /* contents of result set. */
|
|
char *src; /* textual procedure code, after mangling */
|
|
char **argnames; /* Argument names */
|
|
PLyTypeInfo args[FUNC_MAX_ARGS];
|
|
int nargs;
|
|
PyObject *code; /* compiled procedure code */
|
|
PyObject *statics; /* data saved across calls, local scope */
|
|
PyObject *globals; /* data saved across calls, global scope */
|
|
} PLyProcedure;
|
|
|
|
/* the procedure cache key */
|
|
typedef struct PLyProcedureKey
|
|
{
|
|
Oid fn_oid; /* function OID */
|
|
Oid fn_rel; /* triggered-on relation or InvalidOid */
|
|
} PLyProcedureKey;
|
|
|
|
/* the procedure cache entry */
|
|
typedef struct PLyProcedureEntry
|
|
{
|
|
PLyProcedureKey key; /* hash key */
|
|
PLyProcedure *proc;
|
|
} PLyProcedureEntry;
|
|
|
|
/* PLyProcedure manipulation */
|
|
extern char *PLy_procedure_name(PLyProcedure *proc);
|
|
extern PLyProcedure *PLy_procedure_get(Oid fn_oid, Oid fn_rel, bool is_trigger);
|
|
extern void PLy_procedure_compile(PLyProcedure *proc, const char *src);
|
|
extern void PLy_procedure_delete(PLyProcedure *proc);
|
|
|
|
#endif /* PLPY_PROCEDURE_H */
|