mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
BUG#16798: Inapplicable ref_or_null query plan and bad query result on random occasions
The bug was as follows: When merge_key_fields() encounters "t.key=X OR t.key=Y" it will try to join them into ref_or_null access via "t.key=X OR NULL". In order to make this inference it checks if Y<=>NULL, ignoring the fact that value of Y may be not yet known. The fix is that the check if Y<=>NULL is made only if value of Y is known (i.e. it is a constant). TODO: When merging to 5.0, replace used_tables() with const_item() everywhere in merge_key_fields().
This commit is contained in:
@@ -2090,7 +2090,8 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end,
|
||||
new_fields->null_rejecting);
|
||||
}
|
||||
else if (old->eq_func && new_fields->eq_func &&
|
||||
(old->val->is_null() || new_fields->val->is_null()))
|
||||
((!old->val->used_tables() && old->val->is_null()) ||
|
||||
new_fields->val->is_null()))
|
||||
{
|
||||
/* field = expression OR field IS NULL */
|
||||
old->level= and_level;
|
||||
|
||||
Reference in New Issue
Block a user