Hello all; hope I'm doing this right.
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
---------------
Index: src/pl/plpython/plpython.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/pl/plpython/plpython.c,v
retrieving revision 1.4
diff -u -r1.4 plpython.c
--- src/pl/plpython/plpython.c 2001/06/01 18:17:44 1.4
+++ src/pl/plpython/plpython.c 2001/09/10 02:30:42
@@ -595,9 +595,10 @@
{
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();
@@ -620,6 +621,15 @@
pltname = PyString_FromString(tdata->tg_trigger->tgname);
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");