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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • None
    • None

    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  

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

      Attachments

        Activity

          People

            igor Igor Babaev (Inactive)
            philipstoev Philip Stoev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 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.