* ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.77 2003/09/04 15:10:10 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.78 2003/09/14 17:25:54 tgl Exp $
*
**********************************************************************/
static HeapTuple pltcl_trigger_handler(PG_FUNCTION_ARGS);
-static pltcl_proc_desc *compile_pltcl_function(Oid fn_oid, bool is_trigger);
+static pltcl_proc_desc *compile_pltcl_function(Oid fn_oid, Oid tgreloid);
static int pltcl_elog(ClientData cdata, Tcl_Interp *interp,
int argc, CONST84 char *argv[]);
sigjmp_buf save_restart;
/* Find or compile the function */
- prodesc = compile_pltcl_function(fcinfo->flinfo->fn_oid, false);
+ prodesc = compile_pltcl_function(fcinfo->flinfo->fn_oid, InvalidOid);
if (prodesc->lanpltrusted)
interp = pltcl_safe_interp;
sigjmp_buf save_restart;
/* Find or compile the function */
- prodesc = compile_pltcl_function(fcinfo->flinfo->fn_oid, true);
+ prodesc = compile_pltcl_function(fcinfo->flinfo->fn_oid,
+ RelationGetRelid(trigdata->tg_relation));
if (prodesc->lanpltrusted)
interp = pltcl_safe_interp;
/**********************************************************************
* compile_pltcl_function - compile (or hopefully just look up) function
+ *
+ * tgreloid is the OID of the relation when compiling a trigger, or zero
+ * (InvalidOid) when compiling a plain function.
**********************************************************************/
static pltcl_proc_desc *
-compile_pltcl_function(Oid fn_oid, bool is_trigger)
+compile_pltcl_function(Oid fn_oid, Oid tgreloid)
{
+ bool is_trigger = OidIsValid(tgreloid);
HeapTuple procTup;
Form_pg_proc procStruct;
- char internal_proname[64];
+ char internal_proname[128];
Tcl_HashEntry *hashent;
pltcl_proc_desc *prodesc = NULL;
Tcl_Interp *interp;
"__PLTcl_proc_%u", fn_oid);
else
snprintf(internal_proname, sizeof(internal_proname),
- "__PLTcl_proc_%u_trigger", fn_oid);
+ "__PLTcl_proc_%u_trigger_%u", fn_oid, tgreloid);
/************************************************************
* Lookup the internal proc name in the hashtable