Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-20010

Equal on two RANK window functions create wrong result

    XMLWordPrintable

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

          Activity

            People

              monty Michael Widenius
              Alicen -
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.