=== modified file 'sql/ha_ndbcluster_binlog.cc' --- sql/ha_ndbcluster_binlog.cc 2010-03-23 10:40:48 +0000 +++ sql/ha_ndbcluster_binlog.cc 2010-03-23 13:52:42 +0000 @@ -563,12 +563,43 @@ static int ndbcluster_reset_logs(THD *th static int ndbcluster_binlog_index_purge_file(THD *thd, const char *file) { - if (!ndb_binlog_running || thd->slave_thread) - return 0; - + THD * save_thd= thd; DBUG_ENTER("ndbcluster_binlog_index_purge_file"); DBUG_PRINT("enter", ("file: %s", file)); + if (!ndb_binlog_running) + DBUG_RETURN(0); + + /** + * This function really really needs a THD object, + * new/delete one if not available...yuck! + */ + if (thd == 0) + { + thd= new THD; /* note that contructor of THD uses DBUG_ */ + THD_CHECK_SENTRY(thd); + + thd->thread_id= 0; + thd->thread_stack= (char*) &save_thd; /* remember where our stack is */ + if (thd->store_globals()) + { + thd->cleanup(); + delete thd; + DBUG_RETURN(0); + } + lex_start(thd); + + thd->init_for_queries(); + thd->command= COM_DAEMON; + thd->system_thread= SYSTEM_THREAD_NDBCLUSTER_BINLOG; + thd->version= refresh_version; + thd->main_security_ctx.host_or_ip= ""; + thd->client_capabilities= 0; + thd->main_security_ctx.master_access= ~0; + thd->main_security_ctx.priv_user= 0; + thd->lex->start_transaction_opt= 0; + } + char buf[1024]; char *end= strmov(strmov(strmov(buf, "DELETE FROM " @@ -586,6 +617,12 @@ ndbcluster_binlog_index_purge_file(THD * thd->main_da.reset_diagnostics_area(); } + if (save_thd == 0) + { + thd->cleanup(); + delete thd; + } + DBUG_RETURN(0); } === modified file 'sql/handler.cc' --- sql/handler.cc 2010-03-12 10:36:52 +0000 +++ sql/handler.cc 2010-03-23 13:52:42 +0000 @@ -4031,7 +4031,7 @@ int ha_binlog_index_purge_file(THD *thd, { binlog_func_st bfn= {BFN_BINLOG_PURGE_FILE, (void *)file}; binlog_func_foreach(thd, &bfn); - if (thd->main_da.is_error()) + if (thd && thd->main_da.is_error()) return 1; return 0; }