More thorough checks for distribution columns while creating inheritance
authorPavan Deolasee <[email protected]>
Tue, 8 Aug 2017 04:43:16 +0000 (10:13 +0530)
committerPavan Deolasee <[email protected]>
Tue, 8 Aug 2017 04:59:49 +0000 (10:29 +0530)
We now also do checks during CREATE TABLE. Also amend alter_table test case so
that a few tables are distributed using round robin method so that the new
checks/limitations don't come in their way. Also new test cases added to ensure
that the other checks for inheritance are exercised too.

src/backend/commands/tablecmds.c
src/test/regress/expected/alter_table.out
src/test/regress/expected/inherit.out
src/test/regress/expected/privileges.out
src/test/regress/sql/alter_table.sql
src/test/regress/sql/inherit.sql
src/test/regress/sql/privileges.sql

index 16654331451d3a6e773cbc39b7869cd88c7b204b..8f2fc554ea3e933f3150a0ff08d6674dceadceed 100644 (file)
@@ -781,7 +781,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
         */
        CommandCounterIncrement();
 
-#ifdef PGXC
        /*
         * Add to pgxc_class.
         * we need to do this after CommandCounterIncrement
@@ -807,7 +806,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
                /* Make sure locator info gets rebuilt */
                RelationCacheInvalidateEntry(relationId);
        }
-#endif
+
        /*
         * Open the new relation and acquire exclusive lock on it.  This isn't
         * really necessary for locking out other backends (since they can't see
@@ -816,6 +815,26 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
         */
        rel = relation_open(relationId, AccessExclusiveLock);
 
+       /*
+        * If we are inheriting from more than one parent, ensure that the
+        * distribution strategy of the child table and each of the parent table
+        * satisfies various limitations imposed by XL. Any violation will be
+        * reported as ERROR by MergeDistributionIntoExisting.
+        */
+       if (IS_PGXC_COORDINATOR && list_length(inheritOids) > 1)
+       {
+               ListCell   *entry;
+               foreach(entry, inheritOids)
+               {
+                       Oid                     parentOid = lfirst_oid(entry);
+                       Relation        parent_rel = heap_open(parentOid, ShareUpdateExclusiveLock);
+
+                       MergeDistributionIntoExisting(rel, parent_rel);
+                       heap_close(parent_rel, NoLock);
+               }
+       }
+
+
        /* Process and store partition bound, if any. */
        if (stmt->partbound)
        {
@@ -11747,7 +11766,20 @@ MergeDistributionIntoExisting(Relation child_rel, Relation parent_rel)
                                errdetail("Distribution type for the child must be same as the parent")));
 
 
-       /* Same attribute number? */
+       /*
+        * Same attribute number?
+        *
+        * For table distributed by roundrobin or replication, the partAttrNum will
+        * be -1 and inheritance is allowed for tables distributed by roundrobin or
+        * replication, as long as the distribution type matches (i.e. all tables
+        * are either roundrobin or all tables are replicated).
+        *
+        * Tables distributed by roundrobin or replication do not have partAttrName
+        * set. We should have checked for distribution type above. So if the
+        * partAttrNum does not match below, we must be dealing with either modulo
+        * or hash distributed tables and partAttrName must be set in both the
+        * cases.
+        */
        if (parent_locinfo->partAttrNum != child_locinfo->partAttrNum)
                ereport(ERROR,
                                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -11759,6 +11791,24 @@ MergeDistributionIntoExisting(Relation child_rel, Relation parent_rel)
                                        parent_locinfo->partAttrName),
                                errdetail("Distribution column for the child must be same as the parent")));
 
+       /*
+        * Same attribute name? partAttrName could be NULL if we are dealing with
+        * roundrobin or replicated tables. So check for that.
+        */
+       if (parent_locinfo->partAttrName &&
+               child_locinfo->partAttrName &&
+               strcmp(parent_locinfo->partAttrName, child_locinfo->partAttrName) != 0)
+               ereport(ERROR,
+                               (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+                               errmsg("table \"%s\" is distributed on column \"%s\", but the "
+                                       "parent table \"%s\" is distributed on column \"%s\"",
+                                       RelationGetRelationName(child_rel),
+                                       child_locinfo->partAttrName,
+                                       RelationGetRelationName(parent_rel),
+                                       parent_locinfo->partAttrName),
+                               errdetail("Distribution column for the child must be same as the parent")));
+
+
        /* Same node list? */
        if (list_difference_int(nodeList1, nodeList2) != NIL ||
                list_difference_int(nodeList2, nodeList1) != NIL)
