Hi Mayank,
On 5/9/11 10:55 AM, Mayank Prasad wrote:
> [This commit e-mail is a repeat.]
>
> #At file:///home/mayank/mysql-tree/mydefects/5.1_11764633_3/ based on
> revid:karen.langford@stripped
>
> 3685 Mayank Prasad 2011-05-09
> Bug#11764633 : 57491: THD->MAIN_DA.IS_OK() ASSERT IN EMBEDDED
>
> Issue:
> TEE command '\T foo/bar' was aborting. This is because, foo/bar
> directory doesn't exist. To report this error, server error handler was
> invoked and diagnostic area was found not reset. So abort was happenning.
happenning -> happening. Anyway, I don't understand this remark. I
suggest you to focus on describing what was the problem from a user's
perspective, the origin of the problem and solution that was implemented.
> @ libmysqld/lib_sql.cc
> Added code to call client/server error handler based on in control is in
> client/server code respectively.
> @ sql/mysql_priv.h
> Added comments for THR_THD, THR_MALLOC keys.
> @ sql/sql_class.cc
> Function definition of new function restore_global to removes thread
> specific data from stack (which was stored in store global).
Break lines after 80 characters.
> @ sql/sql_class.h
> Function declaration of new function restore_global.
>
> modified:
> libmysqld/lib_sql.cc
> sql/mysql_priv.h
> sql/sql_class.cc
> sql/sql_class.h
> === modified file 'libmysqld/lib_sql.cc'
> --- a/libmysqld/lib_sql.cc 2009-12-18 18:44:24 +0000
> +++ b/libmysqld/lib_sql.cc 2011-05-09 10:17:49 +0000
> @@ -41,7 +41,17 @@ C_MODE_START
> extern unsigned int mysql_server_last_errno;
> extern char mysql_server_last_error[MYSQL_ERRMSG_SIZE];
> static my_bool emb_read_query_result(MYSQL *mysql);
> -
> +/*
> + Wrapper error handler to call client/server error handler based on whether
> + thread is in client/server context
> +*/
> +static int embedded_error_handler(uint error, const char *str, myf MyFlags);
> +/*
> + Pointer to client error handler. It gets assigned in init_embedded_server.
> + It is used to call client error handling routine in embedded_error_handler.
> +*/
> +static int (*client_error_handler_hook)(uint my_err, const char *str,
> + myf MyFlags);
>
> extern "C" void unireg_clear(int exit_code)
> {
> @@ -51,6 +61,23 @@ extern "C" void unireg_clear(int exit_co
> DBUG_VOID_RETURN;
> }
>
> +/*
> + Wrapper error handler for embedded server. Based on thread's state, call
> + the error handler accordingly.
> +*/
> +
> +int embedded_error_handler(uint error, const char *str, myf MyFlags)
> +{
> + DBUG_ENTER("embedded_error_handler");
> +
> + /*
> + If _current_thd() returns NULL, it means restore_global has been
> + called and thread is in client context, then call client error handler
> + else call server error handler.
> + */
> + DBUG_RETURN(_current_thd() ? my_message_sql(error, str, MyFlags):
> + client_error_handler_hook(error, str, MyFlags));
Use current_thd, not _current_thd.
What will be error_handler_hook
> +}
>
> /*
> Reads error information from the MYSQL_DATA and puts
> @@ -107,7 +134,8 @@ emb_advanced_command(MYSQL *mysql, enum
> if (mysql->status != MYSQL_STATUS_READY)
> {
> set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
> - return 1;
> + result= 1;
> + goto end;
> }
>
> /* Clear result variables */
> @@ -147,6 +175,9 @@ emb_advanced_command(MYSQL *mysql, enum
> #if defined(ENABLED_PROFILING)&& defined(COMMUNITY_SERVER)
> thd->profiling.finish_current_query();
> #endif
> +
> +end:
> + thd->restore_globals();
> return result;
> }
>
> @@ -525,7 +556,12 @@ int init_embedded_server(int argc, char
> return 1;
> }
>
> - error_handler_hook = my_message_sql;
> + /*
> + store the client error handler hook and set error handler to
> + embedded_error_handler_hook wrapper.
> + */
> + client_error_handler_hook= error_handler_hook;
Why use a hook at all? Simply invoke error_handler_hook directly from
embedded_error_handler.
Also, error_handler_hook will be pointing to what function?
Regards,
Davi