3131 * ENHANCEMENTS, OR MODIFICATIONS.
3232 *
3333 * IDENTIFICATION
34- * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.77 2003/09/04 15:10:10 tgl Exp $
34+ * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.78 2003/09/14 17:25:54 tgl Exp $
3535 *
3636 **********************************************************************/
3737
@@ -156,7 +156,7 @@ static Datum pltcl_func_handler(PG_FUNCTION_ARGS);
156156
157157static HeapTuple pltcl_trigger_handler (PG_FUNCTION_ARGS );
158158
159- static pltcl_proc_desc * compile_pltcl_function (Oid fn_oid ,bool is_trigger );
159+ static pltcl_proc_desc * compile_pltcl_function (Oid fn_oid ,Oid tgreloid );
160160
161161static int pltcl_elog (ClientData cdata ,Tcl_Interp * interp ,
162162int argc ,CONST84 char * argv []);
@@ -462,7 +462,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS)
462462sigjmp_buf save_restart ;
463463
464464/* Find or compile the function */
465- prodesc = compile_pltcl_function (fcinfo -> flinfo -> fn_oid ,false );
465+ prodesc = compile_pltcl_function (fcinfo -> flinfo -> fn_oid ,InvalidOid );
466466
467467if (prodesc -> lanpltrusted )
468468interp = pltcl_safe_interp ;
@@ -648,7 +648,8 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
648648sigjmp_buf save_restart ;
649649
650650/* Find or compile the function */
651- prodesc = compile_pltcl_function (fcinfo -> flinfo -> fn_oid , true);
651+ prodesc = compile_pltcl_function (fcinfo -> flinfo -> fn_oid ,
652+ RelationGetRelid (trigdata -> tg_relation ));
652653
653654if (prodesc -> lanpltrusted )
654655interp = pltcl_safe_interp ;
@@ -956,13 +957,17 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
956957
957958/**********************************************************************
958959 * compile_pltcl_function- compile (or hopefully just look up) function
960+ *
961+ * tgreloid is the OID of the relation when compiling a trigger, or zero
962+ * (InvalidOid) when compiling a plain function.
959963 **********************************************************************/
960964static pltcl_proc_desc *
961- compile_pltcl_function (Oid fn_oid ,bool is_trigger )
965+ compile_pltcl_function (Oid fn_oid ,Oid tgreloid )
962966{
967+ bool is_trigger = OidIsValid (tgreloid );
963968HeapTuple procTup ;
964969Form_pg_proc procStruct ;
965- char internal_proname [64 ];
970+ char internal_proname [128 ];
966971Tcl_HashEntry * hashent ;
967972pltcl_proc_desc * prodesc = NULL ;
968973Tcl_Interp * interp ;
@@ -986,7 +991,7 @@ compile_pltcl_function(Oid fn_oid, bool is_trigger)
986991"__PLTcl_proc_%u" ,fn_oid );
987992else
988993snprintf (internal_proname ,sizeof (internal_proname ),
989- "__PLTcl_proc_%u_trigger " ,fn_oid );
994+ "__PLTcl_proc_%u_trigger_%u " ,fn_oid , tgreloid );
990995
991996/************************************************************
992997 * Lookup the internal proc name in the hashtable