summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <Li-Bing.Song@sun.com>2010-03-28 16:37:47 +0800
committerunknown <Li-Bing.Song@sun.com>2010-03-28 16:37:47 +0800
commit4775601012f81655643667d8635e46de120be7ae (patch)
treea813ba865f4d9d6b86ee3aa123046c8d65544830
parent604ab4d274ab036acd1725707b436836e98699a0 (diff)
downloadmariadb-git-4775601012f81655643667d8635e46de120be7ae.tar.gz
Bug #50095 Multi statement including CREATE EVENT causes rotten binlog entry
The log event of 'CREATE EVENT' was being binlogged with garbage at the end of the query if 'CREATE EVENT' is followed by another SQL statement and they were executed as one command. for example: DELIMITER |; CREATE EVENT e1 ON EVERY DAY DO SELECT 1; SELECT 'a'; DELIMITER ;| When binlogging 'CREATE EVENT', we always create a new statement with definer and write it into the log event. The new statement is made from cpp_buf(preprocessed buffer). which is not a c string(end with '\0'), but it is copied as a c string. In this patch, cpp_buf is copied with its length.
-rw-r--r--mysql-test/suite/rpl/r/rpl_events.result10
-rw-r--r--mysql-test/suite/rpl/t/rpl_events.test6
-rw-r--r--sql/events.cc4
-rw-r--r--sql/sql_lex.h1
4 files changed, 18 insertions, 3 deletions
diff --git a/mysql-test/suite/rpl/r/rpl_events.result b/mysql-test/suite/rpl/r/rpl_events.result
index b3fd85d7e28..b724d284bfa 100644
--- a/mysql-test/suite/rpl/r/rpl_events.result
+++ b/mysql-test/suite/rpl/r/rpl_events.result
@@ -208,8 +208,14 @@ CREATE /*!50000 DEFINER='user44331' */ EVENT event44331_4
ON SCHEDULE AT CURRENT_TIMESTAMP
ON COMPLETION PRESERVE DISABLE
DO INSERT INTO test.t1 VALUES('event event44331_4 fired - DEFINER=user1');
-Warnings:
-Note 1449 The user specified as a definer ('user44331'@'%') does not exist
+# Test for bug#50095 Multi-statement including CREATE EVENT causes rotten
+# binlog entry
+SELECT 'ABC';
+SELECT '123'|
+ABC
+ABC
+123
+123
#on master
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_1';
diff --git a/mysql-test/suite/rpl/t/rpl_events.test b/mysql-test/suite/rpl/t/rpl_events.test
index 7720ad6658c..327ad9bf22c 100644
--- a/mysql-test/suite/rpl/t/rpl_events.test
+++ b/mysql-test/suite/rpl/t/rpl_events.test
@@ -69,10 +69,16 @@ CREATE DEFINER=CURRENT_USER() EVENT event44331_3
ON COMPLETION PRESERVE DISABLE
DO INSERT INTO test.t1 VALUES('event event44331_3 fired - DEFINER=CURRENT_USER() function');
+DELIMITER |;
CREATE /*!50000 DEFINER='user44331' */ EVENT event44331_4
ON SCHEDULE AT CURRENT_TIMESTAMP
ON COMPLETION PRESERVE DISABLE
DO INSERT INTO test.t1 VALUES('event event44331_4 fired - DEFINER=user1');
+# Test for bug#50095 Multi-statement including CREATE EVENT causes rotten
+# binlog entry
+ SELECT 'ABC';
+ SELECT '123'|
+DELIMITER ;|
--echo #on master
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
diff --git a/sql/events.cc b/sql/events.cc
index 4c6dd0f35d1..afae512c61d 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -362,7 +362,9 @@ create_query_string(THD *thd, String *buf)
/* Append definer */
append_definer(thd, buf, &(thd->lex->definer->user), &(thd->lex->definer->host));
/* Append the left part of thd->query after "DEFINER" part */
- if (buf->append(thd->lex->stmt_definition_begin))
+ if (buf->append(thd->lex->stmt_definition_begin,
+ thd->lex->stmt_definition_end -
+ thd->lex->stmt_definition_begin))
return 1;
return 0;
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 459878c03fc..54eefa22a59 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -1729,6 +1729,7 @@ typedef struct st_lex : public Query_tables_list
- CREATE TRIGGER (points to "TRIGGER");
- CREATE PROCEDURE (points to "PROCEDURE");
- CREATE FUNCTION (points to "FUNCTION" or "AGGREGATE");
+ - CREATE EVENT (points to "EVENT")
This pointer is required to add possibly omitted DEFINER-clause to the
DDL-statement before dumping it to the binlog.