[MDEV-21076] NOT NULL and UNIQUE constraints cause SUM() to yield an incorrect result Created: 2019-11-18 Updated: 2023-04-27 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Server |
| Affects Version/s: | 5.5, 10.1, 10.4.11, 10.2, 10.3, 10.4 |
| Fix Version/s: | 10.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Manuel Rigger | Assignee: | Alexander Barkov |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu 19.04 |
||
| Issue Links: |
|
||||
| Description |
|
Consider the following statements:
I would expect SUM() to yield 1, because the expression evaluates to TRUE for one row:
|
| Comments |
| Comment by Elena Stepanova [ 2019-11-25 ] | |||||||||||||||||||||||||||||||
|
It seems more likely the expression evaluates to TRUE incorrectly. If we run (c1 RLIKE c1) separately, it returns TRUE to both, which seems quite natural:
And naturally c0 IS NULL returns FALSE for both rows:
But when they are run together, strange things happen:
Reproducible on 5.5-10.5. MySQL behaves differently comparing to MariaDB and between its own versions. | |||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2019-11-26 ] | |||||||||||||||||||||||||||||||
|
The problem is also demonstrated in this script:
This query returns a correct result:
Now if a add an extra column, the expression (c1 RLIKE c1) starts to return a wrong result for one row:
If I now add the ORDER BY clause:
it returns correct results again:
The problem seem to reside in this code:
It erroneously performs return false instead of recompiling. |