server
server copied to clipboard
MDEV-33010 Condition with CHARSET()/COERCIBILITY() erroneously pushed…
… into derived table
Based on the current logic, objects of classes Item_func_charset and Item_func_coercibility (responsible for CHARSET() and COERCIBILITY() functions) are always considered const. However, SQL syntax allows their use in a non-constant manner, such as CHARSET(t1.a), COERCIBILITY(t1.a), and similar.
This "const-forcing" was introduced with commit aa1002a35cefcc1851cbfb6b6b60463bda6f9aa3.
When those objects are erroneously deemed const, it could lead to unwanted consequences like pushing down conditions to materialized derived tables illegitimately.
This commits removes the "const-forcing" for Item_func_charset and Item_func_coercibility, making them determine their constness in the general way
- [x] The Jira issue number for this PR is: MDEV-_33010
Release Notes
TODO: What should the release notes say about this change? Include any changed system variables, status variables or behaviour. Optionally list any https://mariadb.com/kb/ pages that need changing.
How can this PR be tested?
TODO: modify the automated test suite to verify that the PR causes MariaDB to behave as intended. Consult the documentation on "Writing good test cases".
If the changes are not amenable to automated testing, please explain why not and carefully describe how to test manually.
Basing the PR against the correct MariaDB version
- [ ] This is a new feature and the PR is based against the latest MariaDB development branch.
- [x] This is a bug fix and the PR is based against the earliest maintained branch in which the bug can be reproduced.
PR quality check
- [x] I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
- [x] For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.
Good catch, the fix makes sense and the accompanying test seems to accurately depict the scenario you are describing in your description.
Another solution has been pushed. @abarkov, @sanja-byelkin , can you please review it?