hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iw...@apache.org
Subject incubator-hawq git commit: HAWQ-455. Disable creating partition tables with non uniform distribution policy
Date Thu, 10 Mar 2016 00:48:52 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 675465d87 -> d72d0fa04


HAWQ-455. Disable creating partition tables with non uniform distribution policy


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/d72d0fa0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/d72d0fa0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/d72d0fa0

Branch: refs/heads/master
Commit: d72d0fa041953c66e1663ce8952f0191b12bf8a1
Parents: 675465d
Author: ivan <iweng@pivotal.io>
Authored: Thu Mar 10 08:48:36 2016 +0800
Committer: ivan <iweng@pivotal.io>
Committed: Thu Mar 10 08:48:36 2016 +0800

----------------------------------------------------------------------
 src/backend/commands/tablecmds.c                |  18 ++++
 src/backend/parser/analyze.c                    |  37 +++++++
 .../expected/create_table_distribution.out      | 102 ++++++++++++++-----
 .../regress/sql/create_table_distribution.sql   |  41 +++++++-
 4 files changed, 171 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d72d0fa0/src/backend/commands/tablecmds.c
----------------------------------------------------------------------
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index a2c98bf..aceee02 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -13758,6 +13758,24 @@ ATPExecPartAdd(AlteredTableInfo *tab,
 					 errhint("use a named partition"),
 							   errOmitLocation(true)));
 
+	PartitionElem *pElem = (PartitionElem *) pc2->arg1;
+	Node *pStoreAttr = pElem->storeAttr;
+	if (pStoreAttr && ((AlterPartitionCmd *)pStoreAttr)->arg1)
+	{
+		List *pWithList = (List *)(((AlterPartitionCmd *)pStoreAttr)->arg1);
+		GpPolicy *parentPolicy = GpPolicyFetch(CurrentMemoryContext, RelationGetRelid(rel));
+		int bucketnum = parentPolicy->bucketnum;
+		int child_bucketnum = GetRelOpt_bucket_num_fromOptions(pWithList, bucketnum);
+
+		if (child_bucketnum != bucketnum)
+			ereport(ERROR,
+					(errcode(ERRCODE_GP_FEATURE_NOT_SUPPORTED),
+							errmsg("distribution policy for partition%s "
+									"must be the same as that for %s",
+									namBuf,
+									lrelname)));
+	}
+
 	/* don't check if splitting or setting a subpartition template */
 	if (!is_split && !bSetTemplate)
 		/* We complain if partition already exists, so prule should be NULL */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d72d0fa0/src/backend/parser/analyze.c
----------------------------------------------------------------------
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index 2bf1a9a..ad35484 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -2986,6 +2986,27 @@ transformDistributedBy(ParseState *pstate, CreateStmtContext *cxt,
 
 	*policyp = policy;
 
+	if (cxt && cxt->inhRelations)
+	{
+		ListCell   *entry;
+
+		foreach(entry, cxt->inhRelations)
+		{
+			RangeVar   *parent = (RangeVar *) lfirst(entry);
+			Oid			relId = RangeVarGetRelid(parent, false, false /*allowHcatalog*/);
+			GpPolicy  *parentPolicy = GpPolicyFetch(CurrentMemoryContext, relId);
+
+			if (!GpPolicyEqual(policy, parentPolicy))
+			{
+				ereport(ERROR,
+						(errcode(ERRCODE_GP_FEATURE_NOT_SUPPORTED),
+								errmsg("distribution policy for \"%s\" "
+										"must be the same as that for \"%s\"",
+										cxt->relation->relname,
+										parent->relname)));
+			}
+		}
+	}
 
 	if (cxt && cxt->pkey)		/* Primary key	specified.	Make sure
 								 * distribution columns match */
@@ -8231,6 +8252,22 @@ transformPartitionBy(ParseState *pstate, CreateStmtContext *cxt,
 										 snamespaceid,
 										 NULL);
 
+		/* check non-uniform bucketnum options */
+		if (pStoreAttr && ((AlterPartitionCmd *)pStoreAttr)->arg1)
+		{
+			List *pWithList = (List *)(((AlterPartitionCmd *)pStoreAttr)->arg1);
+			int bucketnum = policy->bucketnum;
+			int child_bucketnum = GetRelOpt_bucket_num_fromOptions(pWithList, bucketnum);
+
+			if (child_bucketnum != bucketnum)
+				ereport(ERROR,
+						(errcode(ERRCODE_GP_FEATURE_NOT_SUPPORTED),
+								errmsg("distribution policy for \"%s\" "
+										"must be the same as that for \"%s\"",
+										relname,
+										cxt->relation->relname)));
+		}
+
 		/* XXX: temporarily add rule creation code for debugging */
 
 		/* now that we have the child table name, make the rule */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d72d0fa0/src/test/regress/expected/create_table_distribution.out
----------------------------------------------------------------------
diff --git a/src/test/regress/expected/create_table_distribution.out b/src/test/regress/expected/create_table_distribution.out
index 857b103..717cc46 100644
--- a/src/test/regress/expected/create_table_distribution.out
+++ b/src/test/regress/expected/create_table_distribution.out
@@ -4,8 +4,12 @@
 CREATE TABLE t1(c1 int);
 CREATE TABLE t1_1(c2 int) INHERITS(t1);
 NOTICE:  Table has parent, setting distribution columns to match parent table
+-- should error out messages with different bucketnum
 CREATE TABLE t1_1_w(c2 int) INHERITS(t1) WITH (bucketnum = 3);
 NOTICE:  Table has parent, setting distribution columns to match parent table
+ERROR:  distribution policy for "t1_1_w" must be the same as that for "t1"
+CREATE TABLE t1_1_w(c2 int) INHERITS(t1) WITH (bucketnum = 6);
+NOTICE:  Table has parent, setting distribution columns to match parent table
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't1');
  bucketnum | attrnums 
 -----------+----------
