@@ -137,7 +137,7 @@ typedef struct pltcl_query_desc
137137
138138/**********************************************************************
139139 * For speedy lookup, we maintain a hash table mapping from
140- * function OID + triggerOID + user OID to pltcl_proc_desc pointers.
140+ * function OID + triggerflag + user OID to pltcl_proc_desc pointers.
141141 * The reason the pltcl_proc_desc struct isn't directly part of the hash
142142 * entry is to simplify recovery from errors during compile_pltcl_function.
143143 *
@@ -149,7 +149,11 @@ typedef struct pltcl_query_desc
149149typedef struct pltcl_proc_key
150150{
151151Oid proc_id ;/* Function OID */
152- Oid trig_id ;/* Trigger OID, or 0 if not trigger */
152+ /*
153+ * is_trigger is really a bool, but declare as Oid to ensure this struct
154+ * contains no padding
155+ */
156+ Oid is_trigger ;/* is it a trigger function? */
153157Oid user_id ;/* User calling the function, or 0 */
154158}pltcl_proc_key ;
155159
@@ -1172,7 +1176,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid, bool pltrusted)
11721176
11731177/* Try to find function in pltcl_proc_htab */
11741178proc_key .proc_id = fn_oid ;
1175- proc_key .trig_id = tgreloid ;
1179+ proc_key .is_trigger = OidIsValid ( tgreloid ) ;
11761180proc_key .user_id = pltrusted ?GetUserId () :InvalidOid ;
11771181
11781182proc_ptr = hash_search (pltcl_proc_htab ,& proc_key ,
@@ -1228,14 +1232,16 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid, bool pltrusted)
12281232int tcl_rc ;
12291233
12301234/************************************************************
1231- * Build our internal proc name from the functions Oid + trigger Oid
1235+ * Build our internal proc name from the function's Oid. Append
1236+ * "_trigger" when appropriate to ensure the normal and trigger
1237+ * cases are kept separate.
12321238 ************************************************************/
12331239if (!is_trigger )
12341240snprintf (internal_proname ,sizeof (internal_proname ),
12351241"__PLTcl_proc_%u" ,fn_oid );
12361242else
12371243snprintf (internal_proname ,sizeof (internal_proname ),
1238- "__PLTcl_proc_%u_trigger_%u " ,fn_oid , tgreloid );
1244+ "__PLTcl_proc_%u_trigger " ,fn_oid );
12391245
12401246/************************************************************
12411247 * Allocate a new procedure description block