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

LP:777654 - Wrong result with Aggregate + DISTINCT in FROM subquery in maria-5.3, 5.2

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      Reproducible in maria-5.3, maria-5.2. Not reproducible in MySQL 5.5 .

      The following query:

      SELECT * FROM ( SELECT SUM( DISTINCT f11 ) FROM t1) AS a1;

      returns (0) even though the FROM subquery returns (NULL);

      Test case:

      USE test;
      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 ( f11 int NOT NULL ) ;
      SELECT * FROM ( SELECT SUM( DISTINCT f11 ) FROM t1) AS a1;

      explain in maria 5.3:

      ---------------------------------------------------------------------------------------------+

      id select_type table type possible_keys key key_len ref rows Extra

      ---------------------------------------------------------------------------------------------+

      1 PRIMARY <derived2> system NULL NULL NULL NULL 1  
      2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table

      ---------------------------------------------------------------------------------------------+

      explain in mysql 5.5:

      --------------------------------------------------------------------+

      id select_type table type possible_keys key key_len ref rows Extra

      --------------------------------------------------------------------+

      1 PRIMARY <derived2> system NULL NULL NULL NULL 1  
      2 DERIVED t1 ALL NULL NULL NULL NULL 1  

      --------------------------------------------------------------------+

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            philipstoev Philip Stoev added a comment -

            Re: Wrong result with Aggregate + DISTINCT in FROM subquery in maria-5.2, 5.2
            Also reproducible with MySQL 5.1.56

            Show
            philipstoev Philip Stoev added a comment - Re: Wrong result with Aggregate + DISTINCT in FROM subquery in maria-5.2, 5.2 Also reproducible with MySQL 5.1.56
            Hide
            ratzpo Rasmus Johansson added a comment -

            Launchpad bug id: 777654

            Show
            ratzpo Rasmus Johansson added a comment - Launchpad bug id: 777654

              People

              • Assignee:
                igor Igor Babaev
                Reporter:
                philipstoev Philip Stoev
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: