1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

thd_rnd service

This commit is contained in:
Sergei Golubchik
2017-03-06 19:34:22 +01:00
parent 6305533de2
commit 0877eff401
14 changed files with 148 additions and 4 deletions

View File

@@ -4475,6 +4475,28 @@ extern "C" int thd_is_connected(MYSQL_THD thd)
}
extern "C" double thd_rnd(MYSQL_THD thd)
{
return my_rnd(&thd->rand);
}
/**
Generate string of printable random characters of requested length.
@param to[out] Buffer for generation; must be at least length+1 bytes
long; result string is always null-terminated
@param length[in] How many random characters to put in buffer
*/
extern "C" void thd_create_random_password(MYSQL_THD thd,
char *to, size_t length)
{
for (char *end= to + length; to < end; to++)
*to= (char) (my_rnd(&thd->rand)*94 + 33);
*to= '\0';
}
#ifdef INNODB_COMPATIBILITY_HOOKS
extern "C" const struct charset_info_st *thd_charset(MYSQL_THD thd)
{