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.