Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit70a0160

Browse files
committed
Use only one hash entry for all instances of a pltcl trigger function.
Like plperl and unlike plpgsql, there isn't any cached state that coulddepend on exactly which relation the trigger is being fired for. So wecan use just one hash entry for all relations, which might save a littlesomething.Alex Hunsaker
1 parentdd21f0b commit70a0160

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

‎src/pl/tcl/pltcl.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
149149
typedefstructpltcl_proc_key
150150
{
151151
Oidproc_id;/* Function OID */
152-
Oidtrig_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+
Oidis_trigger;/* is it a trigger function? */
153157
Oiduser_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 */
11741178
proc_key.proc_id=fn_oid;
1175-
proc_key.trig_id=tgreloid;
1179+
proc_key.is_trigger=OidIsValid(tgreloid);
11761180
proc_key.user_id=pltrusted ?GetUserId() :InvalidOid;
11771181

11781182
proc_ptr=hash_search(pltcl_proc_htab,&proc_key,
@@ -1228,14 +1232,16 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid, bool pltrusted)
12281232
inttcl_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
************************************************************/
12331239
if (!is_trigger)
12341240
snprintf(internal_proname,sizeof(internal_proname),
12351241
"__PLTcl_proc_%u",fn_oid);
12361242
else
12371243
snprintf(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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp