diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-05-29 01:59:17 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-05-29 01:59:17 +0000 |
| commit | 18952f67446da73f938d213b5225b99e95657837 (patch) | |
| tree | 7ad26843000b8a17e798dafacbd29baf2d390fa1 /src/pl | |
| parent | 147ccf5c8045c79a9c8194044359e140c9074ed7 (diff) | |
| download | postgresql-18952f67446da73f938d213b5225b99e95657837.tar.gz | |
Second round of fmgr changes: triggers are now invoked in new style,
CurrentTriggerData is history.
Diffstat (limited to 'src/pl')
| -rw-r--r-- | src/pl/plperl/plperl.c | 18 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/pl_handler.c | 18 | ||||
| -rw-r--r-- | src/pl/tcl/pltcl.c | 16 |
3 files changed, 15 insertions, 37 deletions
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index b440be12de..278a5709ef 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -33,7 +33,7 @@ * ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.7 2000/05/28 17:56:26 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.8 2000/05/29 01:59:13 tgl Exp $ * **********************************************************************/ @@ -283,18 +283,18 @@ plperl_call_handler(PG_FUNCTION_ARGS) * Determine if called as function or trigger and * call appropriate subhandler ************************************************************/ - if (CurrentTriggerData == NULL) - retval = plperl_func_handler(fcinfo); - else + if (CALLED_AS_TRIGGER(fcinfo)) { elog(ERROR, "plperl: can't use perl in triggers yet."); /* - * retval = (Datum) plperl_trigger_handler(fcinfo); + * retval = PointerGetDatum(plperl_trigger_handler(fcinfo)); */ /* make the compiler happy */ retval = (Datum) 0; } + else + retval = plperl_func_handler(fcinfo); plperl_call_level--; @@ -687,7 +687,7 @@ plperl_func_handler(PG_FUNCTION_ARGS) static HeapTuple plperl_trigger_handler(PG_FUNCTION_ARGS) { - TriggerData *trigdata; + TriggerData *trigdata = (TriggerData *) fcinfo->context; char internal_proname[512]; char *stroid; Tcl_HashEntry *hashent; @@ -711,12 +711,6 @@ plperl_trigger_handler(PG_FUNCTION_ARGS) sigjmp_buf save_restart; /************************************************************ - * Save the current trigger data local - ************************************************************/ - trigdata = CurrentTriggerData; - CurrentTriggerData = NULL; - - /************************************************************ * Build our internal proc name from the functions Oid ************************************************************/ sprintf(internal_proname, "__PLPerl_proc_%u", fcinfo->flinfo->fn_oid); diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c index 54ecb1f4e8..31788b0706 100644 --- a/src/pl/plpgsql/src/pl_handler.c +++ b/src/pl/plpgsql/src/pl_handler.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.4 2000/05/28 17:56:28 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.5 2000/05/29 01:59:14 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -69,22 +69,11 @@ static PLpgSQL_function *compiled_functions = NULL; Datum plpgsql_call_handler(PG_FUNCTION_ARGS) { - TriggerData *trigdata; - bool isTrigger; + bool isTrigger = CALLED_AS_TRIGGER(fcinfo); PLpgSQL_function *func; Datum retval; /* ---------- - * Save the current trigger data local - * - * XXX this should go away in favor of using fcinfo->context - * ---------- - */ - trigdata = CurrentTriggerData; - CurrentTriggerData = NULL; - isTrigger = (trigdata != NULL); - - /* ---------- * Connect to SPI manager * ---------- */ @@ -136,7 +125,8 @@ plpgsql_call_handler(PG_FUNCTION_ARGS) * ---------- */ if (isTrigger) - retval = PointerGetDatum(plpgsql_exec_trigger(func, trigdata)); + retval = PointerGetDatum(plpgsql_exec_trigger(func, + (TriggerData *) fcinfo->context)); else retval = plpgsql_exec_function(func, fcinfo); diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index c968471ed9..201bbdf092 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -31,7 +31,7 @@ * ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.23 2000/05/28 17:56:29 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.24 2000/05/29 01:59:15 tgl Exp $ * **********************************************************************/ @@ -390,10 +390,10 @@ pltcl_call_handler(PG_FUNCTION_ARGS) * Determine if called as function or trigger and * call appropriate subhandler ************************************************************/ - if (CurrentTriggerData == NULL) - retval = pltcl_func_handler(fcinfo); + if (CALLED_AS_TRIGGER(fcinfo)) + retval = PointerGetDatum(pltcl_trigger_handler(fcinfo)); else - retval = (Datum) pltcl_trigger_handler(fcinfo); + retval = pltcl_func_handler(fcinfo); pltcl_call_level--; @@ -734,7 +734,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS) static HeapTuple pltcl_trigger_handler(PG_FUNCTION_ARGS) { - TriggerData *trigdata; + TriggerData *trigdata = (TriggerData *) fcinfo->context; char internal_proname[512]; char *stroid; Tcl_HashEntry *hashent; @@ -758,12 +758,6 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) sigjmp_buf save_restart; /************************************************************ - * Save the current trigger data local - ************************************************************/ - trigdata = CurrentTriggerData; - CurrentTriggerData = NULL; - - /************************************************************ * Build our internal proc name from the functions Oid ************************************************************/ sprintf(internal_proname, "__PLTcl_proc_%u", fcinfo->flinfo->fn_oid); |
