Skip site navigation (1) Skip section navigation (2)

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-12 02:56:32
Message-ID: 200109120256.f8C2uWK19674@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-patches
Patch applied.  Thanks.

> 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

pgsql-patches by date

Next:From: Bruce MomjianDate: 2001-09-12 03:30:34
Subject: Re: Bytea string operator support
Previous:From: Kenji SugitaDate: 2001-09-12 02:23:25
Subject: Re: Configuring fdatasync for Solaris2

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group