MDEV-39451 Accounting for truncation to value_max_length in the ntile comparison#5282
MDEV-39451 Accounting for truncation to value_max_length in the ntile comparison#5282mariadb-YuchenPei wants to merge 2 commits into
Conversation
|
|
There was a problem hiding this comment.
Code Review
This pull request addresses a division by zero exception in Item_sum_ntile::val_int (MDEV-39451) by using partition_row_count_ instead of get_row_count(), adding an assertion, and updating string length comparison in Cached_item_str::cmp_read_only(). It also adds corresponding test cases. Feedback was provided to improve code readability in sql/item_buff.cc by adding spaces around the assignment operator inside the if condition.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
ca61c89 to
18e01e8
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses a floating-point exception (division by zero) in Item_sum_ntile::val_int (MDEV-39451) by updating the logic to use partition_row_count_ instead of get_row_count(), and capping the string length in Cached_item_str::cmp_read_only(). A test case has also been added. The review feedback suggests enhancing the DBUG_ASSERT in Item_sum_ntile::val_int() to ensure current_row_count_ > 0 to prevent an underflow when evaluating (current_row_count_ - 1).
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Reduce function calls that just returns partition_row_count_ Add some assertions and explanations
18e01e8 to
b5085e1
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses a division by zero exception in Item_sum_ntile::val_int (MDEV-39451) by replacing get_row_count() with partition_row_count_ and adding safety assertions. It also updates Cached_item_str::cmp_read_only() to limit the string length. However, modifying the length of the returned String directly in cmp_read_only is dangerous as it can permanently truncate the string for other parts of the query execution; it is recommended to use a temporary String object instead.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
… comparison When truncation to value_max_length in ntile function happens, the cached string value is the truncated string. For the purpose of comparison to determine the size of the current partition, it should not compare the original string with the truncated string.
b5085e1 to
be5e6a5
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses a division by zero floating-point exception in Item_sum_ntile::val_int (MDEV-39451). It updates Cached_item_str::cmp_read_only to safely copy and limit the string length using value_max_length before comparison. Additionally, it refactors Item_sum_ntile::val_int to use partition_row_count_ instead of get_row_count(), adds assertions to ensure the current row count is valid, and includes a test case to verify the fix. As there are no review comments, no further feedback is provided.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
When truncation to value_max_length in ntile function happens, the
cached string value is the truncated string. For the purpose of
comparison to determine the size of the current partition, it should
not compare the original string with the truncated string.