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

Wrong result upon query with join and distinct

    XMLWordPrintable

Details

    Description

      CREATE TABLE t1 (a INT);
      INSERT INTO t1 VALUES (1),(2);
       
      CREATE TABLE t2 (b VARCHAR(1024)) ENGINE=MyISAM;
      INSERT INTO t2 VALUES ('-a'),('-W'),('-f'),('-FANTW'),('-c'),('b'),('r');
       
      CREATE TABLE t3 (c VARCHAR(1024), d VARCHAR(1024)) ENGINE=MyISAM;
      INSERT INTO t3 VALUES
        ('-D-','-r-'),('-i-','-j-'),('-e-','h'),('y','-I-'),('-Y-','-G-'),
        ('-QMCQI-','-J-'),('p','-V-'),('z','s'),('-b-','a'),('-l-','-c-'),
        ('-NACAU-','-FBFMW-'),('-S-','c'),('c','-b-'),('-R-','-e-'),('x','-t-'),
        ('-N-','b'),('-c-','-u-'),('-Q-','c'),('-a-','-m-'),('e','-R-'),('-s-','-y-'),
        ('c','-d-'),('-p-','-y-'),('-r-','-x-'),('-O-','-e-'),('-i-','-c-'),
        ('n','-p-'),('p','-c-'),('e','c'),('-c-','-v-'),('-J-','-H-'),('-P-','p'),
        ('-T-','-x-'),('-v-','-w-'),('-D-','f'),('-p-','-O-'),('-p-','-E-'),
        ('-i-','-K-'),('-a-','-H-'),('f','x'),('-O-','-g-'),('-p-','-c-'),
        ('-c-','-C-'),('-A-','l'),('f','-B-'),('-x-','-G-'),('r','-I-');
       
      SELECT DISTINCT b, c FROM t1 JOIN t2 JOIN t3 WHERE b < d ORDER BY b, c;
       
      DROP TABLE t1, t2, t3;
      

      The actual result contains a duplicate row despite the DISTINCT:

      bb-blob-main-monty 8ecd078f0db4a14fae242a57afea32b19b70f845

      ...
      -f      p
      -f      r
      -f      r
      -f      x
      ...
      

      The failure started happening after this commit:

      commit 636f154bb49b301d5c5272870ac7eba439864b90
      Author: Arcadiy Ivanov
      Date:   Tue Jul 28 16:01:37 2026 -0400
       
          MDEV-40376 `Protocol::end_statement` assertion when window function fills HEAP tmp table
      

      Attachments

        Issue Links

          Activity

            People

              monty Michael Widenius
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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