vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Excuse my English. Patch allows to get triggers table name in the trigger TD['relname']. Usefull when same trigger function applied to different tables. patch for plpython.c in Postgres 8.1 beta (diff was applied to) works also in Postgres 8.0.3 when placed in the same function (may be different line numbers) --- plpython-old.c 2005-07-10 08:56:55.000000000 +0400 +++ plpython.c 2005-10-04 12:03:36.000000000 +0400 @@ -582,7 +582,8 @@ PLy_trigger_build_args(FunctionCallInfo *pltevent, *pltwhen, *pltlevel, - *pltrelid; + *pltrelid, + *pltrelname; PyObject *pltargs, *pytnew, *pytold; @@ -606,6 +607,12 @@ PLy_trigger_build_args(FunctionCallInfo Py_DECREF(pltrelid); pfree(stroid); + stroid = SPI_getrelname(tdata->tg_relation); + pltrelname = PyString_FromString(stroid); + PyDict_SetItemString(pltdata, "relname", pltrelname); + Py_DECREF(pltrelname); + pfree(stroid); + if (TRIGGER_FIRED_BEFORE(tdata->tg_event)) pltwhen = PyString_FromString("BEFORE"); else if (TRIGGER_FIRED_AFTER(tdata->tg_event)) ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster |
| |||
| This has been saved for the 8.2 release: http://momjian.postgresql.org/cgi-bin/pgpatches_hold --------------------------------------------------------------------------- Sokolov Yura wrote: > Excuse my English. > Patch allows to get triggers table name in the trigger TD['relname']. > Usefull when same trigger function applied to different tables. > patch for plpython.c in Postgres 8.1 beta (diff was applied to) > works also in Postgres 8.0.3 when placed in the same function (may be > different line numbers) > > --- plpython-old.c 2005-07-10 08:56:55.000000000 +0400 > +++ plpython.c 2005-10-04 12:03:36.000000000 +0400 > @@ -582,7 +582,8 @@ PLy_trigger_build_args(FunctionCallInfo > *pltevent, > *pltwhen, > *pltlevel, > - *pltrelid; > + *pltrelid, > + *pltrelname; > PyObject *pltargs, > *pytnew, > *pytold; > @@ -606,6 +607,12 @@ PLy_trigger_build_args(FunctionCallInfo > Py_DECREF(pltrelid); > pfree(stroid); > > + stroid = SPI_getrelname(tdata->tg_relation); > + pltrelname = PyString_FromString(stroid); > + PyDict_SetItemString(pltdata, "relname", pltrelname); > + Py_DECREF(pltrelname); > + pfree(stroid); > + > if (TRIGGER_FIRED_BEFORE(tdata->tg_event)) > pltwhen = PyString_FromString("BEFORE"); > else if (TRIGGER_FIRED_AFTER(tdata->tg_event)) > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: Don't 'kill -9' the postmaster > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings |
| ||||
| This will appear in 8.2, but with the name 'table_name': revision 1.80 date: 2006/05/26 19:23:09; author: adunstan; state: Exp; lines: +17 -2 Add table_name and table_schema to plpython trigger data, plus docs and regression test. --------------------------------------------------------------------------- Sokolov Yura wrote: > Excuse my English. > Patch allows to get triggers table name in the trigger TD['relname']. > Usefull when same trigger function applied to different tables. > patch for plpython.c in Postgres 8.1 beta (diff was applied to) > works also in Postgres 8.0.3 when placed in the same function (may be > different line numbers) > > --- plpython-old.c 2005-07-10 08:56:55.000000000 +0400 > +++ plpython.c 2005-10-04 12:03:36.000000000 +0400 > @@ -582,7 +582,8 @@ PLy_trigger_build_args(FunctionCallInfo > *pltevent, > *pltwhen, > *pltlevel, > - *pltrelid; > + *pltrelid, > + *pltrelname; > PyObject *pltargs, > *pytnew, > *pytold; > @@ -606,6 +607,12 @@ PLy_trigger_build_args(FunctionCallInfo > Py_DECREF(pltrelid); > pfree(stroid); > > + stroid = SPI_getrelname(tdata->tg_relation); > + pltrelname = PyString_FromString(stroid); > + PyDict_SetItemString(pltdata, "relname", pltrelname); > + Py_DECREF(pltrelname); > + pfree(stroid); > + > if (TRIGGER_FIRED_BEFORE(tdata->tg_event)) > pltwhen = PyString_FromString("BEFORE"); > else if (TRIGGER_FIRED_AFTER(tdata->tg_event)) > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: Don't 'kill -9' the postmaster -- Bruce Momjian bruce@momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. + ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq |