Skip to content

Commit

Permalink
bugfix: join a=b where cast(a as type_of_b) can produce NULL
Browse files Browse the repository at this point in the history
optimizer implicitly assumed that if `a` in `a=b` is not NULL,
then it's safe to convert `a` to the type of `b` and search the
result in the index(b).

which is not always the case, as converting a non-null value
to a different type might produce NULL. And searching for NULL
in the index might find NULL there, so NULL will be equal to NULL,
making `a=b` behave as if it was `a<=>b`
  • Loading branch information
vuvova committed Jul 5, 2023
1 parent ef84f81 commit 1570c6e
Show file tree
Hide file tree
Showing 4 changed files with 363 additions and 5 deletions.
4 changes: 2 additions & 2 deletions mysql-test/main/subselect_cache.result
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,7 @@ Subquery_cache_miss 18
show status like '%Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 32
Handler_read_key 29
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Expand Down Expand Up @@ -1763,7 +1763,7 @@ Subquery_cache_miss 10
show status like '%Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 13
Handler_read_key 12
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Expand Down
Loading

0 comments on commit 1570c6e

Please sign in to comment.