Improve FK trigger parallel-safety check added by 05c8482f7f.
authorAmit Kapila <[email protected]>
Sat, 13 Mar 2021 03:43:21 +0000 (09:13 +0530)
committerAmit Kapila <[email protected]>
Sat, 13 Mar 2021 03:50:52 +0000 (09:20 +0530)
Commit 05c8482f7f 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

src/backend/optimizer/util/clauses.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.dat

index 12754fdb2bac2ad2e8fed372dc4be4f2676f7402..ade66a541c821d936673263e8e51da693a194d3b 100644 (file)
@@ -971,24 +971,10 @@ target_rel_trigger_max_parallel_hazard(Relation rel,
     */
    for (i = 0; i < rel->trigdesc->numtriggers; i++)
    {
-       int         trigtype;
        Oid         tgfoid = rel->trigdesc->triggers[i].tgfoid;
 
        if (max_parallel_hazard_test(func_parallel(tgfoid), context))
            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;
index 33bb6f9672e100cff720ea555fec86ba63cfc506..609d184e81267c22df099f0e56c9c49712f6e6c5 100644 (file)
@@ -53,6 +53,6 @@
  */
 
 /*                         yyyymmddN */
-#define CATALOG_VERSION_NO 202103093
+#define CATALOG_VERSION_NO 202103131
 
 #endif
index 61361a6bc932847cf070535291a02a63b7f68416..93393fcfd4f314a6a20b4826f2d03e7f9a053e66 100644 (file)
 
 # Generic referential integrity constraint triggers
 { oid => '1644', descr => 'referential integrity FOREIGN KEY ... REFERENCES',
-  proname => 'RI_FKey_check_ins', provolatile => 'v', prorettype => 'trigger',
-  proargtypes => '', prosrc => 'RI_FKey_check_ins' },
+  proname => 'RI_FKey_check_ins', provolatile => 'v', proparallel => 'r',
+  prorettype => 'trigger', proargtypes => '', prosrc => 'RI_FKey_check_ins' },
 { oid => '1645', descr => 'referential integrity FOREIGN KEY ... REFERENCES',
-  proname => 'RI_FKey_check_upd', provolatile => 'v', prorettype => 'trigger',
-  proargtypes => '', prosrc => 'RI_FKey_check_upd' },
+  proname => 'RI_FKey_check_upd', provolatile => 'v', proparallel => 'r',
+  prorettype => 'trigger', proargtypes => '', prosrc => 'RI_FKey_check_upd' },
 { oid => '1646', descr => 'referential integrity ON DELETE CASCADE',
   proname => 'RI_FKey_cascade_del', provolatile => 'v', prorettype => 'trigger',
   proargtypes => '', prosrc => 'RI_FKey_cascade_del' },