@@ -21,26 +25,30 @@ SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid
= (SELECT
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't1_1_w');
  bucketnum | attrnums 
 -----------+----------
-         3 | 
+         6 | 
 (1 row)
 
 CREATE TABLE t1_1_1(c2 int) INHERITS (t1) DISTRIBUTED BY(c1);
+ERROR:  distribution policy for "t1_1_1" must be the same as that for "t1"
 CREATE TABLE t1_1_2(c2 int) INHERITS (t1) DISTRIBUTED BY(c2);
+ERROR:  distribution policy for "t1_1_2" must be the same as that for "t1"
 CREATE TABLE t1_1_3(c2 int) INHERITS (t1) DISTRIBUTED RANDOMLY;
+-- should error out messages with different bucketnum
 CREATE TABLE t1_1_4(c2 int) INHERITS (t1) WITH (bucketnum = 3) DISTRIBUTED BY(c1) ;
+ERROR:  distribution policy for "t1_1_4" must be the same as that for "t1"
 CREATE TABLE t1_1_5(c2 int) INHERITS (t1) WITH (bucketnum = 5) DISTRIBUTED BY(c2);
+ERROR:  distribution policy for "t1_1_5" must be the same as that for "t1"
 CREATE TABLE t1_1_6(c2 int) INHERITS (t1) WITH (bucketnum = 7) DISTRIBUTED RANDOMLY;
+ERROR:  distribution policy for "t1_1_6" must be the same as that for "t1"
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't1_1_1');
  bucketnum | attrnums 
 -----------+----------
-         6 | {1}
-(1 row)
+(0 rows)
 
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't1_1_2');
  bucketnum | attrnums 
 -----------+----------
-         6 | {2}
-(1 row)
+(0 rows)
 
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't1_1_3');
  bucketnum | attrnums 
@@ -51,23 +59,21 @@ SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid
= (SELECT
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't1_1_4');
  bucketnum | attrnums 
 -----------+----------
-         3 | {1}
-(1 row)
+(0 rows)
 
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't1_1_5');
  bucketnum | attrnums 
 -----------+----------
-         5 | {2}
-(1 row)
+(0 rows)
 
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't1_1_6');
  bucketnum | attrnums 
 -----------+----------
-         7 | 
-(1 row)
+(0 rows)
 
 CREATE TABLE t1_2(LIKE t1);        
 NOTICE:  Table doesn't have 'distributed by' clause, defaulting to distribution columns from
LIKE table
+-- should error out messages with different bucketnum
 CREATE TABLE t1_2_w(LIKE t1) WITH (bucketnum = 4);   
 NOTICE:  Table doesn't have 'distributed by' clause, defaulting to distribution columns from
