From 707b72e2ceb4fd521f4f6f8c08b57bfd5925b5a0 Mon Sep 17 00:00:00 2001 From: WangXiuqiang Date: Mon, 20 Feb 2023 14:45:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=93=E4=B8=BA=E5=B8=A6?= =?UTF-8?q?=E6=9C=89=E8=A1=A8=E8=BE=BE=E5=BC=8F=E5=88=86=E5=8C=BA=E9=94=AE?= =?UTF-8?q?=E5=BE=97=E5=88=86=E5=8C=BA=E8=A1=A8=E6=B7=BB=E5=8A=A0=E4=B8=BB?= =?UTF-8?q?=E9=94=AE=E6=97=B6=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/optimizer/commands/indexcmds.cpp | 2 ++ src/test/regress/input/partition_expr_key.source | 13 ++++++++++++- src/test/regress/output/partition_expr_key.source | 12 ++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/gausskernel/optimizer/commands/indexcmds.cpp b/src/gausskernel/optimizer/commands/indexcmds.cpp index 64911467a..fe0211950 100755 --- a/src/gausskernel/optimizer/commands/indexcmds.cpp +++ b/src/gausskernel/optimizer/commands/indexcmds.cpp @@ -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]; diff --git a/src/test/regress/input/partition_expr_key.source b/src/test/regress/input/partition_expr_key.source index 711adbbce..c5d8ef0d4 100644 --- a/src/test/regress/input/partition_expr_key.source +++ b/src/test/regress/input/partition_expr_key.source @@ -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; \ No newline at end of file +drop database if exists part_expr_key_db; +drop database if exists part_expr_key_db1; diff --git a/src/test/regress/output/partition_expr_key.source b/src/test/regress/output/partition_expr_key.source index 648b914ee..3185072dd 100644 --- a/src/test/regress/output/partition_expr_key.source +++ b/src/test/regress/output/partition_expr_key.source @@ -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;