aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/parser/parse_utilcmd.c1
-rw-r--r--src/test/regress/expected/indexing.out16
-rw-r--r--src/test/regress/sql/indexing.sql10
3 files changed, 26 insertions, 1 deletions
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index 2406ca7a5d0..484ca40ddf4 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -3685,7 +3685,6 @@ transformPartitionCmd(CreateStmtContext *cxt, PartitionCmd *cmd)
break;
case RELKIND_PARTITIONED_INDEX:
/* nothing to check */
- Assert(cmd->bound == NULL);
break;
case RELKIND_RELATION:
/* the table must be partitioned */
diff --git a/src/test/regress/expected/indexing.out b/src/test/regress/expected/indexing.out
index ec1d4eaef4c..a8f80329a6a 100644
--- a/src/test/regress/expected/indexing.out
+++ b/src/test/regress/expected/indexing.out
@@ -121,6 +121,22 @@ Partition of: idxparti2
No partition constraint
btree, for table "public.idxpart1"
+-- ALTER TABLE when attaching or detaching an index to a partition.
+create index idxpart_c on only idxpart (c);
+create index idxpart1_c on idxpart1 (c);
+alter table idxpart_c attach partition idxpart1_c for values from (10) to (20);
+alter index idxpart_c attach partition idxpart1_c;
+select relname, relpartbound from pg_class
+ where relname in ('idxpart_c', 'idxpart1_c')
+ order by relname;
+ relname | relpartbound
+------------+--------------
+ idxpart1_c |
+ idxpart_c |
+(2 rows)
+
+alter table idxpart_c detach partition idxpart1_c;
+ERROR: "idxpart_c" is not a table
drop table idxpart;
-- If a partition already has an index, don't create a duplicative one
create table idxpart (a int, b int) partition by range (a, b);
diff --git a/src/test/regress/sql/indexing.sql b/src/test/regress/sql/indexing.sql
index f6a37679189..290d458dc37 100644
--- a/src/test/regress/sql/indexing.sql
+++ b/src/test/regress/sql/indexing.sql
@@ -63,6 +63,16 @@ alter table idxpart attach partition idxpart1 for values from (0) to (10);
\d idxpart1
\d+ idxpart1_a_idx
\d+ idxpart1_b_c_idx
+
+-- ALTER TABLE when attaching or detaching an index to a partition.
+create index idxpart_c on only idxpart (c);
+create index idxpart1_c on idxpart1 (c);
+alter table idxpart_c attach partition idxpart1_c for values from (10) to (20);
+alter index idxpart_c attach partition idxpart1_c;
+select relname, relpartbound from pg_class
+ where relname in ('idxpart_c', 'idxpart1_c')
+ order by relname;
+alter table idxpart_c detach partition idxpart1_c;
drop table idxpart;
-- If a partition already has an index, don't create a duplicative one