@@ -114,7 +114,7 @@ static bool target_rel_max_parallel_hazard(max_parallel_hazard_context *context)
114
114
static bool target_rel_max_parallel_hazard_recurse (Relation relation ,
115
115
CmdType command_type ,
116
116
max_parallel_hazard_context * context );
117
- static bool target_rel_trigger_max_parallel_hazard (TriggerDesc * trigdesc ,
117
+ static bool target_rel_trigger_max_parallel_hazard (Relation rel ,
118
118
max_parallel_hazard_context * context );
119
119
static bool target_rel_index_max_parallel_hazard (Relation rel ,
120
120
max_parallel_hazard_context * context );
@@ -926,7 +926,7 @@ target_rel_max_parallel_hazard_recurse(Relation rel,
926
926
/*
927
927
* If any triggers exist, check that they are parallel-safe.
928
928
*/
929
- if (target_rel_trigger_max_parallel_hazard (rel -> trigdesc , context ))
929
+ if (target_rel_trigger_max_parallel_hazard (rel , context ))
930
930
return true;
931
931
932
932
/*
@@ -952,23 +952,29 @@ target_rel_max_parallel_hazard_recurse(Relation rel,
952
952
/*
953
953
* target_rel_trigger_max_parallel_hazard
954
954
*
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.
956
957
*/
957
958
static bool
958
- target_rel_trigger_max_parallel_hazard (TriggerDesc * trigdesc ,
959
+ target_rel_trigger_max_parallel_hazard (Relation rel ,
959
960
max_parallel_hazard_context * context )
960
961
{
961
962
int i ;
962
963
963
- if (trigdesc == NULL )
964
+ if (rel -> trigdesc == NULL )
964
965
return false;
965
966
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 ++ )
967
973
{
968
974
int trigtype ;
969
- Trigger * trigger = & trigdesc -> triggers [i ];
975
+ Oid tgfoid = rel -> trigdesc -> triggers [i ]. tgfoid ;
970
976
971
- if (max_parallel_hazard_test (func_parallel (trigger -> tgfoid ), context ))
977
+ if (max_parallel_hazard_test (func_parallel (tgfoid ), context ))
972
978
return true;
973
979
974
980
/*
@@ -977,7 +983,7 @@ target_rel_trigger_max_parallel_hazard(TriggerDesc *trigdesc,
977
983
* on insert/update and this isn't supported in a parallel worker (but
978
984
* is safe in the parallel leader).
979
985
*/
980
- trigtype = RI_FKey_trigger_type (trigger -> tgfoid );
986
+ trigtype = RI_FKey_trigger_type (tgfoid );
981
987
if (trigtype == RI_TRIGGER_FK )
982
988
{
983
989
if (max_parallel_hazard_test (PROPARALLEL_RESTRICTED , context ))
0 commit comments