!2933 修复当为带有表达式分区键得分区表添加主键时报错的问题
Merge pull request !2933 from 王修强/og_master_bug
This commit is contained in:
@ -5412,6 +5412,8 @@ static void CheckIndexParamsNumber(IndexStmt* stmt) {
|
||||
|
||||
static bool CheckIdxParamsOwnPartKey(Relation rel, const List* indexParams)
|
||||
{
|
||||
if (!PartExprKeyIsNull(rel, NULL))
|
||||
return false;
|
||||
int2vector* partKey = ((RangePartitionMap*)rel->partMap)->partitionKey;
|
||||
for (int i = 0; i < partKey->dim1; i++) {
|
||||
int2 attNum = partKey->values[i];
|
||||
|
||||
@ -290,6 +290,17 @@ select pg_get_tabledef('testrangesubpart');
|
||||
select pg_get_tabledef('testlistsubpart');
|
||||
select pg_get_tabledef('testhashsubpart');
|
||||
select pg_get_tabledef('testnormalsubpart');
|
||||
create database part_expr_key_db1 dbcompatibility 'B';
|
||||
\c part_expr_key_db1;
|
||||
create table t1(c1 int not null, c2 int)
|
||||
partition by range(c1 + 100) (
|
||||
partition p1 values less than(200),
|
||||
partition p2 values less than(300),
|
||||
partition p3 values less than(400)
|
||||
);
|
||||
CREATE INDEX t1_c2_idx ON t1 USING btree (c2) LOCAL(PARTITION p1_c2_idx, PARTITION p2_c2_idx, PARTITION p3_c2_idx);
|
||||
ALTER TABLE t1 ADD CONSTRAINT t3_pkey PRIMARY KEY USING btree (c1) INCLUDE (tableoid);
|
||||
\c regression
|
||||
|
||||
drop database if exists part_expr_key_db;
|
||||
drop database if exists part_expr_key_db;
|
||||
drop database if exists part_expr_key_db1;
|
||||
|
||||
@ -954,5 +954,17 @@ select pg_get_tabledef('testnormalsubpart');
|
||||
ENABLE ROW MOVEMENT;
|
||||
(1 row)
|
||||
|
||||
create database part_expr_key_db1 dbcompatibility 'B';
|
||||
\c part_expr_key_db1;
|
||||
create table t1(c1 int not null, c2 int)
|
||||
partition by range(c1 + 100) (
|
||||
partition p1 values less than(200),
|
||||
partition p2 values less than(300),
|
||||
partition p3 values less than(400)
|
||||
);
|
||||
CREATE INDEX t1_c2_idx ON t1 USING btree (c2) LOCAL(PARTITION p1_c2_idx, PARTITION p2_c2_idx, PARTITION p3_c2_idx);
|
||||
ALTER TABLE t1 ADD CONSTRAINT t3_pkey PRIMARY KEY USING btree (c1) INCLUDE (tableoid);
|
||||
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "t3_pkey" for table "t1"
|
||||
\c regression
|
||||
drop database if exists part_expr_key_db;
|
||||
drop database if exists part_expr_key_db1;
|
||||
|
||||
Reference in New Issue
Block a user