[MDEV-28027] Never SELECT the first row when using RAND function Created: 2022-03-09 Updated: 2023-04-27 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.7.3, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7 |
| Fix Version/s: | 10.4, 10.5, 10.6 |
| Type: | Bug | Priority: | Major |
| Reporter: | John Jove | Assignee: | Sergei Golubchik |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | innodb | ||
| Environment: |
OS: Ubuntu-20.04 |
||
| Description |
|
The function RAND() with a string type argument is TRUE in WHERE clause, but the SELECT statements with this WHERE clause never select the first row.
|
| Comments |
| Comment by Alice Sherepa [ 2022-03-09 ] | |||||||||||||||||||||||||||||||||||||
|
The value 't' was truncated to 0. RAND with the seed returns the same repeatable sequence:
Currently, if the result of the where expression is >=0.5 then it is evaluated to TRUE, else - FALSE
It is different with constants, they are always evaluated as true (except 0/false):
| |||||||||||||||||||||||||||||||||||||
| Comment by John Jove [ 2022-03-11 ] | |||||||||||||||||||||||||||||||||||||
|
Thank you for your reply. But, "the where expression is >=0.5 then it is evaluated to TRUE" is weired. In MySQL, "SELECT * FROM t WHERE RAND('t');" returns all the records. Please see:
|