]> granicus.if.org Git - postgresql/commitdiff
I noticed that plpython does not make the relid available inside
authorBruce Momjian <bruce@momjian.us>
Wed, 12 Sep 2001 03:03:25 +0000 (03:03 +0000)
committerBruce Momjian <bruce@momjian.us>
Wed, 12 Sep 2001 03:03:25 +0000 (03:03 +0000)
a trigger the way that pltcl does.

Here's a little patch that adds it in.

-Brad McLean

src/pl/plpython/plpython.c

index ea0b7d5ed9175a065561a75a390e738846206abc..df9b4e1080a33c0664af7fc94dc0e5440ad5d94a 100644 (file)
@@ -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))