diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-04-22 14:45:55 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-04-22 14:45:55 +0300 |
commit | 455cf6196c8c73f5a50004ac7f31a9be8ac14bbe (patch) | |
tree | 2d9d696bba2590c63278fee0047a046f58b51a31 | |
parent | 42af2b1d8b8a8508c5aac5c2e0bcf4554c5200ce (diff) | |
parent | e52a36d37be2fa8a2da8a987cb38cb0bb65233f4 (diff) | |
download | mariadb-git-455cf6196c8c73f5a50004ac7f31a9be8ac14bbe.tar.gz |
Merge 10.2 into 10.3
-rw-r--r-- | client/mysqltest.cc | 2 | ||||
-rw-r--r-- | extra/mariabackup/backup_mysql.cc | 340 | ||||
-rw-r--r-- | extra/mariabackup/xtrabackup.cc | 35 | ||||
-rw-r--r-- | extra/mariabackup/xtrabackup.h | 10 | ||||
-rw-r--r-- | extra/resolve_stack_dump.c | 45 | ||||
-rw-r--r-- | mysql-test/main/fulltext.result | 11 | ||||
-rw-r--r-- | mysql-test/main/fulltext.test | 14 | ||||
-rw-r--r-- | mysql-test/main/gis.result | 7 | ||||
-rw-r--r-- | mysql-test/main/gis.test | 8 | ||||
-rwxr-xr-x | mysql-test/mysql-test-run.pl | 7 | ||||
-rw-r--r-- | mysql-test/suite/galera/include/galera_st_shutdown_slave.inc | 3 | ||||
-rw-r--r-- | mysql-test/suite/galera/t/galera_slave_replay.test | 2 | ||||
-rw-r--r-- | mysql-test/suite/mariabackup/partial_exclude.opt | 2 | ||||
-rw-r--r-- | mysql-test/suite/mariabackup/partial_exclude.result | 3 | ||||
-rw-r--r-- | mysql-test/suite/mariabackup/partial_exclude.test | 18 | ||||
-rw-r--r-- | scripts/mysqld_safe.sh | 9 | ||||
-rw-r--r-- | sql/field.cc | 2 | ||||
-rw-r--r-- | sql/item.cc | 8 | ||||
-rw-r--r-- | sql/item.h | 10 | ||||
-rw-r--r-- | sql/mysqld.cc | 8 | ||||
-rw-r--r-- | sql/opt_range.cc | 19 | ||||
-rw-r--r-- | storage/maria/ma_close.c | 3 | ||||
-rw-r--r-- | storage/maria/ma_pagecrc.c | 3 | ||||
-rw-r--r-- | storage/myisam/mi_close.c | 4 |
24 files changed, 355 insertions, 218 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 9b23ebec245..151fff914f9 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -717,7 +717,7 @@ public: DBUG_ASSERT(ds->str); #ifdef EXTRA_DEBUG - DBUG_PRINT("extra", ("str: %*b", (int) ds->length, ds->str)); + DBUG_DUMP("extra", (uchar*) ds->str, ds->length); #endif if (fwrite(ds->str, 1, ds->length, m_file) != ds->length) diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 236acce2483..ba950121548 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -327,194 +327,212 @@ check_server_version(unsigned long version_number, /*********************************************************************//** Receive options important for XtraBackup from MySQL server. @return true on success. */ -bool -get_mysql_vars(MYSQL *connection) +bool get_mysql_vars(MYSQL *connection) { - char *gtid_mode_var = NULL; - char *version_var = NULL; - char *version_comment_var = NULL; - char *innodb_version_var = NULL; - char *have_backup_locks_var = NULL; - char *log_bin_var = NULL; - char *lock_wait_timeout_var= NULL; - char *wsrep_on_var = NULL; - char *slave_parallel_workers_var = NULL; - char *gtid_slave_pos_var = NULL; - char *innodb_buffer_pool_filename_var = NULL; - char *datadir_var = NULL; - char *innodb_log_group_home_dir_var = NULL; - char *innodb_log_file_size_var = NULL; - char *innodb_log_files_in_group_var = NULL; - char *innodb_data_file_path_var = NULL; - char *innodb_data_home_dir_var = NULL; - char *innodb_undo_directory_var = NULL; - char *innodb_page_size_var = NULL; - char *innodb_undo_tablespaces_var = NULL; - char *page_zip_level_var = NULL; - char *endptr; - unsigned long server_version = mysql_get_server_version(connection); - - bool ret = true; - - mysql_variable mysql_vars[] = { - {"have_backup_locks", &have_backup_locks_var}, - {"log_bin", &log_bin_var}, - {"lock_wait_timeout", &lock_wait_timeout_var}, - {"gtid_mode", >id_mode_var}, - {"version", &version_var}, - {"version_comment", &version_comment_var}, - {"innodb_version", &innodb_version_var}, - {"wsrep_on", &wsrep_on_var}, - {"slave_parallel_workers", &slave_parallel_workers_var}, - {"gtid_slave_pos", >id_slave_pos_var}, - {"innodb_buffer_pool_filename", - &innodb_buffer_pool_filename_var}, - {"datadir", &datadir_var}, - {"innodb_log_group_home_dir", &innodb_log_group_home_dir_var}, - {"innodb_log_file_size", &innodb_log_file_size_var}, - {"innodb_log_files_in_group", &innodb_log_files_in_group_var}, - {"innodb_data_file_path", &innodb_data_file_path_var}, - {"innodb_data_home_dir", &innodb_data_home_dir_var}, - {"innodb_undo_directory", &innodb_undo_directory_var}, - {"innodb_page_size", &innodb_page_size_var}, - {"innodb_undo_tablespaces", &innodb_undo_tablespaces_var}, - {"innodb_compression_level", &page_zip_level_var}, - {NULL, NULL} - }; - - read_mysql_variables(connection, "SHOW VARIABLES", - mysql_vars, true); + char *gtid_mode_var= NULL; + char *version_var= NULL; + char *version_comment_var= NULL; + char *innodb_version_var= NULL; + char *have_backup_locks_var= NULL; + char *log_bin_var= NULL; + char *lock_wait_timeout_var= NULL; + char *wsrep_on_var= NULL; + char *slave_parallel_workers_var= NULL; + char *gtid_slave_pos_var= NULL; + char *innodb_buffer_pool_filename_var= NULL; + char *datadir_var= NULL; + char *innodb_log_group_home_dir_var= NULL; + char *innodb_log_file_size_var= NULL; + char *innodb_log_files_in_group_var= NULL; + char *innodb_data_file_path_var= NULL; + char *innodb_data_home_dir_var= NULL; + char *innodb_undo_directory_var= NULL; + char *innodb_page_size_var= NULL; + char *innodb_undo_tablespaces_var= NULL; + char *page_zip_level_var= NULL; + char *ignore_db_dirs= NULL; + char *endptr; + unsigned long server_version= mysql_get_server_version(connection); + + bool ret= true; + + mysql_variable mysql_vars[]= { + {"have_backup_locks", &have_backup_locks_var}, + {"log_bin", &log_bin_var}, + {"lock_wait_timeout", &lock_wait_timeout_var}, + {"gtid_mode", >id_mode_var}, + {"version", &version_var}, + {"version_comment", &version_comment_var}, + {"innodb_version", &innodb_version_var}, + {"wsrep_on", &wsrep_on_var}, + {"slave_parallel_workers", &slave_parallel_workers_var}, + {"gtid_slave_pos", >id_slave_pos_var}, + {"innodb_buffer_pool_filename", &innodb_buffer_pool_filename_var}, + {"datadir", &datadir_var}, + {"innodb_log_group_home_dir", &innodb_log_group_home_dir_var}, + {"innodb_log_file_size", &innodb_log_file_size_var}, + {"innodb_log_files_in_group", &innodb_log_files_in_group_var}, + {"innodb_data_file_path", &innodb_data_file_path_var}, + {"innodb_data_home_dir", &innodb_data_home_dir_var}, + {"innodb_undo_directory", &innodb_undo_directory_var}, + {"innodb_page_size", &innodb_page_size_var}, + {"innodb_undo_tablespaces", &innodb_undo_tablespaces_var}, + {"innodb_compression_level", &page_zip_level_var}, + {"ignore_db_dirs", &ignore_db_dirs}, + {NULL, NULL}}; + + read_mysql_variables(connection, "SHOW VARIABLES", mysql_vars, true); + + if (have_backup_locks_var != NULL && !opt_no_backup_locks) + { + have_backup_locks= true; + } - if (have_backup_locks_var != NULL && !opt_no_backup_locks) { - have_backup_locks = true; - } + if (opt_binlog_info == BINLOG_INFO_AUTO) + { + if (log_bin_var != NULL && !strcmp(log_bin_var, "ON")) + opt_binlog_info= BINLOG_INFO_ON; + else + opt_binlog_info= BINLOG_INFO_OFF; + } - if (opt_binlog_info == BINLOG_INFO_AUTO) { - if (log_bin_var != NULL && !strcmp(log_bin_var, "ON")) - opt_binlog_info = BINLOG_INFO_ON; - else - opt_binlog_info = BINLOG_INFO_OFF; - } + if (lock_wait_timeout_var != NULL) + { + have_lock_wait_timeout= true; + } - if (lock_wait_timeout_var != NULL) { - have_lock_wait_timeout = true; - } + if (wsrep_on_var != NULL) + { + have_galera_enabled= true; + } - if (wsrep_on_var != NULL) { - have_galera_enabled = true; - } + /* Check server version compatibility and detect server flavor */ - /* Check server version compatibility and detect server flavor */ + if (!(ret= check_server_version(server_version, version_var, + version_comment_var, innodb_version_var))) + { + goto out; + } - if (!(ret = check_server_version(server_version, version_var, - version_comment_var, - innodb_version_var))) { - goto out; - } + if (server_version > 50500) + { + have_flush_engine_logs= true; + } - if (server_version > 50500) { - have_flush_engine_logs = true; - } + if (slave_parallel_workers_var != NULL && + atoi(slave_parallel_workers_var) > 0) + { + have_multi_threaded_slave= true; + } - if (slave_parallel_workers_var != NULL - && atoi(slave_parallel_workers_var) > 0) { - have_multi_threaded_slave = true; - } + if (innodb_buffer_pool_filename_var != NULL) + { + buffer_pool_filename= strdup(innodb_buffer_pool_filename_var); + } - if (innodb_buffer_pool_filename_var != NULL) { - buffer_pool_filename = strdup(innodb_buffer_pool_filename_var); - } + if ((gtid_mode_var && strcmp(gtid_mode_var, "ON") == 0) || + (gtid_slave_pos_var && *gtid_slave_pos_var)) + { + have_gtid_slave= true; + } - if ((gtid_mode_var && strcmp(gtid_mode_var, "ON") == 0) || - (gtid_slave_pos_var && *gtid_slave_pos_var)) { - have_gtid_slave = true; - } + msg("Using server version %s", version_var); - msg("Using server version %s", version_var); + if (!(ret= detect_mysql_capabilities_for_backup())) + { + goto out; + } - if (!(ret = detect_mysql_capabilities_for_backup())) { - goto out; - } + /* make sure datadir value is the same in configuration file */ + if (check_if_param_set("datadir")) + { + if (!directory_exists(mysql_data_home, false)) + { + msg("Warning: option 'datadir' points to " + "nonexistent directory '%s'", + mysql_data_home); + } + if (!directory_exists(datadir_var, false)) + { + msg("Warning: MySQL variable 'datadir' points to " + "nonexistent directory '%s'", + datadir_var); + } + if (!equal_paths(mysql_data_home, datadir_var)) + { + msg("Warning: option 'datadir' has different " + "values:\n" + " '%s' in defaults file\n" + " '%s' in SHOW VARIABLES", + mysql_data_home, datadir_var); + } + } - /* make sure datadir value is the same in configuration file */ - if (check_if_param_set("datadir")) { - if (!directory_exists(mysql_data_home, false)) { - msg("Warning: option 'datadir' points to " - "nonexistent directory '%s'", mysql_data_home); - } - if (!directory_exists(datadir_var, false)) { - msg("Warning: MySQL variable 'datadir' points to " - "nonexistent directory '%s'", datadir_var); - } - if (!equal_paths(mysql_data_home, datadir_var)) { - msg("Warning: option 'datadir' has different " - "values:\n" - " '%s' in defaults file\n" - " '%s' in SHOW VARIABLES", - mysql_data_home, datadir_var); - } - } + /* get some default values is they are missing from my.cnf */ + if (datadir_var && *datadir_var) + { + strmake(mysql_real_data_home, datadir_var, FN_REFLEN - 1); + mysql_data_home= mysql_real_data_home; + } - /* get some default values is they are missing from my.cnf */ - if (datadir_var && *datadir_var) { - strmake(mysql_real_data_home, datadir_var, FN_REFLEN - 1); - mysql_data_home= mysql_real_data_home; - } + if (innodb_data_file_path_var && *innodb_data_file_path_var) + { + innobase_data_file_path= my_strdup(innodb_data_file_path_var, MYF(MY_FAE)); + } - if (innodb_data_file_path_var && *innodb_data_file_path_var) { - innobase_data_file_path = my_strdup( - innodb_data_file_path_var, MYF(MY_FAE)); - } + if (innodb_data_home_dir_var) + { + innobase_data_home_dir= my_strdup(innodb_data_home_dir_var, MYF(MY_FAE)); + } - if (innodb_data_home_dir_var) { - innobase_data_home_dir = my_strdup( - innodb_data_home_dir_var, MYF(MY_FAE)); - } + if (innodb_log_group_home_dir_var && *innodb_log_group_home_dir_var) + { + srv_log_group_home_dir= + my_strdup(innodb_log_group_home_dir_var, MYF(MY_FAE)); + } - if (innodb_log_group_home_dir_var - && *innodb_log_group_home_dir_var) { - srv_log_group_home_dir = my_strdup( - innodb_log_group_home_dir_var, MYF(MY_FAE)); - } + if (innodb_undo_directory_var && *innodb_undo_directory_var) + { + srv_undo_dir= my_strdup(innodb_undo_directory_var, MYF(MY_FAE)); + } - if (innodb_undo_directory_var && *innodb_undo_directory_var) { - srv_undo_dir = my_strdup( - innodb_undo_directory_var, MYF(MY_FAE)); - } + if (innodb_log_files_in_group_var) + { + srv_n_log_files= strtol(innodb_log_files_in_group_var, &endptr, 10); + ut_ad(*endptr == 0); + } - if (innodb_log_files_in_group_var) { - srv_n_log_files = strtol( - innodb_log_files_in_group_var, &endptr, 10); - ut_ad(*endptr == 0); - } + if (innodb_log_file_size_var) + { + srv_log_file_size= strtoll(innodb_log_file_size_var, &endptr, 10); + ut_ad(*endptr == 0); + } - if (innodb_log_file_size_var) { - srv_log_file_size = strtoll( - innodb_log_file_size_var, &endptr, 10); - ut_ad(*endptr == 0); - } + if (innodb_page_size_var) + { + innobase_page_size= strtoll(innodb_page_size_var, &endptr, 10); + ut_ad(*endptr == 0); + } - if (innodb_page_size_var) { - innobase_page_size = strtoll( - innodb_page_size_var, &endptr, 10); - ut_ad(*endptr == 0); - } + if (innodb_undo_tablespaces_var) + { + srv_undo_tablespaces= strtoul(innodb_undo_tablespaces_var, &endptr, 10); + ut_ad(*endptr == 0); + } - if (innodb_undo_tablespaces_var) { - srv_undo_tablespaces = strtoul(innodb_undo_tablespaces_var, - &endptr, 10); - ut_ad(*endptr == 0); - } + if (page_zip_level_var != NULL) + { + page_zip_level= strtoul(page_zip_level_var, &endptr, 10); + ut_ad(*endptr == 0); + } - if (page_zip_level_var != NULL) { - page_zip_level = strtoul(page_zip_level_var, &endptr, 10); - ut_ad(*endptr == 0); - } + if (ignore_db_dirs) + xb_load_list_string(ignore_db_dirs, ",", register_ignore_db_dirs_filter); out: - free_mysql_variables(mysql_vars); + free_mysql_variables(mysql_vars); - return(ret); + return (ret); } /*********************************************************************//** diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 875eab52f69..5246ffbda20 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -3628,6 +3628,11 @@ xb_register_exclude_filter_entry( &tables_exclude_hash); } +void register_ignore_db_dirs_filter(const char *name) +{ + xb_add_filter(name, &databases_exclude_hash); +} + /*********************************************************************** Register new table for the filter. */ static @@ -3690,26 +3695,24 @@ xb_register_exclude_regex( typedef void (*insert_entry_func_t)(const char*); -/*********************************************************************** -Scan string and load filter entries from it. */ -static -void -xb_load_list_string( -/*================*/ - char* list, /*!< in: string representing a list */ - const char* delimiters, /*!< in: delimiters of entries */ - insert_entry_func_t ins) /*!< in: callback to add entry */ +/* Scan string and load filter entries from it. +@param[in] list string representing a list +@param[in] delimiters delimiters of entries +@param[in] ins callback to add entry */ +void xb_load_list_string(char *list, const char *delimiters, + insert_entry_func_t ins) { - char* p; - char* saveptr; + char *p; + char *saveptr; - p = strtok_r(list, delimiters, &saveptr); - while (p) { + p= strtok_r(list, delimiters, &saveptr); + while (p) + { - ins(p); + ins(p); - p = strtok_r(NULL, delimiters, &saveptr); - } + p= strtok_r(NULL, delimiters, &saveptr); + } } /*********************************************************************** diff --git a/extra/mariabackup/xtrabackup.h b/extra/mariabackup/xtrabackup.h index c56e83f7a32..2dbdd442f95 100644 --- a/extra/mariabackup/xtrabackup.h +++ b/extra/mariabackup/xtrabackup.h @@ -194,4 +194,14 @@ void mdl_lock_init(); void mdl_lock_table(ulint space_id); void mdl_unlock_all(); bool ends_with(const char *str, const char *suffix); + +typedef void (*insert_entry_func_t)(const char*); + +/* Scan string and load filter entries from it. +@param[in] list string representing a list +@param[in] delimiters delimiters of entries +@param[in] ins callback to add entry */ +void xb_load_list_string(char *list, const char *delimiters, + insert_entry_func_t ins); +void register_ignore_db_dirs_filter(const char *name); #endif /* XB_XTRABACKUP_H */ diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c index 92cd4c0de18..6d6adccfe32 100644 --- a/extra/resolve_stack_dump.c +++ b/extra/resolve_stack_dump.c @@ -53,7 +53,7 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"symbols-file", 's', "Use specified symbols file.", &sym_fname, + {"symbols-file", 's', "Use specified symbols file", &sym_fname, &sym_fname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"numeric-dump-file", 'n', "Read the dump from specified file.", &dump_fname, &dump_fname, 0, GET_STR, REQUIRED_ARG, @@ -63,7 +63,7 @@ static struct my_option my_long_options[] = static void verify_sort(); - +static void clean_up(); static void print_version(void) { @@ -97,9 +97,18 @@ static void die(const char* fmt, ...) vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); va_end(args); + clean_up(); + my_end(0); exit(1); } +void local_exit(int error) +{ + clean_up(); + my_end(0); + exit(error); +} + static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), @@ -108,10 +117,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), switch(optid) { case 'V': print_version(); - exit(0); + local_exit(0); + break; case '?': usage(); - exit(0); + local_exit(0); + break; } return 0; } @@ -122,7 +133,7 @@ static int parse_args(int argc, char **argv) int ho_error; if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) - exit(ho_error); + local_exit(ho_error); /* The following code is to make the command compatible with the old @@ -143,13 +154,13 @@ static int parse_args(int argc, char **argv) else { usage(); - exit(1); + local_exit(1); } } else if (argc != 0 || !sym_fname) { usage(); - exit(1); + local_exit(1); } return 0; } @@ -242,6 +253,10 @@ static void init_sym_table() static void clean_up() { delete_dynamic(&sym_table); + if (fp_dump && fp_dump != stdin) + my_fclose(fp_dump, MYF(0)); + if (fp_sym) + my_fclose(fp_sym, MYF(0)); } static void verify_sort() @@ -283,7 +298,7 @@ static SYM_ENTRY* resolve_addr(uchar* addr, SYM_ENTRY* se) /* - Resolve anything that starts with [0x or (+0x or start of line and 0x + Resolve anything that starts with [0x or (+0x or 0x Skip '_end' as this is an indication of a wrong symbol (stack?) */ @@ -299,9 +314,7 @@ static void do_resolve() found= 3; if (p[0] == '(' && p[1] == '+' && p[2] == '0' && p[3] == 'x') found= 4; - - /* For stdin */ - if (p == buf && p[0] == '0' && p[1] == 'x') + if (p[0] == '0' && p[1] == 'x') found= 2; if (found) @@ -312,14 +325,15 @@ static void do_resolve() addr= (uchar*)read_addr(&tmp); if (resolve_addr(addr, &se) && strcmp(se.symbol, "_end")) { - fprintf(fp_out, "%c%p %s + %d", *p, addr, se.symbol, - (int) (addr - se.addr)); + found-= 2; /* Don't print 0x as it's added by %p */ + while (found--) + fputc(*p++, stdout); + fprintf(fp_out, "%p %s + %d", addr, + se.symbol, (int) (addr - se.addr)); p= tmp-1; } else - { fputc(*p, stdout); - } } else fputc(*p, stdout); @@ -336,5 +350,6 @@ int main(int argc, char** argv) init_sym_table(); do_resolve(); clean_up(); + my_end(0); return 0; } diff --git a/mysql-test/main/fulltext.result b/mysql-test/main/fulltext.result index 3f4223eee07..dbc08144e30 100644 --- a/mysql-test/main/fulltext.result +++ b/mysql-test/main/fulltext.result @@ -776,3 +776,14 @@ CREATE FULLTEXT INDEX IF NOT EXISTS ft1 ON t1(title); Warnings: Note 1061 Duplicate key name 'ft1' DROP TABLE t1; +# +# MDEV-22275 (Memory leak) +# +CREATE TEMPORARY TABLE tmp (a TEXT) ENGINE=MyISAM; +ALTER TABLE tmp ADD FULLTEXT (a); +INSERT INTO tmp VALUES ('foo'); +DROP TABLE tmp; +CREATE TEMPORARY TABLE tmp (a TEXT) ENGINE=Aria; +ALTER TABLE tmp ADD FULLTEXT (a); +INSERT INTO tmp VALUES ('foo'); +DROP TABLE tmp; diff --git a/mysql-test/main/fulltext.test b/mysql-test/main/fulltext.test index 2e53ce7f112..d52f13ab978 100644 --- a/mysql-test/main/fulltext.test +++ b/mysql-test/main/fulltext.test @@ -716,3 +716,17 @@ CREATE TABLE t1 ( CREATE FULLTEXT INDEX IF NOT EXISTS ft1 ON t1(title); CREATE FULLTEXT INDEX IF NOT EXISTS ft1 ON t1(title); DROP TABLE t1; + +--echo # +--echo # MDEV-22275 (Memory leak) +--echo # + +CREATE TEMPORARY TABLE tmp (a TEXT) ENGINE=MyISAM; +ALTER TABLE tmp ADD FULLTEXT (a); +INSERT INTO tmp VALUES ('foo'); +DROP TABLE tmp; + +CREATE TEMPORARY TABLE tmp (a TEXT) ENGINE=Aria; +ALTER TABLE tmp ADD FULLTEXT (a); +INSERT INTO tmp VALUES ('foo'); +DROP TABLE tmp; diff --git a/mysql-test/main/gis.result b/mysql-test/main/gis.result index cdae4b92f79..5a01a402c7d 100644 --- a/mysql-test/main/gis.result +++ b/mysql-test/main/gis.result @@ -2265,6 +2265,13 @@ st_astext(p) POINT(0 0) drop table t1; # +# MDEV-21056 Memory leak after query with DEFAULT on a geometry field +# +CREATE TABLE t1 (f POINT DEFAULT ST_GEOMFROMTEXT('Point(0 0)')); +SELECT ST_GEOMFROMTEXT('Point(1 1)') IN ( DEFAULT( `f` ), ST_GEOMFROMTEXT('Point(2 2)') ) AS x FROM t1; +x +DROP TABLE t1; +# # End of 10.2 tests # # diff --git a/mysql-test/main/gis.test b/mysql-test/main/gis.test index ff09a098107..208b8731e0e 100644 --- a/mysql-test/main/gis.test +++ b/mysql-test/main/gis.test @@ -1796,6 +1796,14 @@ select st_astext(p) from t1; drop table t1; --echo # +--echo # MDEV-21056 Memory leak after query with DEFAULT on a geometry field +--echo # + +CREATE TABLE t1 (f POINT DEFAULT ST_GEOMFROMTEXT('Point(0 0)')); +SELECT ST_GEOMFROMTEXT('Point(1 1)') IN ( DEFAULT( `f` ), ST_GEOMFROMTEXT('Point(2 2)') ) AS x FROM t1; +DROP TABLE t1; + +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 373f8447b0b..ec46d5ed531 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3578,8 +3578,11 @@ sub do_before_run_mysqltest($) # to be able to distinguish them from manually created # version-controlled results, and to ignore them in git. my $dest = "$base_file$suites.result~"; - my @cmd = ($exe_patch, qw/--binary -r - -f -s -o/, - $dest, $base_result, $resfile); + my @cmd = ($exe_patch); + if ($^O eq "MSWin32") { + push @cmd, '--binary'; + } + push @cmd, (qw/-r - -f -s -o/, $dest, $base_result, $resfile); if (-w $resdir) { # don't rebuild a file if it's up to date unless (-e $dest and -M $dest < -M $resfile diff --git a/mysql-test/suite/galera/include/galera_st_shutdown_slave.inc b/mysql-test/suite/galera/include/galera_st_shutdown_slave.inc index 6c09b0ceb0c..207282c8237 100644 --- a/mysql-test/suite/galera/include/galera_st_shutdown_slave.inc +++ b/mysql-test/suite/galera/include/galera_st_shutdown_slave.inc @@ -12,6 +12,9 @@ INSERT INTO t1 VALUES ('node1_committed_before'); COMMIT; --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1'; +--source include/wait_condition.inc + SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t1 VALUES ('node2_committed_before'); diff --git a/mysql-test/suite/galera/t/galera_slave_replay.test b/mysql-test/suite/galera/t/galera_slave_replay.test index 96f6a3e26fc..b3bdaeaa532 100644 --- a/mysql-test/suite/galera/t/galera_slave_replay.test +++ b/mysql-test/suite/galera/t/galera_slave_replay.test @@ -9,12 +9,12 @@ --source include/have_innodb.inc --source include/have_debug.inc --source include/have_debug_sync.inc +--source include/galera_have_debug_sync.inc --connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 --connection node_2a --source include/galera_cluster.inc ---source include/galera_have_debug_sync.inc # # node 1 is native MariaDB server operating as async replication master diff --git a/mysql-test/suite/mariabackup/partial_exclude.opt b/mysql-test/suite/mariabackup/partial_exclude.opt new file mode 100644 index 00000000000..872335edb71 --- /dev/null +++ b/mysql-test/suite/mariabackup/partial_exclude.opt @@ -0,0 +1,2 @@ +--ignore-db-dirs=db3 +--ignore-db-dirs=db4 diff --git a/mysql-test/suite/mariabackup/partial_exclude.result b/mysql-test/suite/mariabackup/partial_exclude.result index 0da9b547caa..628613040e0 100644 --- a/mysql-test/suite/mariabackup/partial_exclude.result +++ b/mysql-test/suite/mariabackup/partial_exclude.result @@ -1,3 +1,6 @@ +select @@ignore_db_dirs; +@@ignore_db_dirs +db3,db4 CREATE TABLE t1(i INT) ENGINE INNODB; INSERT INTO t1 VALUES(1); CREATE TABLE t2(i int) ENGINE INNODB; diff --git a/mysql-test/suite/mariabackup/partial_exclude.test b/mysql-test/suite/mariabackup/partial_exclude.test index cd21ecff29b..99d14e58231 100644 --- a/mysql-test/suite/mariabackup/partial_exclude.test +++ b/mysql-test/suite/mariabackup/partial_exclude.test @@ -1,6 +1,13 @@ #--source include/innodb_page_size.inc # Test --databases-exclude and --tables-exclude feature of xtrabackup 2.3.8 +select @@ignore_db_dirs; + +let $MYSQLD_DATADIR= `select @@datadir`; + +mkdir $MYSQLD_DATADIR/db3; +mkdir $MYSQLD_DATADIR/db4; +mkdir $MYSQLD_DATADIR/db5; CREATE TABLE t1(i INT) ENGINE INNODB; INSERT INTO t1 VALUES(1); @@ -24,8 +31,19 @@ list_files $targetdir/test *.ibd; # check that db2 database is not in the backup (excluded) --error 1 list_files $targetdir/db2 *.ibd; +# check that db3 database is not in the backup (excluded) +--error 1 +list_files $targetdir/db3 *.ibd; +# check that db4 database is not in the backup (excluded) +--error 1 +list_files $targetdir/db4 *.ibd; +# check that db5 database is in the backup +list_files $targetdir/db5 *.ibd; DROP TABLE t1; DROP TABLE t2; DROP DATABASE db2; +rmdir $MYSQLD_DATADIR/db3; +rmdir $MYSQLD_DATADIR/db4; +rmdir $MYSQLD_DATADIR/db5; rmdir $targetdir; diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 8969b01023b..f40a68a3b1e 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -235,7 +235,9 @@ wsrep_recover_position() { fi if [ -f $wr_logfile ]; then - [ "$euid" = "0" ] && chown $user $wr_logfile + # NOTE! Do not change ownership of the temporary file, as on newer kernel + # versions fs.protected_regular is set to '2' and redirecting output with > + # as root to a file not owned by root will fail with "Permission denied" chmod 600 $wr_logfile else log_error "WSREP: mktemp failed" @@ -250,6 +252,11 @@ wsrep_recover_position() { eval "$mysqld_cmd --wsrep_recover $wr_options 2> $wr_logfile" + if [ ! -s "$wr_logfile" ]; then + log_error "Log file $wr_logfile was empty, cannot proceed. Is system running fs.protected_regular?" + exit 1 + fi + local rp="$(grep 'WSREP: Recovered position:' $wr_logfile)" if [ -z "$rp" ]; then local skipped="$(grep WSREP $wr_logfile | grep 'skipping position recovery')" diff --git a/sql/field.cc b/sql/field.cc index 6153ad64fca..a1c2f1c46c2 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -9049,7 +9049,7 @@ int Field_geom::store(const char *from, size_t length, CHARSET_INFO *cs) my_error(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, MYF(0), Geometry::ci_collection[geom_type]->m_name.str, - wkt.c_ptr(), db, tab_name, field_name.str, + wkt.c_ptr_safe(), db, tab_name, field_name.str, (ulong) table->in_use->get_stmt_da()-> current_row_for_warning()); diff --git a/sql/item.cc b/sql/item.cc index 30e83d26a0c..bf0a8e0e754 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -9349,8 +9349,10 @@ bool Item_default_value::fix_fields(THD *thd, Item **items) } if (!(def_field= (Field*) thd->alloc(field_arg->field->size_of()))) goto error; + cached_field= def_field; memcpy((void *)def_field, (void *)field_arg->field, field_arg->field->size_of()); + def_field->reset_fields(); // If non-constant default value expression if (def_field->default_value && def_field->default_value->flags) { @@ -9378,6 +9380,12 @@ error: return TRUE; } +void Item_default_value::cleanup() +{ + delete cached_field; // Free cached blob data + cached_field= 0; + Item_field::cleanup(); +} void Item_default_value::print(String *str, enum_query_type query_type) { diff --git a/sql/item.h b/sql/item.h index d28371be8f5..54c4e9a5504 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2,7 +2,7 @@ #define SQL_ITEM_INCLUDED /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB Corporation. + Copyright (c) 2009, 2020, 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 @@ -5773,21 +5773,23 @@ class Item_default_value : public Item_field void calculate(); public: Item *arg; + Field *cached_field; Item_default_value(THD *thd, Name_resolution_context *context_arg) :Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL, &null_clex_str), - arg(NULL) {} + arg(NULL), cached_field(NULL) {} Item_default_value(THD *thd, Name_resolution_context *context_arg, Item *a) :Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL, &null_clex_str), - arg(a) {} + arg(a), cached_field(NULL) {} Item_default_value(THD *thd, Name_resolution_context *context_arg, Field *a) :Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL, &null_clex_str), - arg(NULL) {} + arg(NULL), cached_field(NULL) {} enum Type type() const { return DEFAULT_VALUE_ITEM; } bool eq(const Item *item, bool binary_cmp) const; bool fix_fields(THD *, Item **); + void cleanup(); void print(String *str, enum_query_type query_type); String *val_str(String *str); double val_real(); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 5e8fdf2266a..74c153d57e9 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2019, MariaDB Corporation. + Copyright (c) 2008, 2020, 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 @@ -2189,11 +2189,7 @@ static void mysqld_exit(int exit_code) shutdown_performance_schema(); // we do it as late as possible #endif set_malloc_size_cb(NULL); - if (opt_endinfo && global_status_var.global_memory_used) - fprintf(stderr, "Warning: Memory not freed: %ld\n", - (long) global_status_var.global_memory_used); - if (!opt_debugging && !my_disable_leak_check && exit_code == 0 && - debug_assert_on_not_freed_memory) + if (global_status_var.global_memory_used) { #ifdef SAFEMALLOC sf_report_leaked_memory(0); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 0cf51415723..180dbb772ef 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2015, MariaDB + Copyright (c) 2008, 2020, 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 @@ -4696,6 +4696,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, double roru_index_costs; ha_rows roru_total_records; double roru_intersect_part= 1.0; + bool only_ror_scans_required= FALSE; size_t n_child_scans; DBUG_ENTER("get_best_disjunct_quick"); DBUG_PRINT("info", ("Full table scan cost: %g", read_time)); @@ -4722,6 +4723,9 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, sizeof(TRP_RANGE*)* n_child_scans))) DBUG_RETURN(NULL); + + only_ror_scans_required= !optimizer_flag(param->thd, + OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION); /* Collect best 'range' scan for each of disjuncts, and, while doing so, analyze possibility of ROR scans. Also calculate some values needed by @@ -4734,7 +4738,8 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, DBUG_EXECUTE("info", print_sel_tree(param, *ptree, &(*ptree)->keys_map, "tree in SEL_IMERGE");); if (!(*cur_child= get_key_scans_params(param, *ptree, TRUE, FALSE, - read_time, TRUE))) + read_time, + only_ror_scans_required))) { /* One of index scans in this index_merge is more expensive than entire @@ -5056,7 +5061,7 @@ TABLE_READ_PLAN *merge_same_index_scans(PARAM *param, SEL_IMERGE *imerge, index merge retrievals are not well calibrated */ trp= get_key_scans_params(param, *imerge->trees, FALSE, TRUE, - read_time, TRUE); + read_time, FALSE); } DBUG_RETURN(trp); @@ -6784,7 +6789,8 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param, index_read_must_be_used if TRUE, assume 'index only' option will be set (except for clustered PK indexes) read_time don't create read plans with cost > read_time. - ror_scans_required set to TRUE for index merge + only_ror_scans_required set to TRUE when we are only interested + in ROR scan RETURN Best range read plan NULL if no plan found or error occurred @@ -6794,7 +6800,7 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree, bool index_read_must_be_used, bool update_tbl_stats, double read_time, - bool ror_scans_required) + bool only_ror_scans_required) { uint idx, UNINIT_VAR(best_idx); SEL_ARG *key_to_read= NULL; @@ -6842,8 +6848,7 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree, update_tbl_stats, &mrr_flags, &buf_size, &cost); - if (ror_scans_required && !param->is_ror_scan && - !optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION)) + if (only_ror_scans_required && !param->is_ror_scan) { /* The scan is not a ROR-scan, just skip it */ continue; diff --git a/storage/maria/ma_close.c b/storage/maria/ma_close.c index 2716f3b5c42..8a054ec044f 100644 --- a/storage/maria/ma_close.c +++ b/storage/maria/ma_close.c @@ -20,7 +20,7 @@ to open other files during the time we flush the cache and close this file */ -#include "maria_def.h" +#include "ma_ftdefs.h" #include "ma_crypt.h" int maria_close(register MARIA_HA *info) @@ -86,6 +86,7 @@ int maria_close(register MARIA_HA *info) share->open_list= list_delete(share->open_list, &info->share_list); } + maria_ftparser_call_deinitializer(info); my_free(info->rec_buff); (*share->end)(info); diff --git a/storage/maria/ma_pagecrc.c b/storage/maria/ma_pagecrc.c index e0fee185980..c0d535d2e9d 100644 --- a/storage/maria/ma_pagecrc.c +++ b/storage/maria/ma_pagecrc.c @@ -251,7 +251,8 @@ my_bool maria_page_crc_check_index(int res, PAGECACHE_IO_HOOK_ARGS *args) if (length > share->block_size - CRC_SIZE) { DBUG_PRINT("error", ("Wrong page length: %u", length)); - return (my_errno= HA_ERR_WRONG_CRC); + my_errno= HA_ERR_WRONG_CRC; + return 1; } return maria_page_crc_check(page, (uint32) page_no, share, MARIA_NO_CRC_NORMAL_PAGE, diff --git a/storage/myisam/mi_close.c b/storage/myisam/mi_close.c index 5f84eb89c28..56197729251 100644 --- a/storage/myisam/mi_close.c +++ b/storage/myisam/mi_close.c @@ -20,7 +20,7 @@ to open other files during the time we flush the cache and close this file */ -#include "myisamdef.h" +#include "ftdefs.h" int mi_close(register MI_INFO *info) { @@ -60,6 +60,8 @@ int mi_close(register MI_INFO *info) mysql_mutex_unlock(&share->intern_lock); my_free(mi_get_rec_buff_ptr(info, info->rec_buff)); + ftparser_call_deinitializer(info); + if (flag) { DBUG_EXECUTE_IF("crash_before_flush_keys", |