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

NOT NULL and UNIQUE constraints cause SUM() to yield an incorrect result

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Confirmed (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 5.5, 10.1, 10.2, 10.3, 10.4, 10.4.11
    • Fix Version/s: 10.1, 10.2, 10.3, 10.4
    • Component/s: Server
    • Labels:
      None
    • Environment:
      Ubuntu 19.04

      Description

      Consider the following statements:

      CREATE TABLE t0(c0 INT NOT NULL, c1 CHAR UNIQUE);
      INSERT INTO t0 VALUES (0, 1);
      INSERT INTO t0 VALUES (0, '');
      SELECT SUM(a.t) FROM (SELECT (c1 RLIKE c1) = (c0 IS NULL) as t FROM t0) as a; -- expected: 1, actual: 0
      

      I would expect SUM() to yield 1, because the expression evaluates to TRUE for one row:

      SELECT (c1 RLIKE c1) = (c0 IS NULL) FROM t0; -- 1, 0
      

        Attachments

          Activity

            People

            Assignee:
            bar Alexander Barkov
            Reporter:
            mrigger Manuel Rigger
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: