← Back to team overview

maria-developers team mailing list archive

Re: Rev 4029: MDEV-4856 SQL_ERROR_LOG shows 1146 errors which didnt appear in mysql client

 

Hi, Alexey!

On Feb 19, Alexey Botchkov wrote:
> Hi, Sergei.
> 
> > Could you, please remove that piece of fine creativity and
> > thd->clear_error() too and use the error handler instead?
> 
> There's one puzzle.
> This field is set here:
> sql_show.cc:4899 (get_schema_tables_record())
>    if (res || info_error)
>    {
>      /*
>        If an error was encountered, push a warning, set the TABLE COMMENT
>        column with the error text, and clear the error so that the operation
>        can continue.
>      */
>      const char *error= thd->is_error() ? thd->stmt_da->message() : "";
>      table->field[20]->store(error, strlen(error), cs);
> 
>      if (thd->is_error())
>      {
>        push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
>                     thd->stmt_da->sql_errno(), thd->stmt_da->message());
>        thd->clear_error();
>      }
>    }
> 
> As we're supposed to block that error with the Error_handler, the
> error message gets lost there and cannot be recovered later in the
> get_schema_tables_record.  So we either have stop showing the error
> message in that field, or we have to store it somewhere.
>
> The Error_handler looks like a good place to store that error message.
> But i can't figure out how to send it to the
> get_schema_tables_record() nicely.  Another place is the TABLE_LIST *
> parameter. Seems to be convenient for everything.  Though the
> TABLE_LIST structure will get even more polluted.

Error handler looks perfect - it could have a char[] buffer and remember
there the first error message for SHOW TABLES.

But I agree that it's difficult to reach from get_schema_tables_record().
One option would be to use

  THD::get_internal_handler()

it'll allow you to access the current error handler. The problem with
this solution - there's no easy way to verify that you've got an object
of the correct class. If someone has pushed another error handler after
you, this will crash.

Another solution could to have a char* pointer in THD or TABLE_LIST and
set it to point to this buffer. This will work even if there's another
handler on top of yours. But it'll need a pointer in THD or TABLE_LIST.

I'd probably use the THD::get_internal_handler() approach and a test
case for it (it'll make sure the calling convention is maintained).
Seems silly to add another member to THD or TABLE_LIST that are used
literally everywhere only to show an open table error in I_S.TABLES.

Regards,
Sergei



Follow ups

References