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
11.8from
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
11.8from
11.8-MDEV-35920

Conversation

@pranavktiwari
Copy link
Copy Markdown

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.

Copy link
Copy Markdown

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

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
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
Author

Choose a reason for hiding this comment

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

done

…_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
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.

2 participants