From 831b0424695b04c8e49f6a4704a4385e74248beb Mon Sep 17 00:00:00 2001 From: FantasyHuang <811594237@qq.com> Date: Fri, 9 Aug 2024 10:08:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A4=84=E7=90=86split=20partition?= =?UTF-8?q?=E5=8F=8D=E8=A7=A3=E6=9E=90=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../optimizer/commands/ddldeparse.cpp | 45 ++++++++++++++++--- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/src/gausskernel/optimizer/commands/ddldeparse.cpp b/src/gausskernel/optimizer/commands/ddldeparse.cpp index 548f7f6f9d..39b8e7f451 100644 --- a/src/gausskernel/optimizer/commands/ddldeparse.cpp +++ b/src/gausskernel/optimizer/commands/ddldeparse.cpp @@ -4822,7 +4822,6 @@ static ObjTree* deparse_AlterRelation(CollectedCommand *cmd, ddl_deparse_context case AT_SplitPartition: { SplitPartitionState *s = (SplitPartitionState*)subcmd->def; bool two_partiiton = false; - tmp_obj = new_objtree_VA("SPLIT PARTITION", 1, "type", ObjTypeString, "split partition"); if (s->src_partition_name) { @@ -4842,13 +4841,24 @@ static ObjTree* deparse_AlterRelation(CollectedCommand *cmd, ddl_deparse_context (RangePartitionDefState*)linitial(s->dest_partition_define_list); RangePartitionDefState *p2 = (RangePartitionDefState*)lsecond(s->dest_partition_define_list); + StringInfoData spc1; + StringInfoData spc2; + if (p1->tablespacename) { + initStringInfo(&spc1); + appendStringInfo(&spc1, "TABLESPACE %s", p1->tablespacename); + } + + if (p2->tablespacename) { + initStringInfo(&spc2); + appendStringInfo(&spc2, "TABLESPACE %s", p2->tablespacename); + } ObjTree *split_obj = new_objtree_VA( "PARTITION %{name1}s %{tblspc1}s, PARTITION %{name2}s %{tblspc2}s", 4, "name1", ObjTypeString, p1->partitionName, - "tblspc1", ObjTypeString, p1->tablespacename ? p1->tablespacename : "", + "tblspc1", ObjTypeString, p1->tablespacename ? spc1.data : "", "name2", ObjTypeString, p2->partitionName, - "tblspc2", ObjTypeString, p2->tablespacename ? p2->tablespacename : ""); + "tblspc2", ObjTypeString, p2->tablespacename ? spc2.data : ""); append_object_object(tmp_obj, "INTO (%{split_list}s)", split_obj); two_partiiton = true; @@ -4904,13 +4914,24 @@ static ObjTree* deparse_AlterRelation(CollectedCommand *cmd, ddl_deparse_context if (list_length(s->dest_partition_define_list) == 2) { ListPartitionDefState *p1 = (ListPartitionDefState*)linitial(s->dest_partition_define_list); ListPartitionDefState *p2 = (ListPartitionDefState*)lsecond(s->dest_partition_define_list); + StringInfoData spc1; + StringInfoData spc2; + if (p1->tablespacename) { + initStringInfo(&spc1); + appendStringInfo(&spc1, "TABLESPACE %s", p1->tablespacename); + } + + if (p2->tablespacename) { + initStringInfo(&spc2); + appendStringInfo(&spc2, "TABLESPACE %s", p2->tablespacename); + } define_list = new_objtree_VA( "SUBPARTITION %{name1}s %{tblspc1}s, SUBPARTITION %{name2}s %{tblspc2}s", 4, "name1", ObjTypeString, p1->partitionName, - "tblspc1", ObjTypeString, p1->tablespacename ? p1->tablespacename : "", + "tblspc1", ObjTypeString, p1->tablespacename ? spc1.data : "", "name2", ObjTypeString, p2->partitionName, - "tblspc2", ObjTypeString, p2->tablespacename ? p2->tablespacename : ""); + "tblspc2", ObjTypeString, p2->tablespacename ? spc2.data : ""); } if (define_list) { append_object_object(tmp_obj, "INTO (%{define_list}s)", define_list); @@ -4924,13 +4945,23 @@ static ObjTree* deparse_AlterRelation(CollectedCommand *cmd, ddl_deparse_context (RangePartitionDefState*)linitial(s->dest_partition_define_list); RangePartitionDefState *p2 = (RangePartitionDefState*)lsecond(s->dest_partition_define_list); + StringInfoData spc1; + StringInfoData spc2; + if (p1->tablespacename) { + initStringInfo(&spc1); + appendStringInfo(&spc1, "TABLESPACE %s", p1->tablespacename); + } + if (p2->tablespacename) { + initStringInfo(&spc2); + appendStringInfo(&spc2, "TABLESPACE %s", p2->tablespacename); + } define_list = new_objtree_VA( "SUBPARTITION %{name1}s %{tblspc1}s, SUBPARTITION %{name2}s %{tblspc2}s", 4, "name1", ObjTypeString, p1->partitionName, - "tblspc1", ObjTypeString, p1->tablespacename ? p1->tablespacename : "", + "tblspc1", ObjTypeString, p1->tablespacename ? spc1.data : "", "name2", ObjTypeString, p2->partitionName, - "tblspc2", ObjTypeString, p2->tablespacename ? p2->tablespacename : ""); + "tblspc2", ObjTypeString, p2->tablespacename ? spc2.data : ""); if (define_list) { append_object_object(tmp_obj, "INTO (%{define_list}s)", define_list); } -- Gitee From f63171dd973074840380c64090b9fc95345ccfe8 Mon Sep 17 00:00:00 2001 From: FantasyHuang <811594237@qq.com> Date: Fri, 9 Aug 2024 18:43:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dsubscription=E5=9B=9E?= =?UTF-8?q?=E5=BD=92=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../testcase/ddl_replication_sql/B/ddl_alter_schema.sql | 2 +- .../testcase/ddl_replication_sql/B/ddl_alter_table_002.sql | 1 + .../ddl_replication_sql/B/ddl_alter_table_fastcheck.sql | 1 + .../testcase/ddl_replication_sql/B/ddl_alter_table_rewrite.sql | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/subscription/testcase/ddl_replication_sql/B/ddl_alter_schema.sql b/src/test/subscription/testcase/ddl_replication_sql/B/ddl_alter_schema.sql index ef95d030dd..c587c85a8c 100644 --- a/src/test/subscription/testcase/ddl_replication_sql/B/ddl_alter_schema.sql +++ b/src/test/subscription/testcase/ddl_replication_sql/B/ddl_alter_schema.sql @@ -5,7 +5,7 @@ ALTER SCHEMA test_sche WITHOUT BLOCKCHAIN; ALTER SCHEMA test_sche RENAME TO test_sche1; ALTER SCHEMA test_sche1 OWNER TO regtest_unpriv_user; - +ALTER SCHEMA test_sche1 OWNER TO ddl_test_user; ALTER SCHEMA test_sche1 CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; create SCHEMA test_sche2; diff --git a/src/test/subscription/testcase/ddl_replication_sql/B/ddl_alter_table_002.sql b/src/test/subscription/testcase/ddl_replication_sql/B/ddl_alter_table_002.sql index 53940da925..ae356708d4 100644 --- a/src/test/subscription/testcase/ddl_replication_sql/B/ddl_alter_table_002.sql +++ b/src/test/subscription/testcase/ddl_replication_sql/B/ddl_alter_table_002.sql @@ -477,6 +477,7 @@ alter table at3acc1 add constraint at3acc_test1 check (test1>3); create table at4acc1 ( test int, test2 int, test3 int); -- add a check constraint (fails) alter table at4acc1 add constraint at4acc_test1 check (test+test2