diff options
author | Sergei Golubchik <serg@mariadb.org> | 2021-02-22 21:25:16 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2021-02-22 22:42:27 +0100 |
commit | 0ab1e3914c78e4a82a8e4502b58b20e5598727ab (patch) | |
tree | 403a06406bd6998e588cb51a0f058cfa668e96da /storage | |
parent | ca126d96f5175ba03c32ea79774075d6d42c98cb (diff) | |
parent | 3c021485c913828b83510967c1ff277011a9d59a (diff) | |
download | mariadb-git-0ab1e3914c78e4a82a8e4502b58b20e5598727ab.tar.gz |
Merge branch '10.2' into 10.3
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/btr/btr0sea.cc | 71 | ||||
-rw-r--r-- | storage/innobase/handler/handler0alter.cc | 34 | ||||
-rw-r--r-- | storage/rocksdb/mysql-test/rocksdb/r/issue896.result | 2 | ||||
-rw-r--r-- | storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result | 6 | ||||
-rw-r--r-- | storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes.result | 2 | ||||
-rw-r--r-- | storage/tokudb/mysql-test/tokudb/r/type_decimal.result | 5 |
6 files changed, 99 insertions, 21 deletions
diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc index 2ca0df6d371..b0b75ded890 100644 --- a/storage/innobase/btr/btr0sea.cc +++ b/storage/innobase/btr/btr0sea.cc @@ -2,7 +2,7 @@ Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -673,6 +673,12 @@ btr_search_update_hash_ref( return; } + if (cursor->index != index) { + ut_ad(cursor->index->id == index->id); + btr_search_drop_page_hash_index(block); + return; + } + ut_ad(block->page.id.space() == index->table->space_id); ut_ad(index == cursor->index); ut_ad(!dict_index_is_ibuf(index)); @@ -1132,15 +1138,26 @@ retry: % btr_ahi_parts; latch = btr_search_latches[ahi_slot]; - rw_lock_s_lock(latch); + dict_index_t* index = block->index; + + bool is_freed = index && index->freed(); + if (is_freed) { + rw_lock_x_lock(latch); + } else { + rw_lock_s_lock(latch); + } + assert_block_ahi_valid(block); - if (!block->index || !btr_search_enabled) { - rw_lock_s_unlock(latch); + if (!index || !btr_search_enabled) { + if (is_freed) { + rw_lock_x_unlock(latch); + } else { + rw_lock_s_unlock(latch); + } return; } - dict_index_t* index = block->index; #ifdef MYSQL_INDEX_DISABLE_AHI ut_ad(!index->disable_ahi); #endif @@ -1156,7 +1173,9 @@ retry: /* NOTE: The AHI fields of block must not be accessed after releasing search latch, as the index page might only be s-latched! */ - rw_lock_s_unlock(latch); + if (!is_freed) { + rw_lock_s_unlock(latch); + } ut_a(n_fields > 0 || n_bytes > 0); @@ -1207,16 +1226,18 @@ next_rec: mem_heap_free(heap); } - rw_lock_x_lock(latch); + if (!is_freed) { + rw_lock_x_lock(latch); - if (UNIV_UNLIKELY(!block->index)) { - /* Someone else has meanwhile dropped the hash index */ + if (UNIV_UNLIKELY(!block->index)) { + /* Someone else has meanwhile dropped the + hash index */ + goto cleanup; + } - goto cleanup; + ut_a(block->index == index); } - ut_a(block->index == index); - if (block->curr_n_fields != n_fields || block->curr_n_bytes != n_bytes) { @@ -1590,6 +1611,7 @@ btr_search_move_or_delete_hash_entries( rw_lock_t* ahi_latch = index ? btr_get_search_latch(index) : NULL; if (new_block->index) { +drop_exit: btr_search_drop_page_hash_index(block); return; } @@ -1601,6 +1623,12 @@ btr_search_move_or_delete_hash_entries( rw_lock_s_lock(ahi_latch); if (block->index) { + + if (block->index != index) { + rw_lock_s_unlock(ahi_latch); + goto drop_exit; + } + ulint n_fields = block->curr_n_fields; ulint n_bytes = block->curr_n_bytes; ibool left_side = block->curr_left_side; @@ -1621,7 +1649,6 @@ btr_search_move_or_delete_hash_entries( ut_ad(left_side == block->curr_left_side); return; } - rw_lock_s_unlock(ahi_latch); } @@ -1659,6 +1686,12 @@ void btr_search_update_hash_on_delete(btr_cur_t* cursor) return; } + if (index != cursor->index) { + ut_ad(index->id == cursor->index->id); + btr_search_drop_page_hash_index(block); + return; + } + ut_ad(block->page.id.space() == index->table->space_id); ut_a(index == cursor->index); ut_a(block->curr_n_fields > 0 || block->curr_n_bytes > 0); @@ -1732,6 +1765,12 @@ btr_search_update_hash_node_on_insert(btr_cur_t* cursor, rw_lock_t* ahi_latch) return; } + if (cursor->index != index) { + ut_ad(cursor->index->id == index->id); + btr_search_drop_page_hash_index(block); + return; + } + ut_a(cursor->index == index); ut_ad(!dict_index_is_ibuf(index)); rw_lock_x_lock(ahi_latch); @@ -1821,6 +1860,12 @@ btr_search_update_hash_on_insert(btr_cur_t* cursor, rw_lock_t* ahi_latch) #ifdef MYSQL_INDEX_DISABLE_AHI ut_a(!index->disable_ahi); #endif + if (index != cursor->index) { + ut_ad(index->id == cursor->index->id); + btr_search_drop_page_hash_index(block); + return; + } + ut_a(index == cursor->index); ut_ad(!dict_index_is_ibuf(index)); diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index dddcb9ceae0..90c8c085785 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -7613,6 +7613,7 @@ innobase_rename_column_try( { pars_info_t* info; dberr_t error; + bool clust_has_prefixes = false; DBUG_ENTER("innobase_rename_column_try"); @@ -7701,6 +7702,39 @@ err_exit: if (error != DB_SUCCESS) { goto err_exit; } + + if (!has_prefixes || !clust_has_prefixes + || field->prefix_len) { + continue; + } + + /* For secondary indexes, the + has_prefixes check can be 'polluted' + by PRIMARY KEY column prefix. Try also + the simpler encoding of SYS_FIELDS.POS. */ + info = pars_info_create(); + + pars_info_add_ull_literal(info, "indexid", index->id); + pars_info_add_int4_literal(info, "nth", i); + pars_info_add_str_literal(info, "new", to); + + error = que_eval_sql( + info, + "PROCEDURE RENAME_SYS_FIELDS_PROC () IS\n" + "BEGIN\n" + "UPDATE SYS_FIELDS SET COL_NAME=:new\n" + "WHERE INDEX_ID=:indexid\n" + "AND POS=:nth;\n" + "END;\n", + FALSE, trx); + + if (error != DB_SUCCESS) { + goto err_exit; + } + } + + if (index == dict_table_get_first_index(ctx.old_table)) { + clust_has_prefixes = has_prefixes; } } diff --git a/storage/rocksdb/mysql-test/rocksdb/r/issue896.result b/storage/rocksdb/mysql-test/rocksdb/r/issue896.result index 917c95733f7..6b742ebaf0c 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/issue896.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/issue896.result @@ -9,7 +9,7 @@ KEY `d` (`d`) INSERT INTO t1 VALUES (100, 'aaabbb', UNIX_TIMESTAMP(), 200); EXPLAIN SELECT COUNT(*) FROM t1 FORCE INDEX(d); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL d 11 NULL # Using index +1 SIMPLE t1 index NULL d 9 NULL # Using index # segfault here without the fix SELECT COUNT(*) FROM t1 FORCE INDEX(d); COUNT(*) diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result index e00872f2903..3eeba720c49 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result @@ -546,7 +546,7 @@ pk key1 col1 explain select key1 from t30; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t30 index NULL key1 20 NULL # Using index +1 SIMPLE t30 index NULL key1 18 NULL # Using index select key1 from t30; key1 row1-key @@ -618,7 +618,7 @@ row3 row3-key row3-data explain select * from t30 order by key1 limit 3; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t30 index NULL key1 20 NULL # +1 SIMPLE t30 index NULL key1 18 NULL # select * from t30 order by key1 limit 3; pk key1 col1 row1 row1-key row1-data @@ -627,7 +627,7 @@ row3 row3-key row3-data explain select * from t30 order by key1 desc limit 3; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t30 index NULL key1 20 NULL # +1 SIMPLE t30 index NULL key1 18 NULL # select * from t30 order by key1 desc limit 3; pk key1 col1 row5 row5-key row5-data diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes.result index 413c3f69f23..e8b913288c5 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/type_char_indexes.result @@ -45,7 +45,7 @@ t1 1 v16 1 v16 A 500 NULL NULL YES LSMTREE INSERT INTO t1 (c,c20,v16,v128,pk) VALUES ('a','char1','varchar1a','varchar1b','1'),('a','char2','varchar2a','varchar2b','2'),('b','char3','varchar1a','varchar1b','3'),('c','char4','varchar3a','varchar3b','4'); EXPLAIN SELECT SUBSTRING(v16,0,3) FROM t1 WHERE v16 LIKE 'varchar%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index v16 v16 21 NULL # Using where; Using index +1 SIMPLE t1 index v16 v16 19 NULL # Using where; Using index SELECT SUBSTRING(v16,7,3) FROM t1 WHERE v16 LIKE 'varchar%'; SUBSTRING(v16,7,3) r1a diff --git a/storage/tokudb/mysql-test/tokudb/r/type_decimal.result b/storage/tokudb/mysql-test/tokudb/r/type_decimal.result index 3b82bbcef4f..c01edef283e 100644 --- a/storage/tokudb/mysql-test/tokudb/r/type_decimal.result +++ b/storage/tokudb/mysql-test/tokudb/r/type_decimal.result @@ -177,9 +177,8 @@ Note 1265 Data truncated for column 'a' at row 2 insert into t1 values ("1e+18446744073709551615"),("1e+18446744073709551616"),("1e-9223372036854775807"),("1e-9223372036854775809"); Warnings: Warning 1264 Out of range value for column 'a' at row 1 -Warning 1366 Incorrect decimal value: '1e+18446744073709551616' for column `test`.`t1`.`a` at row 2 +Warning 1264 Out of range value for column 'a' at row 2 Note 1265 Data truncated for column 'a' at row 3 -Warning 1366 Incorrect decimal value: '1e-9223372036854775809' for column `test`.`t1`.`a` at row 4 insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0"); Warnings: Warning 1265 Data truncated for column 'a' at row 1 @@ -210,7 +209,7 @@ a 99999999.99 0.00 99999999.99 -0.00 +99999999.99 0.00 0.00 123.40 |