Description:
Item::val_int(), Item::val_str() etc do not return execution status code. They return the value produced instead.
However evaluating the value can cause errors to be thrown.
The only way to currently check for these errors is to look at thread's diagnostic area (THD::is_error()).
This is cumbersome to do, probably slow (because of the method call) and easy to forget when coding.
As a result we have a lot of bugs like e.g. Bug#46175, Bug#39022 etc.
How to repeat:
Look at the code
Suggested fix:
Make Item::val_xxx() methods return status. We may follow MySQL's best coding practices here and make Item::val_xxx() return status code and use an output parameter to return the value.
Or if this is deemed to much of a change use output parameter to return the status.