[MDEV-8709] Row equality elements do not get propagated Created: 2015-08-31  Updated: 2015-09-12  Resolved: 2015-09-11

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.0, 10.1
Fix Version/s: 10.1.8

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: propagation, upstream-not-affected

Issue Links:
Blocks
blocks MDEV-8728 Fix a number of problems in equal fie... Closed

 Description   

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT, b INT);
INSERT INTO t1 VALUES (10,10),(20,20);
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=10 AND b=10 AND a>=10;
SHOW WARNINGS;

returns:

+-------+------+---------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message                                                                                                                         |
+-------+------+---------------------------------------------------------------------------------------------------------------------------------+
| Note  | 1003 | select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 10) and (`test`.`t1`.`b` = 10)) |
+-------+------+---------------------------------------------------------------------------------------------------------------------------------+

Notice, the a>=10 part was removed from the condition.

Now if I rewrite the same query using ROW comparison syntax:

EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a,b)=(10,10) AND a>=10;
SHOW WARNINGS;

It returns:

+-------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message                                                                                                                                                     |
+-------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Note  | 1003 | select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 10) and (`test`.`t1`.`b` = 10) and (`test`.`t1`.`a` >= 10)) |
+-------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+

Notice, the a>=10 part is still there.

The problem was that the items that participate in the (a,b)=(10,10) equality did not have cmp_context set properly.
With the changes made under the terms of MDEV-8728 this problem does not seem to exists any more in 10.1.8.


Generated at Thu Feb 08 07:29:11 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.