diff options
author | sergefp@mysql.com <> | 2006-05-06 13:15:00 +0400 |
---|---|---|
committer | sergefp@mysql.com <> | 2006-05-06 13:15:00 +0400 |
commit | 1b349cf85fecaf22b6b16dc24541c345cd5a89fe (patch) | |
tree | 73272c9d7a5faf37a7090ebfec3c556662b7c988 /sql/sql_select.cc | |
parent | 3f1019455bbdbd1a50ec98b28960b3858a7c73f4 (diff) | |
download | mariadb-git-1b349cf85fecaf22b6b16dc24541c345cd5a89fe.tar.gz |
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().
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 46dba61cfc5..4995a164226 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -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; |