aboutsummaryrefslogtreecommitdiff
path: root/src/pl/plpython/plpython.c
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2006-05-26 19:23:09 +0000
committerAndrew Dunstan <andrew@dunslane.net>2006-05-26 19:23:09 +0000
commit0a269db9cf823de737049967a0c03ca82b9abce1 (patch)
tree98663fee1eaad0ffb08fcd9c7eb41b3d7a975ee2 /src/pl/plpython/plpython.c
parent777f72cd37202737a9faea0c406804f37ed1c955 (diff)
downloadpostgresql-0a269db9cf823de737049967a0c03ca82b9abce1.tar.gz
postgresql-0a269db9cf823de737049967a0c03ca82b9abce1.zip
Add table_name and table_schema to plpython trigger data, plus docs and regression test.
Diffstat (limited to 'src/pl/plpython/plpython.c')
-rw-r--r--src/pl/plpython/plpython.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c
index dc36c9f8879..7ac3f89c146 100644
--- a/src/pl/plpython/plpython.c
+++ b/src/pl/plpython/plpython.c
@@ -1,7 +1,7 @@
/**********************************************************************
* plpython.c - python as a procedural language for PostgreSQL
*
- * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.79 2006/04/27 14:18:07 momjian Exp $
+ * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.80 2006/05/26 19:23:09 adunstan Exp $
*
*********************************************************************
*/
@@ -560,7 +560,9 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc, HeapTuple *
*pltevent,
*pltwhen,
*pltlevel,
- *pltrelid;
+ *pltrelid,
+ *plttablename,
+ *plttableschema;
PyObject *pltargs,
*pytnew,
*pytold;
@@ -584,6 +586,19 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc, HeapTuple *
Py_DECREF(pltrelid);
pfree(stroid);
+ stroid = SPI_getrelname(tdata->tg_relation);
+ plttablename = PyString_FromString(stroid);
+ PyDict_SetItemString(pltdata, "table_name", plttablename);
+ Py_DECREF(plttablename);
+ pfree(stroid);
+
+ stroid = SPI_getnspname(tdata->tg_relation);
+ plttableschema = PyString_FromString(stroid);
+ PyDict_SetItemString(pltdata, "table_schema", plttableschema);
+ Py_DECREF(plttableschema);
+ pfree(stroid);
+
+
if (TRIGGER_FIRED_BEFORE(tdata->tg_event))
pltwhen = PyString_FromString("BEFORE");
else if (TRIGGER_FIRED_AFTER(tdata->tg_event))