1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

bugfix: join a=b where cast(a as type_of_b) can produce NULL

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`
This commit is contained in:
Sergei Golubchik
2023-07-05 21:51:52 +02:00
parent ef84f8137b
commit 1570c6e3e0
4 changed files with 363 additions and 5 deletions

View File

@@ -25562,7 +25562,8 @@ cp_buffer_from_ref(THD *thd, TABLE *table, TABLE_REF *ref)
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
for (store_key **copy=ref->key_copy ; *copy ; copy++)
{
if ((*copy)->copy(thd) & 1)
if ((*copy)->copy(thd) & 1 ||
(ref->null_rejecting && (*copy)->null_key))
{
result= 1;
break;