Repository navigation
MDEV-10426 ANY_VALUE function - #5151
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements the ANY_VALUE() function by adding it to the client commands, defining the Item_func_any_value class (inheriting from Item_func_coalesce), and registering it in the function registry. Feedback on the changes points out a critical issue: because Item_func_any_value inherits from Item_func_coalesce, it will still trigger ONLY_FULL_GROUP_BY errors unless check_cols_in_group_by() is overridden to return false directly.
c6f6e73 to
9525ad3
Compare
Per Daniel Black's reference to PR MariaDB#5151 (copy_or_same() fix for ANY_VALUE), investigated whether the same gap exists for our BIT_AND/BIT_OR/BIT_XOR binary mode aggregates. Finding: no bug exists. Item_sum_or/Item_sum_and/Item_sum_xor already have correct copy_or_same() implementations that clone via the Item_sum_bit copy constructor, which properly deep-copies m_str_value and m_binary_bit_counters for each rollup level's independent accumulator. Verified WITH ROLLUP produces mathematically correct results for binary mode BIT_OR/BIT_AND/BIT_XOR (manually cross-checked byte by byte against expected values). Added Section 16 as permanent regression coverage for this previously-untested combination.
86dfc73 to
7660557
Compare
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for working on this. This is a preliminary review.
Please:
- squash your commits into one per feature. I guess one in your case?
- I'd also consider resolving the conflicts with the upstream branch sooner than later.
Is it okay if I save this step until the very end? In the case that I need to make further modifications during the review process, it would be helpful for me to retain the commit history |
e87743f to
cf74df9
Compare
gkodinov
left a comment
There was a problem hiding this comment.
Your test file fails on embedded. It looks like a test stability issue to me. Please rectify.
|
@gkodinov The test should be fixed now. I discovered that the output of ANY_VALUE as a window function is not guaranteed across multiple executions of the same test due to the way that rows are ordered within the temp table. The test has been stabilized by modifying the table used by the window function assertion to ensure that for each group, there exists only one unique value in the any_value column. |
gkodinov
left a comment
There was a problem hiding this comment.
LGTM as far as the preliminary review goes. Please work with your assigned reviewer on the final review.
One small thing: please consider squashing the commits to a reasonable minimum. One maybe? Could be done prior to merging too, as long as it's being done.
|
FYI: According to our development cycle all testing of features must be completed before 30 Apr, 30 Jul, 30 Nov and 31 Jan (approximate release dates). You might get comments from the tester before that date or your feature will be approved as is and merged. But it'll all likely happen closer to the release date, not right now. |
|
Just note: the work should not in such form in main tree pushed, commits should be reworked to present them not historically but functionally, most probably just one commit. |
f2fe757 to
f30e0dd
Compare
1da8edd to
6e878ad
Compare
Implement the ANY_VALUE function that, in a GROUP BY expression, returns any one of the rows as a result. This meets the aggregation requirements of sql_mode=ONLY_FULL_GROUP_BY. Completed as part of Google Summer of Code 2026. Corrected as part of testing: * MDEV-41138 Ensure ANY_VALUE not fully reserved * MDEV-41200 ANY_VALUE not marked BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION * MDEV-41202 ONLY_FULL_GROUP_BY silently bypassed for outer-correlated fields inside aggregate * MDEV-41400 Server is crashing in base_list::push_back/List<Item_field>::push_back
Item_sum_any_value::update_field can no-longer be a no-op and if there is a filter, we delegate this to the parent class to record the value of the aggregation otherwise it will have null value if the first value in the any_value(g) group results if it didn't mean the filter criteria. Review: Rex Johnston
Like MIN and MAX, ANY_VALUE can take a value from an index and will return the first non-NULL value.
…e_field When an early execution takes the Item_sum_any_value::add function the has_value gets set. If the execution plan changes for the second execution the update_field resulting in the has_value debug assertion being hit. Added a Item_sum_any_value::reset_field() to reset the has_value back to false so this test case is covered. Thanks Alice Sherepa for the well found test case and Rex Johnston for review.
6e878ad to
ef9d496
Compare
MDEV-10426: Add support for the MySQL
ANY_VALUE()function (SQL:2023 feature T626).