From: Luís Soares Date: March 15 2010 1:15am Subject: Re: bzr commit into mysql-5.1-bugteam branch (Li-Bing.Song:3368) Bug#50095 List-Archive: http://lists.mysql.com/commits/103169 Message-Id: <1268615743.29113.49.camel@mobilos.lan> MIME-Version: 1.0 Content-Type: text/plain; CHARSET=US-ASCII Content-Transfer-Encoding: 7BIT Hi Li-bing, Nice Work. Please find my review comments below. STATUS ------ Approved. REQUIRED CHANGES ---------------- n/a REQUESTS -------- R1. Should the comments to the definition of stmt_definition_begin be updated to also include CREATE EVENT ? SUGGESTIONS ----------- n/a DETAILS ------- n/a On Wed, 2010-03-10 at 10:36 +0000, Li-Bing.Song@stripped wrote: > #At file:///home/anders/work/bzrwork/worktree3/mysql-5.1-bugteam/ based on revid:staale.smedseng@stripped > > 3368 Li-Bing.Song@stripped 2010-03-10 > 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. > > modified: > mysql-test/suite/rpl/r/rpl_events.result > mysql-test/suite/rpl/t/rpl_events.test > sql/events.cc > === modified file 'mysql-test/suite/rpl/r/rpl_events.result' > --- a/mysql-test/suite/rpl/r/rpl_events.result 2010-02-02 13:38:44 +0000 > +++ b/mysql-test/suite/rpl/r/rpl_events.result 2010-03-10 10:36:48 +0000 > @@ -208,8 +208,14 @@ CREATE /*!50000 DEFINER='user44331' */ E > 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'; > > === modified file 'mysql-test/suite/rpl/t/rpl_events.test' > --- a/mysql-test/suite/rpl/t/rpl_events.test 2010-02-02 13:38:44 +0000 > +++ b/mysql-test/suite/rpl/t/rpl_events.test 2010-03-10 10:36:48 +0000 > @@ -69,10 +69,16 @@ CREATE DEFINER=CURRENT_USER() EVENT even > 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 > > === modified file 'sql/events.cc' > --- a/sql/events.cc 2010-02-02 13:38:44 +0000 > +++ b/sql/events.cc 2010-03-10 10:36:48 +0000 > @@ -362,7 +362,9 @@ create_query_string(THD *thd, String *bu > /* 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; >