1
0
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:
sergefp@mysql.com
2006-05-06 13:15:00 +04:00
parent 3f1019455b
commit 1b349cf85f
3 changed files with 113 additions and 3 deletions

View File

@@ -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;