Re: Add relid to TD in plpython

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Bradley McLean <brad(at)bradm(dot)net>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Add relid to TD in plpython
Date: 2001-09-10 14:24:20
Message-ID: 200109101424.f8AEOKv17009@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


Your patch has been added to the PostgreSQL unapplied patches list at:

http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

> 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");
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://www.postgresql.org/search.mpl
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2001-09-10 14:49:06 Re: UTF-8 patch for PgTcl (was: Patch for pl/tcl ...)
Previous Message Bruce Momjian 2001-09-10 14:24:01 Re: Fix DatabaseMetaDataTest in JDBC test suite