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

SUM(distinct) gives wrong result when reducing max_heap_table_size

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5.28a, 5.3.11, 5.2.13, 5.1.67
    • Fix Version/s: 5.5.29
    • Component/s: None
    • Labels:

      Description

      CREATE TABLE t1 (id INTEGER);
      CREATE TABLE t2 (id INTEGER);
      INSERT INTO t1 VALUES (1), (1), (1),(1);
      INSERT INTO t1 SELECT id FROM t1;
      INSERT INTO t1 SELECT id FROM t1;
      INSERT INTO t1 SELECT id FROM t1;
      INSERT INTO t1 SELECT id FROM t1;
      INSERT INTO t1 SELECT id FROM t1;
      INSERT INTO t1 SELECT id+1 FROM t1;
      INSERT INTO t1 SELECT id+2 FROM t1;
      INSERT INTO t1 SELECT id+4 FROM t1;
      INSERT INTO t1 SELECT id+8 FROM t1;
      INSERT INTO t1 SELECT id+16 FROM t1;
      INSERT INTO t1 SELECT id+32 FROM t1;
      INSERT INTO t1 SELECT id+64 FROM t1;
      INSERT INTO t1 SELECT id+128 FROM t1;
      INSERT INTO t1 SELECT id+256 FROM t1;
      INSERT INTO t1 SELECT id+512 FROM t1;
      INSERT INTO t1 SELECT id+1024 FROM t1;
      INSERT INTO t1 SELECT id+2048 FROM t1;
      INSERT INTO t1 SELECT id+4096 FROM t1;
      INSERT INTO t1 SELECT id+8192 FROM t1;
      INSERT INTO t2 SELECT id FROM t1 ORDER BY id*rand();
      SELECT SUM(DISTINCT id) sm FROM t2;
      SET max_heap_table_size=16384;
      SHOW variables LIKE 'max_heap_table_size';
      SELECT SUM(DISTINCT id) sm FROM t2;
      DROP TABLE t1;
      DROP TABLE t2;
      

      second SUM(DISTINCT) returns NULL

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              There are no comments yet on this issue.

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0 minutes
                    0m
                    Logged:
                    Time Spent - 1 hour
                    1h