[MCOL-4023] MCS doesn't apply optimized WHERE conditions doing UPDATE Created: 2020-05-27  Updated: 2021-04-19  Resolved: 2020-06-01

Status: Closed
Project: MariaDB ColumnStore
Component/s: MDB Plugin
Affects Version/s: 1.4.3, 1.5.2
Fix Version/s: 1.4.4

Type: Bug Priority: Critical
Reporter: Roman Assignee: Daniel Lee (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
PartOf
is part of MCOL-3898 Refactor cond_push mechanism for tabl... Closed
Relates
relates to MCOL-4028 clone of MCOL-4023 for release 1.5.2 Closed

 Description   

Consider the scenario.

create table cs1(i bigint)engine=columnstore;
insert into cs1 values (42),(43);
update cs1 set i = 41 where i = 42 or (i is null and 42 is null);

MariaDB [test]> create table cs1(i bigint)engine=columnstore;
Query OK, 0 rows affected (0.405 sec)
 
MariaDB [test]> insert into cs1 values (42),(43);
Query OK, 2 rows affected (0.316 sec)
Records: 2  Duplicates: 0  Warnings: 0
 
MariaDB [test]> update cs1 set i = 41 where i = 42 or (i is null and 42 is null);
Query OK, 2 rows affected (0.323 sec)
Rows matched: 2  Changed: 2  Warnings: 0

MCS updates two records instead of only one.
MDB optimizes WHERE conditions removing (i is null and 42 is null) block and pushes the the whole WHERE predicate using ha_mcs::cond_push(). cond_push() ignores pushes for UPDATEs thus MCS has an empty WHERE conditions producing CSEP in doUpdateDelete().getSelectPlan().
JFYI MDB both sends WHERE predicate using cond_push() and SELECT_LEX for some queries but doesn't for others.
We need to refactor cond_push to use handler instance to safe conditions for UPDATEs and push them down into doUpdateDelete().getSelectPlan().
NB There should be no cond_push calls for join conditions so the conditions pushed belongs to one table only.



 Comments   
Comment by Daniel Lee (Inactive) [ 2020-06-01 ]

Build verified: 1.4.4-1 (Jenkins 20200601)

Reproduced the issue in 1.4.4-1 (old build) and verified the fix in this new build.

Generated at Thu Feb 08 02:47:12 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.