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

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.4.11, 5.5(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL)
    • N/A
    • Server
    • None
    • 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

        Issue Links

          Activity

            People

              bar Alexander Barkov
              mrigger Manuel Rigger
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.