I noticed that plpython does not make the relid available inside
a trigger the way that pltcl does. Here's a little patch that adds it in. -Brad McLean
This commit is contained in:
parent
3b99f74d95
commit
148f94b98f
@ -29,7 +29,7 @@
|
||||
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.4 2001/06/01 18:17:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.5 2001/09/12 03:03:25 momjian Exp $
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
@ -595,9 +595,10 @@ PLy_trigger_build_args(PG_FUNCTION_ARGS, PLyProcedure *proc, HeapTuple *rv)
|
||||
{
|
||||
DECLARE_EXC();
|
||||
TriggerData *tdata;
|
||||
PyObject *pltname, *pltevent, *pltwhen, *pltlevel;
|
||||
PyObject *pltname, *pltevent, *pltwhen, *pltlevel, *pltrelid;
|
||||
PyObject *pltargs, *pytnew, *pytold;
|
||||
PyObject *pltdata = NULL;
|
||||
char *stroid;
|
||||
|
||||
enter();
|
||||
|
||||
@ -621,6 +622,15 @@ PLy_trigger_build_args(PG_FUNCTION_ARGS, PLyProcedure *proc, HeapTuple *rv)
|
||||
PyDict_SetItemString(pltdata, "name", pltname);
|
||||
Py_DECREF(pltname);
|
||||
|
||||
stroid = DatumGetCString(DirectFunctionCall1(oidout,
|
||||
ObjectIdGetDatum(tdata->tg_relation->rd_id)));
|
||||
pltrelid = PyString_FromString(stroid);
|
||||
PyDict_SetItemString(pltdata, "relid", pltrelid);
|
||||
Py_DECREF(pltrelid);
|
||||
pfree(stroid);
|
||||
|
||||
|
||||
|
||||
if (TRIGGER_FIRED_BEFORE(tdata->tg_event))
|
||||
pltwhen = PyString_FromString("BEFORE");
|
||||
else if (TRIGGER_FIRED_AFTER(tdata->tg_event))
|
||||
|
Loading…
x
Reference in New Issue
Block a user