From: Tomas Vondra Date: Sun, 29 Jan 2017 01:37:33 +0000 (+0100) Subject: fix failures due to distributed update/delete plans in some tests X-Git-Tag: XL_10_R1BETA1~393 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=8a329ead886cca01ccda290d90cbaf9a41b9ede3;p=postgres-xl.git fix failures due to distributed update/delete plans in some tests 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. --- diff --git a/src/test/regress/expected/case.out b/src/test/regress/expected/case.out index 8ff5abfa05..c68158b0a7 100644 --- a/src/test/regress/expected/case.out +++ b/src/test/regress/expected/case.out @@ -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); diff --git a/src/test/regress/expected/create_table.out b/src/test/regress/expected/create_table.out index 41ceb874e8..d0e2e4b845 100644 --- a/src/test/regress/expected/create_table.out +++ b/src/test/regress/expected/create_table.out @@ -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 -- diff --git a/src/test/regress/expected/rowsecurity.out b/src/test/regress/expected/rowsecurity.out index eb095302bf..a82224afc9 100644 --- a/src/test/regress/expected/rowsecurity.out +++ b/src/test/regress/expected/rowsecurity.out @@ -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); diff --git a/src/test/regress/expected/updatable_views.out b/src/test/regress/expected/updatable_views.out index e2502ef55a..3b81b264b8 100644 --- a/src/test/regress/expected/updatable_views.out +++ b/src/test/regress/expected/updatable_views.out @@ -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) diff --git a/src/test/regress/expected/update.out b/src/test/regress/expected/update.out index bd39c08b98..03d6f29735 100644 --- a/src/test/regress/expected/update.out +++ b/src/test/regress/expected/update.out @@ -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; diff --git a/src/test/regress/sql/case.sql b/src/test/regress/sql/case.sql index ed76878217..4d29609c47 100644 --- a/src/test/regress/sql/case.sql +++ b/src/test/regress/sql/case.sql @@ -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); diff --git a/src/test/regress/sql/create_table.sql b/src/test/regress/sql/create_table.sql index b0737aecd8..2ce9dc047c 100644 --- a/src/test/regress/sql/create_table.sql +++ b/src/test/regress/sql/create_table.sql @@ -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 diff --git a/src/test/regress/sql/privileges.sql b/src/test/regress/sql/privileges.sql index f89dfa5e5c..933ca0802f 100644 --- a/src/test/regress/sql/privileges.sql +++ b/src/test/regress/sql/privileges.sql @@ -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; diff --git a/src/test/regress/sql/rowsecurity.sql b/src/test/regress/sql/rowsecurity.sql index 00a64ac83d..31e98db70e 100644 --- a/src/test/regress/sql/rowsecurity.sql +++ b/src/test/regress/sql/rowsecurity.sql @@ -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); diff --git a/src/test/regress/sql/updatable_views.sql b/src/test/regress/sql/updatable_views.sql index 091373db41..8babcdfffe 100644 --- a/src/test/regress/sql/updatable_views.sql +++ b/src/test/regress/sql/updatable_views.sql @@ -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 diff --git a/src/test/regress/sql/update.sql b/src/test/regress/sql/update.sql index 6954b7c628..1f353632be 100644 --- a/src/test/regress/sql/update.sql +++ b/src/test/regress/sql/update.sql @@ -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);