LIKE table
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't1_2');
@@ -96,6 +102,7 @@ SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid =
(SELECT
          6 | 
 (1 row)
 
+-- should error out messages with different bucketnum
 CREATE TABLE t1_2_3(LIKE t1) WITH (bucketnum = 4) DISTRIBUTED BY (c1);
 CREATE TABLE t1_2_4(LIKE t1) WITH (bucketnum = 4) DISTRIBUTED RANDOMLY;
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't1_2_3');
@@ -152,7 +159,7 @@ SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid
= (SELECT
          7 | 
 (1 row)
 
-DROP TABLE t1_3_4, t1_3_3, t1_3_2, t1_3_1, t1_3_w, t1_3, t1_2_4, t1_2_3, t1_2_2, t1_2_1,
t1_2_w, t1_2, t1_1_1, t1_1_2, t1_1_3, t1_1_4, t1_1_5, t1_1_6, t1_1_w, t1_1, t1;
+DROP TABLE t1_3_4, t1_3_3, t1_3_2, t1_3_1, t1_3_w, t1_3, t1_2_4, t1_2_3, t1_2_2, t1_2_1,
t1_2_w, t1_2, t1_1_3, t1_1_w, t1_1, t1;
 CREATE TABLE t2(c1 int) DISTRIBUTED BY (c1);
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't2');
  bucketnum | attrnums 
@@ -170,15 +177,17 @@ SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid
= (SELECT
 
 CREATE TABLE t2_1_w(c2 int) INHERITS (t2) WITH (bucketnum = 3);
 NOTICE:  Table has parent, setting distribution columns to match parent table
+ERROR:  distribution policy for "t2_1_w" must be the same as that for "t2"
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't2_1_w');
  bucketnum | attrnums 
 -----------+----------
-         3 | {1}
-(1 row)
+(0 rows)
 
 CREATE TABLE t2_1_1(c2 int) INHERITS (t2) DISTRIBUTED BY (c1);
 CREATE TABLE t2_1_2(c2 int) INHERITS (t2) DISTRIBUTED BY (c2);
+ERROR:  distribution policy for "t2_1_2" must be the same as that for "t2"
 CREATE TABLE t2_1_3(c2 int) INHERITS (t2) DISTRIBUTED RANDOMLY;
+ERROR:  distribution policy for "t2_1_3" must be the same as that for "t2"
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't2_1_1');
  bucketnum | attrnums 
 -----------+----------
@@ -188,35 +197,33 @@ SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid
= (SELECT
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't2_1_2');
  bucketnum | attrnums 
 -----------+----------
-         6 | {2}
-(1 row)
+(0 rows)
 
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't2_1_3');
  bucketnum | attrnums 
 -----------+----------
-         6 | 
-(1 row)
+(0 rows)
 
 CREATE TABLE t2_1_4(c2 int) INHERITS (t2) WITH (bucketnum = 3) DISTRIBUTED BY (c1);
+ERROR:  distribution policy for "t2_1_4" must be the same as that for "t2"
 CREATE TABLE t2_1_5(c2 int) INHERITS (t2) WITH (bucketnum = 5) DISTRIBUTED BY (c2);
+ERROR:  distribution policy for "t2_1_5" must be the same as that for "t2"
 CREATE TABLE t2_1_6(c2 int) INHERITS (t2) WITH (bucketnum = 7) DISTRIBUTED RANDOMLY;
+ERROR:  distribution policy for "t2_1_6" must be the same as that for "t2"
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't2_1_4');
  bucketnum | attrnums 
 -----------+----------
-         3 | {1}
-(1 row)
+(0 rows)
 
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't2_1_5');
  bucketnum | attrnums 
 -----------+----------
-         5 | {2}
-(1 row)
+(0 rows)
 
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't2_1_6');
  bucketnum | attrnums 
 -----------+----------
-         7 | 
-(1 row)
+(0 rows)
 
 CREATE TABLE t2_2(LIKE t2);
 NOTICE:  Table doesn't have 'distributed by' clause, defaulting to distribution columns from
