mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Bug #22367: Optimizer uses ref join type instead of eq_ref for simple join on
strings MySQL is setting the flag HA_END_SPACE_KEYS for all the keys that reference text or varchar columns with collation different than binary. This was done to handle correctly the situation where a lookup on such a key may return more than 1 row because of the presence of many rows that differ only by the amount of trailing space in the table's string column. Inserting such values however appears to violate the unique checks on INSERT/UPDATE. Thus that flag must not be set as it will prevent the optimizer from choosing a faster access method. This fix removes the setting of the HA_END_SPACE_KEYS flag.
This commit is contained in:
@ -363,12 +363,12 @@ INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1');
|
||||
INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1');
|
||||
EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t8 ref PRIMARY PRIMARY 37 const 1 Using where; Using index
|
||||
4 SUBQUERY t8 ref PRIMARY PRIMARY 37 1 Using where; Using index
|
||||
2 SUBQUERY t8 ref PRIMARY PRIMARY 37 const 1 Using where
|
||||
3 SUBQUERY t8 ref PRIMARY PRIMARY 37 1 Using where; Using index
|
||||
1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 Using index
|
||||
4 SUBQUERY t8 const PRIMARY PRIMARY 37 1 Using index
|
||||
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1
|
||||
3 SUBQUERY t8 const PRIMARY PRIMARY 37 1 Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` AS `email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select `test`.`t8`.`pseudo` AS `pseudo` from `test`.`t8` where (`test`.`t8`.`pseudo` = _latin1'joce')))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select `test`.`t8`.`pseudo` AS `pseudo` from `test`.`t8` where (`test`.`t8`.`pseudo` = _latin1'joce')))
|
||||
Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` AS `email` from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where 1
|
||||
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
|
||||
t8 WHERE pseudo='joce');
|
||||
ERROR 21000: Operand should contain 1 column(s)
|
||||
|
Reference in New Issue
Block a user