Skip to content

MDEV-10426 ANY_VALUE function#5151

Draft
jaeheonshim wants to merge 14 commits into
MariaDB:mainfrom
jaeheonshim:MDEV-10426-any-value
Draft

MDEV-10426 ANY_VALUE function#5151
jaeheonshim wants to merge 14 commits into
MariaDB:mainfrom
jaeheonshim:MDEV-10426-any-value

Conversation

@jaeheonshim

Copy link
Copy Markdown

MDEV-10426: Add support for the MySQL ANY_VALUE() function (SQL:2023 feature T626).

@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 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.

Comment thread sql/item_cmpfunc.h Outdated
@vuvova vuvova added the GSoC label Jun 1, 2026
@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Jun 1, 2026
… to non_agg_fields only if BOTH in_sum_func and in_any_value are false
…related subquery as long as it is aggregated
Under ONLY_FULL_GROUP_BY, a query that aggregated an outer column inside
a subquery was wrongly rejected. This is fixed in
Item_field::fix_outer_field by not appending the field to
select->join->non_agg_fields when thd->lex->in_sum_func is not null.

Furthermore, in Item_sum::check_sum_func, for all outer fields that are
not aggregated at their SELECT_LEX's nest level, we append these fields
to sel->join->non_agg_fields in order to ensure proper aggregation after
the Item_sum's nest_level is known.
@jaeheonshim jaeheonshim force-pushed the MDEV-10426-any-value branch from c6f6e73 to 9525ad3 Compare June 15, 2026 03:32
kjarir added a commit to kjarir/server that referenced this pull request Jun 22, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. GSoC

Development

Successfully merging this pull request may close these issues.

5 participants