LIKE table
@@ -305,7 +312,8 @@ SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid
= (SELECT
          6 | 
 (1 row)
 
-DROP TABLE t2_3_4, t2_3_3, t2_3_2, t2_3_1, t2_3_w, t2_3, t2_2_4, t2_2_3, t2_2_2, t2_2_1,
t2_2_w, t2_2, t2_1_1, t2_1_2, t2_1_3, t2_1_4, t2_1_5, t2_1_6, t2_1_w, t2_1, t2;
+DROP TABLE t2_3_4, t2_3_3, t2_3_2, t2_3_1, t2_3_w, t2_3, t2_2_4, t2_2_3, t2_2_2, t2_2_1,
t2_2_w, t2_2, t2_1_1, t2_1_w, t2_1, t2;
+ERROR:  table "t2_1_w" does not exist
 CREATE TABLE t3 (c1 int) WITH (bucketnum = 4);
 CREATE TABLE t3_1 (c1 int) WITH (bucketnum = 5) DISTRIBUTED BY(c1);
 CREATE TABLE t3_2 (c1 int) WITH (bucketnum = 6) DISTRIBUTED RANDOMLY;
@@ -328,3 +336,47 @@ SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid
= (SELECT
 (1 row)
 
 DROP TABLE t3_2, t3_1, t3;
+CREATE TABLE t4 (id int, date date, amt decimal(10,2))
+DISTRIBUTED RANDOMLY
+PARTITION BY RANGE (date)
+( PARTITION Jan08 START (date '2008-01-01') INCLUSIVE WITH (bucketnum = 9), 
+ PARTITION Feb08 START (date '2008-02-01') INCLUSIVE END (date '2008-03-01') EXCLUSIVE WITH
(bucketnum = 6));
+ERROR:  distribution policy for "t4_1_prt_jan08" must be the same as that for "t4"
+-- expected error out
+select bucketnum, attrnums from gp_distribution_policy where localoid='t4'::regclass;
+ERROR:  relation "t4" does not exist
+LINE 1: ...trnums from gp_distribution_policy where localoid='t4'::regc...
+                                                             ^
+CREATE TABLE t4 (id int, date date, amt decimal(10,2))
+DISTRIBUTED RANDOMLY
+PARTITION BY RANGE (date)
+( PARTITION Jan08 START (date '2008-01-01') INCLUSIVE WITH (bucketnum = 6), 
+ PARTITION Feb08 START (date '2008-02-01') INCLUSIVE END (date '2008-03-01') EXCLUSIVE WITH
(bucketnum = 6));
+NOTICE:  CREATE TABLE will create partition "t4_1_prt_jan08" for table "t4"
+NOTICE:  CREATE TABLE will create partition "t4_1_prt_feb08" for table "t4"
+select bucketnum, attrnums from gp_distribution_policy where localoid='t4'::regclass;
+ bucketnum | attrnums 
+-----------+----------
+         6 | 
+(1 row)
+
+ALTER TABLE t4 ADD PARTITION 
+START (date '2008-03-01') INCLUSIVE 
+END (date '2008-04-01') EXCLUSIVE WITH (bucketnum = 8, tablename='t4_new_part');
+ERROR:  distribution policy for partition must be the same as that for relation "t4"
+-- expected error out
+select bucketnum, attrnums from gp_distribution_policy where localoid='t4_new_part'::regclass;
+ERROR:  relation "t4_new_part" does not exist
+LINE 1: ...trnums from gp_distribution_policy where localoid='t4_new_pa...
+                                                             ^
+ALTER TABLE t4 ADD PARTITION 
+START (date '2008-03-01') INCLUSIVE 
+END (date '2008-04-01') EXCLUSIVE WITH (bucketnum = 6, tablename='t4_new_part');
+NOTICE:  CREATE TABLE will create partition "t4_new_part" for table "t4"
+select bucketnum, attrnums from gp_distribution_policy where localoid='t4_new_part'::regclass;
+ bucketnum | attrnums 
+-----------+----------
+         6 | 
+(1 row)
+
+DROP TABLE t4 CASCADE;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d72d0fa0/src/test/regress/sql/create_table_distribution.sql
----------------------------------------------------------------------
diff --git a/src/test/regress/sql/create_table_distribution.sql b/src/test/regress/sql/create_table_distribution.sql
index bc3899d..7e98c8f 100644
--- a/src/test/regress/sql/create_table_distribution.sql
+++ b/src/test/regress/sql/create_table_distribution.sql
@@ -6,8 +6,11 @@ CREATE TABLE t1(c1 int);
 
 CREATE TABLE t1_1(c2 int) INHERITS(t1);
 
+-- should error out messages with different bucketnum
 CREATE TABLE t1_1_w(c2 int) INHERITS(t1) WITH (bucketnum = 3);
 
+CREATE TABLE t1_1_w(c2 int) INHERITS(t1) WITH (bucketnum = 6);
+
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't1');
 
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't1_1');
@@ -20,6 +23,7 @@ CREATE TABLE t1_1_2(c2 int) INHERITS (t1) DISTRIBUTED BY(c2);
 
 CREATE TABLE t1_1_3(c2 int) INHERITS (t1) DISTRIBUTED RANDOMLY;
 
+-- should error out messages with different bucketnum
 CREATE TABLE t1_1_4(c2 int) INHERITS (t1) WITH (bucketnum = 3) DISTRIBUTED BY(c1) ;
 
 CREATE TABLE t1_1_5(c2 int) INHERITS (t1) WITH (bucketnum = 5) DISTRIBUTED BY(c2);
