diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-01-17 06:40:24 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-01-17 06:40:24 +0200 |
commit | 71eb7626112e5a3d0d0a28dc70b7d117a24c0f40 (patch) | |
tree | a38cea8380b1e55d8c033d64605156fe17324847 | |
parent | 038785e1f898db74f6486fe7b9209d842c76308b (diff) | |
parent | 19a7656fb12bfae7472658056f400bb81ab99c2f (diff) | |
download | mariadb-git-71eb7626112e5a3d0d0a28dc70b7d117a24c0f40.tar.gz |
Merge 10.0 into 10.1
25 files changed, 169 insertions, 77 deletions
diff --git a/mysql-test/r/subselect_exists2in.result b/mysql-test/r/subselect_exists2in.result index d47e446fe8f..b6b2f5b476f 100644 --- a/mysql-test/r/subselect_exists2in.result +++ b/mysql-test/r/subselect_exists2in.result @@ -330,7 +330,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'test.t2.b' of SELECT #3 was resolved in SELECT #2 -Note 1003 select (select 1 from dual where (not(((1 is not null) and <in_optimizer>(1,1 in ( <materialize> (select `test`.`t3`.`c` from `test`.`t3` where (`test`.`t3`.`c` is not null) ), <primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `<subquery3>`.`c`))))))))) AS `( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )` from `test`.`t1` +Note 1003 select (select 1 from dual where (not(((1 is not null) and <in_optimizer>(1,1 in (<primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `<subquery3>`.`c`))))))))) AS `( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )` from `test`.`t1` SELECT ( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1; ( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) ) 1 @@ -344,7 +344,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'test.t2.b' of SELECT #3 was resolved in SELECT #2 -Note 1003 select (select 1 from dual where (not(((1 is not null) and <in_optimizer>(1,1 in ( <materialize> (select `test`.`t3`.`c` from `test`.`t3` where (`test`.`t3`.`c` is not null) ), <primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `<subquery3>`.`c`))))))))) AS `( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )` from `test`.`t1` +Note 1003 select (select 1 from dual where (not(((1 is not null) and <in_optimizer>(1,1 in (<primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `<subquery3>`.`c`))))))))) AS `( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )` from `test`.`t1` SELECT ( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1; ( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) ) 1 diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index af0fb6b4861..27f3f31bed1 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -2121,6 +2121,44 @@ select @advertAcctId as a from dual union all select 1.0 from dual; a 1000003.0 1.0 +# +# MDEV-13784: query causes seg fault +# +CREATE TABLE t1 (`bug_id` int NOT NULL PRIMARY KEY, `product_id` int NOT NULL); +INSERT INTO t1 VALUES (45199,1184); +CREATE TABLE t2 (`product_id` int NOT NULL,`userid` int NOT NULL, PRIMARY KEY (`product_id`,`userid`)); +INSERT INTO t2 VALUES (1184,103),(1184,624),(1184,1577),(1184,1582); +CREATE TABLE t3 (`id` int NOT NULL PRIMARY KEY,`name` varchar(64)); +CREATE TABLE t4 ( `userid` int NOT NULL PRIMARY KEY, `login_name` varchar(255)); +INSERT INTO t4 VALUES (103,'foo'),(624,'foo'),(1577,'foo'),(1582,'foo'); +CREATE TABLE t5 (`id` int NOT NULL PRIMARY KEY, `name` varchar(64)); +explain select +( +select login_name from t4 where userId = ( +select userid from t2 where product_id = t1.product_id +union +select userid from t2 where product_id = ( +select id from t5 where name = (select name from t3 where id = t1.product_id)) limit 1 ) +) as x from t1 where (t1.bug_id=45199); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 +2 SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 func 1 Using where +3 SUBQUERY t2 ref PRIMARY PRIMARY 4 const 3 Using index +4 UNION t2 ref PRIMARY PRIMARY 4 func 1 Using where; Using index +5 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +6 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL +select +( +select login_name from t4 where userId = ( +select userid from t2 where product_id = t1.product_id +union +select userid from t2 where product_id = ( +select id from t5 where name = (select name from t3 where id = t1.product_id)) limit 1 ) +) as x from t1 where (t1.bug_id=45199); +x +foo +drop table t1, t2, t3, t4, t5; End of 5.5 tests # # WL#1763 Avoid creating temporary table in UNION ALL diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index e8c96e49977..a0f4b34af8b 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -4665,7 +4665,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where (not(<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(select NULL from `test`.`t4` where ((`test`.`t4`.`a` >= `test`.`t1`.`a`) and trigcond(((<cache>(10) = NULL) or <cache>(isnull(NULL))))) having trigcond(<is_not_null_test>(NULL))))))) +Note 1003 select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where (not(<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(select NULL from `test`.`t4` where ((`test`.`t4`.`a` >= `test`.`t1`.`a`) and trigcond(((<cache>(10) = NULL) or 1))) having trigcond(<is_not_null_test>(NULL))))))) SELECT * FROM t1, t2 WHERE t2.a NOT IN (SELECT t3.b FROM t3 RIGHT JOIN t4 ON (t4.a = t3.a) WHERE t4.a >= t1.a); @@ -4681,7 +4681,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'v1.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where (not(<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(select NULL from `test`.`t4` where ((`test`.`t4`.`a` >= `test`.`t1`.`a`) and trigcond(((<cache>(10) = NULL) or <cache>(isnull(NULL))))) having trigcond(<is_not_null_test>(NULL))))))) +Note 1003 select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where (not(<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(select NULL from `test`.`t4` where ((`test`.`t4`.`a` >= `test`.`t1`.`a`) and trigcond(((<cache>(10) = NULL) or 1))) having trigcond(<is_not_null_test>(NULL))))))) SELECT * FROM v1, t2 WHERE t2.a NOT IN (SELECT t3.b FROM t3 RIGHT JOIN t4 ON (t4.a = t3.a) WHERE t4.a >= v1.a); diff --git a/mysql-test/suite/innodb/r/innodb-virtual-columns.result b/mysql-test/suite/innodb/r/innodb-virtual-columns.result index 558bb23de0a..900fca8309e 100644 --- a/mysql-test/suite/innodb/r/innodb-virtual-columns.result +++ b/mysql-test/suite/innodb/r/innodb-virtual-columns.result @@ -320,3 +320,18 @@ term uw_id plan wdraw_rsn admit_term 1035 2 CSM ACAD 1009 drop table grad_degree; drop table gso_grad_supr; +CREATE TABLE t1 (a INT, b CHAR(12), c INT AS (a) VIRTUAL, FULLTEXT KEY(b)) ENGINE=InnoDB; +INSERT INTO t1 (a,b) VALUES (1,'foo'); +SELECT * FROM t1; +a b c +1 foo 1 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b CHAR(12), c INT AS (a) VIRTUAL) ENGINE=InnoDB; +INSERT INTO t1 (a,b) VALUES (1,'foo'); +ALTER TABLE t1 ADD FULLTEXT KEY(b); +Warnings: +Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +SELECT * FROM t1; +a b c +1 foo 1 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb-virtual-columns.test b/mysql-test/suite/innodb/t/innodb-virtual-columns.test index 368c6fc8cb1..99f550eb667 100644 --- a/mysql-test/suite/innodb/t/innodb-virtual-columns.test +++ b/mysql-test/suite/innodb/t/innodb-virtual-columns.test @@ -300,3 +300,14 @@ select * from gso_grad_supr; drop table grad_degree; drop table gso_grad_supr; + +CREATE TABLE t1 (a INT, b CHAR(12), c INT AS (a) VIRTUAL, FULLTEXT KEY(b)) ENGINE=InnoDB; +INSERT INTO t1 (a,b) VALUES (1,'foo'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a INT, b CHAR(12), c INT AS (a) VIRTUAL) ENGINE=InnoDB; +INSERT INTO t1 (a,b) VALUES (1,'foo'); +ALTER TABLE t1 ADD FULLTEXT KEY(b); +SELECT * FROM t1; +DROP TABLE t1; diff --git a/mysql-test/suite/sys_vars/r/table_definition_cache_basic.result b/mysql-test/suite/sys_vars/r/table_definition_cache_basic.result index f6befe51bc1..f7ce3f53bfc 100644 --- a/mysql-test/suite/sys_vars/r/table_definition_cache_basic.result +++ b/mysql-test/suite/sys_vars/r/table_definition_cache_basic.result @@ -28,14 +28,14 @@ Warning 1292 Truncated incorrect table_definition_cache value: '2' SELECT @@global.table_definition_cache; @@global.table_definition_cache 400 -SET @@global.table_definition_cache = 524287; +SET @@global.table_definition_cache = 2097151; SELECT @@global.table_definition_cache; @@global.table_definition_cache -524287 -SET @@global.table_definition_cache = 524288; +2097151 +SET @@global.table_definition_cache = 2097152; SELECT @@global.table_definition_cache; @@global.table_definition_cache -524288 +2097152 '#--------------------FN_DYNVARS_019_04-------------------------#' SET @@global.table_definition_cache = 0; Warnings: @@ -49,18 +49,18 @@ Warning 1292 Truncated incorrect table_definition_cache value: '-1024' SELECT @@global.table_definition_cache; @@global.table_definition_cache 400 -SET @@global.table_definition_cache = 524289; +SET @@global.table_definition_cache = 2097153; Warnings: -Warning 1292 Truncated incorrect table_definition_cache value: '524289' +Warning 1292 Truncated incorrect table_definition_cache value: '2097153' SELECT @@global.table_definition_cache; @@global.table_definition_cache -524288 +2097152 SET @@global.table_definition_cache = 42949672950; Warnings: Warning 1292 Truncated incorrect table_definition_cache value: '42949672950' SELECT @@global.table_definition_cache; @@global.table_definition_cache -524288 +2097152 SET @@global.table_definition_cache = 21221204.10; ERROR 42000: Incorrect argument type to variable 'table_definition_cache' SET @@global.table_definition_cache = ON; diff --git a/mysql-test/suite/sys_vars/t/table_definition_cache_basic.test b/mysql-test/suite/sys_vars/t/table_definition_cache_basic.test index 69f29108645..183d1d0316e 100644 --- a/mysql-test/suite/sys_vars/t/table_definition_cache_basic.test +++ b/mysql-test/suite/sys_vars/t/table_definition_cache_basic.test @@ -64,9 +64,9 @@ SET @@global.table_definition_cache = 1; SELECT @@global.table_definition_cache; SET @@global.table_definition_cache = 2; SELECT @@global.table_definition_cache; -SET @@global.table_definition_cache = 524287; +SET @@global.table_definition_cache = 2097151; SELECT @@global.table_definition_cache; -SET @@global.table_definition_cache = 524288; +SET @@global.table_definition_cache = 2097152; SELECT @@global.table_definition_cache; @@ -79,7 +79,7 @@ SET @@global.table_definition_cache = 0; SELECT @@global.table_definition_cache; SET @@global.table_definition_cache = -1024; SELECT @@global.table_definition_cache; -SET @@global.table_definition_cache = 524289; +SET @@global.table_definition_cache = 2097153; SELECT @@global.table_definition_cache; SET @@global.table_definition_cache = 42949672950; SELECT @@global.table_definition_cache; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index e1e95347dc4..4ff89428d3e 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -1470,6 +1470,41 @@ eval SET NAMES $old_charset; SET @advertAcctId = 1000003; select @advertAcctId as a from dual union all select 1.0 from dual; +--echo # +--echo # MDEV-13784: query causes seg fault +--echo # + +CREATE TABLE t1 (`bug_id` int NOT NULL PRIMARY KEY, `product_id` int NOT NULL); +INSERT INTO t1 VALUES (45199,1184); + +CREATE TABLE t2 (`product_id` int NOT NULL,`userid` int NOT NULL, PRIMARY KEY (`product_id`,`userid`)); +INSERT INTO t2 VALUES (1184,103),(1184,624),(1184,1577),(1184,1582); + +CREATE TABLE t3 (`id` int NOT NULL PRIMARY KEY,`name` varchar(64)); + + +CREATE TABLE t4 ( `userid` int NOT NULL PRIMARY KEY, `login_name` varchar(255)); +INSERT INTO t4 VALUES (103,'foo'),(624,'foo'),(1577,'foo'),(1582,'foo'); +CREATE TABLE t5 (`id` int NOT NULL PRIMARY KEY, `name` varchar(64)); + +explain select +( + select login_name from t4 where userId = ( + select userid from t2 where product_id = t1.product_id + union + select userid from t2 where product_id = ( + select id from t5 where name = (select name from t3 where id = t1.product_id)) limit 1 ) +) as x from t1 where (t1.bug_id=45199); +select +( + select login_name from t4 where userId = ( + select userid from t2 where product_id = t1.product_id + union + select userid from t2 where product_id = ( + select id from t5 where name = (select name from t3 where id = t1.product_id)) limit 1 ) +) as x from t1 where (t1.bug_id=45199); +drop table t1, t2, t3, t4, t5; + --echo End of 5.5 tests --echo # diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c index 5d19647c989..08e43d0a80a 100644 --- a/mysys/safemalloc.c +++ b/mysys/safemalloc.c @@ -282,8 +282,8 @@ static void warn(const char *format,...) va_list args; DBUG_PRINT("error", ("%s", format)); va_start(args,format); - fflush(stderr); vfprintf(stderr, format, args); + fflush(stderr); va_end(args); #ifdef HAVE_BACKTRACE diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 1e6abf74a85..94a027e5673 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -3793,6 +3793,7 @@ bool st_select_lex::optimize_unflattened_subqueries(bool const_only) inner_join->select_options|= SELECT_DESCRIBE; } res= inner_join->optimize(); + sl->update_used_tables(); sl->update_correlated_cache(); is_correlated_unit|= sl->is_correlated; inner_join->select_options= save_options; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index f941794f89e..16126c471c0 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3178,11 +3178,15 @@ static Sys_var_charptr Sys_system_time_zone( CMD_LINE_HELP_ONLY, IN_SYSTEM_CHARSET, DEFAULT(system_time_zone)); +/* + If One use views with prepared statements this should be bigger than + table_open_cache (now we allow 2 times bigger value) +*/ static Sys_var_ulong Sys_table_def_size( "table_definition_cache", "The number of cached table definitions", GLOBAL_VAR(tdc_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(TABLE_DEF_CACHE_MIN, 512*1024), + VALID_RANGE(TABLE_DEF_CACHE_MIN, 2*1024*1024), DEFAULT(TABLE_DEF_CACHE_DEFAULT), BLOCK_SIZE(1)); @@ -3194,7 +3198,7 @@ static bool fix_table_open_cache(sys_var *, THD *, enum_var_type) return false; } - +/* Check the table_definition_cache comment if makes changes */ static Sys_var_ulong Sys_table_cache_size( "table_open_cache", "The number of cached open tables", GLOBAL_VAR(tc_size), CMD_LINE(REQUIRED_ARG), diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 76b8c423d34..702f84a52d1 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -5813,19 +5813,18 @@ ha_innobase::open( ib_table = dict_table_open_on_name(norm_name, FALSE, TRUE, ignore_err); if (ib_table - && ((!DICT_TF2_FLAG_IS_SET(ib_table, DICT_TF2_FTS_HAS_DOC_ID) - && table->s->stored_fields != dict_table_get_n_user_cols(ib_table)) - || (DICT_TF2_FLAG_IS_SET(ib_table, DICT_TF2_FTS_HAS_DOC_ID) - && (table->s->fields - != dict_table_get_n_user_cols(ib_table) - 1)))) { + && (table->s->stored_fields != dict_table_get_n_user_cols(ib_table) + - !!DICT_TF2_FLAG_IS_SET(ib_table, DICT_TF2_FTS_HAS_DOC_ID))) { ib_logf(IB_LOG_LEVEL_WARN, "table %s contains " ULINTPF " user defined columns " "in InnoDB, but %u columns in MySQL. Please " "check INFORMATION_SCHEMA.INNODB_SYS_COLUMNS and " REFMAN "innodb-troubleshooting.html " "for how to resolve it", - norm_name, dict_table_get_n_user_cols(ib_table), - table->s->fields); + norm_name, dict_table_get_n_user_cols(ib_table) + - !!DICT_TF2_FLAG_IS_SET(ib_table, + DICT_TF2_FTS_HAS_DOC_ID), + table->s->stored_fields); /* Mark this table as corrupted, so the drop table or force recovery can still use it, but not others. */ diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 9b1c3c03672..4850d2432cc 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1555,6 +1555,9 @@ struct buf_page_t{ by buf_pool->mutex. */ ib_uint32_t offset; /*!< page number; also protected by buf_pool->mutex. */ + buf_page_t* hash; /*!< node used in chaining to + buf_pool->page_hash or + buf_pool->zip_hash */ /** count of how manyfold this block is currently bufferfixed */ #ifdef PAGE_ATOMIC_REF_COUNT ib_uint32_t buf_fix_count; @@ -1617,10 +1620,7 @@ struct buf_page_t{ buf_tmp_buffer_t* slot; /*!< Slot for temporary memory used for encryption/compression or NULL */ - #ifndef UNIV_HOTBACKUP - buf_page_t* hash; /*!< node used in chaining to - buf_pool->page_hash or - buf_pool->zip_hash */ +#ifndef UNIV_HOTBACKUP #ifdef UNIV_DEBUG ibool in_page_hash; /*!< TRUE if in buf_pool->page_hash */ ibool in_zip_hash; /*!< TRUE if in buf_pool->zip_hash */ diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 96eca08232d..0b8a9acdfa0 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -1034,8 +1034,10 @@ struct dict_table_t{ table_id_t id; /*!< id of the table */ + hash_node_t id_hash; /*!< hash chain node */ mem_heap_t* heap; /*!< memory heap */ char* name; /*!< table name */ + hash_node_t name_hash; /*!< hash chain node */ const char* dir_path_of_temp_table;/*!< NULL or the directory path where a TEMPORARY table that was explicitly created by a user should be placed if @@ -1092,8 +1094,6 @@ struct dict_table_t{ 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 */ UT_LIST_BASE_NODE_T(dict_index_t) indexes; /*!< list of indexes of the table */ diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index a8dc9e14381..79a598b3612 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -273,7 +273,9 @@ struct fil_node_t { struct fil_space_t { char* name; /*!< space name = the path to the first file in it */ + hash_node_t name_hash;/*!< hash chain the name_hash table */ ulint id; /*!< space id */ + hash_node_t hash; /*!< hash chain node */ ib_int64_t tablespace_version; /*!< in DISCARD/IMPORT this timestamp is used to check if we should ignore @@ -329,8 +331,6 @@ struct fil_space_t { Note that fil_node_t::n_pending tracks actual pending I/O requests. Protected by fil_system->mutex. */ ulint n_pending_ios; - hash_node_t hash; /*!< hash chain node */ - hash_node_t name_hash;/*!< hash chain the name_hash table */ #ifndef UNIV_HOTBACKUP rw_lock_t latch; /*!< latch protecting the file space storage allocation */ diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 20ecd18f591..e2e165dca3f 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -631,12 +631,14 @@ typedef void* os_thread_ret_t; #include "ut0dbg.h" #include "ut0ut.h" #include "db0err.h" +#include <my_valgrind.h> +/* define UNIV macros in terms of my_valgrind.h */ +#define UNIV_MEM_INVALID(addr, size) MEM_UNDEFINED(addr, size) +#define UNIV_MEM_FREE(addr, size) MEM_NOACCESS(addr, size) +#define UNIV_MEM_ALLOC(addr, size) UNIV_MEM_INVALID(addr, size) #ifdef UNIV_DEBUG_VALGRIND # include <valgrind/memcheck.h> # define UNIV_MEM_VALID(addr, size) VALGRIND_MAKE_MEM_DEFINED(addr, size) -# define UNIV_MEM_INVALID(addr, size) VALGRIND_MAKE_MEM_UNDEFINED(addr, size) -# define UNIV_MEM_FREE(addr, size) VALGRIND_MAKE_MEM_NOACCESS(addr, size) -# define UNIV_MEM_ALLOC(addr, size) VALGRIND_MAKE_MEM_UNDEFINED(addr, size) # define UNIV_MEM_DESC(addr, size) VALGRIND_CREATE_BLOCK(addr, size, #addr) # define UNIV_MEM_UNDESC(b) VALGRIND_DISCARD(b) # define UNIV_MEM_ASSERT_RW_LOW(addr, size, should_abort) do { \ @@ -671,9 +673,6 @@ typedef void* os_thread_ret_t; } while (0) #else # define UNIV_MEM_VALID(addr, size) do {} while(0) -# define UNIV_MEM_INVALID(addr, size) do {} while(0) -# define UNIV_MEM_FREE(addr, size) do {} while(0) -# define UNIV_MEM_ALLOC(addr, size) do {} while(0) # define UNIV_MEM_DESC(addr, size) do {} while(0) # define UNIV_MEM_UNDESC(b) do {} while(0) # define UNIV_MEM_ASSERT_RW_LOW(addr, size, should_abort) do {} while(0) diff --git a/storage/innobase/os/os0proc.cc b/storage/innobase/os/os0proc.cc index ff6d65e4ae6..f711fbb025b 100644 --- a/storage/innobase/os/os0proc.cc +++ b/storage/innobase/os/os0proc.cc @@ -192,7 +192,6 @@ os_mem_free_large( ut_a(ut_total_allocated_memory >= size); ut_total_allocated_memory -= size; os_fast_mutex_unlock(&ut_list_mutex); - UNIV_MEM_FREE(ptr, size); return; } #endif /* HAVE_LARGE_PAGES && UNIV_LINUX */ @@ -208,7 +207,6 @@ os_mem_free_large( ut_a(ut_total_allocated_memory >= size); ut_total_allocated_memory -= size; os_fast_mutex_unlock(&ut_list_mutex); - UNIV_MEM_FREE(ptr, size); } #elif !defined OS_MAP_ANON ut_free(ptr); @@ -226,7 +224,6 @@ os_mem_free_large( ut_a(ut_total_allocated_memory >= size); ut_total_allocated_memory -= size; os_fast_mutex_unlock(&ut_list_mutex); - UNIV_MEM_FREE(ptr, size); } #endif } diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index 1ec666123c9..7e6e92ed849 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2018, MariaDB Corporation. +Copyright (c) 2015, 2019, 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 @@ -779,7 +779,7 @@ loop: goto func_exit; } - UNIV_MEM_INVALID(block[t_ctx.buf_used][0], srv_sort_buf_size); + UNIV_MEM_INVALID(block[t_ctx.buf_used], srv_sort_buf_size); buf[t_ctx.buf_used] = row_merge_buf_empty(buf[t_ctx.buf_used]); mycount[t_ctx.buf_used] += t_ctx.rows_added[t_ctx.buf_used]; t_ctx.rows_added[t_ctx.buf_used] = 0; @@ -874,12 +874,11 @@ exit: goto func_exit; } - UNIV_MEM_INVALID(block[i][0], - srv_sort_buf_size); + UNIV_MEM_INVALID(block[i], srv_sort_buf_size); if (crypt_block[i]) { - UNIV_MEM_INVALID(crypt_block[i][0], - srv_sort_buf_size); + UNIV_MEM_INVALID(crypt_block[i], + srv_sort_buf_size); } } diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 3ea1c17ce16..d3be5155d27 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -6368,19 +6368,18 @@ ha_innobase::open( ib_table = dict_table_open_on_name(norm_name, FALSE, TRUE, ignore_err); if (ib_table - && ((!DICT_TF2_FLAG_IS_SET(ib_table, DICT_TF2_FTS_HAS_DOC_ID) - && table->s->stored_fields != dict_table_get_n_user_cols(ib_table)) - || (DICT_TF2_FLAG_IS_SET(ib_table, DICT_TF2_FTS_HAS_DOC_ID) - && (table->s->fields - != dict_table_get_n_user_cols(ib_table) - 1)))) { + && (table->s->stored_fields != dict_table_get_n_user_cols(ib_table) + - !!DICT_TF2_FLAG_IS_SET(ib_table, DICT_TF2_FTS_HAS_DOC_ID))) { ib_logf(IB_LOG_LEVEL_WARN, "table %s contains " ULINTPF " user defined columns " "in InnoDB, but %u columns in MySQL. Please " "check INFORMATION_SCHEMA.INNODB_SYS_COLUMNS and " REFMAN "innodb-troubleshooting.html " "for how to resolve it", - norm_name, dict_table_get_n_user_cols(ib_table), - table->s->fields); + norm_name, dict_table_get_n_user_cols(ib_table) + - !!DICT_TF2_FLAG_IS_SET(ib_table, + DICT_TF2_FTS_HAS_DOC_ID), + table->s->stored_fields); /* Mark this table as corrupted, so the drop table or force recovery can still use it, but not others. */ diff --git a/storage/xtradb/include/buf0buf.h b/storage/xtradb/include/buf0buf.h index f4278aa7547..a618d925f57 100644 --- a/storage/xtradb/include/buf0buf.h +++ b/storage/xtradb/include/buf0buf.h @@ -1576,6 +1576,9 @@ struct buf_page_t{ ib_uint32_t space; /*!< tablespace id. */ ib_uint32_t offset; /*!< page number. */ + buf_page_t* hash; /*!< node used in chaining to + buf_pool->page_hash or + buf_pool->zip_hash */ /** count of how manyfold this block is currently bufferfixed */ #ifdef PAGE_ATOMIC_REF_COUNT ib_uint32_t buf_fix_count; @@ -1646,9 +1649,6 @@ struct buf_page_t{ used for encryption/compression or NULL */ #ifndef UNIV_HOTBACKUP - buf_page_t* hash; /*!< node used in chaining to - buf_pool->page_hash or - buf_pool->zip_hash */ #ifdef UNIV_DEBUG ibool in_page_hash; /*!< TRUE if in buf_pool->page_hash */ ibool in_zip_hash; /*!< TRUE if in buf_pool->zip_hash */ diff --git a/storage/xtradb/include/dict0mem.h b/storage/xtradb/include/dict0mem.h index 16aaab3e621..09eabf298c9 100644 --- a/storage/xtradb/include/dict0mem.h +++ b/storage/xtradb/include/dict0mem.h @@ -1050,8 +1050,10 @@ struct dict_table_t{ table_id_t id; /*!< id of the table */ + hash_node_t id_hash; /*!< hash chain node */ mem_heap_t* heap; /*!< memory heap */ char* name; /*!< table name */ + hash_node_t name_hash; /*!< hash chain node */ const char* dir_path_of_temp_table;/*!< NULL or the directory path where a TEMPORARY table that was explicitly created by a user should be placed if @@ -1109,8 +1111,6 @@ struct dict_table_t{ 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 */ UT_LIST_BASE_NODE_T(dict_index_t) indexes; /*!< list of indexes of the table */ diff --git a/storage/xtradb/include/fil0fil.h b/storage/xtradb/include/fil0fil.h index 7b8339fec7d..7be4d0380e0 100644 --- a/storage/xtradb/include/fil0fil.h +++ b/storage/xtradb/include/fil0fil.h @@ -267,7 +267,9 @@ struct fil_node_t { struct fil_space_t { char* name; /*!< space name = the path to the first file in it */ + hash_node_t name_hash;/*!< hash chain the name_hash table */ ulint id; /*!< space id */ + hash_node_t hash; /*!< hash chain node */ ib_int64_t tablespace_version; /*!< in DISCARD/IMPORT this timestamp is used to check if we should ignore @@ -323,8 +325,6 @@ struct fil_space_t { Note that fil_node_t::n_pending tracks actual pending I/O requests. Protected by fil_system->mutex. */ ulint n_pending_ios; - hash_node_t hash; /*!< hash chain node */ - hash_node_t name_hash;/*!< hash chain the name_hash table */ #ifndef UNIV_HOTBACKUP prio_rw_lock_t latch; /*!< latch protecting the file space storage allocation */ diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i index 67e4d90d6df..7da0dfe4728 100644 --- a/storage/xtradb/include/univ.i +++ b/storage/xtradb/include/univ.i @@ -645,12 +645,14 @@ typedef void* os_thread_ret_t; #include "ut0dbg.h" #include "ut0ut.h" #include "db0err.h" +#include <my_valgrind.h> +/* define UNIV macros in terms of my_valgrind.h */ +#define UNIV_MEM_INVALID(addr, size) MEM_UNDEFINED(addr, size) +#define UNIV_MEM_FREE(addr, size) MEM_NOACCESS(addr, size) +#define UNIV_MEM_ALLOC(addr, size) UNIV_MEM_INVALID(addr, size) #ifdef UNIV_DEBUG_VALGRIND # include <valgrind/memcheck.h> # define UNIV_MEM_VALID(addr, size) VALGRIND_MAKE_MEM_DEFINED(addr, size) -# define UNIV_MEM_INVALID(addr, size) VALGRIND_MAKE_MEM_UNDEFINED(addr, size) -# define UNIV_MEM_FREE(addr, size) VALGRIND_MAKE_MEM_NOACCESS(addr, size) -# define UNIV_MEM_ALLOC(addr, size) VALGRIND_MAKE_MEM_UNDEFINED(addr, size) # define UNIV_MEM_DESC(addr, size) VALGRIND_CREATE_BLOCK(addr, size, #addr) # define UNIV_MEM_UNDESC(b) VALGRIND_DISCARD(b) # define UNIV_MEM_ASSERT_RW_LOW(addr, size, should_abort) do { \ @@ -685,9 +687,6 @@ typedef void* os_thread_ret_t; } while (0) #else # define UNIV_MEM_VALID(addr, size) do {} while(0) -# define UNIV_MEM_INVALID(addr, size) do {} while(0) -# define UNIV_MEM_FREE(addr, size) do {} while(0) -# define UNIV_MEM_ALLOC(addr, size) do {} while(0) # define UNIV_MEM_DESC(addr, size) do {} while(0) # define UNIV_MEM_UNDESC(b) do {} while(0) # define UNIV_MEM_ASSERT_RW_LOW(addr, size, should_abort) do {} while(0) diff --git a/storage/xtradb/os/os0proc.cc b/storage/xtradb/os/os0proc.cc index 6c9116e1397..c64c37705b5 100644 --- a/storage/xtradb/os/os0proc.cc +++ b/storage/xtradb/os/os0proc.cc @@ -247,7 +247,6 @@ os_mem_free_large( ut_a(ut_total_allocated_memory >= size); ut_total_allocated_memory -= size; os_fast_mutex_unlock(&ut_list_mutex); - UNIV_MEM_FREE(ptr, size); return; } #endif /* HAVE_LARGE_PAGES && UNIV_LINUX */ @@ -263,7 +262,6 @@ os_mem_free_large( ut_a(ut_total_allocated_memory >= size); ut_total_allocated_memory -= size; os_fast_mutex_unlock(&ut_list_mutex); - UNIV_MEM_FREE(ptr, size); } #elif !defined OS_MAP_ANON ut_free(ptr); @@ -281,7 +279,6 @@ os_mem_free_large( ut_a(ut_total_allocated_memory >= size); ut_total_allocated_memory -= size; os_fast_mutex_unlock(&ut_list_mutex); - UNIV_MEM_FREE(ptr, size); } #endif } diff --git a/storage/xtradb/row/row0ftsort.cc b/storage/xtradb/row/row0ftsort.cc index 7b7620c4a02..deae270f716 100644 --- a/storage/xtradb/row/row0ftsort.cc +++ b/storage/xtradb/row/row0ftsort.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2018, MariaDB Corporation. +Copyright (c) 2015, 2019, 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 @@ -782,7 +782,7 @@ loop: goto func_exit; } - UNIV_MEM_INVALID(block[t_ctx.buf_used][0], srv_sort_buf_size); + UNIV_MEM_INVALID(block[t_ctx.buf_used], srv_sort_buf_size); buf[t_ctx.buf_used] = row_merge_buf_empty(buf[t_ctx.buf_used]); mycount[t_ctx.buf_used] += t_ctx.rows_added[t_ctx.buf_used]; t_ctx.rows_added[t_ctx.buf_used] = 0; @@ -877,12 +877,11 @@ exit: goto func_exit; } - UNIV_MEM_INVALID(block[i][0], - srv_sort_buf_size); + UNIV_MEM_INVALID(block[i], srv_sort_buf_size); if (crypt_block[i]) { - UNIV_MEM_INVALID(crypt_block[i][0], - srv_sort_buf_size); + UNIV_MEM_INVALID(crypt_block[i], + srv_sort_buf_size); } } |