Bug #20159 Inconsistant generation of generic error messages
Submitted: 30 May 2006 23:13 Modified: 3 Aug 2006 17:46
Reporter: Hartmut Holzgraefe Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1 and later OS:Any (*)
Assigned to: Magnus Blåudd CPU Architecture:Any

[30 May 2006 23:13] Hartmut Holzgraefe
Description:
At the end of   void handler::print_error(int error, myf errflag)
we have the following code for generic error conditions not
handled by any previous case in that member function:

     if (!str.is_empty())
      {
        const char* engine= table_type();
        if (temporary)
          my_error(ER_GET_TEMPORARY_ERRMSG, MYF(0), error, str.ptr(), engine);
        else
          my_error(ER_GET_ERRMSG, MYF(0), error, str.ptr(), engine);
      }
      else
        my_error(ER_GET_ERRNO,errflag,error);

with the format strings for these error codes being

  ER_GET_ERRNO               "Got error %d from storage engine"
  ER_GET_ERRMSG              "Got error %d '%-.100s' from %s"
  ER_GET_TEMPORARY_ERRMSG "Got temporary error %d '%-.100s' from %s"

Why is "storage engine" hardcoded for the ER_GET_ERRNO case while the two 
cases where a message string is given use the actual storage engine name?

And why do we have code like this in sql/sql_udf.cc?

  if (error > 0)
    sql_print_error(ER(ER_GET_ERRNO), my_errno);

this would emit a "Got error ... from storage engine", too,
although the error is not storage engine related at all

How to repeat:
see source code

Suggested fix:
move engine name detection out of the if() block,
add it as additional parameter to the my_error(ER_GET_ERRNO) call
and change the ER_GET_ERRNO format string to "Got error %d from %s"
plus check all other use cases of ER_GET_ERRNO
 
    const char* engine= table_type();
     if (!str.is_empty())
      {
        if (temporary)
          my_error(ER_GET_TEMPORARY_ERRMSG, MYF(0), error, str.ptr(), engine);
        else
          my_error(ER_GET_ERRMSG, MYF(0), error, str.ptr(), engine);
      }
      else
        my_error(ER_GET_ERRNO,errflag,error, engine);
[31 May 2006 4:39] Valeriy Kravchuk
Thank you for a problem report.
[7 Jun 2006 12:07] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/7351
[20 Jul 2006 11:40] Magnus Blåudd
Pushed to 5.0.25
[3 Aug 2006 16:44] Magnus Blåudd
Pushed to 5.0.25
[3 Aug 2006 17:46] Paul DuBois
No changelog entry needed.
[14 Aug 2006 20:40] Konstantin Osipov
Merged into 5.1.12