diff options
author | Nirbhay Choubey <nirbhay@mariadb.com> | 2016-04-29 16:50:58 -0400 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@mariadb.com> | 2016-04-29 16:50:58 -0400 |
commit | 8a1efa1bdd29b756c93a3ddbd8ad6fadec1082bc (patch) | |
tree | 9827e75d29817f3ddbc2008ba2b5b21553c14c5e | |
parent | 7c42b47e67918104fddd121a1ca9fede28ed47cf (diff) | |
parent | 9eba34f08675c31b0796eeb127582be827773070 (diff) | |
download | mariadb-git-8a1efa1bdd29b756c93a3ddbd8ad6fadec1082bc.tar.gz |
Merge branch '10.0' into 10.0-galera
367 files changed, 4212 insertions, 1393 deletions
diff --git a/Docs/mysql.info b/Docs/mysql.info index 684c0d23437..02692f341d3 100644 --- a/Docs/mysql.info +++ b/Docs/mysql.info @@ -1,11 +1,11 @@ MariaDB is in most aspects identical to MySQL. Differences between MySQL and MariaDB can be found at: -http://kb.askmonty.org/en/mariadb-versus-mysql-features/ -http://kb.askmonty.org/en/mariadb-versus-mysql-compatibility/ +https://mariadb.com/kb/en/mariadb-vs-mysql-features/ +https://mariadb.com/kb/en/mariadb-vs-mysql-compatibility/ The MariaDB manual can be found at: -http://kb.askmonty.org/ +https://mariadb.com/kb/ The MySQL Reference Manual is available in various formats on http://dev.mysql.com/doc. diff --git a/Docs/sp-imp-spec.txt b/Docs/sp-imp-spec.txt index 9795dd72252..259d76ab5bb 100644 --- a/Docs/sp-imp-spec.txt +++ b/Docs/sp-imp-spec.txt @@ -243,7 +243,7 @@ in the caller's frame is set in the new context as well. 4) For each instruction, call its execute() method. The result is a pointer to the next instruction to execute (or NULL) - if an error occured. + if an error occurred. 5) On success, set the new values of the OUT and INOUT parameters in the caller's frame. @@ -853,7 +853,7 @@ // '*nextp' will be set to the index of the next instruction // to execute. (For most instruction this will be the // instruction following this one.) - // Returns 0 on success, non-zero if some error occured. + // Returns 0 on success, non-zero if some error occurred. virtual int execute(THD *, uint *nextp) } diff --git a/INSTALL-SOURCE b/INSTALL-SOURCE index 32cfa9792a7..93c985f2c1d 100644 --- a/INSTALL-SOURCE +++ b/INSTALL-SOURCE @@ -1,3 +1,3 @@ Instructions for building MariaDB can be found at: -https://kb.askmonty.org/en/compiling-mariadb-from-source/ +https://mariadb.com/kb/en/compiling-mariadb-from-source diff --git a/INSTALL-WIN-SOURCE b/INSTALL-WIN-SOURCE index 269bc2c3d1c..f10d13aa93b 100644 --- a/INSTALL-WIN-SOURCE +++ b/INSTALL-WIN-SOURCE @@ -1,3 +1,3 @@ Up-to-date instructions about building MariaDB on Windows can be found -at: http://kb.askmonty.org/en/building-mariadb-on-windows +at: https://mariadb.com/kb/en/Building_MariaDB_on_Windows @@ -1,3 +1,3 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=0 -MYSQL_VERSION_PATCH=24 +MYSQL_VERSION_PATCH=25 diff --git a/client/client_priv.h b/client/client_priv.h index 67a6e822ea3..3905f323156 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -1,5 +1,6 @@ /* Copyright (c) 2001, 2012, Oracle and/or its affiliates. + Copyright (c) 2009, 2016, MariaDB 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 diff --git a/client/mysql.cc b/client/mysql.cc index f1346395dfe..89f9a75ec11 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1,7 +1,6 @@ /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2009, 2013, Monty Program Ab. - Copyright (c) 2013, 2014, SkySQL Ab + Copyright (c) 2009, 2016, MariaDB 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 @@ -96,9 +95,16 @@ extern "C" { #endif } -#if !defined(HAVE_VIDATTR) -#undef vidattr -#define vidattr(A) {} // Can't get this to work +#ifdef HAVE_VIDATTR +static int have_curses= 0; +static void my_vidattr(chtype attrs) +{ + if (have_curses) + vidattr(attrs); +} +#else +#undef HAVE_SETUPTERM +#define my_vidattr(A) {} // Can't get this to work #endif #ifdef FN_NO_CASE_SENSE @@ -3358,7 +3364,7 @@ com_go(String *buffer,char *line __attribute__((unused))) end: - /* Show warnings if any or error occured */ + /* Show warnings if any or error occurred */ if (show_warnings == 1 && (warnings >= 1 || error)) print_warnings(); @@ -4740,9 +4746,9 @@ com_status(String *buffer __attribute__((unused)), if (skip_updates) { - vidattr(A_BOLD); + my_vidattr(A_BOLD); tee_fprintf(stdout, "\nAll updates ignored to this database\n"); - vidattr(A_NORMAL); + my_vidattr(A_NORMAL); } #ifdef USE_POPEN tee_fprintf(stdout, "Current pager:\t\t%s\n", pager); @@ -4810,9 +4816,9 @@ com_status(String *buffer __attribute__((unused)), } if (safe_updates) { - vidattr(A_BOLD); + my_vidattr(A_BOLD); tee_fprintf(stdout, "\nNote that you are running in safe_update_mode:\n"); - vidattr(A_NORMAL); + my_vidattr(A_NORMAL); tee_fprintf(stdout, "\ UPDATEs and DELETEs that don't use a key in the WHERE clause are not allowed.\n\ (One can force an UPDATE/DELETE by adding LIMIT # at the end of the command.)\n\ @@ -4905,10 +4911,11 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate) { if (!inited) { - inited=1; #ifdef HAVE_SETUPTERM - (void) setupterm((char *)0, 1, (int *) 0); + int errret; + have_curses= setupterm((char *)0, 1, &errret) != ERR; #endif + inited=1; } if (info_type == INFO_ERROR) { @@ -4920,7 +4927,7 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate) putchar('\a'); /* This should make a bell */ #endif } - vidattr(A_STANDOUT); + my_vidattr(A_STANDOUT); if (error) { if (sqlstate) @@ -4939,9 +4946,9 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate) tee_fputs(": ", file); } else - vidattr(A_BOLD); + my_vidattr(A_BOLD); (void) tee_puts(str, file); - vidattr(A_NORMAL); + my_vidattr(A_NORMAL); } if (unbuffered) fflush(file); diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index f3076f61b3e..e7170201a2a 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -1,6 +1,6 @@ /* Copyright (c) 2006, 2013, Oracle and/or its affiliates. - Copyright (c) 2010, 2015, MariaDB + Copyright (c) 2010, 2016, MariaDB 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 @@ -649,7 +649,7 @@ static int get_upgrade_info_file_name(char* name) /* Read the content of mysql_upgrade_info file and compare the version number form file against - version number wich mysql_upgrade was compiled for + version number which mysql_upgrade was compiled for NOTE This is an optimization to avoid running mysql_upgrade diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index bc6b68c63d1..daffdefd768 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2010, 2015, MariaDB + Copyright (c) 2010, 2016, MariaDB 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 diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 315fdcd22dc..4be31421f9b 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -34,6 +34,7 @@ #define TABLE TABLE_CLIENT #include "client_priv.h" #include <my_time.h> +#include <sslopt-vars.h> /* That one is necessary for defines of OPTION_NO_FOREIGN_KEY_CHECKS etc */ #include "sql_priv.h" #include "log_event.h" @@ -1392,6 +1393,7 @@ static struct my_option my_options[] = {"socket", 'S', "The socket file to use for connection.", &sock, &sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, +#include <sslopt-longopts.h> {"start-datetime", OPT_START_DATETIME, "Start reading the binlog at first event having a datetime equal or " "posterior to the argument; the argument must be a date and time " @@ -1599,6 +1601,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), DBUG_PUSH(argument ? argument : default_dbug_option); break; #endif +#include <sslopt-case.h> case 'd': one_database = 1; break; @@ -1748,6 +1751,18 @@ static Exit_status safe_connect() return ERROR_STOP; } +#ifdef HAVE_OPENSSL + if (opt_use_ssl) + { + mysql_ssl_set(mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, + opt_ssl_capath, opt_ssl_cipher); + mysql_options(mysql, MYSQL_OPT_SSL_CRL, opt_ssl_crl); + mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath); + } + mysql_options(mysql,MYSQL_OPT_SSL_VERIFY_SERVER_CERT, + (char*)&opt_ssl_verify_server_cert); +#endif /*HAVE_OPENSSL*/ + if (opt_plugindir && *opt_plugindir) mysql_options(mysql, MYSQL_PLUGIN_DIR, opt_plugindir); diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 15b98bb59c2..8dc3efd1ab2 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -1,6 +1,6 @@ /* Copyright (c) 2001, 2013, Oracle and/or its affiliates. - Copyright (c) 2010, 2015, MariaDB + Copyright (c) 2010, 2016, MariaDB 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 @@ -277,8 +277,8 @@ static void usage(void) printf("Usage: %s [OPTIONS] database [tables]\n", my_progname); printf("OR %s [OPTIONS] --databases DB1 [DB2 DB3...]\n", my_progname); - puts("Please consult the MariaDB/MySQL knowledgebase at"); - puts("http://kb.askmonty.org/v/mysqlcheck for latest information about"); + puts("Please consult the MariaDB Knowledge Base at"); + puts("https://mariadb.com/kb/en/mysqlcheck for latest information about"); puts("this program."); print_defaults("my", load_default_groups); puts(""); @@ -523,7 +523,6 @@ static int is_view(const char *table) { fprintf(stderr, "Failed to %s\n", query); fprintf(stderr, "Error: %s\n", mysql_error(sock)); - my_free(query); DBUG_RETURN(-1); } res= mysql_store_result(sock); diff --git a/client/mysqldump.c b/client/mysqldump.c index e41305d7c07..dc6798560c3 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2010, 2015, Monty Program Ab. + Copyright (c) 2010, 2016, MariaDB 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 diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 2363f1b69df..5b15155e039 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2011, 2015, MariaDB + Copyright (c) 2011, 2016, MariaDB 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 diff --git a/client/mysqlshow.c b/client/mysqlshow.c index fd81f18790a..444278d40f1 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2010, 2015, MariaDB + Copyright (c) 2010, 2016, MariaDB 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 diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 29919f3028d..b3229980e77 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -1,6 +1,6 @@ /* Copyright (c) 2005, 2015, Oracle and/or its affiliates. - Copyright (c) 2010, 2015, MariaDB + Copyright (c) 2010, 2016, MariaDB 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 diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 026934a2feb..84d5abc1a67 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2013, Monty Program Ab. + Copyright (c) 2009, 2016, Monty Program Ab. 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 @@ -1104,7 +1104,7 @@ void do_eval(DYNAMIC_STRING *query_eval, const char *query, Run query and dump the result to stderr in vertical format NOTE! This function should be safe to call when an error - has occured and thus any further errors will be ignored(although logged) + has occurred and thus any further errors will be ignored (although logged) SYNOPSIS show_query @@ -1170,7 +1170,7 @@ static void show_query(MYSQL* mysql, const char* query) is added to the warning stack, only print @@warning_count-1 warnings. NOTE! This function should be safe to call when an error - has occured and this any further errors will be ignored(although logged) + has occurred and this any further errors will be ignored(although logged) SYNOPSIS show_warnings_before_error @@ -4701,7 +4701,7 @@ void do_sync_with_master2(struct st_command *command, long offset, master_pos_wait returned NULL. This indicates that slave SQL thread is not started, the slave's master information is not initialized, the arguments are - incorrect, or an error has occured + incorrect, or an error has occurred */ die("%.*s failed: '%s' returned NULL " \ "indicating slave SQL thread failure", diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index 13276080f56..174548502d8 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -40,8 +40,8 @@ SET(CPACK_RPM_PACKAGE_DESCRIPTION "${CPACK_RPM_PACKAGE_SUMMARY} It is GPL v2 licensed, which means you can use the it free of charge under the conditions of the GNU General Public License Version 2 (http://www.gnu.org/licenses/). -MariaDB documentation can be found at http://kb.askmonty.org/ -MariaDB bug reports should be submitted through https://mariadb.atlassian.net/ +MariaDB documentation can be found at https://mariadb.com/kb +MariaDB bug reports should be submitted through https://jira.mariadb.org ") diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 8e3af8d745f..826350e076e 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -202,8 +202,11 @@ MACRO(MYSQL_ADD_PLUGIN) IF(CPACK_COMPONENTS_ALL AND NOT CPACK_COMPONENTS_ALL MATCHES ${ARG_COMPONENT} AND NOT WITH_WSREP) + IF (ARG_STORAGE_ENGINE) + SET(ver " = %{version}-%{release}") + ENDIF() SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} ${ARG_COMPONENT} PARENT_SCOPE) - SET(CPACK_RPM_${ARG_COMPONENT}_PACKAGE_REQUIRES "MariaDB" PARENT_SCOPE) + SET(CPACK_RPM_${ARG_COMPONENT}_PACKAGE_REQUIRES "MariaDB${ver}" PARENT_SCOPE) IF (NOT ARG_CONFIG) SET(ARG_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/${target}.cnf") diff --git a/debian/additions/innotop/innotop b/debian/additions/innotop/innotop index 646f0d7f0fb..9179a0d7a81 100644 --- a/debian/additions/innotop/innotop +++ b/debian/additions/innotop/innotop @@ -1503,7 +1503,7 @@ my %exprs = ( my %columns = ( active_secs => { hdr => 'SecsActive', num => 1, label => 'Seconds transaction has been active', }, - add_pool_alloc => { hdr => 'Add\'l Pool', num => 1, label => 'Additonal pool allocated' }, + add_pool_alloc => { hdr => 'Add\'l Pool', num => 1, label => 'Additional pool allocated' }, attempted_op => { hdr => 'Action', num => 0, label => 'The action that caused the error' }, awe_mem_alloc => { hdr => 'AWE Memory', num => 1, label => '[Windows] AWE memory allocated' }, binlog_cache_overflow => { hdr => 'Binlog Cache', num => 1, label => 'Transactions too big for binlog cache that went to disk' }, @@ -10365,7 +10365,7 @@ show you something like this: pages_modified Dirty Pages Pages modified (dirty IB_bp_pages_m buf_pool_hit_rate Hit Rate Buffer pool hit rate IB_bp_buf_poo total_mem_alloc Memory Total memory allocate IB_bp_total_m - add_pool_alloc Add'l Pool Additonal pool alloca IB_bp_add_poo + add_pool_alloc Add'l Pool Additional pool alloca IB_bp_add_poo The first line shows which table you're editing, and reminds you again to press '?' for a list of key mappings. The rest is a tabular representation of the diff --git a/debian/additions/innotop/innotop.1 b/debian/additions/innotop/innotop.1 index b2e7fce084e..fbb481f9b94 100644 --- a/debian/additions/innotop/innotop.1 +++ b/debian/additions/innotop/innotop.1 @@ -1579,7 +1579,7 @@ show you something like this: \& pages_modified Dirty Pages Pages modified (dirty IB_bp_pages_m \& buf_pool_hit_rate Hit Rate Buffer pool hit rate IB_bp_buf_poo \& total_mem_alloc Memory Total memory allocate IB_bp_total_m -\& add_pool_alloc Add\*(Aql Pool Additonal pool alloca IB_bp_add_poo +\& add_pool_alloc Add\*(Aql Pool Additional pool alloca IB_bp_add_poo .Ve .PP The first line shows which table you're editing, and reminds you again to press diff --git a/debian/additions/mysqlreport b/debian/additions/mysqlreport index 402a5be835d..5cd46441d8a 100755 --- a/debian/additions/mysqlreport +++ b/debian/additions/mysqlreport @@ -350,7 +350,7 @@ sub read_relative_infiles # The infile must begin with the system variable values. # Therefore, the first occurance of Aborted_clients indicates the beginning - # of the first set of status values if no sets have occured yet ($stat_n == 0). + # of the first set of status values if no sets have occurred yet ($stat_n == 0). # In this case, the following status values are printed to the current fh, # along with the system variable values read thus far, until Aborted_clients # occurs again. Then begins the second and subsequent sets of status values. diff --git a/debian/copyright b/debian/copyright index 5207620b411..1a31a958b99 100644 --- a/debian/copyright +++ b/debian/copyright @@ -9,7 +9,7 @@ The MariaDB packages were initally made by http://ourdelta.org/, and are now managed by the MariaDB development team, maria-developers@lists.launchpad.net -MariaDB can be downloaded from http://downloads.askmonty.org/mariadb/ +MariaDB can be downloaded from https://downloads.mariadb.org/ Copyright: diff --git a/debian/dist/Debian/mariadb-galera-server-10.0.postinst b/debian/dist/Debian/mariadb-galera-server-10.0.postinst index 19a69ed00cb..5179fd4944a 100644 --- a/debian/dist/Debian/mariadb-galera-server-10.0.postinst +++ b/debian/dist/Debian/mariadb-galera-server-10.0.postinst @@ -266,8 +266,10 @@ db_stop # in case invoke failes # If we upgrade from MySQL mysql.service may be masked, which also # means init.d script is disabled. Unmask mysql service explicitely. -# Ignore exit code as command is not available everywhere. -deb-systemd-helper unmask mysql.service > /dev/null || true +# Check first that the command exists, to avoid emitting any warning messages. +if [ -x "$(command -v deb-systemd-helper)" ]; then + deb-systemd-helper unmask mysql.service > /dev/null +fi #DEBHELPER# diff --git a/debian/dist/Ubuntu/mariadb-galera-server-10.0.postinst b/debian/dist/Ubuntu/mariadb-galera-server-10.0.postinst index 2486a09a5af..e90ef045e2c 100644 --- a/debian/dist/Ubuntu/mariadb-galera-server-10.0.postinst +++ b/debian/dist/Ubuntu/mariadb-galera-server-10.0.postinst @@ -282,8 +282,10 @@ db_stop # in case invoke failes # If we upgrade from MySQL mysql.service may be masked, which also # means init.d script is disabled. Unmask mysql service explicitely. -# Ignore exit code as command is not available everywhere. -deb-systemd-helper unmask mysql.service > /dev/null || true +# Check first that the command exists, to avoid emitting any warning messages. +if [ -x "$(command -v deb-systemd-helper)" ]; then + deb-systemd-helper unmask mysql.service > /dev/null +fi #DEBHELPER# diff --git a/debian/mariadb-galera-server-10.0.mysql-server.logrotate b/debian/mariadb-galera-server-10.0.mysql-server.logrotate index 789ad353e43..a19e9ec46a2 100644 --- a/debian/mariadb-galera-server-10.0.mysql-server.logrotate +++ b/debian/mariadb-galera-server-10.0.mysql-server.logrotate @@ -10,18 +10,11 @@ compress sharedscripts postrotate - test -x /usr/bin/mysqladmin || exit 0 + test -x /usr/bin/mysqladmin || exit 0 - # If this fails, check debian.conf! - MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" - if [ -z "`$MYADMIN ping 2>/dev/null`" ]; then - # Really no mysqld or rather a missing debian-sys-maint user? - # If this occurs and is not a error please report a bug. - if ps cax | grep -q mysqld; then - exit 1 - fi - else - $MYADMIN flush-logs - fi + if [ -f `my_print_defaults --mysqld | grep -oP "pid-file=\K[^$]+"` ]; then + # If this fails, check debian.conf! + mysqladmin --defaults-file=/etc/mysql/debian.cnf flush-logs + fi endscript } diff --git a/debian/mariadb-galera-test-10.0.dirs b/debian/mariadb-galera-test-10.0.dirs index 4e75b80c8b3..b40bd89463d 100644 --- a/debian/mariadb-galera-test-10.0.dirs +++ b/debian/mariadb-galera-test-10.0.dirs @@ -50,8 +50,6 @@ usr/share/mysql/mysql-test/suite/ndb usr/share/mysql/mysql-test/suite/ndb/t usr/share/mysql/mysql-test/suite/ndb/r usr/share/mysql/mysql-test/suite/maria -usr/share/mysql/mysql-test/suite/maria/t -usr/share/mysql/mysql-test/suite/maria/r usr/share/mysql/mysql-test/suite/funcs_2 usr/share/mysql/mysql-test/suite/funcs_2/lib usr/share/mysql/mysql-test/suite/funcs_2/t diff --git a/extra/yassl/README b/extra/yassl/README index 81d573d0b20..b5eb88824fb 100644 --- a/extra/yassl/README +++ b/extra/yassl/README @@ -12,6 +12,12 @@ before calling SSL_new(); *** end Note *** +yaSSL Release notes, version 2.3.9b (2/03/2016) + This release of yaSSL fixes the OpenSSL compatibility function + X509_NAME_get_index_by_NID() to use the actual index of the common name + instead of searching on the format prefix. Thanks for the report from + yashwant.sahu@oracle.com . Anyone using this function should update. + yaSSL Release notes, version 2.3.9 (12/01/2015) This release of yaSSL fixes two client side Diffie-Hellman problems. yaSSL was only handling the cases of zero or one leading zeros for the key diff --git a/extra/yassl/include/openssl/ssl.h b/extra/yassl/include/openssl/ssl.h index 84ce40b8415..c95eb1ed887 100644 --- a/extra/yassl/include/openssl/ssl.h +++ b/extra/yassl/include/openssl/ssl.h @@ -34,7 +34,7 @@ #include "rsa.h" -#define YASSL_VERSION "2.3.9" +#define YASSL_VERSION "2.3.9b" #if defined(__cplusplus) diff --git a/extra/yassl/include/yassl_int.hpp b/extra/yassl/include/yassl_int.hpp index 269976a6eaa..781eaa38dda 100644 --- a/extra/yassl/include/yassl_int.hpp +++ b/extra/yassl/include/yassl_int.hpp @@ -191,14 +191,18 @@ private: class X509_NAME { char* name_; size_t sz_; + int cnPosition_; // start of common name, -1 is none + int cnLen_; // length of above ASN1_STRING entry_; public: - X509_NAME(const char*, size_t sz); + X509_NAME(const char*, size_t sz, int pos, int len); ~X509_NAME(); const char* GetName() const; ASN1_STRING* GetEntry(int i); size_t GetLength() const; + int GetCnPosition() const { return cnPosition_; } + int GetCnLength() const { return cnLen_; } private: X509_NAME(const X509_NAME&); // hide copy X509_NAME& operator=(const X509_NAME&); // and assign @@ -226,7 +230,7 @@ class X509 { StringHolder afterDate_; // not valid after public: X509(const char* i, size_t, const char* s, size_t, - ASN1_STRING *b, ASN1_STRING *a); + ASN1_STRING *b, ASN1_STRING *a, int, int, int, int); ~X509() {} X509_NAME* GetIssuer(); diff --git a/extra/yassl/src/cert_wrapper.cpp b/extra/yassl/src/cert_wrapper.cpp index af94f5bc24f..1092e428351 100644 --- a/extra/yassl/src/cert_wrapper.cpp +++ b/extra/yassl/src/cert_wrapper.cpp @@ -304,7 +304,10 @@ int CertManager::Validate() afterDate.type= cert.GetAfterDateType(); afterDate.length= strlen((char *) afterDate.data) + 1; peerX509_ = NEW_YS X509(cert.GetIssuer(), iSz, cert.GetCommonName(), - sSz, &beforeDate, &afterDate); + sSz, &beforeDate, &afterDate, + cert.GetIssuerCnStart(), cert.GetIssuerCnLength(), + cert.GetSubjectCnStart(), cert.GetSubjectCnLength() + ); if (err == TaoCrypt::SIG_OTHER_E && verifyCallback_) { X509_STORE_CTX store; @@ -350,7 +353,9 @@ int CertManager::SetPrivateKey(const x509& key) afterDate.type= cd.GetAfterDateType(); afterDate.length= strlen((char *) afterDate.data) + 1; selfX509_ = NEW_YS X509(cd.GetIssuer(), iSz, cd.GetCommonName(), - sSz, &beforeDate, &afterDate); + sSz, &beforeDate, &afterDate, + cd.GetIssuerCnStart(), cd.GetIssuerCnLength(), + cd.GetSubjectCnStart(), cd.GetSubjectCnLength()); } return 0; } @@ -367,7 +372,9 @@ void CertManager::setPeerX509(X509* x) ASN1_STRING* after = x->GetAfter(); peerX509_ = NEW_YS X509(issuer->GetName(), issuer->GetLength(), - subject->GetName(), subject->GetLength(), before, after); + subject->GetName(), subject->GetLength(), before, after, + issuer->GetCnPosition(), issuer->GetCnLength(), + subject->GetCnPosition(), subject->GetCnLength()); } diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp index 26a02afcacf..57542f174c9 100644 --- a/extra/yassl/src/ssl.cpp +++ b/extra/yassl/src/ssl.cpp @@ -1351,15 +1351,13 @@ int ASN1_STRING_type(ASN1_STRING *x) int X509_NAME_get_index_by_NID(X509_NAME* name,int nid, int lastpos) { int idx = -1; // not found - const char* start = &name->GetName()[lastpos + 1]; + int cnPos = -1; switch (nid) { case NID_commonName: - const char* found = strstr(start, "/CN="); - if (found) { - found += 4; // advance to str - idx = found - start + lastpos + 1; - } + cnPos = name->GetCnPosition(); + if (lastpos < cnPos) + idx = cnPos; break; } @@ -1471,10 +1469,6 @@ int SSL_peek(SSL* ssl, void* buffer, int sz) int SSL_pending(SSL* ssl) { - // Just in case there's pending data that hasn't been processed yet... - char c; - SSL_peek(ssl, &c, 1); - return ssl->bufferedData(); } diff --git a/extra/yassl/src/yassl_error.cpp b/extra/yassl/src/yassl_error.cpp index fec6a3394ca..f339655be3d 100644 --- a/extra/yassl/src/yassl_error.cpp +++ b/extra/yassl/src/yassl_error.cpp @@ -121,11 +121,11 @@ void SetErrorString(YasslError error, char* buffer) break; case certificate_error : - strncpy(buffer, "unable to proccess cerificate", max); + strncpy(buffer, "unable to process cerificate", max); break; case privateKey_error : - strncpy(buffer, "unable to proccess private key, bad format", max); + strncpy(buffer, "unable to process private key, bad format", max); break; case badVersion_error : diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp index a38b7a5c81f..ff9c8155d0c 100644 --- a/extra/yassl/src/yassl_int.cpp +++ b/extra/yassl/src/yassl_int.cpp @@ -1554,8 +1554,9 @@ void SSL_SESSION::CopyX509(X509* x) ASN1_TIME* after = x->GetAfter(); peerX509_ = NEW_YS X509(issuer->GetName(), issuer->GetLength(), - subject->GetName(), subject->GetLength(), - before, after); + subject->GetName(), subject->GetLength(), before, after, + issuer->GetCnPosition(), issuer->GetCnLength(), + subject->GetCnPosition(), subject->GetCnLength()); } @@ -2472,8 +2473,8 @@ void Security::set_resuming(bool b) } -X509_NAME::X509_NAME(const char* n, size_t sz) - : name_(0), sz_(sz) +X509_NAME::X509_NAME(const char* n, size_t sz, int pos, int len) + : name_(0), sz_(sz), cnPosition_(pos), cnLen_(len) { if (sz) { name_ = NEW_YS char[sz]; @@ -2503,8 +2504,10 @@ size_t X509_NAME::GetLength() const X509::X509(const char* i, size_t iSz, const char* s, size_t sSz, - ASN1_STRING *b, ASN1_STRING *a) - : issuer_(i, iSz), subject_(s, sSz), + ASN1_STRING *b, ASN1_STRING *a, + int issPos, int issLen, + int subPos, int subLen) + : issuer_(i, iSz, issPos, issLen), subject_(s, sSz, subPos, subLen), beforeDate_((char *) b->data, b->length, b->type), afterDate_((char *) a->data, a->length, a->type) {} @@ -2539,17 +2542,19 @@ ASN1_STRING* X509_NAME::GetEntry(int i) if (i < 0 || i >= int(sz_)) return 0; + if (i != cnPosition_ || cnLen_ <= 0) // only entry currently supported + return 0; + + if (cnLen_ > int(sz_-i)) // make sure there's room in read buffer + return 0; + if (entry_.data) ysArrayDelete(entry_.data); - entry_.data = NEW_YS byte[sz_]; // max size; + entry_.data = NEW_YS byte[cnLen_+1]; // max size; - memcpy(entry_.data, &name_[i], sz_ - i); - if (entry_.data[sz_ -i - 1]) { - entry_.data[sz_ - i] = 0; - entry_.length = int(sz_) - i; - } - else - entry_.length = int(sz_) - i - 1; + memcpy(entry_.data, &name_[i], cnLen_); + entry_.data[cnLen_] = 0; + entry_.length = cnLen_; entry_.type = 0; return &entry_; diff --git a/extra/yassl/taocrypt/include/asn.hpp b/extra/yassl/taocrypt/include/asn.hpp index 2854b8fe06d..999e853b941 100644 --- a/extra/yassl/taocrypt/include/asn.hpp +++ b/extra/yassl/taocrypt/include/asn.hpp @@ -285,6 +285,10 @@ public: byte GetBeforeDateType() const { return beforeDateType_; } const char* GetAfterDate() const { return afterDate_; } byte GetAfterDateType() const { return afterDateType_; } + int GetSubjectCnStart() const { return subCnPos_; } + int GetIssuerCnStart() const { return issCnPos_; } + int GetSubjectCnLength() const { return subCnLen_; } + int GetIssuerCnLength() const { return issCnLen_; } void DecodeToKey(); private: @@ -294,6 +298,10 @@ private: word32 sigLength_; // length of signature word32 signatureOID_; // sum of algorithm object id word32 keyOID_; // sum of key algo object id + int subCnPos_; // subject common name start, -1 is none + int subCnLen_; // length of above + int issCnPos_; // issuer common name start, -1 is none + int issCnLen_; // length of above byte subjectHash_[SHA_SIZE]; // hash of all Names byte issuerHash_[SHA_SIZE]; // hash of all Names byte* signature_; diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp index d8b133a3f0a..0474e7c21d5 100644 --- a/extra/yassl/taocrypt/src/asn.cpp +++ b/extra/yassl/taocrypt/src/asn.cpp @@ -482,8 +482,9 @@ void DH_Decoder::Decode(DH& key) CertDecoder::CertDecoder(Source& s, bool decode, SignerList* signers, bool noVerify, CertType ct) - : BER_Decoder(s), certBegin_(0), sigIndex_(0), sigLength_(0), - signature_(0), verify_(!noVerify) + : BER_Decoder(s), certBegin_(0), sigIndex_(0), sigLength_(0), subCnPos_(-1), + subCnLen_(0), issCnPos_(-1), issCnLen_(0), signature_(0), + verify_(!noVerify) { issuer_[0] = 0; subject_[0] = 0; @@ -804,6 +805,13 @@ void CertDecoder::GetName(NameType nt) case COMMON_NAME: if (!(ptr = AddTag(ptr, buf_end, "/CN=", 4, strLen))) return; + if (nt == ISSUER) { + issCnPos_ = (int)(ptr - strLen - issuer_); + issCnLen_ = (int)strLen; + } else { + subCnPos_ = (int)(ptr - strLen - subject_); + subCnLen_ = (int)strLen; + } break; case SUR_NAME: if (!(ptr = AddTag(ptr, buf_end, "/SN=", 4, strLen))) diff --git a/extra/yassl/testsuite/test.hpp b/extra/yassl/testsuite/test.hpp index 52f6ed79526..5374edd0e2a 100644 --- a/extra/yassl/testsuite/test.hpp +++ b/extra/yassl/testsuite/test.hpp @@ -470,10 +470,28 @@ inline void showPeer(SSL* ssl) char* issuer = X509_NAME_oneline(X509_get_issuer_name(peer), 0, 0); char* subject = X509_NAME_oneline(X509_get_subject_name(peer), 0, 0); - printf("peer's cert info:\n issuer : %s\n subject: %s\n", issuer, - subject); + X509_NAME_ENTRY* se = NULL; + ASN1_STRING* sd = NULL; + char* subCN = NULL; + + X509_NAME* sub = X509_get_subject_name(peer); + int lastpos = -1; + if (sub) + lastpos = X509_NAME_get_index_by_NID(sub, NID_commonName, lastpos); + if (lastpos >= 0) { + se = X509_NAME_get_entry(sub, lastpos); + if (se) + sd = X509_NAME_ENTRY_get_data(se); + if (sd) + subCN = (char*)ASN1_STRING_data(sd); + } + + printf("peer's cert info:\n issuer : %s\n subject: %s\n" + " subject cn: %s\n", issuer, subject, subCN); + free(subject); free(issuer); + } else printf("peer has no cert!\n"); diff --git a/include/my_context.h b/include/my_context.h index 976ed9850cc..c59d6ce3577 100644 --- a/include/my_context.h +++ b/include/my_context.h @@ -178,7 +178,7 @@ struct mysql_async_context { resumed, eg. whether we woke up due to connection completed or timeout in mysql_real_connect_cont(). */ - unsigned int events_occured; + unsigned int events_occurred; /* This is set to the result of the whole asynchronous operation when it completes. It uses a union, as different calls have different return diff --git a/include/mysql/service_progress_report.h b/include/mysql/service_progress_report.h index 670b1c37630..7ec3aa4c946 100644 --- a/include/mysql/service_progress_report.h +++ b/include/mysql/service_progress_report.h @@ -22,7 +22,7 @@ if requested. The functions are documented at - http://kb.askmonty.org/en/progress-reporting#how-to-add-support-for-progress-reporting-to-a-storage-engine + https://mariadb.com/kb/en/progress-reporting/#how-to-add-support-for-progress-reporting-to-a-storage-engine */ #ifdef __cplusplus diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 7dfc572b281..417f91c7879 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -274,6 +274,25 @@ SET(CLIENT_API_FUNCTIONS ) IF(CMAKE_SYSTEM_NAME MATCHES "Linux") + IF (NOT DISABLE_LIBMYSQLCLIENT_SYMBOL_VERSIONING) + + INCLUDE (CheckCSourceCompiles) + FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.ld" + "VERSION {\nlibmysqlclient_18 {\nglobal: *;\n};\n}\n") + SET(CMAKE_REQUIRED_LIBRARIES "-Wl,src.ld") + CHECK_C_SOURCE_COMPILES("int main() { return 0; }" + SUPPORTS_VERSION_IN_LINK_SCRIPT) + SET(CMAKE_REQUIRED_LIBRARIES) + + IF (NOT SUPPORTS_VERSION_IN_LINK_SCRIPT) + # https://sourceware.org/bugzilla/show_bug.cgi?id=16895 + MESSAGE(SEND_ERROR "Your current linker does not support VERSION " + "command in linker scripts like a GNU ld or any compatible linker " + "should. Perhaps you're using gold? Either switch to GNU ld compatible " + "linker or run cmake with -DDISABLE_LIBMYSQLCLIENT_SYMBOL_VERSIONING=TRUE " + "to be able to complete the build") + ENDIF (NOT SUPPORTS_VERSION_IN_LINK_SCRIPT) + # When building RPM, or DEB package on Debian, use ELF symbol versioning # for compatibility with distribution packages, so client shared library can # painlessly replace the one supplied by the distribution. @@ -358,14 +377,26 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux") make_scrambled_password_323 ) - # Linker script to version symbols in Fedora- and Debian- compatible way, MDEV-5529 - SET(VERSION_SCRIPT_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/libmysql_versions.ld.in) - # Generate version script. # Create semicolon separated lists of functions to export from # Since RPM packages use separate versioning for 5.1 API # and 5.5 API (libmysqlclient_16 vs libmysqlclient_18), # we need 2 lists. + SET (VERSION_HEADER +"VERSION { + libmysqlclient_18 { + global:") + SET (VERSION_FOOTER +" local: + *; + }; + + libmysqlclient_16 { + /* empty here. aliases are added above */ + }; +} +") + SET (CLIENT_API_5_1_LIST) SET (CLIENT_API_5_1_ALIASES) FOREACH (f ${CLIENT_API_FUNCTIONS_5_1} ${CLIENT_API_5_1_EXTRA}) @@ -378,6 +409,13 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux") SET(CLIENT_API_5_5_LIST "${CLIENT_API_5_5_LIST}\t${f};\n") ENDFOREACH() + ELSE (NOT DISABLE_LIBMYSQLCLIENT_SYMBOL_VERSIONING) + SET (CLIENT_API_5_1_ALIASES "/* Versioning disabled per user request. MDEV-5982 */") + ENDIF (NOT DISABLE_LIBMYSQLCLIENT_SYMBOL_VERSIONING) + + # Linker script to version symbols in Fedora- and Debian- compatible way, MDEV-5529 + SET(VERSION_SCRIPT_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/libmysql_versions.ld.in) + CONFIGURE_FILE( ${VERSION_SCRIPT_TEMPLATE} ${CMAKE_CURRENT_BINARY_DIR}/libmysql_versions.ld @@ -386,7 +424,7 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux") SET(VERSION_SCRIPT_LINK_FLAGS "-Wl,${CMAKE_CURRENT_BINARY_DIR}/libmysql_versions.ld") -ENDIF() +ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux") SET(CLIENT_SOURCES diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 3af4a032e5b..446f1da0b0c 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2232,7 +2232,7 @@ static int stmt_read_row_buffered(MYSQL_STMT *stmt, unsigned char **row) /* Read one row from network: unbuffered non-cursor fetch. - If last row was read, or error occured, erase this statement + If last row was read, or error occurred, erase this statement from record pointing to object unbuffered fetch is performed from. SYNOPSIS diff --git a/libmysql/libmysql_versions.ld.in b/libmysql/libmysql_versions.ld.in index 8d97da5b2eb..0cf5b45cc18 100644 --- a/libmysql/libmysql_versions.ld.in +++ b/libmysql/libmysql_versions.ld.in @@ -27,19 +27,7 @@ mysql_get_charset_by_csname = get_charset_by_csname; mysql_net_realloc = net_realloc; mysql_client_errors = client_errors; -VERSION { - -libmysqlclient_18 { - global: +@VERSION_HEADER@ @CLIENT_API_5_1_LIST@ @CLIENT_API_5_5_LIST@ - - local: - *; -}; - -libmysqlclient_16 { - /* empty here. aliases are added above */ -}; - -} +@VERSION_FOOTER@ diff --git a/man/mysql-test-run.pl.1 b/man/mysql-test-run.pl.1 index 495c0c50338..303c8877e87 100644 --- a/man/mysql-test-run.pl.1 +++ b/man/mysql-test-run.pl.1 @@ -1602,7 +1602,7 @@ may fail in total, as each repetition is considered a new test case, which may i \fB\-\-retry\-failure=\fR\fB\fIN\fR\fR .sp When using the \fB-\-retry\fR option to retry failed tests, -stop when N failures have occured (default 2)\&. Setting it to 0 or 1 effectively turns off retries\&. +stop when N failures have occurred (default 2)\&. Setting it to 0 or 1 effectively turns off retries\&. .RE .sp .RS 4 diff --git a/mysql-test/README b/mysql-test/README index 162551ad69c..0fba1cc07e3 100644 --- a/mysql-test/README +++ b/mysql-test/README @@ -11,7 +11,7 @@ All tests must pass. If one or more of them fail on your system, please read the following manual section for instructions on how to report the problem: -http://kb.askmonty.org/v/reporting-bugs +https://mariadb.com/kb/en/reporting-bugs If you want to use an already running MySQL server for specific tests, use the --extern option to mysql-test-run. Please note that in this mode, diff --git a/mysql-test/extra/rpl_tests/rpl_binlog_max_cache_size.test b/mysql-test/extra/rpl_tests/rpl_binlog_max_cache_size.test index e1faec8440b..0f46b00f683 100644 --- a/mysql-test/extra/rpl_tests/rpl_binlog_max_cache_size.test +++ b/mysql-test/extra/rpl_tests/rpl_binlog_max_cache_size.test @@ -375,7 +375,7 @@ source include/start_slave.inc; CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage.*"); CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_stmt_cache_size' bytes of storage.*"); CALL mtr.add_suppression("Writing one row to the row-based binary log failed.*"); -CALL mtr.add_suppression("Slave SQL.*The incident LOST_EVENTS occured on the master. Message: error writing to the binary log"); +CALL mtr.add_suppression("Slave SQL.*The incident LOST_EVENTS occurred on the master. Message: error writing to the binary log"); connection master; TRUNCATE t1; diff --git a/mysql-test/include/ctype_numconv.inc b/mysql-test/include/ctype_numconv.inc index 9e59f54a8b3..47b52be9cec 100644 --- a/mysql-test/include/ctype_numconv.inc +++ b/mysql-test/include/ctype_numconv.inc @@ -1819,6 +1819,12 @@ DROP FUNCTION f1; DROP TABLE t1; --echo # +--echo # MDEV-9662 Assertion `precision || !scale' failed in my_decimal_precision_to_length_no_truncation(uint, uint8, bool) +--echo # +SELECT @@collation_connection; +SELECT CASE 1 WHEN 2 THEN ( - '3' ) END; + +--echo # --echo # MDEV-5702 Incorrect results are returned with NULLIF() --echo # CREATE TABLE t1 (d DATE); diff --git a/mysql-test/include/have_crypt.inc b/mysql-test/include/have_crypt.inc index cbf0a7ac876..422f8922edc 100644 --- a/mysql-test/include/have_crypt.inc +++ b/mysql-test/include/have_crypt.inc @@ -1,4 +1,5 @@ --- require r/have_crypt.require -disable_query_log; -show variables like 'have_crypt'; -enable_query_log; +# encrypt('a') is NULL if crypt(3) is not available +# encrypt('a') is "*0" in fips mode +if (`select length(encrypt('a')) > 3 IS NOT TRUE`) { + skip No crypt(3); +} diff --git a/mysql-test/include/have_des.inc b/mysql-test/include/have_des.inc new file mode 100644 index 00000000000..5abdaf6e2aa --- /dev/null +++ b/mysql-test/include/have_des.inc @@ -0,0 +1,6 @@ +# in the FIPS mode, OpenSSL disables DES and other weak algorithms +source include/have_ssl_crypto_functs.inc; + +if (`select des_encrypt("a", "b") IS NULL`) { + skip DES is disabled (fips mode?); +} diff --git a/mysql-test/include/mtr_warnings.sql b/mysql-test/include/mtr_warnings.sql index 345968cd3f0..8f5a4fe6685 100644 --- a/mysql-test/include/mtr_warnings.sql +++ b/mysql-test/include/mtr_warnings.sql @@ -136,7 +136,7 @@ INSERT INTO global_suppressions VALUES ("Slave: Query caused different errors on master and slave"), ("Slave: Table .* doesn't exist"), ("Slave: Table width mismatch"), - ("Slave: The incident LOST_EVENTS occured on the master"), + ("Slave: The incident LOST_EVENTS occurred on the master"), ("Slave: Unknown error.* 1105"), ("Slave: Can't drop database.* database doesn't exist"), ("Time-out in NDB"), diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm index e7917f8fb16..a9b4f9a4ecc 100644 --- a/mysql-test/lib/My/SafeProcess.pm +++ b/mysql-test/lib/My/SafeProcess.pm @@ -34,7 +34,7 @@ package My::SafeProcess; # will zap the "monitored process" and exit # - the "monitored process" to exit, in which case it will exit # itself with same exit code as the "monitored process" -# - the parent process to send the "shutdown" signal in wich case +# - the parent process to send the "shutdown" signal in which case # monitor will kill the "monitored process" hard and exit # # diff --git a/mysql-test/lib/v1/mtr_report.pl b/mysql-test/lib/v1/mtr_report.pl index accf00dbb5d..9c957ea29c3 100644 --- a/mysql-test/lib/v1/mtr_report.pl +++ b/mysql-test/lib/v1/mtr_report.pl @@ -309,7 +309,7 @@ sub mtr_report_stats ($) { /Slave: Query caused different errors on master and slave/ or /Slave: Table .* doesn't exist/ or /Slave: Table width mismatch/ or - /Slave: The incident LOST_EVENTS occured on the master/ or + /Slave: The incident LOST_EVENTS occurred on the master/ or /Slave: Unknown error.* 1105/ or /Slave: Can't drop database.* database doesn't exist/ or /Slave SQL:.*(?:error.* \d+|Query:.*)/ or diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index df832d54ec7..a13a820dfe7 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3643,7 +3643,7 @@ sub mysql_install_db { # Create mtr database mtr_tofile($bootstrap_sql_file, - "CREATE DATABASE mtr;\n"); + "CREATE DATABASE mtr CHARSET=latin1;\n"); # Add help tables and data for warning detection and supression mtr_tofile($bootstrap_sql_file, @@ -6609,7 +6609,7 @@ Misc options failures before stopping, set with the --retry-failure option retry-failure=N When using the --retry option to retry failed tests, - stop when N failures have occured (default $opt_retry_failure) + stop when N failures have occurred (default $opt_retry_failure) reorder Reorder tests to get fewer server restarts help Get this help text diff --git a/mysql-test/r/alter_table_online.result b/mysql-test/r/alter_table_online.result index db7319cadf1..f416c53f42c 100644 --- a/mysql-test/r/alter_table_online.result +++ b/mysql-test/r/alter_table_online.result @@ -1,4 +1,3 @@ -drop table if exists t1,t2,t3; create table t1 (a int not null primary key, b int, c varchar(80), e enum('a','b')); insert into t1 (a) values (1),(2),(3); alter online table t1 modify b int default 5; @@ -62,3 +61,15 @@ create table t3 (a int not null primary key, b int, c varchar(80)) engine=merge alter online table t3 union=(t1,t2); ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE. drop table t1,t2,t3; +create table t1 (i int) partition by hash(i) partitions 2; +alter online table t1 comment 'test'; +drop table t1; +create table t1 (a int); +alter online table t1 modify a int comment 'test'; +drop table t1; +create table t1 (a int) engine=innodb; +alter online table t1 modify a int comment 'test'; +drop table t1; +create table t1 (a int) partition by hash(a) partitions 2; +alter online table t1 modify a int comment 'test'; +drop table t1; diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index 505d655b6bb..b06ec5805a0 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -502,3 +502,9 @@ a SELECT * FROM t1 WHERE a IN (0.8,0.9); a DROP TABLE t1; +# +# MDEV-9372 select 100 between 1 and 9223372036854775808 returns false +# +SELECT 100 BETWEEN 1 AND 9223372036854775808; +100 BETWEEN 1 AND 9223372036854775808 +1 diff --git a/mysql-test/r/cache_temporal_4265.result b/mysql-test/r/cache_temporal_4265.result index b8f13e465de..980bb957e19 100644 --- a/mysql-test/r/cache_temporal_4265.result +++ b/mysql-test/r/cache_temporal_4265.result @@ -8,4 +8,17 @@ a Warnings: Note 1003 2000-01-01 Note 1003 2000-01-06 +set debug_dbug=''; +drop table t1; +create table t1 (id int not null, ut timestamp(6) not null); +insert into t1 values(1, '2001-01-01 00:00:00.2'); +insert into t1 values(1, '2001-01-01 00:00:00.1'); +select * from t1; +id ut +1 2001-01-01 00:00:00.200000 +1 2001-01-01 00:00:00.100000 +select (select max(m2.ut) from t1 m2 where m1.id <> 0) from t1 m1; +(select max(m2.ut) from t1 m2 where m1.id <> 0) +2001-01-01 00:00:00.200000 +2001-01-01 00:00:00.200000 drop table t1; diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result index 3852da5d4b0..274d5da7d1c 100644 --- a/mysql-test/r/case.result +++ b/mysql-test/r/case.result @@ -231,3 +231,16 @@ case t1.f1 when '00:00:00' then 1 end 1 NULL drop table t1; +# +# MDEV-9745 Crash with CASE WHEN TRUE THEN COALESCE(CAST(NULL AS UNSIGNED)) ELSE 4 END +# +CREATE TABLE t1 SELECT CASE WHEN TRUE THEN COALESCE(CAST(NULL AS UNSIGNED)) ELSE 4 END AS a; +DESCRIBE t1; +Field Type Null Key Default Extra +a decimal(1,0) YES NULL +DROP TABLE t1; +CREATE TABLE t1 SELECT CASE WHEN TRUE THEN COALESCE(CAST(NULL AS UNSIGNED)) ELSE 40 END AS a; +DESCRIBE t1; +Field Type Null Key Default Extra +a decimal(2,0) YES NULL +DROP TABLE t1; diff --git a/mysql-test/r/contributors.result b/mysql-test/r/contributors.result index 5669c6b5269..1820c0a5f06 100644 --- a/mysql-test/r/contributors.result +++ b/mysql-test/r/contributors.result @@ -3,12 +3,12 @@ Name Location Comment Booking.com http://www.booking.com Founding member of the MariaDB Foundation MariaDB Corporation https://mariadb.com Founding member of the MariaDB Foundation Auttomattic http://automattic.com Member of the MariaDB Foundation -Parallels http://www.parallels.com/products/plesk Founding member of the MariaDB Foundation +Visma http://visma.com Member of the MariaDB Foundation +Nexedi http://www.nexedi.com Member of the MariaDB Foundation Acronis http://www.acronis.com Member of the MariaDB Foundation Verkkokauppa.com Finland Sponsor of the MariaDB Foundation Webyog Bangalore Sponsor of the MariaDB Foundation -Wikimedia Foundation USA Sponsor of the MariaDB Foundation -Google USA Sponsoring parallel replication and GTID +Google USA Sponsoring encryption, parallel replication and GTID Facebook USA Sponsoring non-blocking API, LIMIT ROWS EXAMINED etc Ronald Bradford Brisbane, Australia EFF contribution for UC2006 Auction Sheeri Kritzer Boston, Mass. USA EFF contribution for UC2006 Auction diff --git a/mysql-test/r/ctype_binary.result b/mysql-test/r/ctype_binary.result index aead73b3090..48b481883ca 100644 --- a/mysql-test/r/ctype_binary.result +++ b/mysql-test/r/ctype_binary.result @@ -2887,6 +2887,15 @@ f1() DROP FUNCTION f1; DROP TABLE t1; # +# MDEV-9662 Assertion `precision || !scale' failed in my_decimal_precision_to_length_no_truncation(uint, uint8, bool) +# +SELECT @@collation_connection; +@@collation_connection +binary +SELECT CASE 1 WHEN 2 THEN ( - '3' ) END; +CASE 1 WHEN 2 THEN ( - '3' ) END +NULL +# # MDEV-5702 Incorrect results are returned with NULLIF() # CREATE TABLE t1 (d DATE); diff --git a/mysql-test/r/ctype_cp1251.result b/mysql-test/r/ctype_cp1251.result index f7952a18f58..9d5dea2f286 100644 --- a/mysql-test/r/ctype_cp1251.result +++ b/mysql-test/r/ctype_cp1251.result @@ -3279,6 +3279,15 @@ f1() DROP FUNCTION f1; DROP TABLE t1; # +# MDEV-9662 Assertion `precision || !scale' failed in my_decimal_precision_to_length_no_truncation(uint, uint8, bool) +# +SELECT @@collation_connection; +@@collation_connection +cp1251_general_ci +SELECT CASE 1 WHEN 2 THEN ( - '3' ) END; +CASE 1 WHEN 2 THEN ( - '3' ) END +NULL +# # MDEV-5702 Incorrect results are returned with NULLIF() # CREATE TABLE t1 (d DATE); diff --git a/mysql-test/r/ctype_cp850.result b/mysql-test/r/ctype_cp850.result new file mode 100644 index 00000000000..c028f72b58a --- /dev/null +++ b/mysql-test/r/ctype_cp850.result @@ -0,0 +1,14 @@ +# +# Start of 5.5 tests +# +# +# MDEV-9862 Illegal mix of collation, when comparing column with CASE expression +# +SET NAMES cp850; +CREATE TABLE t1 (a CHAR(1) CHARACTER SET latin1); +SELECT a FROM t1 WHERE CASE a WHEN 'aaaa' THEN 'Y' WHEN 'aaaa' THEN 'Y' ELSE NULL END <> a; +a +DROP TABLE t1; +# +# End of 5.5 tests +# diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result index 383ea3ca8f2..eee915267d5 100644 --- a/mysql-test/r/ctype_latin1.result +++ b/mysql-test/r/ctype_latin1.result @@ -3563,6 +3563,15 @@ f1() DROP FUNCTION f1; DROP TABLE t1; # +# MDEV-9662 Assertion `precision || !scale' failed in my_decimal_precision_to_length_no_truncation(uint, uint8, bool) +# +SELECT @@collation_connection; +@@collation_connection +latin1_swedish_ci +SELECT CASE 1 WHEN 2 THEN ( - '3' ) END; +CASE 1 WHEN 2 THEN ( - '3' ) END +NULL +# # MDEV-5702 Incorrect results are returned with NULLIF() # CREATE TABLE t1 (d DATE); diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 68435f3f41c..6b3d87b79e1 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -4470,6 +4470,15 @@ f1() DROP FUNCTION f1; DROP TABLE t1; # +# MDEV-9662 Assertion `precision || !scale' failed in my_decimal_precision_to_length_no_truncation(uint, uint8, bool) +# +SELECT @@collation_connection; +@@collation_connection +ucs2_general_ci +SELECT CASE 1 WHEN 2 THEN ( - '3' ) END; +CASE 1 WHEN 2 THEN ( - '3' ) END +NULL +# # MDEV-5702 Incorrect results are returned with NULLIF() # CREATE TABLE t1 (d DATE); diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 532c54dd79e..4123b06b0a7 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -5338,6 +5338,15 @@ f1() DROP FUNCTION f1; DROP TABLE t1; # +# MDEV-9662 Assertion `precision || !scale' failed in my_decimal_precision_to_length_no_truncation(uint, uint8, bool) +# +SELECT @@collation_connection; +@@collation_connection +utf8_general_ci +SELECT CASE 1 WHEN 2 THEN ( - '3' ) END; +CASE 1 WHEN 2 THEN ( - '3' ) END +NULL +# # MDEV-5702 Incorrect results are returned with NULLIF() # CREATE TABLE t1 (d DATE); diff --git a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result index 0eb0661b0e2..98c8b599e88 100644 --- a/mysql-test/r/delayed.result +++ b/mysql-test/r/delayed.result @@ -379,7 +379,7 @@ SELECT * FROM t1 WHERE a=0; a # Connection con1 # Sending: -ALTER TABLE t1 COMMENT 'test'; +ALTER TABLE t1 MODIFY a INT UNSIGNED;; # Connection default # Wait until ALTER TABLE is blocked on table 't1'. INSERT DELAYED INTO t1 VALUES (3); diff --git a/mysql-test/r/events_2.result b/mysql-test/r/events_2.result index 3b7f3566cab..06075b0e66e 100644 --- a/mysql-test/r/events_2.result +++ b/mysql-test/r/events_2.result @@ -1,10 +1,10 @@ drop database if exists events_test; create database events_test; use events_test; -create event e_26 on schedule at '2017-01-01 00:00:00' disable do set @a = 5; +create event e_26 on schedule at '2027-01-01 00:00:00' disable do set @a = 5; select db, name, body, definer, convert_tz(execute_at, 'UTC', 'SYSTEM'), on_completion from mysql.event; db name body definer convert_tz(execute_at, 'UTC', 'SYSTEM') on_completion -events_test e_26 set @a = 5 root@localhost 2017-01-01 00:00:00 DROP +events_test e_26 set @a = 5 root@localhost 2027-01-01 00:00:00 DROP drop event e_26; create event e_26 on schedule at NULL disable do set @a = 5; ERROR HY000: Incorrect AT value: 'NULL' diff --git a/mysql-test/r/events_bugs.result b/mysql-test/r/events_bugs.result index f1ff0faaa47..3e12b43e72c 100644 --- a/mysql-test/r/events_bugs.result +++ b/mysql-test/r/events_bugs.result @@ -602,7 +602,7 @@ INSERT INTO events_test.event_log VALUES (NULL,@evname,@cnt+1,current_timestamp( ROLLBACK; END IF; END;| -Sleep till the first INSERT into events_test.event_log occured +Sleep till the first INSERT into events_test.event_log occurred SELECT COUNT(*) > 0 AS "Expect 1" FROM events_test.event_log; Expect 1 1 diff --git a/mysql-test/r/fulltext3.result b/mysql-test/r/fulltext3.result index 4ec48369ad1..c0b871cd5a7 100644 --- a/mysql-test/r/fulltext3.result +++ b/mysql-test/r/fulltext3.result @@ -15,3 +15,15 @@ CREATE TABLE t1(a VARCHAR(2) CHARACTER SET big5 COLLATE big5_chinese_ci, FULLTEXT(a)); INSERT INTO t1 VALUES(0xA3C2); DROP TABLE t1; +create table t1 ( +id varchar(255), +business_name text null collate utf8mb4_unicode_ci, +street_address text, +fulltext index ft (business_name), +fulltext index ft2 (street_address) +); +select * from t1 where match (business_name, street_address) against ('some business name and address here'); +ERROR HY000: Can't find FULLTEXT index matching the column list +select * from t1 where match (business_name, street_address) against ('some business name and address here' in boolean mode); +id business_name street_address +drop table t1; diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index 3631af8a22f..1259661f0b6 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -660,9 +660,14 @@ ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 DIV CREATE TABLE t1(a BIGINT, b BIGINT UNSIGNED); INSERT INTO t1 VALUES(-9223372036854775808, 9223372036854775809); SELECT -a FROM t1; -ERROR 22003: BIGINT value is out of range in '-(-9223372036854775808)' +ERROR 22003: BIGINT value is out of range in '-(`test`.`t1`.`a`)' SELECT -b FROM t1; -ERROR 22003: BIGINT value is out of range in '-(9223372036854775809)' +ERROR 22003: BIGINT value is out of range in '-(`test`.`t1`.`b`)' +INSERT INTO t1 VALUES(0,0); +SELECT -a FROM t1; +ERROR 22003: BIGINT value is out of range in '-(`test`.`t1`.`a`)' +SELECT -b FROM t1; +ERROR 22003: BIGINT value is out of range in '-(`test`.`t1`.`b`)' DROP TABLE t1; SET @a:=999999999999999999999999999999999999999999999999999999999999999999999999999999999; SELECT @a + @a; diff --git a/mysql-test/r/grant5.result b/mysql-test/r/grant5.result index 2df394c0432..d7f3b6812bb 100644 --- a/mysql-test/r/grant5.result +++ b/mysql-test/r/grant5.result @@ -1,2 +1,18 @@ SHOW GRANTS FOR root@invalid_host; ERROR 42000: There is no such grant defined for user 'root' on host 'invalid_host' +create user test; +create user foo; +create role foo; +grant foo to test; +set role foo; +show grants for test; +Grants for test@% +GRANT foo TO 'test'@'%' +GRANT USAGE ON *.* TO 'test'@'%' +show grants for foo; +Grants for foo +GRANT USAGE ON *.* TO 'foo' +show grants for foo@'%'; +ERROR 42000: Access denied for user 'test'@'%' to database 'mysql' +drop user test, foo; +drop role foo; diff --git a/mysql-test/r/have_crypt.require b/mysql-test/r/have_crypt.require deleted file mode 100644 index 739fbb738f0..00000000000 --- a/mysql-test/r/have_crypt.require +++ /dev/null @@ -1,2 +0,0 @@ -Variable_name Value -have_crypt YES diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result index c907997573a..fcd5eebefa4 100644 --- a/mysql-test/r/index_merge_myisam.result +++ b/mysql-test/r/index_merge_myisam.result @@ -1595,7 +1595,7 @@ explain select * from t1 where a=10 and b=10 or c=10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge a,b,c a,c 5,5 NULL 54 Using union(a,c); Using where This will switch to sort-union (intersection will be gone, too, -thats a known limitation: +that's a known limitation: set optimizer_switch='default,index_merge_union=off'; explain select * from t1 where a=10 and b=10 or c=10; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/r/insert_innodb.result b/mysql-test/r/insert_innodb.result new file mode 100644 index 00000000000..ffba9388ec4 --- /dev/null +++ b/mysql-test/r/insert_innodb.result @@ -0,0 +1,30 @@ +# +# BUG#22037930: INSERT IGNORE FAILS TO IGNORE +# FOREIGN KEY CONSTRAINT +# Setup. +CREATE TABLE t1 (fld1 INT PRIMARY KEY) ENGINE=INNODB; +CREATE TABLE t2 (fld2 INT, FOREIGN KEY (fld2) REFERENCES t1 (fld1)) +ENGINE=INNODB; +INSERT INTO t1 VALUES(0); +INSERT INTO t2 VALUES(0); +# Without fix, an error is reported. +INSERT IGNORE INTO t2 VALUES(1); +Warnings: +Warning 1452 Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`fld2`) REFERENCES `t1` (`fld1`)) +UPDATE IGNORE t2 SET fld2=20 WHERE fld2=0; +UPDATE IGNORE t1 SET fld1=20 WHERE fld1=0; +# Test for multi update. +UPDATE IGNORE t1, t2 SET t2.fld2= t2.fld2 + 3; +UPDATE IGNORE t1, t2 SET t1.fld1= t1.fld1 + 3; +# Reports an error since IGNORE is not used. +INSERT INTO t2 VALUES(1); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`fld2`) REFERENCES `t1` (`fld1`)) +UPDATE t2 SET fld2=20 WHERE fld2=0; +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`fld2`) REFERENCES `t1` (`fld1`)) +UPDATE t1 SET fld1=20 WHERE fld1=0; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`fld2`) REFERENCES `t1` (`fld1`)) +UPDATE t1, t2 SET t2.fld2= t2.fld2 + 3; +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`fld2`) REFERENCES `t1` (`fld1`)) +UPDATE t1, t2 SET t1.fld1= t1.fld1 + 3; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`fld2`) REFERENCES `t1` (`fld1`)) +DROP TABLE t2, t1; diff --git a/mysql-test/r/locale.result b/mysql-test/r/locale.result index 1335f1ec9d5..c28cedae8b1 100644 --- a/mysql-test/r/locale.result +++ b/mysql-test/r/locale.result @@ -90,6 +90,17 @@ SELECT DATE_FORMAT('2001-01-07', '%w %a %W'); DATE_FORMAT('2001-01-07', '%w %a %W') 0 Du Duminică End of 5.4 tests +SET NAMES utf8; +SET lc_time_names=de_AT; +SELECT monthname('2001-01-01'); +monthname('2001-01-01') +Jänner +SELECT monthname('2001-02-01'); +monthname('2001-02-01') +Februar +SELECT monthname('2001-03-01'); +monthname('2001-03-01') +März # # Start of 5.6 tests # diff --git a/mysql-test/r/mdev6830.result b/mysql-test/r/mdev6830.result index 0570659e860..d1cf8c98ac1 100644 --- a/mysql-test/r/mdev6830.result +++ b/mysql-test/r/mdev6830.result @@ -1,5 +1,4 @@ -drop table if exists t1,t2,t3; -drop view if exists v2,v3; +set @@debug_dbug= 'd,opt'; CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=MyISAM; CREATE TABLE t2 ( f1 DATE, diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result index 673b889970e..ef07db5ac52 100644 --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result @@ -1170,10 +1170,8 @@ binlog-stmt-cache-size 32768 bulk-insert-buffer-size 8388608 character-set-client-handshake TRUE character-set-filesystem binary -character-set-server latin1 character-sets-dir MYSQL_CHARSETSDIR/ chroot (No default value) -collation-server latin1_swedish_ci completion-type NO_CHAIN concurrent-insert AUTO console FALSE @@ -1427,7 +1425,7 @@ sysdate-is-now FALSE table-cache 400 table-definition-cache 400 table-open-cache 400 -tc-heuristic-recover COMMIT +tc-heuristic-recover OFF thread-cache-size 0 thread-pool-idle-timeout 60 thread-pool-max-threads 500 diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 1725291d4c6..b6de51c8b03 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -1821,7 +1821,7 @@ a b Osnabrück Köln drop table t1; # -# Bug#15328 Segmentation fault occured if my.cnf is invalid for escape sequence +# Bug#15328 Segmentation fault occurred if my.cnf is invalid for escape sequence # --fields-optionally-enclosed-by=" # diff --git a/mysql-test/r/openssl_1.result b/mysql-test/r/openssl_1.result index c5dd1500110..dd78b1967c4 100644 --- a/mysql-test/r/openssl_1.result +++ b/mysql-test/r/openssl_1.result @@ -207,3 +207,12 @@ Variable_name Value Ssl_cipher DHE-RSA-AES256-SHA DROP USER bug42158@localhost; End of 5.1 tests +/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; +/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; +DELIMITER /*!*/; +DELIMITER ; +# End of log file +ROLLBACK /* added by mysqlbinlog */; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; +/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; diff --git a/mysql-test/r/select_debug.result b/mysql-test/r/select_debug.result index a056affc2cd..55882ad337a 100644 --- a/mysql-test/r/select_debug.result +++ b/mysql-test/r/select_debug.result @@ -6,7 +6,7 @@ insert into t1 values (2,2), (1,1); create table t2 (a int); insert into t2 values (2), (3); set session join_cache_level=3; -set @@debug_dbug= 'd:t:O,/tmp/trace.out'; +set @@debug_dbug= 'd,opt'; explain select t1.b from t1,t2 where t1.b=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where diff --git a/mysql-test/r/set_password_plugin-9835.result b/mysql-test/r/set_password_plugin-9835.result new file mode 100644 index 00000000000..e9ee09fe952 --- /dev/null +++ b/mysql-test/r/set_password_plugin-9835.result @@ -0,0 +1,158 @@ +create user natauth@localhost identified via 'mysql_native_password' using '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29'; +create user newpass@localhost identified by password '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29'; +create user newpassnat@localhost identified via 'mysql_native_password'; +set password for newpassnat@localhost = '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29'; +create user oldauth@localhost identified with 'mysql_old_password' using '378b243e220ca493'; +create user oldpass@localhost identified by password '378b243e220ca493'; +create user oldpassold@localhost identified with 'mysql_old_password'; +set password for oldpassold@localhost = '378b243e220ca493'; +select user, host, password, plugin, authentication_string from mysql.user where user != 'root'; +user host password plugin authentication_string +natauth localhost mysql_native_password *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 +newpass localhost *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 +newpassnat localhost *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 +oldauth localhost mysql_old_password 378b243e220ca493 +oldpass localhost 378b243e220ca493 +oldpassold localhost 378b243e220ca493 +connect con,localhost,natauth,test,; +select current_user(); +current_user() +natauth@localhost +disconnect con; +connect con,localhost,newpass,test,; +select current_user(); +current_user() +newpass@localhost +disconnect con; +connect con,localhost,newpassnat,test,; +select current_user(); +current_user() +newpassnat@localhost +disconnect con; +connect con,localhost,oldauth,test,; +select current_user(); +current_user() +oldauth@localhost +disconnect con; +connect con,localhost,oldpass,test,; +select current_user(); +current_user() +oldpass@localhost +disconnect con; +connect con,localhost,oldpassold,test,; +select current_user(); +current_user() +oldpassold@localhost +disconnect con; +connection default; +flush privileges; +connect con,localhost,natauth,test,; +select current_user(); +current_user() +natauth@localhost +disconnect con; +connect con,localhost,newpass,test,; +select current_user(); +current_user() +newpass@localhost +disconnect con; +connect con,localhost,newpassnat,test,; +select current_user(); +current_user() +newpassnat@localhost +disconnect con; +connect con,localhost,oldauth,test,; +select current_user(); +current_user() +oldauth@localhost +disconnect con; +connect con,localhost,oldpass,test,; +select current_user(); +current_user() +oldpass@localhost +disconnect con; +connect con,localhost,oldpassold,test,; +select current_user(); +current_user() +oldpassold@localhost +disconnect con; +connection default; +set password for natauth@localhost = PASSWORD('test2'); +set password for newpass@localhost = PASSWORD('test2'); +set password for newpassnat@localhost = PASSWORD('test2'); +set password for oldauth@localhost = PASSWORD('test2'); +set password for oldpass@localhost = PASSWORD('test2'); +set password for oldpassold@localhost = PASSWORD('test2'); +select user, host, password, plugin, authentication_string from mysql.user where user != 'root'; +user host password plugin authentication_string +natauth localhost *7CEB3FDE5F7A9C4CE5FBE610D7D8EDA62EBE5F4E +newpass localhost *7CEB3FDE5F7A9C4CE5FBE610D7D8EDA62EBE5F4E +newpassnat localhost *7CEB3FDE5F7A9C4CE5FBE610D7D8EDA62EBE5F4E +oldauth localhost *7CEB3FDE5F7A9C4CE5FBE610D7D8EDA62EBE5F4E +oldpass localhost *7CEB3FDE5F7A9C4CE5FBE610D7D8EDA62EBE5F4E +oldpassold localhost *7CEB3FDE5F7A9C4CE5FBE610D7D8EDA62EBE5F4E +connect con,localhost,natauth,test2,; +select current_user(); +current_user() +natauth@localhost +disconnect con; +connect con,localhost,newpass,test2,; +select current_user(); +current_user() +newpass@localhost +disconnect con; +connect con,localhost,newpassnat,test2,; +select current_user(); +current_user() +newpassnat@localhost +disconnect con; +connect con,localhost,oldauth,test2,; +select current_user(); +current_user() +oldauth@localhost +disconnect con; +connect con,localhost,oldpass,test2,; +select current_user(); +current_user() +oldpass@localhost +disconnect con; +connect con,localhost,oldpassold,test2,; +select current_user(); +current_user() +oldpassold@localhost +disconnect con; +connection default; +flush privileges; +connect con,localhost,natauth,test2,; +select current_user(); +current_user() +natauth@localhost +disconnect con; +connect con,localhost,newpass,test2,; +select current_user(); +current_user() +newpass@localhost +disconnect con; +connect con,localhost,newpassnat,test2,; +select current_user(); +current_user() +newpassnat@localhost +disconnect con; +connect con,localhost,oldauth,test2,; +select current_user(); +current_user() +oldauth@localhost +disconnect con; +connect con,localhost,oldpass,test2,; +select current_user(); +current_user() +oldpass@localhost +disconnect con; +connect con,localhost,oldpassold,test2,; +select current_user(); +current_user() +oldpassold@localhost +disconnect con; +connection default; +drop user natauth@localhost, newpass@localhost, newpassnat@localhost; +drop user oldauth@localhost, oldpass@localhost, oldpassold@localhost; diff --git a/mysql-test/r/show_grants_with_plugin-7985.result b/mysql-test/r/show_grants_with_plugin-7985.result index 5accda75383..1898c316ac5 100644 --- a/mysql-test/r/show_grants_with_plugin-7985.result +++ b/mysql-test/r/show_grants_with_plugin-7985.result @@ -71,7 +71,7 @@ connection default; set password for u1 = PASSWORD('SOMETHINGELSE'); select user, host, password, plugin, authentication_string from mysql.user where user = 'u1'; user host password plugin authentication_string -u1 % *054B7BBD2B9A553DA560520DCD3F76DA2D81B7C6 mysql_native_password *7AFEFD08B6B720E781FB000CAA418F54FA662626 +u1 % *054B7BBD2B9A553DA560520DCD3F76DA2D81B7C6 # # Here we should use the password field, as that primes over # the authentication_string field. @@ -115,7 +115,7 @@ connection default; update mysql.user set authentication_string = '' where user='u1'; select user, host, password, plugin, authentication_string from mysql.user where user = 'u1'; user host password plugin authentication_string -u1 % *054B7BBD2B9A553DA560520DCD3F76DA2D81B7C6 mysql_native_password +u1 % *054B7BBD2B9A553DA560520DCD3F76DA2D81B7C6 flush privileges; show grants for u1; Grants for u1@% @@ -127,7 +127,7 @@ GRANT SELECT ON `mysql`.* TO 'u1'@'%' connect con1, localhost, u1,'SOMETHINGELSE',; select user, host, password, plugin, authentication_string from mysql.user where user = 'u1'; user host password plugin authentication_string -u1 % *054B7BBD2B9A553DA560520DCD3F76DA2D81B7C6 mysql_native_password +u1 % *054B7BBD2B9A553DA560520DCD3F76DA2D81B7C6 disconnect con1; connection default; # diff --git a/mysql-test/r/sp-threads.result b/mysql-test/r/sp-threads.result index 4ce61c44762..ddf709d462b 100644 --- a/mysql-test/r/sp-threads.result +++ b/mysql-test/r/sp-threads.result @@ -32,12 +32,9 @@ update t1, t2 set val= 1 where id1=id2; call bug9486(); lock tables t2 write; call bug9486(); -show processlist; -Id User Host db Command Time State Info Progress -# root localhost test Sleep # NULL 0.000 -# root localhost test Query # Waiting for table metadata lock update t1, t2 set val= 1 where id1=id2 0.000 -# root localhost test Query # init show processlist 0.000 -# root localhost test Sleep # NULL 0.000 +SELECT state,info FROM information_schema.processlist WHERE id=con1root_id; +state info +Waiting for table metadata lock update t1, t2 set val= 1 where id1=id2 unlock tables; drop procedure bug9486; drop table t1, t2; diff --git a/mysql-test/r/ssl_timeout-9836.result b/mysql-test/r/ssl_timeout-9836.result new file mode 100644 index 00000000000..bc2e19e1475 --- /dev/null +++ b/mysql-test/r/ssl_timeout-9836.result @@ -0,0 +1,7 @@ +SET @@net_read_timeout=1; +SELECT 1; +1 +1 +SELECT 1; +1 +1 diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index 66c9e7e48ef..95b82bdef82 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -439,6 +439,41 @@ select 1 from t1 as t1_0 inner join t1 as t2 on (t1_0.a <=> now()) join t1 on 1; 1 drop table t1; # +# MDEV-9521 Least function returns 0000-00-00 for null date columns instead of null +# +CREATE TABLE t1 ( +id BIGINT NOT NULL, +date_debut DATE NOT NULL, +date_fin DATE DEFAULT NULL); +CREATE TABLE t2( +id BIGINT NOT NULL, +date_debut DATE NOT NULL, +date_fin DATE DEFAULT NULL); +INSERT INTO t1 VALUES (1,'2016-01-01','2016-01-31'); +INSERT INTO t1 VALUES (2,'2016-02-01',null); +INSERT INTO t1 VALUES (3,'2016-03-01','2016-03-31'); +INSERT INTO t1 VALUES (4,'2016-04-01',null); +INSERT INTO t2 VALUES (1,'2016-01-01','2016-01-31'); +INSERT INTO t2 VALUES (2,'2016-02-01','2016-01-28'); +INSERT INTO t2 VALUES (3,'2016-03-01',null); +INSERT INTO t2 VALUES (4,'2016-04-01',null); +SELECT t1.id, +GREATEST(t2.date_debut, t1.date_debut) AS date_debut, +LEAST(IFNULL(t2.date_fin, IFNULL(t1.date_fin, NULL)), +IFNULL(t1.date_fin, IFNULL(t2.date_fin, NULL))) AS date_fin +FROM t1 LEFT JOIN t2 ON (t1.id=t2.id); +id date_debut date_fin +1 2016-01-01 2016-01-31 00:00:00 +2 2016-02-01 2016-01-28 00:00:00 +3 2016-03-01 2016-03-31 00:00:00 +4 2016-04-01 NULL +DROP TABLE t1,t2; +SELECT +LEAST(COALESCE(DATE(NULL), DATE(NULL)), COALESCE(DATE(NULL), DATE(NULL))) AS d0, +LEAST(IFNULL(DATE(NULL), DATE(NULL)), IFNULL(DATE(NULL), DATE(NULL))) AS d1; +d0 d1 +NULL NULL +# # MDEV-9511 Valgrind warnings 'Invalid read' in Field_newdate::cmp and Field_newdate::val_str # CREATE TABLE t1 (f1 DATE, f2 VARCHAR(1)); diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result index 1ec2dfc565f..28ec7e75870 100644 --- a/mysql-test/r/type_timestamp.result +++ b/mysql-test/r/type_timestamp.result @@ -644,6 +644,15 @@ SELECT MAX(dt) = '2011-01-06 12:34:30' FROM t1; MAX(dt) = '2011-01-06 12:34:30' 1 DROP TABLE t1; +# +# MDEV-9413 "datetime >= coalesce(c1(NULL))" doesn't return expected NULL +# +CREATE TABLE t1(c1 TIMESTAMP(6) NULL DEFAULT NULL); +INSERT INTO t1 VALUES(NULL); +SELECT c1, '2016-06-13 20:00:00.000003' >= COALESCE( c1 ) FROM t1; +c1 '2016-06-13 20:00:00.000003' >= COALESCE( c1 ) +NULL NULL +DROP TABLE t1; End of 5.5 tests # # MDEV-7254: Assigned expression is evaluated twice when updating column TIMESTAMP NOT NULL diff --git a/mysql-test/r/wait_timeout_not_windows.result b/mysql-test/r/wait_timeout_not_windows.result new file mode 100644 index 00000000000..df70aa99221 --- /dev/null +++ b/mysql-test/r/wait_timeout_not_windows.result @@ -0,0 +1,3 @@ +set global log_warnings=2; +set @@wait_timeout=1; +set global log_warnings=@@log_warnings; diff --git a/mysql-test/suite/archive/partition_archive.result b/mysql-test/suite/archive/partition_archive.result index eb1fca46522..c4cccc03a04 100644 --- a/mysql-test/suite/archive/partition_archive.result +++ b/mysql-test/suite/archive/partition_archive.result @@ -153,3 +153,9 @@ t1 CREATE TABLE `t1` ( PARTITIONS 5 */ #Cleanup. DROP TABLE t1; +create database mysqltest1; +create table mysqltest1.t1 (a int not null, b int not null) engine=archive +partition by list(a) subpartition by hash(b) +(partition p1 values in (1), +partition p2 values in (2)); +drop database mysqltest1; diff --git a/mysql-test/suite/archive/partition_archive.test b/mysql-test/suite/archive/partition_archive.test index 899f266c09c..aa2adb7e44d 100644 --- a/mysql-test/suite/archive/partition_archive.test +++ b/mysql-test/suite/archive/partition_archive.test @@ -147,3 +147,10 @@ SHOW CREATE TABLE t1; --echo #Cleanup. DROP TABLE t1; + +create database mysqltest1; +create table mysqltest1.t1 (a int not null, b int not null) engine=archive + partition by list(a) subpartition by hash(b) + (partition p1 values in (1), + partition p2 values in (2)); +drop database mysqltest1; diff --git a/mysql-test/suite/binlog/r/binlog_row_binlog.result b/mysql-test/suite/binlog/r/binlog_row_binlog.result index 05009c5a570..cabb5672c8d 100644 --- a/mysql-test/suite/binlog/r/binlog_row_binlog.result +++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result @@ -683,7 +683,7 @@ master-bin.000001 # Query # # COMMIT master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE TABLE IF NOT EXISTS `t3` ( `a` int(11) DEFAULT NULL -) +) ENGINE=MyISAM master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (mysql.user) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F diff --git a/mysql-test/suite/innodb/r/innodb-agregate.result b/mysql-test/suite/innodb/r/innodb-agregate.result new file mode 100644 index 00000000000..d3e096c7eb0 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-agregate.result @@ -0,0 +1,21 @@ +create table t2 (a smallint(6) not null, b int(10) not null, name varchar(20), primary key(a,b), key(name)) engine=InnoDB; +insert into t2 values (8355,3,"sanja"),(8355,4,"wlad"),(8366,5, "lawrin"),(8366,6,"markusjm"); +select count(distinct name) from t2 where a=8366 and b>=5 and b<=5; +count(distinct name) +1 +select count(distinct name) from t2 where a=8366 and b=5; +count(distinct name) +1 +select count(distinct name) from t2 where a=8366 and b between 5 and 5.5; +count(distinct name) +1 +select sum(distinct a) from t2 where a=8366 and b>=5 and b<=5; +sum(distinct a) +8366 +select sum(distinct a) from t2 where a=8366 and b=5; +sum(distinct a) +8366 +select sum(distinct a) from t2 where a=8366 and b between 5 and 5.5; +sum(distinct a) +8366 +drop table t2; diff --git a/mysql-test/suite/innodb/r/innodb-corrupted-table.result b/mysql-test/suite/innodb/r/innodb-corrupted-table.result new file mode 100644 index 00000000000..61d10fbb949 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-corrupted-table.result @@ -0,0 +1,49 @@ +call mtr.add_suppression("Table .* has a primary key in InnoDB data dictionary, but not in MySQL.*"); +call mtr.add_suppression("InnoDB: Table .* contains .* indexes inside InnoDB, which is different from the number of indexes .* defined in the MySQL.*"); +create table t1 (pk int, i int, key(i)) engine=InnoDB; +insert into t1 values (1,1),(2,2); +flush tables; +# Save the .frm file without the PK +alter table t1 add primary key (pk); +# Stop the server, replace the frm with the old one and restart the server +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) DEFAULT NULL, + `i` int(11) DEFAULT NULL, + KEY `i` (`i`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +Warnings: +Warning 1082 InnoDB: Table test/t1 has a primary key in InnoDB data dictionary, but not in MySQL! +Warning 1082 InnoDB: Table test/t1 contains 2 indexes inside InnoDB, which is different from the number of indexes 1 defined in the MySQL +select * from t1; +pk i +1 1 +2 2 +alter table t1 add j int; +Warnings: +Warning 1082 InnoDB: Table test/t1 contains 2 indexes inside InnoDB, which is different from the number of indexes 1 defined in the MySQL +show warnings; +Level Code Message +Warning 1082 InnoDB: Table test/t1 contains 2 indexes inside InnoDB, which is different from the number of indexes 1 defined in the MySQL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) DEFAULT NULL, + `i` int(11) DEFAULT NULL, + `j` int(11) DEFAULT NULL, + KEY `i` (`i`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +alter table t1 add primary key (pk); +show warnings; +Level Code Message +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL DEFAULT '0', + `i` int(11) DEFAULT NULL, + `j` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `i` (`i`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/suite/innodb/r/innodb-fk.result b/mysql-test/suite/innodb/r/innodb-fk.result index c916d665bf0..2eb19764769 100644 --- a/mysql-test/suite/innodb/r/innodb-fk.result +++ b/mysql-test/suite/innodb/r/innodb-fk.result @@ -70,6 +70,50 @@ Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key c Warning 1215 Cannot add foreign key constraint drop table t2; drop table t1; +CREATE DATABASE kg_test1; +CREATE DATABASE kg_test2; +CREATE TABLE `kg_test1`.`group` ( +Id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE `kg_test1`.`person` ( +`Id` INT(11) NOT NULL AUTO_INCREMENT, +`Name` VARCHAR(50) NOT NULL, +PRIMARY KEY (`Id`), +CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `group` (`Id`) +) ENGINE=INNODB DEFAULT CHARSET=utf8; +show create table `kg_test1`.`person`; +Table Create Table +person CREATE TABLE `person` ( + `Id` int(11) NOT NULL AUTO_INCREMENT, + `Name` varchar(50) NOT NULL, + PRIMARY KEY (`Id`), + CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `group` (`Id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +CREATE TABLE `kg_test2`.`person2` ( +`Id` INT(11) NOT NULL AUTO_INCREMENT, +`Name` VARCHAR(50) NOT NULL, +PRIMARY KEY (`Id`), +CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `group` (`Id`) +) ENGINE=INNODB DEFAULT CHARSET=utf8; +ERROR HY000: Can't create table `kg_test2`.`person2` (errno: 150 "Foreign key constraint is incorrectly formed") +CREATE TABLE `kg_test2`.`person2` ( +`Id` INT(11) NOT NULL AUTO_INCREMENT, +`Name` VARCHAR(50) NOT NULL, +PRIMARY KEY (`Id`), +CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `kg_test1`.`group` (`Id`) +) ENGINE=INNODB DEFAULT CHARSET=utf8; +show create table `kg_test2`.`person2`; +Table Create Table +person2 CREATE TABLE `person2` ( + `Id` int(11) NOT NULL AUTO_INCREMENT, + `Name` varchar(50) NOT NULL, + PRIMARY KEY (`Id`), + CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `kg_test1`.`group` (`Id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +SHOW WARNINGS; +Level Code Message +DROP DATABASE kg_test2; +DROP DATABASE kg_test1; CREATE TABLE `#departaments` ( `id_depart` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id_depart`) diff --git a/mysql-test/suite/innodb/t/innodb-agregate.test b/mysql-test/suite/innodb/t/innodb-agregate.test new file mode 100644 index 00000000000..e15548c087a --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-agregate.test @@ -0,0 +1,18 @@ +--source include/have_innodb.inc + +# +# MDEV-9667: Server hangs after select count(distinct name) from t2 where a=8366 and b>=5 and b<=5; +# + +create table t2 (a smallint(6) not null, b int(10) not null, name varchar(20), primary key(a,b), key(name)) engine=InnoDB; + +insert into t2 values (8355,3,"sanja"),(8355,4,"wlad"),(8366,5, "lawrin"),(8366,6,"markusjm"); + +select count(distinct name) from t2 where a=8366 and b>=5 and b<=5; +select count(distinct name) from t2 where a=8366 and b=5; +select count(distinct name) from t2 where a=8366 and b between 5 and 5.5; +select sum(distinct a) from t2 where a=8366 and b>=5 and b<=5; +select sum(distinct a) from t2 where a=8366 and b=5; +select sum(distinct a) from t2 where a=8366 and b between 5 and 5.5; + +drop table t2; diff --git a/mysql-test/suite/innodb/t/innodb-corrupted-table.test b/mysql-test/suite/innodb/t/innodb-corrupted-table.test new file mode 100644 index 00000000000..94c5454429f --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-corrupted-table.test @@ -0,0 +1,46 @@ +--source include/have_innodb.inc +--source include/not_embedded.inc + +# +# MDEV-9918: [ERROR] mysqld got signal 11 during ALTER TABLE `name` COLUMN ADD +# + +call mtr.add_suppression("Table .* has a primary key in InnoDB data dictionary, but not in MySQL.*"); +call mtr.add_suppression("InnoDB: Table .* contains .* indexes inside InnoDB, which is different from the number of indexes .* defined in the MySQL.*"); + +create table t1 (pk int, i int, key(i)) engine=InnoDB; +insert into t1 values (1,1),(2,2); + +--let $datadir= `select @@datadir` + +flush tables; + +--echo # Save the .frm file without the PK + +--copy_file $datadir/test/t1.frm $MYSQLTEST_VARDIR/tmp/t1.frm + +alter table t1 add primary key (pk); + +--echo # Stop the server, replace the frm with the old one and restart the server + +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--shutdown_server 10 +--source include/wait_until_disconnected.inc + +--remove_file $datadir/test/t1.frm +--copy_file $MYSQLTEST_VARDIR/tmp/t1.frm $datadir/test/t1.frm + +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--enable_reconnect +--source include/wait_until_connected_again.inc + +show create table t1; +select * from t1; +alter table t1 add j int; +show warnings; +show create table t1; +alter table t1 add primary key (pk); +show warnings; +show create table t1; +# Cleanup +drop table t1; diff --git a/mysql-test/suite/innodb/t/innodb-fk.test b/mysql-test/suite/innodb/t/innodb-fk.test index f7bcbe238dd..17e926e8647 100644 --- a/mysql-test/suite/innodb/t/innodb-fk.test +++ b/mysql-test/suite/innodb/t/innodb-fk.test @@ -126,6 +126,47 @@ drop table t2; drop table t1; # +# MDEV-9142 :Adding Constraint with no database reference +# results in ERROR 1046 (3D000) at line 13: No database selected +# +CREATE DATABASE kg_test1; +CREATE DATABASE kg_test2; + +CREATE TABLE `kg_test1`.`group` ( + Id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `kg_test1`.`person` ( +`Id` INT(11) NOT NULL AUTO_INCREMENT, +`Name` VARCHAR(50) NOT NULL, +PRIMARY KEY (`Id`), +CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `group` (`Id`) +) ENGINE=INNODB DEFAULT CHARSET=utf8; + +show create table `kg_test1`.`person`; + +--error 1005 +CREATE TABLE `kg_test2`.`person2` ( +`Id` INT(11) NOT NULL AUTO_INCREMENT, +`Name` VARCHAR(50) NOT NULL, +PRIMARY KEY (`Id`), +CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `group` (`Id`) +) ENGINE=INNODB DEFAULT CHARSET=utf8; + +CREATE TABLE `kg_test2`.`person2` ( +`Id` INT(11) NOT NULL AUTO_INCREMENT, +`Name` VARCHAR(50) NOT NULL, +PRIMARY KEY (`Id`), +CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `kg_test1`.`group` (`Id`) +) ENGINE=INNODB DEFAULT CHARSET=utf8; + +show create table `kg_test2`.`person2`; + +SHOW WARNINGS; +DROP DATABASE kg_test2; +DROP DATABASE kg_test1; + +# # MDEV-7627: Some symbols in table name can cause to Error Code: 1050 when created FK # diff --git a/mysql-test/suite/multi_source/gtid_ignore_duplicates.test b/mysql-test/suite/multi_source/gtid_ignore_duplicates.test index 1eea038f8c9..4d98b5c2ee7 100644 --- a/mysql-test/suite/multi_source/gtid_ignore_duplicates.test +++ b/mysql-test/suite/multi_source/gtid_ignore_duplicates.test @@ -337,7 +337,7 @@ START SLAVE; --source include/wait_for_slave_to_start.inc --replace_result $gtid GTID eval SELECT MASTER_GTID_WAIT("$gtid", 30); -# The bug occured here, the slave would get an out-of-order binlog error +# The bug occurred here, the slave would get an out-of-order binlog error # due to trying to re-apply the 100-x-x transaction. # Restart stopped multi-source connections, and sync up. diff --git a/mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test b/mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test index d06edb0d78f..086d31113f8 100644 --- a/mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test +++ b/mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test @@ -1651,7 +1651,7 @@ if($print_details) --enable_result_log --horizontal_results --echo # Dump detailed differences after - before statement execution - --echo # 1. The statement executing connection and hopefully noone else + --echo # 1. The statement executing connection and hopefully no one else SELECT @default_object_instance_begin; SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN, COUNT_READ, SUM_NUMBER_OF_BYTES_READ, diff --git a/mysql-test/suite/perfschema/t/socket_summary_by_instance_func_win.test b/mysql-test/suite/perfschema/t/socket_summary_by_instance_func_win.test index cefaf1de549..0ecb51af203 100644 --- a/mysql-test/suite/perfschema/t/socket_summary_by_instance_func_win.test +++ b/mysql-test/suite/perfschema/t/socket_summary_by_instance_func_win.test @@ -1663,7 +1663,7 @@ if($print_details) --enable_result_log --horizontal_results --echo # Dump detailed differences after - before statement execution - --echo # 1. The statement executing connection and hopefully noone else + --echo # 1. The statement executing connection and hopefully no one else SELECT @default_object_instance_begin; SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN, COUNT_READ, SUM_NUMBER_OF_BYTES_READ, diff --git a/mysql-test/suite/rpl/r/create_or_replace_mix.result b/mysql-test/suite/rpl/r/create_or_replace_mix.result index 839032a305c..f2471ac5f9e 100644 --- a/mysql-test/suite/rpl/r/create_or_replace_mix.result +++ b/mysql-test/suite/rpl/r/create_or_replace_mix.result @@ -153,7 +153,7 @@ slave-bin.000001 # Query # # COMMIT slave-bin.000001 # Gtid # # GTID #-#-# slave-bin.000001 # Query # # use `test`; CREATE TABLE `t4` ( `a` int(11) DEFAULT NULL -) +) ENGINE=MyISAM slave-bin.000001 # Gtid # # BEGIN GTID #-#-# slave-bin.000001 # Query # # use `test`; CREATE TABLE `t5` ( `a` int(11) DEFAULT NULL diff --git a/mysql-test/suite/rpl/r/create_or_replace_row.result b/mysql-test/suite/rpl/r/create_or_replace_row.result index 6e29d02e3bc..4645d032482 100644 --- a/mysql-test/suite/rpl/r/create_or_replace_row.result +++ b/mysql-test/suite/rpl/r/create_or_replace_row.result @@ -39,7 +39,7 @@ master-bin.000001 # Query # # use `test`; CREATE OR REPLACE table t1 like t2 master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( `a_in_temporary` int(11) DEFAULT NULL -) +) ENGINE=MyISAM master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ binlog from server 2 @@ -72,7 +72,7 @@ slave-bin.000001 # Query # # use `test`; CREATE OR REPLACE table t1 like t2 slave-bin.000001 # Gtid # # GTID #-#-# slave-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE `t1` ( `a_in_temporary` int(11) DEFAULT NULL -) +) ENGINE=MyISAM slave-bin.000001 # Gtid # # GTID #-#-# slave-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */ # @@ -175,7 +175,7 @@ slave-bin.000001 # Query # # COMMIT slave-bin.000001 # Gtid # # GTID #-#-# slave-bin.000001 # Query # # use `test`; CREATE TABLE `t4` ( `a` int(11) DEFAULT NULL -) +) ENGINE=MyISAM slave-bin.000001 # Gtid # # BEGIN GTID #-#-# slave-bin.000001 # Query # # use `test`; CREATE TABLE `t5` ( `a` int(11) DEFAULT NULL diff --git a/mysql-test/suite/rpl/r/create_or_replace_statement.result b/mysql-test/suite/rpl/r/create_or_replace_statement.result index 8550976e87a..8c8f9bb2ccd 100644 --- a/mysql-test/suite/rpl/r/create_or_replace_statement.result +++ b/mysql-test/suite/rpl/r/create_or_replace_statement.result @@ -153,7 +153,7 @@ slave-bin.000001 # Query # # COMMIT slave-bin.000001 # Gtid # # GTID #-#-# slave-bin.000001 # Query # # use `test`; CREATE TABLE `t4` ( `a` int(11) DEFAULT NULL -) +) ENGINE=MyISAM slave-bin.000001 # Gtid # # BEGIN GTID #-#-# slave-bin.000001 # Query # # use `test`; CREATE TABLE `t5` ( `a` int(11) DEFAULT NULL diff --git a/mysql-test/suite/rpl/r/rpl_checksum.result b/mysql-test/suite/rpl/r/rpl_checksum.result index d88258f3b65..94d215e596a 100644 --- a/mysql-test/suite/rpl/r/rpl_checksum.result +++ b/mysql-test/suite/rpl/r/rpl_checksum.result @@ -142,7 +142,7 @@ ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) SET debug_dbug= @old_dbug; INSERT INTO t4 VALUES (2); include/wait_for_slave_sql_error.inc [errno=1590] -Last_SQL_Error = 'The incident LOST_EVENTS occured on the master. Message: error writing to the binary log' +Last_SQL_Error = 'The incident LOST_EVENTS occurred on the master. Message: error writing to the binary log' SELECT * FROM t4 ORDER BY a; a 1 diff --git a/mysql-test/suite/rpl/r/rpl_incident.result b/mysql-test/suite/rpl/r/rpl_incident.result index 5e725e36389..7cb8168c6a9 100644 --- a/mysql-test/suite/rpl/r/rpl_incident.result +++ b/mysql-test/suite/rpl/r/rpl_incident.result @@ -16,9 +16,9 @@ a 2 3 4 -call mtr.add_suppression("Slave SQL.*The incident LOST_EVENTS occured on the master.* 1590"); +call mtr.add_suppression("Slave SQL.*The incident LOST_EVENTS occurred on the master.* 1590"); include/wait_for_slave_sql_error.inc [errno=1590] -Last_SQL_Error = 'The incident LOST_EVENTS occured on the master. Message: <none>' +Last_SQL_Error = 'The incident LOST_EVENTS occurred on the master. Message: <none>' **** On Slave **** SELECT * FROM t1; a diff --git a/mysql-test/suite/rpl/r/rpl_killed_ddl.result b/mysql-test/suite/rpl/r/rpl_killed_ddl.result index a02c9b599bf..ed8745ca2c1 100644 --- a/mysql-test/suite/rpl/r/rpl_killed_ddl.result +++ b/mysql-test/suite/rpl/r/rpl_killed_ddl.result @@ -56,6 +56,10 @@ CREATE VIEW v1 AS SELECT a FROM t1 WHERE a < 100; CREATE DATABASE d2; source include/kill_query.inc; include/rpl_diff.inc +ALTER DATABASE d1 +DEFAULT CHARACTER SET = 'utf8'; +source include/kill_query.inc; +include/rpl_diff.inc DROP DATABASE d1; source include/kill_query.inc; include/rpl_diff.inc @@ -83,6 +87,9 @@ include/rpl_diff.inc DROP FUNCTION f1; source include/kill_query.inc; include/rpl_diff.inc +DROP FUNCTION IF EXISTS f2; +source include/kill_query.inc; +include/rpl_diff.inc CREATE PROCEDURE p2 (OUT rows INT) BEGIN SELECT COUNT(*) INTO rows FROM t2; @@ -96,6 +103,9 @@ include/rpl_diff.inc DROP PROCEDURE p1; source include/kill_query.inc; include/rpl_diff.inc +DROP PROCEDURE IF EXISTS p2; +source include/kill_query.inc; +include/rpl_diff.inc CREATE TABLE t2 (b int); source include/kill_query.inc; include/rpl_diff.inc diff --git a/mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result b/mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result index 06f9f5617b5..80f76169472 100644 --- a/mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result +++ b/mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result @@ -151,7 +151,7 @@ include/start_slave.inc CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage.*"); CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_stmt_cache_size' bytes of storage.*"); CALL mtr.add_suppression("Writing one row to the row-based binary log failed.*"); -CALL mtr.add_suppression("Slave SQL.*The incident LOST_EVENTS occured on the master. Message: error writing to the binary log"); +CALL mtr.add_suppression("Slave SQL.*The incident LOST_EVENTS occurred on the master. Message: error writing to the binary log"); TRUNCATE t1; SET GLOBAL max_binlog_cache_size= ORIGINAL_VALUE; SET GLOBAL binlog_cache_size= ORIGINAL_VALUE; diff --git a/mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result b/mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result index a4f76da1872..71edcd749e5 100644 --- a/mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result +++ b/mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result @@ -152,7 +152,7 @@ include/start_slave.inc CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage.*"); CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_stmt_cache_size' bytes of storage.*"); CALL mtr.add_suppression("Writing one row to the row-based binary log failed.*"); -CALL mtr.add_suppression("Slave SQL.*The incident LOST_EVENTS occured on the master. Message: error writing to the binary log"); +CALL mtr.add_suppression("Slave SQL.*The incident LOST_EVENTS occurred on the master. Message: error writing to the binary log"); TRUNCATE t1; SET GLOBAL max_binlog_cache_size= ORIGINAL_VALUE; SET GLOBAL binlog_cache_size= ORIGINAL_VALUE; diff --git a/mysql-test/suite/rpl/r/rpl_row_create_table.result b/mysql-test/suite/rpl/r/rpl_row_create_table.result index 9c04f580c07..3030c8e5238 100644 --- a/mysql-test/suite/rpl/r/rpl_row_create_table.result +++ b/mysql-test/suite/rpl/r/rpl_row_create_table.result @@ -194,7 +194,7 @@ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE TABLE `t9` ( `a` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL -) +) ENGINE=MyISAM **** On Slave **** SHOW CREATE TABLE t8; Table t8 @@ -207,7 +207,7 @@ Table t9 Create Table CREATE TABLE `t9` ( `a` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL -) ENGINE=MEMORY DEFAULT CHARSET=latin1 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9; STOP SLAVE; include/wait_for_slave_to_stop.inc diff --git a/mysql-test/suite/rpl/r/rpl_row_merge_engine.result b/mysql-test/suite/rpl/r/rpl_row_merge_engine.result index c61167e84e0..3b2e02bf97c 100644 --- a/mysql-test/suite/rpl/r/rpl_row_merge_engine.result +++ b/mysql-test/suite/rpl/r/rpl_row_merge_engine.result @@ -4,8 +4,9 @@ CREATE TABLE t1 (a int) ENGINE=MyISAM; CREATE TABLE t2 (a int) ENGINE=MyISAM; INSERT INTO t1 VALUES (1), (2), (3); INSERT INTO t2 VALUES (4), (5), (6); -CREATE TABLE IF NOT EXISTS t1_merge LIKE t1; -ALTER TABLE t1_merge ENGINE=MERGE UNION (t2, t1); +CREATE TEMPORARY TABLE IF NOT EXISTS tt1_merge LIKE t1; +ALTER TABLE tt1_merge ENGINE=MERGE UNION (t2, t1); +CREATE TABLE t1_merge LIKE tt1_merge; include/diff_tables.inc [master:test.t1, slave:test.t1] include/diff_tables.inc [master:test.t2, slave:test.t2] UPDATE t1_merge SET a=10 WHERE a=1; diff --git a/mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result b/mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result index 06f9f5617b5..80f76169472 100644 --- a/mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result +++ b/mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result @@ -151,7 +151,7 @@ include/start_slave.inc CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage.*"); CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_stmt_cache_size' bytes of storage.*"); CALL mtr.add_suppression("Writing one row to the row-based binary log failed.*"); -CALL mtr.add_suppression("Slave SQL.*The incident LOST_EVENTS occured on the master. Message: error writing to the binary log"); +CALL mtr.add_suppression("Slave SQL.*The incident LOST_EVENTS occurred on the master. Message: error writing to the binary log"); TRUNCATE t1; SET GLOBAL max_binlog_cache_size= ORIGINAL_VALUE; SET GLOBAL binlog_cache_size= ORIGINAL_VALUE; diff --git a/mysql-test/suite/rpl/r/rpl_tmp_table_and_DDL_innodb.result b/mysql-test/suite/rpl/r/rpl_tmp_table_and_DDL_innodb.result new file mode 100644 index 00000000000..4a5bc3b76e5 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_tmp_table_and_DDL_innodb.result @@ -0,0 +1,13 @@ +include/master-slave.inc +[connection master] +CREATE TEMPORARY TABLE temp_t1 (c1 INT) ENGINE=InnoDB; +CREATE TEMPORARY TABLE temp_t2 (c1 INT) ENGINE=MyISAM; +CREATE TABLE t1 LIKE temp_t1; +CREATE TABLE t2 LIKE temp_t2; +include/assert.inc ["t1 on master and temp_t1 have the same storage engine"] +include/assert.inc ["t2 on master and temp_t2 have the same storage engine"] +include/assert.inc ["t1 on slave and temp_t1 have the same storage engine"] +include/assert.inc ["t2 on slave and temp_t2 have the same storage engine"] +DROP TEMPORARY TABLE temp_t1, temp_t2; +DROP TABLE t1, t2; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_checksum.test b/mysql-test/suite/rpl/t/rpl_checksum.test index bd0ab7ecc9c..1cf9091033e 100644 --- a/mysql-test/suite/rpl/t/rpl_checksum.test +++ b/mysql-test/suite/rpl/t/rpl_checksum.test @@ -298,7 +298,7 @@ if(!$log_error_) } --let SEARCH_FILE= $log_error_ --let SEARCH_RANGE=-50000 ---let SEARCH_PATTERN= Slave SQL: The incident LOST_EVENTS occured on the master\. Message: error writing to the binary log, Internal MariaDB error code: 1590 +--let SEARCH_PATTERN= Slave SQL: The incident LOST_EVENTS occurred on the master\. Message: error writing to the binary log, Internal MariaDB error code: 1590 --source include/search_pattern_in_file.inc SELECT * FROM t4 ORDER BY a; diff --git a/mysql-test/suite/rpl/t/rpl_gtid_errorlog.test b/mysql-test/suite/rpl/t/rpl_gtid_errorlog.test index 24298e9893a..137ac6c0f5d 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_errorlog.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_errorlog.test @@ -66,7 +66,7 @@ if(!$log_error_) --let SEARCH_RANGE=-50000 --let SEARCH_PATTERN=Slave SQL: Error 'Duplicate entry .* on query\. .*Query: '.*', Gtid 0-1-100, Internal MariaDB error code:|Slave SQL: Could not execute Write_rows.*table test.t1; Duplicate entry.*, Gtid 0-1-100, Internal MariaDB error --source include/search_pattern_in_file.inc ---let SEARCH_PATTERN=Slave SQL: The incident LOST_EVENTS occured on the master\. Message: <none>, Internal MariaDB error code: 1590 +--let SEARCH_PATTERN=Slave SQL: The incident LOST_EVENTS occurred on the master\. Message: <none>, Internal MariaDB error code: 1590 --source include/search_pattern_in_file.inc diff --git a/mysql-test/suite/rpl/t/rpl_incident.test b/mysql-test/suite/rpl/t/rpl_incident.test index c591a8261c4..adf20953b0f 100644 --- a/mysql-test/suite/rpl/t/rpl_incident.test +++ b/mysql-test/suite/rpl/t/rpl_incident.test @@ -22,7 +22,7 @@ eval SET GLOBAL debug_dbug= '$debug_save'; connection slave; # Wait until SQL thread stops with error LOST_EVENT on master -call mtr.add_suppression("Slave SQL.*The incident LOST_EVENTS occured on the master.* 1590"); +call mtr.add_suppression("Slave SQL.*The incident LOST_EVENTS occurred on the master.* 1590"); let $slave_sql_errno= 1590; let $show_slave_sql_error= 1; source include/wait_for_slave_sql_error.inc; diff --git a/mysql-test/suite/rpl/t/rpl_killed_ddl.test b/mysql-test/suite/rpl/t/rpl_killed_ddl.test index eff0392d5de..a910ab4bc5c 100644 --- a/mysql-test/suite/rpl/t/rpl_killed_ddl.test +++ b/mysql-test/suite/rpl/t/rpl_killed_ddl.test @@ -26,10 +26,8 @@ # # There are some part of the test are temporarily disabled because of # the following bugs, please enable then once they get fixed: -# - BUG#44041 -# - BUG#43353 -# - BUG#25705 -# - BUG#44171 +# - BUG#22473427 +# - Bug#22587377 # Temporarily disabled on Windows due to bug #47638 --source include/not_windows.inc @@ -148,11 +146,9 @@ let $rpl_diff_statement= SELECT schema_name FROM information_schema.schemata send CREATE DATABASE d2; source include/kill_query_and_diff_master_slave.inc; -# Temporarily disabled, see BUG#44041, the ALTER DATABASE can affect the -# collation of other database on slave -#send ALTER DATABASE d1 -# DEFAULT CHARACTER SET = 'utf8'; -#source include/kill_query_and_diff_master_slave.inc; +send ALTER DATABASE d1 + DEFAULT CHARACTER SET = 'utf8'; +source include/kill_query_and_diff_master_slave.inc; send DROP DATABASE d1; source include/kill_query_and_diff_master_slave.inc; @@ -171,8 +167,8 @@ send CREATE EVENT e2 DO INSERT INTO test.t1 VALUES (2); source include/kill_query_and_diff_master_slave.inc; -# Temporarily disabled because of BUG#44171, killing ALTER EVENT can -# crash the server +# Temporarily disabled,see Bug#22587377-RPL.RPL_KILLED_DDL +# FAILS SPORADICALLY ON PB2 IN 5.5 AND 5.6 #send ALTER EVENT e1 # ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 2 DAY; #source include/kill_query_and_diff_master_slave.inc; @@ -201,16 +197,8 @@ source include/kill_query_and_diff_master_slave.inc; # function f2 probably does not exist because the CREATE query was # killed -# -# Temporarily disabled. Because of BUG#43353, KILL the query may -# result in function not found, and for 5.1, DROP statements will be -# logged if the function is not found on master, so the following DROP -# FUNCTION statement may be interrupted and not drop the function on -# master, but still get logged and executed on slave and cause -# inconsistence. Also disable the following DROP PROCEDURE IF EXITS -# below. -#send DROP FUNCTION IF EXISTS f2; -#source include/kill_query_and_diff_master_slave.inc; +send DROP FUNCTION IF EXISTS f2; +source include/kill_query_and_diff_master_slave.inc; ######## PROCEDURE ######## @@ -231,9 +219,8 @@ source include/kill_query_and_diff_master_slave.inc; send DROP PROCEDURE p1; source include/kill_query_and_diff_master_slave.inc; -# Temporarily disabled because of bug#43353, see comment above for DROP FUNCTION IF EXISTS -#send DROP PROCEDURE IF EXISTS p2; -#source include/kill_query_and_diff_master_slave.inc; +send DROP PROCEDURE IF EXISTS p2; +source include/kill_query_and_diff_master_slave.inc; ######## TABLE ######## @@ -261,9 +248,10 @@ source include/kill_query_and_diff_master_slave.inc; ######## SERVER ######## -# Tempoarily disabled, see bug#25705 +# Temporarily disabled, see Bug #22473427 - DROP SERVER FAILS +# AFTER ALTER SERVER+KILL QUERY -# --let $rpl_diff_statement= SELECT * FROM mysql.server WHERE name like \'s%\' +# --let $rpl_diff_statement= SELECT * FROM mysql.servers WHERE Server_name like \'s%\' # send CREATE SERVER s2 # FOREIGN DATA WRAPPER mysql diff --git a/mysql-test/suite/rpl/t/rpl_row_merge_engine.test b/mysql-test/suite/rpl/t/rpl_row_merge_engine.test index 5add8dc1cda..dcbb8b891d8 100644 --- a/mysql-test/suite/rpl/t/rpl_row_merge_engine.test +++ b/mysql-test/suite/rpl/t/rpl_row_merge_engine.test @@ -20,8 +20,10 @@ CREATE TABLE t1 (a int) ENGINE=MyISAM; CREATE TABLE t2 (a int) ENGINE=MyISAM; INSERT INTO t1 VALUES (1), (2), (3); INSERT INTO t2 VALUES (4), (5), (6); -CREATE TABLE IF NOT EXISTS t1_merge LIKE t1; -ALTER TABLE t1_merge ENGINE=MERGE UNION (t2, t1); +# Changed a little to check also an issue reported on BUG#20574550 +CREATE TEMPORARY TABLE IF NOT EXISTS tt1_merge LIKE t1; +ALTER TABLE tt1_merge ENGINE=MERGE UNION (t2, t1); +CREATE TABLE t1_merge LIKE tt1_merge; --sync_slave_with_master diff --git a/mysql-test/suite/rpl/t/rpl_tmp_table_and_DDL_innodb.test b/mysql-test/suite/rpl/t/rpl_tmp_table_and_DDL_innodb.test new file mode 100644 index 00000000000..1a09b685249 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_tmp_table_and_DDL_innodb.test @@ -0,0 +1,55 @@ +source include/have_innodb.inc; +source include/have_binlog_format_row.inc; +source include/master-slave.inc; +# +# BUG#20574550 +# CREATE TABLE LIKE <TEMP_TABLE> does not preserve original table storage +# engine when using row based replication +# +--connection master + +# Define temp_t1 and temp_t2 storage engines +--let $engine_temp_t1= InnoDB +--let $engine_temp_t2= MyISAM + +# Create the two temporary tables +--eval CREATE TEMPORARY TABLE temp_t1 (c1 INT) ENGINE=$engine_temp_t1 +--eval CREATE TEMPORARY TABLE temp_t2 (c1 INT) ENGINE=$engine_temp_t2 + +# Create t1 and t2 based on temporary tables +CREATE TABLE t1 LIKE temp_t1; +CREATE TABLE t2 LIKE temp_t2; +--sync_slave_with_master + +# On master +--connection master +# Assert that t1 and t2 have the same storage engines as temp_t1 and temp_t2 +--let $engine_t1= query_get_value(SHOW TABLE STATUS WHERE Name='t1', Engine, 1) +--let $assert_cond= "$engine_t1" = "$engine_temp_t1" +--let $assert_text= "t1 on master and temp_t1 have the same storage engine" +--source include/assert.inc + +--let $engine_t2= query_get_value(SHOW TABLE STATUS WHERE Name='t2', Engine, 1) +--let $assert_cond= "$engine_t2" = "$engine_temp_t2" +--let $assert_text= "t2 on master and temp_t2 have the same storage engine" +--source include/assert.inc + +# On slave +--connection slave +# Assert that t1 and t2 have the same storage engines as temp_t1 and temp_t2 +--let $engine_t1= query_get_value(SHOW TABLE STATUS WHERE Name='t1', Engine, 1) +--let $assert_cond= "$engine_t1" = "$engine_temp_t1" +--let $assert_text= "t1 on slave and temp_t1 have the same storage engine" +--source include/assert.inc + +--let $engine_t2= query_get_value(SHOW TABLE STATUS WHERE Name='t2', Engine, 1) +--let $assert_cond= "$engine_t2" = "$engine_temp_t2" +--let $assert_text= "t2 on slave and temp_t2 have the same storage engine" +--source include/assert.inc + +# Cleanup +--connection master +DROP TEMPORARY TABLE temp_t1, temp_t2; +DROP TABLE t1, t2; +--source include/rpl_end.inc + diff --git a/mysql-test/suite/stress/include/ddl1.inc b/mysql-test/suite/stress/include/ddl1.inc index 96adadc5af5..00e64cee395 100644 --- a/mysql-test/suite/stress/include/ddl1.inc +++ b/mysql-test/suite/stress/include/ddl1.inc @@ -111,10 +111,10 @@ # # 6. Hints for analysis of test failures: # 1. Look into the protocol and check in which ddl*.inc -# script the difference to the expected result occured. +# script the difference to the expected result occurred. # 2. Comment the sourcing of all other ddl*.inc scripts # out. -# 3. Edit the ddl*.inc script where the error occured and +# 3. Edit the ddl*.inc script where the error occurred and # remove all # - "--disable_query_log", "--disable_result_log" # - successful passed subtests. diff --git a/mysql-test/suite/sys_vars/t/innodb_buffer_pool_load_now_basic.test b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_load_now_basic.test index fe376a3032e..a0409901865 100644 --- a/mysql-test/suite/sys_vars/t/innodb_buffer_pool_load_now_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_load_now_basic.test @@ -8,12 +8,32 @@ SET @orig = @@global.innodb_buffer_pool_load_now; SELECT @orig; +let $old_status= `SELECT variable_value FROM information_schema.global_status + WHERE LOWER(variable_name) = 'innodb_buffer_pool_dump_status'`; + +# A previous test could have run buffer pool dump already; +# in this case we want to make sure that the current time is different +# from the timestamp in the status variable. +# We should have had a smart wait condition here, like the commented one below, +# but we can't because of MDEV-9867, so there will be just sleep instead. +# And it might be not enough to sleep one second, so we'll have to sleep two. +# let $wait_condition = +# SELECT TRIM(SUBSTR('$old_status', -8)) != DATE_FORMAT(CURTIME(), '%k:%i:%s'); +# -- source include/wait_condition.inc + +if (`SELECT variable_value LIKE '%dump completed at%' FROM information_schema.global_status + WHERE LOWER(variable_name) = 'innodb_buffer_pool_dump_status'`) +{ + -- sleep 2 +} + # Do the dump SET GLOBAL innodb_buffer_pool_dump_now = ON; # Wait for the dump to complete let $wait_condition = - SELECT SUBSTR(variable_value, 1, 33) = 'Buffer pool(s) dump completed at ' + SELECT variable_value != '$old_status' + AND SUBSTR(variable_value, 1, 33) = 'Buffer pool(s) dump completed at ' FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_dump_status'; -- source include/wait_condition.inc diff --git a/mysql-test/suite/sys_vars/t/innodb_empty_free_list_algorithm_basic.opt b/mysql-test/suite/sys_vars/t/innodb_empty_free_list_algorithm_basic.opt new file mode 100644 index 00000000000..c788dc76ac7 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_empty_free_list_algorithm_basic.opt @@ -0,0 +1 @@ +--loose-innodb-buffer-pool-size=20M diff --git a/mysql-test/suite/sys_vars/t/secure_file_priv.test b/mysql-test/suite/sys_vars/t/secure_file_priv.test index 3e2a4fa467a..5c53da58275 100644 --- a/mysql-test/suite/sys_vars/t/secure_file_priv.test +++ b/mysql-test/suite/sys_vars/t/secure_file_priv.test @@ -5,17 +5,39 @@ CREATE TABLE t1 (c1 VARCHAR(50)); INSERT INTO t1 VALUES ("one"),("two"),("three"),("four"),("five"); SHOW VARIABLES LIKE 'secure_file_priv'; --disable_query_log + # Atempt to create a file where we normally aren't allowed to create one. +# # Doing this in a portable manner is difficult but we should be able to -# count on the depth of the directory hierarchy used. Three steps up from -# the datadir is the 'mysql_test' directory. ---let $PROTECTED_FILE=`SELECT concat(@@datadir,'/../../../bug50373.txt')` ---eval SELECT * FROM t1 INTO OUTFILE '$PROTECTED_FILE'; -DELETE FROM t1; ---eval LOAD DATA INFILE '$PROTECTED_FILE' INTO TABLE t1; -SELECT * FROM t1; ---eval SELECT load_file('$PROTECTED_FILE') AS loaded_file; +# count on the directory hierarchy used. A step up from MYSQLTEST_VARDIR +# should definitely lead us to a "protected" directory, +# but at the same time should still be writable since MTR was able +# to create the vardir itself there. +# If we run tests normally, it will be mysql-test directory. +# If we run tests with --mem, it will be /dev/shm. +# If we run tests with --parallel, it will be mysql-test/var +# (because MYSQLTEST_VARDIR in this case is mysql-test/var/N). + +--perl +use File::Basename; +my $protected_file= dirname($ENV{MYSQLTEST_VARDIR}).'/bug50373.txt'; +open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/bug50373.inc") or die; +print FILE "SELECT * FROM t1 INTO OUTFILE '".$protected_file."';\n"; +print FILE "DELETE FROM t1;\n"; +print FILE "LOAD DATA INFILE '".$protected_file."' INTO TABLE t1;\n"; +print FILE "SELECT * FROM t1;\n"; +print FILE "SELECT load_file('",$protected_file,"') AS loaded_file;\n"; +close(FILE); +EOF + +--source $MYSQL_TMP_DIR/bug50373.inc +--remove_file $MYSQL_TMP_DIR/bug50373.inc --enable_query_log -remove_file $PROTECTED_FILE; + DROP TABLE t1; +--perl +use File::Basename; +unlink dirname($ENV{MYSQLTEST_VARDIR}).'/bug50373.txt'; +EOF + diff --git a/mysql-test/t/alter_table_online.test b/mysql-test/t/alter_table_online.test index a160abc8fe2..d9c2a2c4d4f 100644 --- a/mysql-test/t/alter_table_online.test +++ b/mysql-test/t/alter_table_online.test @@ -3,9 +3,7 @@ # --source include/have_innodb.inc ---disable_warnings -drop table if exists t1,t2,t3; ---enable_warnings +--source include/have_partition.inc # # Test of things that can be done online # @@ -101,3 +99,25 @@ create table t3 (a int not null primary key, b int, c varchar(80)) engine=merge --error ER_ALTER_OPERATION_NOT_SUPPORTED alter online table t3 union=(t1,t2); drop table t1,t2,t3; + +# +# MDEV-9868 Altering a partitioned table comment does a full copy +# +create table t1 (i int) partition by hash(i) partitions 2; +alter online table t1 comment 'test'; +drop table t1; + +# +# MDEV-9168 altering a column comment does a full copy +# +create table t1 (a int); +alter online table t1 modify a int comment 'test'; +drop table t1; + +create table t1 (a int) engine=innodb; +alter online table t1 modify a int comment 'test'; +drop table t1; + +create table t1 (a int) partition by hash(a) partitions 2; +alter online table t1 modify a int comment 'test'; +drop table t1; diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index 41f33b8a7f2..fb18d60edd9 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -409,3 +409,8 @@ SELECT * FROM t1 WHERE a=0.9; SELECT * FROM t1 WHERE a IN (0.8,0.9); DROP TABLE t1; + +--echo # +--echo # MDEV-9372 select 100 between 1 and 9223372036854775808 returns false +--echo # +SELECT 100 BETWEEN 1 AND 9223372036854775808; diff --git a/mysql-test/t/bootstrap.test b/mysql-test/t/bootstrap.test index 97376eb7412..e2d21c0d990 100644 --- a/mysql-test/t/bootstrap.test +++ b/mysql-test/t/bootstrap.test @@ -79,7 +79,7 @@ EOF # --write_file $MYSQLTEST_VARDIR/tmp/bootstrap_plugins.sql use test; -create table t1(a int) engine=example; +create table t1(a int) engine=example charset=latin1; EOF --exec $MYSQLD_BOOTSTRAP_CMD --plugin-dir=$PLUGIN_DIR < $MYSQLTEST_VARDIR/tmp/bootstrap_plugins.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1 --remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_plugins.sql diff --git a/mysql-test/t/cache_temporal_4265.test b/mysql-test/t/cache_temporal_4265.test index 6135438f023..c62f3c3c506 100644 --- a/mysql-test/t/cache_temporal_4265.test +++ b/mysql-test/t/cache_temporal_4265.test @@ -7,5 +7,16 @@ create table t1 (a date); insert t1 values ('2000-01-02'), ('2001-02-03'), ('2002-03-04'); set debug_dbug='d,str_to_datetime_warn'; select * from t1 where a > date_add('2000-01-01', interval 5 day); +set debug_dbug=''; +drop table t1; + +# +# MDEV-9707 MAX(timestamp(6) column) in correlated sub-query returns non-existent row data in original table +# +create table t1 (id int not null, ut timestamp(6) not null); +insert into t1 values(1, '2001-01-01 00:00:00.2'); +insert into t1 values(1, '2001-01-01 00:00:00.1'); +select * from t1; +select (select max(m2.ut) from t1 m2 where m1.id <> 0) from t1 m1; drop table t1; diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test index f536f556780..c127836d352 100644 --- a/mysql-test/t/case.test +++ b/mysql-test/t/case.test @@ -193,3 +193,12 @@ insert t1 values ('00:00:00'),('00:01:00'); select case t1.f1 when '00:00:00' then 1 end from t1; drop table t1; +--echo # +--echo # MDEV-9745 Crash with CASE WHEN TRUE THEN COALESCE(CAST(NULL AS UNSIGNED)) ELSE 4 END +--echo # +CREATE TABLE t1 SELECT CASE WHEN TRUE THEN COALESCE(CAST(NULL AS UNSIGNED)) ELSE 4 END AS a; +DESCRIBE t1; +DROP TABLE t1; +CREATE TABLE t1 SELECT CASE WHEN TRUE THEN COALESCE(CAST(NULL AS UNSIGNED)) ELSE 40 END AS a; +DESCRIBE t1; +DROP TABLE t1; diff --git a/mysql-test/t/ctype_cp850.test b/mysql-test/t/ctype_cp850.test new file mode 100644 index 00000000000..358829eb351 --- /dev/null +++ b/mysql-test/t/ctype_cp850.test @@ -0,0 +1,16 @@ +--echo # +--echo # Start of 5.5 tests +--echo # + +--echo # +--echo # MDEV-9862 Illegal mix of collation, when comparing column with CASE expression +--echo # +SET NAMES cp850; +CREATE TABLE t1 (a CHAR(1) CHARACTER SET latin1); +SELECT a FROM t1 WHERE CASE a WHEN 'aaaa' THEN 'Y' WHEN 'aaaa' THEN 'Y' ELSE NULL END <> a; +DROP TABLE t1; + + +--echo # +--echo # End of 5.5 tests +--echo # diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index 1898d1a4691..2886dff8f91 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -457,7 +457,7 @@ SELECT * FROM t1 WHERE a=0; --echo # Connection con1 connection con1; --echo # Sending: ---send ALTER TABLE t1 COMMENT 'test' +--send ALTER TABLE t1 MODIFY a INT UNSIGNED; --echo # Connection default connection default; @@ -465,7 +465,7 @@ connection default; let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE state = "Waiting for table metadata lock" - AND info = "ALTER TABLE t1 COMMENT 'test'"; + AND info LIKE "ALTER TABLE t1%"; --source include/wait_condition.inc --error ER_LOCK_DEADLOCK INSERT DELAYED INTO t1 VALUES (3); diff --git a/mysql-test/t/events_2.test b/mysql-test/t/events_2.test index 3d609654b21..5443f76d1a1 100644 --- a/mysql-test/t/events_2.test +++ b/mysql-test/t/events_2.test @@ -13,7 +13,7 @@ use events_test; # mysql.event intact checking end # -create event e_26 on schedule at '2017-01-01 00:00:00' disable do set @a = 5; +create event e_26 on schedule at '2027-01-01 00:00:00' disable do set @a = 5; select db, name, body, definer, convert_tz(execute_at, 'UTC', 'SYSTEM'), on_completion from mysql.event; drop event e_26; --error ER_WRONG_VALUE @@ -67,10 +67,10 @@ select /*2*/ user, host, db, command, state, info select release_lock("test_lock2"); drop event закачка; -# Wait for release_lock("test_lock2") to complete, +# Wait for get_lock("test_lock2") to complete, # to avoid polluting the next test information_schema.processlist let $wait_condition= select count(*) = 0 from information_schema.processlist - where (state like 'User lock%' AND info like 'select get_lock%'); + where info='select get_lock("test_lock2", 20)'; --source include/wait_condition.inc diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test index 5b5123ad295..c33497f643d 100644 --- a/mysql-test/t/events_bugs.test +++ b/mysql-test/t/events_bugs.test @@ -943,7 +943,7 @@ DELIMITER ;| # reasonable time like 4 seconds. Till ~ 2 seconds could pass on a heavy # loaded testing box before something gets executed). # Detection of execution is via the records inserted by the event. ---echo Sleep till the first INSERT into events_test.event_log occured +--echo Sleep till the first INSERT into events_test.event_log occurred let $wait_timeout= 4; let $wait_condition= SELECT COUNT(*) > 0 FROM events_test.event_log; diff --git a/mysql-test/t/fulltext3.test b/mysql-test/t/fulltext3.test index 1b6a07c540f..66f940b495e 100644 --- a/mysql-test/t/fulltext3.test +++ b/mysql-test/t/fulltext3.test @@ -32,3 +32,18 @@ INSERT INTO t1 VALUES(0xA3C2); DROP TABLE t1; # End of 5.1 tests + +# +# MDEV-9986 Full-text search of the utf8mb4 column causes crash +# +create table t1 ( + id varchar(255), + business_name text null collate utf8mb4_unicode_ci, + street_address text, + fulltext index ft (business_name), + fulltext index ft2 (street_address) +); +--error ER_FT_MATCHING_KEY_NOT_FOUND +select * from t1 where match (business_name, street_address) against ('some business name and address here'); +select * from t1 where match (business_name, street_address) against ('some business name and address here' in boolean mode); +drop table t1; diff --git a/mysql-test/t/func_des_encrypt.test b/mysql-test/t/func_des_encrypt.test index e121aedab06..c9661b81cc0 100644 --- a/mysql-test/t/func_des_encrypt.test +++ b/mysql-test/t/func_des_encrypt.test @@ -1,4 +1,4 @@ --- source include/have_ssl_crypto_functs.inc +-- source include/have_des.inc # This test can't be in func_encrypt.test, because it requires # --des-key-file to not be set. diff --git a/mysql-test/t/func_encrypt.test b/mysql-test/t/func_encrypt.test index 18fb072966b..e24cb80f995 100644 --- a/mysql-test/t/func_encrypt.test +++ b/mysql-test/t/func_encrypt.test @@ -1,4 +1,4 @@ --- source include/have_ssl_crypto_functs.inc +-- source include/have_des.inc --disable_warnings drop table if exists t1; diff --git a/mysql-test/t/func_encrypt_ucs2.test b/mysql-test/t/func_encrypt_ucs2.test index 8b4cd44d354..1242c3b9e6a 100644 --- a/mysql-test/t/func_encrypt_ucs2.test +++ b/mysql-test/t/func_encrypt_ucs2.test @@ -1,4 +1,4 @@ --- source include/have_ssl_crypto_functs.inc +-- source include/have_des.inc -- source include/have_ucs2.inc --echo # diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 2998742dbcc..5d1f87e74a2 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -484,6 +484,14 @@ SELECT -a FROM t1; --error ER_DATA_OUT_OF_RANGE SELECT -b FROM t1; +# try with two rows now +INSERT INTO t1 VALUES(0,0); + +--error ER_DATA_OUT_OF_RANGE +SELECT -a FROM t1; +--error ER_DATA_OUT_OF_RANGE +SELECT -b FROM t1; + DROP TABLE t1; # Decimal overflows diff --git a/mysql-test/t/grant5.test b/mysql-test/t/grant5.test index db953d97fb3..14f2fd65020 100644 --- a/mysql-test/t/grant5.test +++ b/mysql-test/t/grant5.test @@ -5,3 +5,21 @@ # --error ER_NONEXISTING_GRANT SHOW GRANTS FOR root@invalid_host; + +# +# MDEV-9580 SHOW GRANTS FOR <current_user> fails +# +create user test; +create user foo; +create role foo; +grant foo to test; +--connect (conn_1, localhost, test,,) +set role foo; +show grants for test; # user +show grants for foo; # role +--error ER_DBACCESS_DENIED_ERROR +show grants for foo@'%'; # user +--connection default +drop user test, foo; +drop role foo; + diff --git a/mysql-test/t/index_merge_myisam.test b/mysql-test/t/index_merge_myisam.test index 82d0474e28e..d265007431e 100644 --- a/mysql-test/t/index_merge_myisam.test +++ b/mysql-test/t/index_merge_myisam.test @@ -117,7 +117,7 @@ set optimizer_switch='default,index_merge_intersection=off'; explain select * from t1 where a=10 and b=10 or c=10; --echo This will switch to sort-union (intersection will be gone, too, ---echo thats a known limitation: +--echo that's a known limitation: set optimizer_switch='default,index_merge_union=off'; explain select * from t1 where a=10 and b=10 or c=10; diff --git a/mysql-test/t/insert_innodb.test b/mysql-test/t/insert_innodb.test new file mode 100644 index 00000000000..8c8d2690c11 --- /dev/null +++ b/mysql-test/t/insert_innodb.test @@ -0,0 +1,43 @@ +--source include/have_innodb.inc + +# +# MDEV-8979 IGNORE does not ignore the error 1452 +# + +--echo # +--echo # BUG#22037930: INSERT IGNORE FAILS TO IGNORE +--echo # FOREIGN KEY CONSTRAINT + +--echo # Setup. +CREATE TABLE t1 (fld1 INT PRIMARY KEY) ENGINE=INNODB; +CREATE TABLE t2 (fld2 INT, FOREIGN KEY (fld2) REFERENCES t1 (fld1)) +ENGINE=INNODB; +INSERT INTO t1 VALUES(0); +INSERT INTO t2 VALUES(0); + +--echo # Without fix, an error is reported. +INSERT IGNORE INTO t2 VALUES(1); +UPDATE IGNORE t2 SET fld2=20 WHERE fld2=0; +UPDATE IGNORE t1 SET fld1=20 WHERE fld1=0; + +--echo # Test for multi update. +UPDATE IGNORE t1, t2 SET t2.fld2= t2.fld2 + 3; +UPDATE IGNORE t1, t2 SET t1.fld1= t1.fld1 + 3; + +--echo # Reports an error since IGNORE is not used. +--error ER_NO_REFERENCED_ROW_2 +INSERT INTO t2 VALUES(1); + +--error ER_NO_REFERENCED_ROW_2 +UPDATE t2 SET fld2=20 WHERE fld2=0; + +--error ER_ROW_IS_REFERENCED_2 +UPDATE t1 SET fld1=20 WHERE fld1=0; + +--error ER_NO_REFERENCED_ROW_2 +UPDATE t1, t2 SET t2.fld2= t2.fld2 + 3; + +--error ER_ROW_IS_REFERENCED_2 +UPDATE t1, t2 SET t1.fld1= t1.fld1 + 3; + +DROP TABLE t2, t1; diff --git a/mysql-test/t/kill_processlist-6619.test b/mysql-test/t/kill_processlist-6619.test index 95af83be56d..551d36e03fd 100644 --- a/mysql-test/t/kill_processlist-6619.test +++ b/mysql-test/t/kill_processlist-6619.test @@ -23,5 +23,12 @@ SET DEBUG_SYNC='now SIGNAL go'; --error ER_QUERY_INTERRUPTED reap; SET DEBUG_SYNC='reset'; + +# Wait until default connection has reset query string +let $wait_condition= + SELECT COUNT(*) = 1 from information_schema.processlist + WHERE info is NULL; +--source include/wait_condition.inc + --replace_column 1 # 3 # 6 # 7 # SHOW PROCESSLIST; diff --git a/mysql-test/t/locale.test b/mysql-test/t/locale.test index 93e347b722d..5d1fd24d750 100644 --- a/mysql-test/t/locale.test +++ b/mysql-test/t/locale.test @@ -55,6 +55,14 @@ SELECT DATE_FORMAT('2001-01-06', '%w %a %W'); SELECT DATE_FORMAT('2001-01-07', '%w %a %W'); --echo End of 5.4 tests +# +# MDEV-9928 LC_TIME_NAMES=de_AT; unusual name for february +# +SET NAMES utf8; +SET lc_time_names=de_AT; +SELECT monthname('2001-01-01'); +SELECT monthname('2001-02-01'); +SELECT monthname('2001-03-01'); --echo # --echo # Start of 5.6 tests diff --git a/mysql-test/t/mdev6830-master.opt b/mysql-test/t/mdev6830-master.opt deleted file mode 100644 index 2a8c27d4731..00000000000 --- a/mysql-test/t/mdev6830-master.opt +++ /dev/null @@ -1 +0,0 @@ ---debug diff --git a/mysql-test/t/mdev6830.test b/mysql-test/t/mdev6830.test index 24565d04fed..3898d5bbef6 100644 --- a/mysql-test/t/mdev6830.test +++ b/mysql-test/t/mdev6830.test @@ -1,10 +1,10 @@ - +# +# MDEV-6830 Server crashes in best_access_path after a sequence of SELECTs invollving a temptable view +# --source include/have_debug.inc ---disable_warnings -drop table if exists t1,t2,t3; -drop view if exists v2,v3; ---enable_warnings +set @@debug_dbug= 'd,opt'; + CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=MyISAM; CREATE TABLE t2 ( diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 2697e3b9a5f..77e896c7c05 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -655,7 +655,7 @@ insert into t1 values (1); flush tables; # Open t2 and (implicitly) t1. select * from t2; -# Truncate t1, wich was not recognized as open without the bugfix. +# Truncate t1, which was not recognized as open without the bugfix. # After fix for Bug#8306 and before fix for Bug#26379, # it should fail with a table-in-use error message, otherwise succeed. truncate table t1; diff --git a/mysql-test/t/mysqld--help.test b/mysql-test/t/mysqld--help.test index 3d29cbc6cce..c6a46669c8d 100644 --- a/mysql-test/t/mysqld--help.test +++ b/mysql-test/t/mysqld--help.test @@ -22,6 +22,7 @@ perl; log-slow-queries pid-file slow-query-log-file log-basename datadir slave-load-tmpdir tmpdir socket thread-pool-size large-files-support lower-case-file-system system-time-zone + collation-server character-set-server wsrep-node-name wsrep-data-home-dir log-tc-size version.*/; # Plugins which may or may not be there: diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 8a9fd4ba91d..fd50896b71f 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -701,7 +701,7 @@ drop table t1; --echo # ---echo # Bug#15328 Segmentation fault occured if my.cnf is invalid for escape sequence +--echo # Bug#15328 Segmentation fault occurred if my.cnf is invalid for escape sequence --echo # --exec $MYSQL_MY_PRINT_DEFAULTS --config-file=$MYSQL_TEST_DIR/std_data/bug15328.cnf mysqldump diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test index e36f106a5be..91a8cc57b1b 100644 --- a/mysql-test/t/openssl_1.test +++ b/mysql-test/t/openssl_1.test @@ -132,7 +132,7 @@ drop table t1; # verification of servers certificate by setting both ca certificate # and ca path to NULL # ---replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA +--replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA DHE-RSA-CHACHA20-POLY1305 DHE-RSA-AES256-SHA --exec $MYSQL --ssl --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem -e "SHOW STATUS LIKE 'ssl_Cipher'" 2>&1 --echo End of 5.0 tests @@ -257,7 +257,7 @@ select 'is still running; no cipher request crashed the server' as result from d GRANT SELECT ON test.* TO bug42158@localhost REQUIRE X509; FLUSH PRIVILEGES; connect(con1,localhost,bug42158,,,,,SSL); ---replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA +--replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA DHE-RSA-CHACHA20-POLY1305 DHE-RSA-AES256-SHA SHOW STATUS LIKE 'Ssl_cipher'; disconnect con1; connection default; @@ -265,5 +265,12 @@ DROP USER bug42158@localhost; --echo End of 5.1 tests +# +# MDEV-9605 mysqlbinlog does not accept ssl-ca option as expected. +# + +--error 1 +--exec $MYSQL_BINLOG --read-from-remote-server --ssl-ca --user=root --host=localhost nobinlog.111111 + # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/openssl_6975.test b/mysql-test/t/openssl_6975.test index bc6397c5c28..89e6983cf47 100644 --- a/mysql-test/t/openssl_6975.test +++ b/mysql-test/t/openssl_6975.test @@ -15,6 +15,7 @@ let $mysql=$MYSQL --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$ disable_abort_on_error; echo TLS1.2 ciphers: user is ok with any cipher; exec $mysql --ssl-cipher=AES128-SHA256; +--replace_result DHE-RSA-CHACHA20-POLY1305 DHE-RSA-AES256-GCM-SHA384 exec $mysql --ssl-cipher=TLSv1.2; echo TLS1.2 ciphers: user requires SSLv3 cipher RC4-SHA; exec $mysql --user ssl_sslv3 --ssl-cipher=AES128-SHA256; diff --git a/mysql-test/t/partition_innodb_plugin.test b/mysql-test/t/partition_innodb_plugin.test index fd6e60c27fb..d25a4b95bf1 100644 --- a/mysql-test/t/partition_innodb_plugin.test +++ b/mysql-test/t/partition_innodb_plugin.test @@ -125,12 +125,8 @@ SEND; UPDATE `t``\""e` SET a = 12 WHERE a = 0; --echo # default connection connection default; -let $wait_timeout= 2; -let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST -WHERE ID = $id_1 AND STATE = 'Searching rows for update'; +let $wait_condition= SELECT COUNT(*)=2 FROM INFORMATION_SCHEMA.INNODB_LOCKS; --source include/wait_condition.inc -#--echo # tested wait condition $wait_condition_reps times -# INNODB_LOCKS only exists in innodb_plugin --sorted_result SELECT lock_table, COUNT(*) FROM INFORMATION_SCHEMA.INNODB_LOCKS GROUP BY lock_table; diff --git a/mysql-test/t/select_debug.test b/mysql-test/t/select_debug.test index 4b77f9fd047..49415400db3 100644 --- a/mysql-test/t/select_debug.test +++ b/mysql-test/t/select_debug.test @@ -10,7 +10,7 @@ create table t2 (a int); insert into t2 values (2), (3); set session join_cache_level=3; -set @@debug_dbug= 'd:t:O,/tmp/trace.out'; +set @@debug_dbug= 'd,opt'; explain select t1.b from t1,t2 where t1.b=t2.a; select t1.b from t1,t2 where t1.b=t2.a; diff --git a/mysql-test/t/set_password_plugin-9835.test b/mysql-test/t/set_password_plugin-9835.test new file mode 100644 index 00000000000..a10a339540f --- /dev/null +++ b/mysql-test/t/set_password_plugin-9835.test @@ -0,0 +1,128 @@ +# +# MDEV-9835 Valid password is not working after server restart. +# +# Various combinations of SET PASSWORD and not-empty mysql.user.plugin field +# +--source include/not_embedded.inc + +--enable_connect_log + +# The hash (old and new) is for 'test' +create user natauth@localhost identified via 'mysql_native_password' using '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29'; + +create user newpass@localhost identified by password '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29'; + +create user newpassnat@localhost identified via 'mysql_native_password'; +set password for newpassnat@localhost = '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29'; + +create user oldauth@localhost identified with 'mysql_old_password' using '378b243e220ca493'; + +create user oldpass@localhost identified by password '378b243e220ca493'; + +create user oldpassold@localhost identified with 'mysql_old_password'; +set password for oldpassold@localhost = '378b243e220ca493'; + +--sorted_result +select user, host, password, plugin, authentication_string from mysql.user where user != 'root'; + +--connect(con,localhost,natauth,test,) +select current_user(); +--disconnect con +--connect(con,localhost,newpass,test,) +select current_user(); +--disconnect con +--connect(con,localhost,newpassnat,test,) +select current_user(); +--disconnect con +--connect(con,localhost,oldauth,test,) +select current_user(); +--disconnect con +--connect(con,localhost,oldpass,test,) +select current_user(); +--disconnect con +--connect(con,localhost,oldpassold,test,) +select current_user(); +--disconnect con + +--connection default + +flush privileges; + +--connect(con,localhost,natauth,test,) +select current_user(); +--disconnect con +--connect(con,localhost,newpass,test,) +select current_user(); +--disconnect con +--connect(con,localhost,newpassnat,test,) +select current_user(); +--disconnect con +--connect(con,localhost,oldauth,test,) +select current_user(); +--disconnect con +--connect(con,localhost,oldpass,test,) +select current_user(); +--disconnect con +--connect(con,localhost,oldpassold,test,) +select current_user(); +--disconnect con + +--connection default + +# changing to the NEW password hash +set password for natauth@localhost = PASSWORD('test2'); +set password for newpass@localhost = PASSWORD('test2'); +set password for newpassnat@localhost = PASSWORD('test2'); +set password for oldauth@localhost = PASSWORD('test2'); +set password for oldpass@localhost = PASSWORD('test2'); +set password for oldpassold@localhost = PASSWORD('test2'); + +--sorted_result +select user, host, password, plugin, authentication_string from mysql.user where user != 'root'; + +--connect(con,localhost,natauth,test2,) +select current_user(); +--disconnect con +--connect(con,localhost,newpass,test2,) +select current_user(); +--disconnect con +--connect(con,localhost,newpassnat,test2,) +select current_user(); +--disconnect con +--connect(con,localhost,oldauth,test2,) +select current_user(); +--disconnect con +--connect(con,localhost,oldpass,test2,) +select current_user(); +--disconnect con +--connect(con,localhost,oldpassold,test2,) +select current_user(); +--disconnect con + +--connection default + +flush privileges; + +--connect(con,localhost,natauth,test2,) +select current_user(); +--disconnect con +--connect(con,localhost,newpass,test2,) +select current_user(); +--disconnect con +--connect(con,localhost,newpassnat,test2,) +select current_user(); +--disconnect con +--connect(con,localhost,oldauth,test2,) +select current_user(); +--disconnect con +--connect(con,localhost,oldpass,test2,) +select current_user(); +--disconnect con +--connect(con,localhost,oldpassold,test2,) +select current_user(); +--disconnect con + +--connection default +drop user natauth@localhost, newpass@localhost, newpassnat@localhost; +drop user oldauth@localhost, oldpass@localhost, oldpassold@localhost; + diff --git a/mysql-test/t/sp-threads.test b/mysql-test/t/sp-threads.test index e1012e2b72d..7a6d1258331 100644 --- a/mysql-test/t/sp-threads.test +++ b/mysql-test/t/sp-threads.test @@ -77,12 +77,15 @@ call bug9486(); connection con2root; lock tables t2 write; connection con1root; +let $con1root_id=`SELECT CONNECTION_ID()`; send call bug9486(); connection con2root; ---sleep 2 # There should be call statement in locked state. ---replace_column 1 # 3 localhost 6 # -show processlist; +let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE + id=$con1root_id AND state='Waiting for table metadata lock'; +--source include/wait_condition.inc +--replace_result $con1root_id con1root_id +eval SELECT state,info FROM information_schema.processlist WHERE id=$con1root_id; unlock tables; connection con1root; reap; diff --git a/mysql-test/t/ssl.test b/mysql-test/t/ssl.test index 0d14ad82692..21733f7e594 100644 --- a/mysql-test/t/ssl.test +++ b/mysql-test/t/ssl.test @@ -11,7 +11,7 @@ connect (ssl_con,localhost,root,,,,,SSL); # Check ssl turned on ---replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA +--replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA DHE-RSA-CHACHA20-POLY1305 DHE-RSA-AES256-SHA SHOW STATUS LIKE 'Ssl_cipher'; # Check ssl expiration @@ -22,7 +22,7 @@ SHOW STATUS LIKE 'Ssl_server_not_after'; -- source include/common-tests.inc # Check ssl turned on ---replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA +--replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA DHE-RSA-CHACHA20-POLY1305 DHE-RSA-AES256-SHA SHOW STATUS LIKE 'Ssl_cipher'; # diff --git a/mysql-test/t/ssl_compress.test b/mysql-test/t/ssl_compress.test index 5e45e3824a2..28f3453c23e 100644 --- a/mysql-test/t/ssl_compress.test +++ b/mysql-test/t/ssl_compress.test @@ -11,7 +11,7 @@ connect (ssl_compress_con,localhost,root,,,,,SSL COMPRESS); # Check ssl turned on ---replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA +--replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA DHE-RSA-CHACHA20-POLY1305 DHE-RSA-AES256-SHA SHOW STATUS LIKE 'Ssl_cipher'; # Check compression turned on @@ -21,7 +21,7 @@ SHOW STATUS LIKE 'Compression'; -- source include/common-tests.inc # Check ssl turned on ---replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA +--replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA DHE-RSA-CHACHA20-POLY1305 DHE-RSA-AES256-SHA SHOW STATUS LIKE 'Ssl_cipher'; # Check compression turned on diff --git a/mysql-test/t/ssl_timeout-9836.opt b/mysql-test/t/ssl_timeout-9836.opt new file mode 100644 index 00000000000..7a2696875b8 --- /dev/null +++ b/mysql-test/t/ssl_timeout-9836.opt @@ -0,0 +1 @@ +--loose-thread-handling=pool-of-threads diff --git a/mysql-test/t/ssl_timeout-9836.test b/mysql-test/t/ssl_timeout-9836.test new file mode 100644 index 00000000000..5b57917f3b8 --- /dev/null +++ b/mysql-test/t/ssl_timeout-9836.test @@ -0,0 +1,11 @@ +# +# MDEV-9836 Connection lost when using SSL +# +-- source include/have_ssl_communication.inc +connect(con1,localhost,root,,,,,SSL); +SET @@net_read_timeout=1; +SELECT 1; +# MDEV-9836 - YASSL bug - SSL connection lost if it has been idle, for longer than net_read_timeout +-- sleep 2 +SELECT 1; +disconnect con1; diff --git a/mysql-test/t/ssl_timeout.test b/mysql-test/t/ssl_timeout.test index 0d96b3f6601..806b928aca0 100644 --- a/mysql-test/t/ssl_timeout.test +++ b/mysql-test/t/ssl_timeout.test @@ -7,7 +7,7 @@ connect (ssl_con,localhost,root,,,,,SSL read_timeout=5); --echo # Check ssl turned on ---replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA +--replace_result DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA DHE-RSA-CHACHA20-POLY1305 DHE-RSA-AES256-SHA SHOW STATUS LIKE 'Ssl_cipher'; # --error CR_SERVER_LOST diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index c01adc1b233..696cfe67586 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -386,6 +386,36 @@ select 1 from t1 as t1_0 inner join t1 as t2 on (t1_0.a <=> now()) join t1 on 1; drop table t1; --echo # +--echo # MDEV-9521 Least function returns 0000-00-00 for null date columns instead of null +--echo # +CREATE TABLE t1 ( + id BIGINT NOT NULL, + date_debut DATE NOT NULL, + date_fin DATE DEFAULT NULL); +CREATE TABLE t2( + id BIGINT NOT NULL, + date_debut DATE NOT NULL, + date_fin DATE DEFAULT NULL); +INSERT INTO t1 VALUES (1,'2016-01-01','2016-01-31'); +INSERT INTO t1 VALUES (2,'2016-02-01',null); +INSERT INTO t1 VALUES (3,'2016-03-01','2016-03-31'); +INSERT INTO t1 VALUES (4,'2016-04-01',null); + +INSERT INTO t2 VALUES (1,'2016-01-01','2016-01-31'); +INSERT INTO t2 VALUES (2,'2016-02-01','2016-01-28'); +INSERT INTO t2 VALUES (3,'2016-03-01',null); +INSERT INTO t2 VALUES (4,'2016-04-01',null); +SELECT t1.id, + GREATEST(t2.date_debut, t1.date_debut) AS date_debut, + LEAST(IFNULL(t2.date_fin, IFNULL(t1.date_fin, NULL)), + IFNULL(t1.date_fin, IFNULL(t2.date_fin, NULL))) AS date_fin +FROM t1 LEFT JOIN t2 ON (t1.id=t2.id); +DROP TABLE t1,t2; +SELECT + LEAST(COALESCE(DATE(NULL), DATE(NULL)), COALESCE(DATE(NULL), DATE(NULL))) AS d0, + LEAST(IFNULL(DATE(NULL), DATE(NULL)), IFNULL(DATE(NULL), DATE(NULL))) AS d1; + +--echo # --echo # MDEV-9511 Valgrind warnings 'Invalid read' in Field_newdate::cmp and Field_newdate::val_str --echo # CREATE TABLE t1 (f1 DATE, f2 VARCHAR(1)); diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test index 195252a2df9..0ef0832602f 100644 --- a/mysql-test/t/type_timestamp.test +++ b/mysql-test/t/type_timestamp.test @@ -445,6 +445,14 @@ SELECT MAX(ts) = '2011-01-06 12:34:30' FROM t1; SELECT MAX(dt) = '2011-01-06 12:34:30' FROM t1; DROP TABLE t1; +--echo # +--echo # MDEV-9413 "datetime >= coalesce(c1(NULL))" doesn't return expected NULL +--echo # +CREATE TABLE t1(c1 TIMESTAMP(6) NULL DEFAULT NULL); +INSERT INTO t1 VALUES(NULL); +SELECT c1, '2016-06-13 20:00:00.000003' >= COALESCE( c1 ) FROM t1; +DROP TABLE t1; + --echo End of 5.5 tests --echo # diff --git a/mysql-test/t/wait_timeout_not_windows.test b/mysql-test/t/wait_timeout_not_windows.test new file mode 100644 index 00000000000..de4904fada2 --- /dev/null +++ b/mysql-test/t/wait_timeout_not_windows.test @@ -0,0 +1,16 @@ +source include/not_embedded.inc; +source include/not_windows.inc; + +# +# MDEV-7775 Wrong error message (Unknown error) when idle sessions are killed after wait_timeout +# +set global log_warnings=2; +connect (foo,localhost,root); +set @@wait_timeout=1; +sleep 2; +connection default; +let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err; +let SEARCH_RANGE= -50; +let SEARCH_PATTERN= Aborted.*Got timeout reading communication packets; +source include/search_pattern_in_file.inc; +set global log_warnings=@@log_warnings; diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp index c87be27233d..25927cd0e35 100644 --- a/mysql-test/valgrind.supp +++ b/mysql-test/valgrind.supp @@ -1158,6 +1158,13 @@ fun:SSL_library_init } +{ + libcrypto 2.2.1 leak + Memcheck:Leak + fun:malloc + ... + fun:ERR_get_state +} { Problem with udf and libresolve diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c index b599b455ff5..282433ea48d 100644 --- a/mysys/lf_alloc-pin.c +++ b/mysys/lf_alloc-pin.c @@ -103,6 +103,12 @@ #include <my_sys.h> #include <lf.h> +/* + when using alloca() leave at least that many bytes of the stack - + for functions we might be calling from within this stack frame +*/ +#define ALLOCA_SAFETY_MARGIN 8192 + #define LF_PINBOX_MAX_PINS 65536 static void _lf_pinbox_real_free(LF_PINS *pins); @@ -349,7 +355,8 @@ static void _lf_pinbox_real_free(LF_PINS *pins) { int alloca_size= sizeof(void *)*LF_PINBOX_PINS*npins; /* create a sorted list of pinned addresses, to speed up searches */ - if (available_stack_size(&pinbox, *pins->stack_ends_here) > alloca_size) + if (available_stack_size(&pinbox, *pins->stack_ends_here) > + alloca_size + ALLOCA_SAFETY_MARGIN) { struct st_harvester hv; addr= (void **) alloca(alloca_size); diff --git a/mysys/ma_dyncol.c b/mysys/ma_dyncol.c index d7d4a127a75..7cd0c2b02df 100644 --- a/mysys/ma_dyncol.c +++ b/mysys/ma_dyncol.c @@ -4249,7 +4249,7 @@ mariadb_dyncol_unpack(DYNAMIC_COLUMN *str, { *names= my_malloc(sizeof(LEX_STRING) * header.column_count + DYNCOL_NUM_CHAR * header.column_count, MYF(0)); - nm= (char *)(names + sizeof(LEX_STRING) * header.column_count); + nm= (char *)((*names) + header.column_count); } else { diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index 06dfc9f2079..9e693209445 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -44,7 +44,7 @@ RETURN VALUE 0 All OK - 1 An error occured + 1 An error occurred */ int my_b_copy_to_file(IO_CACHE *cache, FILE *file) diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 16ac749fa09..0e7c43cc4c4 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -274,7 +274,7 @@ struct st_hash_link }; /* simple states of a block */ -#define BLOCK_ERROR 1 /* an error occured when performing file i/o */ +#define BLOCK_ERROR 1 /* an error occurred when performing file i/o */ #define BLOCK_READ 2 /* file block is in the block buffer */ #define BLOCK_IN_SWITCH 4 /* block is preparing to read new page */ #define BLOCK_REASSIGNED 8 /* blk does not accept requests for old page */ diff --git a/mysys/my_copy.c b/mysys/my_copy.c index 8af572b5518..bd23dfc48cd 100644 --- a/mysys/my_copy.c +++ b/mysys/my_copy.c @@ -18,7 +18,6 @@ #include "mysys_err.h" #include <my_dir.h> /* for stat */ #include <m_string.h> -#include "mysys_err.h" #if defined(HAVE_UTIME_H) #include <utime.h> #elif defined(HAVE_SYS_UTIME_H) diff --git a/mysys/my_default.c b/mysys/my_default.c index c7ab8763e1f..1ad2fa2090d 100644 --- a/mysys/my_default.c +++ b/mysys/my_default.c @@ -373,7 +373,7 @@ err: RETURN 0 - ok - 1 - error occured + 1 - error occurred */ static int handle_default_option(void *in_ctx, const char *group_name, diff --git a/mysys/my_delete.c b/mysys/my_delete.c index e99c7ff5fcb..3dfe290dabe 100644 --- a/mysys/my_delete.c +++ b/mysys/my_delete.c @@ -110,7 +110,7 @@ static int my_win_unlink(const char *name) if (handle != INVALID_HANDLE_VALUE) { /* - We opened file without sharing flags (exclusive), noone else has this file + We opened file without sharing flags (exclusive), no one else has this file opened, thus it is save to close handle to remove it. No renaming is necessary. */ diff --git a/mysys/my_lock.c b/mysys/my_lock.c index 0abbc6c3084..082d8e9f5a0 100644 --- a/mysys/my_lock.c +++ b/mysys/my_lock.c @@ -131,7 +131,7 @@ error: RETURN VALUE 0 Success - -1 An error has occured and 'my_errno' is set + -1 An error has occurred and 'my_errno' is set to indicate the actual error code. */ @@ -203,7 +203,7 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length, == MY_FILEPOS_ERROR) { /* - If an error has occured in my_seek then we will already + If an error has occurred in my_seek then we will already have an error code in my_errno; Just return error code. */ DBUG_RETURN(-1); diff --git a/plugin/handler_socket/client/hslongrun.cpp b/plugin/handler_socket/client/hslongrun.cpp index e82c12b166b..b7c02951340 100644 --- a/plugin/handler_socket/client/hslongrun.cpp +++ b/plugin/handler_socket/client/hslongrun.cpp @@ -39,7 +39,7 @@ struct auto_mysql : private noncopyable { mysql_close(db); } if ((db = mysql_init(0)) == 0) { - fatal_exit("failed to initialize mysql client"); + fatal_abort("failed to initialize mysql client"); } } operator MYSQL *() const { return db; } @@ -870,7 +870,7 @@ mysql_do(MYSQL *db, const char *query) { if (mysql_real_query(db, query, strlen(query)) != 0) { fprintf(stderr, "mysql: e=[%s] q=[%s]\n", mysql_error(db), query); - fatal_exit("mysql_do"); + fatal_abort("mysql_do"); } } @@ -886,7 +886,7 @@ hs_longrun_init_table(const config& conf, int num_prepare, if (!mysql_real_connect(db, mysql_host.c_str(), mysql_user.c_str(), mysql_passwd.c_str(), mysql_dbname.c_str(), mysql_port, 0, 0)) { fprintf(stderr, "mysql: error=[%s]\n", mysql_error(db)); - fatal_exit("hs_longrun_init_table"); + fatal_abort("hs_longrun_init_table"); } mysql_do(db, "drop database if exists hstestdb"); mysql_do(db, "create database hstestdb"); diff --git a/plugin/handler_socket/docs-en/perl-client.en.txt b/plugin/handler_socket/docs-en/perl-client.en.txt index 448d33b5f12..cc9138518ee 100644 --- a/plugin/handler_socket/docs-en/perl-client.en.txt +++ b/plugin/handler_socket/docs-en/perl-client.en.txt @@ -42,7 +42,7 @@ to be retrieved are specified by the 5th argument for the corresponding open_index call. The execute_single method always returns an arrayref. The first -element is the error code, which is 0 when no error is occured. +element is the error code, which is 0 when no error is occurred. The remaining are the field values. If more than one record is returned, it is flatten to an 1-dimensional array. For example, when 5 records that have 3 columns are returned, you can retrieve @@ -125,9 +125,9 @@ methods. die $hs->get_error() if $res->[0] != 0; ----------------------------------------------------------------- -When an error is occured, the first element of the returned +When an error is occurred, the first element of the returned arrayref becomes a non-zero value. A negative value indicates -that an I/O error is occured and the Net::HandlerSocket object +that an I/O error is occurred and the Net::HandlerSocket object should be disposed. A positive value means that the connection is still active and the Net::HandlerSocket object can be reused later. diff --git a/plugin/handler_socket/libhsclient/fatal.cpp b/plugin/handler_socket/libhsclient/fatal.cpp index 5cdd8879ab1..8e109cf13ba 100644 --- a/plugin/handler_socket/libhsclient/fatal.cpp +++ b/plugin/handler_socket/libhsclient/fatal.cpp @@ -18,14 +18,6 @@ namespace dena { const int opt_syslog = LOG_ERR | LOG_PID | LOG_CONS; void -fatal_exit(const std::string& message) -{ - fprintf(stderr, "FATAL_EXIT: %s\n", message.c_str()); - syslog(opt_syslog, "FATAL_EXIT: %s", message.c_str()); - _exit(1); -} - -void fatal_abort(const std::string& message) { fprintf(stderr, "FATAL_COREDUMP: %s\n", message.c_str()); diff --git a/plugin/handler_socket/libhsclient/fatal.hpp b/plugin/handler_socket/libhsclient/fatal.hpp index 8a630fab1cb..5eaa3db8687 100644 --- a/plugin/handler_socket/libhsclient/fatal.hpp +++ b/plugin/handler_socket/libhsclient/fatal.hpp @@ -13,7 +13,6 @@ namespace dena { -void fatal_exit(const std::string& message); void fatal_abort(const std::string& message); }; diff --git a/plugin/handler_socket/libhsclient/socket.cpp b/plugin/handler_socket/libhsclient/socket.cpp index cf19d4bbe14..2c93a3b4846 100644 --- a/plugin/handler_socket/libhsclient/socket.cpp +++ b/plugin/handler_socket/libhsclient/socket.cpp @@ -43,7 +43,7 @@ socket_args::set(const config& conf) } else { const char *nd = node.empty() ? 0 : node.c_str(); if (resolve(nd, port.c_str()) != 0) { - fatal_exit("getaddrinfo failed: " + node + ":" + port); + fatal_abort("getaddrinfo failed: " + node + ":" + port); } } } diff --git a/plugin/semisync/semisync_master.h b/plugin/semisync/semisync_master.h index 66fa176624b..e68795bcab4 100644 --- a/plugin/semisync/semisync_master.h +++ b/plugin/semisync/semisync_master.h @@ -102,7 +102,7 @@ public: it are in use. A new Block is allocated and is put into the rear of the Block link table if no Block is free. - @return Return a TranxNode *, or NULL if an error occured. + @return Return a TranxNode *, or NULL if an error occurred. */ TranxNode *allocate_node() { @@ -134,7 +134,7 @@ public: /** All nodes are freed. - @return Return 0, or 1 if an error occured. + @return Return 0, or 1 if an error occurred. */ int free_all_nodes() { @@ -150,7 +150,7 @@ public: @param node All nodes before 'node' will be freed - @return Return 0, or 1 if an error occured. + @return Return 0, or 1 if an error occurred. */ int free_nodes_before(TranxNode* node) { diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index 30b7cdb5dcb..b84f2b94806 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -97,13 +97,11 @@ static void closelog() {} #define FLOGGER_NO_PSI /* How to access the pthread_mutex in mysql_mutex_t */ -//#ifdef SAFE_MUTEX -//#define mysql_mutex_real_mutex(A) &(A)->m_mutex.mutex -//#elif defined(MY_PTHREAD_FASTMUTEX) -//#define mysql_mutex_real_mutex(A) &(A)->m_mutex.mutex -//#else +#if defined(SAFE_MUTEX) || defined(MY_PTHREAD_FASTMUTEX) +#define mysql_mutex_real_mutex(A) &(A)->m_mutex.mutex +#else #define mysql_mutex_real_mutex(A) &(A)->m_mutex -//#endif +#endif #define flogger_mutex_init(A,B,C) do{}while(0) #define flogger_mutex_destroy(A) do{}while(0) diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql index 14b59bb3411..ab4ea6dfe41 100644 --- a/scripts/mysql_system_tables.sql +++ b/scripts/mysql_system_tables.sql @@ -229,7 +229,7 @@ SET @cmd= "CREATE TABLE IF NOT EXISTS gtid_slave_pos ( sub_id BIGINT UNSIGNED NOT NULL, server_id INT UNSIGNED NOT NULL, seq_no BIGINT UNSIGNED NOT NULL, - PRIMARY KEY (domain_id, sub_id)) + PRIMARY KEY (domain_id, sub_id)) CHARSET=latin1 COMMENT='Replication slave GTID position'"; SET @str=CONCAT(@cmd, ' ENGINE=', @innodb_or_myisam); PREPARE stmt FROM @str; diff --git a/scripts/mysqlaccess.sh b/scripts/mysqlaccess.sh index d8fd239585c..3626794d533 100644 --- a/scripts/mysqlaccess.sh +++ b/scripts/mysqlaccess.sh @@ -441,7 +441,7 @@ use IPC::Open3; $DEBUG = 0; # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>8 -# Normaly nothing should be changed beneeth this line +# Normally nothing should be changed beneeth this line # **************************** @@ -2342,7 +2342,7 @@ BEGIN { ."of `$MySQLaccess::script'." ,'Access_denied' => "Sorry,\n" - ."An error occured when trying to connect to the database\n" + ."An error occurred when trying to connect to the database\n" ."with the grant-tables:\n" ."* Maybe YOU do not have READ-access to this database?\n" ."* If you used the -U option, you may have supplied an invalid username?\n" @@ -2352,24 +2352,24 @@ BEGIN { ."* If you used the -P option, you may have supplied an invalid password?\n" ,'Dbaccess_denied' => "Sorry,\n" - ."An error occured when trying to connect to the database\n" + ."An error occurred when trying to connect to the database\n" ."with the grant-tables. (dbaccess denied)\n" ,'Unknown_tmp_table' => "Sorry,\n" - ."An error occured when trying to work with the temporary tables in the database\n" + ."An error occurred when trying to work with the temporary tables in the database\n" ."with the grant-tables. (One of the temporary tables does not exist)\n" ,'Unknown_table' => "Sorry,\n" - ."An error occured when trying to work with some tables in the database\n" + ."An error occurred when trying to work with some tables in the database\n" ."with the grant-tables. (table does not exist)\n" ,'use_old_server' => "Sorry,\n" - ."An error occured when executing an SQL statement.\n" + ."An error occurred when executing an SQL statement.\n" ."You might consider altering the use of the parameter `--old_server' when \n" ."calling `$MySQLaccess::script'." ,'unknown_error' => "Sorry,\n" - ."An error occured when trying to connect to the database\n" + ."An error occurred when trying to connect to the database\n" ."with the grant-tables. (unknown error)\n" ,'anonymous_access' => "Accessing the db as an anonymous user.\n" @@ -2422,7 +2422,7 @@ sub Print_Header { sub Print_Footer { if ($MySQLaccess::CMD) { #command-line mode print "\n" - ."BUGs can be reported at https://mariadb.atlassian.net/browse/MDEV\n"; + ."BUGs can be reported at https://jira.mariadb.org\n"; } if ($MySQLaccess::CGI) { #CGI-BIN mode if ($MySQLaccess::Param{'brief'}) { @@ -2430,7 +2430,7 @@ sub Print_Footer { } print "<HR>\n" ."<ADDRESS>\n" - ."BUGs can be reported at <a href=\"https://mariadb.atlassian.net/browse/MDEV\">MariaDB JIRA</a><BR>\n" + ."BUGs can be reported at <a href=\"https://jira.mariadb.org\">MariaDB JIRA</a><BR>\n" # ."Don't forget to mention the version $VERSION!<BR>\n" ."</ADDRESS>\n" ."</BODY>\n" diff --git a/sql-bench/bench-init.pl.sh b/sql-bench/bench-init.pl.sh index a46bb2d7a49..7bc7c23be66 100644 --- a/sql-bench/bench-init.pl.sh +++ b/sql-bench/bench-init.pl.sh @@ -265,7 +265,7 @@ sub fetch_all_rows if (!($sth= $dbh->prepare($query))) { print "\n" if ($opt_debug); - die "Error occured with prepare($query)\n -> $DBI::errstr\n"; + die "Error occurred with prepare($query)\n -> $DBI::errstr\n"; return undef; } if (!$sth->execute) @@ -282,7 +282,7 @@ sub fetch_all_rows print "0\n" if ($opt_debug); return 0; } - die "Error occured with execute($query)\n -> $DBI::errstr\n"; + die "Error occurred with execute($query)\n -> $DBI::errstr\n"; $sth->finish; return undef; } diff --git a/sql-common/client_plugin.c b/sql-common/client_plugin.c index 063fc5c6dc6..dd87b01d932 100644 --- a/sql-common/client_plugin.c +++ b/sql-common/client_plugin.c @@ -235,7 +235,7 @@ static void load_env_plugins(MYSQL *mysql) This function must be called before any other client plugin function. @retval 0 successful - @retval != 0 error occured + @retval != 0 error occurred */ int mysql_client_plugin_init() { diff --git a/sql-common/mysql_async.c b/sql-common/mysql_async.c index ef01f292180..80b4f390641 100644 --- a/sql-common/mysql_async.c +++ b/sql-common/mysql_async.c @@ -102,7 +102,7 @@ my_connect_async(struct mysql_async_context *b, my_socket fd, my_context_yield(&b->async_context); if (b->suspend_resume_hook) (*b->suspend_resume_hook)(FALSE, b->suspend_resume_hook_user_data); - if (b->events_occured & MYSQL_WAIT_TIMEOUT) + if (b->events_occurred & MYSQL_WAIT_TIMEOUT) return -1; s_err_size= sizeof(res); @@ -149,7 +149,7 @@ my_recv_async(struct mysql_async_context *b, int fd, my_context_yield(&b->async_context); if (b->suspend_resume_hook) (*b->suspend_resume_hook)(FALSE, b->suspend_resume_hook_user_data); - if (b->events_occured & MYSQL_WAIT_TIMEOUT) + if (b->events_occurred & MYSQL_WAIT_TIMEOUT) return -1; } } @@ -177,7 +177,7 @@ my_send_async(struct mysql_async_context *b, int fd, my_context_yield(&b->async_context); if (b->suspend_resume_hook) (*b->suspend_resume_hook)(FALSE, b->suspend_resume_hook_user_data); - if (b->events_occured & MYSQL_WAIT_TIMEOUT) + if (b->events_occurred & MYSQL_WAIT_TIMEOUT) return -1; } } @@ -210,7 +210,7 @@ my_io_wait_async(struct mysql_async_context *b, enum enum_vio_io_event event, my_context_yield(&b->async_context); if (b->suspend_resume_hook) (*b->suspend_resume_hook)(FALSE, b->suspend_resume_hook_user_data); - return (b->events_occured & MYSQL_WAIT_TIMEOUT) ? 0 : 1; + return (b->events_occurred & MYSQL_WAIT_TIMEOUT) ? 0 : 1; } @@ -349,7 +349,7 @@ mysql_get_timeout_value_ms(const MYSQL *mysql) } \ \ b->active= 1; \ - b->events_occured= ready_status; \ + b->events_occurred= ready_status; \ res= my_context_continue(&b->async_context); \ b->active= 0; \ if (res > 0) \ @@ -405,7 +405,7 @@ mysql_get_timeout_value_ms(const MYSQL *mysql) } \ \ b->active= 1; \ - b->events_occured= ready_status; \ + b->events_occurred= ready_status; \ res= my_context_continue(&b->async_context); \ b->active= 0; \ if (res > 0) \ diff --git a/sql/contributors.h b/sql/contributors.h index 255decd19cc..04f8b74aa65 100644 --- a/sql/contributors.h +++ b/sql/contributors.h @@ -39,17 +39,17 @@ struct show_table_contributors_st show_table_contributors[]= { /* MariaDB foundation members, in contribution, size , time order */ {"Booking.com", "http://www.booking.com", "Founding member of the MariaDB Foundation"}, {"MariaDB Corporation", "https://mariadb.com", "Founding member of the MariaDB Foundation"}, - {"Auttomattic", "http://automattic.com", "Member of the MariaDB Foundation"}, - {"Parallels", "http://www.parallels.com/products/plesk", "Founding member of the MariaDB Foundation"}, + {"Auttomattic", "http://automattic.com", "Member of the MariaDB Foundation"}, + {"Visma", "http://visma.com", "Member of the MariaDB Foundation"}, + {"Nexedi", "http://www.nexedi.com", "Member of the MariaDB Foundation"}, {"Acronis", "http://www.acronis.com", "Member of the MariaDB Foundation"}, /* Smaller sponsors, newer per year */ {"Verkkokauppa.com", "Finland", "Sponsor of the MariaDB Foundation"}, {"Webyog", "Bangalore", "Sponsor of the MariaDB Foundation"}, - {"Wikimedia Foundation", "USA", "Sponsor of the MariaDB Foundation"}, /* Sponsors of important features */ - {"Google", "USA", "Sponsoring parallel replication and GTID" }, + {"Google", "USA", "Sponsoring encryption, parallel replication and GTID"}, {"Facebook", "USA", "Sponsoring non-blocking API, LIMIT ROWS EXAMINED etc"}, /* Individual contributors, names in historical order, newer first */ diff --git a/sql/debug_sync.h b/sql/debug_sync.h index bf1b3167dbc..25b379e5892 100644 --- a/sql/debug_sync.h +++ b/sql/debug_sync.h @@ -44,6 +44,7 @@ extern void debug_sync_end(void); extern void debug_sync_init_thread(THD *thd); extern void debug_sync_end_thread(THD *thd); extern bool debug_sync_set_action(THD *thd, const char *action_str, size_t len); +extern bool debug_sync_update(THD *thd, char *val_str); #endif /* defined(ENABLED_DEBUG_SYNC) */ diff --git a/sql/discover.cc b/sql/discover.cc index 82648e94bc5..d8ed718fc58 100644 --- a/sql/discover.cc +++ b/sql/discover.cc @@ -199,14 +199,15 @@ int extension_based_table_discovery(MY_DIR *dirp, const char *ext_meta, end= cur + dirp->number_of_files; while (cur < end) { - char *octothorp= strrchr(cur->name + 1, '#'); + char *octothorp= strchr(cur->name + 1, '#'); char *ext= strchr(octothorp ? octothorp : cur->name, FN_EXTCHAR); if (ext) { size_t len= (octothorp ? octothorp : ext) - cur->name; if (from != cur && - (my_strnncoll(cs, (uchar*)from->name, len, (uchar*)cur->name, len) || + (strlen(from->name) <= len || + my_strnncoll(cs, (uchar*)from->name, len, (uchar*)cur->name, len) || (from->name[len] != FN_EXTCHAR && from->name[len] != '#'))) advance(from, to, cur, skip); diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc index 30dffc30edd..6785b46d0da 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -938,7 +938,7 @@ end: @retval FALSE an event with such db/name key exists - @retval TRUE no record found or an error occured. + @retval TRUE no record found or an error occurred. */ bool diff --git a/sql/event_queue.cc b/sql/event_queue.cc index 35187af23ac..ae8ba258717 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -191,7 +191,7 @@ Event_queue::deinit_queue() @param[out] created set to TRUE if no error and the element is added to the queue, FALSE otherwise - @retval TRUE an error occured. The value of created is undefined, + @retval TRUE an error occurred. The value of created is undefined, the element was not deleted. @retval FALSE success */ diff --git a/sql/gcalc_slicescan.h b/sql/gcalc_slicescan.h index 5a0399bc8da..4996287ca88 100644 --- a/sql/gcalc_slicescan.h +++ b/sql/gcalc_slicescan.h @@ -26,7 +26,7 @@ #ifndef GCALC_DBUG_OFF #define GCALC_DBUG_PRINT(b) DBUG_PRINT("Gcalc", b) -#define GCALC_DBUG_ENTER(a) DBUG_ENTER("Gcalc "a) +#define GCALC_DBUG_ENTER(a) DBUG_ENTER("Gcalc " a) #define GCALC_DBUG_RETURN(r) DBUG_RETURN(r) #define GCALC_DBUG_VOID_RETURN DBUG_VOID_RETURN #define GCALC_DBUG_ASSERT(r) DBUG_ASSERT(r) diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index c37f4f145cf..3a3273d279b 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -310,6 +310,7 @@ void print_find_structs() add_structs_to_map(root_by_len,max_len); set_links(root_by_len,max_len); print_hash_map("sql_functions_map"); + free(hash_map); hash_map= 0; size_hash_map= 0; @@ -319,6 +320,7 @@ void print_find_structs() add_structs_to_map(root_by_len2,max_len2); set_links(root_by_len2,max_len2); print_hash_map("symbols_map"); + free(hash_map); } diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index ed05521a473..1daf7f9b944 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -8123,7 +8123,7 @@ uint8 ha_ndbcluster::table_cache_type() @param[out] commit_count Commit count for the table. @return 0 on success. - @return 1 if an error occured. + @return 1 if an error occurred. */ uint ndb_get_commitcount(THD *thd, char *norm_name, diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 64ae31ce231..6ee8fde3e42 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -3875,7 +3875,7 @@ restart: else if (ndb_latest_applied_binlog_epoch > 0) { sql_print_warning("NDB Binlog: cluster has reconnected. " - "Changes to the database that occured while " + "Changes to the database that occurred while " "disconnected will not be in the binlog"); } if (opt_ndb_extra_logging) diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 85c19da9dda..af81962904f 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -8313,7 +8313,7 @@ bool ha_partition::inplace_alter_table(TABLE *altered_table, /* Note that this function will try rollback failed ADD INDEX by executing DROP INDEX for the indexes that were committed (if any) - before the error occured. This means that the underlying storage + before the error occurred. This means that the underlying storage engine must be able to drop index in-place with X-lock held. (As X-lock will be held here if new indexes are to be committed) */ diff --git a/sql/handler.cc b/sql/handler.cc index f3b908ceb1e..e84e1b52ca2 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2013, Monty Program Ab. +/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. + Copyright (c) 2009, 2016, MariaDB 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 @@ -317,7 +317,7 @@ int ha_init_errors(void) /* Set the dedicated error messages. */ SETMSG(HA_ERR_KEY_NOT_FOUND, ER_DEFAULT(ER_KEY_NOT_FOUND)); SETMSG(HA_ERR_FOUND_DUPP_KEY, ER_DEFAULT(ER_DUP_KEY)); - SETMSG(HA_ERR_RECORD_CHANGED, "Update wich is recoverable"); + SETMSG(HA_ERR_RECORD_CHANGED, "Update which is recoverable"); SETMSG(HA_ERR_WRONG_INDEX, "Wrong index given to function"); SETMSG(HA_ERR_CRASHED, ER_DEFAULT(ER_NOT_KEYFILE)); SETMSG(HA_ERR_WRONG_IN_RECORD, ER_DEFAULT(ER_CRASHED_ON_USAGE)); @@ -4279,6 +4279,7 @@ handler::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_info::ALTER_COLUMN_DEFAULT | Alter_inplace_info::ALTER_COLUMN_OPTION | Alter_inplace_info::CHANGE_CREATE_OPTION | + Alter_inplace_info::ALTER_PARTITIONED | Alter_inplace_info::ALTER_RENAME; /* Is there at least one operation that requires copy algorithm? */ diff --git a/sql/handler.h b/sql/handler.h index a2bc0212974..eaa7ccdb1e7 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1,8 +1,8 @@ #ifndef HANDLER_INCLUDED #define HANDLER_INCLUDED /* - Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2009, 2014, Monty Program Ab. + Copyright (c) 2000, 2016, Oracle and/or its affiliates. + Copyright (c) 2009, 2016, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -419,7 +419,9 @@ static const uint MYSQL_START_TRANS_OPT_READ_WRITE = 4; /* Flags for method is_fatal_error */ #define HA_CHECK_DUP_KEY 1 #define HA_CHECK_DUP_UNIQUE 2 +#define HA_CHECK_FK_ERROR 4 #define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE) +#define HA_CHECK_ALL (~0U) enum legacy_db_type { @@ -1295,7 +1297,7 @@ struct handlerton }; /* - By default (if not implemented by the engine, but the discovery_table() is + By default (if not implemented by the engine, but the discover_table() is implemented) it will perform a file-based discovery: - if tablefile_extensions[0] is not null, this will discovers all tables @@ -1832,7 +1834,10 @@ public: // Virtual columns changed static const HA_ALTER_FLAGS ALTER_COLUMN_VCOL = 1L << 30; - // ALTER TABLE for a partitioned table + /** + ALTER TABLE for a partitioned table. The engine needs to commit + online alter of all partitions atomically (using group_commit_ctx) + */ static const HA_ALTER_FLAGS ALTER_PARTITIONED = 1L << 31; /** @@ -2829,7 +2834,10 @@ public: ((flags & HA_CHECK_DUP_KEY) && (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOUND_DUPP_UNIQUE)) || - error == HA_ERR_AUTOINC_ERANGE) + error == HA_ERR_AUTOINC_ERANGE || + ((flags & HA_CHECK_FK_ERROR) && + (error == HA_ERR_ROW_IS_REFERENCED || + error == HA_ERR_NO_REFERENCED_ROW))) return FALSE; return TRUE; } @@ -3512,7 +3520,7 @@ public: *) a) If the previous step succeeds, handler::ha_commit_inplace_alter_table() is called to allow the storage engine to do any final updates to its structures, to make all earlier changes durable and visible to other connections. - b) If we have failed to upgrade lock or any errors have occured during the + b) If we have failed to upgrade lock or any errors have occurred during the handler functions calls (including commit), we call handler::ha_commit_inplace_alter_table() to rollback all changes which were done during previous steps. @@ -4170,4 +4178,4 @@ inline const char *table_case_name(HA_CREATE_INFO *info, const char *name) void print_keydup_error(TABLE *table, KEY *key, const char *msg, myf errflag); void print_keydup_error(TABLE *table, KEY *key, myf errflag); -#endif +#endif /* HANDLER_INCLUDED */ diff --git a/sql/item.cc b/sql/item.cc index bed8824f68f..065204dc9c3 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2014, Oracle and/or its affiliates. + Copyright (c) 2000, 2016, Oracle and/or its affiliates. Copyright (c) 2010, 2016, MariaDB This program is free software; you can redistribute it and/or modify @@ -1306,8 +1306,8 @@ Item *Item_param::safe_charset_converter(CHARSET_INFO *tocs) to it's possible that the converter will not be needed at all: PREPARE stmt FROM 'SELECT * FROM t1 WHERE field = ?'; - SET @@arg= 1; - EXECUTE stms USING @arg; + SET @arg= 1; + EXECUTE stmt USING @arg; In the above example result_type is STRING_RESULT at prepare time, and INT_RESULT at execution time. @@ -3835,7 +3835,7 @@ Item_param::eq(const Item *item, bool binary_cmp) const void Item_param::print(String *str, enum_query_type query_type) { - if (state == NO_VALUE) + if (state == NO_VALUE || query_type & QT_NO_DATA_EXPANSION) { str->append('?'); } @@ -4752,7 +4752,7 @@ bool is_outer_table(TABLE_LIST *table, SELECT_LEX *select) @retval 0 column fully fixed and fix_fields() should return FALSE @retval - -1 error occured + -1 error occurred */ int @@ -6703,7 +6703,7 @@ void Item_field::update_null_value() UPDATE statement. RETURN - 0 if error occured + 0 if error occurred ref if all conditions are met this field otherwise */ @@ -6734,7 +6734,8 @@ Item *Item_field::update_value_transformer(uchar *select_arg) void Item_field::print(String *str, enum_query_type query_type) { - if (field && field->table->const_table) + if (field && field->table->const_table && + !(query_type & QT_NO_DATA_EXPANSION)) { print_value(str); return; diff --git a/sql/item.h b/sql/item.h index 4347bdb6c07..e402112b725 100644 --- a/sql/item.h +++ b/sql/item.h @@ -523,7 +523,7 @@ public: RETURN FALSE if parameter value has been set, - TRUE if error has occured. + TRUE if error has occurred. */ virtual bool set_value(THD *thd, sp_rcontext *ctx, Item **it)= 0; @@ -2363,7 +2363,7 @@ public: max_length= 0; name= name_par ? name_par : (char*) "NULL"; fixed= 1; - collation.set(cs, DERIVATION_IGNORABLE); + collation.set(cs, DERIVATION_IGNORABLE, MY_REPERTOIRE_ASCII); } enum Type type() const { return NULL_ITEM; } bool eq(const Item *item, bool binary_cmp) const { return null_eq(item); } @@ -2513,7 +2513,7 @@ public: /* If value for parameter was not set we treat it as non-const - so noone will use parameters value in fix_fields still + so no one will use parameters value in fix_fields still parameter is constant during execution. */ virtual table_map used_tables() const diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index b2c580db507..e0dbf2c5a73 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -161,10 +161,11 @@ static int cmp_row_type(Item* item1, Item* item2) static int agg_cmp_type(Item_result *type, Item **items, uint nitems) { - uint i; + uint unsigned_count= items[0]->unsigned_flag; type[0]= items[0]->cmp_type(); - for (i= 1 ; i < nitems ; i++) + for (uint i= 1 ; i < nitems ; i++) { + unsigned_count+= items[i]->unsigned_flag; type[0]= item_cmp_type(type[0], items[i]->cmp_type()); /* When aggregating types of two row expressions we have to check @@ -176,6 +177,12 @@ static int agg_cmp_type(Item_result *type, Item **items, uint nitems) if (type[0] == ROW_RESULT && cmp_row_type(items[0], items[i])) return 1; // error found: invalid usage of rows } + /** + If all arguments are of INT type but have different unsigned_flag values, + switch to DECIMAL_RESULT. + */ + if (type[0] == INT_RESULT && unsigned_count != nitems && unsigned_count != 0) + type[0]= DECIMAL_RESULT; return 0; } @@ -2621,10 +2628,7 @@ bool Item_func_ifnull::date_op(MYSQL_TIME *ltime, uint fuzzydate) DBUG_ASSERT(fixed == 1); if (!args[0]->get_date_with_conversion(ltime, fuzzydate & ~TIME_FUZZY_DATES)) return (null_value= false); - if (!args[1]->get_date_with_conversion(ltime, fuzzydate & ~TIME_FUZZY_DATES)) - return (null_value= false); - bzero((char*) ltime,sizeof(*ltime)); - return null_value= !(fuzzydate & TIME_FUZZY_DATES); + return (null_value= args[1]->get_date_with_conversion(ltime, fuzzydate & ~TIME_FUZZY_DATES)); } @@ -3081,24 +3085,6 @@ bool Item_func_case::fix_fields(THD *thd, Item **ref) } -void Item_func_case::agg_str_lengths(Item* arg) -{ - fix_char_length(MY_MAX(max_char_length(), arg->max_char_length())); - set_if_bigger(decimals, arg->decimals); - unsigned_flag= unsigned_flag && arg->unsigned_flag; -} - - -void Item_func_case::agg_num_lengths(Item *arg) -{ - uint len= my_decimal_length_to_precision(arg->max_length, arg->decimals, - arg->unsigned_flag) - arg->decimals; - set_if_bigger(max_length, len); - set_if_bigger(decimals, arg->decimals); - unsigned_flag= unsigned_flag && arg->unsigned_flag; -} - - /** Check if (*place) and new_value points to different Items and call THD::change_item_tree() if needed. @@ -3164,17 +3150,7 @@ void Item_func_case::fix_length_and_dec() } else { - collation.set_numeric(); - max_length=0; - decimals=0; - unsigned_flag= TRUE; - for (uint i= 0; i < ncases; i+= 2) - agg_num_lengths(args[i + 1]); - if (else_expr_num != -1) - agg_num_lengths(args[else_expr_num]); - max_length= my_decimal_precision_to_length_no_truncation(max_length + - decimals, decimals, - unsigned_flag); + fix_attributes(agg, nagg); } /* @@ -3374,16 +3350,12 @@ double Item_func_coalesce::real_op() bool Item_func_coalesce::date_op(MYSQL_TIME *ltime,uint fuzzydate) { DBUG_ASSERT(fixed == 1); - null_value= 0; for (uint i= 0; i < arg_count; i++) { - bool res= args[i]->get_date_with_conversion(ltime, - fuzzydate & ~TIME_FUZZY_DATES); - if (!args[i]->null_value) - return res; + if (!args[i]->get_date_with_conversion(ltime, fuzzydate & ~TIME_FUZZY_DATES)) + return (null_value= false); } - bzero((char*) ltime,sizeof(*ltime)); - return null_value|= !(fuzzydate & TIME_FUZZY_DATES); + return (null_value= true); } @@ -3406,19 +3378,32 @@ void Item_func_coalesce::fix_length_and_dec() { cached_field_type= agg_field_type(args, arg_count); agg_result_type(&cached_result_type, args, arg_count); + fix_attributes(args, arg_count); +} + + +#if MYSQL_VERSION_ID > 100100 +#error Rename this to Item_hybrid_func::fix_attributes() when mering to 10.1 +#endif +void Item_func_hybrid_result_type::fix_attributes(Item **items, uint nitems) +{ switch (cached_result_type) { case STRING_RESULT: - if (count_string_result_length(cached_field_type, args, arg_count)) + if (count_string_result_length(field_type(), + items, nitems)) return; break; case DECIMAL_RESULT: - count_decimal_length(); + collation.set_numeric(); + count_decimal_length(items, nitems); break; case REAL_RESULT: - count_real_length(); + collation.set_numeric(); + count_real_length(items, nitems); break; case INT_RESULT: - count_only_length(args, arg_count); + collation.set_numeric(); + count_only_length(items, nitems); decimals= 0; break; case ROW_RESULT: diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index d109e412f0c..dbd96a89a24 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1274,8 +1274,6 @@ public: Item *find_item(String *str); CHARSET_INFO *compare_collation() { return cmp_collation.collation; } void cleanup(); - void agg_str_lengths(Item *arg); - void agg_num_lengths(Item *arg); }; /* diff --git a/sql/item_func.cc b/sql/item_func.cc index b79be7e9ce4..874687a5c0c 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -227,7 +227,7 @@ Item_func::fix_fields(THD *thd, Item **ref) } } fix_length_and_dec(); - if (thd->is_error()) // An error inside fix_length_and_dec occured + if (thd->is_error()) // An error inside fix_length_and_dec occurred return TRUE; fixed= 1; return FALSE; @@ -639,16 +639,16 @@ void Item_func::count_datetime_length(Item **item, uint nitems) result length/precision depends on argument ones. */ -void Item_func::count_decimal_length() +void Item_func::count_decimal_length(Item **item, uint nitems) { int max_int_part= 0; decimals= 0; unsigned_flag= 1; - for (uint i=0 ; i < arg_count ; i++) + for (uint i=0 ; i < nitems ; i++) { - set_if_bigger(decimals, args[i]->decimals); - set_if_bigger(max_int_part, args[i]->decimal_int_part()); - set_if_smaller(unsigned_flag, args[i]->unsigned_flag); + set_if_bigger(decimals, item[i]->decimals); + set_if_bigger(max_int_part, item[i]->decimal_int_part()); + set_if_smaller(unsigned_flag, item[i]->unsigned_flag); } int precision= MY_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION); fix_char_length(my_decimal_precision_to_length_no_truncation(precision, @@ -679,19 +679,19 @@ void Item_func::count_only_length(Item **item, uint nitems) result length/precision depends on argument ones. */ -void Item_func::count_real_length() +void Item_func::count_real_length(Item **item, uint nitems) { uint32 length= 0; decimals= 0; max_length= 0; - for (uint i=0 ; i < arg_count ; i++) + for (uint i=0 ; i < nitems ; i++) { if (decimals != NOT_FIXED_DEC) { - set_if_bigger(decimals, args[i]->decimals); - set_if_bigger(length, (args[i]->max_length - args[i]->decimals)); + set_if_bigger(decimals, item[i]->decimals); + set_if_bigger(length, (item[i]->max_length - item[i]->decimals)); } - set_if_bigger(max_length, args[i]->max_length); + set_if_bigger(max_length, item[i]->max_length); } if (decimals != NOT_FIXED_DEC) { @@ -809,7 +809,7 @@ void Item_num_op::fix_length_and_dec(void) if (r0 == REAL_RESULT || r1 == REAL_RESULT || r0 == STRING_RESULT || r1 ==STRING_RESULT) { - count_real_length(); + count_real_length(args, arg_count); max_length= float_length(decimals); cached_result_type= REAL_RESULT; } @@ -5651,7 +5651,7 @@ void Item_func_get_user_var::fix_length_and_dec() /* If the variable didn't exist it has been created as a STRING-type. - 'var_entry' is NULL only if there occured an error during the call to + 'var_entry' is NULL only if there occurred an error during the call to get_var_with_binlog. */ if (!error && var_entry) @@ -6317,6 +6317,8 @@ bool Item_func_match::fix_index() for (i=1; i < arg_count; i++) { + if (args[i]->type() != FIELD_ITEM) + goto err; item=(Item_field*)args[i]; for (keynr=0 ; keynr < fts ; keynr++) { diff --git a/sql/item_func.h b/sql/item_func.h index 0b3454fa4b0..3d0cdca4472 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1,7 +1,7 @@ #ifndef ITEM_FUNC_INCLUDED #define ITEM_FUNC_INCLUDED -/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2009, 2014, MariaDB +/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. + Copyright (c) 2009, 2016, MariaDB 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 @@ -40,6 +40,13 @@ protected: */ uint allowed_arg_cols; String *val_str_from_val_str_ascii(String *str, String *str2); + + void count_only_length(Item **item, uint nitems); + void count_real_length(Item **item, uint nitems); + void count_decimal_length(Item **item, uint nitems); + void count_datetime_length(Item **item, uint nitems); + bool count_string_result_length(enum_field_types field_type, + Item **item, uint nitems); public: uint arg_count; /* @@ -154,16 +161,10 @@ public: virtual void print(String *str, enum_query_type query_type); void print_op(String *str, enum_query_type query_type); void print_args(String *str, uint from, enum_query_type query_type); - void count_only_length(Item **item, uint nitems); - void count_real_length(); - void count_decimal_length(); inline bool get_arg0_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) { return (null_value=args[0]->get_date_with_conversion(ltime, fuzzy_date)); } - void count_datetime_length(Item **item, uint nitems); - bool count_string_result_length(enum_field_types field_type, - Item **item, uint nitems); inline bool get_arg0_time(MYSQL_TIME *ltime) { null_value= args[0]->get_time(ltime); @@ -253,7 +254,7 @@ public: char buf[256]; String str(buf, sizeof(buf), system_charset_info); str.length(0); - print(&str, QT_ORDINARY); + print(&str, QT_NO_DATA_EXPANSION); my_error(ER_DATA_OUT_OF_RANGE, MYF(0), type_name, str.c_ptr_safe()); } inline double raise_float_overflow() @@ -444,7 +445,7 @@ class Item_func_hybrid_result_type: public Item_func } protected: Item_result cached_result_type; - + void fix_attributes(Item **item, uint nitems); public: Item_func_hybrid_result_type() :Item_func(), cached_result_type(REAL_RESULT) { collation.set_numeric(); } diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index 94be38e26ee..62d2198e221 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -1,8 +1,8 @@ #ifndef ITEM_GEOFUNC_INCLUDED #define ITEM_GEOFUNC_INCLUDED -/* Copyright (c) 2000, 2010 Oracle and/or its affiliates. - Copyright (C) 2011, 2015 MariaDB +/* Copyright (c) 2000, 2016 Oracle and/or its affiliates. + Copyright (C) 2011, 2016, MariaDB 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 @@ -191,7 +191,7 @@ public: if (args[i]->fixed && args[i]->field_type() != MYSQL_TYPE_GEOMETRY) { String str; - args[i]->print(&str, QT_ORDINARY); + args[i]->print(&str, QT_NO_DATA_EXPANSION); str.append('\0'); my_error(ER_ILLEGAL_VALUE_FOR_TYPE, MYF(0), "non geometric", str.ptr()); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 3b8bc1580bb..4ea3075e69c 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -828,9 +828,10 @@ String *Item_func_des_encrypt::val_str(String *str) /* We make good 24-byte (168 bit) key from given plaintext key with MD5 */ bzero((char*) &ivec,sizeof(ivec)); - EVP_BytesToKey(EVP_des_ede3_cbc(),EVP_md5(),NULL, + if (!EVP_BytesToKey(EVP_des_ede3_cbc(),EVP_md5(),NULL, (uchar*) keystr->ptr(), (int) keystr->length(), - 1, (uchar*) &keyblock,ivec); + 1, (uchar*) &keyblock,ivec)) + goto error; DES_set_key_unchecked(&keyblock.key1,&keyschedule.ks1); DES_set_key_unchecked(&keyblock.key2,&keyschedule.ks2); DES_set_key_unchecked(&keyblock.key3,&keyschedule.ks3); @@ -921,9 +922,10 @@ String *Item_func_des_decrypt::val_str(String *str) goto error; bzero((char*) &ivec,sizeof(ivec)); - EVP_BytesToKey(EVP_des_ede3_cbc(),EVP_md5(),NULL, + if (!EVP_BytesToKey(EVP_des_ede3_cbc(),EVP_md5(),NULL, (uchar*) keystr->ptr(),(int) keystr->length(), - 1,(uchar*) &keyblock,ivec); + 1,(uchar*) &keyblock,ivec)) + goto error; // Here we set all 64-bit keys (56 effective) one by one DES_set_key_unchecked(&keyblock.key1,&keyschedule.ks1); DES_set_key_unchecked(&keyblock.key2,&keyschedule.ks2); diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 7d361263548..5070fc5a646 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -5854,7 +5854,7 @@ int subselect_partial_match_engine::exec() /* Search for a complete match. */ if ((lookup_res= lookup_engine->index_lookup())) { - /* An error occured during lookup(). */ + /* An error occurred during lookup(). */ item_in->value= 0; item_in->null_value= 0; return lookup_res; diff --git a/sql/log.cc b/sql/log.cc index 745b7747aab..83ddca7aa16 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -694,7 +694,7 @@ void Log_to_csv_event_handler::cleanup() indicated in the return value. @retval FALSE OK - @retval TRUE error occured + @retval TRUE error occurred */ bool Log_to_csv_event_handler:: @@ -859,7 +859,7 @@ err: RETURN FALSE - OK - TRUE - error occured + TRUE - error occurred */ bool Log_to_csv_event_handler:: @@ -1164,7 +1164,7 @@ void Log_to_file_event_handler::flush() RETURN FALSE - OK - TRUE - error occured + TRUE - error occurred */ bool LOGGER::error_log_print(enum loglevel level, const char *format, @@ -1322,7 +1322,7 @@ bool LOGGER::flush_general_log() RETURN FALSE OK - TRUE error occured + TRUE error occurred */ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length, @@ -2885,7 +2885,7 @@ void MYSQL_QUERY_LOG::reopen_file() RETURN FASE - OK - TRUE - error occured + TRUE - error occurred */ bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host, @@ -2987,7 +2987,7 @@ err: RETURN FALSE - OK - TRUE - error occured + TRUE - error occurred */ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time, @@ -6291,7 +6291,7 @@ binlog_checkpoint_callback(void *cookie) /* For every supporting engine, we increment the xid_count and issue a commit_checkpoint_request(). Then we can count when all - commit_checkpoint_notify() callbacks have occured, and then log a new + commit_checkpoint_notify() callbacks have occurred, and then log a new binlog checkpoint event. */ mysql_bin_log.mark_xids_active(entry->binlog_id, 1); diff --git a/sql/log_event.cc b/sql/log_event.cc index bffaa9ee554..ee1b865597d 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1351,9 +1351,9 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet, if (packet->append(file, data_len)) { /* - Fatal error occured when appending rest of the event + Fatal error occurred when appending rest of the event to packet, possible failures: - 1. EOF occured when reading from file, it's really an error + 1. EOF occurred when reading from file, it's really an error as data_len is >=0 there's supposed to be more bytes available. file->error will have been set to number of bytes left to read 2. Read was interrupted, file->error would normally be set to -1 @@ -11491,7 +11491,10 @@ Rows_log_event::write_row(rpl_group_info *rgi, /* unpack row into table->record[0] */ if ((error= unpack_current_row(rgi))) + { + table->file->print_error(error, MYF(0)); DBUG_RETURN(error); + } if (m_curr_row == m_rows_buf && !invoke_triggers) { @@ -12602,8 +12605,8 @@ Update_rows_log_event::do_exec_row(rpl_group_info *rgi) We need to read the second image in the event of error to be able to skip to the next pair of updates */ - m_curr_row= m_curr_row_end; - unpack_current_row(rgi); + if ((m_curr_row= m_curr_row_end)) + unpack_current_row(rgi); return error; } diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index e6c05aeb849..ad68275a274 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -249,7 +249,7 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, rpl_group_info *rgi) } if (error) - { /* error has occured during the transaction */ + { /* error has occurred during the transaction */ rli->report(ERROR_LEVEL, ev_thd->get_stmt_da()->sql_errno(), NULL, "Error in %s event: error during transaction execution " "on table %s.%s. %s", @@ -1690,7 +1690,7 @@ int Old_rows_log_event::do_apply_event(rpl_group_info *rgi) } // if (table) if (error) - { /* error has occured during the transaction */ + { /* error has occurred during the transaction */ rli->report(ERROR_LEVEL, thd->net.last_errno, NULL, "Error in %s event: error during transaction execution " "on table %s.%s. %s", diff --git a/sql/my_apc.cc b/sql/my_apc.cc index 17660688be0..0b9fe9899b9 100644 --- a/sql/my_apc.cc +++ b/sql/my_apc.cc @@ -158,7 +158,7 @@ void init_show_explain_psi_keys(void) @retval FALSE - Ok, the call has been made @retval TRUE - Call wasnt made (either the target is in disabled state or - timeout occured) + timeout occurred) */ bool Apc_target::make_apc_call(THD *caller_thd, Apc_call *call, diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc index 9b4f45a9971..c39789f7c97 100644 --- a/sql/mysql_install_db.cc +++ b/sql/mysql_install_db.cc @@ -119,10 +119,10 @@ static void die(const char *fmt, ...) if (verbose_errors) { fprintf(stderr, - "http://kb.askmonty.org/v/installation-issues-on-windows contains some help\n" + "https://mariadb.com/kb/en/installation-issues-on-windows contains some help\n" "for solving the most common problems. If this doesn't help you, please\n" - "leave a comment in the Knowledgebase or file a bug report at\n" - "http://mariadb.org/jira"); + "leave a comment in the Knowledge Base or file a bug report at\n" + "https://jira.mariadb.org"); } fflush(stderr); va_end(args); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 0abb394f89f..f28225f5dad 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -288,7 +288,7 @@ const char *show_comp_option_name[]= {"YES", "NO", "DISABLED"}; static const char *tc_heuristic_recover_names[]= { - "COMMIT", "ROLLBACK", NullS + "OFF", "COMMIT", "ROLLBACK", NullS }; static TYPELIB tc_heuristic_recover_typelib= { @@ -7445,7 +7445,7 @@ pthread_handler_t handle_connections_shared_memory(void *arg) thd->security_ctx->host= my_strdup(my_localhost, MYF(0)); /* Host is unknown */ create_new_thread(thd); connect_number++; - set_current_thd(thd); + set_current_thd(0); continue; errorconn: @@ -9491,6 +9491,7 @@ mysqld_get_one_option(int optid, log_error_file_ptr= const_cast<char*>(""); break; case OPT_IGNORE_DB_DIRECTORY: + opt_ignore_db_dirs= NULL; // will be set in ignore_db_dirs_process_additions if (*argument == 0) ignore_db_dirs_reset(); else diff --git a/sql/mysqld.h b/sql/mysqld.h index d549013cd32..28ce4faceb5 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2006, 2015, Oracle and/or its affiliates. - Copyright (c) 2010, 2015, MariaDB +/* Copyright (c) 2006, 2016, Oracle and/or its affiliates. + Copyright (c) 2010, 2016, MariaDB 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 @@ -636,7 +636,13 @@ enum enum_query_type /// Without character set introducers. QT_WITHOUT_INTRODUCERS= (1 << 1), /// view internal representation (like QT_ORDINARY except ORDER BY clause) - QT_VIEW_INTERNAL= (1 << 2) + QT_VIEW_INTERNAL= (1 << 2), + /** + If an expression is constant, print the expression, not the value + it evaluates to. Should be used for error messages, so that they + don't reveal values. + */ + QT_NO_DATA_EXPANSION= (1 << 9), }; /* query_id */ diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index de57143e61d..a81b091461f 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -2243,7 +2243,8 @@ bool optimize_semijoin_nests(JOIN *join, table_map all_table_map) rows *= join->map2table[tableno]->table->quick_condition_rows; sjm->rows= MY_MIN(sjm->rows, rows); } - memcpy(sjm->positions, join->best_positions + join->const_tables, + memcpy((uchar*) sjm->positions, + (uchar*) (join->best_positions + join->const_tables), sizeof(POSITION) * n_tables); /* @@ -3347,7 +3348,7 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join) SJ_MATERIALIZATION_INFO *sjm= s->emb_sj_nest->sj_mat_info; sjm->is_used= TRUE; sjm->is_sj_scan= FALSE; - memcpy(pos - sjm->tables + 1, sjm->positions, + memcpy((uchar*) (pos - sjm->tables + 1), (uchar*) sjm->positions, sizeof(POSITION) * sjm->tables); recalculate_prefix_record_count(join, tablenr - sjm->tables + 1, tablenr); @@ -3363,8 +3364,8 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join) sjm->is_used= TRUE; sjm->is_sj_scan= TRUE; first= pos->sjmat_picker.sjm_scan_last_inner - sjm->tables + 1; - memcpy(join->best_positions + first, - sjm->positions, sizeof(POSITION) * sjm->tables); + memcpy((uchar*) (join->best_positions + first), + (uchar*) sjm->positions, sizeof(POSITION) * sjm->tables); recalculate_prefix_record_count(join, first, first + sjm->tables); join->best_positions[first].sj_strategy= SJ_OPT_MATERIALIZE_SCAN; join->best_positions[first].n_sj_tables= sjm->tables; diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index b2e957a3e6e..98712f18c1b 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -698,7 +698,7 @@ do_retry: thd->clear_error(); /* - If we retry due to a deadlock kill that occured during the commit step, we + If we retry due to a deadlock kill that occurred during the commit step, we might have already updated (but not committed) an update of table mysql.gtid_slave_pos, and cleared the gtid_pending flag. Now we have rolled back any such update, so we must set the gtid_pending flag back to @@ -1100,7 +1100,7 @@ handle_rpl_parallel_thread(void *arg) /* Register ourself to wait for the previous commit, if we need to do such registration _and_ that previous commit has not already - occured. + occurred. */ register_wait_for_prior_event_group_commit(rgi, entry); @@ -1149,7 +1149,7 @@ handle_rpl_parallel_thread(void *arg) { /* Do an extra check for (deadlock) kill here. This helps prevent a - lingering deadlock kill that occured during normal DML processing to + lingering deadlock kill that occurred during normal DML processing to propagate past the mark_start_commit(). If we detect a deadlock only after mark_start_commit(), we have to unmark, which has at least a theoretical possibility of leaving a window where it looks like all diff --git a/sql/rpl_parallel.h b/sql/rpl_parallel.h index 3012daa8763..a02c1af3b3e 100644 --- a/sql/rpl_parallel.h +++ b/sql/rpl_parallel.h @@ -296,7 +296,7 @@ struct rpl_parallel_entry { group here. Then later event groups (with higher sub_id) can know not to try to start (event groups that already started will be rolled back when wait_for_prior_commit() returns error). - The value is ULONGLONG_MAX when no error occured. + The value is ULONGLONG_MAX when no error occurred. */ uint64 stop_on_error_sub_id; /* diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc index 633e71a963c..df8036c40d8 100644 --- a/sql/rpl_record.cc +++ b/sql/rpl_record.cc @@ -185,7 +185,7 @@ pack_row(TABLE *table, MY_BITMAP const* cols, @retval HA_ERR_GENERIC A generic, internal, error caused the unpacking to fail. - @retval ER_SLAVE_CORRUPT_EVENT + @retval HA_ERR_CORRUPT_EVENT Found error when trying to unpack fields. */ #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) @@ -340,7 +340,7 @@ unpack_row(rpl_group_info *rgi, "Could not read field '%s' of table '%s.%s'", f->field_name, table->s->db.str, table->s->table_name.str); - DBUG_RETURN(ER_SLAVE_CORRUPT_EVENT); + DBUG_RETURN(HA_ERR_CORRUPT_EVENT); } } diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 4394e796a1a..627f54631a3 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -6035,7 +6035,7 @@ ER_EVENT_CANNOT_ALTER_IN_THE_PAST eng "Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was not changed. Specify a time in the future." ger "Execution Zeitpunkt des Ereignisses in der Vergangenheit liegt, und es war NACH ABSCHLUSS Set nicht erhalten. Die Veranstaltung wurde nicht verändert. Geben Sie einen Zeitpunkt in der Zukunft." ER_SLAVE_INCIDENT - eng "The incident %s occured on the master. Message: %-.64s" + eng "The incident %s occurred on the master. Message: %-.64s" ger "Der Vorfall %s passierte auf dem Master. Meldung: %-.64s" ER_NO_PARTITION_FOR_GIVEN_VALUE_SILENT eng "Table has no partition for some existing values" diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc index 3fadbcd088f..bb1e6321042 100644 --- a/sql/signal_handler.cc +++ b/sql/signal_handler.cc @@ -100,7 +100,7 @@ extern "C" sig_handler handle_fatal_signal(int sig) "or misconfigured. This error can also be caused by malfunctioning hardware.\n\n"); my_safe_printf_stderr("%s", - "To report this bug, see http://kb.askmonty.org/en/reporting-bugs\n\n"); + "To report this bug, see https://mariadb.com/kb/en/reporting-bugs\n\n"); my_safe_printf_stderr("%s", "We will try our best to scrape up some info that will hopefully help\n" @@ -216,7 +216,7 @@ extern "C" sig_handler handle_fatal_signal(int sig) if (calling_initgroups) { my_safe_printf_stderr("%s", "\n" - "This crash occured while the server was calling initgroups(). This is\n" + "This crash occurred while the server was calling initgroups(). This is\n" "often due to the use of a mysqld that is statically linked against \n" "glibc and configured to use LDAP in /etc/nsswitch.conf.\n" "You will need to either upgrade to a version of glibc that does not\n" diff --git a/sql/slave.cc b/sql/slave.cc index 625ae7b0b4b..4bc4cd4ab83 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -4932,6 +4932,7 @@ err_during_init: */ mysql_mutex_lock(&LOCK_active_mi); if (opt_slave_parallel_threads > 0 && + master_info_index &&// master_info_index is set to NULL on server shutdown !master_info_index->any_slave_sql_running()) rpl_parallel_inactivate_pool(&global_rpl_thread_pool); mysql_mutex_unlock(&LOCK_active_mi); diff --git a/sql/sp_head.h b/sql/sp_head.h index dbdb957aa79..71a64d9a5af 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -608,7 +608,7 @@ public: instruction for CONTINUE error handlers. @retval 0 on success, - @retval other if some error occured + @retval other if some error occurred */ virtual int execute(THD *thd, uint *nextp) = 0; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index e6fb4911f01..c8223a3cadc 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2014, SkySQL Ab. +/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. + Copyright (c) 2009, 2016, MariaDB 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 @@ -742,9 +742,8 @@ static ACL_USER *find_user_wild(const char *host, const char *user, const char * static ACL_ROLE *find_acl_role(const char *user); static ROLE_GRANT_PAIR *find_role_grant_pair(const LEX_STRING *u, const LEX_STRING *h, const LEX_STRING *r); static ACL_USER_BASE *find_acl_user_base(const char *user, const char *host); -static bool update_user_table(THD *thd, TABLE *table, const char *host, - const char *user, const char *new_password, - uint new_password_len); +static bool update_user_table(THD *, TABLE *, const char *, const char *, const + char *, uint, bool); static my_bool acl_load(THD *thd, TABLE_LIST *tables); static my_bool grant_load(THD *thd, TABLE_LIST *tables); static inline void get_grantor(THD *thd, char* grantor); @@ -1035,7 +1034,6 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) grant_version++; /* Privileges updated */ init_sql_alloc(&acl_memroot, ACL_ALLOC_BLOCK_SIZE, 0, MYF(0)); - (void) my_init_dynamic_array(&acl_hosts,sizeof(ACL_HOST), 20, 50, MYF(0)); if (tables[0].table) // "host" table may not exist (e.g. in MySQL 5.6.7+) { if (init_read_record(&read_record_info, thd, table= tables[0].table, @@ -1097,11 +1095,6 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) NULL, 1, 1, FALSE)) goto end; table->use_all_columns(); - (void) my_init_dynamic_array(&acl_users,sizeof(ACL_USER), 50, 100, MYF(0)); - (void) my_hash_init2(&acl_roles,50, &my_charset_utf8_bin, - 0, 0, 0, (my_hash_get_key) acl_role_get_key, 0, - (void (*)(void *))free_acl_role, 0); - username_char_length= MY_MIN(table->field[1]->char_length(), USERNAME_CHAR_LENGTH); password_length= table->field[2]->field_length / @@ -1361,7 +1354,6 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) NULL, 1, 1, FALSE)) goto end; table->use_all_columns(); - (void) my_init_dynamic_array(&acl_dbs,sizeof(ACL_DB), 50, 100, MYF(0)); while (!(read_record_info.read_record(&read_record_info))) { ACL_DB db; @@ -1423,8 +1415,6 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) end_read_record(&read_record_info); freeze_size(&acl_dbs); - (void) my_init_dynamic_array(&acl_proxy_users, sizeof(ACL_PROXY_USER), - 50, 100, MYF(0)); if (tables[3].table) { if (init_read_record(&read_record_info, thd, table= tables[3].table, @@ -1461,10 +1451,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) NULL, 1, 1, FALSE)) goto end; table->use_all_columns(); - /* account for every role mapping */ - (void) my_hash_init2(&acl_roles_mappings, 50, system_charset_info, 0, 0, 0, - (my_hash_get_key) acl_role_map_get_key, 0, 0, 0); MEM_ROOT temp_root; init_alloc_root(&temp_root, ACL_ALLOC_BLOCK_SIZE, 0, MYF(0)); while (!(read_record_info.read_record(&read_record_info))) @@ -1503,6 +1490,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) return_val= FALSE; end: + end_read_record(&read_record_info); thd->variables.sql_mode= old_sql_mode; DBUG_RETURN(return_val); } @@ -1519,12 +1507,12 @@ void acl_free(bool end) delete_dynamic(&acl_proxy_users); my_hash_free(&acl_check_hosts); my_hash_free(&acl_roles_mappings); - plugin_unlock(0, native_password_plugin); - plugin_unlock(0, old_password_plugin); if (!end) acl_cache->clear(1); /* purecov: inspected */ else { + plugin_unlock(0, native_password_plugin); + plugin_unlock(0, old_password_plugin); delete acl_cache; acl_cache=0; } @@ -1605,6 +1593,15 @@ my_bool acl_reload(THD *thd) old_acl_roles_mappings= acl_roles_mappings; old_acl_proxy_users= acl_proxy_users; old_acl_dbs= acl_dbs; + my_init_dynamic_array(&acl_hosts, sizeof(ACL_HOST), 20, 50, MYF(0)); + my_init_dynamic_array(&acl_users, sizeof(ACL_USER), 50, 100, MYF(0)); + my_init_dynamic_array(&acl_dbs, sizeof(ACL_DB), 50, 100, MYF(0)); + my_init_dynamic_array(&acl_proxy_users, sizeof(ACL_PROXY_USER), 50, 100, MYF(0)); + my_hash_init2(&acl_roles,50, &my_charset_utf8_bin, + 0, 0, 0, (my_hash_get_key) acl_role_get_key, 0, + (void (*)(void *))free_acl_role, 0); + my_hash_init2(&acl_roles_mappings, 50, system_charset_info, 0, 0, 0, + (my_hash_get_key) acl_role_map_get_key, 0, 0, 0); old_mem= acl_memroot; delete_dynamic(&acl_wild_hosts); my_hash_free(&acl_check_hosts); @@ -2622,6 +2619,7 @@ bool change_password(THD *thd, const char *host, const char *user, enum_binlog_format save_binlog_format; uint new_password_len= (uint) strlen(new_password); bool result= 1; + bool use_salt= 0; #ifdef WITH_WSREP const CSET_STRING query_save = thd->query_string; #endif /* WITH_WSREP */ @@ -2694,6 +2692,7 @@ bool change_password(THD *thd, const char *host, const char *user, acl_user->auth_string.length= new_password_len; set_user_salt(acl_user, new_password, new_password_len); set_user_plugin(acl_user, new_password_len); + use_salt= 1; } else push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, @@ -2702,7 +2701,7 @@ bool change_password(THD *thd, const char *host, const char *user, if (update_user_table(thd, table, safe_str(acl_user->host.hostname), safe_str(acl_user->user.str), - new_password, new_password_len)) + new_password, new_password_len, use_salt)) { mysql_mutex_unlock(&acl_cache->lock); /* purecov: deadcode */ goto end; @@ -3012,7 +3011,8 @@ bool hostname_requires_resolving(const char *hostname) static bool update_user_table(THD *thd, TABLE *table, const char *host, const char *user, - const char *new_password, uint new_password_len) + const char *new_password, uint new_password_len, + bool reset_plugin) { char user_key[MAX_KEY_LENGTH]; int error; @@ -3035,6 +3035,11 @@ static bool update_user_table(THD *thd, TABLE *table, } store_record(table,record[1]); table->field[2]->store(new_password, new_password_len, system_charset_info); + if (reset_plugin && table->s->fields >= 41) + { + table->field[40]->reset(); + table->field[41]->reset(); + } if ((error=table->file->ha_update_row(table->record[1],table->record[0])) && error != HA_ERR_RECORD_IS_THE_SAME) { @@ -7493,7 +7498,8 @@ ulong get_column_grant(THD *thd, GRANT_INFO *grant, if (!grant_column) priv|= (grant->privilege | grant_table_role->privs); else - priv|= (grant->privilege | grant_table->privs | grant_column->rights); + priv|= (grant->privilege | grant_table_role->privs | + grant_column->rights); } } mysql_rwlock_unlock(&LOCK_grant); @@ -7598,9 +7604,6 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user) DBUG_RETURN(TRUE); } - mysql_rwlock_rdlock(&LOCK_grant); - mysql_mutex_lock(&acl_cache->lock); - if (lex_user->user.str == current_user.str) { username= thd->security_ctx->priv_user; @@ -7618,23 +7621,28 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user) } else { - lex_user= get_current_user(thd, lex_user, false); + Security_context *sctx= thd->security_ctx; + bool do_check_access; + + lex_user= get_current_user(thd, lex_user); if (!lex_user) - { - mysql_mutex_unlock(&acl_cache->lock); - mysql_rwlock_unlock(&LOCK_grant); DBUG_RETURN(TRUE); - } if (lex_user->is_role()) { rolename= lex_user->user.str; + do_check_access= strcmp(rolename, sctx->priv_role); } else { username= lex_user->user.str; hostname= lex_user->host.str; + do_check_access= strcmp(username, sctx->priv_user) || + strcmp(hostname, sctx->priv_host); } + + if (do_check_access && check_access(thd, SELECT_ACL, "mysql", 0, 0, 1, 0)) + DBUG_RETURN(TRUE); } DBUG_ASSERT(rolename || username); @@ -7649,12 +7657,10 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user) field_list.push_back(field); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - { - mysql_mutex_unlock(&acl_cache->lock); - mysql_rwlock_unlock(&LOCK_grant); - DBUG_RETURN(TRUE); - } + + mysql_rwlock_rdlock(&LOCK_grant); + mysql_mutex_lock(&acl_cache->lock); if (username) { @@ -9935,7 +9941,7 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name, @return @retval FALSE Success - @retval TRUE An error occured. Error message not yet sent. + @retval TRUE An error occurred. Error message not yet sent. */ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name, diff --git a/sql/sql_base.cc b/sql/sql_base.cc index d71fc8a439e..f465a34f199 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8575,7 +8575,7 @@ bool setup_on_expr(THD *thd, TABLE_LIST *table, bool is_update) TODO RETURN - TRUE if some error occured (e.g. out of memory) + TRUE if some error occurred (e.g. out of memory) FALSE if all is OK */ @@ -8685,7 +8685,7 @@ err_no_arena: function. @return Status - @retval true An error occured. + @retval true An error occurred. @retval false OK. */ @@ -8793,7 +8793,7 @@ err: record[1] buffers correspond to new and old versions of row respectively. @return Status - @retval true An error occured. + @retval true An error occurred. @retval false OK. */ @@ -8849,7 +8849,7 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, List<Item> &fields, function. @return Status - @retval true An error occured. + @retval true An error occurred. @retval false OK. */ @@ -8941,7 +8941,7 @@ err: record[1] buffers correspond to new and old versions of row respectively. @return Status - @retval true An error occured. + @retval true An error occurred. @retval false OK. */ diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 205bce08a12..5705694208a 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2130,50 +2130,67 @@ bool THD::notify_shared_lock(MDL_context_owner *ctx_in_use, { THD *in_use= ctx_in_use->get_thd(); bool signalled= FALSE; + DBUG_ENTER("THD::notify_shared_lock"); + DBUG_PRINT("enter",("needs_thr_lock_abort: %d", needs_thr_lock_abort)); if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) && !in_use->killed) { - in_use->killed= KILL_CONNECTION; - mysql_mutex_lock(&in_use->mysys_var->mutex); - if (in_use->mysys_var->current_cond) - mysql_cond_broadcast(in_use->mysys_var->current_cond); - mysql_mutex_unlock(&in_use->mysys_var->mutex); + /* This code is similar to kill_delayed_threads() */ + DBUG_PRINT("info", ("kill delayed thread")); + mysql_mutex_lock(&in_use->LOCK_thd_data); + if (in_use->killed < KILL_CONNECTION) + in_use->killed= KILL_CONNECTION; + if (in_use->mysys_var) + { + mysql_mutex_lock(&in_use->mysys_var->mutex); + if (in_use->mysys_var->current_cond) + mysql_cond_broadcast(in_use->mysys_var->current_cond); + + /* Abort if about to wait in thr_upgrade_write_delay_lock */ + in_use->mysys_var->abort= 1; + mysql_mutex_unlock(&in_use->mysys_var->mutex); + } + mysql_mutex_unlock(&in_use->LOCK_thd_data); signalled= TRUE; } if (needs_thr_lock_abort) { mysql_mutex_lock(&in_use->LOCK_thd_data); - for (TABLE *thd_table= in_use->open_tables; - thd_table ; - thd_table= thd_table->next) + /* If not already dying */ + if (in_use->killed != KILL_CONNECTION_HARD) { - /* - Check for TABLE::needs_reopen() is needed since in some places we call - handler::close() for table instance (and set TABLE::db_stat to 0) - and do not remove such instances from the THD::open_tables - for some time, during which other thread can see those instances - (e.g. see partitioning code). - */ - if (!thd_table->needs_reopen()) -#ifdef WITH_WSREP + for (TABLE *thd_table= in_use->open_tables; + thd_table ; + thd_table= thd_table->next) { - signalled|= mysql_lock_abort_for_thread(this, thd_table); - if (this && WSREP(this) && wsrep_thd_is_BF((void *)this, FALSE)) + /* + Check for TABLE::needs_reopen() is needed since in some + places we call handler::close() for table instance (and set + TABLE::db_stat to 0) and do not remove such instances from + the THD::open_tables for some time, during which other + thread can see those instances (e.g. see partitioning code). + */ + if (!thd_table->needs_reopen()) +#ifdef WITH_WSREP { - WSREP_DEBUG("remove_table_from_cache: %llu", - (unsigned long long) this->real_id); - wsrep_abort_thd((void *)this, (void *)in_use, FALSE); + signalled|= mysql_lock_abort_for_thread(this, thd_table); + if (this && WSREP(this) && wsrep_thd_is_BF((void *)this, FALSE)) + { + WSREP_DEBUG("remove_table_from_cache: %llu", + (unsigned long long) this->real_id); + wsrep_abort_thd((void *)this, (void *)in_use, FALSE); + } } - } #else - signalled|= mysql_lock_abort_for_thread(this, thd_table); + signalled|= mysql_lock_abort_for_thread(this, thd_table); #endif + } } mysql_mutex_unlock(&in_use->LOCK_thd_data); } - return signalled; + DBUG_RETURN(signalled); } diff --git a/sql/sql_class.h b/sql/sql_class.h index 5c9847c5a68..b9f0c0a0ae7 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2015, Oracle and/or its affiliates. + Copyright (c) 2000, 2016, Oracle and/or its affiliates. Copyright (c) 2009, 2016, MariaDB This program is free software; you can redistribute it and/or modify @@ -2120,6 +2120,18 @@ public: current_stmt_binlog_format == BINLOG_FORMAT_ROW); return current_stmt_binlog_format == BINLOG_FORMAT_ROW; } + /** + Determine if binlogging is disabled for this session + @retval 0 if the current statement binlogging is disabled + (could be because of binlog closed/binlog option + is set to false). + @retval 1 if the current statement will be binlogged + */ + inline bool is_current_stmt_binlog_disabled() const + { + return (!(variables.option_bits & OPTION_BIN_LOG) || + !mysql_bin_log.is_open()); + } enum binlog_filter_state { diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 096f4616300..3a67ea40eeb 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1210,7 +1210,8 @@ void end_connection(THD *thd) } if (!thd->killed && (net->error && net->vio != 0)) - thd->print_aborted_warning(1, ER(ER_UNKNOWN_ERROR)); + thd->print_aborted_warning(1, + thd->get_stmt_da()->is_error() ? thd->get_stmt_da()->message() : ER(ER_UNKNOWN_ERROR)); } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index c4dc41f7626..90614624aa6 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2010, 2015, MariaDB + Copyright (c) 2000, 2016, Oracle and/or its affiliates. + Copyright (c) 2010, 2016, MariaDB 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 @@ -1592,9 +1592,10 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) else table->file->insert_id_for_cur_row= insert_id_for_cur_row; bool is_duplicate_key_error; - if (table->file->is_fatal_error(error, HA_CHECK_DUP)) + if (table->file->is_fatal_error(error, HA_CHECK_ALL)) goto err; - is_duplicate_key_error= table->file->is_fatal_error(error, 0); + is_duplicate_key_error= + table->file->is_fatal_error(error, HA_CHECK_ALL & ~HA_CHECK_DUP); if (!is_duplicate_key_error) { /* @@ -1722,7 +1723,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) error != HA_ERR_RECORD_IS_THE_SAME) { if (info->ignore && - !table->file->is_fatal_error(error, HA_CHECK_DUP_KEY)) + !table->file->is_fatal_error(error, HA_CHECK_ALL)) { if (!(thd->variables.old_behavior & OLD_MODE_NO_DUP_KEY_WARNINGS_WITH_IGNORE)) @@ -1852,7 +1853,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) { DEBUG_SYNC(thd, "write_row_noreplace"); if (!info->ignore || - table->file->is_fatal_error(error, HA_CHECK_DUP)) + table->file->is_fatal_error(error, HA_CHECK_ALL)) goto err; if (!(thd->variables.old_behavior & OLD_MODE_NO_DUP_KEY_WARNINGS_WITH_IGNORE)) @@ -1982,7 +1983,7 @@ public: TABLE *table; mysql_mutex_t mutex; mysql_cond_t cond, cond_client; - volatile uint tables_in_use,stacked_inserts; + uint tables_in_use, stacked_inserts; volatile bool status; /** When the handler thread starts, it clones a metadata lock ticket @@ -2624,14 +2625,16 @@ static void end_delayed_insert(THD *thd) void kill_delayed_threads(void) { + DBUG_ENTER("kill_delayed_threads"); mysql_mutex_lock(&LOCK_delayed_insert); // For unlink from list I_List_iterator<Delayed_insert> it(delayed_threads); Delayed_insert *di; while ((di= it++)) { - di->thd.killed= KILL_CONNECTION; mysql_mutex_lock(&di->thd.LOCK_thd_data); + if (di->thd.killed < KILL_CONNECTION) + di->thd.killed= KILL_CONNECTION; if (di->thd.mysys_var) { mysql_mutex_lock(&di->thd.mysys_var->mutex); @@ -2652,6 +2655,7 @@ void kill_delayed_threads(void) mysql_mutex_unlock(&di->thd.LOCK_thd_data); } mysql_mutex_unlock(&LOCK_delayed_insert); // For unlink from list + DBUG_VOID_RETURN; } @@ -2849,6 +2853,12 @@ pthread_handler_t handle_delayed_insert(void *arg) /* Tell client that the thread is initialized */ mysql_cond_signal(&di->cond_client); + /* + Inform mdl that it needs to call mysql_lock_abort to abort locks + for delayed insert. + */ + thd->mdl_context.set_needs_thr_lock_abort(TRUE); + /* Now wait until we get an insert or lock to handle */ /* We will not abort as long as a client thread uses this thread */ @@ -2857,6 +2867,7 @@ pthread_handler_t handle_delayed_insert(void *arg) if (thd->killed) { uint lock_count; + DBUG_PRINT("delayed", ("Insert delayed killed")); /* Remove this from delay insert list so that no one can request a table from this @@ -2867,11 +2878,15 @@ pthread_handler_t handle_delayed_insert(void *arg) lock_count=di->lock_count(); mysql_mutex_unlock(&LOCK_delayed_insert); mysql_mutex_lock(&di->mutex); - if (!lock_count && !di->tables_in_use && !di->stacked_inserts) + if (!lock_count && !di->tables_in_use && !di->stacked_inserts && + !thd->lock) break; // Time to die } /* Shouldn't wait if killed or an insert is waiting. */ + DBUG_PRINT("delayed", + ("thd->killed: %d di->status: %d di->stacked_inserts: %d", + thd->killed, di->status, di->stacked_inserts)); if (!thd->killed && !di->status && !di->stacked_inserts) { struct timespec abstime; @@ -2911,6 +2926,9 @@ pthread_handler_t handle_delayed_insert(void *arg) mysql_mutex_unlock(&di->thd.mysys_var->mutex); mysql_mutex_lock(&di->mutex); } + DBUG_PRINT("delayed", + ("thd->killed: %d di->tables_in_use: %d thd->lock: %d", + thd->killed, di->tables_in_use, thd->lock != 0)); if (di->tables_in_use && ! thd->lock && !thd->killed) { @@ -2971,9 +2989,19 @@ pthread_handler_t handle_delayed_insert(void *arg) { DBUG_ENTER("handle_delayed_insert-cleanup"); di->table=0; - thd->killed= KILL_CONNECTION; // If error mysql_mutex_unlock(&di->mutex); + /* + Protect against mdl_locks trying to access open tables + We use KILL_CONNECTION_HARD here to ensure that + THD::notify_shared_lock() dosn't try to access open tables after + this. + */ + mysql_mutex_lock(&thd->LOCK_thd_data); + thd->killed= KILL_CONNECTION_HARD; // If error + thd->mdl_context.set_needs_thr_lock_abort(0); + mysql_mutex_unlock(&thd->LOCK_thd_data); + close_thread_tables(thd); // Free the table thd->mdl_context.release_transactional_locks(); mysql_cond_broadcast(&di->cond_client); // Safety diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 254b7026e96..f701c424f63 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -2206,7 +2206,7 @@ finish: for a match for any record from join_tab. To iterate over the candidates for a match the virtual function get_next_candidate_for_match is used, while the virtual function prepare_look_for_matches is called to prepare - for such iteration proccess. + for such iteration process. NOTES The function produces all matching extensions for the records in the diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 6ba384e93a0..019231e2004 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -590,7 +590,7 @@ public: global parameters for union */ st_select_lex *global_parameters; - //node on wich we should return current_select pointer after parsing subquery + //node on which we should return current_select pointer after parsing subquery st_select_lex *return_to; /* LIMIT clause runtime counters */ ha_rows select_limit_cnt, offset_limit_cnt; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 08687b20b00..5d631027900 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2010, 2015, MariaDB + Copyright (c) 2000, 2016, Oracle and/or its affiliates. + Copyright (c) 2010, 2016, MariaDB 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 @@ -255,6 +255,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, { DBUG_RETURN(TRUE); } + thd_proc_info(thd, "executing"); /* Let us emit an error if we are loading data to table which is used in subselect in SET clause like we do it for INSERT. diff --git a/sql/sql_locale.cc b/sql/sql_locale.cc index d918d5c9cf4..8dc71452fa4 100644 --- a/sql/sql_locale.cc +++ b/sql/sql_locale.cc @@ -427,7 +427,7 @@ MY_LOCALE my_locale_da_DK /***** LOCALE BEGIN de_AT: German - Austria *****/ static const char *my_locale_month_names_de_AT[13] = - {"Jänner","Feber","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember", NullS }; + {"Jänner","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember", NullS }; static const char *my_locale_ab_month_names_de_AT[13] = {"Jän","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez", NullS }; static const char *my_locale_day_names_de_AT[8] = diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e8c80fed47c..581a8212668 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4819,21 +4819,10 @@ end_with_restore_list: case SQLCOM_SHOW_GRANTS: { LEX_USER *grant_user= lex->grant_user; - Security_context *sctx= thd->security_ctx; if (!grant_user) goto error; - if (grant_user->user.str && !strcmp(sctx->priv_user, grant_user->user.str) && - grant_user->host.str && !strcmp(sctx->priv_host, grant_user->host.str)) - grant_user->user= current_user; - - if (grant_user->user.str == current_user.str || - grant_user->user.str == current_role.str || - grant_user->user.str == current_user_and_current_role.str || - !check_access(thd, SELECT_ACL, "mysql", NULL, NULL, 1, 0)) - { - res = mysql_show_grants(thd, grant_user); - } + res = mysql_show_grants(thd, grant_user); break; } #endif @@ -6589,6 +6578,7 @@ bool check_global_access(THD *thd, ulong want_access, bool no_errors) temporary table flag) @param alter_info [in] Initial list of columns and indexes for the table to be created + @param create_db [in] Database of the created table @retval false ok. @@ -6597,7 +6587,8 @@ bool check_global_access(THD *thd, ulong want_access, bool no_errors) */ bool check_fk_parent_table_access(THD *thd, HA_CREATE_INFO *create_info, - Alter_info *alter_info) + Alter_info *alter_info, + const char* create_db) { Key *key; List_iterator<Key> key_iterator(alter_info->key_list); @@ -6637,10 +6628,28 @@ bool check_fk_parent_table_access(THD *thd, return true; } } - else if (thd->lex->copy_db_to(&db_name.str, &db_name.length)) - return true; else - is_qualified_table_name= false; + { + if (!thd->db) + { + db_name.str= (char *) thd->memdup(create_db, strlen(create_db)+1); + db_name.length= strlen(create_db); + is_qualified_table_name= true; + + if(create_db && check_db_name(&db_name)) + { + my_error(ER_WRONG_DB_NAME, MYF(0), db_name.str); + return true; + } + } + else + { + if (thd->lex->copy_db_to(&db_name.str, &db_name.length)) + return true; + else + is_qualified_table_name= false; + } + } // if lower_case_table_names is set then convert tablename to lower case. if (lower_case_table_names) @@ -7985,7 +7994,7 @@ bool st_select_lex_unit::add_fake_select_lex(THD *thd_arg) @retval FALSE if all is OK @retval - TRUE if a memory allocation error occured + TRUE if a memory allocation error occurred */ bool @@ -8896,7 +8905,7 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, goto err; } - if (check_fk_parent_table_access(thd, &lex->create_info, &lex->alter_info)) + if (check_fk_parent_table_access(thd, &lex->create_info, &lex->alter_info, create_table->db)) goto err; /* diff --git a/sql/sql_parse.h b/sql/sql_parse.h index 859a1f21202..ff22ec55922 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -48,7 +48,8 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, TABLE_LIST *create_table); bool check_fk_parent_table_access(THD *thd, HA_CREATE_INFO *create_info, - Alter_info *alter_info); + Alter_info *alter_info, + const char* create_db); bool parse_sql(THD *thd, Parser_state *parser_state, Object_creation_ctx *creation_ctx, bool do_pfs_digest=false); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 3df9ebcd6bc..5ff03d19339 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1820,7 +1820,7 @@ static bool mysql_test_create_table(Prepared_statement *stmt) @note This function handles create view commands. @retval FALSE Operation was a success. - @retval TRUE An error occured. + @retval TRUE An error occurred. */ static bool mysql_test_create_view(Prepared_statement *stmt) diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index b7f1528e42c..4ee55b59c11 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -3087,7 +3087,7 @@ int reset_slave(THD *thd, Master_info* mi) char fname[FN_REFLEN]; int thread_mask= 0, error= 0; uint sql_errno=ER_UNKNOWN_ERROR; - const char* errmsg= "Unknown error occured while reseting slave"; + const char* errmsg= "Unknown error occurred while reseting slave"; char master_info_file_tmp[FN_REFLEN]; char relay_log_info_file_tmp[FN_REFLEN]; DBUG_ENTER("reset_slave"); @@ -3669,7 +3669,7 @@ bool mysql_show_binlog_events(THD* thd) DBUG_ASSERT(thd->lex->sql_command == SQLCOM_SHOW_BINLOG_EVENTS || thd->lex->sql_command == SQLCOM_SHOW_RELAYLOG_EVENTS); - /* select wich binary log to use: binlog or relay */ + /* select which binary log to use: binlog or relay */ if ( thd->lex->sql_command == SQLCOM_SHOW_BINLOG_EVENTS ) { /* diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 514ba947172..c2b25d812fb 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2015 Oracle and/or its affiliates. +/* Copyright (c) 2000, 2016 Oracle and/or its affiliates. Copyright (c) 2009, 2016 MariaDB This program is free software; you can redistribute it and/or modify @@ -443,7 +443,7 @@ bool handle_select(THD *thd, LEX *lex, select_result *result, this field from inner subqueries. @return Status - @retval true An error occured. + @retval true An error occurred. @retval false OK. */ @@ -12702,7 +12702,7 @@ static bool check_equality(THD *thd, Item *item, COND_EQUAL *cond_equal, equality predicates that is equivalent to the conjunction. Thus, =(a1,a2,a3) can substitute for ((a1=a3) AND (a2=a3) AND (a2=a1)) as it is equivalent to ((a1=a2) AND (a2=a3)). - The function always makes a substitution of all equality predicates occured + The function always makes a substitution of all equality predicates occurred in a conjuction for a minimal set of multiple equality predicates. This set can be considered as a canonical representation of the sub-conjunction of the equality predicates. @@ -15437,6 +15437,14 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, Field *new_field; LINT_INIT(new_field); + /* + To preserve type or DATE/TIME and GEOMETRY fields, + they need to be handled separately. + */ + if (item->cmp_type() == TIME_RESULT || + item->field_type() == MYSQL_TYPE_GEOMETRY) + new_field= item->tmp_table_field_from_field_type(table, 1); + else switch (item->result_type()) { case REAL_RESULT: new_field= new Field_double(item->max_length, maybe_null, @@ -15459,18 +15467,11 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, case STRING_RESULT: DBUG_ASSERT(item->collation.collation); - /* - DATE/TIME and GEOMETRY fields have STRING_RESULT result type. - To preserve type they needed to be handled separately. - */ - if (item->cmp_type() == TIME_RESULT || - item->field_type() == MYSQL_TYPE_GEOMETRY) - new_field= item->tmp_table_field_from_field_type(table, 1); /* Make sure that the blob fits into a Field_varstring which has 2-byte lenght. */ - else if (item->max_length/item->collation.collation->mbmaxlen > 255 && + if (item->max_length/item->collation.collation->mbmaxlen > 255 && convert_blob_length <= Field_varstring::MAX_SIZE && convert_blob_length) new_field= new Field_varstring(convert_blob_length, maybe_null, @@ -21380,7 +21381,7 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, select_item= find_item_in_list(order_item, fields, &counter, REPORT_EXCEPT_NOT_FOUND, &resolution); if (!select_item) - return TRUE; /* The item is not unique, or some other error occured. */ + return TRUE; /* The item is not unique, or some other error occurred. */ /* Check whether the resolved field is not ambiguos. */ @@ -24182,33 +24183,53 @@ static void print_join(THD *thd, /* List is reversed => we should reverse it before using */ List_iterator_fast<TABLE_LIST> ti(*tables); TABLE_LIST **table; - uint non_const_tables= 0; DBUG_ENTER("print_join"); + /* + If the QT_NO_DATA_EXPANSION flag is specified, we print the + original table list, including constant tables that have been + optimized away, as the constant tables may be referenced in the + expression printed by Item_field::print() when this flag is given. + Otherwise, only non-const tables are printed. + + Example: + + Original SQL: + select * from (select 1) t + + Printed without QT_NO_DATA_EXPANSION: + select '1' AS `1` from dual + + Printed with QT_NO_DATA_EXPANSION: + select `t`.`1` from (select 1 AS `1`) `t` + */ + const bool print_const_tables= (query_type & QT_NO_DATA_EXPANSION); + size_t tables_to_print= 0; + for (TABLE_LIST *t= ti++; t ; t= ti++) { - /* - See comment in print_table_array() about the second part of the - condition - */ - if (!t->optimized_away && !is_eliminated_table(eliminated_tables, t)) - non_const_tables++; + /* See comment in print_table_array() about the second condition */ + if (print_const_tables || !t->optimized_away) + if (!is_eliminated_table(eliminated_tables, t)) + tables_to_print++; } - if (!non_const_tables) + if (tables_to_print == 0) { str->append(STRING_WITH_LEN("dual")); DBUG_VOID_RETURN; // all tables were optimized away } ti.rewind(); - if (!(table= (TABLE_LIST **)thd->alloc(sizeof(TABLE_LIST*) * - non_const_tables))) + if (!(table= static_cast<TABLE_LIST **>(thd->alloc(sizeof(TABLE_LIST*) * + tables_to_print)))) DBUG_VOID_RETURN; // out of memory - TABLE_LIST *tmp, **t= table + (non_const_tables - 1); + TABLE_LIST *tmp, **t= table + (tables_to_print - 1); while ((tmp= ti++)) { - if (tmp->optimized_away || is_eliminated_table(eliminated_tables, tmp)) + if (tmp->optimized_away && !print_const_tables) + continue; + if (is_eliminated_table(eliminated_tables, tmp)) continue; *t--= tmp; } @@ -24228,7 +24249,7 @@ static void print_join(THD *thd, */ if ((*table)->sj_inner_tables) { - TABLE_LIST **end= table + non_const_tables; + TABLE_LIST **end= table + tables_to_print; for (TABLE_LIST **t2= table; t2!=end; t2++) { if (!(*t2)->sj_inner_tables) @@ -24241,7 +24262,7 @@ static void print_join(THD *thd, } } print_table_array(thd, eliminated_tables, str, table, - table + non_const_tables, query_type); + table + tables_to_print, query_type); DBUG_VOID_RETURN; } @@ -24651,7 +24672,7 @@ void JOIN::save_query_plan(Join_plan_state *save_to) } memcpy((uchar*) save_to->best_positions, (uchar*) best_positions, sizeof(POSITION) * (table_count + 1)); - memset(best_positions, 0, sizeof(POSITION) * (table_count + 1)); + memset((uchar*) best_positions, 0, sizeof(POSITION) * (table_count + 1)); /* Save SJM nests */ List_iterator<TABLE_LIST> it(select_lex->sj_nests); @@ -24736,7 +24757,7 @@ void JOIN::restore_query_plan(Join_plan_state *restore_from) @retval REOPT_NEW_PLAN there is a new plan. @retval REOPT_OLD_PLAN no new improved plan was produced, use the old one. - @retval REOPT_ERROR an irrecovarable error occured during reoptimization. + @retval REOPT_ERROR an irrecovarable error occurred during reoptimization. */ JOIN::enum_reopt_result diff --git a/sql/sql_select.h b/sql/sql_select.h index 18a649bc47a..cbad287c5e5 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -908,7 +908,7 @@ protected: enum enum_reopt_result { REOPT_NEW_PLAN, /* there is a new reoptimized plan */ REOPT_OLD_PLAN, /* no new improved plan can be found, use the old one */ - REOPT_ERROR, /* an irrecovarable error occured during reoptimization */ + REOPT_ERROR, /* an irrecovarable error occurred during reoptimization */ REOPT_NONE /* not yet reoptimized */ }; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index aef73ccf205..c05af629583 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -4500,7 +4500,7 @@ uint get_table_open_method(TABLE_LIST *tables, @retval FALSE No error, if lock was obtained TABLE_LIST::mdl_request::ticket is set to non-NULL value. - @retval TRUE Some error occured (probably thread was killed). + @retval TRUE Some error occurred (probably thread was killed). */ static bool @@ -4608,7 +4608,7 @@ static int fill_schema_table_from_frm(THD *thd, TABLE_LIST *tables, if (try_acquire_high_prio_shared_mdl_lock(thd, &table_list, can_deadlock)) { /* - Some error occured (most probably we have been killed while + Some error occurred (most probably we have been killed while waiting for conflicting locks to go away), let the caller to handle the situation. */ diff --git a/sql/sql_string.cc b/sql/sql_string.cc index a7bfa6c1455..b94bd6a0175 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -76,9 +76,9 @@ bool String::real_alloc(uint32 length) @retval false Either the copy operation is complete or, if the size of the new buffer is smaller than the currently allocated buffer (if one exists), - no allocation occured. + no allocation occurred. - @retval true An error occured when attempting to allocate memory. + @retval true An error occurred when attempting to allocate memory. */ bool String::realloc_raw(uint32 alloc_length) { diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f19b4e4cb8d..00d1155f923 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2015, Oracle and/or its affiliates. + Copyright (c) 2000, 2016, Oracle and/or its affiliates. Copyright (c) 2010, 2016, MariaDB This program is free software; you can redistribute it and/or modify @@ -5477,6 +5477,9 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, /* We have to write the query before we unlock the tables. */ + if (thd->is_current_stmt_binlog_disabled()) + goto err; + if (thd->is_current_stmt_binlog_format_row()) { /* @@ -5547,6 +5550,21 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, */ if (!table->view) { + /* + After opening a MERGE table add the children to the query list of + tables, so that children tables info can be used on "CREATE TABLE" + statement generation by the binary log. + Note that placeholders don't have the handler open. + */ + if (table->table->file->extra(HA_EXTRA_ADD_CHILDREN_LIST)) + goto err; + + /* + As the reference table is temporary and may not exist on slave, we must + force the ENGINE to be present into CREATE TABLE. + */ + create_info->used_fields|= HA_CREATE_USED_ENGINE; + int result __attribute__((unused))= show_create_table(thd, table, &query, create_info, WITH_DB_NAME); @@ -8519,7 +8537,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, till this point for the alter operation. */ if ((alter_info->flags & Alter_info::ADD_FOREIGN_KEY) && - check_fk_parent_table_access(thd, create_info, alter_info)) + check_fk_parent_table_access(thd, create_info, alter_info, new_db)) DBUG_RETURN(true); /* diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index a2b5f9a68c9..fec90d7ddf3 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -2238,7 +2238,7 @@ void Table_triggers_list::mark_fields_used(trg_event_type event) /** - Signals to the Table_triggers_list that a parse error has occured when + Signals to the Table_triggers_list that a parse error has occurred when reading a trigger from file. This makes the Table_triggers_list enter an error state flagged by m_has_unparseable_trigger == true. The error message will be used whenever a statement invoking or manipulating triggers is diff --git a/sql/sql_update.cc b/sql/sql_update.cc index c07f492a485..f9d95b9dbab 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2011, 2015, MariaDB +/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. + Copyright (c) 2011, 2016, MariaDB 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 @@ -823,7 +823,7 @@ int mysql_update(THD *thd, error= 0; } else if (!ignore || - table->file->is_fatal_error(error, HA_CHECK_DUP_KEY)) + table->file->is_fatal_error(error, HA_CHECK_ALL)) { /* If (ignore && error is ignorable) we don't have to @@ -831,7 +831,7 @@ int mysql_update(THD *thd, */ myf flags= 0; - if (table->file->is_fatal_error(error, HA_CHECK_DUP_KEY)) + if (table->file->is_fatal_error(error, HA_CHECK_ALL)) flags|= ME_FATALERROR; /* Other handler errors are fatal */ prepare_record_for_error_message(error, table); @@ -2135,7 +2135,7 @@ int multi_update::send_data(List<Item> ¬_used_values) { updated--; if (!ignore || - table->file->is_fatal_error(error, HA_CHECK_DUP_KEY)) + table->file->is_fatal_error(error, HA_CHECK_ALL)) { /* If (ignore && error == is ignorable) we don't have to @@ -2143,7 +2143,7 @@ int multi_update::send_data(List<Item> ¬_used_values) */ myf flags= 0; - if (table->file->is_fatal_error(error, HA_CHECK_DUP_KEY)) + if (table->file->is_fatal_error(error, HA_CHECK_ALL)) flags|= ME_FATALERROR; /* Other handler errors are fatal */ prepare_record_for_error_message(error, table); @@ -2422,7 +2422,7 @@ int multi_update::do_updates() local_error != HA_ERR_RECORD_IS_THE_SAME) { if (!ignore || - table->file->is_fatal_error(local_error, HA_CHECK_DUP_KEY)) + table->file->is_fatal_error(local_error, HA_CHECK_ALL)) { err_table= table; goto err; @@ -2564,7 +2564,7 @@ bool multi_update::send_eof() if (local_error > 0) // if the above log write did not fail ... { /* Safety: If we haven't got an error before (can happen in do_updates) */ - my_message(ER_UNKNOWN_ERROR, "An error occured in multi-table update", + my_message(ER_UNKNOWN_ERROR, "An error occurred in multi-table update", MYF(0)); DBUG_RETURN(TRUE); } diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 0d88b3a1eda..f3717e3ded2 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -245,7 +245,7 @@ fill_defined_view_parts (THD *thd, TABLE_LIST *view) @param mode VIEW_CREATE_NEW, VIEW_ALTER, VIEW_CREATE_OR_REPLACE @retval FALSE Operation was a success. - @retval TRUE An error occured. + @retval TRUE An error occurred. */ bool create_view_precheck(THD *thd, TABLE_LIST *tables, TABLE_LIST *view, @@ -388,7 +388,7 @@ bool create_view_precheck(THD *thd, TABLE_LIST *tables, TABLE_LIST *view, @note This function handles both create and alter view commands. @retval FALSE Operation was a success. - @retval TRUE An error occured. + @retval TRUE An error occurred. */ bool mysql_create_view(THD *thd, TABLE_LIST *views, diff --git a/sql/sys_vars.h b/sql/sys_vars.h index 36067c50cc1..79b67d3b45c 100644 --- a/sql/sys_vars.h +++ b/sql/sys_vars.h @@ -30,6 +30,7 @@ #include "strfunc.h" #include "tztime.h" // my_tz_find, my_tz_SYSTEM, struct Time_zone #include "rpl_mi.h" // For Multi-Source Replication +#include "debug_sync.h" /* a set of mostly trivial (as in f(X)=X) defines below to make system variable @@ -1455,7 +1456,6 @@ public: } bool session_update(THD *thd, set_var *var) { - extern bool debug_sync_update(THD *thd, char *val_str); return debug_sync_update(thd, var->save_result.string_value.str); } bool global_update(THD *thd, set_var *var) diff --git a/sql/threadpool_win.cc b/sql/threadpool_win.cc index 4be51f3d6e9..8ae3252caa3 100644 --- a/sql/threadpool_win.cc +++ b/sql/threadpool_win.cc @@ -388,7 +388,7 @@ int start_io(connection_t *connection, PTP_CALLBACK_INSTANCE instance) return 0; } - /* Some error occured */ + /* Some error occurred */ CancelThreadpoolIo(io); return -1; } @@ -575,7 +575,7 @@ static VOID CALLBACK io_completion_callback(PTP_CALLBACK_INSTANCE instance, return; error: - /* Some error has occured. */ + /* Some error has occurred. */ destroy_connection(connection, instance); free(connection); diff --git a/sql/tztime.cc b/sql/tztime.cc index bea1d9c5d28..d4321604a7a 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -309,7 +309,7 @@ tz_load(const char *name, TIME_ZONE_INFO *sp, MEM_ROOT *storage) Note: See description of TIME_to_gmt_sec() function first. In order to perform MYSQL_TIME -> my_time_t conversion we need to build table which defines "shifted by tz offset and leap seconds my_time_t" -> - my_time_t function wich is almost the same (except ranges of ambiguity) + my_time_t function which is almost the same (except ranges of ambiguity) as reverse function to piecewise linear function used for my_time_t -> "shifted my_time_t" conversion and which is also specified as table in zoneinfo file or in our db (It is specified as start of time type ranges @@ -614,7 +614,7 @@ sec_to_TIME(MYSQL_TIME * tmp, my_time_t t, long offset) /* - Find time range wich contains given my_time_t value + Find time range which contains given my_time_t value SYNOPSIS find_time_range() @@ -710,7 +710,7 @@ find_transition_type(my_time_t t, const TIME_ZONE_INFO *sp) TODO We can improve this function by creating joined array of transitions and leap corrections. This will require adding extra field to TRAN_TYPE_INFO - for storing number of "extra" seconds to minute occured due to correction + for storing number of "extra" seconds to minute occurred due to correction (60th and 61st second, look how we calculate them as "hit" in this function). Under realistic assumptions about frequency of transitions the same array @@ -2774,7 +2774,7 @@ main(int argc, char **argv) #ifdef TESTTIME /* - Some simple brute-force test wich allowed to catch a pair of bugs. + Some simple brute-force test which allowed to catch a pair of bugs. Also can provide interesting facts about system's time zone support implementation. */ diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index c1acef4596f..00f3adb07ee 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -56,7 +56,7 @@ meta file is first opened it is marked as dirty. It is opened when the table itself is opened for writing. When the table is closed the new count for rows is written to the meta file and the file is marked as clean. If the meta file - is opened and it is marked as dirty, it is assumed that a crash occured. At + is opened and it is marked as dirty, it is assumed that a crash occurred. At this point an error occurs and the user is told to rebuild the file. A rebuild scans the rows and rewrites the meta file. If corruption is found in the data file then the meta file is not repaired. diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index 7ff2ca7753c..6ef8b45daf9 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -45,6 +45,7 @@ add_definitions( -DHUGE_SUPPORT -DZIP_SUPPORT -DPIVOT_SUPPORT ) # OS specific C flags, definitions and source files. # IF(UNIX) + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") # Bar: -Wfatal-errors removed (does not present in gcc on solaris10) if(WITH_WARNINGS) add_definitions(-Wall -Wextra -Wmissing-declarations) @@ -71,6 +72,7 @@ IF(UNIX) #message(STATUS "CONNECT: GCC: Some warnings disabled") endif(WITH_WARNINGS) + endif() add_definitions( -DUNIX -DLINUX -DUBUNTU ) @@ -126,37 +128,10 @@ IF(WIN32) OPTION(CONNECT_WITH_MSXML "Compile CONNECT storage engine with MSXML support" ON) IF(CONNECT_WITH_MSXML) - find_library(MSXML_LIBRARY - NAMES msxml6 msxml4 msxml3 msxml2 - PATHS - "C:/Program Files/Microsoft SDKs/Windows/v7.0A/Lib" - "C:/Program Files/Microsoft SDKs/Windows/v6.0A/Lib" - "C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib" - DOC "Specify the MSXML? library here." - ) - IF(MSXML_LIBRARY MATCHES .*msxml6[.].*) - add_definitions(-DMSX6 -DDOMDOC_SUPPORT) - message(STATUS "MSXML library version: msxml6") - SET(MSXML_FOUND 1) - SET(CONNECT_SOURCES ${CONNECT_SOURCES} domdoc.cpp domdoc.h) - ELSEIF(MSXML_LIBRARY MATCHES .*msxml4[.].*) - add_definitions(-DMSX4 -DDOMDOC_SUPPORT) - message("MSXML library version: msxml4") - SET(MSXML_FOUND 1) - SET(CONNECT_SOURCES ${CONNECT_SOURCES} domdoc.cpp domdoc.h) - ELSEIF(MSXML_LIBRARY MATCHES .*msxml3[.].*) - message("MSXML library version: msxml3") - add_definitions(-DMSX3 -DDOMDOC_SUPPORT) - SET(MSXML_FOUND 1) - SET(CONNECT_SOURCES ${CONNECT_SOURCES} domdoc.cpp domdoc.h) - ELSEIF(MSXML_LIBRARY MATCHES .*msxml2[.].*) - message("MSXML library version: msxml2") - add_definitions(-DMXS2 -DDOMDOC_SUPPORT) - SET(MSXML_FOUND 1) - SET(CONNECT_SOURCES ${CONNECT_SOURCES} domdoc.cpp domdoc.h) - ELSE() - message(STATUS "msxml? library not found") - ENDIF() + add_definitions(-DMSX6 -DDOMDOC_SUPPORT) + message(STATUS "MSXML library version: msxml6") + SET(MSXML_FOUND 1) + SET(CONNECT_SOURCES ${CONNECT_SOURCES} domdoc.cpp domdoc.h) ENDIF(CONNECT_WITH_MSXML) ENDIF(WIN32) diff --git a/storage/connect/catalog.h b/storage/connect/catalog.h index 6488b513ba9..5fa38277832 100644 --- a/storage/connect/catalog.h +++ b/storage/connect/catalog.h @@ -77,8 +77,8 @@ class DllExport CATALOG { virtual bool ClearName(PGLOBAL, PSZ) {return true;} virtual PRELDEF MakeOneTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;} virtual PRELDEF GetTableDescEx(PGLOBAL, PTABLE) {return NULL;} - virtual PRELDEF GetTableDesc(PGLOBAL, LPCSTR, LPCSTR, - PRELDEF* = NULL) {return NULL;} + /*virtual PRELDEF GetTableDesc(PGLOBAL, LPCSTR, LPCSTR, + PRELDEF* = NULL) {return NULL;}*/ virtual PRELDEF GetFirstTable(PGLOBAL) {return NULL;} virtual PRELDEF GetNextTable(PGLOBAL) {return NULL;} virtual bool TestCond(PGLOBAL, const char*, const char*) {return true;} @@ -95,7 +95,7 @@ class DllExport CATALOG { protected: virtual bool ClearSection(PGLOBAL, const char*, const char*) {return true;} - virtual PRELDEF MakeTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;} + /*virtual PRELDEF MakeTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;}*/ // Members char *Cbuf; /* Buffer used for col section */ diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index 56a0fc4fd4f..460d47bcf62 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -752,7 +752,7 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op, return RC_FX; } else if (x == 2) { // Remote index - if (ptdb->ReadKey(g, op, kr)) + if (op != OP_SAME && ptdb->ReadKey(g, op, kr)) return RC_FX; goto rnd; diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 645d0003c47..e8aa54fc87c 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -169,9 +169,9 @@ #define JSONMAX 10 // JSON Default max grp size extern "C" { - char version[]= "Version 1.04.0005 January 24, 2016"; + char version[]= "Version 1.04.0006 March 12, 2016"; #if defined(__WIN__) - char compver[]= "Version 1.04.0005 " __DATE__ " " __TIME__; + char compver[]= "Version 1.04.0006 " __DATE__ " " __TIME__; char slash= '\\'; #else // !__WIN__ char slash= '/'; @@ -757,7 +757,7 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg) sdvalout= NULL; xmod= MODE_ANY; istable= false; - *partname= 0; + memset(partname, 0, sizeof(partname)); bzero((char*) &xinfo, sizeof(XINFO)); valid_info= false; valid_query_id= 0; @@ -1150,7 +1150,7 @@ char *ha_connect::GetRealString(const char *s) { char *sv; - if (IsPartitioned() && s) { + if (IsPartitioned() && s && partname && *partname) { sv= (char*)PlugSubAlloc(xp->g, NULL, 0); sprintf(sv, s, partname); PlugSubAlloc(xp->g, NULL, strlen(sv) + 1); @@ -1173,7 +1173,9 @@ char *ha_connect::GetStringOption(char *opname, char *sdef) : table->s->connect_string; if (cnc.length) - opval= GetRealString(strz(xp->g, cnc)); + opval= strz(xp->g, cnc); + else + opval= GetListOption(xp->g, opname, options->oplist); } else if (!stricmp(opname, "Query_String")) opval= thd_query_string(table->in_use)->str; @@ -2286,7 +2288,7 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL vop, char q, op= OP_EQ; break; case HA_READ_AFTER_KEY: - op= (stlen >= len) ? (!i ? OP_GT : OP_LE) : OP_GE; + op= (stlen >= len || i > 0) ? (i > 0 ? OP_LE : OP_GT) : OP_GE; break; case HA_READ_KEY_OR_NEXT: op= OP_GE; @@ -3121,13 +3123,14 @@ int ha_connect::open(const char *name, int mode, uint test_if_locked) #if defined(WITH_PARTITION_STORAGE_ENGINE) if (table->part_info) { if (GetStringOption("Filename") || GetStringOption("Tabname") - || GetStringOption("Connect")) { - strcpy(partname, decode(g, strrchr(name, '#') + 1)); + || GetStringOption("Connect")) { + strncpy(partname, decode(g, strrchr(name, '#') + 1), sizeof(partname) - 1); // strcpy(partname, table->part_info->curr_part_elem->partition_name); - part_id= &table->part_info->full_part_field_set; +// part_id= &table->part_info->full_part_field_set; } else // Inward table - strcpy(partname, strrchr(name, slash) + 1); - part_id= &table->part_info->full_part_field_set; // Temporary + strncpy(partname, strrchr(name, slash) + 1, sizeof(partname) - 1); + + part_id= &table->part_info->full_part_field_set; // Temporary } // endif part_info #endif // WITH_PARTITION_STORAGE_ENGINE } else @@ -4054,7 +4057,7 @@ int ha_connect::delete_all_rows() } // end of delete_all_rows -bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn) +bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn, bool quick) { const char *db= (dbn && *dbn) ? dbn : NULL; TABTYPE type=GetRealType(options); @@ -4081,6 +4084,7 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn) case TAB_VEC: case TAB_JSON: if (options->filename && *options->filename) { + if (!quick) { char *s, path[FN_REFLEN], dbpath[FN_REFLEN]; #if defined(__WIN__) s= "\\"; @@ -4099,7 +4103,7 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn) my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv"); return true; } // endif path - + } } else return false; @@ -4121,10 +4125,13 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn) Otherwise it's a DML, the table was normally opened, locked, privilege were already checked, and table->grant.privilege is set. With SQL SECURITY DEFINER, table->grant.privilege has definer's privileges. + + Unless we're in prelocking mode, in this case table->grant.privilege + is only checked in start_stmt(), not in external_lock(). */ if (!table || !table->mdl_ticket || table->mdl_ticket->get_type() == MDL_EXCLUSIVE) return check_access(thd, FILE_ACL, db, NULL, NULL, 0, 0); - if (table->grant.privilege & FILE_ACL) + if ((!quick && thd->lex->requires_prelocking()) || table->grant.privilege & FILE_ACL) return false; status_var_increment(thd->status_var.access_denied_errors); my_error(access_denied_error_code(thd->password), MYF(0), @@ -4308,6 +4315,9 @@ int ha_connect::start_stmt(THD *thd, thr_lock_type lock_type) PGLOBAL g= GetPlug(thd, xp); DBUG_ENTER("ha_connect::start_stmt"); + if (check_privileges(thd, GetTableOptionStruct(), table->s->db.str, true)) + DBUG_RETURN(HA_ERR_INTERNAL_ERROR); + // Action will depend on lock_type switch (lock_type) { case TL_WRITE_ALLOW_WRITE: @@ -5160,7 +5170,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd, fncn= topt->catfunc; fnc= GetFuncID(fncn); sep= topt->separator; - spc= (!sep) ? ',' : (!strcmp(sep, "\\t")) ? '\t' : *sep; + spc= (!sep) ? ',' : *sep; qch= topt->qchar ? *topt->qchar : (signed)topt->quoted >= 0 ? '"' : 0; hdr= (int)topt->header; tbl= topt->tablist; @@ -5227,7 +5237,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd, goto err; } // endif rc - if (!tab) { if (ttp == TAB_TBL) { // Make tab the first table of the list @@ -5296,8 +5305,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd, case TAB_CSV: if (!fn && fnc != FNC_NO) sprintf(g->Message, "Missing %s file name", topt->type); - else - ok= true; + else if (sep && strlen(sep) > 1) + sprintf(g->Message, "Invalid separator %s", sep); + else + ok= true; break; case TAB_MYSQL: @@ -5978,7 +5989,19 @@ int ha_connect::create(const char *name, TABLE *table_arg, DBUG_RETURN(rc); } // endif lrecl - } // endif type + } // endif type JSON + + if (type == TAB_CSV) { + const char *sep = options->separator; + + if (sep && strlen(sep) > 1) { + sprintf(g->Message, "Invalid separator %s", sep); + my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); + rc= HA_ERR_INTERNAL_ERROR; + DBUG_RETURN(rc); + } // endif sep + + } // endif type CSV // Check column types for (field= table_arg->field; *field; field++) { @@ -6129,7 +6152,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, strcpy(dbpath, name); p= strrchr(dbpath, slash); - strcpy(partname, ++p); + strncpy(partname, ++p, sizeof(partname) - 1); strcat(strcat(strcpy(buf, p), "."), lwt); *p= 0; } else { @@ -6180,7 +6203,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, #if defined(WITH_PARTITION_STORAGE_ENGINE) if (part_info && !inward) - strcpy(partname, decode(g, strrchr(name, '#') + 1)); + strncpy(partname, decode(g, strrchr(name, '#') + 1), sizeof(partname) - 1); // strcpy(partname, part_info->curr_part_elem->partition_name); #endif // WITH_PARTITION_STORAGE_ENGINE @@ -6221,8 +6244,9 @@ int ha_connect::create(const char *name, TABLE *table_arg, #if defined(WITH_PARTITION_STORAGE_ENGINE) if (part_info) - strcpy(partname, - decode(g, strrchr(name, (inward ? slash : '#')) + 1)); + strncpy(partname, + decode(g, strrchr(name, (inward ? slash : '#')) + 1), + sizeof(partname) - 1); #endif // WITH_PARTITION_STORAGE_ENGINE if ((rc= optimize(table->in_use, NULL))) { @@ -6766,7 +6790,7 @@ maria_declare_plugin(connect) 0x0104, /* version number (1.04) */ NULL, /* status variables */ connect_system_variables, /* system variables */ - "1.04.0005", /* string version */ + "1.04.0006", /* string version */ MariaDB_PLUGIN_MATURITY_BETA /* maturity */ } maria_declare_plugin_end; diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h index 05cc872fa2a..60194ac0e3c 100644 --- a/storage/connect/ha_connect.h +++ b/storage/connect/ha_connect.h @@ -536,7 +536,7 @@ private: DsMrr_impl ds_mrr; protected: - bool check_privileges(THD *thd, PTOS options, char *dbn); + bool check_privileges(THD *thd, PTOS options, char *dbn, bool quick=false); MODE CheckMode(PGLOBAL g, THD *thd, MODE newmode, bool *chk, bool *cras); char *GetDBfromName(const char *name); @@ -554,7 +554,7 @@ protected: PVAL sdvalin4; // Used to convert date values PVAL sdvalout; // Used to convert date values bool istable; // True for table handler - char partname[64]; // The partition name + char partname[65]; // The partition name MODE xmod; // Table mode XINFO xinfo; // The table info structure bool valid_info; // True if xinfo is valid diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index 25c77cea534..7b82ba2d627 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -533,7 +533,7 @@ PVAL JSNX::CalculateArray(PGLOBAL g, PJAR arp, int n) /*********************************************************************************/ my_bool JSNX::CheckPath(PGLOBAL g) { - PJVAL val; + PJVAL val= NULL; PJSON row = Row; for (int i = 0; i < Nod && row; i++) { @@ -1302,7 +1302,7 @@ static my_bool CalcLen(UDF_ARGS *args, my_bool obj, { char fn[_MAX_PATH]; unsigned long i, k, m, n; - long fl, j = -1; + long fl= 0, j = -1; reslen = args->arg_count + 2; @@ -2087,7 +2087,7 @@ my_bool json_object_nonull_init(UDF_INIT *initid, UDF_ARGS *args, char *json_object_nonull(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *res_length, char *, char *) { - char *str; + char *str= 0; PGLOBAL g = (PGLOBAL)initid->ptr; if (!g->Xchk) { @@ -2621,7 +2621,7 @@ char *json_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result, } // endif Xchk if (!CheckMemory(g, initid, args, 2, false, false, true)) { - PJSON top; + PJSON top= 0; PJVAL jvp; PJSON jsp[2] = {NULL, NULL}; @@ -4721,7 +4721,7 @@ char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result, my_bool b = true; PJSON jsp; PJSNX jsx; - PJVAL jvp; + PJVAL jvp= 0; PBSON bsp = NULL; PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL gb = GetMemPtr(g, args, 0); @@ -4742,6 +4742,7 @@ char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result, if (!g->Xchk) { if (CheckMemory(g, initid, args, 1, true, false, true)) { PUSH_WARNING("CheckMemory error"); + goto fin; } else jvp = MakeValue(g, args, 0); diff --git a/storage/connect/maputil.cpp b/storage/connect/maputil.cpp index c4e016f1511..87263b3adf6 100644 --- a/storage/connect/maputil.cpp +++ b/storage/connect/maputil.cpp @@ -190,8 +190,8 @@ bool CloseMemMap(void *memory, size_t dwSize) { if (memory) { // All this must be redesigned - int rc = msync(memory, dwSize, MS_SYNC); - return (munmap(memory, dwSize) < 0) ? true : false; + int rc = msync((char*)memory, dwSize, MS_SYNC); + return (munmap((char*)memory, dwSize) < 0) ? true : false; } else return false; diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index ada0109a820..e9bd64cf8e6 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -959,11 +959,16 @@ void MYSQLC::FreeResult(void) /***********************************************************************/ /* Place the cursor at the beginning of the result set. */ /***********************************************************************/ -void MYSQLC::Rewind(void) +int MYSQLC::Rewind(PGLOBAL g, PSZ sql) { - if (m_Res) - DataSeek(0); + int rc = RC_OK; + if (m_Res) + DataSeek(0); + else if (sql) + rc = ExecSQL(g, sql); + + return rc; } // end of Rewind /***********************************************************************/ diff --git a/storage/connect/myconn.h b/storage/connect/myconn.h index fa34edd804c..79f095f5c93 100644 --- a/storage/connect/myconn.h +++ b/storage/connect/myconn.h @@ -80,7 +80,7 @@ class DllItem MYSQLC { int Fetch(PGLOBAL g, int pos); char *GetCharField(int i); int GetFieldLength(int i); - void Rewind(void); + int Rewind(PGLOBAL g, PSZ sql); void FreeResult(void); void Close(void); diff --git a/storage/connect/mysql-test/connect/r/grant3.result b/storage/connect/mysql-test/connect/r/grant3.result new file mode 100644 index 00000000000..2f9d37bdb35 --- /dev/null +++ b/storage/connect/mysql-test/connect/r/grant3.result @@ -0,0 +1,5 @@ +create table tcon (i int) engine=Connect table_type=DOS file_name='tcon.dos'; +create table tin (i int); +create trigger tr after insert on tin for each row insert into tcon values (new.i); +insert into tin values (1); +drop table tin,tcon; diff --git a/storage/connect/mysql-test/connect/r/mysql_index.result b/storage/connect/mysql-test/connect/r/mysql_index.result index 4ebf10802ae..dd1864529ca 100644 --- a/storage/connect/mysql-test/connect/r/mysql_index.result +++ b/storage/connect/mysql-test/connect/r/mysql_index.result @@ -112,3 +112,324 @@ id msg 6 Six DROP TABLE t2; DROP TABLE t1; +# +# Make local FIX table with indices matricule and nom/prenom +# +CREATE TABLE t1 +( +matricule INT(4) KEY NOT NULL field_format='Z', +nom VARCHAR(16) NOT NULL, +prenom VARCHAR(20) NOT NULL, +sexe SMALLINT(1) NOT NULL COMMENT 'sexe 1:M 2:F', +aanais INT(4) NOT NULL, +mmnais INT(2) NOT NULL, +ddentree DATE NOT NULL date_format='YYYYMM', +ddnom DATE NOT NULL date_format='YYYYMM', +brut INT(5) NOT NULL, +net DOUBLE(8,2) NOT NULL, +service INT(2) NOT NULL, +sitmat CHAR(1) NOT NULL, +formation CHAR(5) NOT NULL, +INDEX NP(nom,prenom) +) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='emp.txt' ENDING=2; +# +# Make MYSQL table with same indices +# +CREATE TABLE t2 +( +matricule INT(4) KEY NOT NULL, +nom VARCHAR(16) NOT NULL, +prenom VARCHAR(20) NOT NULL, +sexe SMALLINT(1) NOT NULL, +aanais INT(4) NOT NULL, +mmnais INT(2) NOT NULL, +ddentree DATE NOT NULL date_format='YYYYMM', +ddnom DATE NOT NULL date_format='YYYYMM', +brut INT(5) NOT NULL, +net DOUBLE(8,2) NOT NULL, +service INT(2) NOT NULL, +sitmat CHAR(1) NOT NULL, +formation CHAR(5) NOT NULL, +INDEX NP(nom,prenom) +) ENGINE=CONNECT TABLE_TYPE=MYSQL CONNECTIOn='mysql://root@localhost/test/t1'; +SELECT * FROM t2 limit 10; +matricule nom prenom sexe aanais mmnais ddentree ddnom brut net service sitmat formation +5745 ESCOURCHE BENEDICTE 2 1935 7 1962-12-01 1994-05-01 18345 14275.50 0 M TECHN +9692 VICENTE LAURENCE 2 1941 8 1967-10-01 1989-01-01 16212 13032.80 0 M ANGL +9146 NICOLAS ROGER 1 1941 6 1964-07-01 1995-02-01 34173 25098.65 0 M SANS +2985 TESSEREAU MARIE HELENE 2 1941 9 1967-01-01 1990-01-01 19323 14933.78 0 V SANS +3368 MOGADOR ALAIN 1 1941 1 1961-09-01 1993-11-01 43303 31420.55 0 C SANS +7394 CHAUSSEE ERIC DENIS 1 1944 9 1965-11-01 1983-12-01 32002 23583.86 0 M ANGL +4655 MAILLOT GEORGES 1 1945 5 1970-09-01 1986-12-01 24700 18541.64 0 C ANGL +2825 CAMILLE NADINE 2 1956 9 1994-01-01 1993-01-01 19494 15050.45 0 M SANS +1460 BRUYERES JEAN MARC 1 1958 8 1984-08-01 1988-05-01 20902 15980.07 0 M SANS +4974 LONES GERARD 1 1959 10 1979-01-01 1994-12-01 16081 12916.70 0 M SANS +SELECT matricule, nom, prenom FROM t2 WHERE nom IN ('FOCH','MOGADOR'); +matricule nom prenom +1977 FOCH BERNADETTE +5707 FOCH DENIS +2552 FOCH FRANCK +2634 FOCH JOCELYNE +5765 FOCH ROBERT +4080 FOCH SERGE +3368 MOGADOR ALAIN +SELECT matricule, nom, prenom FROM t2 WHERE nom = 'FOCH' OR nom = 'MOGADOR'; +matricule nom prenom +1977 FOCH BERNADETTE +5707 FOCH DENIS +2552 FOCH FRANCK +2634 FOCH JOCELYNE +5765 FOCH ROBERT +4080 FOCH SERGE +3368 MOGADOR ALAIN +SELECT matricule, nom, prenom FROM t2 WHERE nom < 'ADDAX'; +matricule nom prenom +4552 ABBADIE MONIQUE +307 ABBAYE ANNICK +6627 ABBAYE GERALD +7961 ABBE KATIA +1340 ABBE MICHELE +9270 ABBE SOPHIE +2945 ABBEVILLE PASCAL +8596 ABEBERRY PATRICK +6399 ABEILLES RENE +8673 ABEL JEAN PIERRE +6124 ABELIAS DELIA +6314 ABERDEN EVELYNE +895 ABORD CHANTAL +2728 ABOUT CATHERINE MARIE +398 ABREUVOIR JEAN LUC +1122 ACACIAS SERGE +1644 ACARDIE BEATE +115 ACHILLE JACQUES +4038 ADAM JANICK +3395 ADAM JEAN CLAUDE +SELECT matricule, nom, prenom FROM t2 WHERE nom <= 'ABEL'; +matricule nom prenom +4552 ABBADIE MONIQUE +307 ABBAYE ANNICK +6627 ABBAYE GERALD +7961 ABBE KATIA +1340 ABBE MICHELE +9270 ABBE SOPHIE +2945 ABBEVILLE PASCAL +8596 ABEBERRY PATRICK +6399 ABEILLES RENE +8673 ABEL JEAN PIERRE +SELECT matricule, nom, prenom FROM t2 WHERE nom > 'YVON'; +matricule nom prenom +9742 YZENGREMER MICHEL +8738 ZILINA JEAN LOUIS +5357 ZOLA BERNARD +5441 ZOLA BRIGITTE +1325 ZOLA CHRISTINE +4859 ZORI CATHERINE +4102 ZOUAVES ALAIN +SELECT matricule, nom, prenom FROM t2 WHERE nom >= 'YVON'; +matricule nom prenom +5389 YVON CAROLE +9742 YZENGREMER MICHEL +8738 ZILINA JEAN LOUIS +5357 ZOLA BERNARD +5441 ZOLA BRIGITTE +1325 ZOLA CHRISTINE +4859 ZORI CATHERINE +4102 ZOUAVES ALAIN +SELECT matricule, nom, prenom FROM t2 WHERE nom <= 'ABEL' OR nom > 'YVON'; +matricule nom prenom +4552 ABBADIE MONIQUE +307 ABBAYE ANNICK +6627 ABBAYE GERALD +7961 ABBE KATIA +1340 ABBE MICHELE +9270 ABBE SOPHIE +2945 ABBEVILLE PASCAL +8596 ABEBERRY PATRICK +6399 ABEILLES RENE +8673 ABEL JEAN PIERRE +9742 YZENGREMER MICHEL +8738 ZILINA JEAN LOUIS +5357 ZOLA BERNARD +5441 ZOLA BRIGITTE +1325 ZOLA CHRISTINE +4859 ZORI CATHERINE +4102 ZOUAVES ALAIN +SELECT matricule, nom, prenom FROM t2 WHERE nom > 'HELEN' AND nom < 'HEROS'; +matricule nom prenom +9096 HELENA PHILIPPE +3309 HELENE ISABELLE +8365 HELIOTROPES LISE +4666 HELLEN PIERRE +5781 HELSINKI DANIELLE +7626 HENIN PHILIPPE +4254 HENIN SERGE +2673 HENNER LILIANE +9716 HENRI JACQUES +2085 HEOL GUY PAUL +2579 HERANDIERE PIERRE +7093 HERAULTS DANIEL +4050 HERBILLON FRANCOIS +9231 HERBILLON MADELEINE +1291 HERMITAGE XAVIER +6185 HERMITTE FRANCOIS +403 HERMITTE PHILIPPE +9749 HEROLD ISABELLE +SELECT matricule, nom, prenom FROM t2 WHERE nom BETWEEN 'HELEN' AND 'HEROS'; +matricule nom prenom +6199 HELEN MARTIAL +9096 HELENA PHILIPPE +3309 HELENE ISABELLE +8365 HELIOTROPES LISE +4666 HELLEN PIERRE +5781 HELSINKI DANIELLE +7626 HENIN PHILIPPE +4254 HENIN SERGE +2673 HENNER LILIANE +9716 HENRI JACQUES +2085 HEOL GUY PAUL +2579 HERANDIERE PIERRE +7093 HERAULTS DANIEL +4050 HERBILLON FRANCOIS +9231 HERBILLON MADELEINE +1291 HERMITAGE XAVIER +6185 HERMITTE FRANCOIS +403 HERMITTE PHILIPPE +9749 HEROLD ISABELLE +8445 HEROS SYLVIE +SELECT matricule, nom, prenom FROM t2 WHERE nom BETWEEN 'HELEN' AND 'HEROS' AND prenom = 'PHILIPPE'; +matricule nom prenom +9096 HELENA PHILIPPE +7626 HENIN PHILIPPE +403 HERMITTE PHILIPPE +SELECT matricule, nom, prenom FROM t2 ORDER BY nom LIMIT 10; +matricule nom prenom +4552 ABBADIE MONIQUE +6627 ABBAYE GERALD +307 ABBAYE ANNICK +7961 ABBE KATIA +1340 ABBE MICHELE +9270 ABBE SOPHIE +2945 ABBEVILLE PASCAL +8596 ABEBERRY PATRICK +6399 ABEILLES RENE +8673 ABEL JEAN PIERRE +SELECT a.nom, a.prenom, b.nom FROM t1 a STRAIGHT_JOIN t2 b ON a.prenom = b.prenom WHERE a.nom = 'FOCH' AND a.nom != b.nom; +nom prenom nom +FOCH SERGE ACACIAS +FOCH ROBERT AGRIANT +FOCH JOCELYNE ALEXIS +FOCH DENIS AMBOISE +FOCH SERGE ANDALUCIA +FOCH ROBERT ANNECY +FOCH SERGE ARCACHON +FOCH JOCELYNE AUGUSTE +FOCH JOCELYNE BASSE +FOCH SERGE BEACH +FOCH FRANCK BEARN +FOCH SERGE BELLES +FOCH DENIS BERARD +FOCH DENIS BERIN +FOCH BERNADETTE BERTIN +FOCH DENIS BILLEHOU +FOCH DENIS BOILEAU +FOCH BERNADETTE BOISSY +FOCH ROBERT BONVIN +FOCH SERGE BOUTON +FOCH SERGE BREUIL +FOCH SERGE CARREFOUR +FOCH JOCELYNE CARRERE +FOCH JOCELYNE CHAPELLE +FOCH SERGE CHATEAU +FOCH ROBERT CHENIER +FOCH SERGE COLLETTE +FOCH DENIS CONNE +FOCH SERGE COOLE +FOCH DENIS COULOUBRIER +FOCH DENIS COUTURIER +FOCH ROBERT CURAT +FOCH ROBERT DAUDET +FOCH SERGE ECLUSE +FOCH SERGE EGUILLON +FOCH DENIS EPINETTES +FOCH DENIS FIGOURNAS +FOCH JOCELYNE FLEMING +FOCH JOCELYNE GAMBADES +FOCH ROBERT GIOTERAIE +FOCH SERGE GOAS +FOCH ROBERT GRAFFIANE +FOCH SERGE GREFFIER +FOCH ROBERT GUILLOTIERE +FOCH SERGE HENIN +FOCH BERNADETTE HUNTZIGER +FOCH FRANCK ILLIERS +FOCH DENIS ISTANBUL +FOCH DENIS ITALIE +FOCH SERGE JARDIN +FOCH FRANCK JEANPIERRE +FOCH JOCELYNE KENNEDY +FOCH FRANCK LABBE +FOCH DENIS LACATE +FOCH FRANCK LACOMBE +FOCH ROBERT LAMOTHE +FOCH BERNADETTE LATECOERE +FOCH BERNADETTE LEGER +FOCH SERGE LEONIE +FOCH FRANCK LEROY +FOCH SERGE LOZERE +FOCH DENIS MAROLLES +FOCH ROBERT MARRONIERS +FOCH SERGE MARSAT +FOCH SERGE MONTAGNE +FOCH FRANCK MONTALEIGNE +FOCH DENIS MONTELIER +FOCH DENIS MONTILS +FOCH BERNADETTE MONTJUSTIN +FOCH SERGE MORIZET +FOCH ROBERT NIMES +FOCH ROBERT NORD +FOCH SERGE NOVEMBRE +FOCH BERNADETTE ONZE +FOCH SERGE ORANGERIE +FOCH FRANCK ORVEAU +FOCH BERNADETTE PALMAROLE +FOCH JOCELYNE PEYBERT +FOCH ROBERT PEYNIBLOU +FOCH ROBERT PIECE +FOCH JOCELYNE PIED +FOCH ROBERT PLAGNE +FOCH SERGE PLAISANCE +FOCH BERNADETTE PLOUHARNEL +FOCH DENIS POINTE +FOCH ROBERT POMMERY +FOCH JOCELYNE PONTAROUX +FOCH DENIS PORTO +FOCH ROBERT PRESIDENT +FOCH ROBERT PUJADE +FOCH FRANCK PURPAN +FOCH ROBERT QUILICHINI +FOCH DENIS REINOTS +FOCH DENIS REMPART +FOCH SERGE RESISTANCE +FOCH SERGE RESTANQUES +FOCH ROBERT RIOU +FOCH FRANCK ROCQUENCOURT +FOCH ROBERT ROLL +FOCH ROBERT ROSSA +FOCH SERGE ROSSAYS +FOCH DENIS ROUSSIER +FOCH FRANCK RUSSIE +FOCH ROBERT SABLONS +FOCH SERGE SARTRE +FOCH SERGE SAVIGNAC +FOCH SERGE SEGUR +FOCH ROBERT STRASBOURG +FOCH ROBERT TIRE +FOCH DENIS TORTE +FOCH DENIS TOULON +FOCH ROBERT TUBY +FOCH DENIS VALMANTE +FOCH SERGE VANOEL +FOCH ROBERT VIARMES +FOCH SERGE WILSON +DROP TABLE t2; +DROP TABLE t1; diff --git a/storage/connect/mysql-test/connect/r/part_table.result b/storage/connect/mysql-test/connect/r/part_table.result index 122c328fa59..f3a556ae784 100644 --- a/storage/connect/mysql-test/connect/r/part_table.result +++ b/storage/connect/mysql-test/connect/r/part_table.result @@ -191,6 +191,31 @@ id msg 35 thirty five 81 big DROP TABLE t1; +CREATE TABLE t1 ( +id INT KEY NOT NULL, +msg VARCHAR(32)) +ENGINE=CONNECT TABLE_TYPE=MYSQL +OPTION_LIST='connect=mysql://root@localhost/test/xt%s' +PARTITION BY RANGE COLUMNS(id) ( +PARTITION `1` VALUES LESS THAN(10), +PARTITION `2` VALUES LESS THAN(50), +PARTITION `3` VALUES LESS THAN(MAXVALUE)); +Warnings: +Warning 1105 Data repartition in 1 is unchecked +Warning 1105 Data repartition in 2 is unchecked +Warning 1105 Data repartition in 3 is unchecked +SELECT * FROM t1; +id msg +4 four +7 sept +1 one +8 eight +40 forty +10 ten +11 eleven +35 thirty five +81 big +DROP TABLE t1; DROP TABLE xt1; DROP TABLE xt2; DROP TABLE xt3; diff --git a/storage/connect/mysql-test/connect/r/tbl.result b/storage/connect/mysql-test/connect/r/tbl.result index bc77516c22d..f51b4dfa57f 100644 --- a/storage/connect/mysql-test/connect/r/tbl.result +++ b/storage/connect/mysql-test/connect/r/tbl.result @@ -44,8 +44,8 @@ ta message 1 Testing 2 myisam table 3 t4 -CREATE TABLE total (tabname CHAR(8) NOT NULL SPECIAL='TABID', ta TINYINT NOT NULL FLAG=1, message CHAR(20)) engine=CONNECT table_type=TBL table_list='t1,t2,t3,t4' option_list='port=PORT'; -select * from total; +CREATE TABLE total (tabname CHAR(8) NOT NULL SPECIAL='TABID', ta TINYINT NOT NULL FLAG=1, message CHAR(20)) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2,t3,t4' OPTION_LIST='port=PORT'; +SELECT * FROM total; tabname ta message t1 1 Testing t1 2 dos table @@ -59,15 +59,15 @@ t3 3 t3 t4 1 Testing t4 2 myisam table t4 3 t4 -select * from total where tabname = 't2'; +SELECT * FROM total WHERE tabname = 't2'; tabname ta message t2 1 Testing t2 2 NULL t2 3 t2 -select * from total where tabname = 't2' and ta = 3; +SELECT * FROM total WHERE tabname = 't2' AND ta = 3; tabname ta message t2 3 t2 -select * from total where tabname in ('t1','t4'); +SELECT * FROM total WHERE tabname IN ('t1','t4'); tabname ta message t1 1 Testing t1 2 dos table @@ -75,11 +75,11 @@ t1 3 t1 t4 1 Testing t4 2 myisam table t4 3 t4 -select * from total where ta = 3 and tabname in ('t1','t2'); +SELECT * FROM total WHERE ta = 3 AND tabname IN ('t1','t2'); tabname ta message t1 3 t1 t2 3 t2 -select * from total where tabname <> 't2'; +SELECT * FROM total WHERE tabname <> 't2'; tabname ta message t1 1 Testing t1 2 dos table @@ -90,12 +90,12 @@ t3 3 t3 t4 1 Testing t4 2 myisam table t4 3 t4 -select * from total where tabname != 't2' and ta = 3; +SELECT * FROM total WHERE tabname != 't2' AND ta = 3; tabname ta message t1 3 t1 t3 3 t3 t4 3 t4 -select * from total where tabname not in ('t2','t3'); +SELECT * FROM total WHERE tabname NOT IN ('t2','t3'); tabname ta message t1 1 Testing t1 2 dos table @@ -103,11 +103,11 @@ t1 3 t1 t4 1 Testing t4 2 myisam table t4 3 t4 -select * from total where ta = 3 and tabname in ('t2','t3'); +SELECT * FROM total WHERE ta = 3 AND tabname IN ('t2','t3'); tabname ta message t2 3 t2 t3 3 t3 -select * from total where ta = 3 or tabname in ('t2','t4'); +SELECT * FROM total WHERE ta = 3 OR tabname IN ('t2','t4'); tabname ta message t1 3 t1 t2 1 Testing @@ -117,7 +117,7 @@ t3 3 t3 t4 1 Testing t4 2 myisam table t4 3 t4 -select * from total where not tabname = 't2'; +SELECT * FROM total WHERE NOT tabname = 't2'; tabname ta message t1 1 Testing t1 2 dos table @@ -128,7 +128,7 @@ t3 3 t3 t4 1 Testing t4 2 myisam table t4 3 t4 -select * from total where tabname = 't2' or tabname = 't1'; +SELECT * FROM total WHERE tabname = 't2' OR tabname = 't1'; tabname ta message t1 1 Testing t1 2 dos table @@ -141,3 +141,22 @@ DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; DROP TABLE t4; +# +# Checking thread TBL tables +# +CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL SRCDEF='select 11 as v'; +SELECT * FROM t1; +v +11 +CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL SRCDEF='select 22 as v'; +SELECT * FROM t2; +v +22 +CREATE TABLE total (v BIGINT(20) UNSIGNED NOT NULL) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2' OPTION_LIST='thread=yes,port=PORT';; +SELECT * FROM total order by v desc; +v +22 +11 +DROP TABLE total; +DROP TABLE t1; +DROP TABLE t2; diff --git a/storage/connect/mysql-test/connect/t/grant3.test b/storage/connect/mysql-test/connect/t/grant3.test new file mode 100644 index 00000000000..9f05ca796c5 --- /dev/null +++ b/storage/connect/mysql-test/connect/t/grant3.test @@ -0,0 +1,11 @@ +# +# MDEV-9610 Trigger on normal table can't insert into CONNECT engine table - Access Denied +# +create table tcon (i int) engine=Connect table_type=DOS file_name='tcon.dos'; +create table tin (i int); +create trigger tr after insert on tin for each row insert into tcon values (new.i); +insert into tin values (1); +drop table tin,tcon; + +let datadir=`select @@datadir`; +remove_file $datadir/test/tcon.dos; diff --git a/storage/connect/mysql-test/connect/t/mysql_index.test b/storage/connect/mysql-test/connect/t/mysql_index.test index 9a162b4d8e3..81fdcad9330 100644 --- a/storage/connect/mysql-test/connect/t/mysql_index.test +++ b/storage/connect/mysql-test/connect/t/mysql_index.test @@ -64,3 +64,70 @@ SELECT * FROM t2; DROP TABLE t2; DROP TABLE t1; + +let $MYSQLD_DATADIR= `select @@datadir`; +--copy_file $MTR_SUITE_DIR/std_data/emp.txt $MYSQLD_DATADIR/test/emp.txt + +--echo # +--echo # Make local FIX table with indices matricule and nom/prenom +--echo # +CREATE TABLE t1 +( + matricule INT(4) KEY NOT NULL field_format='Z', + nom VARCHAR(16) NOT NULL, + prenom VARCHAR(20) NOT NULL, + sexe SMALLINT(1) NOT NULL COMMENT 'sexe 1:M 2:F', + aanais INT(4) NOT NULL, + mmnais INT(2) NOT NULL, + ddentree DATE NOT NULL date_format='YYYYMM', + ddnom DATE NOT NULL date_format='YYYYMM', + brut INT(5) NOT NULL, + net DOUBLE(8,2) NOT NULL, + service INT(2) NOT NULL, + sitmat CHAR(1) NOT NULL, + formation CHAR(5) NOT NULL, + INDEX NP(nom,prenom) +) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='emp.txt' ENDING=2; + +--echo # +--echo # Make MYSQL table with same indices +--echo # +CREATE TABLE t2 +( + matricule INT(4) KEY NOT NULL, + nom VARCHAR(16) NOT NULL, + prenom VARCHAR(20) NOT NULL, + sexe SMALLINT(1) NOT NULL, + aanais INT(4) NOT NULL, + mmnais INT(2) NOT NULL, + ddentree DATE NOT NULL date_format='YYYYMM', + ddnom DATE NOT NULL date_format='YYYYMM', + brut INT(5) NOT NULL, + net DOUBLE(8,2) NOT NULL, + service INT(2) NOT NULL, + sitmat CHAR(1) NOT NULL, + formation CHAR(5) NOT NULL, + INDEX NP(nom,prenom) +) ENGINE=CONNECT TABLE_TYPE=MYSQL CONNECTIOn='mysql://root@localhost/test/t1'; +SELECT * FROM t2 limit 10; +SELECT matricule, nom, prenom FROM t2 WHERE nom IN ('FOCH','MOGADOR'); +SELECT matricule, nom, prenom FROM t2 WHERE nom = 'FOCH' OR nom = 'MOGADOR'; +SELECT matricule, nom, prenom FROM t2 WHERE nom < 'ADDAX'; +SELECT matricule, nom, prenom FROM t2 WHERE nom <= 'ABEL'; +SELECT matricule, nom, prenom FROM t2 WHERE nom > 'YVON'; +SELECT matricule, nom, prenom FROM t2 WHERE nom >= 'YVON'; +SELECT matricule, nom, prenom FROM t2 WHERE nom <= 'ABEL' OR nom > 'YVON'; +SELECT matricule, nom, prenom FROM t2 WHERE nom > 'HELEN' AND nom < 'HEROS'; +SELECT matricule, nom, prenom FROM t2 WHERE nom BETWEEN 'HELEN' AND 'HEROS'; +SELECT matricule, nom, prenom FROM t2 WHERE nom BETWEEN 'HELEN' AND 'HEROS' AND prenom = 'PHILIPPE'; +SELECT matricule, nom, prenom FROM t2 ORDER BY nom LIMIT 10; +SELECT a.nom, a.prenom, b.nom FROM t1 a STRAIGHT_JOIN t2 b ON a.prenom = b.prenom WHERE a.nom = 'FOCH' AND a.nom != b.nom; + +DROP TABLE t2; +DROP TABLE t1; + +# +# Clean up +# +--remove_file $MYSQLD_DATADIR/test/emp.txt +--remove_file $MYSQLD_DATADIR/test/emp.fnx diff --git a/storage/connect/mysql-test/connect/t/part_table.test b/storage/connect/mysql-test/connect/t/part_table.test index d839337ba6f..5edd5766bd6 100644 --- a/storage/connect/mysql-test/connect/t/part_table.test +++ b/storage/connect/mysql-test/connect/t/part_table.test @@ -82,6 +82,21 @@ SELECT * FROM t1; DELETE FROM t1 WHERE id in (60,72); SELECT * FROM t1; DROP TABLE t1; + +# +# Using a connection string +# +CREATE TABLE t1 ( +id INT KEY NOT NULL, +msg VARCHAR(32)) +ENGINE=CONNECT TABLE_TYPE=MYSQL +OPTION_LIST='connect=mysql://root@localhost/test/xt%s' +PARTITION BY RANGE COLUMNS(id) ( +PARTITION `1` VALUES LESS THAN(10), +PARTITION `2` VALUES LESS THAN(50), +PARTITION `3` VALUES LESS THAN(MAXVALUE)); +SELECT * FROM t1; +DROP TABLE t1; DROP TABLE xt1; DROP TABLE xt2; DROP TABLE xt3; diff --git a/storage/connect/mysql-test/connect/t/tbl.test b/storage/connect/mysql-test/connect/t/tbl.test index 43c506c9403..3dc4b2e64b0 100644 --- a/storage/connect/mysql-test/connect/t/tbl.test +++ b/storage/connect/mysql-test/connect/t/tbl.test @@ -31,23 +31,40 @@ INSERT INTO t4 (message) VALUES ('Testing'),('myisam table'),('t4'); SELECT * FROM t4; --replace_result $PORT PORT ---eval CREATE TABLE total (tabname CHAR(8) NOT NULL SPECIAL='TABID', ta TINYINT NOT NULL FLAG=1, message CHAR(20)) engine=CONNECT table_type=TBL table_list='t1,t2,t3,t4' option_list='port=$PORT' - -select * from total; -select * from total where tabname = 't2'; -select * from total where tabname = 't2' and ta = 3; -select * from total where tabname in ('t1','t4'); -select * from total where ta = 3 and tabname in ('t1','t2'); -select * from total where tabname <> 't2'; -select * from total where tabname != 't2' and ta = 3; -select * from total where tabname not in ('t2','t3'); -select * from total where ta = 3 and tabname in ('t2','t3'); -select * from total where ta = 3 or tabname in ('t2','t4'); -select * from total where not tabname = 't2'; -select * from total where tabname = 't2' or tabname = 't1'; +--eval CREATE TABLE total (tabname CHAR(8) NOT NULL SPECIAL='TABID', ta TINYINT NOT NULL FLAG=1, message CHAR(20)) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2,t3,t4' OPTION_LIST='port=$PORT' + +SELECT * FROM total; +SELECT * FROM total WHERE tabname = 't2'; +SELECT * FROM total WHERE tabname = 't2' AND ta = 3; +SELECT * FROM total WHERE tabname IN ('t1','t4'); +SELECT * FROM total WHERE ta = 3 AND tabname IN ('t1','t2'); +SELECT * FROM total WHERE tabname <> 't2'; +SELECT * FROM total WHERE tabname != 't2' AND ta = 3; +SELECT * FROM total WHERE tabname NOT IN ('t2','t3'); +SELECT * FROM total WHERE ta = 3 AND tabname IN ('t2','t3'); +SELECT * FROM total WHERE ta = 3 OR tabname IN ('t2','t4'); +SELECT * FROM total WHERE NOT tabname = 't2'; +SELECT * FROM total WHERE tabname = 't2' OR tabname = 't1'; DROP TABLE total; DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; DROP TABLE t4; + +--echo # +--echo # Checking thread TBL tables +--echo # +CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL SRCDEF='select 11 as v'; +SELECT * FROM t1; + +CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL SRCDEF='select 22 as v'; +SELECT * FROM t2; + +--replace_result $PORT PORT +--eval CREATE TABLE total (v BIGINT(20) UNSIGNED NOT NULL) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2' OPTION_LIST='thread=yes,port=$PORT'; +SELECT * FROM total order by v desc; + +DROP TABLE total; +DROP TABLE t1; +DROP TABLE t2; diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index cb21a8bda15..55ccbdbada1 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -1758,7 +1758,9 @@ bool ODBConn::BindParam(ODBCCOL *colp) SQLLEN *strlen = colp->GetStrLen(); SQLRETURN rc; +#if 0 try { + // This function is often not or badly implemented by data sources rc = SQLDescribeParam(m_hstmt, n, &sqlt, &colsize, &dec, &nul); if (!Check(rc)) @@ -1766,11 +1768,12 @@ bool ODBConn::BindParam(ODBCCOL *colp) } catch(DBX *x) { sprintf(m_G->Message, "%s: %s", x->m_Msg, x->GetErrorMessage(0)); +#endif // 0 colsize = colp->GetPrecision(); sqlt = GetSQLType(buftype); - dec = IsTypeChar(buftype) ? 0 : colp->GetScale(); - nul = SQL_NULLABLE_UNKNOWN; - } // end try/catch + dec = IsTypeNum(buftype) ? colp->GetScale() : 0; + nul = colp->IsNullable() ? SQL_NULLABLE : SQL_NO_NULLS; +//} // end try/catch buf = colp->GetBuffer(0); len = IsTypeChar(buftype) ? colp->GetBuflen() : 0; diff --git a/storage/connect/plgcnx.h b/storage/connect/plgcnx.h index a1208f9b885..1b341bc5275 100644 --- a/storage/connect/plgcnx.h +++ b/storage/connect/plgcnx.h @@ -25,7 +25,7 @@ enum FNRC {RC_LICENSE = 7, /* PLGConnect prompt for license key */ RC_SUCCESS = 0, /* Successful function (must be 0) */ RC_MEMORY = -1, /* Storage allocation error */ RC_TRUNCATED = -2, /* Result has been truncated */ - RC_TIMEOUT = -3, /* Connection timeout occured */ + RC_TIMEOUT = -3, /* Connection timeout occurred */ RC_TOOBIG = -4, /* Data is too big for connection */ RC_KEY = -5, /* Null ptr to key in Connect */ /* or bad key in other functions */ diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp index 7906f6c9219..98633f49d23 100644 --- a/storage/connect/tabdos.cpp +++ b/storage/connect/tabdos.cpp @@ -184,7 +184,7 @@ bool DOSDEF::GetOptFileName(PGLOBAL g, char *filename) } // end of GetOptFileName /***********************************************************************/ -/* After an optimize error occured, remove all set optimize values. */ +/* After an optimize error occurred, remove all set optimize values. */ /***********************************************************************/ void DOSDEF::RemoveOptValues(PGLOBAL g) { diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index b9cede52a21..98a476bf94f 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -19,7 +19,7 @@ /* --------------- */ /* TABMYSQL.CPP - Source code */ /* PLGDBSEM.H - DB application declaration file */ -/* TABMYSQL.H - TABODBC classes declaration file */ +/* TABMYSQL.H - TABMYSQL classes declaration file */ /* GLOBAL.H - Global declaration file */ /* */ /* REQUIRED LIBRARIES: */ @@ -334,7 +334,7 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int) Delayed = !!GetIntCatInfo("Delayed", 0); } else { // MYSQL access from a PROXY table - Database = GetStringCatInfo(g, "Database", Schema ? Schema : "*"); + Database = GetStringCatInfo(g, "Database", Schema ? Schema : PlugDup(g, "*")); Isview = GetBoolCatInfo("View", false); // We must get other connection parms from the calling table @@ -806,7 +806,7 @@ int TDBMYSQL::GetMaxSize(PGLOBAL g) else if (!Cardinality(NULL)) MaxSize = 10; // To make MySQL happy else if ((MaxSize = Cardinality(g)) < 0) - MaxSize = 12; // So we can see an error occured + MaxSize = 12; // So we can see an error occurred } // endif MaxSize @@ -857,7 +857,9 @@ bool TDBMYSQL::OpenDB(PGLOBAL g) /*******************************************************************/ /* Table already open, just replace it at its beginning. */ /*******************************************************************/ - Myc.Rewind(); + if (Myc.Rewind(g, (Mode == MODE_READX) ? Query->GetStr() : NULL) != RC_OK) + return true; + N = -1; return false; } // endif use diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp index fd9a049a05a..c555f2a5abb 100644 --- a/storage/connect/tabodbc.cpp +++ b/storage/connect/tabodbc.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2000-2015 */ +/* (C) Copyright to the author Olivier BERTRAND 2000-2016 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -818,7 +818,7 @@ int TDBODBC::GetMaxSize(PGLOBAL g) else if (!Cardinality(NULL)) MaxSize = 10; // To make MySQL happy else if ((MaxSize = Cardinality(g)) < 0) - MaxSize = 12; // So we can see an error occured + MaxSize = 12; // So we can see an error occurred } // endif MaxSize @@ -912,19 +912,21 @@ bool TDBODBC::OpenDB(PGLOBAL g) if ((n = Ocp->GetResultSize(Query->GetStr(), Cnp)) < 0) { strcpy(g->Message, "Cannot get result size"); return true; - } // endif n + } else if (n) { + Ocp->m_Rows = n; - Ocp->m_Rows = n; + if ((Qrp = Ocp->AllocateResult(g))) + Memory = 2; // Must be filled + else { + strcpy(g->Message, "Result set memory allocation failed"); + return true; + } // endif n - if ((Qrp = Ocp->AllocateResult(g))) - Memory = 2; // Must be filled - else { - strcpy(g->Message, "Result set memory allocation failed"); - return true; - } // endif n + } else // Void result + Memory = 0; - Ocp->m_Rows = 0; - } else + Ocp->m_Rows = 0; + } else return true; } // endif Memory diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index 6b72c715517..36849146746 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -607,7 +607,7 @@ void TDBTBM::ResetDB(void) for (PTABLE tabp = Tablist; tabp; tabp = tabp->GetNext()) ((PTDBASE)tabp->GetTo_Tdb())->ResetDB(); - Tdbp = (PTDBASE)Tablist->GetTo_Tdb(); + Tdbp = (Tablist) ? (PTDBASE)Tablist->GetTo_Tdb() : NULL; Crp = 0; } // end of ResetDB @@ -679,7 +679,7 @@ bool TDBTBM::OpenDB(PGLOBAL g) /* Table already open, replace it at its beginning. */ /*******************************************************************/ ResetDB(); - return Tdbp->OpenDB(g); // Re-open fist table + return (Tdbp) ? Tdbp->OpenDB(g) : false; // Re-open fist table } // endif use #if 0 diff --git a/storage/connect/tabtbl.h b/storage/connect/tabtbl.h index 9d3f297f9e7..3a5ec45d025 100644 --- a/storage/connect/tabtbl.h +++ b/storage/connect/tabtbl.h @@ -138,7 +138,8 @@ class DllExport TDBTBM : public TDBTBL { virtual void ResetDB(void); // Database routines - virtual int GetMaxSize(PGLOBAL g) {return 10;} // Temporary + virtual int Cardinality(PGLOBAL g) { return 10; } + virtual int GetMaxSize(PGLOBAL g) { return 10; } // Temporary virtual int RowNumber(PGLOBAL g, bool b = FALSE); virtual bool OpenDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g); diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index f9597cb842b..64d0e13e8c4 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -989,7 +989,7 @@ uchar TYPVAL<uchar>::MinMaxVal(bool b) {return (b) ? UINT_MAX8 : 0;} /***********************************************************************/ -/* SafeAdd: adds a value and test whether overflow/underflow occured. */ +/* SafeAdd: adds a value and test whether overflow/underflow occurred. */ /***********************************************************************/ template <class TYPE> TYPE TYPVAL<TYPE>::SafeAdd(TYPE n1, TYPE n2) @@ -1017,7 +1017,7 @@ inline double TYPVAL<double>::SafeAdd(double n1, double n2) } // end of SafeAdd /***********************************************************************/ -/* SafeMult: multiply values and test whether overflow occured. */ +/* SafeMult: multiply values and test whether overflow occurred. */ /***********************************************************************/ template <class TYPE> TYPE TYPVAL<TYPE>::SafeMult(TYPE n1, TYPE n2) @@ -1344,10 +1344,13 @@ bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype) /***********************************************************************/ bool TYPVAL<PSZ>::SetValue_char(char *p, int n) { - bool rc; + bool rc = false; - if (p && n > 0) { - rc = n > Len; + if (!p || n == 0) { + Reset(); + Null = Nullable; + } else if (p != Strp) { + rc = n > Len; if ((n = MY_MIN(n, Len))) { strncpy(Strp, p, n); @@ -1366,10 +1369,6 @@ bool TYPVAL<PSZ>::SetValue_char(char *p, int n) Reset(); Null = false; - } else { - rc = false; - Reset(); - Null = Nullable; } // endif p return rc; @@ -1380,12 +1379,12 @@ bool TYPVAL<PSZ>::SetValue_char(char *p, int n) /***********************************************************************/ void TYPVAL<PSZ>::SetValue_psz(PSZ s) { - if (s) { - strncpy(Strp, s, Len); + if (!s) { + Reset(); + Null = Nullable; + } else if (s != Strp) { + strncpy(Strp, s, Len); Null = false; - } else { - Reset(); - Null = Nullable; } // endif s } // end of SetValue_psz @@ -1643,7 +1642,7 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op) assert(np == 1 || np == 2); if (np == 2) - strncpy(Strp, p[0], Len); + SetValue_psz(p[0]); if ((i = Len - (signed)strlen(Strp)) > 0) strncat(Strp, p[np - 1], i); @@ -1651,11 +1650,11 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op) break; case OP_MIN: assert(np == 2); - strcpy(Strp, (strcmp(p[0], p[1]) < 0) ? p[0] : p[1]); + SetValue_psz((strcmp(p[0], p[1]) < 0) ? p[0] : p[1]); break; case OP_MAX: assert(np == 2); - strcpy(Strp, (strcmp(p[0], p[1]) > 0) ? p[0] : p[1]); + SetValue_psz((strcmp(p[0], p[1]) > 0) ? p[0] : p[1]); break; default: // sprintf(g->Message, MSG(BAD_EXP_OPER), op); diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp index a2d75cec8ab..69aa7e2c20e 100755 --- a/storage/connect/xindex.cpp +++ b/storage/connect/xindex.cpp @@ -1279,7 +1279,7 @@ bool XINDEX::MapInit(PGLOBAL g) IOFF *noff = (IOFF*)mbase; // Position the memory base at the offset of this index - mbase += noff[id].Low; + mbase += noff[id].v.Low; } // endif id // Now start the mapping process. @@ -2347,10 +2347,10 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) return true; } // endif - NewOff.Low = (int)ftell(Xfile); + NewOff.v.Low = (int)ftell(Xfile); if (trace) - htrc("XFILE Open: NewOff.Low=%d\n", NewOff.Low); + htrc("XFILE Open: NewOff.v.Low=%d\n", NewOff.v.Low); } else if (mode == MODE_WRITE) { if (id >= 0) { @@ -2358,10 +2358,10 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) memset(noff, 0, sizeof(noff)); Write(g, noff, sizeof(IOFF), MAX_INDX, rc); fseek(Xfile, 0, SEEK_END); - NewOff.Low = (int)ftell(Xfile); + NewOff.v.Low = (int)ftell(Xfile); if (trace) - htrc("XFILE Open: NewOff.Low=%d\n", NewOff.Low); + htrc("XFILE Open: NewOff.v.Low=%d\n", NewOff.v.Low); } // endif id @@ -2373,10 +2373,10 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) } // endif MAX_INDX if (trace) - htrc("XFILE Open: noff[%d].Low=%d\n", id, noff[id].Low); + htrc("XFILE Open: noff[%d].v.Low=%d\n", id, noff[id].v.Low); // Position the cursor at the offset of this index - if (fseek(Xfile, noff[id].Low, SEEK_SET)) { + if (fseek(Xfile, noff[id].v.Low, SEEK_SET)) { sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Xseek"); return true; } // endif @@ -2566,14 +2566,14 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) return true; } // endif - NewOff.Low = (int)rc; - NewOff.High = (int)high; + NewOff.v.Low = (int)rc; + NewOff.v.High = (int)high; } else if (mode == MODE_WRITE) { if (id >= 0) { // New not sep index file. Write the header. memset(noff, 0, sizeof(noff)); rc = WriteFile(Hfile, noff, sizeof(noff), &drc, NULL); - NewOff.Low = (int)drc; + NewOff.v.Low = (int)drc; } // endif id } else if (mode == MODE_READ && id >= 0) { @@ -2586,8 +2586,8 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) } // endif rc // Position the cursor at the offset of this index - rc = SetFilePointer(Hfile, noff[id].Low, - (PLONG)&noff[id].High, FILE_BEGIN); + rc = SetFilePointer(Hfile, noff[id].v.Low, + (PLONG)&noff[id].v.High, FILE_BEGIN); if (rc == INVALID_SET_FILE_POINTER) { sprintf(g->Message, MSG(FUNC_ERRNO), GetLastError(), "SetFilePointer"); @@ -2649,7 +2649,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) if (id >= 0) { // New not sep index file. Write the header. memset(noff, 0, sizeof(noff)); - NewOff.Low = write(Hfile, &noff, sizeof(noff)); + NewOff.v.Low = write(Hfile, &noff, sizeof(noff)); } // endif id if (trace) diff --git a/storage/connect/xindex.h b/storage/connect/xindex.h index 51b678992ea..ef2e934e5ee 100644 --- a/storage/connect/xindex.h +++ b/storage/connect/xindex.h @@ -66,9 +66,9 @@ typedef struct index_def : public BLOCK { typedef struct index_off { union { #if defined(WORDS_BIGENDIAN) - struct {int High; int Low;}; + struct {int High; int Low;} v; #else // !WORDS_BIGENDIAN - struct {int Low; int High;}; + struct {int Low; int High;} v; #endif //!WORDS_BIGENDIAN longlong Val; // File position }; // end of union diff --git a/storage/csv/ha_tina.h b/storage/csv/ha_tina.h index 000b46b2bb2..127c6053a53 100644 --- a/storage/csv/ha_tina.h +++ b/storage/csv/ha_tina.h @@ -71,7 +71,7 @@ class ha_tina: public handler File update_temp_file; String buffer; /* - The chain contains "holes" in the file, occured because of + The chain contains "holes" in the file, occurred because of deletes/updates. It is used in rnd_end() to get rid of them in the end of the query. */ diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 4ea91dd9e68..97baa27aba6 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -2016,7 +2016,7 @@ void ha_federated::start_bulk_insert(ha_rows rows, uint flags) @return Operation status @retval 0 No error - @retval != 0 Error occured at remote server. Also sets my_errno. + @retval != 0 Error occurred at remote server. Also sets my_errno. */ int ha_federated::end_bulk_insert() diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index 132cccc9c0f..aae26758c78 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -566,17 +566,17 @@ int get_connection(MEM_ROOT *mem_root, FEDERATEDX_SHARE *share) at the address of the share. */ share->server_name_length= server->server_name_length; - share->server_name= server->server_name; - share->username= server->username; - share->password= server->password; - share->database= server->db; + share->server_name= const_cast<char*>(server->server_name); + share->username= const_cast<char*>(server->username); + share->password= const_cast<char*>(server->password); + share->database= const_cast<char*>(server->db); share->port= server->port > MIN_PORT && server->port < 65536 ? (ushort) server->port : MYSQL_PORT; - share->hostname= server->host; - if (!(share->socket= server->socket) && + share->hostname= const_cast<char*>(server->host); + if (!(share->socket= const_cast<char*>(server->socket)) && !strcmp(share->hostname, my_localhost)) share->socket= (char *) MYSQL_UNIX_ADDR; - share->scheme= server->scheme; + share->scheme= const_cast<char*>(server->scheme); DBUG_PRINT("info", ("share->username: %s", share->username)); DBUG_PRINT("info", ("share->password: %s", share->password)); @@ -1319,7 +1319,7 @@ bool ha_federatedx::create_where_from_key(String *to, break; } DBUG_PRINT("info", ("federatedx HA_READ_AFTER_KEY %d", i)); - if (store_length >= length) /* end key */ + if (store_length >= length || i > 0) /* end key */ { if (emit_key_part_name(&tmp, key_part)) goto err; @@ -2157,7 +2157,7 @@ void ha_federatedx::start_bulk_insert(ha_rows rows, uint flags) @return Operation status @retval 0 No error - @retval != 0 Error occured at remote server. Also sets my_errno. + @retval != 0 Error occurred at remote server. Also sets my_errno. */ int ha_federatedx::end_bulk_insert() @@ -2560,9 +2560,7 @@ int ha_federatedx::index_read_idx(uchar *buf, uint index, const uchar *key, RESULT 0 ok In this case *result will contain the result set - table->status == 0 # error In this case *result will contain 0 - table->status == STATUS_NOT_FOUND */ int ha_federatedx::index_read_idx_with_result_set(uchar *buf, uint index, @@ -2619,11 +2617,9 @@ int ha_federatedx::index_read_idx_with_result_set(uchar *buf, uint index, insert_dynamic(&results, (uchar*) result); *result= 0; - table->status= STATUS_NOT_FOUND; DBUG_RETURN(retval); error: - table->status= STATUS_NOT_FOUND; my_error(retval, MYF(0), error_buffer); DBUG_RETURN(retval); } @@ -2704,7 +2700,6 @@ int ha_federatedx::read_range_first(const key_range *start_key, DBUG_RETURN(retval); error: - table->status= STATUS_NOT_FOUND; DBUG_RETURN(retval); } @@ -2909,8 +2904,6 @@ int ha_federatedx::read_next(uchar *buf, FEDERATEDX_IO_RESULT *result) FEDERATEDX_IO_ROW *row; DBUG_ENTER("ha_federatedx::read_next"); - table->status= STATUS_NOT_FOUND; // For easier return - if ((retval= txn->acquire(share, TRUE, &io))) DBUG_RETURN(retval); @@ -2995,7 +2988,6 @@ int ha_federatedx::rnd_pos(uchar *buf, uchar *pos) DBUG_RETURN(retval); error: - table->status= STATUS_NOT_FOUND; DBUG_RETURN(retval); } @@ -3098,7 +3090,7 @@ error: else if (remote_error_number != -1 /* error already reported */) { error_code= remote_error_number; - my_error(error_code, MYF(0), ER(error_code)); + my_error(error_code, MYF(0), ER_THD(thd, error_code)); } fail: tmp_txn->release(&tmp_io); diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index 3ed97f5f082..dbfdc2c8ef9 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -1183,7 +1183,7 @@ dict_create_index_step( >= UNIV_FORMAT_B); node->index = dict_index_get_if_in_cache_low(index_id); - ut_a(err == DB_SUCCESS ? node->index != NULL : node->index == NULL); + ut_a((node->index == NULL) == (err != DB_SUCCESS)); if (err != DB_SUCCESS) { diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 4b64d7285a2..ebbb44db8cb 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -3047,8 +3047,6 @@ fil_create_link_file( const char* tablename, /*!< in: tablename */ const char* filepath) /*!< in: pathname of tablespace */ { - os_file_t file; - ibool success; dberr_t err = DB_SUCCESS; char* link_filepath; char* prev_filepath = fil_read_link_file(tablename); @@ -3067,13 +3065,24 @@ fil_create_link_file( link_filepath = fil_make_isl_name(tablename); - file = os_file_create_simple_no_error_handling( - innodb_file_data_key, link_filepath, - OS_FILE_CREATE, OS_FILE_READ_WRITE, &success); + /** Check if the file already exists. */ + FILE* file = NULL; + ibool exists; + os_file_type_t ftype; - if (!success) { - /* The following call will print an error message */ - ulint error = os_file_get_last_error(true); + bool success = os_file_status(link_filepath, &exists, &ftype); + + ulint error = 0; + if (success && !exists) { + file = fopen(link_filepath, "w"); + if (file == NULL) { + /* This call will print its own error message */ + error = os_file_get_last_error(true); + } + } else { + error = OS_FILE_ALREADY_EXISTS; + } + if (error != 0) { ut_print_timestamp(stderr); fputs(" InnoDB: Cannot create file ", stderr); @@ -3098,13 +3107,17 @@ fil_create_link_file( return(err); } - if (!os_file_write(link_filepath, file, filepath, 0, - strlen(filepath))) { + ulint rbytes = fwrite(filepath, 1, strlen(filepath), file); + if (rbytes != strlen(filepath)) { + os_file_get_last_error(true); + ib_logf(IB_LOG_LEVEL_ERROR, + "cannot write link file " + "%s",filepath); err = DB_ERROR; } /* Close the file, we only need it at startup */ - os_file_close(file); + fclose(file); mem_free(link_filepath); @@ -5034,12 +5047,15 @@ retry: os_offset_t offset = ((os_offset_t) (start_page_no - file_start_page_no)) * page_size; + + const char* name = node->name == NULL ? space->name : node->name; + #ifdef UNIV_HOTBACKUP - success = os_file_write(node->name, node->handle, buf, + success = os_file_write(name, node->handle, buf, offset, page_size * n_pages); #else success = os_aio(OS_FILE_WRITE, OS_AIO_SYNC, - node->name, node->handle, buf, + name, node->handle, buf, offset, page_size * n_pages, NULL, NULL); #endif /* UNIV_HOTBACKUP */ @@ -5610,18 +5626,20 @@ fil_io( ut_a(byte_offset % OS_FILE_LOG_BLOCK_SIZE == 0); ut_a((len % OS_FILE_LOG_BLOCK_SIZE) == 0); + const char* name = node->name == NULL ? space->name : node->name; + #ifdef UNIV_HOTBACKUP /* In mysqlbackup do normal i/o, not aio */ if (type == OS_FILE_READ) { ret = os_file_read(node->handle, buf, offset, len); } else { ut_ad(!srv_read_only_mode); - ret = os_file_write(node->name, node->handle, buf, + ret = os_file_write(name, node->handle, buf, offset, len); } #else /* Queue the aio request */ - ret = os_aio(type, mode | wake_later, node->name, node->handle, buf, + ret = os_aio(type, mode | wake_later, name, node->handle, buf, offset, len, node, message); #endif /* UNIV_HOTBACKUP */ diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 4351dc0b765..54d40cbf72a 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -260,16 +260,18 @@ static const char* fts_config_table_insert_values_sql = "INSERT INTO \"%s\" VALUES ('" FTS_TABLE_STATE "', '0');\n"; -/****************************************************************//** -Run SYNC on the table, i.e., write out data from the cache to the +/** Run SYNC on the table, i.e., write out data from the cache to the FTS auxiliary INDEX table and clear the cache at the end. -@return DB_SUCCESS if all OK */ +@param[in,out] sync sync state +@param[in] unlock_cache whether unlock cache lock when write node +@param[in] wait whether wait when a sync is in progress +@return DB_SUCCESS if all OK */ static dberr_t fts_sync( -/*=====*/ - fts_sync_t* sync) /*!< in: sync state */ - __attribute__((nonnull)); + fts_sync_t* sync, + bool unlock_cache, + bool wait); /****************************************************************//** Release all resources help by the words rb tree e.g., the node ilist. */ @@ -653,6 +655,7 @@ fts_cache_create( mem_heap_zalloc(heap, sizeof(fts_sync_t))); cache->sync->table = table; + cache->sync->event = os_event_create(); /* Create the index cache vector that will hold the inverted indexes. */ cache->indexes = ib_vector_create( @@ -1207,6 +1210,7 @@ fts_cache_destroy( mutex_free(&cache->optimize_lock); mutex_free(&cache->deleted_lock); mutex_free(&cache->doc_id_lock); + os_event_free(cache->sync->event); if (cache->stopword_info.cached_stopword) { rbt_free(cache->stopword_info.cached_stopword); @@ -1435,7 +1439,7 @@ fts_cache_add_doc( ib_vector_last(word->nodes)); } - if (fts_node == NULL + if (fts_node == NULL || fts_node->synced || fts_node->ilist_size > FTS_ILIST_MAX_SIZE || doc_id < fts_node->last_doc_id) { @@ -2886,35 +2890,28 @@ fts_doc_ids_free( } /*********************************************************************//** -Do commit-phase steps necessary for the insertion of a new row. -@return DB_SUCCESS or error code */ -static __attribute__((nonnull, warn_unused_result)) -dberr_t +Do commit-phase steps necessary for the insertion of a new row. */ +void fts_add( /*====*/ fts_trx_table_t*ftt, /*!< in: FTS trx table */ fts_trx_row_t* row) /*!< in: row */ { dict_table_t* table = ftt->table; - dberr_t error = DB_SUCCESS; doc_id_t doc_id = row->doc_id; ut_a(row->state == FTS_INSERT || row->state == FTS_MODIFY); fts_add_doc_by_id(ftt, doc_id, row->fts_indexes); - if (error == DB_SUCCESS) { - mutex_enter(&table->fts->cache->deleted_lock); - ++table->fts->cache->added; - mutex_exit(&table->fts->cache->deleted_lock); + mutex_enter(&table->fts->cache->deleted_lock); + ++table->fts->cache->added; + mutex_exit(&table->fts->cache->deleted_lock); - if (!DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID) - && doc_id >= table->fts->cache->next_doc_id) { - table->fts->cache->next_doc_id = doc_id + 1; - } + if (!DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID) + && doc_id >= table->fts->cache->next_doc_id) { + table->fts->cache->next_doc_id = doc_id + 1; } - - return(error); } /*********************************************************************//** @@ -3025,7 +3022,7 @@ fts_modify( error = fts_delete(ftt, row); if (error == DB_SUCCESS) { - error = fts_add(ftt, row); + fts_add(ftt, row); } return(error); @@ -3114,7 +3111,7 @@ fts_commit_table( switch (row->state) { case FTS_INSERT: - error = fts_add(ftt, row); + fts_add(ftt, row); break; case FTS_MODIFY: @@ -3554,16 +3551,34 @@ fts_add_doc_by_id( get_doc->index_cache, doc_id, doc.tokens); + bool need_sync = false; + if ((cache->total_size > fts_max_cache_size / 10 + || fts_need_sync) + && !cache->sync->in_progress) { + need_sync = true; + } + rw_lock_x_unlock(&table->fts->cache->lock); DBUG_EXECUTE_IF( "fts_instrument_sync", - fts_sync(cache->sync); + fts_optimize_request_sync_table(table); + os_event_wait(cache->sync->event); + ); + + DBUG_EXECUTE_IF( + "fts_instrument_sync_debug", + fts_sync(cache->sync, true, true); ); - if (cache->total_size > fts_max_cache_size - || fts_need_sync) { - fts_sync(cache->sync); + DEBUG_SYNC_C("fts_instrument_sync_request"); + DBUG_EXECUTE_IF( + "fts_instrument_sync_request", + fts_optimize_request_sync_table(table); + ); + + if (need_sync) { + fts_optimize_request_sync_table(table); } mtr_start(&mtr); @@ -3934,16 +3949,17 @@ fts_sync_add_deleted_cache( return(error); } -/*********************************************************************//** -Write the words and ilist to disk. +/** Write the words and ilist to disk. +@param[in,out] trx transaction +@param[in] index_cache index cache +@param[in] unlock_cache whether unlock cache when write node @return DB_SUCCESS if all went well else error code */ static __attribute__((nonnull, warn_unused_result)) dberr_t fts_sync_write_words( -/*=================*/ - trx_t* trx, /*!< in: transaction */ - fts_index_cache_t* - index_cache) /*!< in: index cache */ + trx_t* trx, + fts_index_cache_t* index_cache, + bool unlock_cache) { fts_table_t fts_table; ulint n_nodes = 0; @@ -3951,8 +3967,8 @@ fts_sync_write_words( const ib_rbt_node_t* rbt_node; dberr_t error = DB_SUCCESS; ibool print_error = FALSE; -#ifdef FTS_DOC_STATS_DEBUG dict_table_t* table = index_cache->index->table; +#ifdef FTS_DOC_STATS_DEBUG ulint n_new_words = 0; #endif /* FTS_DOC_STATS_DEBUG */ @@ -3965,7 +3981,7 @@ fts_sync_write_words( since we want to free the memory used during caching. */ for (rbt_node = rbt_first(index_cache->words); rbt_node; - rbt_node = rbt_first(index_cache->words)) { + rbt_node = rbt_next(index_cache->words, rbt_node)) { ulint i; ulint selected; @@ -3998,27 +4014,47 @@ fts_sync_write_words( } #endif /* FTS_DOC_STATS_DEBUG */ - n_nodes += ib_vector_size(word->nodes); - - /* We iterate over all the nodes even if there was an error, - this is to free the memory of the fts_node_t elements. */ + /* We iterate over all the nodes even if there was an error */ for (i = 0; i < ib_vector_size(word->nodes); ++i) { fts_node_t* fts_node = static_cast<fts_node_t*>( ib_vector_get(word->nodes, i)); + if (fts_node->synced) { + continue; + } else { + fts_node->synced = true; + } + + /*FIXME: we need to handle the error properly. */ if (error == DB_SUCCESS) { + if (unlock_cache) { + rw_lock_x_unlock( + &table->fts->cache->lock); + } error = fts_write_node( trx, &index_cache->ins_graph[selected], &fts_table, &word->text, fts_node); - } - ut_free(fts_node->ilist); - fts_node->ilist = NULL; + DEBUG_SYNC_C("fts_write_node"); + DBUG_EXECUTE_IF("fts_write_node_crash", + DBUG_SUICIDE();); + + DBUG_EXECUTE_IF("fts_instrument_sync_sleep", + os_thread_sleep(1000000); + ); + + if (unlock_cache) { + rw_lock_x_lock( + &table->fts->cache->lock); + } + } } + n_nodes += ib_vector_size(word->nodes); + if (error != DB_SUCCESS && !print_error) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error (%s) writing " @@ -4027,9 +4063,6 @@ fts_sync_write_words( print_error = TRUE; } - - /* NOTE: We are responsible for free'ing the node */ - ut_free(rbt_remove_node(index_cache->words, rbt_node)); } #ifdef FTS_DOC_STATS_DEBUG @@ -4330,7 +4363,7 @@ fts_sync_index( ut_ad(rbt_validate(index_cache->words)); - error = fts_sync_write_words(trx, index_cache); + error = fts_sync_write_words(sync->trx, index_cache, sync->unlock_cache); #ifdef FTS_DOC_STATS_DEBUG /* FTS_RESOLVE: the word counter info in auxiliary table "DOC_ID" @@ -4346,6 +4379,36 @@ fts_sync_index( return(error); } +/** Check if index cache has been synced completely +@param[in,out] sync sync state +@param[in,out] index_cache index cache +@return true if index is synced, otherwise false. */ +static +bool +fts_sync_index_check( + fts_sync_t* sync, + fts_index_cache_t* index_cache) +{ + const ib_rbt_node_t* rbt_node; + + for (rbt_node = rbt_first(index_cache->words); + rbt_node != NULL; + rbt_node = rbt_next(index_cache->words, rbt_node)) { + + fts_tokenizer_word_t* word; + word = rbt_value(fts_tokenizer_word_t, rbt_node); + + fts_node_t* fts_node; + fts_node = static_cast<fts_node_t*>(ib_vector_last(word->nodes)); + + if (!fts_node->synced) { + return(false); + } + } + + return(true); +} + /*********************************************************************//** Commit the SYNC, change state of processed doc ids etc. @return DB_SUCCESS if all OK */ @@ -4422,21 +4485,53 @@ fts_sync_rollback( trx_t* trx = sync->trx; fts_cache_t* cache = sync->table->fts->cache; + for (ulint i = 0; i < ib_vector_size(cache->indexes); ++i) { + ulint j; + fts_index_cache_t* index_cache; + + index_cache = static_cast<fts_index_cache_t*>( + ib_vector_get(cache->indexes, i)); + + for (j = 0; fts_index_selector[j].value; ++j) { + + if (index_cache->ins_graph[j] != NULL) { + + fts_que_graph_free_check_lock( + NULL, index_cache, + index_cache->ins_graph[j]); + + index_cache->ins_graph[j] = NULL; + } + + if (index_cache->sel_graph[j] != NULL) { + + fts_que_graph_free_check_lock( + NULL, index_cache, + index_cache->sel_graph[j]); + + index_cache->sel_graph[j] = NULL; + } + } + } + rw_lock_x_unlock(&cache->lock); fts_sql_rollback(trx); trx_free_for_background(trx); } -/****************************************************************//** -Run SYNC on the table, i.e., write out data from the cache to the +/** Run SYNC on the table, i.e., write out data from the cache to the FTS auxiliary INDEX table and clear the cache at the end. +@param[in,out] sync sync state +@param[in] unlock_cache whether unlock cache lock when write node +@param[in] wait whether wait when a sync is in progress @return DB_SUCCESS if all OK */ static dberr_t fts_sync( -/*=====*/ - fts_sync_t* sync) /*!< in: sync state */ + fts_sync_t* sync, + bool unlock_cache, + bool wait) { ulint i; dberr_t error = DB_SUCCESS; @@ -4444,8 +4539,35 @@ fts_sync( rw_lock_x_lock(&cache->lock); + /* Check if cache is being synced. + Note: we release cache lock in fts_sync_write_words() to + avoid long wait for the lock by other threads. */ + while (sync->in_progress) { + rw_lock_x_unlock(&cache->lock); + + if (wait) { + os_event_wait(sync->event); + } else { + return(DB_SUCCESS); + } + + rw_lock_x_lock(&cache->lock); + } + + sync->unlock_cache = unlock_cache; + sync->in_progress = true; + + DEBUG_SYNC_C("fts_sync_begin"); fts_sync_begin(sync); +begin_sync: + if (cache->total_size > fts_max_cache_size) { + /* Avoid the case: sync never finish when + insert/update keeps comming. */ + ut_ad(sync->unlock_cache); + sync->unlock_cache = false; + } + for (i = 0; i < ib_vector_size(cache->indexes); ++i) { fts_index_cache_t* index_cache; @@ -4460,21 +4582,43 @@ fts_sync( if (error != DB_SUCCESS && !sync->interrupted) { - break; + goto end_sync; } } DBUG_EXECUTE_IF("fts_instrument_sync_interrupted", sync->interrupted = true; error = DB_INTERRUPTED; + goto end_sync; ); + /* Make sure all the caches are synced. */ + for (i = 0; i < ib_vector_size(cache->indexes); ++i) { + fts_index_cache_t* index_cache; + + index_cache = static_cast<fts_index_cache_t*>( + ib_vector_get(cache->indexes, i)); + + if (index_cache->index->to_be_dropped + || fts_sync_index_check(sync, index_cache)) { + continue; + } + + goto begin_sync; + } + +end_sync: if (error == DB_SUCCESS && !sync->interrupted) { error = fts_sync_commit(sync); } else { fts_sync_rollback(sync); } + rw_lock_x_lock(&cache->lock); + sync->in_progress = false; + os_event_set(sync->event); + rw_lock_x_unlock(&cache->lock); + /* We need to check whether an optimize is required, for that we make copies of the two variables that control the trigger. These variables can change behind our back and we don't want to hold the @@ -4489,21 +4633,25 @@ fts_sync( return(error); } -/****************************************************************//** -Run SYNC on the table, i.e., write out data from the cache to the -FTS auxiliary INDEX table and clear the cache at the end. */ +/** Run SYNC on the table, i.e., write out data from the cache to the +FTS auxiliary INDEX table and clear the cache at the end. +@param[in,out] table fts table +@param[in] unlock_cache whether unlock cache when write node +@param[in] wait whether wait for existing sync to finish +@return DB_SUCCESS on success, error code on failure. */ UNIV_INTERN dberr_t fts_sync_table( -/*===========*/ - dict_table_t* table) /*!< in: table */ + dict_table_t* table, + bool unlock_cache, + bool wait) { dberr_t err = DB_SUCCESS; ut_ad(table->fts); if (!dict_table_is_discarded(table) && table->fts->cache) { - err = fts_sync(table->fts->cache->sync); + err = fts_sync(table->fts->cache->sync, unlock_cache, wait); } return(err); @@ -6274,7 +6422,7 @@ fts_fake_hex_to_dec( #ifdef _WIN32 ret = sscanf(tmp_id, "%016llu", &dec_id); #else - ret = sscanf(tmp_id, "%016"PRIu64, &dec_id); + ret = sscanf(tmp_id, "%016" PRIu64, &dec_id); #endif /* _WIN32 */ ut_ad(ret == 1); diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc index 2a0aa4daf12..ccb7090c61d 100644 --- a/storage/innobase/fts/fts0opt.cc +++ b/storage/innobase/fts/fts0opt.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -87,6 +87,7 @@ enum fts_msg_type_t { FTS_MSG_DEL_TABLE, /*!< Remove a table from the optimize threads work queue */ + FTS_MSG_SYNC_TABLE /*!< Sync fts cache of a table */ }; /** Compressed list of words that have been read from FTS INDEX @@ -598,7 +599,7 @@ fts_zip_read_word( /* Finished decompressing block. */ if (zip->zp->avail_in == 0) { - /* Free the block thats been decompressed. */ + /* Free the block that's been decompressed. */ if (zip->pos > 0) { ulint prev = zip->pos - 1; @@ -2652,6 +2653,39 @@ fts_optimize_remove_table( os_event_free(event); } +/** Send sync fts cache for the table. +@param[in] table table to sync */ +UNIV_INTERN +void +fts_optimize_request_sync_table( + dict_table_t* table) +{ + fts_msg_t* msg; + table_id_t* table_id; + + /* if the optimize system not yet initialized, return */ + if (!fts_optimize_wq) { + return; + } + + /* FTS optimizer thread is already exited */ + if (fts_opt_start_shutdown) { + ib_logf(IB_LOG_LEVEL_INFO, + "Try to sync table %s after FTS optimize" + " thread exiting.", table->name); + return; + } + + msg = fts_optimize_create_msg(FTS_MSG_SYNC_TABLE, NULL); + + table_id = static_cast<table_id_t*>( + mem_heap_alloc(msg->heap, sizeof(table_id_t))); + *table_id = table->id; + msg->ptr = table_id; + + ib_wqueue_add(fts_optimize_wq, msg, msg->heap); +} + /**********************************************************************//** Find the slot for a particular table. @return slot if found else NULL. */ @@ -2932,6 +2966,25 @@ fts_optimize_need_sync( } #endif +/** Sync fts cache of a table +@param[in] table_id table id */ +void +fts_optimize_sync_table( + table_id_t table_id) +{ + dict_table_t* table = NULL; + + table = dict_table_open_on_id(table_id, FALSE, DICT_TABLE_OP_NORMAL); + + if (table) { + if (dict_table_has_fts_index(table) && table->fts->cache) { + fts_sync_table(table, true, false); + } + + dict_table_close(table, FALSE, FALSE); + } +} + /**********************************************************************//** Optimize all FTS tables. @return Dummy return */ @@ -3053,6 +3106,11 @@ fts_optimize_thread( ((fts_msg_del_t*) msg->ptr)->event); break; + case FTS_MSG_SYNC_TABLE: + fts_optimize_sync_table( + *static_cast<table_id_t*>(msg->ptr)); + break; + default: ut_error; } @@ -3079,26 +3137,7 @@ fts_optimize_thread( ib_vector_get(tables, i)); if (slot->state != FTS_STATE_EMPTY) { - dict_table_t* table = NULL; - - /*slot->table may be freed, so we try to open - table by slot->table_id.*/ - table = dict_table_open_on_id( - slot->table_id, FALSE, - DICT_TABLE_OP_NORMAL); - - if (table) { - - if (dict_table_has_fts_index(table)) { - fts_sync_table(table); - } - - if (table->fts) { - fts_free(table); - } - - dict_table_close(table, FALSE, FALSE); - } + fts_optimize_sync_table(slot->table_id); } } } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 78812d6283b..d0de4300540 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -1,10 +1,10 @@ /***************************************************************************** -Copyright (c) 2000, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2013, 2014 SkySQL Ab. All Rights Reserved. +Copyright (c) 2013, 2016, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -3562,6 +3562,14 @@ innobase_change_buffering_inited_ok: innobase_open_files = tc_size; } } + + if (innobase_open_files > (long) tc_size) { + fprintf(stderr, + "innodb_open_files should not be greater" + " than the open_files_limit.\n"); + innobase_open_files = tc_size; + } + srv_max_n_open_files = (ulint) innobase_open_files; srv_innodb_status = (ibool) innobase_create_status_file; @@ -5643,20 +5651,14 @@ table_opened: prebuilt->clust_index_was_generated = FALSE; if (UNIV_UNLIKELY(primary_key >= MAX_KEY)) { - sql_print_error("Table %s has a primary key in " - "InnoDB data dictionary, but not " - "in MySQL!", name); + ib_table->dict_frm_mismatch = DICT_FRM_NO_PK; /* This mismatch could cause further problems if not attended, bring this to the user's attention by printing a warning in addition to log a message in the errorlog */ - push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, - ER_NO_SUCH_INDEX, - "InnoDB: Table %s has a " - "primary key in InnoDB data " - "dictionary, but not in " - "MySQL!", name); + + ib_push_frm_error(thd, ib_table, table, 0, true); /* If primary_key >= MAX_KEY, its (primary_key) value could be out of bound if continue to index @@ -5703,27 +5705,14 @@ table_opened: } } else { if (primary_key != MAX_KEY) { - sql_print_error( - "Table %s has no primary key in InnoDB data " - "dictionary, but has one in MySQL! If you " - "created the table with a MySQL version < " - "3.23.54 and did not define a primary key, " - "but defined a unique key with all non-NULL " - "columns, then MySQL internally treats that " - "key as the primary key. You can fix this " - "error by dump + DROP + CREATE + reimport " - "of the table.", name); + + ib_table->dict_frm_mismatch = DICT_NO_PK_FRM_HAS; /* This mismatch could cause further problems if not attended, bring this to the user attention by printing a warning in addition to log a message in the errorlog */ - push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, - ER_NO_SUCH_INDEX, - "InnoDB: Table %s has no " - "primary key in InnoDB data " - "dictionary, but has one in " - "MySQL!", name); + ib_push_frm_error(thd, ib_table, table, 0, true); } prebuilt->clust_index_was_generated = TRUE; @@ -12853,12 +12842,8 @@ ha_innobase::info_low( } if (table->s->keys != num_innodb_index) { - sql_print_error("InnoDB: Table %s contains %lu " - "indexes inside InnoDB, which " - "is different from the number of " - "indexes %u defined in the MySQL ", - ib_table->name, num_innodb_index, - table->s->keys); + ib_table->dict_frm_mismatch = DICT_FRM_INCONSISTENT_KEYS; + ib_push_frm_error(user_thd, ib_table, table, num_innodb_index, true); } if (!(flag & HA_STATUS_NO_LOCK)) { @@ -12878,15 +12863,8 @@ ha_innobase::info_low( dict_index_t* index = innobase_get_index(i); if (index == NULL) { - sql_print_error("Table %s contains fewer " - "indexes inside InnoDB than " - "are defined in the MySQL " - ".frm file. Have you mixed up " - ".frm files from different " - "installations? See " - REFMAN - "innodb-troubleshooting.html\n", - ib_table->name); + ib_table->dict_frm_mismatch = DICT_FRM_INCONSISTENT_KEYS; + ib_push_frm_error(user_thd, ib_table, table, num_innodb_index, true); break; } @@ -13080,7 +13058,7 @@ ha_innobase::optimize( if (innodb_optimize_fulltext_only) { if (prebuilt->table->fts && prebuilt->table->fts->cache && !dict_table_is_discarded(prebuilt->table)) { - fts_sync_table(prebuilt->table); + fts_sync_table(prebuilt->table, false, true); fts_optimize_table(prebuilt->table); } return(HA_ADMIN_OK); @@ -19437,3 +19415,96 @@ ib_push_warning( my_free(buf); va_end(args); } + +/********************************************************************//** +Helper function to push frm mismatch error to error log and +if needed to sql-layer. */ +UNIV_INTERN +void +ib_push_frm_error( +/*==============*/ + THD* thd, /*!< in: MySQL thd */ + dict_table_t* ib_table, /*!< in: InnoDB table */ + TABLE* table, /*!< in: MySQL table */ + ulint n_keys, /*!< in: InnoDB #keys */ + bool push_warning) /*!< in: print warning ? */ +{ + switch (ib_table->dict_frm_mismatch) { + case DICT_FRM_NO_PK: + sql_print_error("Table %s has a primary key in " + "InnoDB data dictionary, but not " + "in MySQL!" + " Have you mixed up " + ".frm files from different " + "installations? See " + REFMAN + "innodb-troubleshooting.html\n", + ib_table->name); + + if (push_warning) { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + ER_NO_SUCH_INDEX, + "InnoDB: Table %s has a " + "primary key in InnoDB data " + "dictionary, but not in " + "MySQL!", ib_table->name); + } + break; + case DICT_NO_PK_FRM_HAS: + sql_print_error( + "Table %s has no primary key in InnoDB data " + "dictionary, but has one in MySQL! If you " + "created the table with a MySQL version < " + "3.23.54 and did not define a primary key, " + "but defined a unique key with all non-NULL " + "columns, then MySQL internally treats that " + "key as the primary key. You can fix this " + "error by dump + DROP + CREATE + reimport " + "of the table.", ib_table->name); + + if (push_warning) { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + ER_NO_SUCH_INDEX, + "InnoDB: Table %s has no " + "primary key in InnoDB data " + "dictionary, but has one in " + "MySQL!", + ib_table->name); + } + break; + + case DICT_FRM_INCONSISTENT_KEYS: + sql_print_error("InnoDB: Table %s contains %lu " + "indexes inside InnoDB, which " + "is different from the number of " + "indexes %u defined in the MySQL " + " Have you mixed up " + ".frm files from different " + "installations? See " + REFMAN + "innodb-troubleshooting.html\n", + ib_table->name, n_keys, + table->s->keys); + + if (push_warning) { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + ER_NO_SUCH_INDEX, + "InnoDB: Table %s contains %lu " + "indexes inside InnoDB, which " + "is different from the number of " + "indexes %u defined in the MySQL ", + ib_table->name, n_keys, + table->s->keys); + } + break; + + case DICT_FRM_CONSISTENT: + default: + sql_print_error("InnoDB: Table %s is consistent " + "on InnoDB data dictionary and MySQL " + " FRM file.", + ib_table->name); + ut_error; + break; + } +} diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 87fe658fc17..0c3d4a5e099 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2016, 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 @@ -680,3 +681,16 @@ innobase_copy_frm_flags_from_table_share( /*=====================================*/ dict_table_t* innodb_table, /*!< in/out: InnoDB table */ const TABLE_SHARE* table_share); /*!< in: table share */ + +/********************************************************************//** +Helper function to push frm mismatch error to error log and +if needed to sql-layer. */ +UNIV_INTERN +void +ib_push_frm_error( +/*==============*/ + THD* thd, /*!< in: MySQL thd */ + dict_table_t* ib_table, /*!< in: InnoDB table */ + TABLE* table, /*!< in: MySQL table */ + ulint n_keys, /*!< in: InnoDB #keys */ + bool push_warning); /*!< in: print warning ? */ diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index e66fc07ff10..bdc2070e056 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -439,6 +439,20 @@ ha_innobase::check_if_supported_inplace_alter( } } + ulint n_indexes = UT_LIST_GET_LEN((prebuilt->table)->indexes); + + /* If InnoDB dictionary and MySQL frm file are not consistent + use "Copy" method. */ + if (prebuilt->table->dict_frm_mismatch) { + + ha_alter_info->unsupported_reason = innobase_get_err_msg( + ER_NO_SUCH_INDEX); + ib_push_frm_error(user_thd, prebuilt->table, altered_table, + n_indexes, true); + + DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED); + } + /* We should be able to do the operation in-place. See if we can do it online (LOCK=NONE). */ bool online = true; diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index f6b080b713d..374f61d74c1 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -2,6 +2,7 @@ Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2015, 2016, 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 @@ -906,6 +907,18 @@ if table->memcached_sync_count == DICT_TABLE_IN_DDL means there's DDL running on the table, DML from memcached will be blocked. */ #define DICT_TABLE_IN_DDL -1 +/** These are used when MySQL FRM and InnoDB data dictionary are +in inconsistent state. */ +typedef enum { + DICT_FRM_CONSISTENT = 0, /*!< Consistent state */ + DICT_FRM_NO_PK = 1, /*!< MySQL has no primary key + but InnoDB dictionary has + non-generated one. */ + DICT_NO_PK_FRM_HAS = 2, /*!< MySQL has primary key but + InnoDB dictionary has not. */ + DICT_FRM_INCONSISTENT_KEYS = 3 /*!< Key count mismatch */ +} dict_frm_t; + /** Data structure for a database table. Most fields will be initialized to 0, NULL or FALSE in dict_mem_table_create(). */ struct dict_table_t{ @@ -964,6 +977,10 @@ struct dict_table_t{ /*!< True if the table belongs to a system database (mysql, information_schema or performance_schema) */ + dict_frm_t dict_frm_mismatch; + /*!< !DICT_FRM_CONSISTENT==0 if data + dictionary information and + MySQL FRM information mismatch. */ #ifndef UNIV_HOTBACKUP hash_node_t name_hash; /*!< hash chain node */ hash_node_t id_hash; /*!< hash chain node */ diff --git a/storage/innobase/include/fts0fts.h b/storage/innobase/include/fts0fts.h index d54ed281d9a..9f7b0216d9b 100644 --- a/storage/innobase/include/fts0fts.h +++ b/storage/innobase/include/fts0fts.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -724,6 +724,13 @@ fts_optimize_remove_table( /*======================*/ dict_table_t* table); /*!< in: table to remove */ +/** Send sync fts cache for the table. +@param[in] table table to sync */ +UNIV_INTERN +void +fts_optimize_request_sync_table( + dict_table_t* table); + /**********************************************************************//** Signal the optimize thread to prepare for shutdown. */ UNIV_INTERN @@ -826,15 +833,18 @@ fts_drop_index_split_tables( dict_index_t* index) /*!< in: fts instance */ __attribute__((nonnull, warn_unused_result)); -/****************************************************************//** -Run SYNC on the table, i.e., write out data from the cache to the -FTS auxiliary INDEX table and clear the cache at the end. */ +/** Run SYNC on the table, i.e., write out data from the cache to the +FTS auxiliary INDEX table and clear the cache at the end. +@param[in,out] table fts table +@param[in] unlock_cache whether unlock cache when write node +@param[in] wait whether wait for existing sync to finish +@return DB_SUCCESS on success, error code on failure. */ UNIV_INTERN dberr_t fts_sync_table( -/*===========*/ - dict_table_t* table) /*!< in: table */ - __attribute__((nonnull)); + dict_table_t* table, + bool unlock_cache, + bool wait); /****************************************************************//** Free the query graph but check whether dict_sys->mutex is already diff --git a/storage/innobase/include/fts0priv.ic b/storage/innobase/include/fts0priv.ic index 2d07c60f980..ec61691870b 100644 --- a/storage/innobase/include/fts0priv.ic +++ b/storage/innobase/include/fts0priv.ic @@ -53,7 +53,7 @@ fts_write_object_id( /* Use this to construct old(5.6.14 and 5.7.3) windows ambiguous aux table names */ DBUG_EXECUTE_IF("innodb_test_wrong_windows_fts_aux_table_name", - return(sprintf(str, "%016"PRIu64, id));); + return(sprintf(str, "%016" PRIu64, id));); DBUG_EXECUTE_IF("innodb_test_wrong_fts_aux_table_name", return(sprintf(str, UINT64PFx, id));); @@ -66,7 +66,7 @@ fts_write_object_id( // FIXME: Use ut_snprintf(), so does following one. return(sprintf(str, "%016llu", id)); #else /* _WIN32 */ - return(sprintf(str, "%016"PRIu64, id)); + return(sprintf(str, "%016" PRIu64, id)); #endif /* _WIN32 */ } diff --git a/storage/innobase/include/fts0types.h b/storage/innobase/include/fts0types.h index 64677428331..e495fe72a60 100644 --- a/storage/innobase/include/fts0types.h +++ b/storage/innobase/include/fts0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -122,7 +122,11 @@ struct fts_sync_t { doc_id_t max_doc_id; /*!< The doc id at which the cache was noted as being full, we use this to set the upper_limit field */ - ib_time_t start_time; /*!< SYNC start time */ + ib_time_t start_time; /*!< SYNC start time */ + bool in_progress; /*!< flag whether sync is in progress.*/ + bool unlock_cache; /*!< flag whether unlock cache when + write fts node */ + os_event_t event; /*!< sync finish event */ }; /** The cache for the FTS system. It is a memory-based inverted index @@ -165,7 +169,6 @@ struct fts_cache_t { objects, they are recreated after a SYNC is completed */ - ib_alloc_t* self_heap; /*!< This heap is the heap out of which an instance of the cache itself was created. Objects created using @@ -212,6 +215,7 @@ struct fts_node_t { ulint ilist_size_alloc; /*!< Allocated size of ilist in bytes */ + bool synced; /*!< flag whether the node is synced */ }; /** A tokenizer word. Contains information about one word. */ diff --git a/storage/innobase/include/os0sync.h b/storage/innobase/include/os0sync.h index e192a3a6c94..95e724ec48e 100644 --- a/storage/innobase/include/os0sync.h +++ b/storage/innobase/include/os0sync.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -466,28 +466,7 @@ amount to decrement. */ # define os_atomic_decrement_uint64(ptr, amount) \ os_atomic_decrement(ptr, amount) -# if defined(HAVE_IB_GCC_ATOMIC_TEST_AND_SET) - -/** Do an atomic test-and-set. -@param[in,out] ptr Memory location to set to non-zero -@return the previous value */ -inline -lock_word_t -os_atomic_test_and_set(volatile lock_word_t* ptr) -{ - return(__atomic_test_and_set(ptr, __ATOMIC_ACQUIRE)); -} - -/** Do an atomic clear. -@param[in,out] ptr Memory location to set to zero */ -inline -void -os_atomic_clear(volatile lock_word_t* ptr) -{ - __atomic_clear(ptr, __ATOMIC_RELEASE); -} - -# elif defined(HAVE_ATOMIC_BUILTINS) +# if defined(IB_STRONG_MEMORY_MODEL) /** Do an atomic test and set. @param[in,out] ptr Memory location to set to non-zero @@ -516,6 +495,27 @@ os_atomic_clear(volatile lock_word_t* ptr) return(__sync_lock_test_and_set(ptr, 0)); } +# elif defined(HAVE_IB_GCC_ATOMIC_TEST_AND_SET) + +/** Do an atomic test-and-set. +@param[in,out] ptr Memory location to set to non-zero +@return the previous value */ +inline +lock_word_t +os_atomic_test_and_set(volatile lock_word_t* ptr) +{ + return(__atomic_test_and_set(ptr, __ATOMIC_ACQUIRE)); +} + +/** Do an atomic clear. +@param[in,out] ptr Memory location to set to zero */ +inline +void +os_atomic_clear(volatile lock_word_t* ptr) +{ + __atomic_clear(ptr, __ATOMIC_RELEASE); +} + # else # error "Unsupported platform" diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 8347425c5c0..e63aa41dfa1 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -44,7 +44,7 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MINOR 6 -#define INNODB_VERSION_BUGFIX 29 +#define INNODB_VERSION_BUGFIX 30 /* The following is the InnoDB version as shown in SELECT plugin_version FROM information_schema.plugins; diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index a1a7e91bb2f..adde6517636 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -2696,7 +2696,7 @@ try_again: "Error in system call pread(). The operating" " system error number is %lu.",(ulint) errno); } else { - /* Partial read occured */ + /* Partial read occurred */ ib_logf(IB_LOG_LEVEL_ERROR, "Tried to read " ULINTPF " bytes at offset " UINT64PF ". Was only able to read %ld.", @@ -2827,7 +2827,7 @@ try_again: "Error in system call pread(). The operating" " system error number is %lu.",(ulint) errno); } else { - /* Partial read occured */ + /* Partial read occurred */ ib_logf(IB_LOG_LEVEL_ERROR, "Tried to read " ULINTPF " bytes at offset " UINT64PF ". Was only able to read %ld.", diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 74978a680af..14806ceb3b9 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -1986,7 +1986,8 @@ wait_again: if (max_doc_id && err == DB_SUCCESS) { /* Sync fts cache for other fts indexes to keep all fts indexes consistent in sync_doc_id. */ - err = fts_sync_table(const_cast<dict_table_t*>(new_table)); + err = fts_sync_table(const_cast<dict_table_t*>(new_table), + false, true); if (err == DB_SUCCESS) { fts_update_next_doc_id( diff --git a/storage/maria/ma_packrec.c b/storage/maria/ma_packrec.c index a541a657ed2..6a4e7ea99cf 100644 --- a/storage/maria/ma_packrec.c +++ b/storage/maria/ma_packrec.c @@ -1204,7 +1204,7 @@ static void decode_bytes(MARIA_COLUMNDEF *rec,MARIA_BIT_BUFF *bit_buff, /* This means that the Huffman code must be longer than table_bits. */ pos=decode_tree->table+low_byte; bits-=table_bits; - /* NOTE: decode_bytes_test_bit() is a macro wich contains a break !!! */ + /* NOTE: decode_bytes_test_bit() is a macro which contains a break !!! */ for (;;) { low_byte=(uint) (bit_buff->current_byte >> (bits-8)); diff --git a/storage/mroonga/mrn_table.cpp b/storage/mroonga/mrn_table.cpp index ebd3e7e0528..ca5646b3e0b 100644 --- a/storage/mroonga/mrn_table.cpp +++ b/storage/mroonga/mrn_table.cpp @@ -272,7 +272,7 @@ void mrn_get_partition_info(const char *table_name, uint table_name_length, #define MRN_PARAM_STR(title_name, param_name) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info", ("mroonga "title_name" start")); \ + DBUG_PRINT("info", ("mroonga " title_name " start")); \ if (!share->param_name) \ { \ if ((share->param_name = mrn_get_string_between_quote( \ @@ -284,7 +284,7 @@ void mrn_get_partition_info(const char *table_name, uint table_name_length, MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info", ("mroonga "title_name"=%s", share->param_name)); \ + DBUG_PRINT("info", ("mroonga " title_name "=%s", share->param_name)); \ } \ break; \ } @@ -292,7 +292,7 @@ void mrn_get_partition_info(const char *table_name, uint table_name_length, #define MRN_PARAM_STR_LIST(title_name, param_name, param_pos) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info", ("mroonga "title_name" start")); \ + DBUG_PRINT("info", ("mroonga " title_name " start")); \ if (share->param_name && !share->param_name[param_pos]) \ { \ if ((share->param_name[param_pos] = mrn_get_string_between_quote( \ @@ -305,7 +305,7 @@ void mrn_get_partition_info(const char *table_name, uint table_name_length, MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info", ("mroonga "title_name"[%d]=%s", param_pos, \ + DBUG_PRINT("info", ("mroonga " title_name "[%d]=%s", param_pos, \ share->param_name[param_pos])); \ } \ break; \ diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 6befe3b2d7a..766f8411ca1 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. 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 @@ -197,7 +197,8 @@ static int ftb_query_add_word(MYSQL_FTPARSER_PARAM *param, ftbw= (FTB_WORD *)alloc_root(&ftb_param->ftb->mem_root, sizeof(FTB_WORD) + (info->trunc ? HA_MAX_KEY_BUFF : - word_len * ftb_param->ftb->charset->mbmaxlen + + (word_len + 1) * + ftb_param->ftb->charset->mbmaxlen + HA_FT_WLEN + ftb_param->ftb->info->s->rec_reflength)); ftbw->len= word_len + 1; diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 2fe519da794..d97aa503d42 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -2405,7 +2405,7 @@ maria_declare_plugin_end; @return The error code. The engine_data and engine_callback will be set to 0. @retval TRUE Success - @retval FALSE An error occured + @retval FALSE An error occurred */ my_bool ha_myisam::register_query_cache_table(THD *thd, char *table_name, diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c index d1ad911d334..eeadb70ae81 100644 --- a/storage/myisam/mi_packrec.c +++ b/storage/myisam/mi_packrec.c @@ -1158,7 +1158,7 @@ static void decode_bytes(MI_COLUMNDEF *rec,MI_BIT_BUFF *bit_buff,uchar *to, /* This means that the Huffman code must be longer than table_bits. */ pos=decode_tree->table+low_byte; bits-=table_bits; - /* NOTE: decode_bytes_test_bit() is a macro wich contains a break !!! */ + /* NOTE: decode_bytes_test_bit() is a macro which contains a break !!! */ for (;;) { low_byte=(uint) (bit_buff->current_byte >> (bits-8)); diff --git a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c index d549dd76037..7ce03ca9485 100644 --- a/storage/myisam/myisamlog.c +++ b/storage/myisam/myisamlog.c @@ -266,7 +266,7 @@ static void get_options(register int *argc, register char ***argv) puts(" -u \"update\" -v \"verbose\" -w \"write file\""); puts(" -D \"myisam compiled with DBUG\" -P \"processes\""); puts("\nOne can give a second and a third '-v' for more verbose."); - puts("Normaly one does a update (-u)."); + puts("Normally one does a update (-u)."); puts("If a recover is done all writes and all possibly updates and deletes is done\nand errors are only counted."); puts("If one gives table names as arguments only these tables will be updated\n"); help=1; diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index 93722162d86..1a575a2ceea 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2011, Oracle and/or its affiliates + Copyright (c) 2009, 2016, MariaDB 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 diff --git a/storage/ndb/include/ndbapi/NdbEventOperation.hpp b/storage/ndb/include/ndbapi/NdbEventOperation.hpp index 5f41f30a38b..62a85bb3149 100644 --- a/storage/ndb/include/ndbapi/NdbEventOperation.hpp +++ b/storage/ndb/include/ndbapi/NdbEventOperation.hpp @@ -34,7 +34,7 @@ class NdbEventOperationImpl; * Ndb::createEventOperation() * - execute() starts the event flow. Use Ndb::pollEvents() to wait * for an event to occur. Use Ndb::nextEvent() to iterate - * through the events that have occured. + * through the events that have occurred. * - The instance is removed by Ndb::dropEventOperation() * * For more info see: @@ -63,7 +63,7 @@ class NdbEventOperationImpl; * - Event code does not check table schema version. Make sure to drop events * after table is dropped. Will be fixed in later * versions. - * - If a node failure has occured not all events will be recieved + * - If a node failure has occurred not all events will be recieved * anymore. Drop NdbEventOperation and Create again after nodes are up * again. Will be fixed in later versions. * @@ -167,7 +167,7 @@ public: bool isConsistent() const; /** - * Query for occured event type. + * Query for occurred event type. * * @note Only valid after Ndb::nextEvent() has been called and * returned a not NULL value diff --git a/storage/ndb/include/ndbapi/NdbOperation.hpp b/storage/ndb/include/ndbapi/NdbOperation.hpp index 9049c8cdd22..9b2b2f92818 100644 --- a/storage/ndb/include/ndbapi/NdbOperation.hpp +++ b/storage/ndb/include/ndbapi/NdbOperation.hpp @@ -761,9 +761,9 @@ public: const NdbError & getNdbError() const; /** - * Get the method number where the error occured. + * Get the method number where the error occurred. * - * @return method number where the error occured. + * @return method number where the error occurred. */ int getNdbErrorLine(); diff --git a/storage/ndb/include/ndbapi/NdbTransaction.hpp b/storage/ndb/include/ndbapi/NdbTransaction.hpp index f3eea49d19d..b11ce87e680 100644 --- a/storage/ndb/include/ndbapi/NdbTransaction.hpp +++ b/storage/ndb/include/ndbapi/NdbTransaction.hpp @@ -521,9 +521,9 @@ public: NdbOperation* getNdbErrorOperation(); /** - * Get the method number where the latest error occured. + * Get the method number where the latest error occurred. * - * @return Line number where latest error occured. + * @return Line number where latest error occurred. */ int getNdbErrorLine(); diff --git a/storage/ndb/include/newtonapi/dba.h b/storage/ndb/include/newtonapi/dba.h index b02a7abb8af..c38545c9ec8 100644 --- a/storage/ndb/include/newtonapi/dba.h +++ b/storage/ndb/include/newtonapi/dba.h @@ -124,7 +124,7 @@ typedef enum { DBA_SCHEMA_ERROR = 4, /**< Table already exists */ DBA_INSUFFICIENT_SPACE = 5, /**< The DB is full */ - DBA_TEMPORARY_ERROR = 6, /**< Some temporary problem occured */ + DBA_TEMPORARY_ERROR = 6, /**< Some temporary problem occurred */ DBA_TIMEOUT = 7, /**< The request timed out, probably due to dead-lock */ DBA_OVERLOAD = 8, /**< The DB is overloaded */ diff --git a/storage/ndb/src/cw/cpcd/CPCD.hpp b/storage/ndb/src/cw/cpcd/CPCD.hpp index 3c2934c0f49..38c498f3b67 100644 --- a/storage/ndb/src/cw/cpcd/CPCD.hpp +++ b/storage/ndb/src/cw/cpcd/CPCD.hpp @@ -148,7 +148,7 @@ public: * * @return * - 0 if successful - - -1 and sets errno if an error occured + - -1 and sets errno if an error occurred */ int writePid(int pid); @@ -308,7 +308,7 @@ public: * - true if the addition was successful, * - false if not * - RequestStatus will be filled in with a suitable error - * if an error occured. + * if an error occurred. */ bool defineProcess(RequestStatus *rs, Process * arg); @@ -320,7 +320,7 @@ public: * - true if the removal was successful, * - false if not * - The RequestStatus will be filled in with a suitable error - * if an error occured. + * if an error occurred. */ bool undefineProcess(RequestStatus *rs, int id); @@ -334,7 +334,7 @@ public: * - true if the marking was successful * - false if not * - RequestStatus will be filled in with a suitable error - * if an error occured. + * if an error occurred. */ bool startProcess(RequestStatus *rs, int id); @@ -344,7 +344,7 @@ public: * - true if the marking was successful * - false if not * - The RequestStatus will be filled in with a suitable error - * if an error occured. + * if an error occurred. */ bool stopProcess(RequestStatus *rs, int id); diff --git a/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp b/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp index da614b0276c..e63d7e523b9 100644 --- a/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp +++ b/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp @@ -8107,7 +8107,7 @@ void Dbacc::seizeOverRec(Signal* signal) { /** - * A ZPAGESIZE_ERROR has occured, out of index pages + * A ZPAGESIZE_ERROR has occurred, out of index pages * Print some debug info if debug compiled */ void Dbacc::zpagesize_error(const char* where){ diff --git a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index e0e0a496e0a..c80e1455b31 100644 --- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -10860,7 +10860,7 @@ Dbdict::execSUB_REMOVE_REF(Signal* signal) OpSubEventPtr subbPtr; c_opSubEvent.getPtr(subbPtr, ref->senderData); if (err == 1407) { - // conf this since this may occur if a nodefailure has occured + // conf this since this may occur if a nodefailure has occurred // earlier so that the systable was not cleared SubRemoveConf* conf = (SubRemoveConf*) signal->getDataPtrSend(); conf->senderRef = reference(); diff --git a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index f4b0e07854c..419725b3487 100644 --- a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -6941,7 +6941,7 @@ void Dbtc::execSCAN_HBREP(Signal* signal) }//execSCAN_HBREP() /*--------------------------------------------------------------------------*/ -/* Timeout has occured on a fragment which means a scan has timed out. */ +/* Timeout has occurred on a fragment which means a scan has timed out. */ /* If this is true we have an error in LQH/ACC. */ /*--------------------------------------------------------------------------*/ void Dbtc::timeOutFoundFragLab(Signal* signal, UintR TscanConPtr) diff --git a/storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp b/storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp index 1a309e34c2d..a6b05283521 100644 --- a/storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp +++ b/storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp @@ -3817,7 +3817,7 @@ void Qmgr::systemErrorLab(Signal* signal, Uint32 line, const char * message) // Broadcast that this node is failing to other nodes failReport(signal, getOwnNodeId(), (UintR)ZTRUE, FailRep::ZOWN_FAILURE); - // If it's known why shutdown occured + // If it's known why shutdown occurred // an error message has been passed to this function progError(line, NDBD_EXIT_NDBREQUIRE, message); diff --git a/storage/ndb/src/kernel/vm/Emulator.cpp b/storage/ndb/src/kernel/vm/Emulator.cpp index 6610d88fba0..ca278ccbc3c 100644 --- a/storage/ndb/src/kernel/vm/Emulator.cpp +++ b/storage/ndb/src/kernel/vm/Emulator.cpp @@ -246,7 +246,7 @@ NdbShutdown(NdbShutdownType type, } if(type != NST_Normal && type != NST_Restart){ - // Signal parent that error occured during startup + // Signal parent that error occurred during startup if (type == NST_ErrorHandlerStartup) kill(getppid(), SIGUSR1); g_eventLogger.info("Error handler shutdown completed - %s", exitAbort); diff --git a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp index 255a3e962ea..49533667b39 100644 --- a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp +++ b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp @@ -627,7 +627,7 @@ private: NodeId m_master_node; /** - * Handles the thread wich upon a 'Node is started' event will + * Handles the thread which upon a 'Node is started' event will * set the node's previous loglevel settings. */ struct NdbThread* _logLevelThread; diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp index e3cf3488ce7..a647d387142 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp @@ -437,7 +437,7 @@ public: bool setTransporter(class Ndb * ndb, class TransporterFacade * tf); bool setTransporter(class TransporterFacade * tf); - // To abstract the stuff thats made in all create/drop/lists below + // To abstract the stuff that's made in all create/drop/lists below int dictSignal(NdbApiSignal* signal, LinearSectionPtr ptr[3], int secs, int nodeId, // -1 any, 0 = master, >1 = specified WaitSignalType wst, diff --git a/storage/ndb/src/ndbapi/NdbTransaction.cpp b/storage/ndb/src/ndbapi/NdbTransaction.cpp index f446267f3b2..7c3e360b9fc 100644 --- a/storage/ndb/src/ndbapi/NdbTransaction.cpp +++ b/storage/ndb/src/ndbapi/NdbTransaction.cpp @@ -1747,7 +1747,7 @@ transactions. } /**********************************************************************/ - /* A serious error has occured. This could be due to deadlock or */ + /* A serious error has occurred. This could be due to deadlock or */ /* lack of resources or simply a programming error in NDB. This */ /* transaction will be aborted. Actually it has already been */ /* and we only need to report completion and return with the */ @@ -1869,7 +1869,7 @@ NdbTransaction::receiveTCKEY_FAILCONF(const TcKeyFailConf * failConf) */ if(checkState_TransId(&failConf->transId1)){ /* - A node failure of the TC node occured. The transaction has + A node failure of the TC node occurred. The transaction has been committed. */ theCommitStatus = Committed; diff --git a/storage/ndb/src/ndbapi/Ndbif.cpp b/storage/ndb/src/ndbapi/Ndbif.cpp index ba3aebc5800..3608ec962f9 100644 --- a/storage/ndb/src/ndbapi/Ndbif.cpp +++ b/storage/ndb/src/ndbapi/Ndbif.cpp @@ -1315,7 +1315,7 @@ int sendPollNdb(int aMillisecondNumber, int minNoOfEventsToWakeup = 1, int force Remark: First send all prepared operations and then check if there are any transactions already completed. Wait for not completed transactions until the specified number have completed or until the - timeout has occured. Timeout zero means no waiting time. + timeout has occurred. Timeout zero means no waiting time. ******************************************************************************/ int Ndb::sendPollNdb(int aMillisecondNumber, int minNoOfEventsToWakeup, int forceSend) @@ -1359,7 +1359,7 @@ int pollNdb(int aMillisecondNumber, int minNoOfEventsToWakeup); Remark: Check if there are any transactions already completed. Wait for not completed transactions until the specified number have completed or - until the timeout has occured. Timeout zero means no waiting time. + until the timeout has occurred. Timeout zero means no waiting time. ******************************************************************************/ int Ndb::pollNdb(int aMillisecondNumber, int minNoOfEventsToWakeup) diff --git a/storage/ndb/test/include/NDBT_Error.hpp b/storage/ndb/test/include/NDBT_Error.hpp index 1d057d6b90f..9b04b76cf0e 100644 --- a/storage/ndb/test/include/NDBT_Error.hpp +++ b/storage/ndb/test/include/NDBT_Error.hpp @@ -79,7 +79,7 @@ private: // // ERR prints an NdbError object together with a description of where the -// error occured +// error occurred // #define ERR_OUT(where, error) \ { where << "ERROR: " << error.code << " " \ diff --git a/storage/ndb/test/ndbapi/flexAsynch.cpp b/storage/ndb/test/ndbapi/flexAsynch.cpp index d24965a9134..182baec2b91 100644 --- a/storage/ndb/test/ndbapi/flexAsynch.cpp +++ b/storage/ndb/test/ndbapi/flexAsynch.cpp @@ -618,7 +618,7 @@ executeCallback(int result, NdbConnection* NdbObject, void* aObject) ndbout_c("execute: %s", NdbObject->getNdbError().message); }//if(retCode == 3) - // ndbout << "Error occured in poll:" << endl; + // ndbout << "Error occurred in poll:" << endl; // ndbout << NdbObject->getNdbError() << endl; failed++ ; return; diff --git a/storage/ndb/test/ndbapi/flexTimedAsynch.cpp b/storage/ndb/test/ndbapi/flexTimedAsynch.cpp index 2a846008c56..c3b176fbaa8 100644 --- a/storage/ndb/test/ndbapi/flexTimedAsynch.cpp +++ b/storage/ndb/test/ndbapi/flexTimedAsynch.cpp @@ -512,7 +512,7 @@ executeCallback(int result, NdbConnection* NdbObject, void* aObject) ndbout_c("execute: %s", NdbObject->getNdbError().message); }//if(retCode == 3) - // ndbout << "Error occured in poll:" << NdbObject->getNdbError() << + // ndbout << "Error occurred in poll:" << NdbObject->getNdbError() << // " ErrorCode = " << NdbObject->getNdbError() << endl; ndbout << "executeCallback threadInfo->transactionCompleted = " << threadInfo->transactionCompleted << endl; diff --git a/storage/ndb/test/ndbapi/initronja.cpp b/storage/ndb/test/ndbapi/initronja.cpp index 9b96e7e8625..2aa7d575710 100644 --- a/storage/ndb/test/ndbapi/initronja.cpp +++ b/storage/ndb/test/ndbapi/initronja.cpp @@ -302,13 +302,13 @@ inline int InsertRecords(Ndb* pNdb, int nNoRecords){ return 0; error_handler1: - ndbout << "Error occured in getNdbOperation " << endl; + ndbout << "Error occurred in getNdbOperation " << endl; ndbout << MyTransaction->getNdbError() << endl; pNdb->closeTransaction(MyTransaction); return -1 ; error_handler2: - ndbout << "Error occured in defining operation " << endl; + ndbout << "Error occurred in defining operation " << endl; ndbout << MyOperation[count_tables]->getNdbError() << endl; pNdb->closeTransaction(MyTransaction); return -1 ; @@ -318,13 +318,13 @@ error_handler3: return -1 ; error_handler4: - ndbout << "Error occured in equal " << endl; + ndbout << "Error occurred in equal " << endl; ndbout << MyOperation[count_tables]->getNdbError() << endl; pNdb->closeTransaction(MyTransaction); return -1 ; error_handler5: - ndbout << "Error occured in get/setValue " << endl; + ndbout << "Error occurred in get/setValue " << endl; ndbout << MyOperation[count_tables]->getNdbError() << endl; pNdb->closeTransaction(MyTransaction); return -1 ; diff --git a/storage/ndb/test/ndbapi/testNdbApi.cpp b/storage/ndb/test/ndbapi/testNdbApi.cpp index 0d631023f75..c4d313a267b 100644 --- a/storage/ndb/test/ndbapi/testNdbApi.cpp +++ b/storage/ndb/test/ndbapi/testNdbApi.cpp @@ -1011,7 +1011,7 @@ int runCheckGetNdbErrorOperation(NDBT_Context* ctx, NDBT_Step* step){ for(int a = 0; a<pTab->getNoOfColumns(); a++){ if (pTab->getColumn(a)->getPrimaryKey() == true){ if(hugoOps.equalForAttr(pOp, a, 1) != 0){ - // An error has occured, check that + // An error has occurred, check that // it's possible to get the NdbErrorOperation const NdbError err = pCon->getNdbError(); ERR(err); diff --git a/storage/ndb/test/ndbapi/testTimeout.cpp b/storage/ndb/test/ndbapi/testTimeout.cpp index 711a943f965..519946d83d7 100644 --- a/storage/ndb/test/ndbapi/testTimeout.cpp +++ b/storage/ndb/test/ndbapi/testTimeout.cpp @@ -511,7 +511,7 @@ TESTCASE("TimeoutRandTransaction", } TESTCASE("BuddyTransNoTimeout", "Start a transaction and perform an insert with NoCommit. " \ - "Start a buddy transaction wich performs long running scans " \ + "Start a buddy transaction which performs long running scans " \ "and sleeps. " \ "The total sleep time is longer than TransactionInactiveTimeout" \ "Commit the first transaction, it should not have timed out."){ @@ -523,7 +523,7 @@ TESTCASE("BuddyTransNoTimeout", } TESTCASE("BuddyTransNoTimeout5", "Start a transaction and perform an insert with NoCommit. " \ - "Start a buddy transaction wich performs long running scans " \ + "Start a buddy transaction which performs long running scans " \ "and sleeps. " \ "The total sleep time is longer than TransactionInactiveTimeout" \ "Commit the first transaction, it should not have timed out." \ diff --git a/storage/ndb/test/ndbapi/test_event.cpp b/storage/ndb/test/ndbapi/test_event.cpp index e435c59e457..92856d38602 100644 --- a/storage/ndb/test/ndbapi/test_event.cpp +++ b/storage/ndb/test/ndbapi/test_event.cpp @@ -254,7 +254,7 @@ eventOperation(Ndb* pNdb, const NdbDictionary::Table &tab, void* pstats, int rec last_inconsitant_gci = gci; stats.n_inconsistent_gcis++; } - g_warning << "A node failure has occured and events might be missing\n"; + g_warning << "A node failure has occurred and events might be missing\n"; } g_info << function << "GCI " << gci << ": " << count; struct receivedEvent* recEvent; @@ -1166,7 +1166,7 @@ static int copy_events(Ndb *ndb) r++; if (!pOp->isConsistent()) { - g_err << "A node failure has occured and events might be missing\n"; + g_err << "A node failure has occurred and events might be missing\n"; DBUG_RETURN(-1); } diff --git a/storage/ndb/test/ndbapi/test_event_multi_table.cpp b/storage/ndb/test/ndbapi/test_event_multi_table.cpp index a8cf0fa86c0..04e5caa7e9c 100644 --- a/storage/ndb/test/ndbapi/test_event_multi_table.cpp +++ b/storage/ndb/test/ndbapi/test_event_multi_table.cpp @@ -95,7 +95,7 @@ static int copy_events(Ndb *ndb) Uint32 gci= pOp->getGCI(); if (!pOp->isConsistent()) { - g_err << "A node failure has occured and events might be missing\n"; + g_err << "A node failure has occurred and events might be missing\n"; DBUG_RETURN(-1); } diff --git a/storage/ndb/tools/restore/restore_main.cpp b/storage/ndb/tools/restore/restore_main.cpp index 9af989e457a..c8e9b3e0f6e 100644 --- a/storage/ndb/tools/restore/restore_main.cpp +++ b/storage/ndb/tools/restore/restore_main.cpp @@ -862,7 +862,7 @@ main(int argc, char** argv) if (res < 0) { - err <<" Restore: An error occured while restoring data. Exiting..."; + err <<" Restore: An error occurred while restoring data. Exiting..."; err << endl; exitHandler(NDBT_FAILED); } @@ -875,7 +875,7 @@ main(int argc, char** argv) if (res < 0) { - err << "Restore: An error occured while restoring data. Exiting... " + err << "Restore: An error occurred while restoring data. Exiting... " << "res= " << res << endl; exitHandler(NDBT_FAILED); } diff --git a/storage/oqgraph/graphcore.cc b/storage/oqgraph/graphcore.cc index 73433fc8219..4346b94805c 100644 --- a/storage/oqgraph/graphcore.cc +++ b/storage/oqgraph/graphcore.cc @@ -1036,11 +1036,11 @@ int stack_cursor::fetch_row(const row &row_info, row &result, optional<EdgeWeight> w; optional<Vertex> v; result= row_info; - if ((result.seq_indicator= seq= last.sequence())) + if ((result.seq_indicator= static_cast<bool>(seq= last.sequence()))) result.seq= *seq; - if ((result.link_indicator= v= last.vertex())) + if ((result.link_indicator= static_cast<bool>(v= last.vertex()))) result.link= get(boost::vertex_index, share->g, *v); - if ((result.weight_indicator= w= last.weight())) + if ((result.weight_indicator= static_cast<bool>(w= last.weight()))) result.weight= *w; return oqgraph::OK; } diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index 89bc9128c29..f7add0d4204 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -715,6 +715,10 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) int ha_oqgraph::close(void) { DBUG_PRINT( "oq-debug", ("close()")); + if (graph->get_thd() != current_thd) { + DBUG_PRINT( "oq-debug", ("index_next_same g->table->in_use: 0x%lx <-- current_thd 0x%lx", (long) graph->get_thd(), (long) current_thd)); + graph->set_thd(current_thd); + } oqgraph::free(graph); graph= 0; oqgraph::free(graph_share); graph_share= 0; @@ -1099,6 +1103,10 @@ int ha_oqgraph::info(uint flag) int ha_oqgraph::extra(enum ha_extra_function operation) { + if (graph->get_thd() != ha_thd()) { + DBUG_PRINT( "oq-debug", ("rnd_pos g->table->in_use: 0x%lx <-- current_thd 0x%lx", (long) graph->get_thd(), (long) current_thd)); + graph->set_thd(current_thd); + } return edges->file->extra(operation); } diff --git a/storage/oqgraph/oqgraph_judy.cc b/storage/oqgraph/oqgraph_judy.cc index 020cab57ed2..44c7e28e268 100644 --- a/storage/oqgraph/oqgraph_judy.cc +++ b/storage/oqgraph/oqgraph_judy.cc @@ -23,6 +23,28 @@ */ #include "oqgraph_judy.h" + +/* + Currently the only active code that can return error is: + judy_bitset::reset()/J1U() + judy_bitset::setbit()/J1S() + + In most cases errors are either about wrong parameters passed to Judy + functions or internal structures corruption. These definitely deserve + abnormal process termination instead of exit() as it is done by original + JUDYERROR. + + TODO: there's one exception that should be handled properly though: OOM. +*/ +#include <stdio.h> +#define JUDYERROR(CallerFile, CallerLine, JudyFunc, JudyErrno, JudyErrID) \ + { \ + (void) fprintf(stderr, "File '%s', line %d: %s(), " \ + "JU_ERRNO_* == %d, ID == %d\n", \ + CallerFile, CallerLine, \ + JudyFunc, JudyErrno, JudyErrID); \ + abort(); \ + } #include <Judy.h> void open_query::judy_bitset::clear() diff --git a/storage/spider/hs_client/fatal.cpp b/storage/spider/hs_client/fatal.cpp index bec031153e4..260a2e75372 100644 --- a/storage/spider/hs_client/fatal.cpp +++ b/storage/spider/hs_client/fatal.cpp @@ -26,26 +26,6 @@ const int opt_syslog = LOG_ERR | LOG_PID | LOG_CONS; */ void -fatal_exit(const String& message) -{ - fprintf(stderr, "FATAL_EXIT: %s\n", message.ptr()); -/* - syslog(opt_syslog, "FATAL_EXIT: %s", message.ptr()); -*/ - _exit(1); -} - -void -fatal_exit(const char *message) -{ - fprintf(stderr, "FATAL_EXIT: %s\n", message); -/* - syslog(opt_syslog, "FATAL_EXIT: %s", message); -*/ - _exit(1); -} - -void fatal_abort(const String& message) { fprintf(stderr, "FATAL_COREDUMP: %s\n", message.ptr()); diff --git a/storage/spider/hs_client/fatal.hpp b/storage/spider/hs_client/fatal.hpp index a75c56bddad..e1190ae49c1 100644 --- a/storage/spider/hs_client/fatal.hpp +++ b/storage/spider/hs_client/fatal.hpp @@ -22,8 +22,6 @@ namespace dena { -void fatal_exit(const String& message); -void fatal_exit(const char *message); void fatal_abort(const String& message); void fatal_abort(const char *message); diff --git a/storage/spider/hs_client/socket.cpp b/storage/spider/hs_client/socket.cpp index 2082d1f024e..c61b39d140f 100644 --- a/storage/spider/hs_client/socket.cpp +++ b/storage/spider/hs_client/socket.cpp @@ -67,7 +67,7 @@ socket_args::set(const config& conf) message.append(node); message.q_append(":", sizeof(":") - 1); message.append(port); - fatal_exit(message); + fatal_abort(message); } } } diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index c5c47064403..2f7fdb62ad4 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -2706,7 +2706,7 @@ void *spider_bg_sts_action( SPIDER_TRX *trx; int error_num = 0, roop_count; ha_spider spider; -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) int *need_mons; SPIDER_CONN **conns; uint *conn_link_idx; @@ -2733,7 +2733,7 @@ void *spider_bg_sts_action( my_thread_init(); DBUG_ENTER("spider_bg_sts_action"); /* init start */ -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) if (!(need_mons = (int *) spider_bulk_malloc(spider_current_trx, 21, MYF(MY_WME), @@ -2777,7 +2777,7 @@ void *spider_bg_sts_action( share->bg_sts_init = FALSE; pthread_mutex_unlock(&share->sts_mutex); my_thread_end(); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_free(NULL, need_mons, MYF(MY_WME)); #endif DBUG_RETURN(NULL); @@ -2801,7 +2801,7 @@ void *spider_bg_sts_action( my_pthread_setspecific_ptr(THR_THD, NULL); #endif my_thread_end(); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_free(NULL, need_mons, MYF(MY_WME)); #endif DBUG_RETURN(NULL); @@ -2866,7 +2866,7 @@ void *spider_bg_sts_action( my_pthread_setspecific_ptr(THR_THD, NULL); #endif my_thread_end(); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_free(NULL, need_mons, MYF(MY_WME)); #endif DBUG_RETURN(NULL); @@ -2897,7 +2897,7 @@ void *spider_bg_sts_action( my_pthread_setspecific_ptr(THR_THD, NULL); #endif my_thread_end(); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_free(NULL, need_mons, MYF(MY_WME)); #endif DBUG_RETURN(NULL); @@ -3088,7 +3088,7 @@ void *spider_bg_crd_action( int error_num = 0, roop_count; ha_spider spider; TABLE table; -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) int *need_mons; SPIDER_CONN **conns; uint *conn_link_idx; @@ -3115,7 +3115,7 @@ void *spider_bg_crd_action( my_thread_init(); DBUG_ENTER("spider_bg_crd_action"); /* init start */ -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) if (!(need_mons = (int *) spider_bulk_malloc(spider_current_trx, 22, MYF(MY_WME), @@ -3159,7 +3159,7 @@ void *spider_bg_crd_action( share->bg_crd_init = FALSE; pthread_mutex_unlock(&share->crd_mutex); my_thread_end(); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_free(NULL, need_mons, MYF(MY_WME)); #endif DBUG_RETURN(NULL); @@ -3183,7 +3183,7 @@ void *spider_bg_crd_action( my_pthread_setspecific_ptr(THR_THD, NULL); #endif my_thread_end(); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_free(NULL, need_mons, MYF(MY_WME)); #endif DBUG_RETURN(NULL); @@ -3252,7 +3252,7 @@ void *spider_bg_crd_action( my_pthread_setspecific_ptr(THR_THD, NULL); #endif my_thread_end(); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_free(NULL, need_mons, MYF(MY_WME)); #endif DBUG_RETURN(NULL); @@ -3283,7 +3283,7 @@ void *spider_bg_crd_action( my_pthread_setspecific_ptr(THR_THD, NULL); #endif my_thread_end(); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_free(NULL, need_mons, MYF(MY_WME)); #endif DBUG_RETURN(NULL); @@ -3417,7 +3417,7 @@ int spider_create_mon_threads( { char link_idx_str[SPIDER_SQL_INT_LEN]; int link_idx_str_length; -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_string conv_name_str(share->table_name_length + SPIDER_SQL_INT_LEN + 1); conv_name_str.set_charset(system_charset_info); @@ -3748,7 +3748,7 @@ int spider_conn_first_link_idx( int roop_count, active_links = 0; longlong balance_total = 0, balance_val; double rand_val; -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) int *link_idxs, link_idx; long *balances; #else @@ -3756,7 +3756,7 @@ int spider_conn_first_link_idx( long balances[link_count]; #endif DBUG_ENTER("spider_conn_first_link_idx"); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) if (!(link_idxs = (int *) spider_bulk_malloc(spider_current_trx, 24, MYF(MY_WME), &link_idxs, sizeof(int) * link_count, @@ -3782,7 +3782,7 @@ int spider_conn_first_link_idx( if (active_links == 0) { DBUG_PRINT("info",("spider all links are failed")); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_free(spider_current_trx, link_idxs, MYF(MY_WME)); #endif DBUG_RETURN(-1); @@ -3811,7 +3811,7 @@ int spider_conn_first_link_idx( } DBUG_PRINT("info",("spider first link_idx=%d", link_idxs[roop_count])); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) link_idx = link_idxs[roop_count]; spider_free(spider_current_trx, link_idxs, MYF(MY_WME)); DBUG_RETURN(link_idx); diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc index c01549f8e99..7e7845635af 100644 --- a/storage/spider/spd_copy_tables.cc +++ b/storage/spider/spd_copy_tables.cc @@ -81,7 +81,7 @@ int spider_udf_set_copy_tables_param_default( #define SPIDER_PARAM_STR(title_name, param_name) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ if (!copy_tables->param_name) \ { \ if ((copy_tables->param_name = spider_get_string_between_quote( \ @@ -94,14 +94,14 @@ int spider_udf_set_copy_tables_param_default( MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info",("spider "title_name"=%s", copy_tables->param_name)); \ + DBUG_PRINT("info",("spider " title_name "=%s", copy_tables->param_name)); \ } \ break; \ } #define SPIDER_PARAM_HINT_WITH_MAX(title_name, param_name, check_length, max_size, min_val, max_val) \ if (!strncasecmp(tmp_ptr, title_name, check_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ DBUG_PRINT("info",("spider max_size=%d", max_size)); \ int hint_num = atoi(tmp_ptr + check_length) - 1; \ DBUG_PRINT("info",("spider hint_num=%d", hint_num)); \ @@ -131,7 +131,7 @@ int spider_udf_set_copy_tables_param_default( MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info",("spider "title_name"[%d]=%d", hint_num, \ + DBUG_PRINT("info",("spider " title_name "[%d]=%d", hint_num, \ copy_tables->param_name[hint_num])); \ } else { \ error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; \ @@ -144,7 +144,7 @@ int spider_udf_set_copy_tables_param_default( #define SPIDER_PARAM_INT_WITH_MAX(title_name, param_name, min_val, max_val) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ if (copy_tables->param_name == -1) \ { \ if ((tmp_ptr2 = spider_get_string_between_quote( \ @@ -161,14 +161,14 @@ int spider_udf_set_copy_tables_param_default( MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info",("spider "title_name"=%d", copy_tables->param_name)); \ + DBUG_PRINT("info",("spider " title_name "=%d", copy_tables->param_name)); \ } \ break; \ } #define SPIDER_PARAM_INT(title_name, param_name, min_val) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ if (copy_tables->param_name == -1) \ { \ if ((tmp_ptr2 = spider_get_string_between_quote( \ @@ -183,14 +183,14 @@ int spider_udf_set_copy_tables_param_default( MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info",("spider "title_name"=%d", copy_tables->param_name)); \ + DBUG_PRINT("info",("spider " title_name "=%d", copy_tables->param_name)); \ } \ break; \ } #define SPIDER_PARAM_LONGLONG(title_name, param_name, min_val) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ if (copy_tables->param_name == -1) \ { \ if ((tmp_ptr2 = spider_get_string_between_quote( \ @@ -206,7 +206,7 @@ int spider_udf_set_copy_tables_param_default( MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info",("spider "title_name"=%lld", \ + DBUG_PRINT("info",("spider " title_name "=%lld", \ copy_tables->param_name)); \ } \ break; \ diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 9f46e55ca09..c29172a474a 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -9294,7 +9294,7 @@ int spider_db_udf_ping_table( { int init_sql_alloc_size = spider_param_init_sql_alloc_size(trx->thd, share->init_sql_alloc_size); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_string sql_str(init_sql_alloc_size); sql_str.set_charset(system_charset_info); spider_string where_str(init_sql_alloc_size); @@ -9517,7 +9517,7 @@ int spider_db_udf_ping_table_mon_next( SPIDER_SHARE *share = table_mon->share; int init_sql_alloc_size = spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_string sql_str(init_sql_alloc_size); sql_str.set_charset(thd->variables.character_set_client); #else diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index 7de31e34e94..c0eb7806bb0 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -896,7 +896,7 @@ error: #define SPIDER_PARAM_STR(title_name, param_name) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ if (!direct_sql->param_name) \ { \ if ((direct_sql->param_name = spider_get_string_between_quote( \ @@ -909,14 +909,14 @@ error: MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info",("spider "title_name"=%s", direct_sql->param_name)); \ + DBUG_PRINT("info",("spider " title_name "=%s", direct_sql->param_name)); \ } \ break; \ } #define SPIDER_PARAM_HINT_WITH_MAX(title_name, param_name, check_length, max_size, min_val, max_val) \ if (!strncasecmp(tmp_ptr, title_name, check_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ DBUG_PRINT("info",("spider max_size=%d", max_size)); \ int hint_num = atoi(tmp_ptr + check_length) - 1; \ DBUG_PRINT("info",("spider hint_num=%d", hint_num)); \ @@ -946,7 +946,7 @@ error: MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info",("spider "title_name"[%d]=%d", hint_num, \ + DBUG_PRINT("info",("spider " title_name "[%d]=%d", hint_num, \ direct_sql->param_name[hint_num])); \ } else { \ error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ @@ -959,7 +959,7 @@ error: #define SPIDER_PARAM_INT_WITH_MAX(title_name, param_name, min_val, max_val) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ if (direct_sql->param_name == -1) \ { \ if ((tmp_ptr2 = spider_get_string_between_quote( \ @@ -976,7 +976,7 @@ error: MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info",("spider "title_name"=%d", \ + DBUG_PRINT("info",("spider " title_name "=%d", \ (int) direct_sql->param_name)); \ } \ break; \ @@ -984,7 +984,7 @@ error: #define SPIDER_PARAM_INT(title_name, param_name, min_val) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ if (direct_sql->param_name == -1) \ { \ if ((tmp_ptr2 = spider_get_string_between_quote( \ @@ -999,14 +999,14 @@ error: MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info",("spider "title_name"=%d", direct_sql->param_name)); \ + DBUG_PRINT("info",("spider " title_name "=%d", direct_sql->param_name)); \ } \ break; \ } #define SPIDER_PARAM_LONGLONG(title_name, param_name, min_val) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ if (direct_sql->param_name == -1) \ { \ if ((tmp_ptr2 = spider_get_string_between_quote( \ @@ -1022,7 +1022,7 @@ error: MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info",("spider "title_name"=%lld", \ + DBUG_PRINT("info",("spider " title_name "=%lld", \ direct_sql->param_name)); \ } \ break; \ diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc index 41c5c240dd3..f59f7760359 100644 --- a/storage/spider/spd_ping_table.cc +++ b/storage/spider/spd_ping_table.cc @@ -241,7 +241,7 @@ void spider_release_ping_table_mon_list( DBUG_PRINT("info", ("spider link_idx=%d", link_idx)); link_idx_str_length = my_sprintf(link_idx_str, (link_idx_str, "%010d", link_idx)); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_string conv_name_str(conv_name_length + link_idx_str_length + 1); conv_name_str.set_charset(system_charset_info); #else @@ -1362,7 +1362,7 @@ int spider_ping_table_mon_from_table( link_idx_str_length = my_sprintf(link_idx_str, (link_idx_str, "%010d", link_idx)); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_string conv_name_str(conv_name_length + link_idx_str_length + 1); conv_name_str.set_charset(system_charset_info); *((char *)(conv_name_str.ptr() + conv_name_length + link_idx_str_length)) = diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index a20598969ee..ead335c07ea 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -1500,7 +1500,7 @@ static int spider_set_ll_value( #define SPIDER_PARAM_STR(title_name, param_name) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ if (!share->param_name) \ { \ if ((share->param_name = spider_get_string_between_quote( \ @@ -1512,7 +1512,7 @@ static int spider_set_ll_value( MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info",("spider "title_name"=%s", share->param_name)); \ + DBUG_PRINT("info",("spider " title_name "=%s", share->param_name)); \ } \ break; \ } @@ -1521,7 +1521,7 @@ static int spider_set_ll_value( #define SPIDER_PARAM_STR_LIST(title_name, param_name) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ if (!share->param_name) \ { \ if ((tmp_ptr2 = spider_get_string_between_quote( \ @@ -1547,7 +1547,7 @@ static int spider_set_ll_value( #define SPIDER_PARAM_HINT(title_name, param_name, check_length, max_size, append_method) \ if (!strncasecmp(tmp_ptr, title_name, check_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ DBUG_PRINT("info",("spider max_size=%d", max_size)); \ int hint_num = atoi(tmp_ptr + check_length); \ DBUG_PRINT("info",("spider hint_num=%d", hint_num)); \ @@ -1566,7 +1566,7 @@ static int spider_set_ll_value( if ((error_num = \ append_method(&share->param_name[hint_num], hint_str))) \ goto error; \ - DBUG_PRINT("info",("spider "title_name"[%d]=%s", hint_num, \ + DBUG_PRINT("info",("spider " title_name "[%d]=%s", hint_num, \ share->param_name[hint_num].ptr())); \ } else { \ error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ @@ -1579,7 +1579,7 @@ static int spider_set_ll_value( #define SPIDER_PARAM_NUMHINT(title_name, param_name, check_length, max_size, append_method) \ if (!strncasecmp(tmp_ptr, title_name, check_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ DBUG_PRINT("info",("spider max_size=%d", max_size)); \ int hint_num = atoi(tmp_ptr + check_length); \ DBUG_PRINT("info",("spider hint_num=%d", hint_num)); \ @@ -1598,7 +1598,7 @@ static int spider_set_ll_value( if ((error_num = \ append_method(&share->param_name[hint_num], hint_str))) \ goto error; \ - DBUG_PRINT("info",("spider "title_name"[%d]=%lld", hint_num, \ + DBUG_PRINT("info",("spider " title_name "[%d]=%lld", hint_num, \ share->param_name[hint_num])); \ } else { \ error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ @@ -1613,7 +1613,7 @@ static int spider_set_ll_value( min_val, max_val) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ if (!share->param_name) \ { \ if ((tmp_ptr2 = spider_get_string_between_quote( \ @@ -1640,7 +1640,7 @@ static int spider_set_ll_value( min_val, max_val) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ if (!share->param_name) \ { \ if ((tmp_ptr2 = spider_get_string_between_quote( \ @@ -1665,7 +1665,7 @@ static int spider_set_ll_value( #define SPIDER_PARAM_INT_WITH_MAX(title_name, param_name, min_val, max_val) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ if (share->param_name == -1) \ { \ if ((tmp_ptr2 = spider_get_string_between_quote( \ @@ -1682,14 +1682,14 @@ static int spider_set_ll_value( MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info",("spider "title_name"=%d", share->param_name)); \ + DBUG_PRINT("info",("spider " title_name "=%d", share->param_name)); \ } \ break; \ } #define SPIDER_PARAM_INT(title_name, param_name, min_val) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ if (share->param_name == -1) \ { \ if ((tmp_ptr2 = spider_get_string_between_quote( \ @@ -1704,14 +1704,14 @@ static int spider_set_ll_value( MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info",("spider "title_name"=%d", share->param_name)); \ + DBUG_PRINT("info",("spider " title_name "=%d", share->param_name)); \ } \ break; \ } #define SPIDER_PARAM_DOUBLE(title_name, param_name, min_val) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ if (share->param_name == -1) \ { \ if ((tmp_ptr2 = spider_get_string_between_quote( \ @@ -1726,14 +1726,14 @@ static int spider_set_ll_value( MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info",("spider "title_name"=%f", share->param_name)); \ + DBUG_PRINT("info",("spider " title_name "=%f", share->param_name)); \ } \ break; \ } #define SPIDER_PARAM_LONGLONG(title_name, param_name, min_val) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \ { \ - DBUG_PRINT("info",("spider "title_name" start")); \ + DBUG_PRINT("info",("spider " title_name " start")); \ if (share->param_name == -1) \ { \ if ((tmp_ptr2 = spider_get_string_between_quote( \ @@ -1748,7 +1748,7 @@ static int spider_set_ll_value( MYF(0), tmp_ptr); \ goto error; \ } \ - DBUG_PRINT("info",("spider "title_name"=%lld", share->param_name)); \ + DBUG_PRINT("info",("spider " title_name "=%lld", share->param_name)); \ } \ break; \ } @@ -3703,7 +3703,7 @@ int spider_create_conn_keys( #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) char *tmp_hs_r_name, *tmp_hs_w_name; #endif -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) uint *conn_keys_lengths; #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) uint *hs_r_conn_keys_lengths; @@ -3717,7 +3717,7 @@ int spider_create_conn_keys( #endif #endif DBUG_ENTER("spider_create_conn_keys"); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) if (!(conn_keys_lengths = (uint *) spider_bulk_alloc_mem(spider_current_trx, 44, __func__, __FILE__, __LINE__, MYF(MY_WME), @@ -3806,7 +3806,7 @@ int spider_create_conn_keys( #endif NullS)) ) { -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_free(spider_current_trx, conn_keys_lengths, MYF(MY_WME)); #endif DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -3823,7 +3823,7 @@ int spider_create_conn_keys( sizeof(uint) * share->all_link_count); #endif -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_free(spider_current_trx, conn_keys_lengths, MYF(MY_WME)); #endif @@ -4676,7 +4676,7 @@ SPIDER_SHARE *spider_get_share( share->link_count, SPIDER_LINK_STATUS_OK); if (search_link_idx == -1) { -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) char *db, *table_name; if (!(db = (char *) spider_bulk_malloc(spider_current_trx, 48, MYF(MY_WME), @@ -4702,7 +4702,7 @@ SPIDER_SHARE *spider_get_share( table_name[table_share->table_name.length] = '\0'; my_printf_error(ER_SPIDER_ALL_LINKS_FAILED_NUM, ER_SPIDER_ALL_LINKS_FAILED_STR, MYF(0), db, table_name); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_free(spider->trx, db, MYF(MY_WME)); #endif *error_num = ER_SPIDER_ALL_LINKS_FAILED_NUM; @@ -5100,7 +5100,7 @@ SPIDER_SHARE *spider_get_share( share->link_count, SPIDER_LINK_STATUS_OK); if (search_link_idx == -1) { -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) char *db, *table_name; if (!(db = (char *) spider_bulk_malloc(spider_current_trx, 50, MYF(MY_WME), @@ -5123,7 +5123,7 @@ SPIDER_SHARE *spider_get_share( table_name[table_share->table_name.length] = '\0'; my_printf_error(ER_SPIDER_ALL_LINKS_FAILED_NUM, ER_SPIDER_ALL_LINKS_FAILED_STR, MYF(0), db, table_name); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_free(spider->trx, db, MYF(MY_WME)); #endif *error_num = ER_SPIDER_ALL_LINKS_FAILED_NUM; diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index d7127fa0084..18b6fd5ec89 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -3710,7 +3710,7 @@ int spider_check_trx_and_get_conn( { TABLE *table = spider->get_table(); TABLE_SHARE *table_share = table->s; -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) char *db, *table_name; if (!(db = (char *) spider_bulk_malloc(spider_current_trx, 57, MYF(MY_WME), @@ -3732,7 +3732,7 @@ int spider_check_trx_and_get_conn( table_name[table_share->table_name.length] = '\0'; my_printf_error(ER_SPIDER_ALL_LINKS_FAILED_NUM, ER_SPIDER_ALL_LINKS_FAILED_STR, MYF(0), db, table_name); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_free(trx, db, MYF(MY_WME)); #endif DBUG_RETURN(ER_SPIDER_ALL_LINKS_FAILED_NUM); @@ -3869,7 +3869,7 @@ int spider_check_trx_and_get_conn( { TABLE *table = spider->get_table(); TABLE_SHARE *table_share = table->s; -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) char *db, *table_name; if (!(db = (char *) spider_bulk_malloc(spider_current_trx, 57, MYF(MY_WME), @@ -3891,7 +3891,7 @@ int spider_check_trx_and_get_conn( table_name[table_share->table_name.length] = '\0'; my_printf_error(ER_SPIDER_LINK_MON_JUST_NG_NUM, ER_SPIDER_LINK_MON_JUST_NG_STR, MYF(0), db, table_name); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_free(trx, db, MYF(MY_WME)); #endif DBUG_RETURN(ER_SPIDER_LINK_MON_JUST_NG_NUM); @@ -4015,7 +4015,7 @@ int spider_check_trx_and_get_conn( { TABLE *table = spider->get_table(); TABLE_SHARE *table_share = table->s; -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) char *db, *table_name; if (!(db = (char *) spider_bulk_malloc(spider_current_trx, 57, MYF(MY_WME), @@ -4037,7 +4037,7 @@ int spider_check_trx_and_get_conn( table_name[table_share->table_name.length] = '\0'; my_printf_error(ER_SPIDER_LINK_MON_JUST_NG_NUM, ER_SPIDER_LINK_MON_JUST_NG_STR, MYF(0), db, table_name); -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__SUNPRO_CC) spider_free(trx, db, MYF(MY_WME)); #endif DBUG_RETURN(ER_SPIDER_LINK_MON_JUST_NG_NUM); diff --git a/storage/tokudb/PerconaFT/buildheader/CMakeLists.txt b/storage/tokudb/PerconaFT/buildheader/CMakeLists.txt index 5da3c98ff48..6d5cbb94358 100644 --- a/storage/tokudb/PerconaFT/buildheader/CMakeLists.txt +++ b/storage/tokudb/PerconaFT/buildheader/CMakeLists.txt @@ -1,6 +1,6 @@ set_directory_properties(PROPERTIES INCLUDE_DIRECTORIES "") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/runcat.sh" "#!/bin/bash +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/runcat.sh" "#!/bin/sh out=$1; shift exec \"$@\" >$out") @@ -8,7 +8,7 @@ add_executable(make_tdb make_tdb.cc) set_property(TARGET make_tdb APPEND PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE) add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/db.h" - COMMAND bash runcat.sh "${CMAKE_CURRENT_BINARY_DIR}/db.h" $<TARGET_FILE:make_tdb> + COMMAND sh runcat.sh "${CMAKE_CURRENT_BINARY_DIR}/db.h" $<TARGET_FILE:make_tdb> DEPENDS make_tdb) add_custom_target(install_tdb_h DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/db.h") diff --git a/storage/tokudb/PerconaFT/cmake_modules/TokuSetupCompiler.cmake b/storage/tokudb/PerconaFT/cmake_modules/TokuSetupCompiler.cmake index c011349c714..40fd27e9c74 100644 --- a/storage/tokudb/PerconaFT/cmake_modules/TokuSetupCompiler.cmake +++ b/storage/tokudb/PerconaFT/cmake_modules/TokuSetupCompiler.cmake @@ -61,12 +61,13 @@ endmacro(set_cflags_if_supported_named) ## adds a compiler flag if the compiler supports it macro(set_cflags_if_supported) foreach(flag ${ARGN}) - check_c_compiler_flag(${flag} HAVE_C_${flag}) - if (HAVE_C_${flag}) + STRING(REGEX REPLACE "[-,= ]" "_" res ${flag}) + check_c_compiler_flag(${flag} HAVE_C_${res}) + if (HAVE_C_${res}) set(CMAKE_C_FLAGS "${flag} ${CMAKE_C_FLAGS}") endif () - check_cxx_compiler_flag(${flag} HAVE_CXX_${flag}) - if (HAVE_CXX_${flag}) + check_cxx_compiler_flag(${flag} HAVE_CXX_${res}) + if (HAVE_CXX_${res}) set(CMAKE_CXX_FLAGS "${flag} ${CMAKE_CXX_FLAGS}") endif () endforeach(flag) @@ -75,8 +76,9 @@ endmacro(set_cflags_if_supported) ## adds a linker flag if the compiler supports it macro(set_ldflags_if_supported) foreach(flag ${ARGN}) - check_cxx_compiler_flag(${flag} HAVE_${flag}) - if (HAVE_${flag}) + STRING(REGEX REPLACE "[-,= ]" "_" res ${flag}) + check_cxx_compiler_flag(${flag} HAVE_${res}) + if (HAVE_${res}) set(CMAKE_EXE_LINKER_FLAGS "${flag} ${CMAKE_EXE_LINKER_FLAGS}") set(CMAKE_SHARED_LINKER_FLAGS "${flag} ${CMAKE_SHARED_LINKER_FLAGS}") endif () @@ -104,8 +106,8 @@ set_cflags_if_supported( if (CMAKE_CXX_FLAGS MATCHES -fno-implicit-templates) # must append this because mysql sets -fno-implicit-templates and we need to override it - check_cxx_compiler_flag(-fimplicit-templates HAVE_CXX_-fimplicit-templates) - if (HAVE_CXX_-fimplicit-templates) + check_cxx_compiler_flag(-fimplicit-templates HAVE_CXX_IMPLICIT_TEMPLATES) + if (HAVE_CXX_IMPLICIT_TEMPLATES) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fimplicit-templates") endif () endif() diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_filter_unpack_varchar.result b/storage/tokudb/mysql-test/tokudb/r/cluster_filter_unpack_varchar.result index d3273437f77..9faf04b6a10 100644 --- a/storage/tokudb/mysql-test/tokudb/r/cluster_filter_unpack_varchar.result +++ b/storage/tokudb/mysql-test/tokudb/r/cluster_filter_unpack_varchar.result @@ -182,14 +182,14 @@ a b c d e f 3 30 200 2000 20000 200000 explain select * from t1 where b > "0"; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index b b NULL NULL NULL; Using where; Using index +1 SIMPLE t1 # b b NULL NULL NULL; Using where; Using index select * from t1 where b > "0"; a b c d e f 2 20 100 1000 10000 100000 3 30 200 2000 20000 200000 explain select * from t1 where d > "0"; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index d d NULL NULL NULL; Using where; Using index +1 SIMPLE t1 # d d NULL NULL NULL; Using where; Using index select * from t1 where d > "0"; a b c d e f 2 20 100 1000 10000 100000 diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_filter_unpack_varchar_hidden.result b/storage/tokudb/mysql-test/tokudb/r/cluster_filter_unpack_varchar_hidden.result index 640c7badc71..6269b8f2d71 100644 --- a/storage/tokudb/mysql-test/tokudb/r/cluster_filter_unpack_varchar_hidden.result +++ b/storage/tokudb/mysql-test/tokudb/r/cluster_filter_unpack_varchar_hidden.result @@ -182,14 +182,14 @@ a b c d e f 3 30 200 2000 20000 200000 explain select * from t1 where b > "0"; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index b b NULL NULL NULL; Using where; Using index +1 SIMPLE t1 <type> b b NULL NULL NULL; Using where; Using index select * from t1 where b > "0"; a b c d e f 2 20 100 1000 10000 100000 3 30 200 2000 20000 200000 explain select * from t1 where d > "0"; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index d d NULL NULL NULL; Using where; Using index +1 SIMPLE t1 <type> d d NULL NULL NULL; Using where; Using index select * from t1 where d > "0"; a b c d e f 2 20 100 1000 10000 100000 diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_filter_unpack_varchar.test b/storage/tokudb/mysql-test/tokudb/t/cluster_filter_unpack_varchar.test index 3a30919a8ff..f3e494e0dd4 100644 --- a/storage/tokudb/mysql-test/tokudb/t/cluster_filter_unpack_varchar.test +++ b/storage/tokudb/mysql-test/tokudb/t/cluster_filter_unpack_varchar.test @@ -82,11 +82,11 @@ alter table t1 add key d(d,a) clustering=yes, add key b(b) clustering=yes; explain select * from t1 where c > "0"; select * from t1 where c > "0"; ---replace_column 7 NULL 9 NULL; +--replace_column 4 # 7 NULL 9 NULL; explain select * from t1 where b > "0"; select * from t1 where b > "0"; ---replace_column 7 NULL 9 NULL; +--replace_column 4 # 7 NULL 9 NULL; explain select * from t1 where d > "0"; select * from t1 where d > "0"; diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_filter_unpack_varchar_hidden.test b/storage/tokudb/mysql-test/tokudb/t/cluster_filter_unpack_varchar_hidden.test index d1be871c7d2..e9bb18a586e 100644 --- a/storage/tokudb/mysql-test/tokudb/t/cluster_filter_unpack_varchar_hidden.test +++ b/storage/tokudb/mysql-test/tokudb/t/cluster_filter_unpack_varchar_hidden.test @@ -82,11 +82,11 @@ alter table t1 add key d(d,a) clustering=yes, add key b(b) clustering=yes; explain select * from t1; select * from t1; ---replace_column 7 NULL 9 NULL; +--replace_column 4 <type> 7 NULL 9 NULL; explain select * from t1 where b > "0"; select * from t1 where b > "0"; ---replace_column 7 NULL 9 NULL; +--replace_column 4 <type> 7 NULL 9 NULL; explain select * from t1 where d > "0"; select * from t1 where d > "0"; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/checkpoint_lock.test b/storage/tokudb/mysql-test/tokudb_bugs/t/checkpoint_lock.test index d57a59b22e5..607b1991e26 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/t/checkpoint_lock.test +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/checkpoint_lock.test @@ -8,8 +8,10 @@ connect (conn1,localhost,root,,); connection default; --sleep 2 +--replace_result Execute Query select DB, command, state, info from information_schema.processlist order by info; flush logs; +--replace_result Execute Query select DB, command, state, info from information_schema.processlist order by info; connection conn1; @@ -20,6 +22,7 @@ connection default; connection conn1; --sleep 2 +--replace_result Execute Query select DB, command, state, info from information_schema.processlist order by info; set tokudb_checkpoint_lock=0; diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/checkpoint_lock_3.test b/storage/tokudb/mysql-test/tokudb_bugs/t/checkpoint_lock_3.test index 64c0f491f9a..91d7e59bee6 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/t/checkpoint_lock_3.test +++ b/storage/tokudb/mysql-test/tokudb_bugs/t/checkpoint_lock_3.test @@ -7,8 +7,10 @@ connect (conn1,localhost,root,,); connection default; --sleep 2 +--replace_result Execute Query select DB, command, state, info from information_schema.processlist order by info; flush logs; +--replace_result Execute Query select DB, command, state, info from information_schema.processlist order by info; connection conn1; @@ -19,6 +21,7 @@ connection default; connection conn1; --sleep 2 +--replace_result Execute Query select DB, command, state, info from information_schema.processlist order by info; set tokudb_checkpoint_lock=0; diff --git a/storage/xtradb/buf/buf0dump.cc b/storage/xtradb/buf/buf0dump.cc index 2b3b506a457..8f3385311df 100644 --- a/storage/xtradb/buf/buf0dump.cc +++ b/storage/xtradb/buf/buf0dump.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -167,6 +167,25 @@ buf_load_status( va_end(ap); } +/** Returns the directory path where the buffer pool dump file will be created. +@return directory path */ +static +const char* +get_buf_dump_dir() +{ + const char* dump_dir; + + /* The dump file should be created in the default data directory if + innodb_data_home_dir is set as an empty string. */ + if (strcmp(srv_data_home, "") == 0) { + dump_dir = fil_path_to_mysql_datadir; + } else { + dump_dir = srv_data_home; + } + + return(dump_dir); +} + /*****************************************************************//** Perform a buffer pool dump into the file specified by innodb_buffer_pool_filename. If any errors occur then the value of @@ -190,7 +209,7 @@ buf_dump( int ret; ut_snprintf(full_filename, sizeof(full_filename), - "%s%c%s", srv_data_home, SRV_PATH_SEPARATOR, + "%s%c%s", get_buf_dump_dir(), SRV_PATH_SEPARATOR, srv_buf_dump_filename); ut_snprintf(tmp_filename, sizeof(tmp_filename), @@ -463,7 +482,7 @@ buf_load() buf_load_abort_flag = FALSE; ut_snprintf(full_filename, sizeof(full_filename), - "%s%c%s", srv_data_home, SRV_PATH_SEPARATOR, + "%s%c%s", get_buf_dump_dir(), SRV_PATH_SEPARATOR, srv_buf_dump_filename); buf_load_status(STATUS_NOTICE, diff --git a/storage/xtradb/buf/buf0flu.cc b/storage/xtradb/buf/buf0flu.cc index 9c53dc70a78..e2f77a74a36 100644 --- a/storage/xtradb/buf/buf0flu.cc +++ b/storage/xtradb/buf/buf0flu.cc @@ -67,12 +67,6 @@ UNIV_INTERN mysql_pfs_key_t buf_page_cleaner_thread_key; UNIV_INTERN mysql_pfs_key_t buf_lru_manager_thread_key; #endif /* UNIV_PFS_THREAD */ -/** If LRU list of a buf_pool is less than this size then LRU eviction -should not happen. This is because when we do LRU flushing we also put -the blocks on free list. If LRU list is very small then we can end up -in thrashing. */ -#define BUF_LRU_MIN_LEN 256 - /* @} */ /** Handled page counters for a single flush */ diff --git a/storage/xtradb/dict/dict0dict.cc b/storage/xtradb/dict/dict0dict.cc index 7e2d95d499b..1f97ce1ae52 100644 --- a/storage/xtradb/dict/dict0dict.cc +++ b/storage/xtradb/dict/dict0dict.cc @@ -1107,7 +1107,7 @@ dict_init(void) &dict_operation_lock, SYNC_DICT_OPERATION); if (!srv_read_only_mode) { - dict_foreign_err_file = os_file_create_tmpfile(); + dict_foreign_err_file = os_file_create_tmpfile(NULL); ut_a(dict_foreign_err_file); mutex_create(dict_foreign_err_mutex_key, diff --git a/storage/xtradb/dict/dict0stats.cc b/storage/xtradb/dict/dict0stats.cc index 1eac9e0df51..b073398f8ec 100644 --- a/storage/xtradb/dict/dict0stats.cc +++ b/storage/xtradb/dict/dict0stats.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2009, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2009, 2015, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -1436,7 +1436,6 @@ on the leaf page. when comparing records @param[out] n_diff number of distinct records @param[out] n_external_pages number of external pages -@param[in,out] mtr mini-transaction @return number of distinct records on the leaf page */ static void @@ -1444,8 +1443,7 @@ dict_stats_analyze_index_below_cur( const btr_cur_t* cur, ulint n_prefix, ib_uint64_t* n_diff, - ib_uint64_t* n_external_pages, - mtr_t* mtr) + ib_uint64_t* n_external_pages) { dict_index_t* index; ulint space; @@ -1459,6 +1457,7 @@ dict_stats_analyze_index_below_cur( ulint* offsets2; ulint* offsets_rec; ulint size; + mtr_t mtr; index = btr_cur_get_index(cur); @@ -1497,12 +1496,14 @@ dict_stats_analyze_index_below_cur( function without analyzing any leaf pages */ *n_external_pages = 0; + mtr_start(&mtr); + /* descend to the leaf level on the B-tree */ for (;;) { block = buf_page_get_gen(space, zip_size, page_no, RW_S_LATCH, NULL /* no guessed block */, - BUF_GET, __FILE__, __LINE__, mtr); + BUF_GET, __FILE__, __LINE__, &mtr); page = buf_block_get_frame(block); @@ -1524,6 +1525,8 @@ dict_stats_analyze_index_below_cur( ut_a(*n_diff > 0); if (*n_diff == 1) { + mtr_commit(&mtr); + /* page has all keys equal and the end of the page was reached by dict_stats_scan_page(), no need to descend to the leaf level */ @@ -1548,7 +1551,7 @@ dict_stats_analyze_index_below_cur( } /* make sure we got a leaf page as a result from the above loop */ - ut_ad(btr_page_get_level(page, mtr) == 0); + ut_ad(btr_page_get_level(page, &mtr) == 0); /* scan the leaf page and find the number of distinct keys, when looking only at the first n_prefix columns; also estimate @@ -1565,6 +1568,7 @@ dict_stats_analyze_index_below_cur( __func__, page_no, n_diff); #endif + mtr_commit(&mtr); mem_heap_free(heap); } @@ -1774,8 +1778,7 @@ dict_stats_analyze_index_for_n_prefix( dict_stats_analyze_index_below_cur(btr_pcur_get_btr_cur(&pcur), n_prefix, &n_diff_on_leaf_page, - &n_external_pages, - mtr); + &n_external_pages); /* We adjust n_diff_on_leaf_page here to avoid counting one record twice - once as the last on some page and once diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc index bbef1afcda6..99a44ffa639 100644 --- a/storage/xtradb/fil/fil0fil.cc +++ b/storage/xtradb/fil/fil0fil.cc @@ -5060,12 +5060,15 @@ retry: os_offset_t offset = ((os_offset_t) (start_page_no - file_start_page_no)) * page_size; + + const char* name = node->name == NULL ? space->name : node->name; + #ifdef UNIV_HOTBACKUP - success = os_file_write(node->name, node->handle, buf, + success = os_file_write(name, node->handle, buf, offset, page_size * n_pages); #else success = os_aio(OS_FILE_WRITE, OS_AIO_SYNC, - node->name, node->handle, buf, + name, node->handle, buf, offset, page_size * n_pages, NULL, NULL, space_id, NULL); #endif /* UNIV_HOTBACKUP */ @@ -5664,7 +5667,9 @@ _fil_io( } /* Queue the aio request */ - ret = os_aio(type, mode | wake_later, node->name, node->handle, buf, + const char* name = node->name == NULL ? space->name : node->name; + + ret = os_aio(type, mode | wake_later, name, node->handle, buf, offset, len, node, message, space_id, trx); #else @@ -5673,7 +5678,7 @@ _fil_io( ret = os_file_read(node->handle, buf, offset, len); } else { ut_ad(!srv_read_only_mode); - ret = os_file_write(node->name, node->handle, buf, + ret = os_file_write(name, node->handle, buf, offset, len); } #endif /* !UNIV_HOTBACKUP */ diff --git a/storage/xtradb/fts/fts0fts.cc b/storage/xtradb/fts/fts0fts.cc index 5adda1fad6c..267d95a71ed 100644 --- a/storage/xtradb/fts/fts0fts.cc +++ b/storage/xtradb/fts/fts0fts.cc @@ -6274,7 +6274,7 @@ fts_fake_hex_to_dec( #ifdef _WIN32 ret = sscanf(tmp_id, "%016llu", &dec_id); #else - ret = sscanf(tmp_id, "%016"PRIu64, &dec_id); + ret = sscanf(tmp_id, "%016" PRIu64, &dec_id); #endif /* _WIN32 */ ut_ad(ret == 1); diff --git a/storage/xtradb/fts/fts0opt.cc b/storage/xtradb/fts/fts0opt.cc index e096b8bf6d6..00b3b4682c3 100644 --- a/storage/xtradb/fts/fts0opt.cc +++ b/storage/xtradb/fts/fts0opt.cc @@ -580,7 +580,7 @@ fts_zip_read_word( #ifdef UNIV_DEBUG ulint i; #endif - byte len = 0; + short len = 0; void* null = NULL; byte* ptr = word->f_str; int flush = Z_NO_FLUSH; @@ -590,7 +590,7 @@ fts_zip_read_word( return(NULL); } - zip->zp->next_out = &len; + zip->zp->next_out = reinterpret_cast<byte*>(&len); zip->zp->avail_out = sizeof(len); while (zip->status == Z_OK && zip->zp->avail_out > 0) { @@ -598,7 +598,7 @@ fts_zip_read_word( /* Finished decompressing block. */ if (zip->zp->avail_in == 0) { - /* Free the block thats been decompressed. */ + /* Free the block that's been decompressed. */ if (zip->pos > 0) { ulint prev = zip->pos - 1; @@ -688,11 +688,12 @@ fts_fetch_index_words( fts_zip_t* zip = static_cast<fts_zip_t*>(user_arg); que_node_t* exp = sel_node->select_list; dfield_t* dfield = que_node_get_val(exp); - byte len = (byte) dfield_get_len(dfield); + short len = static_cast<short>(dfield_get_len(dfield)); void* data = dfield_get_data(dfield); /* Skip the duplicate words. */ - if (zip->word.f_len == len && !memcmp(zip->word.f_str, data, len)) { + if (zip->word.f_len == static_cast<ulint>(len) + && !memcmp(zip->word.f_str, data, len)) { return(TRUE); } @@ -706,7 +707,7 @@ fts_fetch_index_words( ut_a(zip->zp->next_in == NULL); /* The string is prefixed by len. */ - zip->zp->next_in = &len; + zip->zp->next_in = reinterpret_cast<byte*>(&len); zip->zp->avail_in = sizeof(len); /* Compress the word, create output blocks as necessary. */ diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 5e67e3e3e5d..d06e5cca333 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -4,7 +4,7 @@ Copyright (c) 2000, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2013, 2014 SkySQL Ab. All Rights Reserved. +Copyright (c) 2013, 2016, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -604,6 +604,68 @@ ib_cb_t innodb_api_cb[] = { (ib_cb_t) ib_trx_read_only }; +/** + Test a file path whether it is same as mysql data directory path. + + @param path null terminated character string + + @return + @retval TRUE The path is different from mysql data directory. + @retval FALSE The path is same as mysql data directory. +*/ +static bool is_mysql_datadir_path(const char *path) +{ + if (path == NULL) + return false; + + char mysql_data_dir[FN_REFLEN], path_dir[FN_REFLEN]; + convert_dirname(path_dir, path, NullS); + convert_dirname(mysql_data_dir, mysql_unpacked_real_data_home, NullS); + size_t mysql_data_home_len= dirname_length(mysql_data_dir); + size_t path_len = dirname_length(path_dir); + + if (path_len < mysql_data_home_len) + return true; + + if (!lower_case_file_system) + return(memcmp(mysql_data_dir, path_dir, mysql_data_home_len)); + + return(files_charset_info->coll->strnncoll(files_charset_info, + (uchar *) path_dir, path_len, + (uchar *) mysql_data_dir, + mysql_data_home_len, + TRUE)); +} + + +static int mysql_tmpfile_path(const char *path, const char *prefix) +{ + DBUG_ASSERT(path != NULL); + DBUG_ASSERT((strlen(path) + strlen(prefix)) <= FN_REFLEN); + + char filename[FN_REFLEN]; + File fd = create_temp_file(filename, path, prefix, +#ifdef __WIN__ + O_BINARY | O_TRUNC | O_SEQUENTIAL | + O_SHORT_LIVED | +#endif /* __WIN__ */ + O_CREAT | O_EXCL | O_RDWR | O_TEMPORARY, + MYF(MY_WME)); + if (fd >= 0) { +#ifndef __WIN__ + /* + This can be removed once the following bug is fixed: + Bug #28903 create_temp_file() doesn't honor O_TEMPORARY option + (file not removed) (Unix) + */ + unlink(filename); +#endif /* !__WIN__ */ + } + + return fd; +} + + /*************************************************************//** Check whether valid argument given to innodb_ft_*_stopword_table. This function is registered as a callback with MySQL. @@ -619,6 +681,108 @@ innodb_stopword_table_validate( for update function */ struct st_mysql_value* value); /*!< in: incoming string */ +/** Validate passed-in "value" is a valid directory name. +This function is registered as a callback with MySQL. +@param[in,out] thd thread handle +@param[in] var pointer to system variable +@param[out] save immediate result for update +@param[in] value incoming string +@return 0 for valid name */ +static +int +innodb_tmpdir_validate( + THD* thd, + struct st_mysql_sys_var* var, + void* save, + struct st_mysql_value* value) +{ + + char* alter_tmp_dir; + char* innodb_tmp_dir; + char buff[OS_FILE_MAX_PATH]; + int len = sizeof(buff); + char tmp_abs_path[FN_REFLEN + 2]; + + ut_ad(save != NULL); + ut_ad(value != NULL); + + if (check_global_access(thd, FILE_ACL)) { + push_warning_printf( + thd, Sql_condition::WARN_LEVEL_WARN, + ER_WRONG_ARGUMENTS, + "InnoDB: FILE Permissions required"); + *static_cast<const char**>(save) = NULL; + return(1); + } + + alter_tmp_dir = (char*) value->val_str(value, buff, &len); + + if (!alter_tmp_dir) { + *static_cast<const char**>(save) = alter_tmp_dir; + return(0); + } + + if (strlen(alter_tmp_dir) > FN_REFLEN) { + push_warning_printf( + thd, Sql_condition::WARN_LEVEL_WARN, + ER_WRONG_ARGUMENTS, + "Path length should not exceed %d bytes", FN_REFLEN); + *static_cast<const char**>(save) = NULL; + return(1); + } + + my_realpath(tmp_abs_path, alter_tmp_dir, 0); + size_t tmp_abs_len = strlen(tmp_abs_path); + + if (my_access(tmp_abs_path, F_OK)) { + + push_warning_printf( + thd, Sql_condition::WARN_LEVEL_WARN, + ER_WRONG_ARGUMENTS, + "InnoDB: Path doesn't exist."); + *static_cast<const char**>(save) = NULL; + return(1); + } else if (my_access(tmp_abs_path, R_OK | W_OK)) { + push_warning_printf( + thd, Sql_condition::WARN_LEVEL_WARN, + ER_WRONG_ARGUMENTS, + "InnoDB: Server doesn't have permission in " + "the given location."); + *static_cast<const char**>(save) = NULL; + return(1); + } + + MY_STAT stat_info_dir; + + if (my_stat(tmp_abs_path, &stat_info_dir, MYF(0))) { + if ((stat_info_dir.st_mode & S_IFDIR) != S_IFDIR) { + + push_warning_printf( + thd, Sql_condition::WARN_LEVEL_WARN, + ER_WRONG_ARGUMENTS, + "Given path is not a directory. "); + *static_cast<const char**>(save) = NULL; + return(1); + } + } + + if (!is_mysql_datadir_path(tmp_abs_path)) { + + push_warning_printf( + thd, Sql_condition::WARN_LEVEL_WARN, + ER_WRONG_ARGUMENTS, + "InnoDB: Path Location should not be same as " + "mysql data directory location."); + *static_cast<const char**>(save) = NULL; + return(1); + } + + innodb_tmp_dir = static_cast<char*>( + thd_memdup(thd, tmp_abs_path, tmp_abs_len + 1)); + *static_cast<const char**>(save) = innodb_tmp_dir; + return(0); +} + /** "GEN_CLUST_INDEX" is the name reserved for InnoDB default system clustered index when there is no primary key. */ const char innobase_index_reserve_name[] = "GEN_CLUST_INDEX"; @@ -723,6 +887,10 @@ static MYSQL_THDVAR_BOOL(fake_changes, PLUGIN_VAR_OPCMDARG, "This is to cause replication prefetch IO. ATTENTION: the transaction started after enabled is affected.", NULL, NULL, FALSE); +static MYSQL_THDVAR_STR(tmpdir, + PLUGIN_VAR_OPCMDARG|PLUGIN_VAR_MEMALLOC, + "Directory for temporary non-tablespace files.", + innodb_tmpdir_validate, NULL, NULL); static SHOW_VAR innodb_status_variables[]= { {"available_undo_logs", @@ -1325,6 +1493,28 @@ normalize_table_name_low( ibool set_lower_case); /* in: TRUE if we want to set name to lower case */ +/*************************************************************//** +Checks if buffer pool is big enough to enable backoff algorithm. +InnoDB empty free list algorithm backoff requires free pages +from LRU for the best performance. +buf_LRU_buf_pool_running_out cancels query if 1/4 of +buffer pool belongs to LRU or freelist. +At the same time buf_flush_LRU_list_batch +keeps up to BUF_LRU_MIN_LEN in LRU. +In order to avoid deadlock baclkoff requires buffer pool +to be at least 4*BUF_LRU_MIN_LEN, +but flush peformance is bad because of trashing +and additional BUF_LRU_MIN_LEN pages are requested. +@return true if it's possible to enable backoff. */ +static +bool +innodb_empty_free_list_algorithm_backoff_allowed( + srv_empty_free_list_t + algorithm, /*!< in: desired algorithm + from srv_empty_free_list_t */ + long long buf_pool_pages); /*!< in: total number + of pages inside buffer pool */ + #ifdef NOT_USED /*************************************************************//** Removes old archived transaction log files. @@ -1613,6 +1803,26 @@ thd_supports_xa( return(THDVAR(thd, support_xa)); } +/** Get the value of innodb_tmpdir. +@param[in] thd thread handle, or NULL to query + the global innodb_tmpdir. +@retval NULL if innodb_tmpdir="" */ +UNIV_INTERN +const char* +thd_innodb_tmpdir( + THD* thd) +{ +#ifdef UNIV_SYNC_DEBUG + ut_ad(!sync_thread_levels_nonempty_trx(false)); +#endif /* UNIV_SYNC_DEBUG */ + + const char* tmp_dir = THDVAR(thd, tmpdir); + if (tmp_dir != NULL && *tmp_dir == '\0') { + tmp_dir = NULL; + } + + return(tmp_dir); +} /******************************************************************//** Check the status of fake changes mode (innodb_fake_changes) @return true if fake change mode is enabled. */ @@ -2190,13 +2400,14 @@ innobase_get_lower_case_table_names(void) return(lower_case_table_names); } -/*********************************************************************//** -Creates a temporary file. +/** Create a temporary file in the location specified by the parameter +path. If the path is null, then it will be created in tmpdir. +@param[in] path location for creating temporary file @return temporary file descriptor, or < 0 on error */ UNIV_INTERN int -innobase_mysql_tmpfile(void) -/*========================*/ +innobase_mysql_tmpfile( + const char* path) { #ifdef WITH_INNODB_DISALLOW_WRITES os_event_wait(srv_allow_writes_event); @@ -2209,7 +2420,11 @@ innobase_mysql_tmpfile(void) return(-1); ); - fd = mysql_tmpfile("ib"); + if (path == NULL) { + fd = mysql_tmpfile("ib"); + } else { + fd = mysql_tmpfile_path(path, "ib"); + } if (fd >= 0) { /* Copy the file descriptor, so that the additional resources @@ -3236,6 +3451,13 @@ ha_innobase::reset_template(void) ut_ad(prebuilt->magic_n == ROW_PREBUILT_ALLOCATED); ut_ad(prebuilt->magic_n2 == prebuilt->magic_n); + /* Force table to be freed in close_thread_table(). */ + DBUG_EXECUTE_IF("free_table_in_fts_query", + if (prebuilt->in_fts_query) { + table->m_needs_reopen = true; + } + ); + prebuilt->keep_other_fields_on_keyread = 0; prebuilt->read_just_key = 0; prebuilt->in_fts_query = 0; @@ -3831,6 +4053,22 @@ innobase_change_buffering_inited_ok: #ifdef HAVE_POSIX_FALLOCATE srv_use_posix_fallocate = (ibool) innobase_use_fallocate; #endif + + /* Do not enable backoff algorithm for small buffer pool. */ + if (!innodb_empty_free_list_algorithm_backoff_allowed( + static_cast<srv_empty_free_list_t>( + srv_empty_free_list_algorithm), + innobase_buffer_pool_size / srv_page_size)) { + sql_print_information( + "InnoDB: innodb_empty_free_list_algorithm " + "has been changed to legacy " + "because of small buffer pool size. " + "In order to use backoff, " + "increase buffer pool at least up to 20MB.\n"); + srv_empty_free_list_algorithm + = SRV_EMPTY_FREE_LIST_LEGACY; + } + srv_use_atomic_writes = (ibool) innobase_use_atomic_writes; if (innobase_use_atomic_writes) { ib_logf(IB_LOG_LEVEL_INFO, "using atomic writes."); @@ -5570,7 +5808,7 @@ building based on the assumption that there is no concurrent index creation/drop and DMLs that requires index lookup. All table handle will be closed before the index creation/drop. @return TRUE if index translation table built successfully */ -static +UNIV_INTERN ibool innobase_build_index_translation( /*=============================*/ @@ -6080,20 +6318,14 @@ table_opened: prebuilt->clust_index_was_generated = FALSE; if (UNIV_UNLIKELY(primary_key >= MAX_KEY)) { - sql_print_error("Table %s has a primary key in " - "InnoDB data dictionary, but not " - "in MySQL!", name); + ib_table->dict_frm_mismatch = DICT_FRM_NO_PK; /* This mismatch could cause further problems if not attended, bring this to the user's attention by printing a warning in addition to log a message in the errorlog */ - push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, - ER_NO_SUCH_INDEX, - "InnoDB: Table %s has a " - "primary key in InnoDB data " - "dictionary, but not in " - "MySQL!", name); + + ib_push_frm_error(thd, ib_table, table, 0, true); /* If primary_key >= MAX_KEY, its (primary_key) value could be out of bound if continue to index @@ -6140,27 +6372,14 @@ table_opened: } } else { if (primary_key != MAX_KEY) { - sql_print_error( - "Table %s has no primary key in InnoDB data " - "dictionary, but has one in MySQL! If you " - "created the table with a MySQL version < " - "3.23.54 and did not define a primary key, " - "but defined a unique key with all non-NULL " - "columns, then MySQL internally treats that " - "key as the primary key. You can fix this " - "error by dump + DROP + CREATE + reimport " - "of the table.", name); + + ib_table->dict_frm_mismatch = DICT_NO_PK_FRM_HAS; /* This mismatch could cause further problems if not attended, bring this to the user attention by printing a warning in addition to log a message in the errorlog */ - push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, - ER_NO_SUCH_INDEX, - "InnoDB: Table %s has no " - "primary key in InnoDB data " - "dictionary, but has one in " - "MySQL!", name); + ib_push_frm_error(thd, ib_table, table, 0, true); } prebuilt->clust_index_was_generated = TRUE; @@ -8109,7 +8328,7 @@ ha_innobase::write_row( if (share->ib_table != prebuilt->table) { fprintf(stderr, - "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.", share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); } @@ -8462,7 +8681,7 @@ func_exit: if (share->ib_table != prebuilt->table) { fprintf(stderr, - "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.", share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); } @@ -8881,7 +9100,7 @@ ha_innobase::update_row( if (share->ib_table != prebuilt->table) { fprintf(stderr, - "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.", share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); } @@ -9002,7 +9221,7 @@ wsrep_error: if (share->ib_table != prebuilt->table) { fprintf(stderr, - "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.", share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); } @@ -12301,7 +12520,7 @@ ha_innobase::truncate() if (share->ib_table != prebuilt->table) { fprintf(stderr, - "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.", share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); } @@ -12322,7 +12541,7 @@ ha_innobase::truncate() if (share->ib_table != prebuilt->table) { fprintf(stderr, - "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.", share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); } @@ -13428,12 +13647,8 @@ ha_innobase::info_low( } if (table->s->keys != num_innodb_index) { - sql_print_error("InnoDB: Table %s contains %lu " - "indexes inside InnoDB, which " - "is different from the number of " - "indexes %u defined in the MySQL ", - ib_table->name, num_innodb_index, - table->s->keys); + ib_table->dict_frm_mismatch = DICT_FRM_INCONSISTENT_KEYS; + ib_push_frm_error(user_thd, ib_table, table, num_innodb_index, true); } if (!(flag & HA_STATUS_NO_LOCK)) { @@ -13453,15 +13668,8 @@ ha_innobase::info_low( dict_index_t* index = innobase_get_index(i); if (index == NULL) { - sql_print_error("Table %s contains fewer " - "indexes inside InnoDB than " - "are defined in the MySQL " - ".frm file. Have you mixed up " - ".frm files from different " - "installations? See " - REFMAN - "innodb-troubleshooting.html\n", - ib_table->name); + ib_table->dict_frm_mismatch = DICT_FRM_INCONSISTENT_KEYS; + ib_push_frm_error(user_thd, ib_table, table, num_innodb_index, true); break; } @@ -13623,7 +13831,7 @@ ha_innobase::analyze( if (share->ib_table != prebuilt->table) { fprintf(stderr, - "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.", share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); } @@ -13639,7 +13847,7 @@ ha_innobase::analyze( if (share->ib_table != prebuilt->table) { fprintf(stderr, - "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.", share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); } @@ -14820,7 +15028,7 @@ ha_innobase::transactional_table_lock( if (share->ib_table != prebuilt->table) { fprintf(stderr, - "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.", + "InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.", share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt); } @@ -18158,8 +18366,6 @@ innobase_fts_close_ranking( { fts_result_t* result; - ((NEW_FT_INFO*) fts_hdl)->ft_prebuilt->in_fts_query = false; - result = ((NEW_FT_INFO*) fts_hdl)->ft_result; fts_query_free_result(result); @@ -18510,6 +18716,87 @@ innodb_status_output_update( os_event_set(srv_monitor_event); } +/*************************************************************//** +Empty free list algorithm. +Checks if buffer pool is big enough to enable backoff algorithm. +InnoDB empty free list algorithm backoff requires free pages +from LRU for the best performance. +buf_LRU_buf_pool_running_out cancels query if 1/4 of +buffer pool belongs to LRU or freelist. +At the same time buf_flush_LRU_list_batch +keeps up to BUF_LRU_MIN_LEN in LRU. +In order to avoid deadlock baclkoff requires buffer pool +to be at least 4*BUF_LRU_MIN_LEN, +but flush peformance is bad because of trashing +and additional BUF_LRU_MIN_LEN pages are requested. +@return true if it's possible to enable backoff. */ +static +bool +innodb_empty_free_list_algorithm_backoff_allowed( + srv_empty_free_list_t algorithm, /*!< in: desired algorithm + from srv_empty_free_list_t */ + long long buf_pool_pages) /*!< in: total number + of pages inside buffer pool */ +{ + return(buf_pool_pages >= BUF_LRU_MIN_LEN * (4 + 1) + || algorithm != SRV_EMPTY_FREE_LIST_BACKOFF); +} + +/*************************************************************//** +Empty free list algorithm. This function is registered as +a callback with MySQL. +@return 0 for valid algorithm */ +static +int +innodb_srv_empty_free_list_algorithm_validate( +/*===========================*/ + THD* thd, /*!< in: thread handle */ + struct st_mysql_sys_var* var, /*!< in: pointer to system + variable */ + void* save, /*!< out: immediate result + for update function */ + struct st_mysql_value* value) /*!< in: incoming string */ +{ + const char* algorithm_name; + char buff[STRING_BUFFER_USUAL_SIZE]; + int len = sizeof(buff); + ulint algo; + srv_empty_free_list_t algorithm; + + algorithm_name = value->val_str(value, buff, &len); + + if (!algorithm_name) { + return(1); + } + + for (algo = 0; algo < array_elements( + innodb_empty_free_list_algorithm_names + ) - 1; + algo++) { + if (!innobase_strcasecmp( + algorithm_name, + innodb_empty_free_list_algorithm_names[algo])) + break; + } + + if (algo == array_elements( innodb_empty_free_list_algorithm_names) - 1) + return(1); + + algorithm = static_cast<srv_empty_free_list_t>(algo); + if (!innodb_empty_free_list_algorithm_backoff_allowed( + algorithm, + innobase_buffer_pool_size / srv_page_size)) { + sql_print_warning( + "InnoDB: innodb_empty_free_list_algorithm " + "= 'backoff' requires at least" + " 20MB buffer pool.\n"); + return(1); + } + + *reinterpret_cast<ulong*>(save) = static_cast<ulong>(algorithm); + return(0); +} + static SHOW_VAR innodb_status_variables_export[]= { {"Innodb", (char*) &show_innodb_vars, SHOW_FUNC}, {NullS, NullS, SHOW_LONG} @@ -19382,7 +19669,7 @@ static MYSQL_SYSVAR_ENUM(empty_free_list_algorithm, "The algorithm to use for empty free list handling. Allowed values: " "LEGACY: Original Oracle MySQL 5.6 handling with single page flushes; " "BACKOFF: (default) Wait until cleaner produces a free page.", - NULL, NULL, SRV_EMPTY_FREE_LIST_BACKOFF, + innodb_srv_empty_free_list_algorithm_validate, NULL, SRV_EMPTY_FREE_LIST_BACKOFF, &innodb_empty_free_list_algorithm_typelib); static MYSQL_SYSVAR_LONG(buffer_pool_instances, innobase_buffer_pool_instances, @@ -20177,6 +20464,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(corrupt_table_action), MYSQL_SYSVAR(fake_changes), MYSQL_SYSVAR(locking_fake_changes), + MYSQL_SYSVAR(tmpdir), MYSQL_SYSVAR(use_stacktrace), MYSQL_SYSVAR(simulate_comp_failures), NULL @@ -20739,3 +21027,96 @@ ib_push_warning( my_free(buf); va_end(args); } + +/********************************************************************//** +Helper function to push frm mismatch error to error log and +if needed to sql-layer. */ +UNIV_INTERN +void +ib_push_frm_error( +/*==============*/ + THD* thd, /*!< in: MySQL thd */ + dict_table_t* ib_table, /*!< in: InnoDB table */ + TABLE* table, /*!< in: MySQL table */ + ulint n_keys, /*!< in: InnoDB #keys */ + bool push_warning) /*!< in: print warning ? */ +{ + switch (ib_table->dict_frm_mismatch) { + case DICT_FRM_NO_PK: + sql_print_error("Table %s has a primary key in " + "InnoDB data dictionary, but not " + "in MySQL!" + " Have you mixed up " + ".frm files from different " + "installations? See " + REFMAN + "innodb-troubleshooting.html\n", + ib_table->name); + + if (push_warning) { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + ER_NO_SUCH_INDEX, + "InnoDB: Table %s has a " + "primary key in InnoDB data " + "dictionary, but not in " + "MySQL!", ib_table->name); + } + break; + case DICT_NO_PK_FRM_HAS: + sql_print_error( + "Table %s has no primary key in InnoDB data " + "dictionary, but has one in MySQL! If you " + "created the table with a MySQL version < " + "3.23.54 and did not define a primary key, " + "but defined a unique key with all non-NULL " + "columns, then MySQL internally treats that " + "key as the primary key. You can fix this " + "error by dump + DROP + CREATE + reimport " + "of the table.", ib_table->name); + + if (push_warning) { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + ER_NO_SUCH_INDEX, + "InnoDB: Table %s has no " + "primary key in InnoDB data " + "dictionary, but has one in " + "MySQL!", + ib_table->name); + } + break; + + case DICT_FRM_INCONSISTENT_KEYS: + sql_print_error("InnoDB: Table %s contains %lu " + "indexes inside InnoDB, which " + "is different from the number of " + "indexes %u defined in the MySQL " + " Have you mixed up " + ".frm files from different " + "installations? See " + REFMAN + "innodb-troubleshooting.html\n", + ib_table->name, n_keys, + table->s->keys); + + if (push_warning) { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + ER_NO_SUCH_INDEX, + "InnoDB: Table %s contains %lu " + "indexes inside InnoDB, which " + "is different from the number of " + "indexes %u defined in the MySQL ", + ib_table->name, n_keys, + table->s->keys); + } + break; + + case DICT_FRM_CONSISTENT: + default: + sql_print_error("InnoDB: Table %s is consistent " + "on InnoDB data dictionary and MySQL " + " FRM file.", + ib_table->name); + ut_error; + break; + } +} diff --git a/storage/xtradb/handler/ha_innodb.h b/storage/xtradb/handler/ha_innodb.h index 7fd39741993..34a3567e99f 100644 --- a/storage/xtradb/handler/ha_innodb.h +++ b/storage/xtradb/handler/ha_innodb.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2016, 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 @@ -686,3 +687,39 @@ innobase_copy_frm_flags_from_table_share( /*=====================================*/ dict_table_t* innodb_table, /*!< in/out: InnoDB table */ const TABLE_SHARE* table_share); /*!< in: table share */ + +/*******************************************************************//** +This function builds a translation table in INNOBASE_SHARE +structure for fast index location with mysql array number from its +table->key_info structure. This also provides the necessary translation +between the key order in mysql key_info and Innodb ib_table->indexes if +they are not fully matched with each other. +Note we do not have any mutex protecting the translation table +building based on the assumption that there is no concurrent +index creation/drop and DMLs that requires index lookup. All table +handle will be closed before the index creation/drop. +@return TRUE if index translation table built successfully */ +UNIV_INTERN +ibool +innobase_build_index_translation( +/*=============================*/ + const TABLE* table, /*!< in: table in MySQL data + dictionary */ + dict_table_t* ib_table, /*!< in: table in Innodb data + dictionary */ + INNOBASE_SHARE* share); /*!< in/out: share structure + where index translation table + will be constructed in. */ + +/********************************************************************//** +Helper function to push frm mismatch error to error log and +if needed to sql-layer. */ +UNIV_INTERN +void +ib_push_frm_error( +/*==============*/ + THD* thd, /*!< in: MySQL thd */ + dict_table_t* ib_table, /*!< in: InnoDB table */ + TABLE* table, /*!< in: MySQL table */ + ulint n_keys, /*!< in: InnoDB #keys */ + bool push_warning); /*!< in: print warning ? */ diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc index 70ab40534b4..0675469b4fa 100644 --- a/storage/xtradb/handler/handler0alter.cc +++ b/storage/xtradb/handler/handler0alter.cc @@ -439,6 +439,20 @@ ha_innobase::check_if_supported_inplace_alter( } } + ulint n_indexes = UT_LIST_GET_LEN((prebuilt->table)->indexes); + + /* If InnoDB dictionary and MySQL frm file are not consistent + use "Copy" method. */ + if (prebuilt->table->dict_frm_mismatch) { + + ha_alter_info->unsupported_reason = innobase_get_err_msg( + ER_NO_SUCH_INDEX); + ib_push_frm_error(user_thd, prebuilt->table, altered_table, + n_indexes, true); + + DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED); + } + /* We should be able to do the operation in-place. See if we can do it online (LOCK=NONE). */ bool online = true; @@ -2751,6 +2765,10 @@ prepare_inplace_alter_table_dict( ctx->num_to_add_index = ha_alter_info->index_add_count; + ut_ad(ctx->prebuilt->trx->mysql_thd != NULL); + const char* path = thd_innodb_tmpdir( + ctx->prebuilt->trx->mysql_thd); + index_defs = innobase_create_key_defs( ctx->heap, ha_alter_info, altered_table, ctx->num_to_add_index, num_fts_index, @@ -3094,8 +3112,10 @@ prepare_inplace_alter_table_dict( error = DB_OUT_OF_MEMORY; goto error_handling;); rw_lock_x_lock(&ctx->add_index[a]->lock); + bool ok = row_log_allocate(ctx->add_index[a], - NULL, true, NULL, NULL); + NULL, true, NULL, + NULL, path); rw_lock_x_unlock(&ctx->add_index[a]->lock); if (!ok) { @@ -3121,7 +3141,7 @@ prepare_inplace_alter_table_dict( clust_index, ctx->new_table, !(ha_alter_info->handler_flags & Alter_inplace_info::ADD_PK_INDEX), - ctx->add_cols, ctx->col_map); + ctx->add_cols, ctx->col_map, path); rw_lock_x_unlock(&clust_index->lock); if (!ok) { @@ -4107,6 +4127,7 @@ ok_exit: files and merge sort. */ DBUG_EXECUTE_IF("innodb_OOM_inplace_alter", error = DB_OUT_OF_MEMORY; goto oom;); + error = row_merge_build_indexes( prebuilt->trx, prebuilt->table, ctx->new_table, @@ -6130,6 +6151,21 @@ foreign_fail: row_mysql_unlock_data_dictionary(trx); trx_free_for_mysql(trx); + /* Rebuild index translation table now for temporary tables if we are + restoring secondary keys, as ha_innobase::open will not be called for + the next access. */ + if (dict_table_is_temporary(ctx0->new_table) + && ctx0->num_to_add_index > 0) { + ut_ad(!ctx0->num_to_drop_index); + ut_ad(!ctx0->num_to_drop_fk); + if (!innobase_build_index_translation(altered_table, + ctx0->new_table, + share)) { + MONITOR_ATOMIC_DEC(MONITOR_PENDING_ALTER_TABLE); + DBUG_RETURN(true); + } + } + /* TODO: The following code could be executed while allowing concurrent access to the table (MDL downgrade). */ diff --git a/storage/xtradb/include/buf0flu.h b/storage/xtradb/include/buf0flu.h index 2cd8eefb79d..83f1275e4d2 100644 --- a/storage/xtradb/include/buf0flu.h +++ b/storage/xtradb/include/buf0flu.h @@ -304,6 +304,12 @@ buf_flush_flush_list_in_progress(void) /*==================================*/ __attribute__((warn_unused_result)); +/** If LRU list of a buf_pool is less than this size then LRU eviction +should not happen. This is because when we do LRU flushing we also put +the blocks on free list. If LRU list is very small then we can end up +in thrashing. */ +#define BUF_LRU_MIN_LEN 256 + #ifndef UNIV_NONINL #include "buf0flu.ic" #endif diff --git a/storage/xtradb/include/dict0mem.h b/storage/xtradb/include/dict0mem.h index 519e52cba38..dfb5d85e383 100644 --- a/storage/xtradb/include/dict0mem.h +++ b/storage/xtradb/include/dict0mem.h @@ -2,6 +2,7 @@ Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2015, 2016, 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 @@ -917,6 +918,18 @@ if table->memcached_sync_count == DICT_TABLE_IN_DDL means there's DDL running on the table, DML from memcached will be blocked. */ #define DICT_TABLE_IN_DDL -1 +/** These are used when MySQL FRM and InnoDB data dictionary are +in inconsistent state. */ +typedef enum { + DICT_FRM_CONSISTENT = 0, /*!< Consistent state */ + DICT_FRM_NO_PK = 1, /*!< MySQL has no primary key + but InnoDB dictionary has + non-generated one. */ + DICT_NO_PK_FRM_HAS = 2, /*!< MySQL has primary key but + InnoDB dictionary has not. */ + DICT_FRM_INCONSISTENT_KEYS = 3 /*!< Key count mismatch */ +} dict_frm_t; + /** Data structure for a database table. Most fields will be initialized to 0, NULL or FALSE in dict_mem_table_create(). */ struct dict_table_t{ @@ -975,6 +988,10 @@ struct dict_table_t{ /*!< True if the table belongs to a system database (mysql, information_schema or performance_schema) */ + dict_frm_t dict_frm_mismatch; + /*!< !DICT_FRM_CONSISTENT==0 if data + dictionary information and + MySQL FRM information mismatch. */ #ifndef UNIV_HOTBACKUP hash_node_t name_hash; /*!< hash chain node */ hash_node_t id_hash; /*!< hash chain node */ diff --git a/storage/xtradb/include/fts0priv.ic b/storage/xtradb/include/fts0priv.ic index 2d07c60f980..ec61691870b 100644 --- a/storage/xtradb/include/fts0priv.ic +++ b/storage/xtradb/include/fts0priv.ic @@ -53,7 +53,7 @@ fts_write_object_id( /* Use this to construct old(5.6.14 and 5.7.3) windows ambiguous aux table names */ DBUG_EXECUTE_IF("innodb_test_wrong_windows_fts_aux_table_name", - return(sprintf(str, "%016"PRIu64, id));); + return(sprintf(str, "%016" PRIu64, id));); DBUG_EXECUTE_IF("innodb_test_wrong_fts_aux_table_name", return(sprintf(str, UINT64PFx, id));); @@ -66,7 +66,7 @@ fts_write_object_id( // FIXME: Use ut_snprintf(), so does following one. return(sprintf(str, "%016llu", id)); #else /* _WIN32 */ - return(sprintf(str, "%016"PRIu64, id)); + return(sprintf(str, "%016" PRIu64, id)); #endif /* _WIN32 */ } diff --git a/storage/xtradb/include/ha_prototypes.h b/storage/xtradb/include/ha_prototypes.h index 259cf8380a7..c25ac1ef045 100644 --- a/storage/xtradb/include/ha_prototypes.h +++ b/storage/xtradb/include/ha_prototypes.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2015, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -363,6 +363,15 @@ thd_supports_xa( THD* thd); /*!< in: thread handle, or NULL to query the global innodb_supports_xa */ +/** Get status of innodb_tmpdir. +@param[in] thd thread handle, or NULL to query + the global innodb_tmpdir. +@retval NULL if innodb_tmpdir="" */ +UNIV_INTERN +const char* +thd_innodb_tmpdir( + THD* thd); + /******************************************************************//** Check the status of fake changes mode (innodb_fake_changes) @return true if fake change mode is enabled. */ diff --git a/storage/xtradb/include/os0file.h b/storage/xtradb/include/os0file.h index 93e1b3edef9..1a6651df58a 100644 --- a/storage/xtradb/include/os0file.h +++ b/storage/xtradb/include/os0file.h @@ -456,14 +456,19 @@ UNIV_INTERN void os_io_init_simple(void); /*===================*/ -/***********************************************************************//** -Creates a temporary file. This function is like tmpfile(3), but -the temporary file is created in the MySQL temporary directory. -@return temporary file handle, or NULL on error */ + +/** Create a temporary file. This function is like tmpfile(3), but +the temporary file is created in the given parameter path. If the path +is null then it will create the file in the mysql server configuration +parameter (--tmpdir). +@param[in] path location for creating temporary file +@return temporary file handle, or NULL on error */ +UNIV_INTERN FILE* -os_file_create_tmpfile(void); -/*========================*/ +os_file_create_tmpfile( + const char* path); + #endif /* !UNIV_HOTBACKUP */ /***********************************************************************//** The os_file_opendir() function opens a directory stream corresponding to the @@ -1285,14 +1290,14 @@ os_file_get_status( file can be opened in RW mode */ #if !defined(UNIV_HOTBACKUP) -/*********************************************************************//** -Creates a temporary file that will be deleted on close. -This function is defined in ha_innodb.cc. -@return temporary file descriptor, or < 0 on error */ +/** Create a temporary file in the location specified by the parameter +path. If the path is null, then it will be created in tmpdir. +@param[in] path location for creating temporary file +@return temporary file descriptor, or < 0 on error */ UNIV_INTERN int -innobase_mysql_tmpfile(void); -/*========================*/ +innobase_mysql_tmpfile( + const char* path); #endif /* !UNIV_HOTBACKUP */ diff --git a/storage/xtradb/include/row0log.h b/storage/xtradb/include/row0log.h index 62715fe8808..5eed390aced 100644 --- a/storage/xtradb/include/row0log.h +++ b/storage/xtradb/include/row0log.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -51,8 +51,9 @@ row_log_allocate( const dtuple_t* add_cols, /*!< in: default values of added columns, or NULL */ - const ulint* col_map)/*!< in: mapping of old column + const ulint* col_map,/*!< in: mapping of old column numbers to new ones, or NULL if !table */ + const char* path) /*!< in: where to create temporary file */ __attribute__((nonnull(1), warn_unused_result)); /******************************************************//** diff --git a/storage/xtradb/include/row0merge.h b/storage/xtradb/include/row0merge.h index 79cbf304722..8ce65ccd696 100644 --- a/storage/xtradb/include/row0merge.h +++ b/storage/xtradb/include/row0merge.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2015, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -171,14 +171,14 @@ void row_merge_drop_temp_indexes(void); /*=============================*/ -/*********************************************************************//** -Creates temporary merge files, and if UNIV_PFS_IO defined, register -the file descriptor with Performance Schema. +/** Create temporary merge files in the given paramater path, and if +UNIV_PFS_IO defined, register the file descriptor with Performance Schema. +@param[in] path location for creating temporary merge files. @return File descriptor */ UNIV_INTERN int -row_merge_file_create_low(void) -/*===========================*/ +row_merge_file_create_low( + const char* path) __attribute__((warn_unused_result)); /*********************************************************************//** Destroy a merge file. And de-register the file from Performance Schema @@ -352,15 +352,17 @@ row_merge_buf_empty( /*================*/ row_merge_buf_t* buf) /*!< in,own: sort buffer */ __attribute__((warn_unused_result, nonnull)); -/*********************************************************************//** -Create a merge file. + +/** Create a merge file in the given location. +@param[out] merge_file merge file structure +@param[in] path location for creating temporary file @return file descriptor, or -1 on failure */ UNIV_INTERN int row_merge_file_create( -/*==================*/ - merge_file_t* merge_file) /*!< out: merge file structure */ - __attribute__((nonnull)); + merge_file_t* merge_file, + const char* path); + /*********************************************************************//** Merge disk files. @return DB_SUCCESS or error code */ diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i index cd2803d1855..8cdbad9f722 100644 --- a/storage/xtradb/include/univ.i +++ b/storage/xtradb/include/univ.i @@ -44,10 +44,10 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MINOR 6 -#define INNODB_VERSION_BUGFIX 28 +#define INNODB_VERSION_BUGFIX 29 #ifndef PERCONA_INNODB_VERSION -#define PERCONA_INNODB_VERSION 76.1 +#define PERCONA_INNODB_VERSION 76.2 #endif /* Enable UNIV_LOG_ARCHIVE in XtraDB */ diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc index 93955331204..6c4b08237f6 100644 --- a/storage/xtradb/lock/lock0lock.cc +++ b/storage/xtradb/lock/lock0lock.cc @@ -643,7 +643,7 @@ lock_sys_create( lock_sys->rec_num = 0; if (!srv_read_only_mode) { - lock_latest_err_file = os_file_create_tmpfile(); + lock_latest_err_file = os_file_create_tmpfile(NULL); ut_a(lock_latest_err_file); } } diff --git a/storage/xtradb/os/os0file.cc b/storage/xtradb/os/os0file.cc index 757e541962e..2de0402e0d2 100644 --- a/storage/xtradb/os/os0file.cc +++ b/storage/xtradb/os/os0file.cc @@ -864,19 +864,21 @@ os_io_init_simple(void) #endif } -/***********************************************************************//** -Creates a temporary file. This function is like tmpfile(3), but -the temporary file is created in the MySQL temporary directory. -@return temporary file handle, or NULL on error */ +/** Create a temporary file. This function is like tmpfile(3), but +the temporary file is created in the given parameter path. If the path +is null then it will create the file in the mysql server configuration +parameter (--tmpdir). +@param[in] path location for creating temporary file +@return temporary file handle, or NULL on error */ UNIV_INTERN FILE* -os_file_create_tmpfile(void) -/*========================*/ +os_file_create_tmpfile( + const char* path) { FILE* file = NULL; int fd; WAIT_ALLOW_WRITES(); - fd = innobase_mysql_tmpfile(); + fd = innobase_mysql_tmpfile(path); ut_ad(!srv_read_only_mode); @@ -2954,7 +2956,7 @@ try_again: "Error in system call pread(). The operating" " system error number is %lu.",(ulint) errno); } else { - /* Partial read occured */ + /* Partial read occurred */ ib_logf(IB_LOG_LEVEL_ERROR, "Tried to read " ULINTPF " bytes at offset " UINT64PF ". Was only able to read %ld.", @@ -3058,7 +3060,7 @@ try_again: "Error in system call pread(). The operating" " system error number is %lu.",(ulint) errno); } else { - /* Partial read occured */ + /* Partial read occurred */ ib_logf(IB_LOG_LEVEL_ERROR, "Tried to read " ULINTPF " bytes at offset " UINT64PF ". Was only able to read %ld.", @@ -3872,7 +3874,7 @@ os_aio_native_aio_supported(void) return(FALSE); } else if (!srv_read_only_mode) { /* Now check if tmpdir supports native aio ops. */ - fd = innobase_mysql_tmpfile(); + fd = innobase_mysql_tmpfile(NULL); if (fd < 0) { ib_logf(IB_LOG_LEVEL_WARN, diff --git a/storage/xtradb/row/row0ftsort.cc b/storage/xtradb/row/row0ftsort.cc index e38d9ef6276..731f3d6a98b 100644 --- a/storage/xtradb/row/row0ftsort.cc +++ b/storage/xtradb/row/row0ftsort.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2010, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2010, 2015, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -223,6 +223,9 @@ row_fts_psort_info_init( common_info->merge_event = os_event_create(); common_info->opt_doc_id_size = opt_doc_id_size; + ut_ad(trx->mysql_thd != NULL); + const char* path = thd_innodb_tmpdir(trx->mysql_thd); + /* There will be FTS_NUM_AUX_INDEX number of "sort buckets" for each parallel sort thread. Each "sort bucket" holds records for a particular "FTS index partition" */ @@ -244,8 +247,8 @@ row_fts_psort_info_init( psort_info[j].merge_buf[i] = row_merge_buf_create( dup->index); - if (row_merge_file_create(psort_info[j].merge_file[i]) - < 0) { + if (row_merge_file_create(psort_info[j].merge_file[i], + path) < 0) { goto func_exit; } @@ -613,6 +616,11 @@ fts_parallel_tokenization( ulint retried = 0; dberr_t error = DB_SUCCESS; + ut_ad(psort_info->psort_common->trx->mysql_thd != NULL); + + const char* path = thd_innodb_tmpdir( + psort_info->psort_common->trx->mysql_thd); + ut_ad(psort_info); buf = psort_info->merge_buf; @@ -843,7 +851,7 @@ exit: continue; } - tmpfd[i] = row_merge_file_create_low(); + tmpfd[i] = row_merge_file_create_low(path); if (tmpfd[i] < 0) { error = DB_OUT_OF_MEMORY; goto func_exit; diff --git a/storage/xtradb/row/row0log.cc b/storage/xtradb/row/row0log.cc index fa0b0887442..494bc8ae411 100644 --- a/storage/xtradb/row/row0log.cc +++ b/storage/xtradb/row/row0log.cc @@ -194,8 +194,25 @@ struct row_log_t { or by index->lock X-latch only */ row_log_buf_t head; /*!< reader context; protected by MDL only; modifiable by row_log_apply_ops() */ + const char* path; /*!< where to create temporary file during + log operation */ }; +/** Create the file or online log if it does not exist. +@param[in,out] log online rebuild log +@return file descriptor. */ +static __attribute__((warn_unused_result)) +int +row_log_tmpfile( + row_log_t* log) +{ + DBUG_ENTER("row_log_tmpfile"); + if (log->fd < 0) { + log->fd = row_merge_file_create_low(log->path); + } + + DBUG_RETURN(log->fd); +} /** Allocate the memory for the log buffer. @param[in,out] log_buf Buffer used for log operation @@ -340,6 +357,12 @@ row_log_online_op( log->tail.buf, avail_size); } UNIV_MEM_ASSERT_RW(log->tail.block, srv_sort_buf_size); + + if (row_log_tmpfile(log) < 0) { + log->error = DB_OUT_OF_MEMORY; + goto err_exit; + } + ret = os_file_write( "(modification log)", OS_FILE_FROM_FD(log->fd), @@ -450,6 +473,12 @@ row_log_table_close_func( log->tail.buf, avail); } UNIV_MEM_ASSERT_RW(log->tail.block, srv_sort_buf_size); + + if (row_log_tmpfile(log) < 0) { + log->error = DB_OUT_OF_MEMORY; + goto err_exit; + } + ret = os_file_write( "(modification log)", OS_FILE_FROM_FD(log->fd), @@ -469,6 +498,7 @@ write_failed: log->tail.total += size; UNIV_MEM_INVALID(log->tail.buf, sizeof log->tail.buf); +err_exit: mutex_exit(&log->mutex); } @@ -2536,7 +2566,8 @@ corruption: if (index->online_log->head.blocks) { #ifdef HAVE_FTRUNCATE /* Truncate the file in order to save space. */ - if (ftruncate(index->online_log->fd, 0) == -1) { + if (index->online_log->fd != -1 + && ftruncate(index->online_log->fd, 0) == -1) { perror("ftruncate"); } #endif /* HAVE_FTRUNCATE */ @@ -2852,8 +2883,9 @@ row_log_allocate( const dtuple_t* add_cols, /*!< in: default values of added columns, or NULL */ - const ulint* col_map)/*!< in: mapping of old column + const ulint* col_map,/*!< in: mapping of old column numbers to new ones, or NULL if !table */ + const char* path) /*!< in: where to create temporary file */ { row_log_t* log; DBUG_ENTER("row_log_allocate"); @@ -2872,11 +2904,7 @@ row_log_allocate( DBUG_RETURN(false); } - log->fd = row_merge_file_create_low(); - if (log->fd < 0) { - ut_free(log); - DBUG_RETURN(false); - } + log->fd = -1; mutex_create(index_online_log_key, &log->mutex, SYNC_INDEX_ONLINE_LOG); log->blobs = NULL; @@ -2891,6 +2919,7 @@ row_log_allocate( log->tail.block = log->head.block = NULL; log->head.blocks = log->head.bytes = 0; log->head.total = 0; + log->path = path; dict_index_set_online_status(index, ONLINE_INDEX_CREATION); index->online_log = log; @@ -3368,7 +3397,8 @@ corruption: if (index->online_log->head.blocks) { #ifdef HAVE_FTRUNCATE /* Truncate the file in order to save space. */ - if (ftruncate(index->online_log->fd, 0) == -1) { + if (index->online_log->fd != -1 + && ftruncate(index->online_log->fd, 0) == -1) { perror("ftruncate"); } #endif /* HAVE_FTRUNCATE */ diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc index a1de6b292ce..3839858ad27 100644 --- a/storage/xtradb/row/row0merge.cc +++ b/storage/xtradb/row/row0merge.cc @@ -1243,47 +1243,95 @@ row_merge_write_eof( return(&block[0]); } -/********************************************************************//** -Reads clustered index of the table and create temporary files +/** Create a temporary file if it has not been created already. +@param[in,out] tmpfd temporary file handle +@param[in] path path to create temporary file +@return file descriptor, or -1 on failure */ +static __attribute__((warn_unused_result)) +int +row_merge_tmpfile_if_needed( + int* tmpfd, + const char* path) +{ + if (*tmpfd < 0) { + *tmpfd = row_merge_file_create_low(path); + } + + return(*tmpfd); +} + +/** Create a temporary file for merge sort if it was not created already. +@param[in,out] file merge file structure +@param[in,out] tmpfd temporary file structure +@param[in] nrec number of records in the file +@param[in] path path to create temporary files +@return file descriptor, or -1 on failure */ +static __attribute__((warn_unused_result)) +int +row_merge_file_create_if_needed( + merge_file_t* file, + int* tmpfd, + ulint nrec, + const char* path) +{ + ut_ad(file->fd < 0 || *tmpfd >=0); + if (file->fd < 0 && row_merge_file_create(file, path) >= 0) { + if (row_merge_tmpfile_if_needed(tmpfd, path) < 0) { + return(-1); + } + + file->n_rec = nrec; + } + + ut_ad(file->fd < 0 || *tmpfd >=0); + return(file->fd); +} + +/** Reads clustered index of the table and create temporary files containing the index entries for the indexes to be built. -@return DB_SUCCESS or error */ +@param[in] trx transaction +@param[in,out] table MySQL table object, for reporting erroneous + records +@param[in] old_table table where rows are read from +@param[in] new_table table where indexes are created; identical to + old_table unless creating a PRIMARY KEY +@param[in] online true if creating indexes online +@param[in] index indexes to be created +@param[in] fts_sort_idx full-text index to be created, or NULL +@param[in] psort_info parallel sort info for fts_sort_idx creation, + or NULL +@param[in] files temporary files +@param[in] key_numbers MySQL key numbers to create +@param[in] n_index number of indexes to create +@param[in] add_cols default values of added columns, or NULL +@param[in] col_map mapping of old column numbers to new ones, or + NULL if old_table == new_table +@param[in] add_autoinc number of added AUTO_INCREMENT columns, or + ULINT_UNDEFINED if none is added +@param[in,out] sequence autoinc sequence +@param[in,out] block file buffer +@param[in,out] tmpfd temporary file handle +return DB_SUCCESS or error */ static __attribute__((nonnull(1,2,3,4,6,9,10,16), warn_unused_result)) dberr_t row_merge_read_clustered_index( -/*===========================*/ - trx_t* trx, /*!< in: transaction */ - struct TABLE* table, /*!< in/out: MySQL table object, - for reporting erroneous records */ - const dict_table_t* old_table,/*!< in: table where rows are - read from */ - const dict_table_t* new_table,/*!< in: table where indexes are - created; identical to old_table - unless creating a PRIMARY KEY */ - bool online, /*!< in: true if creating indexes - online */ - dict_index_t** index, /*!< in: indexes to be created */ + trx_t* trx, + struct TABLE* table, + const dict_table_t* old_table, + const dict_table_t* new_table, + bool online, + dict_index_t** index, dict_index_t* fts_sort_idx, - /*!< in: full-text index to be created, - or NULL */ fts_psort_t* psort_info, - /*!< in: parallel sort info for - fts_sort_idx creation, or NULL */ - merge_file_t* files, /*!< in: temporary files */ + merge_file_t* files, const ulint* key_numbers, - /*!< in: MySQL key numbers to create */ - ulint n_index,/*!< in: number of indexes to create */ + ulint n_index, const dtuple_t* add_cols, - /*!< in: default values of - added columns, or NULL */ - const ulint* col_map,/*!< in: mapping of old column - numbers to new ones, or NULL - if old_table == new_table */ + const ulint* col_map, ulint add_autoinc, - /*!< in: number of added - AUTO_INCREMENT column, or - ULINT_UNDEFINED if none is added */ - ib_sequence_t& sequence,/*!< in/out: autoinc sequence */ - row_merge_block_t* block) /*!< in/out: file buffer */ + ib_sequence_t& sequence, + row_merge_block_t* block, + int* tmpfd) { dict_index_t* clust_index; /* Clustered index */ mem_heap_t* row_heap; /* Heap memory to create @@ -1315,6 +1363,9 @@ row_merge_read_clustered_index( DEBUG_FTS_SORT_PRINT("FTS_SORT: Start Create Index\n"); #endif + ut_ad(trx->mysql_thd != NULL); + const char* path = thd_innodb_tmpdir(trx->mysql_thd); + /* Create and initialize memory for record buffers */ merge_buf = static_cast<row_merge_buf_t**>( @@ -1785,13 +1836,25 @@ write_buffers: dict_index_get_lock(buf->index)); } - row_merge_buf_write(buf, file, block); + if (buf->n_tuples > 0) { - if (!row_merge_write(file->fd, file->offset++, - block)) { - err = DB_TEMP_FILE_WRITE_FAILURE; - trx->error_key_num = i; - break; + if (row_merge_file_create_if_needed( + file, tmpfd, buf->n_tuples, path) < 0) { + err = DB_OUT_OF_MEMORY; + trx->error_key_num = i; + break; + } + + ut_ad(file->n_rec > 0); + + row_merge_buf_write(buf, file, block); + + if (!row_merge_write(file->fd, file->offset++, + block)) { + err = DB_TEMP_FILE_WRITE_FAILURE; + trx->error_key_num = i; + break; + } } UNIV_MEM_INVALID(&block[0], srv_sort_buf_size); @@ -1835,6 +1898,7 @@ write_buffers: func_exit: mtr_commit(&mtr); + mem_heap_free(row_heap); if (nonnull) { @@ -3066,14 +3130,15 @@ row_merge_drop_temp_indexes(void) trx_free_for_background(trx); } -/*********************************************************************//** -Creates temporary merge files, and if UNIV_PFS_IO defined, register -the file descriptor with Performance Schema. -@return file descriptor, or -1 on failure */ + +/** Create temporary merge files in the given paramater path, and if +UNIV_PFS_IO defined, register the file descriptor with Performance Schema. +@param[in] path location for creating temporary merge files. +@return File descriptor */ UNIV_INTERN int -row_merge_file_create_low(void) -/*===========================*/ +row_merge_file_create_low( + const char* path) { int fd; #ifdef UNIV_PFS_IO @@ -3087,7 +3152,7 @@ row_merge_file_create_low(void) "Innodb Merge Temp File", __FILE__, __LINE__); #endif - fd = innobase_mysql_tmpfile(); + fd = innobase_mysql_tmpfile(path); #ifdef UNIV_PFS_IO register_pfs_file_open_end(locker, fd); #endif @@ -3100,16 +3165,18 @@ row_merge_file_create_low(void) return(fd); } -/*********************************************************************//** -Create a merge file. + +/** Create a merge file in the given location. +@param[out] merge_file merge file structure +@param[in] path location for creating temporary file @return file descriptor, or -1 on failure */ UNIV_INTERN int row_merge_file_create( -/*==================*/ - merge_file_t* merge_file) /*!< out: merge file structure */ + merge_file_t* merge_file, + const char* path) { - merge_file->fd = row_merge_file_create_low(); + merge_file->fd = row_merge_file_create_low(path); merge_file->offset = 0; merge_file->n_rec = 0; @@ -3647,10 +3714,6 @@ row_merge_build_indexes( } for (i = 0; i < n_indexes; i++) { - if (row_merge_file_create(&merge_files[i]) < 0) { - error = DB_OUT_OF_MEMORY; - goto func_exit; - } if (indexes[i]->type & DICT_FTS) { ibool opt_doc_id_size = FALSE; @@ -3679,13 +3742,6 @@ row_merge_build_indexes( } } - tmpfd = row_merge_file_create_low(); - - if (tmpfd < 0) { - error = DB_OUT_OF_MEMORY; - goto func_exit; - } - /* Reset the MySQL row buffer that is used when reporting duplicate keys. */ innobase_rec_reset(table); @@ -3697,7 +3753,7 @@ row_merge_build_indexes( trx, table, old_table, new_table, online, indexes, fts_sort_idx, psort_info, merge_files, key_numbers, n_indexes, add_cols, col_map, - add_autoinc, sequence, block); + add_autoinc, sequence, block, &tmpfd); if (error != DB_SUCCESS) { @@ -3778,7 +3834,7 @@ wait_again: #ifdef FTS_INTERNAL_DIAG_PRINT DEBUG_FTS_SORT_PRINT("FTS_SORT: Complete Insert\n"); #endif - } else { + } else if (merge_files[i].fd != -1) { row_merge_dup_t dup = { sort_idx, table, col_map, 0}; diff --git a/storage/xtradb/row/row0sel.cc b/storage/xtradb/row/row0sel.cc index 457e8361331..3aaf8cd5878 100644 --- a/storage/xtradb/row/row0sel.cc +++ b/storage/xtradb/row/row0sel.cc @@ -3738,12 +3738,6 @@ row_search_for_mysql( ut_error; } - /* init null bytes with default values as they might be - left uninitialized in some cases and these uninited bytes - might be copied into mysql record buffer that leads to - valgrind warnings */ - memcpy(buf, prebuilt->default_rec, prebuilt->null_bitmap_len); - #if 0 /* August 19, 2005 by Heikki: temporarily disable this error print until the cursor lock count is done correctly. diff --git a/storage/xtradb/srv/srv0srv.cc b/storage/xtradb/srv/srv0srv.cc index 2008ca07b84..03060599dc7 100644 --- a/storage/xtradb/srv/srv0srv.cc +++ b/storage/xtradb/srv/srv0srv.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2013, 2014, SkySQL Ab. All Rights Reserved. @@ -2133,6 +2133,8 @@ exit_func: /*********************************************************************//** A thread which prints warnings about semaphore waits which have lasted too long. These can be used to track bugs which cause hangs. +Note: In order to make sync_arr_wake_threads_if_sema_free work as expected, +we should avoid waiting any mutexes in this function! @return a dummy parameter */ extern "C" UNIV_INTERN os_thread_ret_t @@ -2172,23 +2174,21 @@ loop: /* Try to track a strange bug reported by Harald Fuchs and others, where the lsn seems to decrease at times */ - /* We have to use nowait to ensure we don't block */ - new_lsn= log_get_lsn_nowait(); - - if (new_lsn && new_lsn < old_lsn) { - ut_print_timestamp(stderr); - fprintf(stderr, - " InnoDB: Error: old log sequence number " LSN_PF - " was greater\n" - "InnoDB: than the new log sequence number " LSN_PF "!\n" - "InnoDB: Please submit a bug report" - " to http://bugs.mysql.com\n", - old_lsn, new_lsn); - ut_ad(0); - } + if (log_peek_lsn(&new_lsn)) { + if (new_lsn < old_lsn) { + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Error: old log sequence number " LSN_PF + " was greater\n" + "InnoDB: than the new log sequence number " LSN_PF "!\n" + "InnoDB: Please submit a bug report" + " to http://bugs.mysql.com\n", + old_lsn, new_lsn); + ut_ad(0); + } - if (new_lsn) old_lsn = new_lsn; + } if (difftime(time(NULL), srv_last_monitor_time) > 60) { /* We referesh InnoDB Monitor values so that averages are diff --git a/storage/xtradb/srv/srv0start.cc b/storage/xtradb/srv/srv0start.cc index 27e95a272e3..c19540d24bc 100644 --- a/storage/xtradb/srv/srv0start.cc +++ b/storage/xtradb/srv/srv0start.cc @@ -1983,7 +1983,7 @@ innobase_start_or_create_for_mysql(void) } } else { srv_monitor_file_name = NULL; - srv_monitor_file = os_file_create_tmpfile(); + srv_monitor_file = os_file_create_tmpfile(NULL); if (!srv_monitor_file) { return(DB_ERROR); @@ -1993,7 +1993,7 @@ innobase_start_or_create_for_mysql(void) mutex_create(srv_dict_tmpfile_mutex_key, &srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION); - srv_dict_tmpfile = os_file_create_tmpfile(); + srv_dict_tmpfile = os_file_create_tmpfile(NULL); if (!srv_dict_tmpfile) { return(DB_ERROR); @@ -2002,7 +2002,7 @@ innobase_start_or_create_for_mysql(void) mutex_create(srv_misc_tmpfile_mutex_key, &srv_misc_tmpfile_mutex, SYNC_ANY_LATCH); - srv_misc_tmpfile = os_file_create_tmpfile(); + srv_misc_tmpfile = os_file_create_tmpfile(NULL); if (!srv_misc_tmpfile) { return(DB_ERROR); diff --git a/strings/str2int.c b/strings/str2int.c index ec89503af5e..fe6cd6b793e 100644 --- a/strings/str2int.c +++ b/strings/str2int.c @@ -45,7 +45,7 @@ easy task. Coping with integer overflow and the asymmetric range of twos complement machines is anything but easy. - So that users of atoi and atol can check whether an error occured, + So that users of atoi and atol can check whether an error occurred, I have taken a wholly unprecedented step: errno is CLEARED if this call has no problems. */ diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp index 47eb8a827f1..9f9215704ec 100644 --- a/support-files/compiler_warnings.supp +++ b/support-files/compiler_warnings.supp @@ -184,10 +184,10 @@ jemalloc/src/jemalloc\.c: set but not used # # Connect engine # -storage/connect/ha_connect\.cc: might be clobbered by ~longjmp~ -storage/connect/connect\.cc: might be clobbered by ~longjmp~ +storage/connect/ha_connect\.cc: might be clobbered by .*longjmp +storage/connect/connect\.cc: might be clobbered by .*longjmp storage/connect/filamvct\.cpp: ignoring return value of -storage/connect/filamvct\.cpp: might be clobbered by ~longjmp~ +storage/connect/filamvct\.cpp: might be clobbered by .*longjmp storage/connect/xindex\.cpp: ignoring return value of storage/connect/value\.cpp: always false diff --git a/tests/async_queries.c b/tests/async_queries.c index 75229eec4b4..76e884e6a69 100644 --- a/tests/async_queries.c +++ b/tests/async_queries.c @@ -265,7 +265,7 @@ again: { if (mysql_errno(&sd->mysql)) { - /* An error occured. */ + /* An error occurred. */ printf("%d | Error: %s\n", sd->index, mysql_error(&sd->mysql)); } else diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 51e549d9d1b..fcc89482f4e 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -2261,7 +2261,7 @@ static void test_ps_query_cache() return; } - rc= mysql_query(mysql, "SET SQL_MODE=''"); + rc= mysql_set_character_set(mysql, "utf8"); myquery(rc); /* prepare the table */ @@ -2306,7 +2306,7 @@ static void test_ps_query_cache() mysql_close(lmysql); DIE_UNLESS(0); } - rc= mysql_query(lmysql, "SET SQL_MODE=''"); + rc= mysql_set_character_set(lmysql, "utf8"); myquery(rc); if (!opt_silent) @@ -11725,10 +11725,10 @@ static void test_bug5315() rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); DIE_UNLESS(rc == 0); if (!opt_silent) - printf("Excuting mysql_change_user\n"); + printf("Executing mysql_change_user\n"); mysql_change_user(mysql, opt_user, opt_password, current_db); if (!opt_silent) - printf("Excuting mysql_stmt_execute\n"); + printf("Executing mysql_stmt_execute\n"); rc= mysql_stmt_execute(stmt); DIE_UNLESS(rc != 0); if (rc) @@ -11738,10 +11738,10 @@ static void test_bug5315() } /* check that connection is OK */ if (!opt_silent) - printf("Excuting mysql_stmt_close\n"); + printf("Executing mysql_stmt_close\n"); mysql_stmt_close(stmt); if (!opt_silent) - printf("Excuting mysql_stmt_init\n"); + printf("Executing mysql_stmt_init\n"); stmt= mysql_stmt_init(mysql); rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); DIE_UNLESS(rc == 0); @@ -16647,7 +16647,7 @@ static void test_bug30472() /* Switch client character set. */ - DIE_IF(mysql_set_character_set(&con, "utf8")); + DIE_IF(mysql_set_character_set(&con, "latin2")); /* Retrieve character set information. */ @@ -16663,10 +16663,10 @@ static void test_bug30472() 2) new character set is different from the original one. */ - DIE_UNLESS(strcmp(character_set_name_2, "utf8") == 0); - DIE_UNLESS(strcmp(character_set_client_2, "utf8") == 0); - DIE_UNLESS(strcmp(character_set_results_2, "utf8") == 0); - DIE_UNLESS(strcmp(collation_connnection_2, "utf8_general_ci") == 0); + DIE_UNLESS(strcmp(character_set_name_2, "latin2") == 0); + DIE_UNLESS(strcmp(character_set_client_2, "latin2") == 0); + DIE_UNLESS(strcmp(character_set_results_2, "latin2") == 0); + DIE_UNLESS(strcmp(collation_connnection_2, "latin2_general_ci") == 0); DIE_UNLESS(strcmp(character_set_name_1, character_set_name_2) != 0); DIE_UNLESS(strcmp(character_set_client_1, character_set_client_2) != 0); diff --git a/tests/nonblock-wrappers.h b/tests/nonblock-wrappers.h index 3ed470b3400..d6f42511f3a 100644 --- a/tests/nonblock-wrappers.h +++ b/tests/nonblock-wrappers.h @@ -30,7 +30,7 @@ /* Run the appropriate poll() syscall to wait for the event that libmysql - requested. Return which event(s) occured. + requested. Return which event(s) occurred. */ static int wait_for_mysql(MYSQL *mysql, int status) diff --git a/unittest/mysys/ma_dyncol-t.c b/unittest/mysys/ma_dyncol-t.c index 51e84bc4e40..b3fff638b65 100644 --- a/unittest/mysys/ma_dyncol-t.c +++ b/unittest/mysys/ma_dyncol-t.c @@ -691,13 +691,54 @@ err: mariadb_dyncol_free(&str2); } +static void test_mdev_9773() +{ + int rc; + uint i; + uint num_keys[5]= {1,2,3,4,5}; + char const *strval[]= {"Val1", "Val2", "Val3", "Val4", "Val5"}; + DYNAMIC_COLUMN_VALUE vals[5]; + DYNAMIC_COLUMN dynstr; + uint unpack_columns= 0; + MYSQL_LEX_STRING *unpack_keys= 0; + DYNAMIC_COLUMN_VALUE *unpack_vals= 0; + + for (i = 0; i < 5; i++) + { + vals[i].type= DYN_COL_STRING; + vals[i].x.string.value.str= (char *)strval[i]; + vals[i].x.string.value.length= strlen(strval[i]); + vals[i].x.string.charset= &my_charset_latin1; + } + + mariadb_dyncol_init(&dynstr); + + /* create numeric */ + rc= mariadb_dyncol_create_many_num(&dynstr, 5, num_keys, vals, 1); + + if (rc == ER_DYNCOL_OK) + rc= mariadb_dyncol_unpack(&dynstr, &unpack_columns, &unpack_keys, + &unpack_vals); + ok (rc == ER_DYNCOL_OK && unpack_columns == 5, "5 fields unpacked"); + for (i = 0; i < unpack_columns; i++) + { + ok(memcmp(unpack_vals[i].x.string.value.str, + vals[i].x.string.value.str, vals[i].x.string.value.length) == 0, + "unpack %u", i); + } + + my_free(unpack_keys); + my_free(unpack_vals); + mariadb_dyncol_free(&dynstr); +} + int main(int argc __attribute__((unused)), char **argv) { uint i; char *big_string= (char *)malloc(1024*1024); MY_INIT(argv[0]); - plan(62); + plan(68); if (!big_string) exit(1); @@ -830,6 +871,7 @@ int main(int argc __attribute__((unused)), char **argv) } test_mdev_4994(); test_mdev_4995(); + test_mdev_9773(); my_end(0); return exit_status(); |