@@ -137,7 +137,7 @@ typedef struct pltcl_query_desc
137
137
138
138
/**********************************************************************
139
139
* For speedy lookup, we maintain a hash table mapping from
140
- * function OID + trigger OID + user OID to pltcl_proc_desc pointers.
140
+ * function OID + trigger flag + user OID to pltcl_proc_desc pointers.
141
141
* The reason the pltcl_proc_desc struct isn't directly part of the hash
142
142
* entry is to simplify recovery from errors during compile_pltcl_function.
143
143
*
@@ -149,7 +149,11 @@ typedef struct pltcl_query_desc
149
149
typedef struct pltcl_proc_key
150
150
{
151
151
Oid 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? */
153
157
Oid user_id ; /* User calling the function, or 0 */
154
158
} pltcl_proc_key ;
155
159
@@ -1172,7 +1176,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid, bool pltrusted)
1172
1176
1173
1177
/* Try to find function in pltcl_proc_htab */
1174
1178
proc_key .proc_id = fn_oid ;
1175
- proc_key .trig_id = tgreloid ;
1179
+ proc_key .is_trigger = OidIsValid ( tgreloid ) ;
1176
1180
proc_key .user_id = pltrusted ? GetUserId () : InvalidOid ;
1177
1181
1178
1182
proc_ptr = hash_search (pltcl_proc_htab , & proc_key ,
@@ -1228,14 +1232,16 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid, bool pltrusted)
1228
1232
int tcl_rc ;
1229
1233
1230
1234
/************************************************************
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.
1232
1238
************************************************************/
1233
1239
if (!is_trigger )
1234
1240
snprintf (internal_proname , sizeof (internal_proname ),
1235
1241
"__PLTcl_proc_%u" , fn_oid );
1236
1242
else
1237
1243
snprintf (internal_proname , sizeof (internal_proname ),
1238
- "__PLTcl_proc_%u_trigger_%u " , fn_oid , tgreloid );
1244
+ "__PLTcl_proc_%u_trigger " , fn_oid );
1239
1245
1240
1246
/************************************************************
1241
1247
* Allocate a new procedure description block
0 commit comments