Hi Luis,
Patch approved.
I don't have any comment related to this bug.
However, I think there are still problems related to how we handle
"GRANT..." and similar functions:
. user names are not properly escaped;
. most likely there are other DDLs that fail similarly.
Please, file a but report to handle both problems.
Cheers.
On 03/14/2011 03:03 PM, Luis Soares wrote:
> [This commit e-mail is a repeat.]
>
> #At file:///home/lsoares/Workspace/bzr/work/bugfixing/11827392/mysql-trunk/ based on
> revid:joerg.bruehe@stripped
>
> 3756 Luis Soares 2011-03-11
> Fix for BUG#11827392 (BUG#60082).
>
> Even though the CREATE USER statement fails, it still gets
> written to the binary log.
>
> We fix this by setting the flag some_users_created correctly
> inside mysql_create_users.
>
> modified:
> mysql-test/suite/rpl/r/rpl_grant.result
> mysql-test/suite/rpl/t/rpl_grant.test
> sql/sql_acl.cc
> === modified file 'mysql-test/suite/rpl/r/rpl_grant.result'
> --- a/mysql-test/suite/rpl/r/rpl_grant.result 2010-12-19 17:22:30 +0000
> +++ b/mysql-test/suite/rpl/r/rpl_grant.result 2011-03-11 19:16:12 +0000
> @@ -178,4 +178,9 @@ DROP FUNCTION b54866_f;
> DROP TABLE test.t2;
> DROP USER 'b54866_user'@'localhost';
> DROP DATABASE b54866;
> +include/rpl_reset.inc
> +CREATE USER foo IDENTIFIED WITH 'my_plugin';
> +ERROR HY000: Plugin 'my_plugin' is not loaded
> +# Search for occurrences of CREATE USER in the output from mysqlbinlog
> +- Occurrences: 0
> include/rpl_end.inc
>
> === modified file 'mysql-test/suite/rpl/t/rpl_grant.test'
> --- a/mysql-test/suite/rpl/t/rpl_grant.test 2010-12-19 17:22:30 +0000
> +++ b/mysql-test/suite/rpl/t/rpl_grant.test 2011-03-11 19:16:12 +0000
> @@ -242,4 +242,56 @@ DROP TABLE test.t2;
> --eval DROP DATABASE $dbname
> --sync_slave_with_master
>
> +#
> +# BUG#11827392: 60082: EVEN THOUGH IT FAILS, 'CREATE USER' STATEMENT SI STILL
> BINLOGGED.
> +#
> +
> +#
> +# The test case is based on the one included in the
> +# original report. It works as follows:
> +#
> +# 1. We issue a failing statement on the master
> +# 2. Then we synchronize the slave
> +# - this asserts that there is no side-effect
> +# on the replication stream
> +# 3. We then dump the contents of the binlog and
> +# search for the CREATE USER entry. There should
> +# not be any, so we print the # of entries found.
> +#
> +
> +--connection master
> +--source include/rpl_reset.inc
> +--connection master
> +
> +--error ER_PLUGIN_IS_NOT_LOADED
> +CREATE USER foo IDENTIFIED WITH 'my_plugin';
> +--sync_slave_with_master
> +
> +--connection master
> +
> +--disable_query_log
> +
> +--let $MYSQLD_DATADIR= `select @@datadir`
> +--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
> +--let $prefix=`SELECT UUID()`
> +--let $out_file=$MYSQLTEST_VARDIR/tmp/$prefix.out
> +--exec $MYSQL_BINLOG --verbose $MYSQLD_DATADIR/$binlog_file > $out_file
> +
> +--let OUTF=$out_file
> +
> +--enable_query_log
> +
> +--echo # Search for occurrences of CREATE USER in the output from mysqlbinlog
> +
> +perl;
> + use strict;
> + my $outf= $ENV{'OUTF'} or die "OUTF not set";
> + open(FILE, "$outf") or die("Unable to open $outf: $!\n");
> + my $count = () = grep(/create user 'foo'/gi,<FILE>);
> + print "- Occurrences: $count\n";
> + close(FILE);
> +EOF
> +
> +--remove_file $out_file
> +
> --source include/rpl_end.inc
>
> === modified file 'sql/sql_acl.cc'
> --- a/sql/sql_acl.cc 2011-03-09 20:54:55 +0000
> +++ b/sql/sql_acl.cc 2011-03-11 19:16:12 +0000
> @@ -6489,12 +6489,14 @@ bool mysql_create_user(THD *thd, List <L
> continue;
> }
>
> - some_users_created= TRUE;
> if (replace_user_table(thd, tables[0].table, *user_name, 0, 0, 1, 0))
> {
> append_user(&wrong_users, user_name, wrong_users.length() > 0);
> result= TRUE;
> + continue;
> }
> +
> + some_users_created= TRUE;
> }
>
> mysql_mutex_unlock(&acl_cache->lock);
>
>
>
>
>