summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bar@mysql.com/bar.intranet.mysql.r18.ru>2006-11-30 11:08:23 +0400
committerunknown <bar@mysql.com/bar.intranet.mysql.r18.ru>2006-11-30 11:08:23 +0400
commitfa46c80340e13c76bcab21d2eef9b5dd8f539a7e (patch)
tree7902bcc87fa67d48bce0393ddefb24a8af1bef62
parentd553728bfbf4ea4cbdf0532326c4873f4cdcae78 (diff)
downloadmariadb-git-fa46c80340e13c76bcab21d2eef9b5dd8f539a7e.tar.gz
Bug#24158 SET PASSWORD in binary log fails under ANSI_QUOTES
Problem: ``SET PASSWORD FOR foo@localhost'' was written into binary log using double quites: ``SET PASSWORD FOR "foo"@"localhost"...''. If sql_mode was set to ANSI_QUOTES, parser on slave considered "foo" and "localhost" as identifiers instead of strigns constants, so it failed to parse, generated syntax error and slave then stopped. Fix: changing binary log entries to use single quotes: ``SET PASSWORD FOR 'foo'@'localhost'...'' not to depend on ANSI_QUOTES. mysql-test/r/rpl_do_grant.result: Adding test case mysql-test/t/rpl_do_grant.test: Adding test case sql/sql_acl.cc: Using single quotes instead of double quotes, not to fails when sql_mode=ANSI_QUOTES.
-rw-r--r--mysql-test/r/rpl_do_grant.result11
-rw-r--r--mysql-test/t/rpl_do_grant.test16
-rw-r--r--sql/sql_acl.cc2
3 files changed, 28 insertions, 1 deletions
diff --git a/mysql-test/r/rpl_do_grant.result b/mysql-test/r/rpl_do_grant.result
index ff3e059503c..fe6ef3c26bc 100644
--- a/mysql-test/r/rpl_do_grant.result
+++ b/mysql-test/r/rpl_do_grant.result
@@ -20,6 +20,17 @@ set password for rpl_do_grant@localhost=password("does it work?");
select password<>_binary'' from mysql.user where user=_binary'rpl_do_grant';
password<>_binary''
1
+update mysql.user set password='' where user='rpl_do_grant';
+flush privileges;
+select password<>'' from mysql.user where user='rpl_do_grant';
+password<>''
+0
+set sql_mode='ANSI_QUOTES';
+set password for rpl_do_grant@localhost=password('does it work?');
+set sql_mode='';
+select password<>'' from mysql.user where user='rpl_do_grant';
+password<>''
+1
delete from mysql.user where user=_binary'rpl_do_grant';
delete from mysql.db where user=_binary'rpl_do_grant';
flush privileges;
diff --git a/mysql-test/t/rpl_do_grant.test b/mysql-test/t/rpl_do_grant.test
index 54287a67657..4a9c1554630 100644
--- a/mysql-test/t/rpl_do_grant.test
+++ b/mysql-test/t/rpl_do_grant.test
@@ -33,6 +33,22 @@ connection slave;
sync_with_master;
select password<>_binary'' from mysql.user where user=_binary'rpl_do_grant';
+#
+# Bug#24158 SET PASSWORD in binary log fails under ANSI_QUOTES
+#
+connection master;
+update mysql.user set password='' where user='rpl_do_grant';
+flush privileges;
+select password<>'' from mysql.user where user='rpl_do_grant';
+set sql_mode='ANSI_QUOTES';
+set password for rpl_do_grant@localhost=password('does it work?');
+set sql_mode='';
+save_master_pos;
+connection slave;
+sync_with_master;
+select password<>'' from mysql.user where user='rpl_do_grant';
+
+
# clear what we have done, to not influence other tests.
connection master;
delete from mysql.user where user=_binary'rpl_do_grant';
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 724cf88d373..be5591ce3d7 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1498,7 +1498,7 @@ bool change_password(THD *thd, const char *host, const char *user,
{
query_length=
my_sprintf(buff,
- (buff,"SET PASSWORD FOR \"%-.120s\"@\"%-.120s\"=\"%-.120s\"",
+ (buff,"SET PASSWORD FOR '%-.120s'@'%-.120s'='%-.120s'",
acl_user->user ? acl_user->user : "",
acl_user->host.hostname ? acl_user->host.hostname : "",
new_password));