diff options
Diffstat (limited to 'plugin')
38 files changed, 395 insertions, 147 deletions
diff --git a/plugin/auth_dialog/CMakeLists.txt b/plugin/auth_dialog/CMakeLists.txt index d16007405dc..cdc961bb390 100644 --- a/plugin/auth_dialog/CMakeLists.txt +++ b/plugin/auth_dialog/CMakeLists.txt @@ -14,9 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -ADD_DEFINITIONS(-DNO_GET_TTY_PASSWORD) -IF(LIBDL) - SET(LLDL LINK_LIBRARIES dl) -ENDIF() -MYSQL_ADD_PLUGIN(dialog dialog.c ${CMAKE_SOURCE_DIR}/libmysql/get_password.c - MODULE_ONLY CLIENT ${LLDL} COMPONENT ClientPlugins) +# disabled in favor of libmariadb/plugins/auth/dialog.c +# +#MYSQL_ADD_PLUGIN(dialog dialog.c ${CMAKE_SOURCE_DIR}/libmysql/get_password.c +# MODULE_ONLY CLIENT COMPONENT ClientPlugins) diff --git a/plugin/auth_ed25519/server_ed25519.c b/plugin/auth_ed25519/server_ed25519.c index 7720a0a4074..8870c271b18 100644 --- a/plugin/auth_ed25519/server_ed25519.c +++ b/plugin/auth_ed25519/server_ed25519.c @@ -33,7 +33,6 @@ static int loaded= 0; static int auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) { - unsigned int i; int pkt_len; unsigned long nonce[CRYPTO_LONGS + NONCE_LONGS]; unsigned char *pkt, *reply= (unsigned char*)nonce; @@ -45,14 +44,14 @@ static int auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) return CR_AUTH_USER_CREDENTIALS; memcpy(pw, info->auth_string, PASSWORD_LEN); pw[PASSWORD_LEN]= '='; - if (base64_decode(pw, PASSWORD_LEN_BUF, pk, NULL, 0) != CRYPTO_PUBLICKEYBYTES) + if (my_base64_decode(pw, PASSWORD_LEN_BUF, pk, NULL, 0) != CRYPTO_PUBLICKEYBYTES) return CR_AUTH_USER_CREDENTIALS; info->password_used= PASSWORD_USED_YES; /* prepare random nonce */ - for (i=CRYPTO_LONGS; i < CRYPTO_LONGS + NONCE_LONGS; i++) - nonce[i]= thd_rnd(info->thd) * ~0UL; + if (my_random_bytes((unsigned char *)nonce, (int)sizeof(nonce))) + return CR_AUTH_USER_CREDENTIALS; /* send it */ if (vio->write_packet(vio, reply + CRYPTO_BYTES, NONCE_BYTES)) @@ -119,7 +118,7 @@ char *ed25519_password(UDF_INIT *initid __attribute__((unused)), *length= PASSWORD_LEN; crypto_sign_keypair(pk, (unsigned char*)args->args[0], args->lengths[0]); - base64_encode(pk, CRYPTO_PUBLICKEYBYTES, result); + my_base64_encode(pk, CRYPTO_PUBLICKEYBYTES, result); return result; } diff --git a/plugin/auth_examples/CMakeLists.txt b/plugin/auth_examples/CMakeLists.txt index d1152227eff..b5859f158d6 100644 --- a/plugin/auth_examples/CMakeLists.txt +++ b/plugin/auth_examples/CMakeLists.txt @@ -29,5 +29,8 @@ MYSQL_ADD_PLUGIN(qa_auth_client qa_auth_client.c MYSQL_ADD_PLUGIN(auth_0x0100 auth_0x0100.c MODULE_ONLY COMPONENT Test) -MYSQL_ADD_PLUGIN(mysql_clear_password clear_password_client.c - MODULE_ONLY CLIENT COMPONENT ClientPlugins) +# disabled in favor of +# libmariadb/plugins/auth/mariadb_cleartext.c +# +#MYSQL_ADD_PLUGIN(mysql_clear_password clear_password_client.c +# MODULE_ONLY CLIENT COMPONENT ClientPlugins) diff --git a/plugin/auth_examples/qa_auth_client.c b/plugin/auth_examples/qa_auth_client.c index a7ee2f83a39..2153ee71504 100644 --- a/plugin/auth_examples/qa_auth_client.c +++ b/plugin/auth_examples/qa_auth_client.c @@ -90,7 +90,7 @@ static int test_plugin_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) return CR_ERROR; /* send the reply to the server */ res= vio->write_packet(vio, (const unsigned char *) reply, - strlen(reply) + 1); + (int)strlen(reply) + 1); if (res) return CR_ERROR; diff --git a/plugin/auth_examples/qa_auth_interface.c b/plugin/auth_examples/qa_auth_interface.c index c9bc6c5aae4..5002330fb80 100644 --- a/plugin/auth_examples/qa_auth_interface.c +++ b/plugin/auth_examples/qa_auth_interface.c @@ -226,7 +226,7 @@ static int test_plugin_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) return CR_ERROR; /* send the reply to the server */ res= vio->write_packet(vio, (const unsigned char *) reply, - strlen(reply) + 1); + (int)strlen(reply) + 1); if (res) return CR_ERROR; diff --git a/plugin/auth_examples/test_plugin.c b/plugin/auth_examples/test_plugin.c index 2b20a8cb56c..8cc17894be4 100644 --- a/plugin/auth_examples/test_plugin.c +++ b/plugin/auth_examples/test_plugin.c @@ -205,7 +205,7 @@ static int test_plugin_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) return CR_ERROR; /* send the reply to the server */ res= vio->write_packet(vio, (const unsigned char *) reply, - strlen(reply) + 1); + (int)strlen(reply) + 1); if (res) return CR_ERROR; diff --git a/plugin/auth_gssapi/CMakeLists.txt b/plugin/auth_gssapi/CMakeLists.txt index 7d9e58e165f..d2f854c2918 100644 --- a/plugin/auth_gssapi/CMakeLists.txt +++ b/plugin/auth_gssapi/CMakeLists.txt @@ -38,8 +38,10 @@ MYSQL_ADD_PLUGIN(auth_gssapi server_plugin.cc ${GSSAPI_SERVER} ${GSSAPI_ERRMSG} COMPONENT gssapi-server MODULE_ONLY) -MYSQL_ADD_PLUGIN(auth_gssapi_client client_plugin.cc ${GSSAPI_CLIENT} ${GSSAPI_ERRMSG} - LINK_LIBRARIES ${GSSAPI_LIBS} - COMPONENT gssapi-client - CLIENT - MODULE_ONLY) +# disabled in favor of libmariadb/plugins/auth/auth_gssapi_client.c +# +#MYSQL_ADD_PLUGIN(auth_gssapi_client client_plugin.cc ${GSSAPI_CLIENT} ${GSSAPI_ERRMSG} +# LINK_LIBRARIES ${GSSAPI_LIBS COMPONENT ClientPlugins} +# COMPONENT gssapi-client +# CLIENT +# MODULE_ONLY) diff --git a/plugin/auth_gssapi/gssapi_server.cc b/plugin/auth_gssapi/gssapi_server.cc index 50c34ecc573..9197b3e06fc 100644 --- a/plugin/auth_gssapi/gssapi_server.cc +++ b/plugin/auth_gssapi/gssapi_server.cc @@ -44,21 +44,21 @@ static char* get_default_principal_name() if(krb5_init_context(&context)) { - my_printf_error(0, "GSSAPI plugin : krb5_init_context failed", + my_printf_error(1, "GSSAPI plugin : krb5_init_context failed", ME_ERROR_LOG | ME_WARNING); goto cleanup; } if (krb5_sname_to_principal(context, NULL, "mariadb", KRB5_NT_SRV_HST, &principal)) { - my_printf_error(0, "GSSAPI plugin : krb5_sname_to_principal failed", + my_printf_error(1, "GSSAPI plugin : krb5_sname_to_principal failed", ME_ERROR_LOG | ME_WARNING); goto cleanup; } if (krb5_unparse_name(context, principal, &unparsed_name)) { - my_printf_error(0, "GSSAPI plugin : krb5_unparse_name failed", + my_printf_error(1, "GSSAPI plugin : krb5_unparse_name failed", ME_ERROR_LOG | ME_WARNING); goto cleanup; } @@ -66,7 +66,7 @@ static char* get_default_principal_name() /* Check for entry in keytab */ if (krb5_kt_read_service_key(context, NULL, principal, 0, (krb5_enctype)0, &key)) { - my_printf_error(0, "GSSAPI plugin : default principal '%s' not found in keytab", + my_printf_error(1, "GSSAPI plugin : default principal '%s' not found in keytab", ME_ERROR_LOG | ME_WARNING, unparsed_name); goto cleanup; } @@ -104,7 +104,7 @@ int plugin_init() /* import service principal from plain text */ if(srv_principal_name && srv_principal_name[0]) { - my_printf_error(0, "GSSAPI plugin : using principal name '%s'", + my_printf_error(1, "GSSAPI plugin : using principal name '%s'", ME_ERROR_LOG | ME_NOTE, srv_principal_name); principal_name_buf.length= strlen(srv_principal_name); principal_name_buf.value= srv_principal_name; diff --git a/plugin/auth_gssapi/mysql-test/auth_gssapi/basic.result b/plugin/auth_gssapi/mysql-test/auth_gssapi/basic.result index dc5155fac8c..b7cf3d8e488 100644 --- a/plugin/auth_gssapi/mysql-test/auth_gssapi/basic.result +++ b/plugin/auth_gssapi/mysql-test/auth_gssapi/basic.result @@ -1,16 +1,24 @@ INSTALL SONAME 'auth_gssapi'; +Warnings: +Note 1105 SSPI: using principal name 'localhost', mech 'Negotiate' CREATE USER 'GSSAPI_SHORTNAME' IDENTIFIED WITH gssapi; +connect con1,localhost,$GSSAPI_SHORTNAME,,; SELECT USER(),CURRENT_USER(); USER() CURRENT_USER() GSSAPI_SHORTNAME@localhost GSSAPI_SHORTNAME@% +disconnect con1; +connection default; DROP USER 'GSSAPI_SHORTNAME'; CREATE USER nosuchuser IDENTIFIED WITH gssapi; ERROR 28000: GSSAPI name mismatch, requested 'nosuchuser', actual name 'GSSAPI_SHORTNAME' DROP USER nosuchuser; CREATE USER usr1 IDENTIFIED WITH gssapi as 'GSSAPI_FULLNAME'; +connect con1,localhost,usr1,,; SELECT USER(),CURRENT_USER(); USER() CURRENT_USER() usr1@localhost usr1@% +disconnect con1; +connection default; DROP USER usr1; CREATE USER nosuchuser IDENTIFIED WITH gssapi AS 'nosuchuser@EXAMPLE.COM'; ERROR 28000: GSSAPI name mismatch, requested 'nosuchuser@EXAMPLE.COM', actual name 'GSSAPI_FULLNAME' diff --git a/plugin/auth_gssapi/sspi_server.cc b/plugin/auth_gssapi/sspi_server.cc index d2c2ae7e4b9..44ab091771f 100644 --- a/plugin/auth_gssapi/sspi_server.cc +++ b/plugin/auth_gssapi/sspi_server.cc @@ -284,7 +284,7 @@ int plugin_init() { srv_principal_name= get_default_principal_name(); } - my_printf_error(0, "SSPI: using principal name '%s', mech '%s'", + my_printf_error(ER_UNKNOWN_ERROR, "SSPI: using principal name '%s', mech '%s'", ME_ERROR_LOG | ME_NOTE, srv_principal_name, srv_mech_name); ret = AcquireCredentialsHandle( diff --git a/plugin/auth_pipe/auth_pipe.c b/plugin/auth_pipe/auth_pipe.c index 20c33c07e84..a803653b31a 100644 --- a/plugin/auth_pipe/auth_pipe.c +++ b/plugin/auth_pipe/auth_pipe.c @@ -36,7 +36,7 @@ static int pipe_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) unsigned char *pkt; MYSQL_PLUGIN_VIO_INFO vio_info; char username[UNLEN + 1]; - size_t username_length; + DWORD username_length; int ret; /* no user name yet ? read the client handshake packet with the user name */ @@ -54,7 +54,7 @@ static int pipe_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) if (!ImpersonateNamedPipeClient(vio_info.handle)) return CR_ERROR; - username_length= sizeof(username) - 1; + username_length=UNLEN; ret= CR_ERROR; if (GetUserName(username, &username_length)) { diff --git a/plugin/aws_key_management/CMakeLists.txt b/plugin/aws_key_management/CMakeLists.txt index 9221b54ef7e..aa93fc3aa03 100644 --- a/plugin/aws_key_management/CMakeLists.txt +++ b/plugin/aws_key_management/CMakeLists.txt @@ -12,22 +12,12 @@ # Give message why the building this plugin is skipped (only if -DVERBOSE is defined) # or if plugin is explicitly requested to build. Then bail out. MACRO(SKIP_AWS_PLUGIN msg) - IF(VERBOSE OR "${PLUGIN_AWS_KEY_MANAGEMENT}" MATCHES "^(STATIC|DYNAMIC)$") - MESSAGE(STATUS "Can't build aws_key_management - ${msg}") - ENDIF() - IF(TARGET aws_key_management) - MESSAGE(FATAL_ERROR "Error configuring aws_key_management - aborting") - ENDIF() + MESSAGE_ONCE(SKIP_AWS_PLUGIN "Skip aws_key_management - ${msg}") RETURN() ENDMACRO() SET(CMAKE_CXX_STANDARD 11) -MYSQL_ADD_PLUGIN(aws_key_management aws_key_management_plugin.cc DISABLED - COMPONENT aws-key-management) -IF(NOT TARGET aws_key_management) - RETURN() -ENDIF() # This plugin needs recent C++ compilers (AWS C++ SDK header files are using C++11 features) SET(CXX11_FLAGS) @@ -124,13 +114,10 @@ ELSE() ENDFOREACH() # To be compatible with older cmake, we use older version of the SDK - # We increase the version for macs however, so the newest mac could built it. - IF(APPLE) - SET(GIT_TAG "1.0.100") - ELSEIF(_OPENSSL_VERSION VERSION_EQUAL "1.1") - SET(GIT_TAG "1.0.114") + IF(CMAKE_VERSION LESS "3.0") + SET(GIT_TAG "1.0.8") ELSE() - SET(GIT_TAG "1.0.8") + SET(GIT_TAG "1.2.11") ENDIF() SET(AWS_SDK_PATCH_COMMAND ) @@ -152,6 +139,7 @@ ELSE() "-DCMAKE_CXX_FLAGS_MINSIZEREL=${CMAKE_CXX_FLAGS_MINSIZEREL} ${PIC_FLAG}" ${EXTRA_SDK_CMAKE_FLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/aws_sdk_cpp + -DCMAKE_INSTALL_LIBDIR=lib TEST_COMMAND "" ) SET_TARGET_PROPERTIES(aws_sdk_cpp PROPERTIES EXCLUDE_FROM_ALL TRUE) @@ -175,5 +163,8 @@ IF(WIN32) ELSE() SET(AWS_CPP_SDK_DEPENDENCIES ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES} ${UUID_LIBRARIES}) ENDIF() +MYSQL_ADD_PLUGIN(aws_key_management aws_key_management_plugin.cc + LINK_LIBRARIES ${AWS_SDK_LIBS} ${AWS_CPP_SDK_DEPENDENCIES} + COMPONENT aws-key-management) + -TARGET_LINK_LIBRARIES(aws_key_management ${AWS_SDK_LIBS} ${AWS_CPP_SDK_DEPENDENCIES}) diff --git a/plugin/disks/mysql-test/disks/disks.result b/plugin/disks/mysql-test/disks/disks.result index bd6befc5e11..65b1127d479 100644 --- a/plugin/disks/mysql-test/disks/disks.result +++ b/plugin/disks/mysql-test/disks/disks.result @@ -3,9 +3,9 @@ Table Create Table DISKS CREATE TEMPORARY TABLE `DISKS` ( `Disk` varchar(4096) NOT NULL DEFAULT '', `Path` varchar(4096) NOT NULL DEFAULT '', - `Total` int(32) NOT NULL DEFAULT '0', - `Used` int(32) NOT NULL DEFAULT '0', - `Available` int(32) NOT NULL DEFAULT '0' + `Total` int(32) NOT NULL DEFAULT 0, + `Used` int(32) NOT NULL DEFAULT 0, + `Available` int(32) NOT NULL DEFAULT 0 ) ENGINE=MEMORY DEFAULT CHARSET=utf8 select sum(Total) > sum(Available), sum(Total)>sum(Used) from information_schema.disks; sum(Total) > sum(Available) sum(Total)>sum(Used) diff --git a/plugin/feedback/feedback.cc b/plugin/feedback/feedback.cc index bd433efa4d3..15a280f34bf 100644 --- a/plugin/feedback/feedback.cc +++ b/plugin/feedback/feedback.cc @@ -112,7 +112,7 @@ static COND* make_cond(THD *thd, TABLE_LIST *tables, LEX_STRING *filter) Item_field *fld= new (thd->mem_root) Item_field(thd, &nrc, db, table, field); Item_string *pattern= new (thd->mem_root) Item_string(thd, filter->str, - filter->length, cs); + (uint) filter->length, cs); Item_string *escape= new (thd->mem_root) Item_string(thd, "\\", 1, cs); if (!fld || !pattern || !escape) diff --git a/plugin/feedback/sender_thread.cc b/plugin/feedback/sender_thread.cc index d61e303e8b3..bcd10f6713f 100644 --- a/plugin/feedback/sender_thread.cc +++ b/plugin/feedback/sender_thread.cc @@ -89,9 +89,8 @@ static int prepare_for_fill(TABLE_LIST *tables) (every increment of global thread_id counts as a new connection in SHOW STATUS and we want to avoid skewing the statistics) */ - thd->thread_id= thd->variables.pseudo_thread_id= thd_thread_id; + thd->variables.pseudo_thread_id= thd->thread_id; mysql_mutex_lock(&LOCK_thread_count); - thread_count++; threads.append(thd); mysql_mutex_unlock(&LOCK_thread_count); thd->thread_stack= (char*) &tables; @@ -208,7 +207,7 @@ static void send_report(const char *when) SELECT * FROM INFORMATION_SCHEMA.FEEDBACK is doing, read and concatenate table data into a String. */ - if (!(thd= new THD())) + if (!(thd= new THD(thd_thread_id))) return; if (prepare_for_fill(&tables)) @@ -239,7 +238,7 @@ static void send_report(const char *when) Url *url= todo[i]; if (thd) // for nicer SHOW PROCESSLIST - thd->set_query(const_cast<char*>(url->url()), url->url_length()); + thd->set_query(const_cast<char*>(url->url()), (uint) url->url_length()); if (url->send(str.ptr(), str.length())) i++; @@ -263,8 +262,8 @@ ret: */ mysql_mutex_lock(&LOCK_thread_count); thd->set_status_var_init(); - thread_count--; thd->killed= KILL_CONNECTION; + thd->unlink(); mysql_cond_broadcast(&COND_thread_count); mysql_mutex_unlock(&LOCK_thread_count); delete thd; @@ -280,9 +279,7 @@ pthread_handler_t background_thread(void *arg __attribute__((unused))) if (my_thread_init()) return 0; - mysql_mutex_lock(&LOCK_thread_count); - thd_thread_id= thread_id++; - mysql_mutex_unlock(&LOCK_thread_count); + thd_thread_id= next_thread_id(); if (slept_ok(startup_interval)) { diff --git a/plugin/feedback/utils.cc b/plugin/feedback/utils.cc index 6da1b591652..b5b9d412f05 100644 --- a/plugin/feedback/utils.cc +++ b/plugin/feedback/utils.cc @@ -151,7 +151,7 @@ namespace feedback { */ #define INSERT2(NAME,LEN,VALUE) \ do { \ - table->field[0]->store(NAME, LEN, system_charset_info); \ + table->field[0]->store(NAME, (uint) LEN, system_charset_info); \ table->field[1]->store VALUE; \ if (schema_table_store_record(thd, table)) \ return 1; \ @@ -159,7 +159,7 @@ namespace feedback { #define INSERT1(NAME,VALUE) \ do { \ - table->field[0]->store(NAME, sizeof(NAME)-1, system_charset_info); \ + table->field[0]->store(NAME, (uint) sizeof(NAME)-1, system_charset_info); \ table->field[1]->store VALUE; \ if (schema_table_store_record(thd, table)) \ return 1; \ @@ -186,7 +186,7 @@ static my_bool show_plugins(THD *thd, plugin_ref plugin, void *arg) (plugin_decl(plugin)->version) & 0xff); INSERT2(name, name_len, - (version, version_len, system_charset_info)); + (version, (uint)version_len, system_charset_info)); name_len= my_snprintf(name, sizeof(name), "%s used", plugin_name(plugin)->str); @@ -358,10 +358,10 @@ int fill_linux_info(THD *thd, TABLE_LIST *tables) #ifdef HAVE_SYS_UTSNAME_H if (have_ubuf) { - INSERT1("Uname_sysname", (ubuf.sysname, strlen(ubuf.sysname), cs)); - INSERT1("Uname_release", (ubuf.release, strlen(ubuf.release), cs)); - INSERT1("Uname_version", (ubuf.version, strlen(ubuf.version), cs)); - INSERT1("Uname_machine", (ubuf.machine, strlen(ubuf.machine), cs)); + INSERT1("Uname_sysname", (ubuf.sysname, (uint) strlen(ubuf.sysname), cs)); + INSERT1("Uname_release", (ubuf.release, (uint) strlen(ubuf.release), cs)); + INSERT1("Uname_version", (ubuf.version, (uint) strlen(ubuf.version), cs)); + INSERT1("Uname_machine", (ubuf.machine, (uint) strlen(ubuf.machine), cs)); } #endif @@ -428,8 +428,8 @@ int calculate_server_uid(char *dest) my_sha1((uint8*) shabuf, (char*) rawbuf, sizeof(rawbuf)); - assert(base64_needed_encoded_length(sizeof(shabuf)) <= SERVER_UID_SIZE); - base64_encode(shabuf, sizeof(shabuf), dest); + assert(my_base64_needed_encoded_length(sizeof(shabuf)) <= SERVER_UID_SIZE); + my_base64_encode(shabuf, sizeof(shabuf), dest); return 0; } diff --git a/plugin/file_key_management/file_key_management_plugin.cc b/plugin/file_key_management/file_key_management_plugin.cc index f6f7083d5f7..141599c53de 100644 --- a/plugin/file_key_management/file_key_management_plugin.cc +++ b/plugin/file_key_management/file_key_management_plugin.cc @@ -179,6 +179,12 @@ static int file_key_management_plugin_init(void *p) return parser.parse(&keys); } +static int file_key_management_plugin_deinit(void *p) +{ + keys.clear(); + return 0; +} + /* Plugin library descriptor */ @@ -191,7 +197,7 @@ maria_declare_plugin(file_key_management) "File-based key management plugin", PLUGIN_LICENSE_GPL, file_key_management_plugin_init, - NULL, + file_key_management_plugin_deinit, 0x0100 /* 1.0 */, NULL, /* status variables */ settings, diff --git a/plugin/file_key_management/parser.cc b/plugin/file_key_management/parser.cc index ac78186a488..4700788bf83 100644 --- a/plugin/file_key_management/parser.cc +++ b/plugin/file_key_management/parser.cc @@ -230,9 +230,9 @@ bool Parser::parse_file(std::map<uint,keyentry> *keys, const char *secret) return 0; } -void Parser::report_error(const char *reason, uint position) +void Parser::report_error(const char *reason, size_t position) { - my_printf_error(EE_READ, "%s at %s line %u, column %u", + my_printf_error(EE_READ, "%s at %s line %u, column %zu", ME_ERROR_LOG, reason, filename, line_number, position + 1); } diff --git a/plugin/file_key_management/parser.h b/plugin/file_key_management/parser.h index 627b7fd84a6..044be0f5b95 100644 --- a/plugin/file_key_management/parser.h +++ b/plugin/file_key_management/parser.h @@ -23,6 +23,7 @@ Created 09/15/2014 #include <my_crypt.h> #include <ctype.h> #include <map> +#include <stdlib.h> /* size_t */ struct keyentry { unsigned int id; @@ -43,7 +44,7 @@ class Parser unsigned char *key, unsigned char *iv); bool read_filekey(const char *filekey, char *secret); bool parse_file(std::map<unsigned int ,keyentry> *keys, const char *secret); - void report_error(const char *reason, unsigned int position); + void report_error(const char *reason, size_t position); int parse_line(char **line_ptr, keyentry *key); char* read_and_decrypt_file(const char *secret); diff --git a/plugin/fulltext/plugin_example.c b/plugin/fulltext/plugin_example.c index 778918cb439..72d78db50f1 100644 --- a/plugin/fulltext/plugin_example.c +++ b/plugin/fulltext/plugin_example.c @@ -150,7 +150,7 @@ static void add_word(MYSQL_FTPARSER_PARAM *param, const char *word, size_t len) MYSQL_FTPARSER_BOOLEAN_INFO bool_info= { FT_TOKEN_WORD, 0, 0, 0, 0, ' ', 0 }; - param->mysql_add_word(param, word, len, &bool_info); + param->mysql_add_word(param, word, (int)len, &bool_info); } /* diff --git a/plugin/handler_socket/handlersocket/database.cpp b/plugin/handler_socket/handlersocket/database.cpp index b05b6384565..4292b826753 100644 --- a/plugin/handler_socket/handlersocket/database.cpp +++ b/plugin/handler_socket/handlersocket/database.cpp @@ -278,7 +278,7 @@ dbcontext::init_thread(const void *stack_bottom, volatile int& shutdown_flag) DBG_THR(fprintf(stderr, "HNDSOCK init thread\n")); { my_thread_init(); - thd = new THD; + thd = new THD(0); thd->thread_stack = (char *)stack_bottom; DBG_THR(fprintf(stderr, "thread_stack = %p sizeof(THD)=%zu sizeof(mtx)=%zu " @@ -309,11 +309,8 @@ dbcontext::init_thread(const void *stack_bottom, volatile int& shutdown_flag) DBG_THR(fprintf(stderr, "HNDSOCK x0 %p\n", thd)); } { - pthread_mutex_lock(&LOCK_thread_count); - thd->thread_id = thread_id++; - threads.append(thd); - ++thread_count; - pthread_mutex_unlock(&LOCK_thread_count); + thd->thread_id = next_thread_id(); + add_to_active_threads(thd); } DBG_THR(fprintf(stderr, "HNDSOCK init thread wsts\n")); @@ -350,7 +347,6 @@ dbcontext::term_thread() pthread_mutex_lock(&LOCK_thread_count); delete thd; thd = 0; - --thread_count; pthread_mutex_unlock(&LOCK_thread_count); my_thread_end(); } diff --git a/plugin/handler_socket/libhsclient/allocator.hpp b/plugin/handler_socket/libhsclient/allocator.hpp index 82ff51f00e7..dd3a28ba7bd 100644 --- a/plugin/handler_socket/libhsclient/allocator.hpp +++ b/plugin/handler_socket/libhsclient/allocator.hpp @@ -35,7 +35,7 @@ typedef std::allocator<int> allocator_type; #if 1 #define DENA_ALLOCA_ALLOCATE(typ, len) \ - static_cast<typ *>(alloca((len) * sizeof(typ))) + (typ *) alloca((len) * sizeof(typ)) #define DENA_ALLOCA_FREE(x) #else #define DENA_ALLOCA_ALLOCATE(typ, len) \ diff --git a/plugin/metadata_lock_info/metadata_lock_info.cc b/plugin/metadata_lock_info/metadata_lock_info.cc index 39ac390b0bd..a2e3667dbab 100644 --- a/plugin/metadata_lock_info/metadata_lock_info.cc +++ b/plugin/metadata_lock_info/metadata_lock_info.cc @@ -39,6 +39,7 @@ static const LEX_STRING metadata_lock_info_lock_mode[] = { { C_STRING_WITH_LEN("MDL_SHARED_READ") }, { C_STRING_WITH_LEN("MDL_SHARED_WRITE") }, { C_STRING_WITH_LEN("MDL_SHARED_UPGRADABLE") }, + { C_STRING_WITH_LEN("MDL_SHARED_READ_ONLY") }, { C_STRING_WITH_LEN("MDL_SHARED_NO_WRITE") }, { C_STRING_WITH_LEN("MDL_SHARED_NO_READ_WRITE") }, { C_STRING_WITH_LEN("MDL_EXCLUSIVE") }, diff --git a/plugin/qc_info/qc_info.cc b/plugin/qc_info/qc_info.cc index 1dcef004447..e36e490dec3 100644 --- a/plugin/qc_info/qc_info.cc +++ b/plugin/qc_info/qc_info.cc @@ -32,10 +32,11 @@ #define MYSQL_SERVER #endif -#include <sql_cache.h> +#include <my_global.h> #include <sql_parse.h> // check_global_access #include <sql_acl.h> // PROCESS_ACL #include <sql_class.h> // THD +#include <sql_cache.h> #include <table.h> // ST_SCHEMA_TABLE #include <set_var.h> // sql_mode_string_representation #include <tztime.h> diff --git a/plugin/query_response_time/mysql-test/query_response_time/basic.result b/plugin/query_response_time/mysql-test/query_response_time/basic.result index 11cc607df39..d2de1b23e5f 100644 --- a/plugin/query_response_time/mysql-test/query_response_time/basic.result +++ b/plugin/query_response_time/mysql-test/query_response_time/basic.result @@ -7,7 +7,7 @@ SHOW CREATE TABLE INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; Table Create Table QUERY_RESPONSE_TIME CREATE TEMPORARY TABLE `QUERY_RESPONSE_TIME` ( `TIME` varchar(14) NOT NULL DEFAULT '', - `COUNT` int(11) unsigned NOT NULL DEFAULT '0', + `COUNT` int(11) unsigned NOT NULL DEFAULT 0, `TOTAL` varchar(14) NOT NULL DEFAULT '' ) ENGINE=MEMORY DEFAULT CHARSET=utf8 SELECT PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_TYPE, PLUGIN_AUTHOR, PLUGIN_DESCRIPTION, PLUGIN_LICENSE, PLUGIN_MATURITY FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE 'query_response_time%';; diff --git a/plugin/query_response_time/query_response_time.cc b/plugin/query_response_time/query_response_time.cc index 10b9391d9da..5d6119d20ef 100644 --- a/plugin/query_response_time/query_response_time.cc +++ b/plugin/query_response_time/query_response_time.cc @@ -221,7 +221,7 @@ public: print_time(total, sizeof(total), TOTAL_STRING_FORMAT, this->total(i)); } fields[0]->store(time,strlen(time),system_charset_info); - fields[1]->store(this->count(i)); + fields[1]->store((longlong)this->count(i),true); fields[2]->store(total,strlen(total),system_charset_info); if (schema_table_store_record(thd, table)) { diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index b5f6e996b42..612e9e91515 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -24,6 +24,7 @@ #include <time.h> #include <string.h> #include <fcntl.h> +#include <assert.h> #ifndef _WIN32 #include <syslog.h> @@ -97,7 +98,7 @@ static void closelog() {} #define FLOGGER_NO_PSI /* How to access the pthread_mutex in mysql_mutex_t */ -#if defined(SAFE_MUTEX) || defined(MY_PTHREAD_FASTMUTEX) +#ifdef SAFE_MUTEX #define mysql_mutex_real_mutex(A) &(A)->m_mutex.mutex #else #define mysql_mutex_real_mutex(A) &(A)->m_mutex @@ -140,7 +141,7 @@ static size_t loc_write(File Filedes, const uchar *Buffer, size_t Count) { size_t writtenbytes; #ifdef _WIN32 - writtenbytes= my_win_write(Filedes, Buffer, Count); + writtenbytes= (size_t)_write(Filedes, Buffer, (unsigned int)Count); #else writtenbytes= write(Filedes, Buffer, Count); #endif @@ -154,10 +155,29 @@ static File loc_open(const char *FileName, int Flags) /* Special flags */ { File fd; -#if defined(_WIN32) - fd= my_win_open(FileName, Flags); +#ifdef _WIN32 + HANDLE h; + /* + We could just use _open() here. but prefer to open in unix-similar way + just like my_open() does it on Windows. + This gives atomic multiprocess-safe appends, and possibility to rename + or even delete file while it is open, and CRT lacks this features. + */ + assert(Flags == (O_APPEND | O_CREAT | O_WRONLY)); + h= CreateFile(FileName, FILE_APPEND_DATA, + FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, NULL, + OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (h == INVALID_HANDLE_VALUE) + { + fd= -1; + my_osmaperr(GetLastError()); + } + else + { + fd= _open_osfhandle((intptr)h, O_WRONLY|O_BINARY); + } #else - fd = open(FileName, Flags, my_umask); + fd= open(FileName, Flags, my_umask); #endif my_errno= errno; return fd; @@ -173,7 +193,7 @@ static int loc_close(File fd) err= close(fd); } while (err == -1 && errno == EINTR); #else - err= my_win_close(fd); + err= close(fd); #endif my_errno=errno; return err; @@ -203,32 +223,9 @@ static int loc_rename(const char *from, const char *to) } -static my_off_t loc_seek(File fd, my_off_t pos, int whence) -{ - os_off_t newpos= -1; -#ifdef _WIN32 - newpos= my_win_lseek(fd, pos, whence); -#else - newpos= lseek(fd, pos, whence); -#endif - if (newpos == (os_off_t) -1) - { - my_errno= errno; - return MY_FILEPOS_ERROR; - } - - return (my_off_t) newpos; -} - - static my_off_t loc_tell(File fd) { - os_off_t pos; -#if defined (HAVE_TELL) && !defined (_WIN32) - pos= tell(fd); -#else - pos= loc_seek(fd, 0L, MY_SEEK_CUR); -#endif + os_off_t pos= IF_WIN(_telli64(fd),lseek(fd, 0, SEEK_CUR)); if (pos == (os_off_t) -1) { my_errno= errno; @@ -303,7 +300,7 @@ static size_t big_buffer_alloced= 0; static unsigned int query_log_limit= 0; static char servhost[256]; -static size_t servhost_len; +static uint servhost_len; static char *syslog_ident; static char syslog_ident_buffer[128]= "mysql-server_auditing"; @@ -626,7 +623,7 @@ static void remove_blanks(char *user) struct user_name { - int name_len; + size_t name_len; char *name; }; @@ -661,7 +658,7 @@ static int cmp_users(const void *ia, const void *ib) { const struct user_name *a= (const struct user_name *) ia; const struct user_name *b= (const struct user_name *) ib; - int dl= a->name_len - b->name_len; + int dl= (int)(a->name_len - b->name_len); if (dl != 0) return dl; @@ -669,7 +666,7 @@ static int cmp_users(const void *ia, const void *ib) } -static char *coll_search(struct user_coll *c, const char *n, int len) +static char *coll_search(struct user_coll *c, const char *n, size_t len) { struct user_name un; struct user_name *found; @@ -681,7 +678,7 @@ static char *coll_search(struct user_coll *c, const char *n, int len) } -static int coll_insert(struct user_coll *c, char *n, int len) +static int coll_insert(struct user_coll *c, char *n, size_t len) { if (c->n_users >= c->n_alloced) { @@ -936,7 +933,7 @@ static void get_str_n(char *dest, int *dest_len, size_t dest_size, memcpy(dest, src, src_len); dest[src_len]= 0; - *dest_len= src_len; + *dest_len= (int)src_len; } @@ -1008,7 +1005,7 @@ static int start_logging() if (output_type == OUTPUT_FILE) { char alt_path_buffer[FN_REFLEN+1+DEFAULT_FILENAME_LEN]; - MY_STAT *f_stat; + struct stat *f_stat= (struct stat *)alt_path_buffer; const char *alt_fname= file_path; while (*alt_fname == ' ') @@ -1023,7 +1020,7 @@ static int start_logging() { /* See if the directory exists with the name of file_path. */ /* Log file name should be [file_path]/server_audit.log then. */ - if ((f_stat= my_stat(file_path, (MY_STAT *)alt_path_buffer, MYF(0))) && + if (stat(file_path, (struct stat *)alt_path_buffer) == 0 && S_ISDIR(f_stat->st_mode)) { size_t p_len= strlen(file_path); @@ -1251,12 +1248,12 @@ static void change_connection(struct connection_info *cn, event->ip, event->ip_length); } -static int write_log(const char *message, int len) +static int write_log(const char *message, size_t len) { if (output_type == OUTPUT_FILE) { if (logfile && - (is_active= (logger_write(logfile, message, len) == len))) + (is_active= (logger_write(logfile, message, len) == (int)len))) return 0; ++log_write_failures; return 1; @@ -1265,7 +1262,7 @@ static int write_log(const char *message, int len) { syslog(syslog_facility_codes[syslog_facility] | syslog_priority_codes[syslog_priority], - "%s %.*s", syslog_info, len, message); + "%s %.*s", syslog_info, (int)len, message); } return 0; } @@ -1449,7 +1446,7 @@ static size_t escape_string_hide_passwords(const char *str, unsigned int len, } next_s++; } - len-= next_s - str; + len-= (uint)(next_s - str); str= next_s; continue; } @@ -1763,9 +1760,9 @@ static int log_table(const struct connection_info *cn, (void) time(&ctime); csize= log_header(message, sizeof(message)-1, &ctime, servhost, servhost_len, - event->user, SAFE_STRLEN(event->user), - event->host, SAFE_STRLEN(event->host), - event->ip, SAFE_STRLEN(event->ip), + event->user, (unsigned int)SAFE_STRLEN(event->user), + event->host, (unsigned int)SAFE_STRLEN(event->host), + event->ip, (unsigned int)SAFE_STRLEN(event->ip), event->thread_id, cn->query_id, type); csize+= my_snprintf(message+csize, sizeof(message) - 1 - csize, ",%.*s,%.*s,",event->database_length, event->database, @@ -1785,9 +1782,9 @@ static int log_rename(const struct connection_info *cn, (void) time(&ctime); csize= log_header(message, sizeof(message)-1, &ctime, servhost, servhost_len, - event->user, SAFE_STRLEN(event->user), - event->host, SAFE_STRLEN(event->host), - event->ip, SAFE_STRLEN(event->ip), + event->user, (unsigned int)SAFE_STRLEN(event->user), + event->host, (unsigned int)SAFE_STRLEN(event->host), + event->ip, (unsigned int)SAFE_STRLEN(event->ip), event->thread_id, cn->query_id, "RENAME"); csize+= my_snprintf(message+csize, sizeof(message) - 1 - csize, ",%.*s,%.*s|%.*s.%.*s,",event->database_length, event->database, @@ -2368,7 +2365,7 @@ static int server_audit_init(void *p __attribute__((unused))) if (gethostname(servhost, sizeof(servhost))) strcpy(servhost, "unknown"); - servhost_len= strlen(servhost); + servhost_len= (uint)strlen(servhost); logger_init_mutexes(); #if defined(HAVE_PSI_INTERFACE) && !defined(FLOGGER_NO_PSI) diff --git a/plugin/server_audit/test_audit_v4.c b/plugin/server_audit/test_audit_v4.c index ae7527f8449..85d45e35808 100644 --- a/plugin/server_audit/test_audit_v4.c +++ b/plugin/server_audit/test_audit_v4.c @@ -56,11 +56,11 @@ static int auditing_v4(MYSQL_THD thd, mysql_event_class_t class, const void *ev) ev_302.general_error_code= event->general_error_code; ev_302.general_thread_id= event->general_thread_id; ev_302.general_user= event->general_user.str; - ev_302.general_user_length= event->general_user.length; + ev_302.general_user_length= (unsigned int)event->general_user.length; ev_302.general_command= event->general_command.str; - ev_302.general_command_length= event->general_command.length; + ev_302.general_command_length= (unsigned int)event->general_command.length; ev_302.general_query= event->general_query.str; - ev_302.general_query_length= event->general_query.length; + ev_302.general_query_length= (unsigned int)event->general_query.length; ev_302.general_charset= event->general_charset; ev_302.general_time= event->general_time; ev_302.general_rows= event->general_rows; diff --git a/plugin/simple_password_check/simple_password_check.c b/plugin/simple_password_check/simple_password_check.c index f1c425b332c..977a7487b78 100644 --- a/plugin/simple_password_check/simple_password_check.c +++ b/plugin/simple_password_check/simple_password_check.c @@ -25,7 +25,7 @@ static unsigned min_length, min_digits, min_letters, min_others; static int validate(MYSQL_LEX_STRING *username, MYSQL_LEX_STRING *password) { - unsigned digits=0 , uppers=0 , lowers=0, others=0, length= password->length; + unsigned digits=0 , uppers=0 , lowers=0, others=0, length= (unsigned)password->length; const char *ptr= password->str, *end= ptr + length; if (strncmp(password->str, username->str, length) == 0) @@ -68,6 +68,7 @@ static void fix_min_length(MYSQL_THD thd __attribute__((unused)), } } + static MYSQL_SYSVAR_UINT(minimal_length, min_length, PLUGIN_VAR_RQCMDARG, "Minimal required password length", NULL, fix_min_length, 8, 0, 1000, 1); diff --git a/plugin/user_variables/CMakeLists.txt b/plugin/user_variables/CMakeLists.txt new file mode 100644 index 00000000000..6638a5cb622 --- /dev/null +++ b/plugin/user_variables/CMakeLists.txt @@ -0,0 +1,2 @@ +MYSQL_ADD_PLUGIN(user_variables user_variables.cc + DEFAULT RECOMPILE_FOR_EMBEDDED) diff --git a/plugin/user_variables/mysql-test/user_variables/basic.result b/plugin/user_variables/mysql-test/user_variables/basic.result new file mode 100644 index 00000000000..5650fa0dcce --- /dev/null +++ b/plugin/user_variables/mysql-test/user_variables/basic.result @@ -0,0 +1,63 @@ +SELECT PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_STATUS, PLUGIN_TYPE, PLUGIN_AUTHOR, PLUGIN_DESCRIPTION, PLUGIN_LICENSE, LOAD_OPTION, PLUGIN_MATURITY FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME='user_variables'; +PLUGIN_NAME user_variables +PLUGIN_VERSION 1.0 +PLUGIN_STATUS ACTIVE +PLUGIN_TYPE INFORMATION SCHEMA +PLUGIN_AUTHOR Sergey Vojtovich +PLUGIN_DESCRIPTION User-defined variables +PLUGIN_LICENSE GPL +LOAD_OPTION ON +PLUGIN_MATURITY Gamma +SHOW CREATE TABLE INFORMATION_SCHEMA.USER_VARIABLES; +Table Create Table +user_variables CREATE TEMPORARY TABLE `user_variables` ( + `VARIABLE_NAME` varchar(64) NOT NULL DEFAULT '', + `VARIABLE_VALUE` varchar(2048) DEFAULT NULL, + `VARIABLE_TYPE` varchar(64) NOT NULL DEFAULT '', + `CHARACTER_SET_NAME` varchar(32) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8 +FLUSH USER_VARIABLES; +SELECT COUNT(*) FROM INFORMATION_SCHEMA.USER_VARIABLES; +COUNT(*) +0 +SET @int_var=1; +SET @uint_var=CAST(2 AS UNSIGNED INTEGER); +SET @str_var='Value of string variable'; +SET @utf8str_var=_utf8 'UTF8 string value'; +SET @double_var=CAST(1 AS DOUBLE); +SET @dec_var=CAST(1 AS DECIMAL(20, 10)); +SET @time_var=CAST('2016-02-25' AS DATE); +SET @' @#^%'='Value of variable with odd name'; +SET @''='Value of variable with empty name'; +SET @null_var=NULL; +SELECT COUNT(*) FROM INFORMATION_SCHEMA.USER_VARIABLES; +COUNT(*) +10 +SELECT * FROM INFORMATION_SCHEMA.USER_VARIABLES ORDER BY VARIABLE_NAME; +VARIABLE_NAME VARIABLE_VALUE VARIABLE_TYPE CHARACTER_SET_NAME + Value of variable with empty name VARCHAR latin1 + @#^% Value of variable with odd name VARCHAR latin1 +dec_var 1.0000000000 DECIMAL latin1 +double_var 1 DOUBLE latin1 +int_var 1 INT latin1 +null_var NULL VARCHAR binary +str_var Value of string variable VARCHAR latin1 +time_var 2016-02-25 VARCHAR latin1 +uint_var 2 INT UNSIGNED latin1 +utf8str_var UTF8 string value VARCHAR utf8 +SHOW USER_VARIABLES; +Variable_name Value + Value of variable with empty name + @#^% Value of variable with odd name +dec_var 1.0000000000 +double_var 1 +int_var 1 +null_var NULL +str_var Value of string variable +time_var 2016-02-25 +uint_var 2 +utf8str_var UTF8 string value +FLUSH USER_VARIABLES; +SELECT COUNT(*) FROM INFORMATION_SCHEMA.USER_VARIABLES; +COUNT(*) +0 diff --git a/plugin/user_variables/mysql-test/user_variables/basic.test b/plugin/user_variables/mysql-test/user_variables/basic.test new file mode 100644 index 00000000000..7e67e4fa5af --- /dev/null +++ b/plugin/user_variables/mysql-test/user_variables/basic.test @@ -0,0 +1,24 @@ +query_vertical SELECT PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_STATUS, PLUGIN_TYPE, PLUGIN_AUTHOR, PLUGIN_DESCRIPTION, PLUGIN_LICENSE, LOAD_OPTION, PLUGIN_MATURITY FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME='user_variables'; +SHOW CREATE TABLE INFORMATION_SCHEMA.USER_VARIABLES; + +FLUSH USER_VARIABLES; +SELECT COUNT(*) FROM INFORMATION_SCHEMA.USER_VARIABLES; + +SET @int_var=1; +SET @uint_var=CAST(2 AS UNSIGNED INTEGER); +SET @str_var='Value of string variable'; +SET @utf8str_var=_utf8 'UTF8 string value'; +SET @double_var=CAST(1 AS DOUBLE); +SET @dec_var=CAST(1 AS DECIMAL(20, 10)); +SET @time_var=CAST('2016-02-25' AS DATE); +SET @' @#^%'='Value of variable with odd name'; +SET @''='Value of variable with empty name'; +SET @null_var=NULL; + +SELECT COUNT(*) FROM INFORMATION_SCHEMA.USER_VARIABLES; +SELECT * FROM INFORMATION_SCHEMA.USER_VARIABLES ORDER BY VARIABLE_NAME; +--sorted_result +SHOW USER_VARIABLES; + +FLUSH USER_VARIABLES; +SELECT COUNT(*) FROM INFORMATION_SCHEMA.USER_VARIABLES; diff --git a/plugin/user_variables/mysql-test/user_variables/suite.opt b/plugin/user_variables/mysql-test/user_variables/suite.opt new file mode 100644 index 00000000000..6140014d569 --- /dev/null +++ b/plugin/user_variables/mysql-test/user_variables/suite.opt @@ -0,0 +1 @@ +--plugin-load-add=$USER_VARIABLES_SO --plugin-user-variables=ON diff --git a/plugin/user_variables/mysql-test/user_variables/suite.pm b/plugin/user_variables/mysql-test/user_variables/suite.pm new file mode 100644 index 00000000000..b927bf40ecc --- /dev/null +++ b/plugin/user_variables/mysql-test/user_variables/suite.pm @@ -0,0 +1,14 @@ +package My::Suite::User_variables; + +@ISA = qw(My::Suite); + +return "No USER_VARIABLES plugin" unless + $ENV{USER_VARIABLES_SO} or + $::mysqld_variables{'user-variables'} eq "ON"; + +return "Not run for embedded server" if $::opt_embedded_server and + $ENV{USER_VARIABLES_SO}; + +sub is_default { 1 } + +bless { }; diff --git a/plugin/user_variables/user_variables.cc b/plugin/user_variables/user_variables.cc new file mode 100644 index 00000000000..9190b2effb7 --- /dev/null +++ b/plugin/user_variables/user_variables.cc @@ -0,0 +1,139 @@ +/* Copyright (C) 2016 MariaDB Foundation and Sergey Vojtovich + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER +#include <sql_class.h> +#include <table.h> +#include <sql_show.h> + + +static const LEX_CSTRING result_types[]= +{ + { STRING_WITH_LEN("VARCHAR") }, + { STRING_WITH_LEN("DOUBLE") }, + { STRING_WITH_LEN("INT") }, + { STRING_WITH_LEN("<IMPOSSIBLE1>") }, // ROW_RESULT + { STRING_WITH_LEN("DECIMAL") }, + { STRING_WITH_LEN("<IMPOSSIBLE2>")} // TIME_RESULT +}; + + +static const LEX_CSTRING unsigned_result_types[]= +{ + { STRING_WITH_LEN("<IMPOSSIBLE3>") }, // UNSIGNED STRING_RESULT + { STRING_WITH_LEN("DOUBLE UNSIGNED") }, + { STRING_WITH_LEN("INT UNSIGNED") }, + { STRING_WITH_LEN("<IMPOSSIBLE4>") }, // UNSIGNED ROW_RESULT + { STRING_WITH_LEN("DECIMAL UNSIGNED") }, + { STRING_WITH_LEN("<IMPOSSIBLE5>") } // UNSIGNED TIME_RESULT +}; + + +static ST_FIELD_INFO user_variables_fields_info[] = +{ + { "VARIABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Variable_name", 0 }, + { "VARIABLE_VALUE", 2048, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, "Value", 0 }, + { "VARIABLE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, 0 }, + { "CHARACTER_SET_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, + MY_I_S_MAYBE_NULL, 0, 0 }, + { 0, 0, MYSQL_TYPE_NULL, 0, 0, 0, 0 } +}; + + +static int user_variables_fill(THD *thd, TABLE_LIST *tables, COND *cond) +{ + ulong i; + TABLE *table= tables->table; + Field **field= table->field; + String buff; + bool is_null; + + for (i= 0; i < thd->user_vars.records; i++) + { + user_var_entry *var= (user_var_entry*) my_hash_element(&thd->user_vars, i); + + field[0]->store(var->name.str, var->name.length, system_charset_info); + + if (var->val_str(&is_null, &buff, NOT_FIXED_DEC)) + { + field[1]->store(buff.ptr(), buff.length(), buff.charset()); + field[1]->set_notnull(); + } + else if (is_null) + field[1]->set_null(); + else + return 1; + + const LEX_CSTRING *tmp= var->unsigned_flag ? + &unsigned_result_types[var->type] : + &result_types[var->type]; + field[2]->store(tmp->str, tmp->length, system_charset_info); + + if (var->charset()) + { + field[3]->store(var->charset()->csname, strlen(var->charset()->csname), + system_charset_info); + field[3]->set_notnull(); + } + else + field[3]->set_null(); + + if (schema_table_store_record(thd, table)) + return 1; + } + return 0; +} + + +int user_variables_reset(void) +{ + THD *thd= current_thd; + if (thd) + my_hash_reset(&thd->user_vars); + return 0; +} + + +static int user_variables_init(void *p) +{ + ST_SCHEMA_TABLE *is= (ST_SCHEMA_TABLE *) p; + is->fields_info= user_variables_fields_info; + is->fill_table= user_variables_fill; + is->reset_table= user_variables_reset; + return 0; +} + + +static struct st_mysql_information_schema user_variables_descriptor= +{ MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION }; + + +maria_declare_plugin(user_variables) +{ + MYSQL_INFORMATION_SCHEMA_PLUGIN, + &user_variables_descriptor, + "user_variables", + "Sergey Vojtovich", + "User-defined variables", + PLUGIN_LICENSE_GPL, + user_variables_init, + NULL, + 0x0100, + NULL, + NULL, + "1.0", + MariaDB_PLUGIN_MATURITY_GAMMA +} +maria_declare_plugin_end; diff --git a/plugin/userstat/index_stats.cc b/plugin/userstat/index_stats.cc index 236130d327f..87e6da63e38 100644 --- a/plugin/userstat/index_stats.cc +++ b/plugin/userstat/index_stats.cc @@ -35,11 +35,11 @@ static int index_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond) index_name_length= (index_stats->index_name_length - schema_name_length - table_name_length - 3); - table->field[0]->store(tmp_table.db, schema_name_length, + table->field[0]->store(tmp_table.db, (uint)schema_name_length, system_charset_info); - table->field[1]->store(tmp_table.table_name, table_name_length, + table->field[1]->store(tmp_table.table_name, (uint) table_name_length, system_charset_info); - table->field[2]->store(index_name, index_name_length, system_charset_info); + table->field[2]->store(index_name, (uint) index_name_length, system_charset_info); table->field[3]->store((longlong)index_stats->rows_read, TRUE); if (schema_table_store_record(thd, table)) diff --git a/plugin/wsrep_info/mysql-test/wsrep_info/r/plugin.result b/plugin/wsrep_info/mysql-test/wsrep_info/r/plugin.result index 31d66ab8b34..f33a628d428 100644 --- a/plugin/wsrep_info/mysql-test/wsrep_info/r/plugin.result +++ b/plugin/wsrep_info/mysql-test/wsrep_info/r/plugin.result @@ -1,4 +1,5 @@ # On node 1 +connection node_1; SELECT * FROM INFORMATION_SCHEMA.WSREP_STATUS; NODE_INDEX NODE_STATUS CLUSTER_STATUS CLUSTER_SIZE CLUSTER_STATE_UUID CLUSTER_STATE_SEQNO CLUSTER_CONF_ID GAP PROTOCOL_VERSION <IDX> Synced Primary 2 <CLUSTER_STATE_UUID> 0 <CLUSTER_CONF_ID> NO 3 @@ -7,6 +8,7 @@ INDEX UUID NAME ADDRESS <IDX> <MEMBER_ID> test-node-1 <ADDRESS> <IDX> <MEMBER_ID> test-node-2 <ADDRESS> # On node 2 +connection node_2; SELECT * FROM INFORMATION_SCHEMA.WSREP_STATUS; NODE_INDEX NODE_STATUS CLUSTER_STATUS CLUSTER_SIZE CLUSTER_STATE_UUID CLUSTER_STATE_SEQNO CLUSTER_CONF_ID GAP PROTOCOL_VERSION <IDX> Synced Primary 2 <CLUSTER_STATE_UUID> 0 <CLUSTER_CONF_ID> YES 3 @@ -14,4 +16,6 @@ SELECT * FROM INFORMATION_SCHEMA.WSREP_MEMBERSHIP ORDER BY NAME; INDEX UUID NAME ADDRESS <IDX> <MEMBER_ID> test-node-1 <ADDRESS> <IDX> <MEMBER_ID> test-node-2 <ADDRESS> +disconnect node_2; +disconnect node_1; # End of test diff --git a/plugin/wsrep_info/plugin.cc b/plugin/wsrep_info/plugin.cc index a4362f0072e..ed502d30f88 100644 --- a/plugin/wsrep_info/plugin.cc +++ b/plugin/wsrep_info/plugin.cc @@ -120,10 +120,10 @@ static int wsrep_memb_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) if (check_global_access(thd, SUPER_ACL, true)) return rc; - wsrep_config_state.lock(); + wsrep_config_state->lock(); Dynamic_array<wsrep_member_info_t> *memb_arr= - wsrep_config_state.get_member_info(); + wsrep_config_state->get_member_info(); TABLE *table= tables->table; @@ -151,7 +151,7 @@ static int wsrep_memb_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) } end: - wsrep_config_state.unlock(); + wsrep_config_state->unlock(); return rc; } @@ -175,10 +175,10 @@ static int wsrep_status_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) if (check_global_access(thd, SUPER_ACL, true)) return rc; - wsrep_config_state.lock(); + wsrep_config_state->lock(); - wsrep_view_info_t view= wsrep_config_state.get_view_info(); - wsrep_member_status_t status= wsrep_config_state.get_status(); + wsrep_view_info_t view= wsrep_config_state->get_view_info(); + wsrep_member_status_t status= wsrep_config_state->get_status(); TABLE *table= tables->table; @@ -210,7 +210,7 @@ static int wsrep_status_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) if (schema_table_store_record(thd, table)) rc= 1; - wsrep_config_state.unlock(); + wsrep_config_state->unlock(); return rc; } |