summaryrefslogtreecommitdiff
path: root/sql/event_data_objects.cc
diff options
context:
space:
mode:
authorunknown <kostja@vajra.(none)>2007-04-13 23:53:05 -0400
committerunknown <kostja@vajra.(none)>2007-04-13 23:53:05 -0400
commitab59263b2496ffa37a37068996aa342b87ca422a (patch)
tree80a138b97ff91b9b6181aec552a578672c0ca8c8 /sql/event_data_objects.cc
parentc1b6e128ccae21cec31bf4f4a60594d0e13a13ea (diff)
downloadmariadb-git-ab59263b2496ffa37a37068996aa342b87ca422a.tar.gz
Fix rpl_events test failure in the runtime tree.
mysql-test/r/rpl_events.result: Now ON COMPLETION NOT PRESERVE events are also dropped on the slave, since DROP EVENT command that is invoked for all such commands gets invoked on the slave. sql/event_data_objects.cc: Fix the failing rpl_events test after the patch for Bug#27733. At the time Events::drop_event got invoked inside Event_job_data::execute() thd->query pointed to CREATE PROCEDURE statement. This statement was written to the binary log from inside Events::drop_event (under assumption that this is a DROP EVENT statement that needs to be replicated), and caused creation of this procedure on the slave (and a subsequent failure when a procedure with the same name already exist). The patch ensures that thd->query points at the right query text for DROP EVENT executed when dropping ON COMPLETION NOT PRESERVE events. sql/event_data_objects.h: Update a declaration. sql/events.cc: Change if () to an assert: thd->query now always points at a valid query.
Diffstat (limited to 'sql/event_data_objects.cc')
-rw-r--r--sql/event_data_objects.cc46
1 files changed, 43 insertions, 3 deletions
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index 19c902df4ba..7e62bb308b5 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -1792,6 +1792,33 @@ Event_job_data::construct_sp_sql(THD *thd, String *sp_sql)
}
+/**
+ Get DROP EVENT statement to binlog the drop of ON COMPLETION NOT
+ PRESERVE event.
+*/
+
+bool
+Event_job_data::construct_drop_event_sql(THD *thd, String *sp_sql)
+{
+ LEX_STRING buffer;
+ const uint STATIC_SQL_LENGTH= 14;
+
+ DBUG_ENTER("Event_job_data::construct_drop_event_sql");
+
+ buffer.length= STATIC_SQL_LENGTH + name.length*2 + dbname.length*2;
+ if (! (buffer.str= (char*) thd->alloc(buffer.length)))
+ DBUG_RETURN(TRUE);
+
+ sp_sql->set(buffer.str, buffer.length, system_charset_info);
+ sp_sql->length(0);
+
+ sp_sql->append(C_STRING_WITH_LEN("DROP EVENT "));
+ append_identifier(thd, sp_sql, dbname.str, dbname.length);
+ sp_sql->append('.');
+ append_identifier(thd, sp_sql, name.str, name.length);
+
+ DBUG_RETURN(thd->is_fatal_error);
+}
/**
Compiles and executes the event (the underlying sp_head object)
@@ -1804,7 +1831,9 @@ bool
Event_job_data::execute(THD *thd, bool drop)
{
String sp_sql;
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
Security_context event_sctx, *save_sctx= NULL;
+#endif
CHARSET_INFO *charset_connection;
List<Item> empty_item_list;
bool ret= TRUE;
@@ -1916,14 +1945,25 @@ Event_job_data::execute(THD *thd, bool drop)
end:
if (drop && !thd->is_fatal_error)
{
- sql_print_information("Event Scheduler: Dropping %s.%s",
- (const char *) dbname.str, (const char *) name.str);
/*
We must do it here since here we're under the right authentication
ID of the event definer.
*/
- if (Events::drop_event(thd, dbname, name, FALSE))
+ sql_print_information("Event Scheduler: Dropping %s.%s",
+ (const char *) dbname.str, (const char *) name.str);
+ /*
+ Construct a query for the binary log, to ensure the event is dropped
+ on the slave
+ */
+ if (construct_drop_event_sql(thd, &sp_sql))
ret= 1;
+ else
+ {
+ thd->query= sp_sql.c_ptr_safe();
+ thd->query_length= sp_sql.length();
+ if (Events::drop_event(thd, dbname, name, FALSE))
+ ret= 1;
+ }
}
if (thd->lex->sphead) /* NULL only if a parse error */
{