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

SUM(b'1100') and SUM(DISTINCT b'1100') return different numeric results for the same BIT literal (e.g. 12 vs 9)

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 12.3.1
    • None
    • Optimizer
    • None
    • ubuntu22.04

    Description

      Summary

      SUM(b'1100') and SUM(DISTINCT b'1100') return different numeric results for the same BIT literal (e.g. 12 vs 9). DISTINCT should only remove duplicates, not change the values fed into the aggregate.

      Impact

      • Any query using SUM(DISTINCT ...) on BIT values or BIT literals that goes through the DISTINCT temp-table path may disagree with SUM(...) without DISTINCT.

      Steps to reproduce

      SELECT SUM(b'1100'), SUM(DISTINCT b'1100');
      

      Actual result

      • SUM(b'1100') = 12
      • SUM(DISTINCT b'1100') = 9
      • The two expressions are not equal.

      Expected result

      • SUM(b'1100') and SUM(DISTINCT b'1100') must match (both 12)

      Attachments

        Activity

          People

            Unassigned Unassigned
            mu mu
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.