Skip to content

Commit c5be48f

Browse files
author
Amit Kapila
committed
Improve FK trigger parallel-safety check added by 05c8482.
Commit 05c8482 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
1 parent b9164ea commit c5be48f

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

src/backend/optimizer/util/clauses.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -971,24 +971,10 @@ target_rel_trigger_max_parallel_hazard(Relation rel,
971971
*/
972972
for (i = 0; i < rel->trigdesc->numtriggers; i++)
973973
{
974-
int trigtype;
975974
Oid tgfoid = rel->trigdesc->triggers[i].tgfoid;
976975

977976
if (max_parallel_hazard_test(func_parallel(tgfoid), context))
978977
return true;
979-
980-
/*
981-
* If the trigger type is RI_TRIGGER_FK, this indicates a FK exists in
982-
* the relation, and this would result in creation of new CommandIds
983-
* on insert/update and this isn't supported in a parallel worker (but
984-
* is safe in the parallel leader).
985-
*/
986-
trigtype = RI_FKey_trigger_type(tgfoid);
987-
if (trigtype == RI_TRIGGER_FK)
988-
{
989-
if (max_parallel_hazard_test(PROPARALLEL_RESTRICTED, context))
990-
return true;
991-
}
992978
}
993979

994980
return false;

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 202103093
56+
#define CATALOG_VERSION_NO 202103131
5757

5858
#endif

src/include/catalog/pg_proc.dat

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3745,11 +3745,11 @@
37453745

37463746
# Generic referential integrity constraint triggers
37473747
{ oid => '1644', descr => 'referential integrity FOREIGN KEY ... REFERENCES',
3748-
proname => 'RI_FKey_check_ins', provolatile => 'v', prorettype => 'trigger',
3749-
proargtypes => '', prosrc => 'RI_FKey_check_ins' },
3748+
proname => 'RI_FKey_check_ins', provolatile => 'v', proparallel => 'r',
3749+
prorettype => 'trigger', proargtypes => '', prosrc => 'RI_FKey_check_ins' },
37503750
{ oid => '1645', descr => 'referential integrity FOREIGN KEY ... REFERENCES',
3751-
proname => 'RI_FKey_check_upd', provolatile => 'v', prorettype => 'trigger',
3752-
proargtypes => '', prosrc => 'RI_FKey_check_upd' },
3751+
proname => 'RI_FKey_check_upd', provolatile => 'v', proparallel => 'r',
3752+
prorettype => 'trigger', proargtypes => '', prosrc => 'RI_FKey_check_upd' },
37533753
{ oid => '1646', descr => 'referential integrity ON DELETE CASCADE',
37543754
proname => 'RI_FKey_cascade_del', provolatile => 'v', prorettype => 'trigger',
37553755
proargtypes => '', prosrc => 'RI_FKey_cascade_del' },

0 commit comments

Comments
 (0)