Bug #38451 unreachable code in udf_handler::fix_fields
Submitted: 30 Jul 2008 10:20 Modified: 30 Jul 2008 13:21
Reporter: Roland Bouman Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: User-defined functions ( UDF ) Severity:S3 (Non-critical)
Version:5.1.26-rc OS:Any
Assigned to: CPU Architecture:Any

[30 Jul 2008 10:20] Roland Bouman
Description:
In item_func.cc is the declaration for udf_handler::fix_fields (lines: 2797..2968)

There are two places where the udf_handler::error member is tested, to see if the function should exit with an error:

    if ((error=(uchar) init(&initid, &f_args, init_msg_buff)))

(line 2942)

and

  if (error)

(line 2961)

AFAIKS there is no oportunity for udf_handler::error to be modified before line 2942 - neither is there such opportunity between lines 2942 .. 2961

The logical conclusion would be that the block at 2961..2966 is an unnecesary check whose insides will never be reached.

How to repeat:
Open Item_func.cc, reviw code

Suggested fix:
Remove code from item_func.cc, lines 2961..2966

  if (error)
  {
    my_error(ER_CANT_INITIALIZE_UDF, MYF(0),
             u_d->name.str, ER(ER_UNKNOWN_ERROR));
    DBUG_RETURN(TRUE);
  }
[30 Jul 2008 13:21] MySQL Verification Team
Thank you for the bug report.