!3635 修复分区表bypass update报错问题

Merge pull request !3635 from 胡正超/onupdate
This commit is contained in:
opengauss_bot
2023-07-03 02:20:16 +00:00
committed by Gitee
3 changed files with 118 additions and 2 deletions

View File

@ -384,7 +384,7 @@ lreplace:
temp_values = m_local.m_reslot->tts_values;
m_local.m_reslot->tts_values = m_local.m_values;
bool update_fix_result = ExecComputeStoredUpdateExpr(result_rel_info, m_c_local.m_estate, m_local.m_reslot,
tup, CMD_UPDATE, tupleid, InvalidOid, bucketid);
tup, CMD_UPDATE, tupleid, (part == NULL ? InvalidOid : part->pd_id), bucketid);
if (!update_fix_result) {
if (tup != m_local.m_reslot->tts_tuple) {
tableam_tops_free_tuple(tup);

View File

@ -665,5 +665,89 @@ select * from t_dmpportal_common_intent;
--?.*
(3 rows)
show sql_beta_feature;
sql_beta_feature
------------------
a_style_coerce
(1 row)
show enable_partition_opfusion;
enable_partition_opfusion
---------------------------
off
(1 row)
show enable_opfusion;
enable_opfusion
-----------------
off
(1 row)
set sql_beta_feature = 'a_style_coerce, partition_opfusion';
set enable_partition_opfusion = on;
set enable_opfusion = on;
create table bypass_pt_update (
a serial primary key,
b int default 1
) partition by range(a) (
partition p1 values less than (5),
partition p2 values less than (maxvalue)
);
NOTICE: CREATE TABLE will create implicit sequence "bypass_pt_update_a_seq" for serial column "bypass_pt_update.a"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "bypass_pt_update_pkey" for table "bypass_pt_update"
insert into bypass_pt_update(b) select generate_series(1,8);
select * from bypass_pt_update order by a;
a | b
---+---
1 | 1
2 | 2
3 | 3
4 | 4
5 | 5
6 | 6
7 | 7
8 | 8
(8 rows)
explain (verbose on, costs off) update bypass_pt_update set b = 2 where a = 1;
QUERY PLAN
-------------------------------------------------------------------------------------
[Bypass]
Update on public.bypass_pt_update
-> Partitioned Index Scan using bypass_pt_update_pkey on public.bypass_pt_update
Output: a, 2, ctid, tableoid
Index Cond: (bypass_pt_update.a = 1)
Selected Partitions: 1
(6 rows)
update bypass_pt_update set b = 2 where a = 1;
explain (verbose on, costs off) update bypass_pt_update set a = 9 where a = 2;
QUERY PLAN
-------------------------------------------------------------------------------------
Update on public.bypass_pt_update
-> Partitioned Index Scan using bypass_pt_update_pkey on public.bypass_pt_update
Output: 9, b, ctid, tableoid
Index Cond: (bypass_pt_update.a = 2)
Selected Partitions: 1
(5 rows)
update bypass_pt_update set a = 9 where a = 2;
select * from bypass_pt_update order by a;
a | b
---+---
1 | 2
3 | 3
4 | 4
5 | 5
6 | 6
7 | 7
8 | 8
9 | 2
(8 rows)
drop table bypass_pt_update;
set sql_beta_feature='a_style_coerce';
set enable_partition_opfusion = off;
set enable_opfusion = off;
\c regression
DROP database mysql;

View File

@ -261,5 +261,37 @@ update t_dmpportal_common_intent set intent_name='2' where id=2;
select count(upt_time) from t_dmpportal_common_intent group by upt_time order by upt_time;
select * from t_dmpportal_common_intent;
show sql_beta_feature;
show enable_partition_opfusion;
show enable_opfusion;
set sql_beta_feature = 'a_style_coerce, partition_opfusion';
set enable_partition_opfusion = on;
set enable_opfusion = on;
create table bypass_pt_update (
a serial primary key,
b int default 1
) partition by range(a) (
partition p1 values less than (5),
partition p2 values less than (maxvalue)
);
insert into bypass_pt_update(b) select generate_series(1,8);
select * from bypass_pt_update order by a;
explain (verbose on, costs off) update bypass_pt_update set b = 2 where a = 1;
update bypass_pt_update set b = 2 where a = 1;
explain (verbose on, costs off) update bypass_pt_update set a = 9 where a = 2;
update bypass_pt_update set a = 9 where a = 2;
select * from bypass_pt_update order by a;
drop table bypass_pt_update;
set sql_beta_feature='a_style_coerce';
set enable_partition_opfusion = off;
set enable_opfusion = off;
\c regression
DROP database mysql;
DROP database mysql;