Fix for MySQL bug #77448 Inconsistent handling of RAND() in WHERE and HAVING
Problem was that for queries of type: select rand() r, rand() p, rand() = rand() from a having r = p The optimizer thought that r = p was same as rand() = rand() and this would always be true. The problem was that when testing if two expressions are equal, we didn't take into account no determinstic functions. The fix is to not compare non deterministic functions as equal.
This commit is contained in:
parent
872a953b22
commit
0ad00c66d2
@ -480,7 +480,11 @@ bool Item_func::eq(const Item *item, bool binary_cmp) const
|
||||
/* Assume we don't have rtti */
|
||||
if (this == item)
|
||||
return 1;
|
||||
if (item->type() != FUNC_ITEM)
|
||||
/*
|
||||
Ensure that we are comparing two functions and that the function
|
||||
is deterministic.
|
||||
*/
|
||||
if (item->type() != FUNC_ITEM || (used_tables() & RAND_TABLE_BIT))
|
||||
return 0;
|
||||
Item_func *item_func=(Item_func*) item;
|
||||
Item_func::Functype func_type;
|
||||
|
Loading…
x
Reference in New Issue
Block a user