fix failures due to distributed update/delete plans in some tests
authorTomas Vondra <[email protected]>
Sun, 29 Jan 2017 01:37:33 +0000 (02:37 +0100)
committerTomas Vondra <[email protected]>
Sun, 29 Jan 2017 01:37:33 +0000 (02:37 +0100)
Some tests are updating multiple columns of input tables, which is
not supported by XL. So instead of failing due to this limitation,
simply replicate the whole table to test whatever was the original
intent of the test.

All the UPDATE/DELETE cases fixed by this commit were failing in
XL 9.5, so none of this should be a regression.

src/test/regress/expected/case.out
src/test/regress/expected/create_table.out
src/test/regress/expected/rowsecurity.out
src/test/regress/expected/updatable_views.out
src/test/regress/expected/update.out
src/test/regress/sql/case.sql
src/test/regress/sql/create_table.sql
src/test/regress/sql/privileges.sql
src/test/regress/sql/rowsecurity.sql
src/test/regress/sql/updatable_views.sql
src/test/regress/sql/update.sql

index 8ff5abfa05639b1231753168b6c19de4395e0838..c68158b0a743d51227d88b759b3a8a557f707454 100644 (file)
@@ -5,11 +5,11 @@
 CREATE TABLE CASE_TBL (
   i integer,
   f double precision
-);
+) DISTRIBUTE BY REPLICATION;
 CREATE TABLE CASE2_TBL (
   i integer,
   j integer
-);
+) DISTRIBUTE BY REPLICATION;
 INSERT INTO CASE_TBL VALUES (1, 10.1);
 INSERT INTO CASE_TBL VALUES (2, 20.2);
 INSERT INTO CASE_TBL VALUES (3, -30.3);
index 41ceb874e8f650f82f66ddc06b9c8b955474d61a..d0e2e4b845a3aa5aa8f17f4a3ea6bd207a0c370c 100644 (file)
@@ -150,19 +150,19 @@ CREATE TABLE aggtest (
 CREATE TABLE hash_i4_heap (
        seqno           int4,
        random          int4
-);
+) DISTRIBUTE BY REPLICATION;
 CREATE TABLE hash_name_heap (
        seqno           int4,
        random          name
-);
+) DISTRIBUTE BY REPLICATION;
 CREATE TABLE hash_txt_heap (
        seqno           int4,
        random          text
-);
+) DISTRIBUTE BY REPLICATION;
 CREATE TABLE hash_f8_heap (
        seqno           int4,
        random          float8
-);
+) DISTRIBUTE BY REPLICATION;
 -- don't include the hash_ovfl_heap stuff in the distribution
 -- the data set is too large for what it's worth
 --
index eb095302bf64ca72349abd71012a73313a857169..a82224afc9328cdbb01c82d470adb507277579f5 100644 (file)
@@ -2792,8 +2792,8 @@ ROLLBACK;
 -- Non-target relations are only subject to SELECT policies
 --
 SET SESSION AUTHORIZATION regress_rls_alice;
-CREATE TABLE r1 (a int);
-CREATE TABLE r2 (a int);
+CREATE TABLE r1 (a int) DISTRIBUTE BY REPLICATION;
+CREATE TABLE r2 (a int) DISTRIBUTE BY REPLICATION;
 INSERT INTO r1 VALUES (10), (20);
 INSERT INTO r2 VALUES (10), (20);
 GRANT ALL ON r1, r2 TO regress_rls_bob;
@@ -2834,26 +2834,30 @@ DELETE FROM r2 RETURNING *; -- Deletes nothing
 INSERT INTO r1 SELECT a + 1 FROM r2 RETURNING *; -- OK
  a  
 ----
- 21
  11
+ 21
 (2 rows)
 
 UPDATE r1 SET a = r2.a + 2 FROM r2 WHERE r1.a = r2.a RETURNING *; -- OK
-ERROR:  could not plan this distributed update
-DETAIL:  correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+ a  | a  
+----+----
+ 12 | 10
+ 22 | 20
+(2 rows)
+
 DELETE FROM r1 USING r2 WHERE r1.a = r2.a + 2 RETURNING *; -- OK
- a | a 
----+---
-(0 rows)
+ a  | a  
+----+----
+ 12 | 10
+ 22 | 20
+(2 rows)
 
 SELECT * FROM r1;
  a  
 ----
- 21
- 10
- 20
  11
-(4 rows)
+ 21
+(2 rows)
 
 SELECT * FROM r2;
  a  
@@ -2870,7 +2874,7 @@ DROP TABLE r2;
 --
 SET SESSION AUTHORIZATION regress_rls_alice;
 SET row_security = on;
