mirror of
https://github.com/MariaDB/server.git
synced 2026-05-04 06:05:32 +02:00
Initail merge with MySQL 5.1 (XtraDB still needs to be merged)
Fixed up copyright messages.
This commit is contained in:
commit
a8d03ab235
837 changed files with 11276 additions and 4578 deletions
|
|
@ -1,4 +1,5 @@
|
|||
/* Copyright (C) 2004-2006 MySQL AB
|
||||
/*
|
||||
Copyright (c) 2005, 2011, Oracle and/or its affiliates.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -11,7 +12,8 @@
|
|||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "mysql_priv.h"
|
||||
#include "events.h"
|
||||
|
|
@ -369,6 +371,7 @@ create_query_string(THD *thd, String *buf)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a new event.
|
||||
|
||||
|
|
@ -389,8 +392,8 @@ bool
|
|||
Events::create_event(THD *thd, Event_parse_data *parse_data,
|
||||
bool if_not_exists)
|
||||
{
|
||||
int ret;
|
||||
bool save_binlog_row_based;
|
||||
bool ret;
|
||||
bool save_binlog_row_based, event_already_exists;
|
||||
DBUG_ENTER("Events::create_event");
|
||||
|
||||
/*
|
||||
|
|
@ -439,28 +442,32 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
|
|||
pthread_mutex_lock(&LOCK_event_metadata);
|
||||
|
||||
/* On error conditions my_error() is called so no need to handle here */
|
||||
if (!(ret= db_repository->create_event(thd, parse_data, if_not_exists)))
|
||||
if (!(ret= db_repository->create_event(thd, parse_data, if_not_exists,
|
||||
&event_already_exists)))
|
||||
{
|
||||
Event_queue_element *new_element;
|
||||
bool dropped= 0;
|
||||
|
||||
if (!(new_element= new Event_queue_element()))
|
||||
ret= TRUE; // OOM
|
||||
else if ((ret= db_repository->load_named_event(thd, parse_data->dbname,
|
||||
parse_data->name,
|
||||
new_element)))
|
||||
if (!event_already_exists)
|
||||
{
|
||||
if (!db_repository->drop_event(thd, parse_data->dbname, parse_data->name,
|
||||
TRUE))
|
||||
dropped= 1;
|
||||
delete new_element;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TODO: do not ignore the out parameter and a possible OOM error! */
|
||||
bool created;
|
||||
if (event_queue)
|
||||
event_queue->create_event(thd, new_element, &created);
|
||||
if (!(new_element= new Event_queue_element()))
|
||||
ret= TRUE; // OOM
|
||||
else if ((ret= db_repository->load_named_event(thd, parse_data->dbname,
|
||||
parse_data->name,
|
||||
new_element)))
|
||||
{
|
||||
if (!db_repository->drop_event(thd, parse_data->dbname,
|
||||
parse_data->name, TRUE))
|
||||
dropped= 1;
|
||||
delete new_element;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TODO: do not ignore the out parameter and a possible OOM error! */
|
||||
bool created;
|
||||
if (event_queue)
|
||||
event_queue->create_event(thd, new_element, &created);
|
||||
}
|
||||
}
|
||||
/*
|
||||
binlog the create event unless it's been successfully dropped
|
||||
|
|
@ -472,15 +479,19 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
|
|||
String log_query;
|
||||
if (create_query_string(thd, &log_query))
|
||||
{
|
||||
sql_print_error("Event Error: An error occurred while creating query string, "
|
||||
"before writing it into binary log.");
|
||||
/* Restore the state of binlog format */
|
||||
thd->current_stmt_binlog_row_based= save_binlog_row_based;
|
||||
DBUG_RETURN(TRUE);
|
||||
sql_print_error("Event Error: An error occurred while creating query "
|
||||
"string, before writing it into binary log.");
|
||||
ret= true;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
If the definer is not set or set to CURRENT_USER, the value
|
||||
of CURRENT_USER will be written into the binary log as the
|
||||
definer for the SQL thread.
|
||||
*/
|
||||
ret= write_bin_log(thd, TRUE, log_query.c_ptr(), log_query.length());
|
||||
}
|
||||
/* If the definer is not set or set to CURRENT_USER, the value of CURRENT_USER
|
||||
will be written into the binary log as the definer for the SQL thread. */
|
||||
ret= write_bin_log(thd, TRUE, log_query.c_ptr(), log_query.length());
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&LOCK_event_metadata);
|
||||
|
|
@ -546,7 +557,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
|
|||
!sortcmp_lex_string(parse_data->name, *new_name,
|
||||
system_charset_info))
|
||||
{
|
||||
my_error(ER_EVENT_SAME_NAME, MYF(0), parse_data->name.str);
|
||||
my_error(ER_EVENT_SAME_NAME, MYF(0));
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
|
|
@ -1153,7 +1164,7 @@ Events::switch_event_scheduler_state(enum_opt_event_scheduler new_state)
|
|||
|
||||
if (ret)
|
||||
{
|
||||
my_error(ER_EVENT_SET_VAR_ERROR, MYF(0));
|
||||
my_error(ER_EVENT_SET_VAR_ERROR, MYF(0), 0);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue