Bug #49892 Make Item::val_int/str/real/ return status code
Submitted: 23 Dec 2009 12:26
Reporter: Georgi Kodinov Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S4 (Feature request)
Version:4.1+ OS:Any
Assigned to: CPU Architecture:Any
Tags: reengineering

[23 Dec 2009 12:26] Georgi Kodinov
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.