summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2021-03-06 12:31:02 +0100
committerSergei Golubchik <serg@mariadb.org>2021-03-08 15:00:45 +0100
commit9742cf42035b3bebd50bbefe787e316cd041bf01 (patch)
tree50d47a21daac5a6cb3b97c158828bb1d3bf079cf
parentcf1ca57e75de0a06349d13813146396c4b0e3a9d (diff)
downloadmariadb-git-9742cf42035b3bebd50bbefe787e316cd041bf01.tar.gz
MDEV-24668 debug assert on SET PASSWORD when binlog fails
don't use `result` both for an error status and to remember if the mutex was locked
-rw-r--r--mysql-test/suite/binlog/r/binlog_write_error.result6
-rw-r--r--mysql-test/suite/binlog/t/binlog_write_error.test3
-rw-r--r--mysql-test/suite/binlog_encryption/binlog_write_error.result6
-rw-r--r--sql/sql_acl.cc8
4 files changed, 19 insertions, 4 deletions
diff --git a/mysql-test/suite/binlog/r/binlog_write_error.result b/mysql-test/suite/binlog/r/binlog_write_error.result
index f37351770ac..2ee68465243 100644
--- a/mysql-test/suite/binlog/r/binlog_write_error.result
+++ b/mysql-test/suite/binlog/r/binlog_write_error.result
@@ -100,6 +100,12 @@ ERROR HY000: Error writing file 'master-bin' ((errno: #)
set @@global.debug_dbug = @saved_dbug;
set @saved_dbug = @@global.debug_dbug;
SET GLOBAL debug_dbug='d,injecting_fault_writing';
+SET PASSWORD FOR user1=PASSWORD('foobar');
+SET PASSWORD FOR user1=PASSWORD('foobar');
+ERROR HY000: Error writing file 'master-bin' ((errno: #)
+set @@global.debug_dbug = @saved_dbug;
+set @saved_dbug = @@global.debug_dbug;
+SET GLOBAL debug_dbug='d,injecting_fault_writing';
DROP USER user1;
DROP USER user1;
ERROR HY000: Error writing file 'master-bin' ((errno: #)
diff --git a/mysql-test/suite/binlog/t/binlog_write_error.test b/mysql-test/suite/binlog/t/binlog_write_error.test
index 1eccee31a9f..2c55173c2a1 100644
--- a/mysql-test/suite/binlog/t/binlog_write_error.test
+++ b/mysql-test/suite/binlog/t/binlog_write_error.test
@@ -75,5 +75,8 @@ source include/binlog_inject_error.inc;
let $query= REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1;
source include/binlog_inject_error.inc;
+let $query= SET PASSWORD FOR user1=PASSWORD('foobar');
+source include/binlog_inject_error.inc;
+
let $query= DROP USER user1;
source include/binlog_inject_error.inc;
diff --git a/mysql-test/suite/binlog_encryption/binlog_write_error.result b/mysql-test/suite/binlog_encryption/binlog_write_error.result
index f37351770ac..2ee68465243 100644
--- a/mysql-test/suite/binlog_encryption/binlog_write_error.result
+++ b/mysql-test/suite/binlog_encryption/binlog_write_error.result
@@ -100,6 +100,12 @@ ERROR HY000: Error writing file 'master-bin' ((errno: #)
set @@global.debug_dbug = @saved_dbug;
set @saved_dbug = @@global.debug_dbug;
SET GLOBAL debug_dbug='d,injecting_fault_writing';
+SET PASSWORD FOR user1=PASSWORD('foobar');
+SET PASSWORD FOR user1=PASSWORD('foobar');
+ERROR HY000: Error writing file 'master-bin' ((errno: #)
+set @@global.debug_dbug = @saved_dbug;
+set @saved_dbug = @@global.debug_dbug;
+SET GLOBAL debug_dbug='d,injecting_fault_writing';
DROP USER user1;
DROP USER user1;
ERROR HY000: Error writing file 'master-bin' ((errno: #)
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 85f4b178b36..b8c061456c8 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -3794,7 +3794,7 @@ bool change_password(THD *thd, LEX_USER *user)
char buff[512];
ulong query_length= 0;
enum_binlog_format save_binlog_format;
- int result=0;
+ bool result, acl_cache_is_locked= false;
ACL_USER *acl_user;
ACL_USER::AUTH auth;
const char *password_plugin= 0;
@@ -3819,7 +3819,7 @@ bool change_password(THD *thd, LEX_USER *user)
if ((result= tables.open_and_lock(thd, Table_user, TL_WRITE)))
DBUG_RETURN(result != 1);
- result= 1;
+ acl_cache_is_locked= 1;
mysql_mutex_lock(&acl_cache->lock);
if (!(acl_user= find_user_exact(user->host.str, user->user.str)))
@@ -3872,7 +3872,7 @@ bool change_password(THD *thd, LEX_USER *user)
acl_cache->clear(1); // Clear locked hostname cache
mysql_mutex_unlock(&acl_cache->lock);
- result= 0;
+ result= acl_cache_is_locked= 0;
if (mysql_bin_log.is_open())
{
query_length= sprintf(buff, "SET PASSWORD FOR '%-.120s'@'%-.120s'='%-.120s'",
@@ -3883,7 +3883,7 @@ bool change_password(THD *thd, LEX_USER *user)
FALSE, FALSE, FALSE, 0) > 0;
}
end:
- if (result)
+ if (acl_cache_is_locked)
mysql_mutex_unlock(&acl_cache->lock);
close_mysql_tables(thd);