index 7763dc2a02e77155558771652d34fa732c9a8bc1..319264f454fb0902f03d289c9683c5e09abae58f 100644 (file)
@@ -709,8 +709,8 @@ ERROR:  new row for relation "atacc1" violates check constraint "atacc1_check"
 DETAIL:  Failing row contains (4, 3).
 drop table atacc1;
 -- inheritance related tests
-create table atacc1 (test int);
-create table atacc2 (test2 int);
+create table atacc1 (test int) distribute by roundrobin;
+create table atacc2 (test2 int) distribute by roundrobin;
 create table atacc3 (test3 int) inherits (atacc1, atacc2);
 alter table atacc2 add constraint foo check (test2>0);
 -- fail and then succeed on atacc2
@@ -726,9 +726,25 @@ insert into atacc3 (test2) values (3);
 drop table atacc3;
 drop table atacc2;
 drop table atacc1;
--- same things with one created with INHERIT
 create table atacc1 (test int);
-create table atacc2 (test2 int);
+create table atacc2 (test int);
+-- fail due to missing constraint
+alter table atacc1 add constraint foo check (test>0);
+alter table atacc2 inherit atacc1;
+ERROR:  child table is missing constraint "foo"
+-- fail due to not-matching constraint
+alter table atacc2 add constraint foo check (test>10);
+alter table atacc2 inherit atacc1;
+ERROR:  child table "atacc2" has different definition for check constraint "foo"
+-- succeed
+alter table atacc2 drop constraint foo;
+alter table atacc2 add constraint foo check (test>0);
+alter table atacc2 inherit atacc1;
+drop table atacc1 cascade;
+NOTICE:  drop cascades to table atacc2
+-- same things with one created with INHERIT
+create table atacc1 (test int) distribute by roundrobin;
+create table atacc2 (test2 int) distribute by roundrobin;
 create table atacc3 (test3 int) inherits (atacc1, atacc2);
 alter table atacc3 no inherit atacc2;
 -- fail
@@ -741,10 +757,6 @@ select test2 from atacc2;
 -------
 (0 rows)
 
--- fail due to missing constraint
-alter table atacc2 add constraint foo check (test2>0);
-alter table atacc3 inherit atacc2;
-ERROR:  child table is missing constraint "foo"
 -- fail due to missing column
 alter table atacc3 rename test2 to testx;
 alter table atacc3 inherit atacc2;
@@ -758,26 +770,32 @@ alter table atacc3 drop test2;
 alter table atacc3 add test2 int;
 update atacc3 set test2 = 4 where test2 is null;
 alter table atacc3 add constraint foo check (test2>0);
+-- XXX fails in XL because of column position mismatch
 alter table atacc3 inherit atacc2;
+ERROR:  table "atacc3" contains column "test2" at position 5, but parent "atacc2" has it at position 1
+DETAIL:  Postgres-XL requires attribute positions to match
+HINT:  Check for column ordering and dropped columns, if any
 -- fail due to duplicates and circular inheritance
 alter table atacc3 inherit atacc2;
-ERROR:  relation "atacc2" would be inherited from more than once
+ERROR:  table "atacc3" contains column "test2" at position 5, but parent "atacc2" has it at position 1
+DETAIL:  Postgres-XL requires attribute positions to match
+HINT:  Check for column ordering and dropped columns, if any
 alter table atacc2 inherit atacc3;
-ERROR:  circular inheritance not allowed
-DETAIL:  "atacc3" is already a child of "atacc2".
+ERROR:  child table is missing column "test"
 alter table atacc2 inherit atacc2;
 ERROR:  circular inheritance not allowed
 DETAIL:  "atacc2" is already a child of "atacc2".
 -- test that we really are a child now (should see 4 not 3 and cascade should go through)
+-- XXX fails in XL because the previous alter table failed
 select test2 from atacc2;
  test2 
 -------
-     4
-(1 row)
+(0 rows)
 
 drop table atacc2 cascade;
+-- XXX needs a cascade drop in XL because atacc3 is still a child of atacc1
+drop table atacc1 cascade;
 NOTICE:  drop cascades to table atacc3
-drop table atacc1;
 -- adding only to a parent is allowed as of 9.2
 create table atacc1 (test int);
 create table atacc2 (test2 int) inherits (atacc1);
@@ -1563,8 +1581,8 @@ alter table only p1 drop column f1;
 alter table c1 drop column f1;
 drop table p1 cascade;
 NOTICE:  drop cascades to table c1