-CREATE TABLE r1 (a int);
+CREATE TABLE r1 (a int) DISTRIBUTE BY REPLICATION;
 INSERT INTO r1 VALUES (10), (20);
 CREATE POLICY p1 ON r1 USING (false);
 ALTER TABLE r1 ENABLE ROW LEVEL SECURITY;
@@ -2974,7 +2978,7 @@ TABLE r2;
 DROP TABLE r2;
 DROP TABLE r1;
 -- Ensure cascaded UPDATE works
-CREATE TABLE r1 (a int PRIMARY KEY);
+CREATE TABLE r1 (a int PRIMARY KEY) DISTRIBUTE BY REPLICATION;
 CREATE TABLE r2 (a int REFERENCES r1 ON UPDATE CASCADE);
 INSERT INTO r1 VALUES (10), (20);
 INSERT INTO r2 VALUES (10), (20);
@@ -3034,7 +3038,7 @@ DROP TABLE r1;
 --
 SET SESSION AUTHORIZATION regress_rls_alice;
 SET row_security = on;
-CREATE TABLE r1 (a int);
+CREATE TABLE r1 (a int) DISTRIBUTE BY REPLICATION;
 CREATE POLICY p1 ON r1 FOR SELECT USING (a < 20);
 CREATE POLICY p2 ON r1 FOR UPDATE USING (a < 20) WITH CHECK (true);
 INSERT INTO r1 VALUES (10);
index e2502ef55aa5bb21aee03727977ec7f9337e6960..3b81b264b8bb8d8e132818a9dc3169e6eedccdb1 100644 (file)
@@ -2374,9 +2374,9 @@ DROP TABLE tx3;
 -- Test handling of vars from correlated subqueries in quals from outer
 -- security barrier views, per bug #13988
 --
-CREATE TABLE t1 (a int, b text, c int);
+CREATE TABLE t1 (a int, b text, c int) DISTRIBUTE BY REPLICATION;
 INSERT INTO t1 VALUES (1, 'one', 10);
-CREATE TABLE t2 (cc int);
+CREATE TABLE t2 (cc int) DISTRIBUTE BY REPLICATION;
 INSERT INTO t2 VALUES (10), (20);
 CREATE VIEW v1 WITH (security_barrier = true) AS
   SELECT * FROM t1 WHERE (a > 0)
index bd39c08b986d36a27e890af0eb93c7b95249a608..03d6f29735ffb9f92efcddb67ad31ba186b9711f 100644 (file)
@@ -5,11 +5,11 @@ CREATE TABLE update_test (
     a   INT DEFAULT 10,
     b   INT,
     c   TEXT
-);
+) DISTRIBUTE BY REPLICATION;
 CREATE TABLE upsert_test (
     a   INT PRIMARY KEY,
     b   TEXT
-);
+) DISTRIBUTE BY REPLICATION;
 INSERT INTO update_test VALUES (5, 10, 'foo');
 INSERT INTO update_test(b, a) VALUES (15, 10);
 SELECT * FROM update_test ORDER BY a, b, c;
index ed76878217fa8b573588c274afe7cce83e07a2da..4d29609c472a1ae6e718984a6c036e52c49f82e4 100644 (file)
@@ -6,12 +6,12 @@
 CREATE TABLE CASE_TBL (
   i integer,
   f double precision
-);
+) DISTRIBUTE BY REPLICATION;
 
 CREATE TABLE CASE2_TBL (
   i integer,
   j integer
-);
+) DISTRIBUTE BY REPLICATION;
 
 INSERT INTO CASE_TBL VALUES (1, 10.1);
 INSERT INTO CASE_TBL VALUES (2, 20.2);
index b0737aecd828771dc0d9596b15b4bc1e8a16d483..2ce9dc047c7e5e7b0a5e4f0d1213c9c3f1f70aec 100644 (file)
@@ -174,22 +174,22 @@ CREATE TABLE aggtest (
 CREATE TABLE hash_i4_heap (
        seqno           int4,
        random          int4
-);
+) DISTRIBUTE BY REPLICATION;
 
 CREATE TABLE hash_name_heap (
        seqno           int4,
        random          name
-);
+) DISTRIBUTE BY REPLICATION;
 
 CREATE TABLE hash_txt_heap (
        seqno           int4,
        random          text
-);
+) DISTRIBUTE BY REPLICATION;
 
 CREATE TABLE hash_f8_heap (
        seqno           int4,
        random          float8
-);
+) DISTRIBUTE BY REPLICATION;
 
 -- don't include the hash_ovfl_heap stuff in the distribution
 -- the data set is too large for what it's worth
index f89dfa5e5cda1dac853b3c73ac3fd00651979437..933ca0802ffe6b865e038e25298384524af9f8bb 100644 (file)
@@ -44,7 +44,7 @@ GRANT regress_group2 TO regress_user4 WITH ADMIN OPTION;
 SET SESSION AUTHORIZATION regress_user1;
 SELECT session_user, current_user;
 