@@ -40,6 +44,7 @@ SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid =
(SELECT
 
 CREATE TABLE t1_2(LIKE t1);        
 
+-- should error out messages with different bucketnum
 CREATE TABLE t1_2_w(LIKE t1) WITH (bucketnum = 4);   
 
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't1_2');
@@ -54,6 +59,7 @@ CREATE TABLE t1_2_2(LIKE t1) DISTRIBUTED RANDOMLY;
 
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't1_2_2');
 
+-- should error out messages with different bucketnum
 CREATE TABLE t1_2_3(LIKE t1) WITH (bucketnum = 4) DISTRIBUTED BY (c1);
 
 CREATE TABLE t1_2_4(LIKE t1) WITH (bucketnum = 4) DISTRIBUTED RANDOMLY;
@@ -86,7 +92,7 @@ SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid =
(SELECT
 
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't1_3_4');
 
-DROP TABLE t1_3_4, t1_3_3, t1_3_2, t1_3_1, t1_3_w, t1_3, t1_2_4, t1_2_3, t1_2_2, t1_2_1,
t1_2_w, t1_2, t1_1_1, t1_1_2, t1_1_3, t1_1_4, t1_1_5, t1_1_6, t1_1_w, t1_1, t1;
+DROP TABLE t1_3_4, t1_3_3, t1_3_2, t1_3_1, t1_3_w, t1_3, t1_2_4, t1_2_3, t1_2_2, t1_2_1,
t1_2_w, t1_2, t1_1_3, t1_1_w, t1_1, t1;
 
 CREATE TABLE t2(c1 int) DISTRIBUTED BY (c1);
 
@@ -172,7 +178,7 @@ CREATE TABLE t2_3_4 WITH (bucketnum = 6) AS (SELECT * FROM  t2) DISTRIBUTED
RAND
 
 SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid = (SELECT oid FROM
pg_class WHERE relname = 't2_3_4');
 
-DROP TABLE t2_3_4, t2_3_3, t2_3_2, t2_3_1, t2_3_w, t2_3, t2_2_4, t2_2_3, t2_2_2, t2_2_1,
t2_2_w, t2_2, t2_1_1, t2_1_2, t2_1_3, t2_1_4, t2_1_5, t2_1_6, t2_1_w, t2_1, t2;
+DROP TABLE t2_3_4, t2_3_3, t2_3_2, t2_3_1, t2_3_w, t2_3, t2_2_4, t2_2_3, t2_2_2, t2_2_1,
t2_2_w, t2_2, t2_1_1, t2_1_w, t2_1, t2;
 
 CREATE TABLE t3 (c1 int) WITH (bucketnum = 4);
 
@@ -188,3 +194,34 @@ SELECT bucketnum, attrnums FROM gp_distribution_policy WHERE localoid
= (SELECT
 
 DROP TABLE t3_2, t3_1, t3;
 
+CREATE TABLE t4 (id int, date date, amt decimal(10,2))
+DISTRIBUTED RANDOMLY
+PARTITION BY RANGE (date)
+( PARTITION Jan08 START (date '2008-01-01') INCLUSIVE WITH (bucketnum = 9), 
+ PARTITION Feb08 START (date '2008-02-01') INCLUSIVE END (date '2008-03-01') EXCLUSIVE WITH
(bucketnum = 6));
+
+-- expected error out
+select bucketnum, attrnums from gp_distribution_policy where localoid='t4'::regclass;
+
+CREATE TABLE t4 (id int, date date, amt decimal(10,2))
+DISTRIBUTED RANDOMLY
+PARTITION BY RANGE (date)
+( PARTITION Jan08 START (date '2008-01-01') INCLUSIVE WITH (bucketnum = 6), 
+ PARTITION Feb08 START (date '2008-02-01') INCLUSIVE END (date '2008-03-01') EXCLUSIVE WITH
(bucketnum = 6));
+
+select bucketnum, attrnums from gp_distribution_policy where localoid='t4'::regclass;
+
+ALTER TABLE t4 ADD PARTITION 
+START (date '2008-03-01') INCLUSIVE 
+END (date '2008-04-01') EXCLUSIVE WITH (bucketnum = 8, tablename='t4_new_part');
+
+-- expected error out
+select bucketnum, attrnums from gp_distribution_policy where localoid='t4_new_part'::regclass;
+
+ALTER TABLE t4 ADD PARTITION 
+START (date '2008-03-01') INCLUSIVE 
+END (date '2008-04-01') EXCLUSIVE WITH (bucketnum = 6, tablename='t4_new_part');
+
+select bucketnum, attrnums from gp_distribution_policy where localoid='t4_new_part'::regclass;
+
+DROP TABLE t4 CASCADE;


Mime
View raw message