Commit c5be48f0 authored by Amit Kapila's avatar Amit Kapila

Improve FK trigger parallel-safety check added by 05c8482f.

Commit 05c8482f added special logic related to parallel-safety of FK
triggers. This is a bit of a hack and should have instead been done by
simply setting appropriate proparallel values on those trigger functions
themselves.

Suggested-by: Tom Lane
Author: Greg Nancarrow
Reviewed-by: Amit Kapila
Discussion: https://postgr.es/m/2309260.1615485644@sss.pgh.pa.us
parent b9164eab
...@@ -971,24 +971,10 @@ target_rel_trigger_max_parallel_hazard(Relation rel, ...@@ -971,24 +971,10 @@ target_rel_trigger_max_parallel_hazard(Relation rel,
*/ */
for (i = 0; i < rel->trigdesc->numtriggers; i++) for (i = 0; i < rel->trigdesc->numtriggers; i++)
{ {
int trigtype;
Oid tgfoid = rel->trigdesc->triggers[i].tgfoid; Oid tgfoid = rel->trigdesc->triggers[i].tgfoid;
if (max_parallel_hazard_test(func_parallel(tgfoid), context)) if (max_parallel_hazard_test(func_parallel(tgfoid), context))
return true; return true;
/*
* If the trigger type is RI_TRIGGER_FK, this indicates a FK exists in
* the relation, and this would result in creation of new CommandIds
* on insert/update and this isn't supported in a parallel worker (but
* is safe in the parallel leader).
*/
trigtype = RI_FKey_trigger_type(tgfoid);
if (trigtype == RI_TRIGGER_FK)
{
if (max_parallel_hazard_test(PROPARALLEL_RESTRICTED, context))
return true;
}
} }
return false; return false;
......
...@@ -53,6 +53,6 @@ ...@@ -53,6 +53,6 @@
*/ */
/* yyyymmddN */ /* yyyymmddN */
#define CATALOG_VERSION_NO 202103093 #define CATALOG_VERSION_NO 202103131
#endif #endif
...@@ -3745,11 +3745,11 @@ ...@@ -3745,11 +3745,11 @@
# Generic referential integrity constraint triggers # Generic referential integrity constraint triggers
{ oid => '1644', descr => 'referential integrity FOREIGN KEY ... REFERENCES', { oid => '1644', descr => 'referential integrity FOREIGN KEY ... REFERENCES',
proname => 'RI_FKey_check_ins', provolatile => 'v', prorettype => 'trigger', proname => 'RI_FKey_check_ins', provolatile => 'v', proparallel => 'r',
proargtypes => '', prosrc => 'RI_FKey_check_ins' }, prorettype => 'trigger', proargtypes => '', prosrc => 'RI_FKey_check_ins' },
{ oid => '1645', descr => 'referential integrity FOREIGN KEY ... REFERENCES', { oid => '1645', descr => 'referential integrity FOREIGN KEY ... REFERENCES',
proname => 'RI_FKey_check_upd', provolatile => 'v', prorettype => 'trigger', proname => 'RI_FKey_check_upd', provolatile => 'v', proparallel => 'r',
proargtypes => '', prosrc => 'RI_FKey_check_upd' }, prorettype => 'trigger', proargtypes => '', prosrc => 'RI_FKey_check_upd' },
{ oid => '1646', descr => 'referential integrity ON DELETE CASCADE', { oid => '1646', descr => 'referential integrity ON DELETE CASCADE',
proname => 'RI_FKey_cascade_del', provolatile => 'v', prorettype => 'trigger', proname => 'RI_FKey_cascade_del', provolatile => 'v', prorettype => 'trigger',
proargtypes => '', prosrc => 'RI_FKey_cascade_del' }, proargtypes => '', prosrc => 'RI_FKey_cascade_del' },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment