This task is a "cut the Gordian Knot" approach to solving the problem described in two comments here:
The idea is that as soon as range optimizer concludes that some for Item* (possibly inside an OR) we have produced a tree of type SEL_ARG::IMPOSSIBLE, that Item* should be removed from the WHERE condition.
The will solve the problem described in the above two comments, and also will open additional optimization possibilities.
Challenges to explore
- How does one remove Item* from the WHERE in a PS-safe way (call thd->change_item_tree() or ... ?)
- Do we need to do AND/OR flattening after such conversion?