-create table p1(id int, name text);
-create table p2(id2 int, name text, height int);
+create table p1(id int, name text) distribute by roundrobin;
+create table p2(id2 int, name text, height int) distribute by roundrobin;
 create table c1(age int) inherits(p1,p2);
 NOTICE:  merging multiple inherited definitions of column "name"
 create table gc1() inherits (c1);
@@ -2140,7 +2158,13 @@ CREATE TABLE test_type_diff2_c1 (int_four int4, int_eight int8, int_two int2);
 CREATE TABLE test_type_diff2_c2 (int_eight int8, int_two int2, int_four int4);
 CREATE TABLE test_type_diff2_c3 (int_two int2, int_four int4, int_eight int8);
 ALTER TABLE test_type_diff2_c1 INHERIT test_type_diff2;
+ERROR:  table "test_type_diff2_c1" contains column "int_two" at position 3, but parent "test_type_diff2" has it at position 1
+DETAIL:  Postgres-XL requires attribute positions to match
+HINT:  Check for column ordering and dropped columns, if any
 ALTER TABLE test_type_diff2_c2 INHERIT test_type_diff2;
+ERROR:  table "test_type_diff2_c2" contains column "int_two" at position 2, but parent "test_type_diff2" has it at position 1
+DETAIL:  Postgres-XL requires attribute positions to match
+HINT:  Check for column ordering and dropped columns, if any
 ALTER TABLE test_type_diff2_c3 INHERIT test_type_diff2;
 INSERT INTO test_type_diff2_c1 VALUES (1, 2, 3);
 INSERT INTO test_type_diff2_c2 VALUES (4, 5, 6);
@@ -3115,7 +3139,7 @@ LINE 1: ALTER TABLE partitioned ADD EXCLUDE USING gist (a WITH &&);
                                     ^
 -- cannot drop column that is part of the partition key
 ALTER TABLE partitioned DROP COLUMN a;
-ERROR:  cannot drop column named in partition key
+ERROR:  Distribution column cannot be dropped
 ALTER TABLE partitioned ALTER COLUMN a TYPE char(5);
 ERROR:  cannot alter type of column named in partition key
 ALTER TABLE partitioned DROP COLUMN b;
@@ -3190,7 +3214,12 @@ CREATE TEMP TABLE temp_parted (a int) PARTITION BY LIST (a);
 CREATE TABLE perm_part (a int);
 ALTER TABLE temp_parted ATTACH PARTITION perm_part FOR VALUES IN (1);
 ERROR:  cannot attach a permanent relation as partition of temporary relation "temp_parted"
+-- XXX fail in XL because temp and regular tables can't be dropped together
 DROP TABLE temp_parted, perm_part;
+ERROR:  DROP not supported for TEMP and non-TEMP objects
+DETAIL:  You should separate TEMP and non-TEMP objects
+DROP TABLE temp_parted;
+DROP TABLE perm_part;
 -- check that the table being attached is not a typed table
 CREATE TYPE mytype AS (a int);
 CREATE TABLE fail_part OF mytype;
@@ -3225,10 +3254,14 @@ CREATE TABLE fail_part (
        a int NOT NULL
 );
 ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1);
-ERROR:  child table "fail_part" has different type for column "b"
+ERROR:  table "fail_part" contains column "a" at position 2, but parent "list_parted" has it at position 1
+DETAIL:  Postgres-XL requires attribute positions to match
+HINT:  Check for column ordering and dropped columns, if any
 ALTER TABLE fail_part ALTER b TYPE char (2) COLLATE "POSIX";
 ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1);
-ERROR:  child table "fail_part" has different collation for column "b"
+ERROR:  table "fail_part" contains column "a" at position 2, but parent "list_parted" has it at position 1
+DETAIL:  Postgres-XL requires attribute positions to match
+HINT:  Check for column ordering and dropped columns, if any
 DROP TABLE fail_part;
 -- check that the table being attached has all constraints of the parent
 CREATE TABLE fail_part (
@@ -3236,11 +3269,15 @@ CREATE TABLE fail_part (
        a int NOT NULL
 );
 ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1);
-ERROR:  child table is missing constraint "check_a"
+ERROR:  table "fail_part" contains column "a" at position 2, but parent "list_parted" has it at position 1
+DETAIL:  Postgres-XL requires attribute positions to match
+HINT:  Check for column ordering and dropped columns, if any
 -- check that the constraint matches in definition with parent's constraint
 ALTER TABLE fail_part ADD CONSTRAINT check_a CHECK (a >= 0);
 ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1);
