Conversation
…meric results for the same BIT literal (e.g. 12 vs 9) SUM(DISTINCT b'1100') can produce a different numeric value from SUM(b'1100'), despite both aggregating the same bit literal. The DISTINCT expression should return 12. The DISTINCT temporary field is chosen from the argument's type handler and metadata. That can materialize a bit literal in a representation that disagrees with the aggregate's numeric conversion and subsequent value consumption. Choose the DISTINCT numeric temporary field using the aggregate's type handler and metadata. Retain the existing temporary-table and Unique-based deduplication path. The regression evaluates SUM(DISTINCT b'1100') and checks the numeric result 12. Bug report: https://jira.mariadb.org/browse/MDEV-39194
DerZc
force-pushed
the
fix-mdev-39194
branch
from
September 21, 2026 06:03
5f94299 to
3634ec3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUM(DISTINCT b'1100') can produce a different numeric value from SUM(b'1100'), despite both aggregating the same bit literal. The DISTINCT expression should return 12.
Bug report: https://jira.mariadb.org/browse/MDEV-39194
Root cause
The DISTINCT temporary field is chosen from the argument's type handler and metadata. That can materialize a bit literal in a representation that disagrees with the aggregate's numeric conversion and subsequent value consumption.
Changes
Regression coverage
The regression evaluates SUM(DISTINCT b'1100') and checks the numeric result 12.
mysql-test/main/sum_distinct_bit_literal.resultmysql-test/main/sum_distinct_bit_literal.testValidation
On
11.4atd10e5d726799b1cd57cc866f40aad68c720803da:main.sum_distinct_bit_literalfailed on the unchanged target branch and passed with this fix.main.func_group,main.group_by,main.select,main.type_bit,main.type_bit_innodb,main.type_decimal,main.type_float.