[MDEV-26329] Equality operator does not work with ROWNUM() function after first row Created: 2021-08-09 Updated: 2021-08-10 Resolved: 2021-08-10 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | N/A |
| Affects Version/s: | 10.6.4 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Geoff Montee (Inactive) | Assignee: | Ralf Gebhardt |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||
| Description |
|
The equality operator (=) does not work with the ROWNUM() function after the first row. Let's say that we have the following table:
The ROWNUM() function works with the following range query:
Results:
And it works with the following query that uses the equality operator (=):
Results:
However, when you use the equality operator on any other row, the query returns an empty result set. This applies to the following queries:
|
| Comments |
| Comment by Geoff Montee (Inactive) [ 2021-08-09 ] | ||||||||||||||||||||||||||||
|
The equality operator does seem to work when the ROWNUM() result is aliased inside a CTE or subquery. Subquery:
CTE:
But an alias does not work with a flat query:
| ||||||||||||||||||||||||||||
| Comment by Ralf Gebhardt [ 2021-08-10 ] | ||||||||||||||||||||||||||||
|
Hi GeoffMontee, you cannot use the equality operator (=) with ROWNUM, an exception is 1. Also Conditions testing for ROWNUM values greater than a positive integer will always have an empty result set. This is "as designed" and also works this way with Oracle. Your working example generate a result set first, which is then evaluated. This is fine. |