diff options
author | Mayank Prasad <mayank.prasad@oracle.com> | 2011-05-18 20:10:01 +0530 |
---|---|---|
committer | Mayank Prasad <mayank.prasad@oracle.com> | 2011-05-18 20:10:01 +0530 |
commit | 55d3381cc7bdde44d7f040921e5df1d7c229b846 (patch) | |
tree | 4cce2b7b8458e61ce73aefc6a834029bf0860901 /libmysqld | |
parent | a7cd008e12875d21d37ae92ccbef50d87d4fbd35 (diff) | |
download | mariadb-git-55d3381cc7bdde44d7f040921e5df1d7c229b846.tar.gz |
Bug#11764633 : 57491: THD->MAIN_DA.IS_OK() ASSERT IN EMBEDDED
Issue:
While running embedded server, if client issues TEE command (\T foo/bar) and
"foo/bar" directory doesn't exist, it is suppose to give error. But it was
aborting. This was happening because wrong error handler was being called.
Solution:
Modified calls to correct error handler. In embedded server case, there are
two error handler (client and server) which are supposed to be called based
on which context code is in. If it is in client context, client error handler
should be called otherwise server.
Test case:
Test case automation is not possible as current (following) code doesn't
allow '\T' to be executed from command line (OR command read from a file):
[client/mysql.cc]
...
static int
com_tee(String *buffer __attribute__((unused)),
char *line __attribute__((unused)))
{
char file_name[FN_REFLEN], *end, *param;
if (status.batch) << THIS IS TRUE WHILE EXECUTING FROM COMMAND LINE.
return 0;
...
So, not adding test case in GA. WIll add a test case in mysql-trunk after
removing above code so that this could be properly tested before GA.
Diffstat (limited to 'libmysqld')
-rw-r--r-- | libmysqld/lib_sql.cc | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 778d4874ad4..b6da6172039 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -51,6 +51,23 @@ extern "C" void unireg_clear(int exit_code) DBUG_VOID_RETURN; } +/* + Wrapper error handler for embedded server 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) +{ + DBUG_ENTER("embedded_error_handler"); + + /* + If current_thd is 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): + my_message_no_curses(error, str, MyFlags)); +} /* Reads error information from the MYSQL_DATA and puts @@ -107,7 +124,8 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, 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 +165,9 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER) thd->profiling.finish_current_query(); #endif + +end: + thd->restore_globals(); return result; } @@ -525,7 +546,10 @@ int init_embedded_server(int argc, char **argv, char **groups) return 1; } - error_handler_hook = my_message_sql; + /* + set error_handler_hook to embedded_error_handler wrapper. + */ + error_handler_hook= embedded_error_handler; acl_error= 0; #ifndef NO_EMBEDDED_ACCESS_CHECKS |