Details
Description
The following code results into a wrong result in MariaDB must of the time. It is not completely deterministic, but about 80% of all executions trigger a wrong execution:
CREATE SCHEMA A; |
|
CREATE TABLE A.A (A INTEGER, E BIGINT); |
|
INSERT INTO A.A VALUES (4, -2), (3, -1); |
|
SELECT RANK() OVER (ORDER BY D.C) = RANK() OVER (ORDER BY B.A) FROM (SELECT 5 AS C FROM A.A) AS D, (SELECT A.E AS A FROM A.A) AS B; |
MariaDB returns 0, 0, 0, 1. Postgres and MySQL both return 0, 0, 1, 1, which is - manually verified - the correct answer. Therefore, I expect that MariaDB should also return this.
We need both RANK window function calls and the equal - erasing one of the RANKs with the equal returns the correct results.
I checked versions 10.4.5 and 10.4.6, I don't know if the bug occurs in previous versions. In MySQL, the query works.
Attachments
Issue Links
- relates to
-
MDEV-19680 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index) || (!(ptr >= table->record[0] && ptr < table->record[0] + table->s->reclength)))' or alike failed upon SELECT with mix of functions from simple view
- Stalled
-
MDEV-20922 Adding an order by changes the query results
- Closed