diff --git a/src/gausskernel/optimizer/commands/ddldeparse.cpp b/src/gausskernel/optimizer/commands/ddldeparse.cpp index 548f7f6f9d8cf6ba8e8fd94b7dd5a161fd1a48b0..39b8e7f451fc4745c366d5382c8ff36e984a0553 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); } 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 ef95d030ddb0ad861206caacef268a44a2cad271..c587c85a8c03cfbd4894c2fcb50609d32e4d9402 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 53940da9255407148c4215958ea85f25438dfce3..ae356708d4e7c47737900e308c9970bc53b57d4b 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