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: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 5.5, 10.1, 10.4.11, 10.2, 10.3, 10.4
    • 10.4
    • 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

        Activity

          People

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

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.