Do not add any distribution to a dummy append node
authorPavan Deolasee <[email protected]>
Mon, 28 Aug 2017 10:03:47 +0000 (15:33 +0530)
committerPavan Deolasee <[email protected]>
Mon, 28 Aug 2017 11:07:51 +0000 (16:37 +0530)
A dummy append node with no subpaths doesn't need any adjustment for
distribution. This allows us to actually correct handle UPDATE/DELETE in some
cases which were failing earlier.

src/backend/optimizer/plan/planner.c
src/test/regress/expected/rowsecurity.out
src/test/regress/expected/rules.out

index ee6c50d7c069087125b8646b8897c03094f652cd..cc4b06a292b6b1f3d982b5c64c57b7fc4d5e855e 100644 (file)
@@ -6918,6 +6918,9 @@ adjust_path_distribution(PlannerInfo *root, Query *parse, Path *path)
        if ((path->distribution == NULL) && (root->distribution == NULL))
                return path;
 
+       if (IS_DUMMY_PATH(path))
+               return path;
+
        if (equal_distributions(root, root->distribution, path->distribution))
        {
                if (IsLocatorReplicated(path->distribution->distributionType) &&
index 000af55572ed11f91bc9d05d4d7a65aaaa8005cf..6a6492f3fb98b18fea0d0db4edec5c3e49944f65 100644 (file)
@@ -3344,13 +3344,12 @@ UPDATE r2 SET a = 2 RETURNING *; -- Updates nothing
 ---
 (0 rows)
 
-UPDATE 0
 DELETE FROM r2 RETURNING *; -- Deletes nothing
  a 
 ---
 (0 rows)
 
-DELETE 0
+-- r2 can be used as a non-target relation in DML
 INSERT INTO r1 SELECT a + 1 FROM r2 RETURNING *; -- OK
  a  
 ----
@@ -3410,8 +3409,6 @@ INSERT INTO r1 VALUES (1);
 ERROR:  new row violates row-level security policy for table "r1"
 -- No error (unable to see any rows to update)
 UPDATE r1 SET a = 1;
-ERROR:  could not plan this distributed update
-DETAIL:  correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
 TABLE r1;
  a 
 ---
index 499ffb31cdaf32593f5b89f5b0ea5850c6da2527..8cc84adc8bc401e85bafe627728b8eef975cf77f 100644 (file)
@@ -2676,8 +2676,6 @@ create rule t1_upd_2 as on update to t1
 set constraint_exclusion = on;
 insert into t1 select * from generate_series(5,19,1) g;
 update t1 set a = 4 where a = 5;
-ERROR:  could not plan this distributed update
-DETAIL:  correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
 select * from only t1 order by 1;
  a 
 ---
@@ -2686,7 +2684,7 @@ select * from only t1 order by 1;
 select * from only t1_1 order by 1;
  a 
 ---
- 5
+ 4
  6
  7
  8