From a943dd7151e8192dcffcbdc671af964d5287854d Mon Sep 17 00:00:00 2001 From: laishenghao Date: Tue, 24 Dec 2024 10:49:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=A1=A8=E8=BE=BE=E5=BC=8F?= =?UTF-8?q?=E4=BD=9C=E5=88=86=E5=8C=BA=E9=94=AE=E6=97=B6split=E5=88=86?= =?UTF-8?q?=E5=8C=BA=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 --- .../optimizer/commands/tablecmds.cpp | 8 +++++--- .../regress/input/partition_expr_key.source | 17 +++++++++++++++++ .../regress/output/partition_expr_key.source | 19 +++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/gausskernel/optimizer/commands/tablecmds.cpp b/src/gausskernel/optimizer/commands/tablecmds.cpp index ca96430061..0eae0f4fd8 100755 --- a/src/gausskernel/optimizer/commands/tablecmds.cpp +++ b/src/gausskernel/optimizer/commands/tablecmds.cpp @@ -30600,9 +30600,10 @@ static void checkSplitPointForSplit(SplitPartitionState* splitPart, Relation par splitPart->split_point = transformRangePartitionValueInternal(pstate, splitPart->split_point, true, true); pfree_ext(pstate); + bool partkeyIsFunc = IsPartKeyFunc(partTableRel, false, partTableRel->parentId != InvalidOid); List *tmp = splitPart->split_point; - splitPart->split_point = - transformConstIntoTargetType(partTableRel->rd_att->attrs, partMap->base.partitionKey, splitPart->split_point); + splitPart->split_point = transformConstIntoTargetType(partTableRel->rd_att->attrs, partMap->base.partitionKey, + splitPart->split_point, partkeyIsFunc); list_free_ext(tmp); foreach (cell, splitPart->split_point) { @@ -33425,7 +33426,8 @@ void CreateWeakPasswordDictionary(CreateWeakPasswordDictionaryStmt* stmt) values[Anum_gs_global_config_name - 1] = DirectFunctionCall1(namein, CStringGetDatum(name)); values[Anum_gs_global_config_value - 1] = CStringGetTextDatum(pwd); tup = (HeapTuple) heap_form_tuple(RelationGetDescr(rel), values, nulls); - simple_heap_insert(rel, tup); + simple_heap_insert(rel, tup); + heap_freetuple_ext(tup); } } heap_close(rel, RowExclusiveLock); diff --git a/src/test/regress/input/partition_expr_key.source b/src/test/regress/input/partition_expr_key.source index f8fa9eb683..9a67f7dc66 100644 --- a/src/test/regress/input/partition_expr_key.source +++ b/src/test/regress/input/partition_expr_key.source @@ -398,6 +398,23 @@ select * from test_exprkey_move_part; update test_exprkey_move_part set a=1001 where a=1000; select * from test_exprkey_move_part; +-- test split expkey partition +DROP TABLE IF EXISTS tb1 cascade; +CREATE TABLE tb1 ( + id serial NOT NULL, + inqueuetime timestamp NOT NULL, + url_count int NOT NULL DEFAULT 0, + constraint tb1_id_inqueuetime_pk primary key(id,inqueuetime) +) +PARTITION BY RANGE (date_part('year', inqueuetime))( + PARTITION p1 VALUES LESS THAN (2000), + PARTITION p4 VALUES LESS THAN (maxvalue) +); +alter table tb1 split partition p4 at(2001) into (partition p5,partition p6); + +-- test split expkey partition with updating index +alter table tb1 split partition p1 at(1000) into (partition p11,partition p12) update global index; + \c regression drop database if exists part_expr_key_db; diff --git a/src/test/regress/output/partition_expr_key.source b/src/test/regress/output/partition_expr_key.source index a4592cdc90..3e4de25624 100644 --- a/src/test/regress/output/partition_expr_key.source +++ b/src/test/regress/output/partition_expr_key.source @@ -1280,6 +1280,25 @@ select * from test_exprkey_move_part; 1001 | 1 (1 row) +-- test split expkey partition +DROP TABLE IF EXISTS tb1 cascade; +NOTICE: table "tb1" does not exist, skipping +CREATE TABLE tb1 ( + id serial NOT NULL, + inqueuetime timestamp NOT NULL, + url_count int NOT NULL DEFAULT 0, + constraint tb1_id_inqueuetime_pk primary key(id,inqueuetime) +) +PARTITION BY RANGE (date_part('year', inqueuetime))( + PARTITION p1 VALUES LESS THAN (2000), + PARTITION p4 VALUES LESS THAN (maxvalue) +); +NOTICE: CREATE TABLE will create implicit sequence "tb1_id_seq" for serial column "tb1.id" +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "tb1_id_inqueuetime_pk" for table "tb1" +alter table tb1 split partition p4 at(2001) into (partition p5,partition p6); +NOTICE: Command without UPDATE GLOBAL INDEX will disable global index +-- test split expkey partition with updating index +alter table tb1 split partition p1 at(1000) into (partition p11,partition p12) update global index; \c regression drop database if exists part_expr_key_db; drop database if exists part_expr_key_db1; -- Gitee