diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-03-28 00:21:56 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-03-28 00:21:56 +0000 |
commit | 7692d8d5b72f510bd84f708d0a8e53c548f71adc (patch) | |
tree | 2db349ab412c7353734bfd232fbba8c5261913a0 /src/pl | |
parent | 107b3d0c23b52cf20b705d00200211d8cc341f52 (diff) | |
download | postgresql-7692d8d5b72f510bd84f708d0a8e53c548f71adc.tar.gz postgresql-7692d8d5b72f510bd84f708d0a8e53c548f71adc.zip |
Support statement-level ON TRUNCATE triggers. Simon Riggs
Diffstat (limited to 'src/pl')
-rw-r--r-- | src/pl/plperl/plperl.c | 6 | ||||
-rw-r--r-- | src/pl/plpgsql/src/pl_exec.c | 6 | ||||
-rw-r--r-- | src/pl/plpython/plpython.c | 4 | ||||
-rw-r--r-- | src/pl/tcl/pltcl.c | 4 |
4 files changed, 15 insertions, 5 deletions
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index 9922a4a0edb..1bf95d96059 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -1,7 +1,7 @@ /********************************************************************** * plperl.c - perl as a procedural language for PostgreSQL * - * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.138 2008/03/25 22:42:45 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.139 2008/03/28 00:21:56 tgl Exp $ * **********************************************************************/ @@ -689,6 +689,8 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo) tupdesc)); } } + else if (TRIGGER_FIRED_BY_TRUNCATE(tdata->tg_event)) + event = "TRUNCATE"; else event = "UNKNOWN"; @@ -1395,6 +1397,8 @@ plperl_trigger_handler(PG_FUNCTION_ARGS) retval = (Datum) trigdata->tg_newtuple; else if (TRIGGER_FIRED_BY_DELETE(trigdata->tg_event)) retval = (Datum) trigdata->tg_trigtuple; + else if (TRIGGER_FIRED_BY_TRUNCATE(trigdata->tg_event)) + retval = (Datum) trigdata->tg_trigtuple; else retval = (Datum) 0; /* can this happen? */ } diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 592365cad88..931e17d26d8 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.206 2008/03/26 18:48:59 alvherre Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.207 2008/03/28 00:21:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -538,8 +538,10 @@ plpgsql_exec_trigger(PLpgSQL_function *func, var->value = CStringGetTextDatum("UPDATE"); else if (TRIGGER_FIRED_BY_DELETE(trigdata->tg_event)) var->value = CStringGetTextDatum("DELETE"); + else if (TRIGGER_FIRED_BY_TRUNCATE(trigdata->tg_event)) + var->value = CStringGetTextDatum("TRUNCATE"); else - elog(ERROR, "unrecognized trigger action: not INSERT, DELETE, or UPDATE"); + elog(ERROR, "unrecognized trigger action: not INSERT, DELETE, UPDATE, or TRUNCATE"); var->isnull = false; var->freeval = true; diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c index 20177d62e1b..130eca4f71d 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.107 2008/03/25 22:42:45 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.108 2008/03/28 00:21:56 tgl Exp $ * ********************************************************************* */ @@ -714,6 +714,8 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc, HeapTuple * pltevent = PyString_FromString("DELETE"); else if (TRIGGER_FIRED_BY_UPDATE(tdata->tg_event)) pltevent = PyString_FromString("UPDATE"); + else if (TRIGGER_FIRED_BY_TRUNCATE(tdata->tg_event)) + pltevent = PyString_FromString("TRUNCATE"); else { elog(ERROR, "unrecognized OP tg_event: %u", tdata->tg_event); diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index 508ec301bf8..5219a4127e0 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -2,7 +2,7 @@ * pltcl.c - PostgreSQL support for Tcl as * procedural language (PL) * - * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.118 2008/03/25 22:42:46 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.119 2008/03/28 00:21:56 tgl Exp $ * **********************************************************************/ @@ -824,6 +824,8 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) Tcl_DStringAppendElement(&tcl_cmd, "DELETE"); else if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event)) Tcl_DStringAppendElement(&tcl_cmd, "UPDATE"); + else if (TRIGGER_FIRED_BY_TRUNCATE(trigdata->tg_event)) + Tcl_DStringAppendElement(&tcl_cmd, "TRUNCATE"); else elog(ERROR, "unrecognized OP tg_event: %u", trigdata->tg_event); |