-ERROR:  child table "fail_part" has different definition for check constraint "check_a"
+ERROR:  table "fail_part" contains column "a" at position 2, but parent "list_parted" has it at position 1
+DETAIL:  Postgres-XL requires attribute positions to match
+HINT:  Check for column ordering and dropped columns, if any
 DROP TABLE fail_part;
 -- check the attributes and constraints after partition is attached
 CREATE TABLE part_1 (
@@ -3487,10 +3524,17 @@ order by attrelid::regclass::text;
 (3 rows)
 
 alter table p1 attach partition p11 for values from (2) to (5);
+ERROR:  table "p11" contains column "a" at position 4, but parent "p1" has it at position 2
+DETAIL:  Postgres-XL requires attribute positions to match
+HINT:  Check for column ordering and dropped columns, if any
 insert into p1 (a, b) values (2, 3);
+ERROR:  no partition of relation "p1" found for row
+DETAIL:  Partition key of the failing row contains (b) = (3).
 -- check that partition validation scan correctly detects violating rows
 alter table p attach partition p1 for values from (1, 2) to (1, 10);
-ERROR:  partition constraint is violated by some row
+ERROR:  table "p1" contains column "a" at position 2, but parent "p" has it at position 1
+DETAIL:  Postgres-XL requires attribute positions to match
+HINT:  Check for column ordering and dropped columns, if any
 -- cleanup
 drop table p;
 drop table p1;
index c5415a63310a003937141560ea25d4f4e32dfa3f..1f74d62925854cb4dc7aaf4b39ac611c78c248ba 100644 (file)
@@ -994,8 +994,8 @@ select NULL::derived::base;
 
 drop table derived;
 drop table base;
-create table p1(ff1 int);
-create table p2(f1 text);
+create table p1(ff1 int) distribute by roundrobin;
+create table p2(f1 text) distribute by roundrobin;
 create function p2text(p2) returns text as 'select $1.f1' language sql;
 create table c1(f3 int) inherits(p1,p2);
 insert into c1 values(123456789, 'hi', 42);
@@ -1094,8 +1094,8 @@ select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg
 
 drop table bc;
 drop table ac;
-create table ac (a int constraint check_a check (a <> 0));
-create table bc (b int constraint check_b check (b <> 0));
+create table ac (a int constraint check_a check (a <> 0)) distribute by roundrobin;
+create table bc (b int constraint check_b check (b <> 0)) distribute by roundrobin;
 create table cc (c int constraint check_c check (c <> 0)) inherits (ac, bc);
 select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pgc.consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc', 'cc') order by 1,2;
  relname | conname | contype | conislocal | coninhcount |  consrc  
@@ -1121,8 +1121,8 @@ select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg
 drop table cc;
 drop table bc;
 drop table ac;
-create table p1(f1 int);
-create table p2(f2 int);
+create table p1(f1 int) distribute by roundrobin;
+create table p2(f2 int) distribute by roundrobin;
 create table c1(f3 int) inherits(p1,p2);
 insert into c1 values(1,-1,2);
 alter table p2 add constraint cc check (f2>0);  -- fail
@@ -1227,8 +1227,8 @@ NOTICE:  drop cascades to 2 other objects
 DETAIL:  drop cascades to table cc1
 drop cascades to table cc2
 -- Test for renaming in simple multiple inheritance
-CREATE TABLE inht1 (a int, b int);
-CREATE TABLE inhs1 (b int, c int);
+CREATE TABLE inht1 (a int, b int) distribute by roundrobin;
+CREATE TABLE inhs1 (b int, c int) distribute by roundrobin;
 CREATE TABLE inhts (d int) INHERITS (inht1, inhs1);
 NOTICE:  merging multiple inherited definitions of column "b"
 ALTER TABLE inht1 RENAME a TO aa;
@@ -1247,7 +1247,7 @@ ALTER TABLE inhts RENAME d TO dd;
  dd     | integer |           |          |         | plain   |              | 
 Inherits: inht1,
           inhs1
-Distribute By: HASH(aa)
+Distribute By: ROUND ROBIN
 Location Nodes: ALL DATANODES
 
 DROP TABLE inhts;
@@ -1269,7 +1269,7 @@ ALTER TABLE inht1 RENAME aa TO aaa;
  z      | integer |           |          |         | plain   |              | 
 Inherits: inht2,
           inht3
-Distribute By: HASH(aaa)
+Distribute By: ROUND ROBIN
 Location Nodes: ALL DATANODES
 
 CREATE TABLE inhts (d int) INHERITS (inht2, inhs1);
@@ -1288,7 +1288,7 @@ ERROR:  cannot rename inherited column "b"
  d      | integer |           |          |         | plain   |              | 
 Inherits: inht2,
           inhs1
-Distribute By: HASH(aaaa)
+Distribute By: ROUND ROBIN
 Location Nodes: ALL DATANODES
 
 WITH RECURSIVE r AS (
index 8e38ddcde30464f85b0841b5848a42202d308807..106d68d8560eb02fda4ef9a61c57f16230cdcde8 100644 (file)
@@ -591,8 +591,8 @@ ERROR:  permission denied for relation atest5
 DELETE FROM atest5 WHERE two = 2; -- ok
 -- check inheritance cases
 SET SESSION AUTHORIZATION regress_user1;
-CREATE TABLE atestp1 (f1 int, f2 int) WITH OIDS;
-CREATE TABLE atestp2 (fx int, fy int) WITH OIDS;
+CREATE TABLE atestp1 (f1 int, f2 int) WITH OIDS DISTRIBUTE BY ROUNDROBIN;
+CREATE TABLE atestp2 (fx int, fy int) WITH OIDS DISTRIBUTE BY ROUNDROBIN;
 CREATE TABLE atestc (fz int) INHERITS (atestp1, atestp2);
 GRANT SELECT(fx,fy,oid) ON atestp2 TO regress_user2;
 GRANT SELECT(fx) ON atestc TO regress_user2;
index b0be9e00b4d1859d9d54692fbd1a3ab74d2eed08..7fb8691e3e2d39f2e4884a8234f6b3fbeef4b666 100644 (file)
@@ -522,8 +522,8 @@ insert into atacc1 (test2, test) values (3, 4);
 drop table atacc1;
 
 -- inheritance related tests
-create table atacc1 (test int);
-create table atacc2 (test2 int);
+create table atacc1 (test int) distribute by roundrobin;
+create table atacc2 (test2 int) distribute by roundrobin;
 create table atacc3 (test3 int) inherits (atacc1, atacc2);
 alter table atacc2 add constraint foo check (test2>0);
 -- fail and then succeed on atacc2
@@ -536,9 +536,23 @@ drop table atacc3;
 drop table atacc2;
 drop table atacc1;
 
--- same things with one created with INHERIT
 create table atacc1 (test int);
-create table atacc2 (test2 int);
+create table atacc2 (test int);
+-- fail due to missing constraint
+alter table atacc1 add constraint foo check (test>0);
+alter table atacc2 inherit atacc1;
+-- fail due to not-matching constraint
+alter table atacc2 add constraint foo check (test>10);
+alter table atacc2 inherit atacc1;
+-- succeed
+alter table atacc2 drop constraint foo;
+alter table atacc2 add constraint foo check (test>0);
+alter table atacc2 inherit atacc1;
+drop table atacc1 cascade;
+
+-- same things with one created with INHERIT
+create table atacc1 (test int) distribute by roundrobin;
+create table atacc2 (test2 int) distribute by roundrobin;
 create table atacc3 (test3 int) inherits (atacc1, atacc2);
 alter table atacc3 no inherit atacc2;
 -- fail
@@ -546,9 +560,6 @@ alter table atacc3 no inherit atacc2;
 -- make sure it really isn't a child
 insert into atacc3 (test2) values (3);
 select test2 from atacc2;
--- fail due to missing constraint
-alter table atacc2 add constraint foo check (test2>0);
-alter table atacc3 inherit atacc2;
 -- fail due to missing column
 alter table atacc3 rename test2 to testx;
 alter table atacc3 inherit atacc2;
@@ -560,15 +571,18 @@ alter table atacc3 drop test2;
 alter table atacc3 add test2 int;
 update atacc3 set test2 = 4 where test2 is null;
 alter table atacc3 add constraint foo check (test2>0);
+-- XXX fails in XL because of column position mismatch
 alter table atacc3 inherit atacc2;
 -- fail due to duplicates and circular inheritance
 alter table atacc3 inherit atacc2;
 alter table atacc2 inherit atacc3;
 alter table atacc2 inherit atacc2;
 -- test that we really are a child now (should see 4 not 3 and cascade should go through)
+-- XXX fails in XL because the previous alter table failed
 select test2 from atacc2;
 drop table atacc2 cascade;
-drop table atacc1;
+-- XXX needs a cascade drop in XL because atacc3 is still a child of atacc1
+drop table atacc1 cascade;
 
 -- adding only to a parent is allowed as of 9.2
 
@@ -1098,8 +1112,8 @@ alter table c1 drop column f1;
 
 drop table p1 cascade;
 
-create table p1(id int, name text);
-create table p2(id2 int, name text, height int);
+create table p1(id int, name text) distribute by roundrobin;
+create table p2(id2 int, name text, height int) distribute by roundrobin;
 create table c1(age int) inherits(p1,p2);
 create table gc1() inherits (c1);
 
@@ -2031,7 +2045,10 @@ DROP TABLE parent CASCADE;
 CREATE TEMP TABLE temp_parted (a int) PARTITION BY LIST (a);
 CREATE TABLE perm_part (a int);
 ALTER TABLE temp_parted ATTACH PARTITION perm_part FOR VALUES IN (1);
+-- XXX fail in XL because temp and regular tables can't be dropped together
 DROP TABLE temp_parted, perm_part;
+DROP TABLE temp_parted;
+DROP TABLE perm_part;
 
 -- check that the table being attached is not a typed table
 CREATE TYPE mytype AS (a int);
index 39e81dc966b2c02c20de120ad6a8837fd36e3b02..2f304b7bd56ce1bf67f5f464a0b88a42ca78b702 100644 (file)
@@ -295,8 +295,8 @@ select NULL::derived::base;
 drop table derived;
 drop table base;
 
-create table p1(ff1 int);
-create table p2(f1 text);
+create table p1(ff1 int) distribute by roundrobin;
+create table p2(f1 text) distribute by roundrobin;
 create function p2text(p2) returns text as 'select $1.f1' language sql;
 create table c1(f3 int) inherits(p1,p2);
 insert into c1 values(123456789, 'hi', 42);
@@ -347,8 +347,8 @@ select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg
 drop table bc;
 drop table ac;
 
-create table ac (a int constraint check_a check (a <> 0));
-create table bc (b int constraint check_b check (b <> 0));
+create table ac (a int constraint check_a check (a <> 0)) distribute by roundrobin;
+create table bc (b int constraint check_b check (b <> 0)) distribute by roundrobin;
 create table cc (c int constraint check_c check (c <> 0)) inherits (ac, bc);
 select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pgc.consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc', 'cc') order by 1,2;
 
@@ -359,8 +359,8 @@ drop table cc;
 drop table bc;
 drop table ac;
 
-create table p1(f1 int);
-create table p2(f2 int);
+create table p1(f1 int) distribute by roundrobin;
+create table p2(f2 int) distribute by roundrobin;
 create table c1(f3 int) inherits(p1,p2);
 insert into c1 values(1,-1,2);
 alter table p2 add constraint cc check (f2>0);  -- fail
@@ -387,8 +387,8 @@ alter table pp1 add column a2 int check (a2 > 0);
 drop table pp1 cascade;
 
 -- Test for renaming in simple multiple inheritance
-CREATE TABLE inht1 (a int, b int);
-CREATE TABLE inhs1 (b int, c int);
+CREATE TABLE inht1 (a int, b int) distribute by roundrobin;
+CREATE TABLE inhs1 (b int, c int) distribute by roundrobin;
 CREATE TABLE inhts (d int) INHERITS (inht1, inhs1);
 
 ALTER TABLE inht1 RENAME a TO aa;
index e2222bdc6654d937a1c7e265e1bda631439c4b1c..ad80361b46f8e3db117b2098c7649c8d42abbda0 100644 (file)
@@ -393,8 +393,8 @@ DELETE FROM atest5 WHERE two = 2; -- ok
 
 -- check inheritance cases
 SET SESSION AUTHORIZATION regress_user1;
-CREATE TABLE atestp1 (f1 int, f2 int) WITH OIDS;
-CREATE TABLE atestp2 (fx int, fy int) WITH OIDS;
+CREATE TABLE atestp1 (f1 int, f2 int) WITH OIDS DISTRIBUTE BY ROUNDROBIN;
+CREATE TABLE atestp2 (fx int, fy int) WITH OIDS DISTRIBUTE BY ROUNDROBIN;
 CREATE TABLE atestc (fz int) INHERITS (atestp1, atestp2);
 GRANT SELECT(fx,fy,oid) ON atestp2 TO regress_user2;
 GRANT SELECT(fx) ON atestc TO regress_user2;