Skip to content

MDEV-35920: Fix assertion failure "decimals == 0" in Item_func_mod::fix_length_and_dec_int#5079

Open
pranavktiwari wants to merge 1 commit into
10.11from
11.8-MDEV-35920
Open

MDEV-35920: Fix assertion failure "decimals == 0" in Item_func_mod::fix_length_and_dec_int#5079
pranavktiwari wants to merge 1 commit into
10.11from
11.8-MDEV-35920

Conversation

@pranavktiwari

@pranavktiwari pranavktiwari commented May 15, 2026

Copy link
Copy Markdown
Contributor

fixes MDEV-35920

Problem:

Hex hybrid literals (0x...) were incorrectly treated as string values
during hybrid expression aggregation (CASE/COALESCE/IF/LEAST/IFNULL).
This allowed NOT_FIXED_DEC to propagate into numeric contexts and
triggered an assertion failure in MOD(), which requires
decimals == 0 for integer arithmetic.

Cause:

Hybrid expression type aggregation preserved string semantics for hex
literals but did not enforce the integer properties expected in numeric
contexts. As a result, decimals remained NOT_FIXED_DEC instead of 0.

Fix:

Keep the existing string collation behavior for hex hybrid values while
enforcing numeric semantics by setting decimals = 0 and
unsigned_flag = true.

Add a regression test for MOD() using hex literals in hybrid
expressions.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a bug where hex hybrid types resulted in incorrect decimal values during arithmetic operations by introducing the aggregate_attributes_hex_hybrid method and updating the Type_handler_hex_hybrid class. Feedback suggests refactoring the new method to reuse existing logic and reduce duplication, updating the documentation for accuracy, and correcting the issue reference prefix in the test files.

Comment thread sql/sql_type.cc
Comment thread mysql-test/main/bug35920.test Outdated
@@ -0,0 +1,11 @@
--echo #
--echo # DEV-35920: Hex hybrid type causing invalid decimals in arithmetic context

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Typo in the issue reference: DEV-35920 should be MDEV-35920 to match the MariaDB Jira project prefix and the PR title.

--echo # MDEV-35920: Hex hybrid type causing invalid decimals in arithmetic context

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread mysql-test/main/bug35920.result Outdated
@@ -0,0 +1,15 @@
#
# DEV-35920: Hex hybrid type causing invalid decimals in arithmetic context

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Typo in the issue reference: DEV-35920 should be MDEV-35920.

# MDEV-35920: Hex hybrid type causing invalid decimals in arithmetic context

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@pranavktiwari pranavktiwari force-pushed the 11.8-MDEV-35920 branch 3 times, most recently from 82bb1bc to 6650a42 Compare May 18, 2026 10:48

@abarkov abarkov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok to push. Thanks.

…_length_and_dec_int

Hex hybrid literals (0x..) were incorrectly treated as string values during hybrid
expression aggregation (CASE/COALESCE/IF/LEAST/IFNULL), causing NOT_FIXED_DEC to
propagate into numeric contexts. This led to an assertion failure in MOD() which
requires decimals == 0 for integer arithmetic.

Fix ensures hex hybrid values retain string collation behavior but enforce numeric
semantics by setting decimals = 0 and unsigned_flag = true.

Add regression test for MOD() with hex in hybrid expressions
@pranavktiwari pranavktiwari changed the base branch from 11.8 to 10.11 June 18, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants