Fix ignore+opfusion+prepare
This commit is contained in:
@ -411,7 +411,8 @@ bool InsertFusion::execute(long max_rows, char* completionTag)
|
|||||||
InitResultRelInfo(result_rel_info, rel, 1, 0);
|
InitResultRelInfo(result_rel_info, rel, 1, 0);
|
||||||
|
|
||||||
if (result_rel_info->ri_RelationDesc->rd_rel->relhasindex) {
|
if (result_rel_info->ri_RelationDesc->rd_rel->relhasindex) {
|
||||||
bool speculative = m_c_local.m_estate->es_plannedstmt && m_c_local.m_estate->es_plannedstmt->hasIgnore;
|
bool speculative = (m_c_local.m_estate->es_plannedstmt && m_c_local.m_estate->es_plannedstmt->hasIgnore) ||
|
||||||
|
(m_global->m_planstmt && m_global->m_planstmt->hasIgnore);
|
||||||
ExecOpenIndices(result_rel_info, speculative);
|
ExecOpenIndices(result_rel_info, speculative);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,7 +612,8 @@ bool UpdateFusion::execute(long max_rows, char *completionTag)
|
|||||||
m_c_local.m_estate->es_plannedstmt = m_global->m_planstmt;
|
m_c_local.m_estate->es_plannedstmt = m_global->m_planstmt;
|
||||||
|
|
||||||
if (result_rel_info->ri_RelationDesc->rd_rel->relhasindex) {
|
if (result_rel_info->ri_RelationDesc->rd_rel->relhasindex) {
|
||||||
bool speculative = m_c_local.m_estate->es_plannedstmt && m_c_local.m_estate->es_plannedstmt->hasIgnore;
|
bool speculative = (m_c_local.m_estate->es_plannedstmt && m_c_local.m_estate->es_plannedstmt->hasIgnore) ||
|
||||||
|
(m_global->m_planstmt && m_global->m_planstmt->hasIgnore);
|
||||||
ExecOpenIndices(result_rel_info, speculative);
|
ExecOpenIndices(result_rel_info, speculative);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,5 +442,44 @@ update /*+ ignore_error */ t_column_orien set c1 = null where c1 = 2;
|
|||||||
ERROR: IGNORE is not supported on UPDATE column orientated table.
|
ERROR: IGNORE is not supported on UPDATE column orientated table.
|
||||||
update /*+ ignore_error */ t_column_orien set c1 = 1 where c1 = 2;
|
update /*+ ignore_error */ t_column_orien set c1 = 1 where c1 = 2;
|
||||||
ERROR: IGNORE is not supported on UPDATE column orientated table.
|
ERROR: IGNORE is not supported on UPDATE column orientated table.
|
||||||
|
--test under opfusion+prepare
|
||||||
|
set enable_opfusion = on;
|
||||||
|
set enable_bitmapscan to off;
|
||||||
|
set enable_seqscan to off;
|
||||||
|
create table t_ignore_0037(c1 int primary key, c2 number(5,2));
|
||||||
|
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "t_ignore_0037_pkey" for table "t_ignore_0037"
|
||||||
|
create index i_test on t_ignore_0037(c2);
|
||||||
|
analyze t_ignore_0037;
|
||||||
|
prepare insert_ignore(int,number(5,2)) as insert /*+ ignore_error */ into t_ignore_0037 values(1,2);
|
||||||
|
explain(costs off) execute insert_ignore(0, 123.12);
|
||||||
|
QUERY PLAN
|
||||||
|
-------------------------
|
||||||
|
[Bypass]
|
||||||
|
Insert on t_ignore_0037
|
||||||
|
-> Result
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
execute insert_ignore(0, 123.12);
|
||||||
|
execute insert_ignore(0, 123.12);
|
||||||
|
WARNING: duplicate key value violates unique constraint in table "t_ignore_0037"
|
||||||
|
insert into t_ignore_0037 values(3,1);
|
||||||
|
insert into t_ignore_0037 values(4,1);
|
||||||
|
prepare update_ignore(int) as update /*+ ignore_error */ t_ignore_0037 set c1=$1 where c2=1;
|
||||||
|
explain(costs off) execute update_ignore(0);
|
||||||
|
QUERY PLAN
|
||||||
|
------------------------------------------------
|
||||||
|
[Bypass]
|
||||||
|
Update on t_ignore_0037
|
||||||
|
-> Index Scan using i_test on t_ignore_0037
|
||||||
|
Index Cond: (c2 = 1::numeric)
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
execute update_ignore(0);
|
||||||
|
WARNING: duplicate key value violates unique constraint in table "t_ignore_0037"
|
||||||
|
execute update_ignore(0);
|
||||||
|
WARNING: duplicate key value violates unique constraint in table "t_ignore_0037"
|
||||||
|
reset enable_bitmapscan;
|
||||||
|
reset enable_seqscan;
|
||||||
|
DEALLOCATE all;
|
||||||
\c postgres
|
\c postgres
|
||||||
drop database if exists sql_ignore_unique_test;
|
drop database if exists sql_ignore_unique_test;
|
||||||
|
@ -217,5 +217,29 @@ insert /*+ ignore_error */ into t_column_orien values(null);
|
|||||||
update /*+ ignore_error */ t_column_orien set c1 = null where c1 = 2;
|
update /*+ ignore_error */ t_column_orien set c1 = null where c1 = 2;
|
||||||
update /*+ ignore_error */ t_column_orien set c1 = 1 where c1 = 2;
|
update /*+ ignore_error */ t_column_orien set c1 = 1 where c1 = 2;
|
||||||
|
|
||||||
|
--test under opfusion+prepare
|
||||||
|
set enable_opfusion = on;
|
||||||
|
set enable_bitmapscan to off;
|
||||||
|
set enable_seqscan to off;
|
||||||
|
|
||||||
|
create table t_ignore_0037(c1 int primary key, c2 number(5,2));
|
||||||
|
create index i_test on t_ignore_0037(c2);
|
||||||
|
analyze t_ignore_0037;
|
||||||
|
prepare insert_ignore(int,number(5,2)) as insert /*+ ignore_error */ into t_ignore_0037 values(1,2);
|
||||||
|
explain(costs off) execute insert_ignore(0, 123.12);
|
||||||
|
execute insert_ignore(0, 123.12);
|
||||||
|
execute insert_ignore(0, 123.12);
|
||||||
|
|
||||||
|
insert into t_ignore_0037 values(3,1);
|
||||||
|
insert into t_ignore_0037 values(4,1);
|
||||||
|
|
||||||
|
prepare update_ignore(int) as update /*+ ignore_error */ t_ignore_0037 set c1=$1 where c2=1;
|
||||||
|
explain(costs off) execute update_ignore(0);
|
||||||
|
execute update_ignore(0);
|
||||||
|
execute update_ignore(0);
|
||||||
|
reset enable_bitmapscan;
|
||||||
|
reset enable_seqscan;
|
||||||
|
DEALLOCATE all;
|
||||||
|
|
||||||
\c postgres
|
\c postgres
|
||||||
drop database if exists sql_ignore_unique_test;
|
drop database if exists sql_ignore_unique_test;
|
Reference in New Issue
Block a user