[MDEV-23066] RAND() evaluated and filtered twice with subquery Created: 2020-07-01 Updated: 2023-04-27 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 10.4.8, 10.2, 10.3, 10.4, 10.5 |
| Fix Version/s: | 10.4, 10.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Christopher Granahan | Assignee: | Igor Babaev |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows 10 |
||
| Issue Links: |
|
||||||||
| Description |
|
When calling RAND() in a subquery and filtering on it in the outer query, it appears that a random number is being generated twice, with both values checked against the WHERE clause. This issue sounds similar to Example:
This query should return 10 on average, but instead returns 1 on average. One workaround is to add a LIMIT clause to the inner query. The following code returns an average of 10 as expected:
|
| Comments |
| Comment by Alice Sherepa [ 2020-07-08 ] | ||||||||||||||||||||||||||||||||||||
|
It is repeatable on 10.2-10.5 - when condition_pushdown_for_derived=on.
|