Add relid to TD in plpython

From: Bradley McLean <brad(at)bradm(dot)net>
To: pgsql-patches(at)postgresql(dot)org
Subject: Add relid to TD in plpython
Date: 2001-09-10 02:34:29
Message-ID: 20010909223429.A3724@bradm.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

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");

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Karel Zak 2001-09-10 06:27:52 Re: [PATCHES] CURRENT CVS: MULTIBYTE: CANT CONNECT....
Previous Message Bruce Momjian 2001-09-10 00:19:51 Re: Makefiles for building with mingw32 on win32