diff options
30 files changed, 284 insertions, 104 deletions
diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake index 4b7faacc466..e269c473f36 100644 --- a/cmake/zlib.cmake +++ b/cmake/zlib.cmake @@ -34,11 +34,6 @@ ENDMACRO() MACRO (MYSQL_CHECK_ZLIB_WITH_COMPRESS) - # For NDBCLUSTER: Use bundled zlib by default - IF (NOT WITH_ZLIB) - SET(WITH_ZLIB "bundled" CACHE STRING "By default use bundled zlib on this platform") - ENDIF() - IF(WITH_ZLIB STREQUAL "bundled") MYSQL_USE_BUNDLED_ZLIB() ELSE() diff --git a/mysql-test/r/func_group_innodb.result b/mysql-test/r/func_group_innodb.result index 52d5922df95..17b3c1e797e 100644 --- a/mysql-test/r/func_group_innodb.result +++ b/mysql-test/r/func_group_innodb.result @@ -246,4 +246,34 @@ EXPLAIN SELECT MIN(c) FROM t1 GROUP BY b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL b 263 NULL 3 Using index for group-by DROP TABLE t1; +# +# MDEV-17589: Stack-buffer-overflow with indexed varchar (utf8) field +# +set @save_innodb_file_format= @@innodb_file_format; +set @save_innodb_large_prefix= @@innodb_large_prefix; +set global innodb_file_format = BARRACUDA; +set global innodb_large_prefix = ON; +CREATE TABLE t1 (v1 varchar(1020), v2 varchar(2), v3 varchar(2), +KEY k1 (v3,v2,v1)) ENGINE=InnoDB CHARACTER SET=utf8 ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES ('king', 'qu','qu'), ('bad','go','go'); +explain +SELECT MIN(t1.v1) FROM t1 where t1.v2='qu' and t1.v3='qu'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +SELECT MIN(t1.v1) FROM t1 where t1.v2='qu' and t1.v3='qu'; +MIN(t1.v1) +king +drop table t1; +CREATE TABLE t1 (v1 varchar(1024) CHARACTER SET utf8, KEY v1 (v1)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES ('king'), ('bad'); +explain +SELECT MIN(x.v1) FROM (SELECT t1.* FROM t1 WHERE t1.v1 >= 'p') x; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching min/max row +SELECT MIN(x.v1) FROM (SELECT t1.* FROM t1 WHERE t1.v1 >= 'p') x; +MIN(x.v1) +NULL +drop table t1; +set global innodb_file_format = @save_innodb_file_format; +set global innodb_large_prefix = @save_innodb_large_prefix; End of 5.5 tests diff --git a/mysql-test/r/innodb_ext_key.result b/mysql-test/r/innodb_ext_key.result index de1323e00f8..e02b78cad15 100644 --- a/mysql-test/r/innodb_ext_key.result +++ b/mysql-test/r/innodb_ext_key.result @@ -1089,6 +1089,7 @@ from t0 A, t0 B, t0 C; drop table t0,t1; # +# # MDEV-10360: Extended keys: index properties depend on index order # create table t0 (a int); diff --git a/mysql-test/r/range_innodb.result b/mysql-test/r/range_innodb.result index 794e6c7b3cc..8bb1c833a56 100644 --- a/mysql-test/r/range_innodb.result +++ b/mysql-test/r/range_innodb.result @@ -37,3 +37,21 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 10 1 SIMPLE t2 range a,b b 5 NULL 201 Using where; Using join buffer (flat, BNL join) drop table t0,t1,t2; +CREATE TABLE t1 ( +pk INT PRIMARY KEY, f1 INT, f2 CHAR(1), f3 CHAR(1), +KEY(f1), KEY(f2) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES +(1,4,'v',NULL),(2,6,'v',NULL),(3,7,'c',NULL),(4,1,'e',NULL),(5,0,'x',NULL), +(6,7,'i',NULL),(7,7,'e',NULL),(8,1,'p',NULL),(9,7,'s',NULL),(10,1,'j',NULL), +(11,5,'z',NULL),(12,2,'c',NULL),(13,0,'a',NULL),(14,1,'q',NULL),(15,8,'y',NULL), +(16,1,'m',NULL),(17,1,'r',NULL),(18,9,'v',NULL),(19,1,'n',NULL); +CREATE TABLE t2 (f4 INT, f5 CHAR(1)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (4,'q'),(NULL,'j'); +SELECT * FROM t1 AS t1_1, t1 AS t1_2, t2 +WHERE f5 = t1_2.f2 AND ( t1_1.f1 = 103 AND t1_1.f2 = 'o' OR t1_1.pk < f4 ); +pk f1 f2 f3 pk f1 f2 f3 f4 f5 +1 4 v NULL 14 1 q NULL 4 q +2 6 v NULL 14 1 q NULL 4 q +3 7 c NULL 14 1 q NULL 4 q +drop table t1,t2; diff --git a/mysql-test/r/read_only.result b/mysql-test/r/read_only.result index 0640360f4f5..7690be28147 100644 --- a/mysql-test/r/read_only.result +++ b/mysql-test/r/read_only.result @@ -168,11 +168,24 @@ flush privileges; drop database mysqltest_db1; set global read_only= @start_read_only; # +# MDEV-16987 - ALTER DATABASE possible in read-only mode +# +CREATE USER user1@localhost; +GRANT ALTER ON test1.* TO user1@localhost; +CREATE DATABASE test1; +SET GLOBAL read_only=1; +ALTER DATABASE test1 CHARACTER SET utf8; +ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement +SET GLOBAL read_only=0; +DROP DATABASE test1; +DROP USER user1@localhost; +USE test; +# End of 5.5 tests +# # WL#5968 Implement START TRANSACTION READ (WRITE|ONLY); # # # Test interaction with read_only system variable. -DROP TABLE IF EXISTS t1; CREATE TABLE t1(a INT); INSERT INTO t1 VALUES (1), (2); CREATE USER user1; @@ -204,3 +217,4 @@ COMMIT; DROP USER user1; SET GLOBAL read_only= 0; DROP TABLE t1; +# End of 10.0 tests diff --git a/mysql-test/suite/innodb/r/innodb-alter.result b/mysql-test/suite/innodb/r/innodb-alter.result index 4e0e5f1aef2..ebafc4fdb59 100644 --- a/mysql-test/suite/innodb/r/innodb-alter.result +++ b/mysql-test/suite/innodb/r/innodb-alter.result @@ -865,6 +865,27 @@ WHERE T.NAME='test/t1'; NAME a DROP TABLE t1; +# and an MDEV-18041 regression related to indexes prefixes +create table `test` ( +`test_old` varchar(255) NOT NULL, +`other` varchar(255) NOT NULL, +PRIMARY KEY (`test_old`,`other`), +UNIQUE KEY uk (`test_old`(100), `other`) +) ENGINE=InnoDB; +select name, pos from information_schema.innodb_SYS_FIELDS where name in ('test_old', 'other', 'test_new'); +name pos +test_old 0 +other 1 +test_old 0 +other 1 +alter table `test` CHANGE COLUMN `test_old` `test_new` varchar(255) NOT NULL; +select name, pos from information_schema.innodb_SYS_FIELDS where name in ('test_old', 'other', 'test_new'); +name pos +test_new 0 +other 1 +test_new 0 +other 1 +drop table `test`; # # BUG 20029625 - HANDLE_FATAL_SIGNAL (SIG=11) IN # DICT_MEM_TABLE_COL_RENAME_LOW diff --git a/mysql-test/suite/innodb/t/innodb-alter.test b/mysql-test/suite/innodb/t/innodb-alter.test index 30e3292ec10..a47573626aa 100644 --- a/mysql-test/suite/innodb/t/innodb-alter.test +++ b/mysql-test/suite/innodb/t/innodb-alter.test @@ -522,6 +522,19 @@ SELECT C.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS C INNER JOIN WHERE T.NAME='test/t1'; DROP TABLE t1; +--echo # and an MDEV-18041 regression related to indexes prefixes +create table `test` ( + `test_old` varchar(255) NOT NULL, + `other` varchar(255) NOT NULL, + PRIMARY KEY (`test_old`,`other`), + UNIQUE KEY uk (`test_old`(100), `other`) +) ENGINE=InnoDB; + +select name, pos from information_schema.innodb_SYS_FIELDS where name in ('test_old', 'other', 'test_new'); +alter table `test` CHANGE COLUMN `test_old` `test_new` varchar(255) NOT NULL; +select name, pos from information_schema.innodb_SYS_FIELDS where name in ('test_old', 'other', 'test_new'); +drop table `test`; + --echo # --echo # BUG 20029625 - HANDLE_FATAL_SIGNAL (SIG=11) IN diff --git a/mysql-test/suite/rpl/r/rpl_idempotency.result b/mysql-test/suite/rpl/r/rpl_idempotency.result index 38b955d7697..03482e6fefb 100644 --- a/mysql-test/suite/rpl/r/rpl_idempotency.result +++ b/mysql-test/suite/rpl/r/rpl_idempotency.result @@ -67,6 +67,18 @@ a -3 1 include/check_slave_no_error.inc +drop table t1, t2; DROP TABLE t1, t2; +include/check_slave_no_error.inc +create database d; +create database e; +create database d; +create database if not exists e; +include/check_slave_no_error.inc +drop database d; +drop database e; +drop database d; +drop database if exists e; +include/check_slave_no_error.inc SET @@global.slave_exec_mode= @old_slave_exec_mode; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_idempotency.test b/mysql-test/suite/rpl/t/rpl_idempotency.test index 186c6260154..e801aac9b5e 100644 --- a/mysql-test/suite/rpl/t/rpl_idempotency.test +++ b/mysql-test/suite/rpl/t/rpl_idempotency.test @@ -75,9 +75,30 @@ SELECT * FROM t1 ORDER BY a; SELECT * FROM t2 ORDER BY a; --source include/check_slave_no_error.inc +connection slave; +drop table t1, t2; + connection master; DROP TABLE t1, t2; sync_slave_with_master; +--source include/check_slave_no_error.inc +create database d; +create database e; + +connection master; +create database d; +create database if not exists e; + +sync_slave_with_master; +--source include/check_slave_no_error.inc +drop database d; +drop database e; + +connection master; +drop database d; +drop database if exists e; +sync_slave_with_master; +--source include/check_slave_no_error.inc SET @@global.slave_exec_mode= @old_slave_exec_mode; diff --git a/mysql-test/t/func_group_innodb.test b/mysql-test/t/func_group_innodb.test index c62d3d08496..a65d2326d0f 100644 --- a/mysql-test/t/func_group_innodb.test +++ b/mysql-test/t/func_group_innodb.test @@ -192,4 +192,30 @@ EXPLAIN SELECT MIN(c) FROM t1 GROUP BY b; DROP TABLE t1; +--echo # +--echo # MDEV-17589: Stack-buffer-overflow with indexed varchar (utf8) field +--echo # + +set @save_innodb_file_format= @@innodb_file_format; +set @save_innodb_large_prefix= @@innodb_large_prefix; +set global innodb_file_format = BARRACUDA; +set global innodb_large_prefix = ON; + +CREATE TABLE t1 (v1 varchar(1020), v2 varchar(2), v3 varchar(2), + KEY k1 (v3,v2,v1)) ENGINE=InnoDB CHARACTER SET=utf8 ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES ('king', 'qu','qu'), ('bad','go','go'); +explain +SELECT MIN(t1.v1) FROM t1 where t1.v2='qu' and t1.v3='qu'; +SELECT MIN(t1.v1) FROM t1 where t1.v2='qu' and t1.v3='qu'; +drop table t1; + +CREATE TABLE t1 (v1 varchar(1024) CHARACTER SET utf8, KEY v1 (v1)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES ('king'), ('bad'); +explain +SELECT MIN(x.v1) FROM (SELECT t1.* FROM t1 WHERE t1.v1 >= 'p') x; +SELECT MIN(x.v1) FROM (SELECT t1.* FROM t1 WHERE t1.v1 >= 'p') x; +drop table t1; +set global innodb_file_format = @save_innodb_file_format; +set global innodb_large_prefix = @save_innodb_large_prefix; + --echo End of 5.5 tests diff --git a/mysql-test/t/innodb_ext_key.test b/mysql-test/t/innodb_ext_key.test index c8acfc5db2e..bec4462df08 100644 --- a/mysql-test/t/innodb_ext_key.test +++ b/mysql-test/t/innodb_ext_key.test @@ -726,6 +726,7 @@ if ($rows < 2) drop table t0,t1; --echo # +--echo # --echo # MDEV-10360: Extended keys: index properties depend on index order --echo # create table t0 (a int); diff --git a/mysql-test/t/range_innodb.test b/mysql-test/t/range_innodb.test index f76794814ef..605006587cc 100644 --- a/mysql-test/t/range_innodb.test +++ b/mysql-test/t/range_innodb.test @@ -45,3 +45,20 @@ explain select * from t0 left join t2 on t2.a <t0.a and t2.b between 50 and 250; drop table t0,t1,t2; +CREATE TABLE t1 ( + pk INT PRIMARY KEY, f1 INT, f2 CHAR(1), f3 CHAR(1), + KEY(f1), KEY(f2) +) ENGINE=InnoDB; + +INSERT INTO t1 VALUES +(1,4,'v',NULL),(2,6,'v',NULL),(3,7,'c',NULL),(4,1,'e',NULL),(5,0,'x',NULL), +(6,7,'i',NULL),(7,7,'e',NULL),(8,1,'p',NULL),(9,7,'s',NULL),(10,1,'j',NULL), +(11,5,'z',NULL),(12,2,'c',NULL),(13,0,'a',NULL),(14,1,'q',NULL),(15,8,'y',NULL), +(16,1,'m',NULL),(17,1,'r',NULL),(18,9,'v',NULL),(19,1,'n',NULL); + +CREATE TABLE t2 (f4 INT, f5 CHAR(1)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (4,'q'),(NULL,'j'); + +SELECT * FROM t1 AS t1_1, t1 AS t1_2, t2 +WHERE f5 = t1_2.f2 AND ( t1_1.f1 = 103 AND t1_1.f2 = 'o' OR t1_1.pk < f4 ); +drop table t1,t2; diff --git a/mysql-test/t/read_only.test b/mysql-test/t/read_only.test index 6b608dacf26..d9c4bacabcf 100644 --- a/mysql-test/t/read_only.test +++ b/mysql-test/t/read_only.test @@ -312,6 +312,23 @@ flush privileges; drop database mysqltest_db1; set global read_only= @start_read_only; +--echo # +--echo # MDEV-16987 - ALTER DATABASE possible in read-only mode +--echo # +CREATE USER user1@localhost; +GRANT ALTER ON test1.* TO user1@localhost; +CREATE DATABASE test1; +SET GLOBAL read_only=1; +change_user user1; +--error ER_OPTION_PREVENTS_STATEMENT +ALTER DATABASE test1 CHARACTER SET utf8; +change_user root; +SET GLOBAL read_only=0; +DROP DATABASE test1; +DROP USER user1@localhost; +USE test; + +--echo # End of 5.5 tests --echo # --echo # WL#5968 Implement START TRANSACTION READ (WRITE|ONLY); @@ -320,10 +337,6 @@ set global read_only= @start_read_only; --echo # --echo # Test interaction with read_only system variable. ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings - CREATE TABLE t1(a INT); INSERT INTO t1 VALUES (1), (2); @@ -373,3 +386,5 @@ DROP TABLE t1; # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc + +--echo # End of 10.0 tests diff --git a/sql/handler.h b/sql/handler.h index 42429e9dcbe..792cce281f6 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -382,6 +382,12 @@ enum enum_alter_inplace_result { #define HA_KEY_NULL_LENGTH 1 #define HA_KEY_BLOB_LENGTH 2 +/* Maximum length of any index lookup key, in bytes */ + +#define MAX_KEY_LENGTH (MAX_DATA_LENGTH_FOR_KEY \ + +(MAX_REF_PARTS \ + *(HA_KEY_NULL_LENGTH + HA_KEY_BLOB_LENGTH))) + #define HA_LEX_CREATE_TMP_TABLE 1 #define HA_CREATE_TMP_ALTER 8 @@ -3371,14 +3377,14 @@ public: uint max_key_parts() const { return MY_MIN(MAX_REF_PARTS, max_supported_key_parts()); } uint max_key_length() const - { return MY_MIN(MAX_KEY_LENGTH, max_supported_key_length()); } + { return MY_MIN(MAX_DATA_LENGTH_FOR_KEY, max_supported_key_length()); } uint max_key_part_length() const - { return MY_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); } + { return MY_MIN(MAX_DATA_LENGTH_FOR_KEY, max_supported_key_part_length()); } virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; } virtual uint max_supported_keys() const { return 0; } virtual uint max_supported_key_parts() const { return MAX_REF_PARTS; } - virtual uint max_supported_key_length() const { return MAX_KEY_LENGTH; } + virtual uint max_supported_key_length() const { return MAX_DATA_LENGTH_FOR_KEY; } virtual uint max_supported_key_part_length() const { return 255; } virtual uint min_record_length(uint options) const { return 1; } diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 41d74611abc..072f607fb51 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2734,10 +2734,6 @@ bool create_key_parts_for_pseudo_indexes(RANGE_OPT_PARAM *param, { Field **field_ptr; TABLE *table= param->table; - partition_info *part_info= NULL; - #ifdef WITH_PARTITION_STORAGE_ENGINE - part_info= table->part_info; - #endif uint parts= 0; for (field_ptr= table->field; *field_ptr; field_ptr++) diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 74a1c2a267a..c633ea708d0 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -1987,12 +1987,12 @@ bool partition_info::check_partition_field_length() for (i= 0; i < num_part_fields; i++) store_length+= get_partition_field_store_length(part_field_array[i]); - if (store_length > MAX_KEY_LENGTH) + if (store_length > MAX_DATA_LENGTH_FOR_KEY) DBUG_RETURN(TRUE); store_length= 0; for (i= 0; i < num_subpart_fields; i++) store_length+= get_partition_field_store_length(subpart_field_array[i]); - if (store_length > MAX_KEY_LENGTH) + if (store_length > MAX_DATA_LENGTH_FOR_KEY) DBUG_RETURN(TRUE); DBUG_RETURN(FALSE); } diff --git a/sql/sql_const.h b/sql/sql_const.h index 0cd214d8bc7..1d6549f777f 100644 --- a/sql/sql_const.h +++ b/sql/sql_const.h @@ -33,7 +33,17 @@ #define MAX_SYS_VAR_LENGTH 32 #define MAX_KEY MAX_INDEXES /* Max used keys */ #define MAX_REF_PARTS 32 /* Max parts used as ref */ -#define MAX_KEY_LENGTH 3072 /* max possible key */ + +/* + Maximum length of the data part of an index lookup key. + + The "data part" is defined as the value itself, not including the + NULL-indicator bytes or varchar length bytes ("the Extras"). We need this + value because there was a bug where length of the Extras were not counted. + + You probably need MAX_KEY_LENGTH, not this constant. +*/ +#define MAX_DATA_LENGTH_FOR_KEY 3072 #if SIZEOF_OFF_T > 4 #define MAX_REFLENGTH 8 /* Max length for record ref */ #else diff --git a/sql/sql_db.cc b/sql/sql_db.cc index f626b4e6112..d7ed82a2ef3 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -771,8 +771,7 @@ exit: } -int mysql_create_db(THD *thd, char *db, - const DDL_options_st &options, +int mysql_create_db(THD *thd, char *db, DDL_options_st options, const Schema_specification_st *create_info) { /* @@ -780,6 +779,9 @@ int mysql_create_db(THD *thd, char *db, to it, we need to use a copy to make execution prepared statement- safe. */ Schema_specification_st tmp(*create_info); + if (thd->slave_thread && + slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT) + options.add(DDL_options::OPT_IF_NOT_EXISTS); return mysql_create_db_internal(thd, db, options, &tmp, false); } @@ -1059,6 +1061,9 @@ exit: bool mysql_rm_db(THD *thd,char *db, bool if_exists) { + if (thd->slave_thread && + slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT) + if_exists= true; return mysql_rm_db_internal(thd, db, if_exists, false); } diff --git a/sql/sql_db.h b/sql/sql_db.h index b0d99cc1ba4..ed8417a7793 100644 --- a/sql/sql_db.h +++ b/sql/sql_db.h @@ -20,8 +20,7 @@ class THD; -int mysql_create_db(THD *thd, char *db, - const DDL_options_st &options, +int mysql_create_db(THD *thd, char *db, DDL_options_st options, const Schema_specification_st *create); bool mysql_alter_db(THD *thd, const char *db, const Schema_specification_st *create); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a73c3c22ba8..3f6ce8356ce 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1198,6 +1198,7 @@ static bool deny_updates_if_read_only_option(THD *thd, TABLE_LIST *all_tables) DBUG_RETURN(FALSE); if (lex->sql_command == SQLCOM_CREATE_DB || + lex->sql_command == SQLCOM_ALTER_DB || lex->sql_command == SQLCOM_DROP_DB) DBUG_RETURN(TRUE); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 62f40eeb99c..155e261ac34 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -19361,6 +19361,10 @@ test_if_quick_select(JOIN_TAB *tab) delete tab->select->quick; tab->select->quick=0; + + if (tab->table->file->inited != handler::NONE) + tab->table->file->ha_index_or_rnd_end(); + int res= tab->select->test_quick_select(tab->join->thd, tab->keys, (table_map) 0, HA_POS_ERROR, 0, FALSE, /*remove where parts*/FALSE); diff --git a/sql/table.cc b/sql/table.cc index e1edcc0b407..ca06eee077c 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1851,7 +1851,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, uint pk_part_length= key_first_info->key_part[i].store_length; if (keyinfo->ext_key_part_map & 1<<i) { - if (ext_key_length + pk_part_length > MAX_KEY_LENGTH) + if (ext_key_length + pk_part_length > MAX_DATA_LENGTH_FOR_KEY) { add_keyparts_for_this_key= i; break; @@ -1861,9 +1861,9 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, } } - if (add_keyparts_for_this_key < (keyinfo->ext_key_parts - - keyinfo->user_defined_key_parts)) - { + if (add_keyparts_for_this_key < keyinfo->ext_key_parts - + keyinfo->user_defined_key_parts) + { share->ext_key_parts-= keyinfo->ext_key_parts; key_part_map ext_key_part_map= keyinfo->ext_key_part_map; keyinfo->ext_key_parts= keyinfo->user_defined_key_parts; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 1bfeaaa4ece..6b40edef390 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -4650,36 +4650,40 @@ err_exit: index != NULL; index = dict_table_get_next_index(index)) { + bool has_prefixes = false; + for (size_t i = 0; i < dict_index_get_n_fields(index); i++) { + if (dict_index_get_nth_field(index, i)->prefix_len) { + has_prefixes = true; + break; + } + } + for (ulint i = 0; i < dict_index_get_n_fields(index); i++) { - if (my_strcasecmp( - system_charset_info, - dict_index_get_nth_field(index, i)->name, - from)) { + const dict_field_t* field + = dict_index_get_nth_field(index, i); + if (my_strcasecmp(system_charset_info, field->name, + from)) { continue; } info = pars_info_create(); + int pos = i; + if (has_prefixes) { + pos = (pos << 16) + field->prefix_len; + } + pars_info_add_ull_literal(info, "indexid", index->id); - pars_info_add_int4_literal(info, "nth", i); + pars_info_add_int4_literal(info, "nth", pos); 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" - - /* Try again, in case there is a prefix_len - encoded in SYS_FIELDS.POS */ - - "UPDATE SYS_FIELDS SET COL_NAME=:new\n" - "WHERE INDEX_ID=:indexid\n" - "AND POS>=65536*:nth AND POS<65536*(:nth+1);\n" - "END;\n", FALSE, trx); diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 6ec45c591eb..6ccedfd5343 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -4470,7 +4470,8 @@ do_drop: char msg_tablename[MAX_FULL_NAME_LEN + 1]; innobase_format_name( - msg_tablename, sizeof(tablename), + msg_tablename, + sizeof msg_tablename, tablename, FALSE); ib_logf(IB_LOG_LEVEL_INFO, diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc index 7ea30bee8ae..0f34dc5ab11 100644 --- a/storage/xtradb/handler/handler0alter.cc +++ b/storage/xtradb/handler/handler0alter.cc @@ -4666,36 +4666,40 @@ err_exit: index != NULL; index = dict_table_get_next_index(index)) { + bool has_prefixes = false; + for (size_t i = 0; i < dict_index_get_n_fields(index); i++) { + if (dict_index_get_nth_field(index, i)->prefix_len) { + has_prefixes = true; + break; + } + } + for (ulint i = 0; i < dict_index_get_n_fields(index); i++) { - if (my_strcasecmp( - system_charset_info, - dict_index_get_nth_field(index, i)->name, - from)) { + const dict_field_t* field + = dict_index_get_nth_field(index, i); + if (my_strcasecmp(system_charset_info, field->name, + from)) { continue; } info = pars_info_create(); + int pos = i; + if (has_prefixes) { + pos = (pos << 16) + field->prefix_len; + } + pars_info_add_ull_literal(info, "indexid", index->id); - pars_info_add_int4_literal(info, "nth", i); + pars_info_add_int4_literal(info, "nth", pos); 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" - - /* Try again, in case there is a prefix_len - encoded in SYS_FIELDS.POS */ - - "UPDATE SYS_FIELDS SET COL_NAME=:new\n" - "WHERE INDEX_ID=:indexid\n" - "AND POS>=65536*:nth AND POS<65536*(:nth+1);\n" - "END;\n", FALSE, trx); diff --git a/storage/xtradb/row/row0mysql.cc b/storage/xtradb/row/row0mysql.cc index a5381df1995..57d06e58943 100644 --- a/storage/xtradb/row/row0mysql.cc +++ b/storage/xtradb/row/row0mysql.cc @@ -4481,7 +4481,8 @@ do_drop: char msg_tablename[MAX_FULL_NAME_LEN + 1]; innobase_format_name( - msg_tablename, sizeof(tablename), + msg_tablename, + sizeof msg_tablename, tablename, FALSE); ib_logf(IB_LOG_LEVEL_INFO, diff --git a/unittest/mysys/lf-t.c b/unittest/mysys/lf-t.c index cb0c2853d13..80f58856940 100644 --- a/unittest/mysys/lf-t.c +++ b/unittest/mysys/lf-t.c @@ -48,9 +48,6 @@ pthread_handler_t test_lf_pinbox(void *arg) pins= lf_pinbox_get_pins(&lf_allocator.pinbox); } lf_pinbox_put_pins(pins); - pthread_mutex_lock(&mutex); - if (!--running_threads) pthread_cond_signal(&cond); - pthread_mutex_unlock(&mutex); if (with_my_thread_init) my_thread_end(); @@ -105,7 +102,6 @@ pthread_handler_t test_lf_alloc(void *arg) bad|= lf_allocator.mallocs - lf_alloc_pool_count(&lf_allocator); #endif } - if (!--running_threads) pthread_cond_signal(&cond); pthread_mutex_unlock(&mutex); if (with_my_thread_init) @@ -172,7 +168,6 @@ pthread_handler_t test_lf_hash(void *arg) lf_hash.size, inserts, scans); bad|= lf_hash.count; } - if (!--running_threads) pthread_cond_signal(&cond); pthread_mutex_unlock(&mutex); if (with_my_thread_init) my_thread_end(); diff --git a/unittest/mysys/my_atomic-t.c b/unittest/mysys/my_atomic-t.c index 0f21c33455e..3198da6836d 100644 --- a/unittest/mysys/my_atomic-t.c +++ b/unittest/mysys/my_atomic-t.c @@ -29,9 +29,6 @@ pthread_handler_t test_atomic_add(void *arg) my_atomic_add32(&bad, x); my_atomic_add32(&bad, -x); } - pthread_mutex_lock(&mutex); - if (!--running_threads) pthread_cond_signal(&cond); - pthread_mutex_unlock(&mutex); return 0; } @@ -47,13 +44,6 @@ pthread_handler_t test_atomic_add64(void *arg) my_atomic_add64(&a64, x); my_atomic_add64(&a64, -x); } - pthread_mutex_lock(&mutex); - if (!--running_threads) - { - bad= (a64 != 0); - pthread_cond_signal(&cond); - } - pthread_mutex_unlock(&mutex); return 0; } @@ -83,9 +73,6 @@ pthread_handler_t test_atomic_fas(void *arg) my_atomic_add32(&bad, -x); - pthread_mutex_lock(&mutex); - if (!--running_threads) pthread_cond_signal(&cond); - pthread_mutex_unlock(&mutex); return 0; } @@ -109,9 +96,6 @@ pthread_handler_t test_atomic_cas(void *arg) ok= my_atomic_cas32(&bad, &y, y-x); } while (!ok) ; } - pthread_mutex_lock(&mutex); - if (!--running_threads) pthread_cond_signal(&cond); - pthread_mutex_unlock(&mutex); return 0; } @@ -146,4 +130,5 @@ void do_tests() } a64=0; test_concurrently("my_atomic_add64", test_atomic_add64, THREADS, CYCLES); + bad= (a64 != 0); } diff --git a/unittest/mysys/thr_template.c b/unittest/mysys/thr_template.c index 38999022da0..de68aca6d36 100644 --- a/unittest/mysys/thr_template.c +++ b/unittest/mysys/thr_template.c @@ -20,35 +20,34 @@ #include <tap.h> volatile uint32 bad; -pthread_attr_t thr_attr; pthread_mutex_t mutex; -pthread_cond_t cond; -uint running_threads; void do_tests(); void test_concurrently(const char *test, pthread_handler handler, int n, int m) { - pthread_t t; + pthread_t *threads= malloc(n * sizeof(pthread_t)); + int i; ulonglong now= my_interval_timer(); + assert(threads); bad= 0; diag("Testing %s with %d threads, %d iterations... ", test, n, m); - for (running_threads= n ; n ; n--) + for (i= n; i; i--) { - if (pthread_create(&t, &thr_attr, handler, &m) != 0) + if (pthread_create(&threads[i], 0, handler, &m) != 0) { diag("Could not create thread"); abort(); } } - pthread_mutex_lock(&mutex); - while (running_threads) - pthread_cond_wait(&cond, &mutex); - pthread_mutex_unlock(&mutex); + + for (i= n; i; i--) + pthread_join(threads[i], 0); now= my_interval_timer() - now; + free(threads); ok(!bad, "tested %s in %g secs (%d)", test, ((double)now)/1e9, bad); } @@ -60,9 +59,6 @@ int main(int argc __attribute__((unused)), char **argv) DBUG_SET_INITIAL(argv[1]); pthread_mutex_init(&mutex, 0); - pthread_cond_init(&cond, 0); - pthread_attr_init(&thr_attr); - pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); #define CYCLES 3000 #define THREADS 30 @@ -71,16 +67,7 @@ int main(int argc __attribute__((unused)), char **argv) do_tests(); - /* - workaround until we know why it crashes randomly on some machine - (BUG#22320). - */ -#ifdef NOT_USED - sleep(2); -#endif pthread_mutex_destroy(&mutex); - pthread_cond_destroy(&cond); - pthread_attr_destroy(&thr_attr); my_end(0); return exit_status(); } diff --git a/unittest/mysys/waiting_threads-t.c b/unittest/mysys/waiting_threads-t.c index 56b2f967c00..ac481e0fe99 100644 --- a/unittest/mysys/waiting_threads-t.c +++ b/unittest/mysys/waiting_threads-t.c @@ -136,10 +136,8 @@ retry: pthread_mutex_unlock(&lock); pthread_mutex_unlock(& thds[id].lock); wt_thd_destroy(& thds[id].thd); - - if (!--running_threads) /* now, signal when everybody is done with deinit */ - pthread_cond_signal(&cond); pthread_mutex_unlock(&mutex); + DBUG_PRINT("wt", ("exiting")); my_thread_end(); return 0; |