YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
Diagnostics_area::Sql_condition_iterator it=
thd->get_stmt_da()->sql_conditions(); while ((err= it++))
{
String err_msg(msg_buf, sizeof(msg_buf), system_charset_info); /* set it to 0 or we start adding at the end. That's the trick ;) */
err_msg.length(0);
err_msg.append(prefix);
err_msg.append(err->get_message_text(),
err->get_message_octet_length(), system_charset_info);
DBUG_ASSERT(err->get_level() < 3);
(sql_print_message_handlers[err->get_level()])("%*s", err_msg.length(),
err_msg.c_ptr_safe());
}
DBUG_VOID_RETURN;
}
Event_scheduler::~Event_scheduler()
{
stop(); /* does nothing if not running */
mysql_mutex_destroy(&LOCK_scheduler_state);
mysql_cond_destroy(&COND_state);
}
/* This should not be marked with MY_THREAD_SPECIFIC */
scheduler_param_value=
(struct scheduler_param *)my_malloc(key_memory_Event_scheduler_scheduler_param, sizeof(struct scheduler_param), MYF(0));
scheduler_param_value->thd= new_thd;
scheduler_param_value->scheduler= this;
scheduler_thd= new_thd;
DBUG_PRINT("info", ("Setting state go RUNNING"));
state= RUNNING;
DBUG_PRINT("info", ("Forking new thread for scheduler. THD: %p", new_thd)); if ((*err_no= mysql_thread_create(key_thread_event_scheduler,
&th, &connection_attrib,
event_scheduler_thread,
(void*)scheduler_param_value)))
{
DBUG_PRINT("error", ("cannot create a new thread"));
sql_print_error("Event scheduler: Failed to start scheduler," " Can not create thread for event scheduler (errno=%d)",
*err_no);
bool
Event_scheduler::run(THD *thd)
{ int res= FALSE;
DBUG_ENTER("Event_scheduler::run");
if (global_system_variables.log_warnings)
sql_print_information("Event Scheduler: scheduler thread started with " "id %llu", (ulonglong) thd->thread_id); /* Recalculatethevaluesinthequeuebecausetherecouldhavebeenstops inexecutionsoftheschedulerandsometimescouldhavepassedby.
*/
queue->recalculate_activation_times(thd);
while (is_running())
{
Event_queue_element_for_exec *event_name;
/* Gets a minimized version */ if (queue->get_top_for_execution_if_time(thd, &event_name))
{
sql_print_error("Event Scheduler: Serious error during getting next " "event to execute. Stopping"); break;
}
DBUG_PRINT("info", ("get_top_for_execution_if_time returned " "event_name=%p", event_name)); if (event_name)
{ if ((res= execute_top(event_name))) break;
} else
{
DBUG_ASSERT(thd->killed);
DBUG_PRINT("info", ("job_data is NULL, the thread was killed"));
}
DBUG_PRINT("info", ("state=%s", scheduler_states_names[state].str));
free_root(thd->mem_root, MYF(0)); /* Ensure we don't have any open tables or table locks */
DBUG_ASSERT(thd->lock == 0);
}
LOCK_DATA();
scheduler_thd= NULL;
state= INITIALIZED;
DBUG_PRINT("info", ("Broadcasting COND_state back to the stoppers"));
mysql_cond_broadcast(&COND_state);
UNLOCK_DATA();
LOCK_DATA();
DBUG_PRINT("info", ("state before action %s", scheduler_states_names[state].str)); if (state != RUNNING)
{ /* Synchronously wait until the scheduler stops. */ while (state != INITIALIZED)
COND_STATE_WAIT(thd, NULL, &stage_waiting_for_scheduler_to_stop); goto end;
}
/* Guarantee we don't catch spurious signals */ do {
DBUG_PRINT("info", ("Waiting for COND_started_or_stopped from " "the scheduler thread. Current value of state is %s . " "workers count=%d", scheduler_states_names[state].str,
workers_count())); /* NOTE:Wedon'tusekill_one_thread()becauseitcan'tkillCOM_DEAMON threads.Inaddition,kill_one_thread()requiresTHDbutduringshutdown current_thdisNULL.Hence,ifkill_one_threadshouldbeusedithasto bemodifiedtokillalsodaemons,byaddingaflag,andalsowehaveto createartificialTHDhere.Tosaveallthiswork,wejustdowhat kill_one_thread()doestokillathread.Seealsosql_repl.ccforsimilar usage.
*/
state= STOPPING;
DBUG_PRINT("info", ("Scheduler thread has id %lu",
(ulong) scheduler_thd->thread_id)); /* This will wake up the thread if it waits on Queue's conditional */ if (global_system_variables.log_warnings)
sql_print_information("Event Scheduler: Killing the scheduler thread, " "thread id %llu",
(ulonglong) scheduler_thd->thread_id);
scheduler_thd->awake(KILL_CONNECTION);
/* thd could be 0x0, when shutting down */ if (global_system_variables.log_warnings > 1)
sql_print_information("Event Scheduler: " "Waiting for the scheduler thread to reply");
/* Waitonly2seconds,asthereisasmallchancethethreadmissedthe aboveawake()callandwemayhavetodoitagain
*/ struct timespec top_time;
set_timespec(top_time, 2);
COND_STATE_WAIT(thd, &top_time, &stage_waiting_for_scheduler_to_stop);
} while (state == STOPPING);
DBUG_PRINT("info", ("Scheduler thread has cleaned up. Set state to INIT")); if (global_system_variables.log_warnings)
sql_print_information("Event Scheduler: Stopped");
end:
UNLOCK_DATA();
DBUG_RETURN(FALSE);
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.16Bemerkung:
(vorverarbeitet am 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.