1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-05 02:22:28 +03:00

Fix plpython's handling of functions used as triggers on multiple tables.

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
This commit is contained in:
Tom Lane
2013-01-25 16:59:00 -05:00
parent 6d5c62ad99
commit 308711afc7
5 changed files with 99 additions and 41 deletions

View File

@@ -32,16 +32,23 @@ typedef struct PLyProcedure
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
{
Oid fn_oid; /* hash key */
PLyProcedureKey key; /* hash key */
PLyProcedure *proc;
} PLyProcedureEntry;
/* PLyProcedure manipulation */
extern char *PLy_procedure_name(PLyProcedure *proc);
extern PLyProcedure *PLy_procedure_get(Oid fn_oid, bool is_trigger);
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);