From d4ea179e13b3e796384173c1b151c770f8c6ed07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 2 Feb 2018 09:10:15 +0200 Subject: [PATCH 1/5] MDEV-13626: Merge InnoDB test cases from MySQL 5.7 (part 7) Import and adjust the innodb.innodb_buffer_pool_resize tests, except innodb.innodb_buffer_pool_resize_debug, which would time out. buf_pool_clear_hash_index(): Adjust assertions. --- .../innodb/r/innodb_buffer_pool_resize.result | 34 +++++++++ ...nodb_buffer_pool_resize_with_chunks.result | 26 +++++++ .../innodb/t/innodb_buffer_pool_resize.opt | 2 + .../innodb/t/innodb_buffer_pool_resize.test | 74 +++++++++++++++++++ .../innodb_buffer_pool_resize_with_chunks.opt | 3 + ...innodb_buffer_pool_resize_with_chunks.test | 63 ++++++++++++++++ storage/innobase/buf/buf0buf.cc | 21 +++++- 7 files changed, 220 insertions(+), 3 deletions(-) create mode 100644 mysql-test/suite/innodb/r/innodb_buffer_pool_resize.result create mode 100644 mysql-test/suite/innodb/r/innodb_buffer_pool_resize_with_chunks.result create mode 100644 mysql-test/suite/innodb/t/innodb_buffer_pool_resize.opt create mode 100644 mysql-test/suite/innodb/t/innodb_buffer_pool_resize.test create mode 100644 mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.opt create mode 100644 mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.test diff --git a/mysql-test/suite/innodb/r/innodb_buffer_pool_resize.result b/mysql-test/suite/innodb/r/innodb_buffer_pool_resize.result new file mode 100644 index 00000000000..667d31a0b69 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_buffer_pool_resize.result @@ -0,0 +1,34 @@ +set global innodb_adaptive_hash_index=ON; +select @@innodb_buffer_pool_size; +@@innodb_buffer_pool_size +8388608 +set global innodb_buffer_pool_size = 10485760; +Warnings: +Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '10485760' +select @@innodb_buffer_pool_size; +@@innodb_buffer_pool_size +16777216 +create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +create or replace view view0 as select 1 union all select 1; +set @`v_id` := 0; +set @`v_val` := 0; +replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17; +set global innodb_buffer_pool_size = 7340032; +Warnings: +Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '7340032' +select @@innodb_buffer_pool_size; +@@innodb_buffer_pool_size +8388608 +select count(val) from t1; +count(val) +262144 +set global innodb_adaptive_hash_index=OFF; +set global innodb_buffer_pool_size = 25165824; +select @@innodb_buffer_pool_size; +@@innodb_buffer_pool_size +25165824 +select count(val) from t1; +count(val) +262144 +drop table t1; +drop view view0; diff --git a/mysql-test/suite/innodb/r/innodb_buffer_pool_resize_with_chunks.result b/mysql-test/suite/innodb/r/innodb_buffer_pool_resize_with_chunks.result new file mode 100644 index 00000000000..4bf244c9588 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_buffer_pool_resize_with_chunks.result @@ -0,0 +1,26 @@ +select @@innodb_buffer_pool_chunk_size; +@@innodb_buffer_pool_chunk_size +2097152 +create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +create or replace view view0 as select 1 union all select 1; +set @`v_id` := 0; +set @`v_val` := 0; +replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17; +set global innodb_buffer_pool_size = 7340032; +Warnings: +Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '7340032' +select count(val) from t1; +count(val) +262144 +set global innodb_buffer_pool_size = 16777216; +select count(val) from t1; +count(val) +262144 +drop table t1; +drop view view0; +set global innodb_buffer_pool_size = 1048576; +Warnings: +Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '1048576' +select @@innodb_buffer_pool_size; +@@innodb_buffer_pool_size +6291456 diff --git a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize.opt b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize.opt new file mode 100644 index 00000000000..39543543a53 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize.opt @@ -0,0 +1,2 @@ +--innodb-buffer-pool-size=8M +--innodb-page-size=4k diff --git a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize.test b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize.test new file mode 100644 index 00000000000..77fdb49a57d --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize.test @@ -0,0 +1,74 @@ +# +# WL6117 : Resize the InnoDB Buffer Pool Online +# + +--source include/have_innodb.inc +--source include/big_test.inc + +let $wait_timeout = 180; +let $wait_condition = + SELECT SUBSTR(variable_value, 1, 34) = 'Completed resizing buffer pool at ' + FROM information_schema.global_status + WHERE LOWER(variable_name) = 'innodb_buffer_pool_resize_status'; + +--disable_query_log +set @old_innodb_buffer_pool_size = @@innodb_buffer_pool_size; +set @old_innodb_adaptive_hash_index = @@innodb_adaptive_hash_index; +if (`select (version() like '%debug%') > 0`) +{ + set @old_innodb_disable_resize = @@innodb_disable_resize_buffer_pool_debug; + set global innodb_disable_resize_buffer_pool_debug = OFF; +} +--enable_query_log + +set global innodb_adaptive_hash_index=ON; + +select @@innodb_buffer_pool_size; + +# Expand buffer pool +set global innodb_buffer_pool_size = 10485760; + +--source include/wait_condition.inc + +select @@innodb_buffer_pool_size; + +# fill buffer pool +create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +create or replace view view0 as select 1 union all select 1; + +set @`v_id` := 0; +set @`v_val` := 0; + +# 2^18 == 262144 records +replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17; + +# Shrink buffer pool +set global innodb_buffer_pool_size = 7340032; +--source include/wait_condition.inc + +select @@innodb_buffer_pool_size; + +select count(val) from t1; + +set global innodb_adaptive_hash_index=OFF; + +# Expand buffer pool to 24MB +set global innodb_buffer_pool_size = 25165824; +--source include/wait_condition.inc + +select @@innodb_buffer_pool_size; + +select count(val) from t1; + +drop table t1; +drop view view0; + +--disable_query_log +set global innodb_adaptive_hash_index = @old_innodb_adaptive_hash_index; +set global innodb_buffer_pool_size = @old_innodb_buffer_pool_size; +if (`select (version() like '%debug%') > 0`) +{ + set global innodb_disable_resize_buffer_pool_debug = @old_innodb_disable_resize; +} +--enable_query_log +--source include/wait_condition.inc diff --git a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.opt b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.opt new file mode 100644 index 00000000000..b97a3995457 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.opt @@ -0,0 +1,3 @@ +--innodb-buffer-pool-size=16M +--innodb-buffer-pool-chunk-size=2M +--innodb-page-size=4k diff --git a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.test b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.test new file mode 100644 index 00000000000..b04b0306bf1 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_with_chunks.test @@ -0,0 +1,63 @@ +# +# WL6117 : Resize the InnoDB Buffer Pool Online +# (innodb_buffer_pool_chunk_size used case) +# + +--source include/have_innodb.inc +--source include/big_test.inc + +let $wait_timeout = 180; +let $wait_condition = + SELECT SUBSTR(variable_value, 1, 34) = 'Completed resizing buffer pool at ' + FROM information_schema.global_status + WHERE LOWER(variable_name) = 'innodb_buffer_pool_resize_status'; + +--disable_query_log +set @old_innodb_buffer_pool_size = @@innodb_buffer_pool_size; +if (`select (version() like '%debug%') > 0`) +{ + set @old_innodb_disable_resize = @@innodb_disable_resize_buffer_pool_debug; + set global innodb_disable_resize_buffer_pool_debug = OFF; +} +--enable_query_log + +select @@innodb_buffer_pool_chunk_size; + +# fill buffer pool +create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +create or replace view view0 as select 1 union all select 1; + +set @`v_id` := 0; +set @`v_val` := 0; + +# 2^18 == 262144 records +replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17; + +# Shrink buffer pool to 7MB +set global innodb_buffer_pool_size = 7340032; +--source include/wait_condition.inc + +select count(val) from t1; + +# Expand buffer pool to 16MB +set global innodb_buffer_pool_size = 16777216; +--source include/wait_condition.inc + +select count(val) from t1; + +drop table t1; +drop view view0; + +# Try to shrink buffer pool to smaller than chunk size +set global innodb_buffer_pool_size = 1048576; +--source include/wait_condition.inc +select @@innodb_buffer_pool_size; + +--disable_query_log +set global innodb_buffer_pool_size = @old_innodb_buffer_pool_size; +if (`select (version() like '%debug%') > 0`) +{ + set global innodb_disable_resize_buffer_pool_debug = @old_innodb_disable_resize; +} +--enable_query_log +--source include/wait_condition.inc diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 07d3f7efe27..445a6597f7d 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -2,7 +2,7 @@ Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -3141,11 +3141,26 @@ buf_pool_clear_hash_index() see the comments in buf0buf.h */ if (!index) { +# if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG + ut_a(!block->n_pointers); +# endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ continue; } - ut_ad(buf_block_get_state(block) - == BUF_BLOCK_FILE_PAGE); + ut_d(buf_page_state state + = buf_block_get_state(block)); + /* Another thread may have set the + state to BUF_BLOCK_REMOVE_HASH in + buf_LRU_block_remove_hashed(). + + The state change in buf_page_realloc() + is not observable here, because in + that case we would have !block->index. + + In the end, the entire adaptive hash + index will be removed. */ + ut_ad(state == BUF_BLOCK_FILE_PAGE + || state == BUF_BLOCK_REMOVE_HASH); # if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG block->n_pointers = 0; # endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ From 009e872b1caf0fe34b7405e45eafae8deb4aa9e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 2 Feb 2018 14:28:46 +0200 Subject: [PATCH 2/5] Merge a test case from MySQL 5.7 (no code fix needed) --- mysql-test/r/partition_innodb.result | 27 +++++++++++++++++++++++++++ mysql-test/t/partition_innodb.test | 28 ++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result index c74f25928a9..942455f23ed 100644 --- a/mysql-test/r/partition_innodb.result +++ b/mysql-test/r/partition_innodb.result @@ -900,3 +900,30 @@ SELECT b FROM t1 WHERE b = 0; ERROR HY000: Table definition has changed, please retry transaction disconnect con1; DROP TABLE t1; +# +# Bug#26390658 RENAMING A PARTITIONED TABLE DOES NOT UPDATE +# MYSQL.INNODB_TABLE_STATS +# +CREATE DATABASE test_jfg; +CREATE TABLE test_jfg.test_jfg1 (id int(10) unsigned NOT NULL,PRIMARY +KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1; +CREATE TABLE test_jfg.test_jfg2 (id int(10) unsigned NOT NULL,PRIMARY +KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1 +PARTITION BY RANGE ( id ) (PARTITION p1000 VALUES LESS THAN (1000) +ENGINE = InnoDB,PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = +InnoDB); +SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE +database_name = 'test_jfg'; +database_name table_name +test_jfg test_jfg1 +test_jfg test_jfg2#P#p1000 +test_jfg test_jfg2#P#pmax +RENAME TABLE test_jfg.test_jfg1 TO test_jfg.test_jfg11; +RENAME TABLE test_jfg.test_jfg2 TO test_jfg.test_jfg12; +SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE +database_name = 'test_jfg'; +database_name table_name +test_jfg test_jfg11 +test_jfg test_jfg12#P#p1000 +test_jfg test_jfg12#P#pmax +DROP DATABASE test_jfg; diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index 300121e88fd..7b5a69fe622 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -991,3 +991,31 @@ SELECT b FROM t1 WHERE b = 0; SELECT b FROM t1 WHERE b = 0; --disconnect con1 DROP TABLE t1; + +--echo # +--echo # Bug#26390658 RENAMING A PARTITIONED TABLE DOES NOT UPDATE +--echo # MYSQL.INNODB_TABLE_STATS +--echo # + +CREATE DATABASE test_jfg; + +CREATE TABLE test_jfg.test_jfg1 (id int(10) unsigned NOT NULL,PRIMARY +KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1; +CREATE TABLE test_jfg.test_jfg2 (id int(10) unsigned NOT NULL,PRIMARY +KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1 +PARTITION BY RANGE ( id ) (PARTITION p1000 VALUES LESS THAN (1000) +ENGINE = InnoDB,PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = +InnoDB); + +--replace_result #p# #P# +SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE +database_name = 'test_jfg'; + +RENAME TABLE test_jfg.test_jfg1 TO test_jfg.test_jfg11; +RENAME TABLE test_jfg.test_jfg2 TO test_jfg.test_jfg12; + +--replace_result #p# #P# +SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE +database_name = 'test_jfg'; + +DROP DATABASE test_jfg; From 4c731a2d7c310cca53a68c30cb7927cdc25ceed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 2 Feb 2018 15:04:52 +0200 Subject: [PATCH 3/5] Adapt a MySQL 5.7 fix for SET GLOBAL innodb_buffer_pool_size Bug#23590280 NO WARNING WHEN REDUCING INNODB_BUFFER_POOL_SIZE INSIZE (sic) THE FIRST CHUNK innodb_buffer_pool_size_validate(): Issue a warning if the requested innodb_buffer_pool_size is less than innodb_buffer_pool_chunk_size, because we cannot shrink individual chunks. --- storage/innobase/handler/ha_innodb.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 5dee02bed67..8ae8e003905 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -22566,8 +22566,19 @@ innodb_buffer_pool_size_validate( *static_cast(save) = requested_buf_pool_size; + if (srv_buf_pool_size == static_cast(intbuf)) { + buf_pool_mutex_exit_all(); + /* nothing to do */ + return(0); + } + if (srv_buf_pool_size == requested_buf_pool_size) { buf_pool_mutex_exit_all(); + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + ER_WRONG_ARGUMENTS, + "innodb_buffer_pool_size must be at least" + " innodb_buffer_pool_chunk_size=%lu", + srv_buf_pool_chunk_unit); /* nothing to do */ return(0); } From 6266493fc33cfcfd3f878c6955b53576277f52ba Mon Sep 17 00:00:00 2001 From: Jimmy Yang Date: Wed, 20 Sep 2017 01:38:26 +0200 Subject: [PATCH 4/5] Bug #25729649 LOCK0LOCK.CC:NNN:ADD_POSITION != __NULL Reviewed-by: Sunny Bains --- .../innodb/r/high_prio_trx_predicate.result | 30 +++++++++ .../innodb/t/high_prio_trx_predicate.test | 61 +++++++++++++++++++ storage/innobase/lock/lock0lock.cc | 7 ++- 3 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 mysql-test/suite/innodb/r/high_prio_trx_predicate.result create mode 100644 mysql-test/suite/innodb/t/high_prio_trx_predicate.test diff --git a/mysql-test/suite/innodb/r/high_prio_trx_predicate.result b/mysql-test/suite/innodb/r/high_prio_trx_predicate.result new file mode 100644 index 00000000000..965e1e0f6ad --- /dev/null +++ b/mysql-test/suite/innodb/r/high_prio_trx_predicate.result @@ -0,0 +1,30 @@ +CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL); +CREATE SPATIAL INDEX idx1 on tab(c2); +INSERT INTO tab(c1,c2) VALUES(1,ST_GeomFromText('POINT(10 10)')); + +# On connection 1 +set transaction isolation level serializable ; +START TRANSACTION; +SELECT ST_AsText(c2) FROM tab WHERE MBRWithin(c2, ST_GeomFromText('POLYGON((5 5, 15 5, 15 15, 5 15, 5 5))')); +ST_AsText(c2) +POINT(10 10) + +# On connection 2 +start transaction; +INSERT INTO tab(c1,c2) VALUES(7, ST_GeomFromText('POINT(11 11)'));; + +# On connection 3 +include/start_transaction_high_prio.inc +START TRANSACTION /* HIGH PRIORITY */; +INSERT INTO tab(c1,c2) VALUES(8, ST_GeomFromText('POINT(10 10)')); +COMMIT; + +# On connection 1 +COMMIT; +ERROR HY000: Got error 149 during COMMIT +include/assert.inc ['There is a 8 in tab'] +SELECT c1 FROM tab; +c1 +1 +8 +DROP TABLE tab; diff --git a/mysql-test/suite/innodb/t/high_prio_trx_predicate.test b/mysql-test/suite/innodb/t/high_prio_trx_predicate.test new file mode 100644 index 00000000000..6503e90653b --- /dev/null +++ b/mysql-test/suite/innodb/t/high_prio_trx_predicate.test @@ -0,0 +1,61 @@ +# Scenario: +# T1=({R(B)}) +# T2=({W(B)}) +# T3=({W(B), C}, HIGH_PRIORITY). +# +# Outcome: T1 must abort, T2 must commit. + +--source include/count_sessions.inc + +CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL); +CREATE SPATIAL INDEX idx1 on tab(c2); +INSERT INTO tab(c1,c2) VALUES(1,ST_GeomFromText('POINT(10 10)')); + +--connect(con1,localhost,root,,test) +--connect(con2,localhost,root,,test) +--connect(con3,localhost,root,,test) + +--echo +--echo # On connection 1 +--connection con1 +set transaction isolation level serializable ; +START TRANSACTION; +SELECT ST_AsText(c2) FROM tab WHERE MBRWithin(c2, ST_GeomFromText('POLYGON((5 5, 15 5, 15 15, 5 15, 5 5))')); + + +--echo +--echo # On connection 2 +--connection con2 +start transaction; +--send INSERT INTO tab(c1,c2) VALUES(7, ST_GeomFromText('POINT(11 11)')); + +--echo +--echo # On connection 3 +--connection con3 +--source include/start_transaction_high_prio.inc +INSERT INTO tab(c1,c2) VALUES(8, ST_GeomFromText('POINT(10 10)')); +COMMIT; +--disconnect con3 + +--echo +--echo # On connection 1 +--connection con1 +--error ER_ERROR_DURING_COMMIT +COMMIT; +--disconnect con1 + +--connection default +--let $assert_text= 'There is a 8 in tab' +--let $assert_cond= [SELECT COUNT(*) AS count FROM tab WHERE tab.c1 = 8, count, 1] = 1 +--source include/assert.inc + +--connection con2 +--reap; +--disconnect con2 + +--connection default +SELECT c1 FROM tab; + +DROP TABLE tab; + +--source include/wait_until_count_sessions.inc diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index f25ac596d5f..cde267aa638 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2014, 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -2728,7 +2728,10 @@ RecLock::lock_add_priority( lock_t* grant_position = NULL; lock_t* add_position = NULL; - HASH_SEARCH(hash, lock_sys->rec_hash, m_rec_id.fold(), lock_t*, + /* Different lock (such as predicate lock) are on different hash */ + hash_table_t* lock_hash = lock_hash_get(m_mode); + + HASH_SEARCH(hash, lock_hash, m_rec_id.fold(), lock_t*, lock_head, ut_ad(lock_head->is_record_lock()), true); ut_ad(lock_head); From d13fbc6212e3fcaf4c0c4eee9c677151a6efafe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 2 Feb 2018 15:27:03 +0200 Subject: [PATCH 5/5] Remove code related to InnoDB native partitioning in MySQL 5.7 row_rename_partitions_for_mysql(): Remove. This should only be relevant in an upgrade into MySQL 5.7, which has InnoDB native partitioning. --- storage/innobase/handler/ha_innodb.cc | 20 ---------- storage/innobase/include/row0mysql.h | 12 ------ storage/innobase/row/row0mysql.cc | 53 --------------------------- 3 files changed, 85 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 8ae8e003905..11b11db09a7 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -13762,26 +13762,6 @@ innobase_rename_table( error = row_rename_table_for_mysql(norm_from, norm_to, trx, TRUE); - if (error == DB_TABLE_NOT_FOUND) { - /* May be partitioned table, which consists of partitions - named table_name#P#partition_name[#SP#subpartition_name]. - - We are doing a DDL operation. */ - ++trx->will_lock; - trx_set_dict_operation(trx, TRX_DICT_OP_INDEX); - trx_start_if_not_started(trx, true); - error = row_rename_partitions_for_mysql(norm_from, norm_to, - trx); - if (error == DB_TABLE_NOT_FOUND) { - ib::error() << "Table " << ut_get_name(trx, norm_from) - << " does not exist in the InnoDB internal" - " data dictionary though MariaDB is trying to" - " rename the table. Have you copied the .frm" - " file of the table to the MariaDB database" - " directory from another database? " - << TROUBLESHOOTING_MSG; - } - } if (error != DB_SUCCESS) { if (error == DB_TABLE_NOT_FOUND && innobase_get_lower_case_table_names() == 1) { diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h index 5cb0249517c..85f763f07a9 100644 --- a/storage/innobase/include/row0mysql.h +++ b/storage/innobase/include/row0mysql.h @@ -494,18 +494,6 @@ row_rename_table_for_mysql( bool commit) /*!< in: whether to commit trx */ MY_ATTRIBUTE((nonnull, warn_unused_result)); -/** Renames a partitioned table for MySQL. -@param[in] old_name Old table name. -@param[in] new_name New table name. -@param[in,out] trx Transaction. -@return error code or DB_SUCCESS */ -dberr_t -row_rename_partitions_for_mysql( - const char* old_name, - const char* new_name, - trx_t* trx) - MY_ATTRIBUTE((nonnull, warn_unused_result)); - /*********************************************************************//** Scans an index for either COOUNT(*) or CHECK TABLE. If CHECK TABLE; Checks that the index contains entries in an ascending order, diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 7c1c07e4a74..ffd884b2755 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -4837,59 +4837,6 @@ funct_exit: return(err); } -/** Renames a partitioned table for MySQL. -@param[in] old_name Old table name. -@param[in] new_name New table name. -@param[in,out] trx Transaction. -@return error code or DB_SUCCESS */ -dberr_t -row_rename_partitions_for_mysql( - const char* old_name, - const char* new_name, - trx_t* trx) -{ - char from_name[FN_REFLEN]; - char to_name[FN_REFLEN]; - ulint from_len = strlen(old_name); - ulint to_len = strlen(new_name); - char* table_name; - dberr_t error = DB_TABLE_NOT_FOUND; - - ut_a(from_len < (FN_REFLEN - 4)); - ut_a(to_len < (FN_REFLEN - 4)); - memcpy(from_name, old_name, from_len); - from_name[from_len] = '#'; - from_name[from_len + 1] = 0; - while ((table_name = dict_get_first_table_name_in_db(from_name))) { - ut_a(memcmp(table_name, from_name, from_len) == 0); - /* Must match #[Pp]# */ - if (strlen(table_name) <= (from_len + 3) - || table_name[from_len] != '#' - || table_name[from_len + 2] != '#' - || (table_name[from_len + 1] != 'P' - && table_name[from_len + 1] != 'p')) { - - ut_ad(0); - ut_free(table_name); - continue; - } - memcpy(to_name, new_name, to_len); - memcpy(to_name + to_len, table_name + from_len, - strlen(table_name) - from_len + 1); - error = row_rename_table_for_mysql(table_name, to_name, - trx, false); - if (error != DB_SUCCESS) { - /* Rollback and return. */ - trx_rollback_for_mysql(trx); - ut_free(table_name); - return(error); - } - ut_free(table_name); - } - trx_commit_for_mysql(trx); - return(error); -} - /*********************************************************************//** Scans an index for either COUNT(*) or CHECK TABLE. If CHECK TABLE; Checks that the index contains entries in an ascending order,