diff options
author | Sergei Golubchik <serg@mariadb.org> | 2017-03-06 19:34:22 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-03-10 18:21:27 +0100 |
commit | 0877eff4012ab1184112814a3492d23bf266f848 (patch) | |
tree | 1b34a6bbbd9c1e2d505a0806b85bdc521620083a /include/mysql | |
parent | 6305533de2fd38d43c149d4d7c847f65d68205c7 (diff) | |
download | mariadb-git-0877eff4012ab1184112814a3492d23bf266f848.tar.gz |
thd_rnd service
Diffstat (limited to 'include/mysql')
-rw-r--r-- | include/mysql/plugin_audit.h.pp | 6 | ||||
-rw-r--r-- | include/mysql/plugin_auth.h.pp | 6 | ||||
-rw-r--r-- | include/mysql/plugin_encryption.h.pp | 6 | ||||
-rw-r--r-- | include/mysql/plugin_ftparser.h.pp | 6 | ||||
-rw-r--r-- | include/mysql/plugin_password_validation.h.pp | 6 | ||||
-rw-r--r-- | include/mysql/service_thd_rnd.h | 62 | ||||
-rw-r--r-- | include/mysql/services.h | 1 |
7 files changed, 93 insertions, 0 deletions
diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index 309bae1a0b0..c74fa4bacb7 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -219,6 +219,12 @@ extern struct thd_autoinc_service_st { } *thd_autoinc_service; void thd_get_autoinc(const void* thd, unsigned long* off, unsigned long* inc); +extern struct thd_rnd_service_st { + double (*thd_rnd_ptr)(void* thd); + void (*thd_c_r_p_ptr)(void* thd, char *to, size_t length); +} *thd_rnd_service; +double thd_rnd(void* thd); +void thd_create_random_password(void* thd, char *to, size_t length); extern struct thd_error_context_service_st { const char *(*thd_get_error_message_func)(const void* thd); unsigned int (*thd_get_error_number_func)(const void* thd); diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index 63ad776314d..c3e90210dd6 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -219,6 +219,12 @@ extern struct thd_autoinc_service_st { } *thd_autoinc_service; void thd_get_autoinc(const void* thd, unsigned long* off, unsigned long* inc); +extern struct thd_rnd_service_st { + double (*thd_rnd_ptr)(void* thd); + void (*thd_c_r_p_ptr)(void* thd, char *to, size_t length); +} *thd_rnd_service; +double thd_rnd(void* thd); +void thd_create_random_password(void* thd, char *to, size_t length); extern struct thd_error_context_service_st { const char *(*thd_get_error_message_func)(const void* thd); unsigned int (*thd_get_error_number_func)(const void* thd); diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp index 86d4427bc03..3d027e58389 100644 --- a/include/mysql/plugin_encryption.h.pp +++ b/include/mysql/plugin_encryption.h.pp @@ -219,6 +219,12 @@ extern struct thd_autoinc_service_st { } *thd_autoinc_service; void thd_get_autoinc(const void* thd, unsigned long* off, unsigned long* inc); +extern struct thd_rnd_service_st { + double (*thd_rnd_ptr)(void* thd); + void (*thd_c_r_p_ptr)(void* thd, char *to, size_t length); +} *thd_rnd_service; +double thd_rnd(void* thd); +void thd_create_random_password(void* thd, char *to, size_t length); extern struct thd_error_context_service_st { const char *(*thd_get_error_message_func)(const void* thd); unsigned int (*thd_get_error_number_func)(const void* thd); diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index 595735f0cf5..44ac17fbc7b 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -219,6 +219,12 @@ extern struct thd_autoinc_service_st { } *thd_autoinc_service; void thd_get_autoinc(const void* thd, unsigned long* off, unsigned long* inc); +extern struct thd_rnd_service_st { + double (*thd_rnd_ptr)(void* thd); + void (*thd_c_r_p_ptr)(void* thd, char *to, size_t length); +} *thd_rnd_service; +double thd_rnd(void* thd); +void thd_create_random_password(void* thd, char *to, size_t length); extern struct thd_error_context_service_st { const char *(*thd_get_error_message_func)(const void* thd); unsigned int (*thd_get_error_number_func)(const void* thd); diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp index 23a56273e51..8851ae77b4a 100644 --- a/include/mysql/plugin_password_validation.h.pp +++ b/include/mysql/plugin_password_validation.h.pp @@ -219,6 +219,12 @@ extern struct thd_autoinc_service_st { } *thd_autoinc_service; void thd_get_autoinc(const void* thd, unsigned long* off, unsigned long* inc); +extern struct thd_rnd_service_st { + double (*thd_rnd_ptr)(void* thd); + void (*thd_c_r_p_ptr)(void* thd, char *to, size_t length); +} *thd_rnd_service; +double thd_rnd(void* thd); +void thd_create_random_password(void* thd, char *to, size_t length); extern struct thd_error_context_service_st { const char *(*thd_get_error_message_func)(const void* thd); unsigned int (*thd_get_error_number_func)(const void* thd); diff --git a/include/mysql/service_thd_rnd.h b/include/mysql/service_thd_rnd.h new file mode 100644 index 00000000000..21133c7889f --- /dev/null +++ b/include/mysql/service_thd_rnd.h @@ -0,0 +1,62 @@ +#ifndef MYSQL_SERVICE_THD_RND_INCLUDED +/* Copyright (C) 2017 MariaDB Corporation + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** + @file + This service provides access to the thd-local random number generator. + + It's preferrable over the global one, because concurrent threads + can generate random numbers without fighting each other over the access + to the shared rnd state. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef MYSQL_ABI_CHECK +#include <stdlib.h> +#endif + +extern struct thd_rnd_service_st { + double (*thd_rnd_ptr)(MYSQL_THD thd); + void (*thd_c_r_p_ptr)(MYSQL_THD thd, char *to, size_t length); +} *thd_rnd_service; + +#ifdef MYSQL_DYNAMIC_PLUGIN +#define thd_rnd(A) thd_rnd_service->thd_rnd_ptr(A) +#define thd_create_random_password(A,B,C) thd_rnd_service->thd_c_r_p_ptr(A,B,C) +#else + +double thd_rnd(MYSQL_THD thd); + +/** + 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 +*/ +void thd_create_random_password(MYSQL_THD thd, char *to, size_t length); + +#endif + +#ifdef __cplusplus +} +#endif + +#define MYSQL_SERVICE_THD_RND_INCLUDED +#endif diff --git a/include/mysql/services.h b/include/mysql/services.h index 3ba0ce6511c..6cb5f50dc82 100644 --- a/include/mysql/services.h +++ b/include/mysql/services.h @@ -32,6 +32,7 @@ extern "C" { #include <mysql/service_base64.h> #include <mysql/service_logger.h> #include <mysql/service_thd_autoinc.h> +#include <mysql/service_thd_rnd.h> #include <mysql/service_thd_error_context.h> #include <mysql/service_thd_specifics.h> #include <mysql/service_encryption.h> |