MDEV-11584: GRANT inside an SP does not work well on 2nd execution

Allocate password hash in statment memory
This commit is contained in:
Oleksandr Byelkin 2016-12-21 20:11:14 +01:00
commit 23cc1be270
3 changed files with 29 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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);