!2731 解决update部分列无法选择正确分区的问题

Merge pull request !2731 from 王修强/partition_key_update
This commit is contained in:
opengauss-bot
2023-02-18 06:21:52 +00:00
committed by Gitee
3 changed files with 64 additions and 2 deletions

View File

@ -2431,11 +2431,11 @@ lreplace:
bool need_create_file = false;
int seqNum = -1;
bool can_ignore = estate->es_plannedstmt->hasIgnore;
if (!partKeyUpdate) {
Datum newval = ComputePartKeyExprTuple(result_relation_desc, estate, slot, NULL);
if (!newval && !partKeyUpdate) {
row_movement = false;
new_partId = oldPartitionOid;
} else {
Datum newval = ComputePartKeyExprTuple(result_relation_desc, estate, slot, NULL);
if (newval) {
partitionRoutingForTuple(result_relation_desc, (void*)newval, u_sess->exec_cxt.route, can_ignore);
} else {

View File

@ -199,6 +199,22 @@ insert into b_bug_1 values(100,1.5),(199,2.5);
select * from b_bug_1 partition(p1);
select * from b_bug_1 partition(p2);
drop table if exists b_bug_1;
create table b_bug_2(a int, b int, c int) partition by range(a-b)
(
partition p1 values less than(10),
partition p2 values less than(20),
partition p3 values less than(30)
);
create index on b_bug_2(a) global;
create index on b_bug_2(b) local;
insert into b_bug_2 values(19,10,1),(30,20,2),(50,30,3);
select * from b_bug_2 partition(p1);
select * from b_bug_2 partition(p2);
select * from b_bug_2 partition(p3);
update b_bug_2 set b = 21 where c = 2;
select * from b_bug_2 partition(p1);
select * from b_bug_2 partition(p2);
select * from b_bug_2 partition(p3);
--test pg_get_tabledef and pg_dump

View File

@ -558,6 +558,52 @@ select * from b_bug_1 partition(p2);
(1 row)
drop table if exists b_bug_1;
create table b_bug_2(a int, b int, c int) partition by range(a-b)
(
partition p1 values less than(10),
partition p2 values less than(20),
partition p3 values less than(30)
);
create index on b_bug_2(a) global;
create index on b_bug_2(b) local;
insert into b_bug_2 values(19,10,1),(30,20,2),(50,30,3);
select * from b_bug_2 partition(p1);
a | b | c
----+----+---
19 | 10 | 1
(1 row)
select * from b_bug_2 partition(p2);
a | b | c
----+----+---
30 | 20 | 2
(1 row)
select * from b_bug_2 partition(p3);
a | b | c
----+----+---
50 | 30 | 3
(1 row)
update b_bug_2 set b = 21 where c = 2;
select * from b_bug_2 partition(p1);
a | b | c
----+----+---
19 | 10 | 1
30 | 21 | 2
(2 rows)
select * from b_bug_2 partition(p2);
a | b | c
---+---+---
(0 rows)
select * from b_bug_2 partition(p3);
a | b | c
----+----+---
50 | 30 | 3
(1 row)
--test pg_get_tabledef and pg_dump
create table testnormalsubpart(a int, b int) partition by range(a) subpartition by range(b)
(