summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2016-12-21 20:11:14 +0100
committerOleksandr Byelkin <sanja@mariadb.com>2016-12-28 20:35:19 +0100
commit23cc1be270c7304963643947d8e5ab88f4e312ee (patch)
treec2b8d39a472df5f2188f9404254a78ef9202e941
parent283e9cf4cbb34e1325699707068ab72ec3accfff (diff)
downloadmariadb-git-23cc1be270c7304963643947d8e5ab88f4e312ee.tar.gz
MDEV-11584: GRANT inside an SP does not work well on 2nd execution
Allocate password hash in statment memory
-rw-r--r--mysql-test/r/sp.result10
-rw-r--r--mysql-test/t/sp.test14
-rw-r--r--sql/sql_acl.cc5
3 files changed, 29 insertions, 0 deletions
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 820701f844c..4142fc0b796 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -8032,3 +8032,13 @@ return 1;
end |
ERROR 0A000: Not allowed to return a result set from a function
drop table t1,t2;
+#
+# MDEV-11584: GRANT inside an SP does not work well on 2nd execution
+#
+CREATE PROCEDURE sp1()
+GRANT ALL PRIVILEGES ON *.* TO 'foo'@'%' IDENTIFIED BY 'pass';
+CALL sp1();
+CALL sp1();
+drop user 'foo'@'%';
+drop procedure sp1;
+#End of 10.1 tests
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index bcddbd6f97e..3034f34d763 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -9504,3 +9504,17 @@ end |
--delimiter ;
drop table t1,t2;
+
+--echo #
+--echo # MDEV-11584: GRANT inside an SP does not work well on 2nd execution
+--echo #
+
+CREATE PROCEDURE sp1()
+ GRANT ALL PRIVILEGES ON *.* TO 'foo'@'%' IDENTIFIED BY 'pass';
+CALL sp1();
+CALL sp1();
+drop user 'foo'@'%';
+drop procedure sp1;
+
+
+--echo #End of 10.1 tests
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 3f26bc2e08a..2accb3abc91 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1067,7 +1067,12 @@ static bool fix_lex_user(THD *thd, LEX_USER *user)
make_scramble= my_make_scrambled_password;
}
+ Query_arena *arena, backup;
+ arena= thd->activate_stmt_arena_if_needed(&backup);
char *buff= (char *) thd->alloc(scramble_length + 1);
+ if (arena)
+ thd->restore_active_arena(arena, &backup);
+
if (buff == NULL)
return true;
make_scramble(buff, user->pwtext.str, user->pwtext.length);