Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 148f94b

Browse files
committed
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
1 parent 3b99f74 commit 148f94b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/pl/plpython/plpython.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
3030
*
3131
* IDENTIFICATION
32-
* $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.4 2001/06/01 18:17:44 tgl Exp $
32+
* $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.5 2001/09/12 03:03:25 momjian Exp $
3333
*
3434
*********************************************************************
3535
*/
@@ -595,9 +595,10 @@ PLy_trigger_build_args(PG_FUNCTION_ARGS, PLyProcedure *proc, HeapTuple *rv)
595595
{
596596
DECLARE_EXC();
597597
TriggerData *tdata;
598-
PyObject *pltname, *pltevent, *pltwhen, *pltlevel;
598+
PyObject *pltname, *pltevent, *pltwhen, *pltlevel, *pltrelid;
599599
PyObject *pltargs, *pytnew, *pytold;
600600
PyObject *pltdata = NULL;
601+
char *stroid;
601602

602603
enter();
603604

@@ -621,6 +622,15 @@ PLy_trigger_build_args(PG_FUNCTION_ARGS, PLyProcedure *proc, HeapTuple *rv)
621622
PyDict_SetItemString(pltdata, "name", pltname);
622623
Py_DECREF(pltname);
623624

625+
stroid = DatumGetCString(DirectFunctionCall1(oidout,
626+
ObjectIdGetDatum(tdata->tg_relation->rd_id)));
627+
pltrelid = PyString_FromString(stroid);
628+
PyDict_SetItemString(pltdata, "relid", pltrelid);
629+
Py_DECREF(pltrelid);
630+
pfree(stroid);
631+
632+
633+
624634
if (TRIGGER_FIRED_BEFORE(tdata->tg_event))
625635
pltwhen = PyString_FromString("BEFORE");
626636
else if (TRIGGER_FIRED_AFTER(tdata->tg_event))

0 commit comments

Comments
 (0)