-CREATE TABLE atest1 ( a int, b text );
+CREATE TABLE atest1 ( a int, b text ) DISTRIBUTE BY REPLICATION;
 SELECT * FROM atest1;
 INSERT INTO atest1 VALUES (1, 'one');
 DELETE FROM atest1;
@@ -61,7 +61,7 @@ GRANT ALL ON atest1 TO regress_user2;
 GRANT SELECT ON atest1 TO regress_user3, regress_user4;
 SELECT * FROM atest1;
 
-CREATE TABLE atest2 (col1 varchar(10), col2 boolean);
+CREATE TABLE atest2 (col1 varchar(10), col2 boolean) DISTRIBUTE BY REPLICATION;
 GRANT SELECT ON atest2 TO regress_user2;
 GRANT UPDATE ON atest2 TO regress_user3;
 GRANT INSERT ON atest2 TO regress_user4;
index 00a64ac83d04c8599b735ad7d6a280b9d8de267b..31e98db70e08970fcbb666e88e86b66dfb60e84a 100644 (file)
@@ -1291,8 +1291,8 @@ ROLLBACK;
 -- Non-target relations are only subject to SELECT policies
 --
 SET SESSION AUTHORIZATION regress_rls_alice;
-CREATE TABLE r1 (a int);
-CREATE TABLE r2 (a int);
+CREATE TABLE r1 (a int) DISTRIBUTE BY REPLICATION;
+CREATE TABLE r2 (a int) DISTRIBUTE BY REPLICATION;
 INSERT INTO r1 VALUES (10), (20);
 INSERT INTO r2 VALUES (10), (20);
 
@@ -1332,7 +1332,7 @@ DROP TABLE r2;
 --
 SET SESSION AUTHORIZATION regress_rls_alice;
 SET row_security = on;
-CREATE TABLE r1 (a int);
+CREATE TABLE r1 (a int) DISTRIBUTE BY REPLICATION;
 INSERT INTO r1 VALUES (10), (20);
 
 CREATE POLICY p1 ON r1 USING (false);
@@ -1430,7 +1430,7 @@ DROP TABLE r2;
 DROP TABLE r1;
 
 -- Ensure cascaded UPDATE works
-CREATE TABLE r1 (a int PRIMARY KEY);
+CREATE TABLE r1 (a int PRIMARY KEY) DISTRIBUTE BY REPLICATION;
 CREATE TABLE r2 (a int REFERENCES r1 ON UPDATE CASCADE);
 INSERT INTO r1 VALUES (10), (20);
 INSERT INTO r2 VALUES (10), (20);
@@ -1491,7 +1491,7 @@ DROP TABLE r1;
 --
 SET SESSION AUTHORIZATION regress_rls_alice;
 SET row_security = on;
-CREATE TABLE r1 (a int);
+CREATE TABLE r1 (a int) DISTRIBUTE BY REPLICATION;
 
 CREATE POLICY p1 ON r1 FOR SELECT USING (a < 20);
 CREATE POLICY p2 ON r1 FOR UPDATE USING (a < 20) WITH CHECK (true);
index 091373db41526d0c36049d2797e121aadb3dc9e8..8babcdfffe5bc996856e2eacce1d66021d56dd8c 100644 (file)
@@ -1069,10 +1069,10 @@ DROP TABLE tx3;
 -- Test handling of vars from correlated subqueries in quals from outer
 -- security barrier views, per bug #13988
 --
-CREATE TABLE t1 (a int, b text, c int);
+CREATE TABLE t1 (a int, b text, c int) DISTRIBUTE BY REPLICATION;
 INSERT INTO t1 VALUES (1, 'one', 10);
 
-CREATE TABLE t2 (cc int);
+CREATE TABLE t2 (cc int) DISTRIBUTE BY REPLICATION;
 INSERT INTO t2 VALUES (10), (20);
 
 CREATE VIEW v1 WITH (security_barrier = true) AS
index 6954b7c628b5d9b0a5e8c5a7646cdb5947ddf052..1f353632be50ae2e8911d5e5a89ce43c6f14f484 100644 (file)
@@ -6,12 +6,12 @@ CREATE TABLE update_test (
     a   INT DEFAULT 10,
     b   INT,
     c   TEXT
-);
+) DISTRIBUTE BY REPLICATION;
 
 CREATE TABLE upsert_test (
     a   INT PRIMARY KEY,
     b   TEXT
-);
+) DISTRIBUTE BY REPLICATION;
 
 INSERT INTO update_test VALUES (5, 10, 'foo');
 INSERT INTO update_test(b, a) VALUES (15, 10);