Add relid to TD in plpython
Add relid to TD in plpython
От:
Bradley McLean <brad@bradm.net>
Дата:
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");
Re: Add relid to TD in plpython
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
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@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Re: Add relid to TD in plpython
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
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. > Thanks, Bruce. > > Here's some matching documentation, including some other > undocumented items in TD. > > Should doc patches alse be sent to pgsql-patches, or do I > have to subscribe to pgsql-docs? > > The archive link for pgsql-patches is broken, and I don't > see any patches in spot checking the archive for pgsql-docs. > > -Brad McLean. > > * Bruce Momjian (pgman@candle.pha.pa.us) [010910 10:24]: > > > > 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. [ Attachment, skipping... ] -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Re: Add relid to TD in plpython
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
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@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026