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

Commite2cda3c

Browse files
author
Amit Kapila
committed
Fix use of relcache TriggerDesc field introduced by commit05c8482.
The commit added code which used a relcache TriggerDesc field acrossanother cache access, which it shouldn't because the relcache doesn'tguarantee it won't get moved.Diagnosed-by: Tom LaneAuthor: Greg NancarrowReviewed-by: Hou Zhijie, Amit KapilaDiscussion:https://postgr.es/m/2309260.1615485644@sss.pgh.pa.us
1 parent57dcc2e commite2cda3c

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

‎src/backend/optimizer/util/clauses.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static bool target_rel_max_parallel_hazard(max_parallel_hazard_context *context)
114114
staticbooltarget_rel_max_parallel_hazard_recurse(Relationrelation,
115115
CmdTypecommand_type,
116116
max_parallel_hazard_context*context);
117-
staticbooltarget_rel_trigger_max_parallel_hazard(TriggerDesc*trigdesc,
117+
staticbooltarget_rel_trigger_max_parallel_hazard(Relationrel,
118118
max_parallel_hazard_context*context);
119119
staticbooltarget_rel_index_max_parallel_hazard(Relationrel,
120120
max_parallel_hazard_context*context);
@@ -926,7 +926,7 @@ target_rel_max_parallel_hazard_recurse(Relation rel,
926926
/*
927927
* If any triggers exist, check that they are parallel-safe.
928928
*/
929-
if (target_rel_trigger_max_parallel_hazard(rel->trigdesc,context))
929+
if (target_rel_trigger_max_parallel_hazard(rel,context))
930930
return true;
931931

932932
/*
@@ -952,23 +952,29 @@ target_rel_max_parallel_hazard_recurse(Relation rel,
952952
/*
953953
* target_rel_trigger_max_parallel_hazard
954954
*
955-
* Finds the maximum parallel-mode hazard level for the specified trigger data.
955+
* Finds the maximum parallel-mode hazard level for the specified relation's
956+
* trigger data.
956957
*/
957958
staticbool
958-
target_rel_trigger_max_parallel_hazard(TriggerDesc*trigdesc,
959+
target_rel_trigger_max_parallel_hazard(Relationrel,
959960
max_parallel_hazard_context*context)
960961
{
961962
inti;
962963

963-
if (trigdesc==NULL)
964+
if (rel->trigdesc==NULL)
964965
return false;
965966

966-
for (i=0;i<trigdesc->numtriggers;i++)
967+
/*
968+
* Care is needed here to avoid using the same relcache TriggerDesc field
969+
* across other cache accesses, because relcache doesn't guarantee that it
970+
* won't move.
971+
*/
972+
for (i=0;i<rel->trigdesc->numtriggers;i++)
967973
{
968974
inttrigtype;
969-
Trigger*trigger=&trigdesc->triggers[i];
975+
Oidtgfoid=rel->trigdesc->triggers[i].tgfoid;
970976

971-
if (max_parallel_hazard_test(func_parallel(trigger->tgfoid),context))
977+
if (max_parallel_hazard_test(func_parallel(tgfoid),context))
972978
return true;
973979

974980
/*
@@ -977,7 +983,7 @@ target_rel_trigger_max_parallel_hazard(TriggerDesc *trigdesc,
977983
* on insert/update and this isn't supported in a parallel worker (but
978984
* is safe in the parallel leader).
979985
*/
980-
trigtype=RI_FKey_trigger_type(trigger->tgfoid);
986+
trigtype=RI_FKey_trigger_type(tgfoid);
981987
if (trigtype==RI_TRIGGER_FK)
982988
{
983989
if (max_parallel_hazard_test(PROPARALLEL_RESTRICTED,context))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp