From 50b9d0862d656b7b7019e5ef3602e2233d330401 Mon Sep 17 00:00:00 2001 From: Ingo Struewing Date: Mon, 26 Apr 2010 15:44:10 +0200 Subject: [PATCH 001/183] Bug#46339 - crash on REPAIR TABLE merge table USE_FRM REPAIR TABLE ... USE_FRM crashed debug servers. A wrong assert assumed that this operation would not be executed for MERGE tables. Removed the assert. --- mysql-test/r/merge.result | 41 ++++++++++++++++++++ mysql-test/t/merge.test | 78 +++++++++++++++++++++++++++++++++++++++ sql/sql_table.cc | 3 -- 3 files changed, 119 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index dbffbba1b8b..1fb074d38bf 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -2298,4 +2298,45 @@ t2 WHERE b SOUNDS LIKE e AND d = 1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables DROP TABLE t2, t1; +# +# Bug#46339 - crash on REPAIR TABLE merge table USE_FRM +# +DROP TABLE IF EXISTS m1, t1; +CREATE TABLE t1 (c1 INT) ENGINE=MYISAM; +CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1) INSERT_METHOD=LAST; +LOCK TABLE m1 READ; +REPAIR TABLE m1 USE_FRM; +Table Op Msg_type Msg_text +test.m1 repair note The storage engine for the table doesn't support repair +UNLOCK TABLES; +REPAIR TABLE m1 USE_FRM; +Table Op Msg_type Msg_text +test.m1 repair note The storage engine for the table doesn't support repair +DROP TABLE m1,t1; +CREATE TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1); +REPAIR TABLE m1 USE_FRM; +Table Op Msg_type Msg_text +test.m1 repair Error Can't open table +test.m1 repair error Corrupt +CREATE TABLE t1 (f1 BIGINT) ENGINE = MyISAM; +REPAIR TABLE m1 USE_FRM; +Table Op Msg_type Msg_text +test.m1 repair note The storage engine for the table doesn't support repair +REPAIR TABLE m1; +Table Op Msg_type Msg_text +test.m1 repair note The storage engine for the table doesn't support repair +DROP TABLE m1, t1; +CREATE TEMPORARY TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1); +REPAIR TABLE m1 USE_FRM; +Table Op Msg_type Msg_text +test.m1 repair Error Table 'test.m1' doesn't exist +test.m1 repair error Corrupt +CREATE TEMPORARY TABLE t1 (f1 BIGINT) ENGINE=MyISAM; +REPAIR TABLE m1 USE_FRM; +Table Op Msg_type Msg_text +m1 repair error Cannot repair temporary table from .frm file +REPAIR TABLE m1; +Table Op Msg_type Msg_text +test.m1 repair note The storage engine for the table doesn't support repair +DROP TABLE m1, t1; End of 5.1 tests diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 44b202fab97..f290803bbd2 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -1705,4 +1705,82 @@ t2 WHERE b SOUNDS LIKE e AND d = 1; DROP TABLE t2, t1; +--echo # +--echo # Bug#46339 - crash on REPAIR TABLE merge table USE_FRM +--echo # +--disable_warnings +DROP TABLE IF EXISTS m1, t1; +--enable_warnings +# +# Test derived from a proposal of Shane Bester. +# +CREATE TABLE t1 (c1 INT) ENGINE=MYISAM; +CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1) INSERT_METHOD=LAST; +# +# REPAIR ... USE_FRM with LOCK TABLES. +# +LOCK TABLE m1 READ; +REPAIR TABLE m1 USE_FRM; +UNLOCK TABLES; +# +# REPAIR ... USE_FRM without LOCK TABLES. +# +# This statement crashed the server (Bug#46339). +# +REPAIR TABLE m1 USE_FRM; +# +DROP TABLE m1,t1; +# +# Test derived from a proposal of Matthias Leich. +# +# Base table is missing. +# +CREATE TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1); +# +# This statement crashed the server (Bug#46339). +# +REPAIR TABLE m1 USE_FRM; +# +# Create base table. +# +CREATE TABLE t1 (f1 BIGINT) ENGINE = MyISAM; +# +# This statement crashed the server (Bug#46339). +# +REPAIR TABLE m1 USE_FRM; +# +# Normal repair as reference. +# +REPAIR TABLE m1; +# +# Cleanup. +# +DROP TABLE m1, t1; +# +# Same with temporary tables. +# +# Base table is missing. +# +CREATE TEMPORARY TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1); +# +# This statement crashed the server (Bug#46339). +# +REPAIR TABLE m1 USE_FRM; +# +# Create base table. +# +CREATE TEMPORARY TABLE t1 (f1 BIGINT) ENGINE=MyISAM; +# +# This statement crashed the server (Bug#46339). +# +REPAIR TABLE m1 USE_FRM; +# +# Normal repair as reference. +# +REPAIR TABLE m1; +# +# Cleanup. +# +DROP TABLE m1, t1; + --echo End of 5.1 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ad72cab664e..78128fae576 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4384,9 +4384,6 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list, pthread_mutex_unlock(&LOCK_open); } - /* A MERGE table must not come here. */ - DBUG_ASSERT(!table->child_l); - /* REPAIR TABLE ... USE_FRM for temporary tables makes little sense. */ From f4b088972aeb6432b65aefae56ba2ce53942bf8a Mon Sep 17 00:00:00 2001 From: Jimmy Yang Date: Sun, 1 Aug 2010 22:25:57 -0700 Subject: [PATCH 002/183] Fix Bug #55382 Assignment with SELECT expressions takes unexpected S locks in READ COMMITTED rb://410 Approved by Sunny Bains --- storage/innobase/handler/ha_innodb.cc | 9 +++++---- storage/innodb_plugin/ChangeLog | 7 +++++++ storage/innodb_plugin/handler/ha_innodb.cc | 9 +++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index d10fcb8d31e..f29dd3be990 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -7814,16 +7814,17 @@ ha_innobase::store_lock( && (lock_type == TL_READ || lock_type == TL_READ_NO_INSERT) && (sql_command == SQLCOM_INSERT_SELECT || sql_command == SQLCOM_UPDATE - || sql_command == SQLCOM_CREATE_TABLE)) { + || sql_command == SQLCOM_CREATE_TABLE + || sql_command == SQLCOM_SET_OPTION)) { /* If we either have innobase_locks_unsafe_for_binlog option set or this session is using READ COMMITTED isolation level and isolation level of the transaction is not set to serializable and MySQL is doing INSERT INTO...SELECT or UPDATE ... = (SELECT ...) or - CREATE ... SELECT... without FOR UPDATE or - IN SHARE MODE in select, then we use consistent - read for select. */ + CREATE ... SELECT... or SET ... = (SELECT ...) + without FOR UPDATE or IN SHARE MODE in select, + then we use consistent read for select. */ prebuilt->select_lock_type = LOCK_NONE; prebuilt->stored_select_lock_type = LOCK_NONE; diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index 3e802360d23..1f8491baa51 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,10 @@ +2010-08-01 The InnoDB Team + + * handler/ha_innodb.cc + Fix Bug #55382 Assignment with SELECT expressions takes unexpected + S locks in READ COMMITTED + + 2010-07-27 The InnoDB Team * include/mem0pool.h, mem/mem0mem.c, mem/mem0pool.c, srv/srv0start.c: diff --git a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc index e0a62ed3ac5..a70921806b4 100644 --- a/storage/innodb_plugin/handler/ha_innodb.cc +++ b/storage/innodb_plugin/handler/ha_innodb.cc @@ -9235,7 +9235,8 @@ ha_innobase::store_lock( && (sql_command == SQLCOM_INSERT_SELECT || sql_command == SQLCOM_REPLACE_SELECT || sql_command == SQLCOM_UPDATE - || sql_command == SQLCOM_CREATE_TABLE)) { + || sql_command == SQLCOM_CREATE_TABLE + || sql_command == SQLCOM_SET_OPTION)) { /* If we either have innobase_locks_unsafe_for_binlog option set or this session is using READ COMMITTED @@ -9243,9 +9244,9 @@ ha_innobase::store_lock( is not set to serializable and MySQL is doing INSERT INTO...SELECT or REPLACE INTO...SELECT or UPDATE ... = (SELECT ...) or CREATE ... - SELECT... without FOR UPDATE or IN SHARE - MODE in select, then we use consistent read - for select. */ + SELECT... or SET ... = (SELECT ...) without + FOR UPDATE or IN SHARE MODE in select, + then we use consistent read for select. */ prebuilt->select_lock_type = LOCK_NONE; prebuilt->stored_select_lock_type = LOCK_NONE; From a394519ef96008079049b8a1a3136600b5073ddc Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Tue, 3 Aug 2010 14:52:20 +0300 Subject: [PATCH 003/183] addendum to the fix for bug #54476: fixed a failing test case. --- mysql-test/t/func_gconcat.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 693fa7d1c89..54c7291bb5e 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -734,6 +734,9 @@ EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t1; +--echo End of 5.1 tests + + # # Bug#36785: Wrong error message when group_concat() exceeds max length # From 9a05541bf1034fc131dc51585cebf1a2e141289a Mon Sep 17 00:00:00 2001 From: "karen.langford@oracle.com" <> Date: Tue, 3 Aug 2010 18:57:39 +0200 Subject: [PATCH 004/183] Raise version number after cloning 5.1.50 --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index efd291f953c..3ec62b836f1 100644 --- a/configure.in +++ b/configure.in @@ -12,7 +12,7 @@ dnl dnl When changing the major version number please also check the switch dnl statement in mysqlbinlog::check_master_version(). You may also need dnl to update version.c in ndb. -AC_INIT([MySQL Server], [5.1.50], [], [mysql]) +AC_INIT([MySQL Server], [5.1.51], [], [mysql]) AC_CONFIG_SRCDIR([sql/mysqld.cc]) AC_CANONICAL_SYSTEM From e79a7e1b939b02cdeb63a81f9af6d299d8f05b27 Mon Sep 17 00:00:00 2001 From: Jimmy Yang Date: Tue, 3 Aug 2010 20:20:55 -0700 Subject: [PATCH 005/183] Backport "NULL pointer check for ut_free()" from mysql-trunk-innodb to mysql-5.1-innodb plugin to fix bug #55627 segv in ut_free pars_lexer_close innobase_shutdown innodb-use-sys-malloc=0. --- storage/innodb_plugin/ChangeLog | 7 ++++++- storage/innodb_plugin/include/ut0mem.h | 3 ++- storage/innodb_plugin/ut/ut0mem.c | 7 +++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index 1f8491baa51..9fe5c1e7ee6 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,10 +1,15 @@ +2010-08-03 The InnoDB Team + + * include/ut0mem.h, ut/ut0mem.c: + Fix Bug #55627 segv in ut_free pars_lexer_close innobase_shutdown + innodb-use-sys-malloc=0 + 2010-08-01 The InnoDB Team * handler/ha_innodb.cc Fix Bug #55382 Assignment with SELECT expressions takes unexpected S locks in READ COMMITTED - 2010-07-27 The InnoDB Team * include/mem0pool.h, mem/mem0mem.c, mem/mem0pool.c, srv/srv0start.c: diff --git a/storage/innodb_plugin/include/ut0mem.h b/storage/innodb_plugin/include/ut0mem.h index cf41cba4643..f14606be966 100644 --- a/storage/innodb_plugin/include/ut0mem.h +++ b/storage/innodb_plugin/include/ut0mem.h @@ -113,7 +113,8 @@ ut_test_malloc( ulint n); /*!< in: try to allocate this many bytes */ #endif /* !UNIV_HOTBACKUP */ /**********************************************************************//** -Frees a memory block allocated with ut_malloc. */ +Frees a memory block allocated with ut_malloc. Freeing a NULL pointer is +a nop. */ UNIV_INTERN void ut_free( diff --git a/storage/innodb_plugin/ut/ut0mem.c b/storage/innodb_plugin/ut/ut0mem.c index 35a325b9ccd..bf55e4273b6 100644 --- a/storage/innodb_plugin/ut/ut0mem.c +++ b/storage/innodb_plugin/ut/ut0mem.c @@ -290,7 +290,8 @@ ut_test_malloc( #endif /* !UNIV_HOTBACKUP */ /**********************************************************************//** -Frees a memory block allocated with ut_malloc. */ +Frees a memory block allocated with ut_malloc. Freeing a NULL pointer is +a nop. */ UNIV_INTERN void ut_free( @@ -300,7 +301,9 @@ ut_free( #ifndef UNIV_HOTBACKUP ut_mem_block_t* block; - if (UNIV_LIKELY(srv_use_sys_malloc)) { + if (ptr == NULL) { + return; + } else if (UNIV_LIKELY(srv_use_sys_malloc)) { free(ptr); return; } From d8f8b1cb0b0ca08c8ffbf95cb21fc508b95b5a84 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Wed, 4 Aug 2010 12:52:38 +0400 Subject: [PATCH 006/183] Fix default.conf. --- .bzr-mysql/default.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf index 41a3d479084..1b6d7676984 100644 --- a/.bzr-mysql/default.conf +++ b/.bzr-mysql/default.conf @@ -1,4 +1,4 @@ [MYSQL] post_commit_to = "dbg_mysql_security@sun.com" post_push_to = "dbg_mysql_security@sun.com" -tree_name = "mysql-trunk-security" +tree_name = "mysql-5.5-security" From 6fce5c4c771dba0845429cf967df80d49482c37c Mon Sep 17 00:00:00 2001 From: Jimmy Yang Date: Wed, 4 Aug 2010 03:11:33 -0700 Subject: [PATCH 007/183] Fix Bug #54582 stack overflow when opening many tables linked with foreign keys at once rb://391 approved by Heikki Z --- storage/innobase/dict/dict0load.c | 81 ++++++++++++++++++++-- storage/innobase/handler/ha_innodb.cc | 10 +++ storage/innobase/include/db0err.h | 3 + storage/innobase/include/dict0load.h | 2 + storage/innobase/include/dict0mem.h | 21 ++++++ storage/innobase/include/que0que.h | 3 + storage/innobase/row/row0mysql.c | 21 +++++- storage/innodb_plugin/ChangeLog | 8 +++ storage/innodb_plugin/dict/dict0load.c | 81 ++++++++++++++++++++-- storage/innodb_plugin/handler/ha_innodb.cc | 13 ++++ storage/innodb_plugin/include/db0err.h | 3 + storage/innodb_plugin/include/dict0load.h | 2 + storage/innodb_plugin/include/dict0mem.h | 21 ++++++ storage/innodb_plugin/include/que0que.h | 3 + storage/innodb_plugin/row/row0merge.c | 2 +- storage/innodb_plugin/row/row0mysql.c | 21 +++++- 16 files changed, 276 insertions(+), 19 deletions(-) diff --git a/storage/innobase/dict/dict0load.c b/storage/innobase/dict/dict0load.c index d5e7600f4d0..625956600c0 100644 --- a/storage/innobase/dict/dict0load.c +++ b/storage/innobase/dict/dict0load.c @@ -864,16 +864,27 @@ err_exit: err = dict_load_indexes(table, heap); + /* Initialize table foreign_child value. Its value could be + changed when dict_load_foreigns() is called below */ + table->fk_max_recusive_level = 0; + /* If the force recovery flag is set, we open the table irrespective of the error condition, since the user may want to dump data from the clustered index. However we load the foreign key information only if all indexes were loaded. */ if (err == DB_SUCCESS) { - err = dict_load_foreigns(table->name, TRUE); + err = dict_load_foreigns(table->name, TRUE, TRUE); + + if (err != DB_SUCCESS) { + dict_table_remove_from_cache(table); + table = NULL; + } } else if (!srv_force_recovery) { dict_table_remove_from_cache(table); table = NULL; } + + table->fk_max_recusive_level = 0; #if 0 if (err != DB_SUCCESS && table != NULL) { @@ -1095,8 +1106,12 @@ dict_load_foreign( /* out: DB_SUCCESS or error code */ const char* id, /* in: foreign constraint id as a null-terminated string */ - ibool check_charsets) + ibool check_charsets, /* in: TRUE=check charset compatibility */ + ibool check_recursive) + /* in: Whether to record the foreign table + parent count to avoid unlimited recursive + load of chained foreign tables */ { dict_foreign_t* foreign; dict_table_t* sys_foreign; @@ -1110,6 +1125,8 @@ dict_load_foreign( ulint len; ulint n_fields_and_type; mtr_t mtr; + dict_table_t* for_table; + dict_table_t* ref_table; ut_ad(mutex_own(&(dict_sys->mutex))); @@ -1194,11 +1211,54 @@ dict_load_foreign( dict_load_foreign_cols(id, foreign); - /* If the foreign table is not yet in the dictionary cache, we - have to load it so that we are able to make type comparisons - in the next function call. */ + ref_table = dict_table_check_if_in_cache_low( + foreign->referenced_table_name); - dict_table_get_low(foreign->foreign_table_name); + /* We could possibly wind up in a deep recursive calls if + we call dict_table_get_low() again here if there + is a chain of tables concatenated together with + foreign constraints. In such case, each table is + both a parent and child of the other tables, and + act as a "link" in such table chains. + To avoid such scenario, we would need to check the + number of ancesters the current table has. If that + exceeds DICT_FK_MAX_CHAIN_LEN, we will stop loading + the child table. + Foreign constraints are loaded in a Breath First fashion, + that is, the index on FOR_NAME is scanned first, and then + index on REF_NAME. So foreign constrains in which + current table is a child (foreign table) are loaded first, + and then those constraints where current table is a + parent (referenced) table. + Thus we could check the parent (ref_table) table's + reference count (fk_max_recusive_level) to know how deep the + recursive call is. If the parent table (ref_table) is already + loaded, and its fk_max_recusive_level is larger than + DICT_FK_MAX_CHAIN_LEN, we will stop the recursive loading + by skipping loading the child table. It will not affect foreign + constraint check for DMLs since child table will be loaded + at that time for the constraint check. */ + if (!ref_table + || ref_table->fk_max_recusive_level < DICT_FK_MAX_RECURSIVE_LOAD) { + + /* If the foreign table is not yet in the dictionary cache, we + have to load it so that we are able to make type comparisons + in the next function call. */ + + for_table = dict_table_get_low(foreign->foreign_table_name); + + if (for_table && ref_table && check_recursive) { + /* This is to record the longest chain of ancesters + this table has, if the parent has more ancesters + than this table has, record it after add 1 (for this + parent */ + if (ref_table->fk_max_recusive_level + >= for_table->fk_max_recusive_level) { + for_table->fk_max_recusive_level = + ref_table->fk_max_recusive_level + 1; + } + } + } /* Note that there may already be a foreign constraint object in the dictionary cache for this constraint: then the following @@ -1223,6 +1283,8 @@ dict_load_foreigns( /*===============*/ /* out: DB_SUCCESS or error code */ const char* table_name, /* in: table name */ + ibool check_recursive,/* in: Whether to check recursive + load of tables chained by FK */ ibool check_charsets) /* in: TRUE=check charset compatibility */ { @@ -1324,7 +1386,7 @@ loop: /* Load the foreign constraint definition to the dictionary cache */ - err = dict_load_foreign(id, check_charsets); + err = dict_load_foreign(id, check_charsets, check_recursive); if (err != DB_SUCCESS) { btr_pcur_close(&pcur); @@ -1352,6 +1414,11 @@ load_next_index: mtr_start(&mtr); + /* Switch to scan index on REF_NAME, fk_max_recusive_level + already been updated when scanning FOR_NAME index, no need to + update again */ + check_recursive = FALSE; + goto start_load; } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index d10fcb8d31e..930785d7dcd 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -763,6 +763,16 @@ convert_error_code_to_mysql( my_error(ER_QUERY_INTERRUPTED, MYF(0)); return(-1); + } else if (error == DB_FOREIGN_EXCEED_MAX_CASCADE) { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + HA_ERR_ROW_IS_REFERENCED, + "InnoDB: Cannot delete/update " + "rows with cascading foreign key " + "constraints that exceed max " + "depth of %d. Please " + "drop extra constraints and try " + "again", DICT_FK_MAX_RECURSIVE_LOAD); + return(-1); } else { return(-1); // Unknown error } diff --git a/storage/innobase/include/db0err.h b/storage/innobase/include/db0err.h index 2be6005622d..af3e78fe833 100644 --- a/storage/innobase/include/db0err.h +++ b/storage/innobase/include/db0err.h @@ -73,6 +73,9 @@ Created 5/24/1996 Heikki Tuuri a later version of the engine. */ #define DB_INTERRUPTED 49 /* the query has been interrupted with "KILL QUERY N;" */ +#define DB_FOREIGN_EXCEED_MAX_CASCADE 50/* Foreign key constraint related + cascading delete/update exceeds + maximum allowed depth */ /* The following are partial failure codes */ #define DB_FAIL 1000 diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h index 7e19c2eb3c0..eb6083e06f9 100644 --- a/storage/innobase/include/dict0load.h +++ b/storage/innobase/include/dict0load.h @@ -82,6 +82,8 @@ dict_load_foreigns( /*===============*/ /* out: DB_SUCCESS or error code */ const char* table_name, /* in: table name */ + ibool check_recursive,/* in: Whether to check recursive + load of tables chained by FK */ ibool check_charsets);/* in: TRUE=check charsets compatibility */ /************************************************************************ diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index ac28fdb1bae..2f2a7441478 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -283,6 +283,21 @@ a foreign key constraint is enforced, therefore RESTRICT just means no flag */ #define DICT_FOREIGN_ON_DELETE_NO_ACTION 16 #define DICT_FOREIGN_ON_UPDATE_NO_ACTION 32 +/** Tables could be chained together with Foreign key constraint. When +first load the parent table, we would load all of its descedents. +This could result in rescursive calls and out of stack error eventually. +DICT_FK_MAX_RECURSIVE_LOAD defines the maximum number of recursive loads, +when exceeded, the child table will not be loaded. It will be loaded when +the foreign constraint check needs to be run. */ +#define DICT_FK_MAX_RECURSIVE_LOAD 250 + +/** Similarly, when tables are chained together with foreign key constraints +with on cascading delete/update clause, delete from parent table could +result in recursive cascading calls. This defines the maximum number of +such cascading deletes/updates allowed. When exceeded, the delete from +parent table will fail, and user has to drop excessive foreign constraint +before proceeds. */ +#define FK_MAX_CASCADE_DEL 300 /* Data structure for a database table */ struct dict_table_struct{ @@ -339,6 +354,12 @@ struct dict_table_struct{ NOT allowed until this count gets to zero; MySQL does NOT itself check the number of open handles at drop */ + unsigned fk_max_recusive_level:8; + /*!< maximum recursive level we support when + loading tables chained together with FK + constraints. If exceeds this level, we will + stop loading child table into memory along with + its parent table */ ulint n_foreign_key_checks_running; /* count of how many foreign key check operations are currently being performed diff --git a/storage/innobase/include/que0que.h b/storage/innobase/include/que0que.h index 8fbf5330c89..71f4cfdfb8f 100644 --- a/storage/innobase/include/que0que.h +++ b/storage/innobase/include/que0que.h @@ -367,6 +367,9 @@ struct que_thr_struct{ thus far */ ulint lock_state; /* lock state of thread (table or row) */ + ulint fk_cascade_depth; /*!< maximum cascading call depth + supported for foreign key constraint + related delete/updates */ }; #define QUE_THR_MAGIC_N 8476583 diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index 4a834c4efc2..3b76ffa76f1 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -555,6 +555,12 @@ handle_new_error: "forcing-recovery.html" " for help.\n", stderr); + } else if (err == DB_FOREIGN_EXCEED_MAX_CASCADE) { + fprintf(stderr, "InnoDB: Cannot delete/update rows with" + " cascading foreign key constraints that exceed max" + " depth of %lu\n" + "Please drop excessive foreign constraints" + " and try again\n", (ulong) DICT_FK_MAX_RECURSIVE_LOAD); } else { fprintf(stderr, "InnoDB: unknown error code %lu\n", (ulong) err); @@ -1406,11 +1412,15 @@ row_update_for_mysql( run_again: thr->run_node = node; thr->prev_node = node; + thr->fk_cascade_depth = 0; row_upd_step(thr); err = trx->error_state; + /* Reset fk_cascade_depth back to 0 */ + thr->fk_cascade_depth = 0; + if (err != DB_SUCCESS) { que_thr_stop_for_mysql(thr); @@ -1597,6 +1607,12 @@ row_update_cascade_for_mysql( trx_t* trx; trx = thr_get_trx(thr); + + thr->fk_cascade_depth++; + + if (thr->fk_cascade_depth > FK_MAX_CASCADE_DEL) { + return (DB_FOREIGN_EXCEED_MAX_CASCADE); + } run_again: thr->run_node = node; thr->prev_node = node; @@ -2129,7 +2145,7 @@ row_table_add_foreign_constraints( if (err == DB_SUCCESS) { /* Check that also referencing constraints are ok */ - err = dict_load_foreigns(name, TRUE); + err = dict_load_foreigns(name, FALSE, TRUE); } if (err != DB_SUCCESS) { @@ -3878,7 +3894,8 @@ end: an ALTER, not in a RENAME. */ err = dict_load_foreigns( - new_name, old_is_tmp ? trx->check_foreigns : TRUE); + new_name, FALSE, + old_is_tmp ? trx->check_foreigns : TRUE); if (err != DB_SUCCESS) { ut_print_timestamp(stderr); diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index 3e802360d23..56729852a62 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,11 @@ +2010-08-03 The InnoDB Team + + * dict/dict0load.c, handler/ha_innodb.cc, include/db0err.h, + include/dict0load.h, include/dict0mem.h, include/que0que.h, + row/row0merge.c, row/row0mysql.c: + Fix Bug#54582 stack overflow when opening many tables linked + with foreign keys at once + 2010-07-27 The InnoDB Team * include/mem0pool.h, mem/mem0mem.c, mem/mem0pool.c, srv/srv0start.c: diff --git a/storage/innodb_plugin/dict/dict0load.c b/storage/innodb_plugin/dict/dict0load.c index 3c495d21786..3acc267308f 100644 --- a/storage/innodb_plugin/dict/dict0load.c +++ b/storage/innodb_plugin/dict/dict0load.c @@ -1009,16 +1009,27 @@ err_exit: err = dict_load_indexes(table, heap); + /* Initialize table foreign_child value. Its value could be + changed when dict_load_foreigns() is called below */ + table->fk_max_recusive_level = 0; + /* If the force recovery flag is set, we open the table irrespective of the error condition, since the user may want to dump data from the clustered index. However we load the foreign key information only if all indexes were loaded. */ if (err == DB_SUCCESS) { - err = dict_load_foreigns(table->name, TRUE); + err = dict_load_foreigns(table->name, TRUE, TRUE); + + if (err != DB_SUCCESS) { + dict_table_remove_from_cache(table); + table = NULL; + } } else if (!srv_force_recovery) { dict_table_remove_from_cache(table); table = NULL; } + + table->fk_max_recusive_level = 0; #if 0 if (err != DB_SUCCESS && table != NULL) { @@ -1241,8 +1252,12 @@ dict_load_foreign( /*==============*/ const char* id, /*!< in: foreign constraint id as a null-terminated string */ - ibool check_charsets) + ibool check_charsets, /*!< in: TRUE=check charset compatibility */ + ibool check_recursive) + /*!< in: Whether to record the foreign table + parent count to avoid unlimited recursive + load of chained foreign tables */ { dict_foreign_t* foreign; dict_table_t* sys_foreign; @@ -1256,6 +1271,8 @@ dict_load_foreign( ulint len; ulint n_fields_and_type; mtr_t mtr; + dict_table_t* for_table; + dict_table_t* ref_table; ut_ad(mutex_own(&(dict_sys->mutex))); @@ -1340,11 +1357,54 @@ dict_load_foreign( dict_load_foreign_cols(id, foreign); - /* If the foreign table is not yet in the dictionary cache, we - have to load it so that we are able to make type comparisons - in the next function call. */ + ref_table = dict_table_check_if_in_cache_low( + foreign->referenced_table_name); - dict_table_get_low(foreign->foreign_table_name); + /* We could possibly wind up in a deep recursive calls if + we call dict_table_get_low() again here if there + is a chain of tables concatenated together with + foreign constraints. In such case, each table is + both a parent and child of the other tables, and + act as a "link" in such table chains. + To avoid such scenario, we would need to check the + number of ancesters the current table has. If that + exceeds DICT_FK_MAX_CHAIN_LEN, we will stop loading + the child table. + Foreign constraints are loaded in a Breath First fashion, + that is, the index on FOR_NAME is scanned first, and then + index on REF_NAME. So foreign constrains in which + current table is a child (foreign table) are loaded first, + and then those constraints where current table is a + parent (referenced) table. + Thus we could check the parent (ref_table) table's + reference count (fk_max_recusive_level) to know how deep the + recursive call is. If the parent table (ref_table) is already + loaded, and its fk_max_recusive_level is larger than + DICT_FK_MAX_CHAIN_LEN, we will stop the recursive loading + by skipping loading the child table. It will not affect foreign + constraint check for DMLs since child table will be loaded + at that time for the constraint check. */ + if (!ref_table + || ref_table->fk_max_recusive_level < DICT_FK_MAX_RECURSIVE_LOAD) { + + /* If the foreign table is not yet in the dictionary cache, we + have to load it so that we are able to make type comparisons + in the next function call. */ + + for_table = dict_table_get_low(foreign->foreign_table_name); + + if (for_table && ref_table && check_recursive) { + /* This is to record the longest chain of ancesters + this table has, if the parent has more ancesters + than this table has, record it after add 1 (for this + parent */ + if (ref_table->fk_max_recusive_level + >= for_table->fk_max_recusive_level) { + for_table->fk_max_recusive_level = + ref_table->fk_max_recusive_level + 1; + } + } + } /* Note that there may already be a foreign constraint object in the dictionary cache for this constraint: then the following @@ -1369,6 +1429,8 @@ ulint dict_load_foreigns( /*===============*/ const char* table_name, /*!< in: table name */ + ibool check_recursive,/*!< in: Whether to check recursive + load of tables chained by FK */ ibool check_charsets) /*!< in: TRUE=check charset compatibility */ { @@ -1470,7 +1532,7 @@ loop: /* Load the foreign constraint definition to the dictionary cache */ - err = dict_load_foreign(id, check_charsets); + err = dict_load_foreign(id, check_charsets, check_recursive); if (err != DB_SUCCESS) { btr_pcur_close(&pcur); @@ -1498,6 +1560,11 @@ load_next_index: mtr_start(&mtr); + /* Switch to scan index on REF_NAME, fk_max_recusive_level + already been updated when scanning FOR_NAME index, no need to + update again */ + check_recursive = FALSE; + goto start_load; } diff --git a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc index e0a62ed3ac5..1cba1de1590 100644 --- a/storage/innodb_plugin/handler/ha_innodb.cc +++ b/storage/innodb_plugin/handler/ha_innodb.cc @@ -767,6 +767,19 @@ convert_error_code_to_mysql( case DB_INTERRUPTED: my_error(ER_QUERY_INTERRUPTED, MYF(0)); /* fall through */ + + case DB_FOREIGN_EXCEED_MAX_CASCADE: + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + HA_ERR_ROW_IS_REFERENCED, + "InnoDB: Cannot delete/update " + "rows with cascading foreign key " + "constraints that exceed max " + "depth of %d. Please " + "drop extra constraints and try " + "again", DICT_FK_MAX_RECURSIVE_LOAD); + + /* fall through */ + case DB_ERROR: default: return(-1); /* unspecified error */ diff --git a/storage/innodb_plugin/include/db0err.h b/storage/innodb_plugin/include/db0err.h index c841c2b4afe..c7fa6d2a444 100644 --- a/storage/innodb_plugin/include/db0err.h +++ b/storage/innodb_plugin/include/db0err.h @@ -94,6 +94,9 @@ enum db_err { DB_PRIMARY_KEY_IS_NULL, /* a column in the PRIMARY KEY was found to be NULL */ + DB_FOREIGN_EXCEED_MAX_CASCADE, /* Foreign key constraint related + cascading delete/update exceeds + maximum allowed depth */ /* The following are partial failure codes */ DB_FAIL = 1000, diff --git a/storage/innodb_plugin/include/dict0load.h b/storage/innodb_plugin/include/dict0load.h index 60b8c1fb632..f41882019d5 100644 --- a/storage/innodb_plugin/include/dict0load.h +++ b/storage/innodb_plugin/include/dict0load.h @@ -97,6 +97,8 @@ ulint dict_load_foreigns( /*===============*/ const char* table_name, /*!< in: table name */ + ibool check_recursive,/*!< in: Whether to check recursive + load of tables chained by FK */ ibool check_charsets);/*!< in: TRUE=check charsets compatibility */ /********************************************************************//** diff --git a/storage/innodb_plugin/include/dict0mem.h b/storage/innodb_plugin/include/dict0mem.h index 2fce1e00927..19782c2e76a 100644 --- a/storage/innodb_plugin/include/dict0mem.h +++ b/storage/innodb_plugin/include/dict0mem.h @@ -112,6 +112,21 @@ ROW_FORMAT=REDUNDANT. */ in table->flags. */ /* @} */ +/** Tables could be chained together with Foreign key constraint. When +first load the parent table, we would load all of its descedents. +This could result in rescursive calls and out of stack error eventually. +DICT_FK_MAX_RECURSIVE_LOAD defines the maximum number of recursive loads, +when exceeded, the child table will not be loaded. It will be loaded when +the foreign constraint check needs to be run. */ +#define DICT_FK_MAX_RECURSIVE_LOAD 250 + +/** Similarly, when tables are chained together with foreign key constraints +with on cascading delete/update clause, delete from parent table could +result in recursive cascading calls. This defines the maximum number of +such cascading deletes/updates allowed. When exceeded, the delete from +parent table will fail, and user has to drop excessive foreign constraint +before proceeds. */ +#define FK_MAX_CASCADE_DEL 300 /**********************************************************************//** Creates a table memory object. @@ -434,6 +449,12 @@ struct dict_table_struct{ NOT allowed until this count gets to zero; MySQL does NOT itself check the number of open handles at drop */ + unsigned fk_max_recusive_level:8; + /*!< maximum recursive level we support when + loading tables chained together with FK + constraints. If exceeds this level, we will + stop loading child table into memory along with + its parent table */ ulint n_foreign_key_checks_running; /*!< count of how many foreign key check operations are currently being performed diff --git a/storage/innodb_plugin/include/que0que.h b/storage/innodb_plugin/include/que0que.h index 39f8d07af89..84b83208416 100644 --- a/storage/innodb_plugin/include/que0que.h +++ b/storage/innodb_plugin/include/que0que.h @@ -381,6 +381,9 @@ struct que_thr_struct{ thus far */ ulint lock_state; /*!< lock state of thread (table or row) */ + ulint fk_cascade_depth; /*!< maximum cascading call depth + supported for foreign key constraint + related delete/updates */ }; #define QUE_THR_MAGIC_N 8476583 diff --git a/storage/innodb_plugin/row/row0merge.c b/storage/innodb_plugin/row/row0merge.c index 56a68b58225..05d77ad7f19 100644 --- a/storage/innodb_plugin/row/row0merge.c +++ b/storage/innodb_plugin/row/row0merge.c @@ -2395,7 +2395,7 @@ row_merge_rename_tables( goto err_exit; } - err = dict_load_foreigns(old_name, TRUE); + err = dict_load_foreigns(old_name, FALSE, TRUE); if (err != DB_SUCCESS) { err_exit: diff --git a/storage/innodb_plugin/row/row0mysql.c b/storage/innodb_plugin/row/row0mysql.c index feeb7fc80b7..a582de3e583 100644 --- a/storage/innodb_plugin/row/row0mysql.c +++ b/storage/innodb_plugin/row/row0mysql.c @@ -576,6 +576,13 @@ handle_new_error: "InnoDB: " REFMAN "forcing-recovery.html" " for help.\n", stderr); break; + case DB_FOREIGN_EXCEED_MAX_CASCADE: + fprintf(stderr, "InnoDB: Cannot delete/update rows with" + " cascading foreign key constraints that exceed max" + " depth of %lu\n" + "Please drop excessive foreign constraints" + " and try again\n", (ulong) DICT_FK_MAX_RECURSIVE_LOAD); + break; default: fprintf(stderr, "InnoDB: unknown error code %lu\n", (ulong) err); @@ -1381,11 +1388,15 @@ row_update_for_mysql( run_again: thr->run_node = node; thr->prev_node = node; + thr->fk_cascade_depth = 0; row_upd_step(thr); err = trx->error_state; + /* Reset fk_cascade_depth back to 0 */ + thr->fk_cascade_depth = 0; + if (err != DB_SUCCESS) { que_thr_stop_for_mysql(thr); @@ -1576,6 +1587,12 @@ row_update_cascade_for_mysql( trx_t* trx; trx = thr_get_trx(thr); + + thr->fk_cascade_depth++; + + if (thr->fk_cascade_depth > FK_MAX_CASCADE_DEL) { + return (DB_FOREIGN_EXCEED_MAX_CASCADE); + } run_again: thr->run_node = node; thr->prev_node = node; @@ -2056,7 +2073,7 @@ row_table_add_foreign_constraints( name, reject_fks); if (err == DB_SUCCESS) { /* Check that also referencing constraints are ok */ - err = dict_load_foreigns(name, TRUE); + err = dict_load_foreigns(name, FALSE, TRUE); } if (err != DB_SUCCESS) { @@ -3915,7 +3932,7 @@ end: an ALTER, not in a RENAME. */ err = dict_load_foreigns( - new_name, !old_is_tmp || trx->check_foreigns); + new_name, FALSE, !old_is_tmp || trx->check_foreigns); if (err != DB_SUCCESS) { ut_print_timestamp(stderr); From f4e68824c83c3e3d38597df393a33e1fb0a9d2a4 Mon Sep 17 00:00:00 2001 From: Jimmy Yang Date: Wed, 4 Aug 2010 03:37:44 -0700 Subject: [PATCH 008/183] Fix bug #54678, InnoDB, TRUNCATE, ALTER, I_S SELECT, crash or deadlock rb://399 approved by Sunny Bains --- storage/innodb_plugin/ChangeLog | 5 +++ storage/innodb_plugin/include/dict0dict.h | 16 +++++++++ storage/innodb_plugin/include/dict0dict.ic | 42 ++++++++++++++++++++++ storage/innodb_plugin/row/row0mysql.c | 14 ++++++++ 4 files changed, 77 insertions(+) diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index 56729852a62..ce625a93871 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,8 @@ +2010-08-03 The InnoDB Team + + * include/dict0dict.h, include/dict0dict.ic, row/row0mysql.c: + Fix bug #54678, InnoDB, TRUNCATE, ALTER, I_S SELECT, crash or deadlock + 2010-08-03 The InnoDB Team * dict/dict0load.c, handler/ha_innodb.cc, include/db0err.h, diff --git a/storage/innodb_plugin/include/dict0dict.h b/storage/innodb_plugin/include/dict0dict.h index 3a1bee4cd89..5ffa59538c8 100644 --- a/storage/innodb_plugin/include/dict0dict.h +++ b/storage/innodb_plugin/include/dict0dict.h @@ -680,6 +680,22 @@ ulint dict_table_zip_size( /*================*/ const dict_table_t* table); /*!< in: table */ +/*********************************************************************//** +Obtain exclusive locks on all index trees of the table. This is to prevent +accessing index trees while InnoDB is updating internal metadata for +operations such as truncate tables. */ +UNIV_INLINE +void +dict_table_x_lock_indexes( +/*======================*/ + dict_table_t* table); /*!< in: table */ +/*********************************************************************//** +Release the exclusive locks on all index tree. */ +UNIV_INLINE +void +dict_table_x_unlock_indexes( +/*========================*/ + dict_table_t* table); /*!< in: table */ /********************************************************************//** Checks if a column is in the ordering columns of the clustered index of a table. Column prefixes are treated like whole columns. diff --git a/storage/innodb_plugin/include/dict0dict.ic b/storage/innodb_plugin/include/dict0dict.ic index 46e78df8272..1704e9c2d71 100644 --- a/storage/innodb_plugin/include/dict0dict.ic +++ b/storage/innodb_plugin/include/dict0dict.ic @@ -452,6 +452,48 @@ dict_table_zip_size( return(dict_table_flags_to_zip_size(table->flags)); } +/*********************************************************************//** +Obtain exclusive locks on all index trees of the table. This is to prevent +accessing index trees while InnoDB is updating internal metadata for +operations such as truncate tables. */ +UNIV_INLINE +void +dict_table_x_lock_indexes( +/*======================*/ + dict_table_t* table) /*!< in: table */ +{ + dict_index_t* index; + + ut_a(table); + ut_ad(mutex_own(&(dict_sys->mutex))); + + /* Loop through each index of the table and lock them */ + for (index = dict_table_get_first_index(table); + index != NULL; + index = dict_table_get_next_index(index)) { + rw_lock_x_lock(dict_index_get_lock(index)); + } +} + +/*********************************************************************//** +Release the exclusive locks on all index tree. */ +UNIV_INLINE +void +dict_table_x_unlock_indexes( +/*========================*/ + dict_table_t* table) /*!< in: table */ +{ + dict_index_t* index; + + ut_a(table); + ut_ad(mutex_own(&(dict_sys->mutex))); + + for (index = dict_table_get_first_index(table); + index != NULL; + index = dict_table_get_next_index(index)) { + rw_lock_x_unlock(dict_index_get_lock(index)); + } +} /********************************************************************//** Gets the number of fields in the internal representation of an index, including fields added by the dictionary system. diff --git a/storage/innodb_plugin/row/row0mysql.c b/storage/innodb_plugin/row/row0mysql.c index a582de3e583..9d7cb976caf 100644 --- a/storage/innodb_plugin/row/row0mysql.c +++ b/storage/innodb_plugin/row/row0mysql.c @@ -2766,6 +2766,15 @@ row_truncate_table_for_mysql( trx->table_id = table->id; + /* Lock all index trees for this table, as we will + truncate the table/index and possibly change their metadata. + All DML/DDL are blocked by table level lock, with + a few exceptions such as queries into information schema + about the table, MySQL could try to access index stats + for this kind of query, we need to use index locks to + sync up */ + dict_table_x_lock_indexes(table); + if (table->space && !table->dir_path_of_temp_table) { /* Discard and create the single-table tablespace. */ ulint space = table->space; @@ -2782,6 +2791,7 @@ row_truncate_table_for_mysql( || fil_create_new_single_table_tablespace( space, table->name, FALSE, flags, FIL_IBD_FILE_INITIAL_SIZE) != DB_SUCCESS) { + dict_table_x_unlock_indexes(table); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: TRUNCATE TABLE %s failed to" @@ -2885,6 +2895,10 @@ next_rec: mem_heap_free(heap); + /* Done with index truncation, release index tree locks, + subsequent work relates to table level metadata change */ + dict_table_x_unlock_indexes(table); + dict_hdr_get_new_id(&new_id, NULL, NULL); info = pars_info_create(); From e19a494287037b24b272b0a88cb48baf80a1df09 Mon Sep 17 00:00:00 2001 From: Sunny Bains Date: Thu, 5 Aug 2010 19:18:17 +1000 Subject: [PATCH 009/183] Fix bug# 55543 - InnoDB Plugin: Signal 6: Assertion failure in file fil/fil0fil.c line 4306 The bug is due to a double delete of a BLOB, once via: rollback -> btr_cur_pessimistic_delete() and the second time via purge. The bug is in row_upd_clust_rec_by_insert(). There we relinquish ownership of the non-updated BLOB columns in btr_cur_mark_extern_inherited_fields() before building the row entry that will be inserted and whose contents will be logged in the UNDO log. However, we don't set the BLOB column later to INHERITED so that a possible rollback will not free the original row's non-updated BLOB entries. This is because the condition that checks for that is in : if (node->upd_ext) {}. node->upd_ext is non-NULL only if a BLOB column was updated and that column is part of some key ordering (see row_upd_replace()). This results in the non-update BLOB columns being deleted during a rollback and subsequently by purge again. rb://413 --- storage/innodb_plugin/btr/btr0cur.c | 12 +++++++++--- storage/innodb_plugin/include/btr0cur.h | 5 +++-- storage/innodb_plugin/row/row0upd.c | 12 +++++++----- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0cur.c index 7fa7d42320a..8db12a0bbb8 100644 --- a/storage/innodb_plugin/btr/btr0cur.c +++ b/storage/innodb_plugin/btr/btr0cur.c @@ -3484,9 +3484,10 @@ btr_cur_set_ownership_of_extern_field( Marks not updated extern fields as not-owned by this record. The ownership is transferred to the updated record which is inserted elsewhere in the index tree. In purge only the owner of externally stored field is allowed -to free the field. */ +to free the field. +@return TRUE if BLOB ownership was transferred */ UNIV_INTERN -void +ibool btr_cur_mark_extern_inherited_fields( /*=================================*/ page_zip_des_t* page_zip,/*!< in/out: compressed page whose uncompressed @@ -3500,13 +3501,14 @@ btr_cur_mark_extern_inherited_fields( ulint n; ulint j; ulint i; + ibool change_ownership = FALSE; ut_ad(rec_offs_validate(rec, NULL, offsets)); ut_ad(!rec_offs_comp(offsets) || !rec_get_node_ptr_flag(rec)); if (!rec_offs_any_extern(offsets)) { - return; + return(FALSE); } n = rec_offs_n_fields(offsets); @@ -3529,10 +3531,14 @@ btr_cur_mark_extern_inherited_fields( btr_cur_set_ownership_of_extern_field( page_zip, rec, index, offsets, i, FALSE, mtr); + + change_ownership = TRUE; updated: ; } } + + return(change_ownership); } /*******************************************************************//** diff --git a/storage/innodb_plugin/include/btr0cur.h b/storage/innodb_plugin/include/btr0cur.h index 7dc2eb63cf5..e151fdcb563 100644 --- a/storage/innodb_plugin/include/btr0cur.h +++ b/storage/innodb_plugin/include/btr0cur.h @@ -468,9 +468,10 @@ btr_estimate_number_of_different_key_vals( Marks not updated extern fields as not-owned by this record. The ownership is transferred to the updated record which is inserted elsewhere in the index tree. In purge only the owner of externally stored field is allowed -to free the field. */ +to free the field. +@return TRUE if BLOB ownership was transferred */ UNIV_INTERN -void +ibool btr_cur_mark_extern_inherited_fields( /*=================================*/ page_zip_des_t* page_zip,/*!< in/out: compressed page whose uncompressed diff --git a/storage/innodb_plugin/row/row0upd.c b/storage/innodb_plugin/row/row0upd.c index 397b117c067..04c3139fcc7 100644 --- a/storage/innodb_plugin/row/row0upd.c +++ b/storage/innodb_plugin/row/row0upd.c @@ -1598,6 +1598,7 @@ row_upd_clust_rec_by_insert( dict_table_t* table; dtuple_t* entry; ulint err; + ibool change_ownership = FALSE; ut_ad(node); ut_ad(dict_index_is_clust(index)); @@ -1630,9 +1631,9 @@ row_upd_clust_rec_by_insert( index = dict_table_get_first_index(table); offsets = rec_get_offsets(rec, index, offsets_, ULINT_UNDEFINED, &heap); - btr_cur_mark_extern_inherited_fields( - btr_cur_get_page_zip(btr_cur), - rec, index, offsets, node->update, mtr); + change_ownership = btr_cur_mark_extern_inherited_fields( + btr_cur_get_page_zip(btr_cur), rec, index, offsets, + node->update, mtr); if (check_ref) { /* NOTE that the following call loses the position of pcur ! */ @@ -1661,10 +1662,11 @@ row_upd_clust_rec_by_insert( row_upd_index_entry_sys_field(entry, index, DATA_TRX_ID, trx->id); - if (node->upd_ext) { + if (change_ownership) { /* If we return from a lock wait, for example, we may have extern fields marked as not-owned in entry (marked in the - if-branch above). We must unmark them. */ + if-branch above). We must unmark them, take the ownership + back. */ btr_cur_unmark_dtuple_extern_fields(entry); From 6c0f9301ea434cce4fe2df0ad36c26694375b997 Mon Sep 17 00:00:00 2001 From: Sunny Bains Date: Thu, 5 Aug 2010 19:24:34 +1000 Subject: [PATCH 010/183] Fix Bug #55277 - Failing assertion: auto_inc > 0 Handle overflow when reading value from SELECT MAX(C) FROM T; Call ha_innobase::info() after initializing the autoinc value in ha_innobase::open(). Fix for both the builtin and plugin. rb://402 --- .../suite/innodb/r/innodb-autoinc.result | 13 ++++++++++++ mysql-test/suite/innodb/t/innodb-autoinc.test | 12 +++++++++++ storage/innobase/handler/ha_innodb.cc | 21 ++++++++++++------- storage/innodb_plugin/handler/ha_innodb.cc | 21 ++++++++++++------- 4 files changed, 53 insertions(+), 14 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-autoinc.result b/mysql-test/suite/innodb/r/innodb-autoinc.result index a36b3a1a865..350c7ebd541 100644 --- a/mysql-test/suite/innodb/r/innodb-autoinc.result +++ b/mysql-test/suite/innodb/r/innodb-autoinc.result @@ -1244,3 +1244,16 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`c1`) ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 DROP TABLE t1; +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1(c1 BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (18446744073709551615); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB AUTO_INCREMENT=18446744073709551615 DEFAULT CHARSET=latin1 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb-autoinc.test b/mysql-test/suite/innodb/t/innodb-autoinc.test index ef0359b78b0..10602499222 100644 --- a/mysql-test/suite/innodb/t/innodb-autoinc.test +++ b/mysql-test/suite/innodb/t/innodb-autoinc.test @@ -662,3 +662,15 @@ INSERT INTO t1 VALUES (1), (2), (-685113344), (NULL); SELECT * FROM t1; SHOW CREATE TABLE t1; DROP TABLE t1; + +## +# 55277: Failing assertion: auto_inc > 0 +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(c1 BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (18446744073709551615); +# Restart the server +-- source include/restart_mysqld.inc +SHOW CREATE TABLE t1; +DROP TABLE t1; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 930785d7dcd..300d9743234 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2720,12 +2720,19 @@ ha_innobase::innobase_initialize_autoinc() err = row_search_max_autoinc(index, col_name, &read_auto_inc); switch (err) { - case DB_SUCCESS: - /* At the this stage we do not know the increment - or the offset, so use a default increment of 1. */ - auto_inc = read_auto_inc + 1; - break; + case DB_SUCCESS: { + ulonglong col_max_value; + col_max_value = innobase_get_int_col_max_value(field); + + /* At the this stage we do not know the increment + nor the offset, so use a default increment of 1. */ + + auto_inc = innobase_next_autoinc( + read_auto_inc, 1, 1, col_max_value); + + break; + } case DB_RECORD_NOT_FOUND: ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: MySQL and InnoDB data " @@ -2951,8 +2958,6 @@ retry: /* Init table lock structure */ thr_lock_data_init(&share->lock,&lock,(void*) 0); - info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST); - /* Only if the table has an AUTOINC column. */ if (prebuilt->table != NULL && table->found_next_number_field != NULL) { dict_table_autoinc_lock(prebuilt->table); @@ -2969,6 +2974,8 @@ retry: dict_table_autoinc_unlock(prebuilt->table); } + info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST); + DBUG_RETURN(0); } diff --git a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc index 1cba1de1590..69ca4a5051e 100644 --- a/storage/innodb_plugin/handler/ha_innodb.cc +++ b/storage/innodb_plugin/handler/ha_innodb.cc @@ -3361,12 +3361,19 @@ ha_innobase::innobase_initialize_autoinc() err = row_search_max_autoinc(index, col_name, &read_auto_inc); switch (err) { - case DB_SUCCESS: - /* At the this stage we do not know the increment - or the offset, so use a default increment of 1. */ - auto_inc = read_auto_inc + 1; - break; + case DB_SUCCESS: { + ulonglong col_max_value; + col_max_value = innobase_get_int_col_max_value(field); + + /* At the this stage we do not know the increment + nor the offset, so use a default increment of 1. */ + + auto_inc = innobase_next_autoinc( + read_auto_inc, 1, 1, col_max_value); + + break; + } case DB_RECORD_NOT_FOUND: ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: MySQL and InnoDB data " @@ -3661,8 +3668,6 @@ retry: dict_table_get_format(prebuilt->table)); } - info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST); - /* Only if the table has an AUTOINC column. */ if (prebuilt->table != NULL && table->found_next_number_field != NULL) { dict_table_autoinc_lock(prebuilt->table); @@ -3679,6 +3684,8 @@ retry: dict_table_autoinc_unlock(prebuilt->table); } + info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST); + DBUG_RETURN(0); } From 372999ed01237c623630063e5030d8b7948170c9 Mon Sep 17 00:00:00 2001 From: Inaam Rana Date: Thu, 5 Aug 2010 11:34:44 -0400 Subject: [PATCH 011/183] Backport of revno 3148 mysql-innodb-trunk Currently we do a full validation of AHI whenever check tables is called on any table. This patch fixes this by only doing this full check in debug versions. bug#55716 rb://423 approved by: Marko --- storage/innodb_plugin/btr/btr0sea.c | 2 ++ storage/innodb_plugin/ha/ha0ha.c | 2 ++ storage/innodb_plugin/include/btr0sea.h | 4 ++++ storage/innodb_plugin/include/ha0ha.h | 2 ++ 4 files changed, 10 insertions(+) diff --git a/storage/innodb_plugin/btr/btr0sea.c b/storage/innodb_plugin/btr/btr0sea.c index ac7248fef20..f3ffe07a951 100644 --- a/storage/innodb_plugin/btr/btr0sea.c +++ b/storage/innodb_plugin/btr/btr0sea.c @@ -1734,6 +1734,7 @@ function_exit: } } +#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG /********************************************************************//** Validates the search system. @return TRUE if ok */ @@ -1897,3 +1898,4 @@ btr_search_validate(void) return(ok); } +#endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */ diff --git a/storage/innodb_plugin/ha/ha0ha.c b/storage/innodb_plugin/ha/ha0ha.c index f9e798012f8..7f11917de0a 100644 --- a/storage/innodb_plugin/ha/ha0ha.c +++ b/storage/innodb_plugin/ha/ha0ha.c @@ -354,6 +354,7 @@ ha_remove_all_nodes_to_page( #endif } +#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG /*************************************************************//** Validates a given range of the cells in hash table. @return TRUE if ok */ @@ -400,6 +401,7 @@ ha_validate( return(ok); } +#endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */ /*************************************************************//** Prints info of a hash table. */ diff --git a/storage/innodb_plugin/include/btr0sea.h b/storage/innodb_plugin/include/btr0sea.h index 20a2be7f877..6493689a969 100644 --- a/storage/innodb_plugin/include/btr0sea.h +++ b/storage/innodb_plugin/include/btr0sea.h @@ -180,6 +180,7 @@ btr_search_update_hash_on_delete( btr_cur_t* cursor);/*!< in: cursor which was positioned on the record to delete using btr_cur_search_..., the record is not yet deleted */ +#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG /********************************************************************//** Validates the search system. @return TRUE if ok */ @@ -187,6 +188,9 @@ UNIV_INTERN ibool btr_search_validate(void); /*======================*/ +#else +# define btr_search_validate() TRUE +#endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */ /** Flag: has the search system been enabled? Protected by btr_search_latch and btr_search_enabled_mutex. */ diff --git a/storage/innodb_plugin/include/ha0ha.h b/storage/innodb_plugin/include/ha0ha.h index 1ffbd3440aa..3299000bf3c 100644 --- a/storage/innodb_plugin/include/ha0ha.h +++ b/storage/innodb_plugin/include/ha0ha.h @@ -186,6 +186,7 @@ ha_remove_all_nodes_to_page( hash_table_t* table, /*!< in: hash table */ ulint fold, /*!< in: fold value */ const page_t* page); /*!< in: buffer page */ +#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG /*************************************************************//** Validates a given range of the cells in hash table. @return TRUE if ok */ @@ -196,6 +197,7 @@ ha_validate( hash_table_t* table, /*!< in: hash table */ ulint start_index, /*!< in: start index */ ulint end_index); /*!< in: end index */ +#endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */ /*************************************************************//** Prints info of a hash table. */ UNIV_INTERN From ff8cf2e97413d45eb719743fc14e6e9d8e503663 Mon Sep 17 00:00:00 2001 From: Jimmy Yang Date: Fri, 6 Aug 2010 02:49:22 -0700 Subject: [PATCH 012/183] Address bug #55465 ERROR 1280 (42000): Incorrect index name '', adding a couple FK related messages. rb://409 approved by Sunny Bains --- storage/innobase/dict/dict0dict.c | 4 ++-- storage/innobase/handler/ha_innodb.cc | 26 ++++++++++++++++++++++++-- storage/innobase/include/db0err.h | 6 ++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c index d2b59469cdc..9f9c4da46f4 100644 --- a/storage/innobase/dict/dict0dict.c +++ b/storage/innobase/dict/dict0dict.c @@ -2140,7 +2140,7 @@ dict_foreign_add_to_cache( mem_heap_free(foreign->heap); } - return(DB_CANNOT_ADD_CONSTRAINT); + return(DB_FOREIGN_NO_INDEX); } for_in_cache->referenced_table = ref_table; @@ -2184,7 +2184,7 @@ dict_foreign_add_to_cache( mem_heap_free(foreign->heap); } - return(DB_CANNOT_ADD_CONSTRAINT); + return(DB_REFERENCING_NO_INDEX); } for_in_cache->foreign_table = for_table; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index f29dd3be990..991b3a394d7 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -707,7 +707,9 @@ convert_error_code_to_mysql( return(HA_ERR_ROW_IS_REFERENCED); - } else if (error == (int) DB_CANNOT_ADD_CONSTRAINT) { + } else if (error == (int) DB_CANNOT_ADD_CONSTRAINT + || error == (int) DB_FOREIGN_NO_INDEX + || error == (int) DB_REFERENCING_NO_INDEX) { return(HA_ERR_CANNOT_ADD_FOREIGN); @@ -6099,6 +6101,8 @@ ha_innobase::rename_table( innobase_commit_low(trx); trx_free_for_mysql(trx); + switch (error) { + case DB_DUPLICATE_KEY: /* Add a special case to handle the Duplicated Key error and return DB_ERROR instead. This is to avoid a possible SIGSEGV error from mysql error @@ -6111,10 +6115,28 @@ ha_innobase::rename_table( the dup key error here is due to an existing table whose name is the one we are trying to rename to) and return the generic error code. */ - if (error == (int) DB_DUPLICATE_KEY) { my_error(ER_TABLE_EXISTS_ERROR, MYF(0), to); error = DB_ERROR; + break; + case DB_FOREIGN_NO_INDEX: + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + HA_ERR_CANNOT_ADD_FOREIGN, + "Alter or rename of table '%s' failed" + " because the new table is a child table" + " in a FK relationship and it does not" + " have an index that contains foreign" + " keys as its prefix columns.", norm_to); + break; + case DB_REFERENCING_NO_INDEX: + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + HA_ERR_CANNOT_ADD_FOREIGN, + "Alter or rename of table '%s' failed" + " because the new table is a parent table" + " in a FK relationship and it does not" + " have an index that contains foreign" + " keys as its prefix columns.", norm_to); + break; } error = convert_error_code_to_mysql(error, NULL); diff --git a/storage/innobase/include/db0err.h b/storage/innobase/include/db0err.h index 2be6005622d..cc6b0745b97 100644 --- a/storage/innobase/include/db0err.h +++ b/storage/innobase/include/db0err.h @@ -73,6 +73,12 @@ Created 5/24/1996 Heikki Tuuri a later version of the engine. */ #define DB_INTERRUPTED 49 /* the query has been interrupted with "KILL QUERY N;" */ +#define DB_FOREIGN_NO_INDEX 50 /* the child (foreign) table does not + have an index that contains the + foreign keys as its prefix columns */ +#define DB_REFERENCING_NO_INDEX 51 /* the parent (referencing) table does + not have an index that contains the + foreign keys as its prefix columns */ /* The following are partial failure codes */ #define DB_FAIL 1000 From ed736379f5ba4e681088a139cefaebb50600a44a Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Fri, 6 Aug 2010 23:29:37 +0400 Subject: [PATCH 013/183] Bug #55424: convert_tz crashes when fed invalid data The CONVERT_TZ function crashes the server when the timezone argument is an empty SET field value. 1) The CONVERT_TZ may find a timezone string in the tz_names hash. 2) A string representation of the empty SET is a String of zero length with the NULL pointer. 3) If the key argument length is zero, hash functions do comparison using the length of the record being compared against. I.e. a zero-length String buffer is an invalid argument for hash search functions, and if String points to NULL buffer, hashcmp() fails with SEGV accessing that memory. The my_tz_find function has been modified to treat empty Strings as invalid timezone values to skip unnecessary hash search. --- mysql-test/r/timezone2.result | 12 ++++++++++++ mysql-test/t/timezone2.test | 9 +++++++++ sql/sql_string.h | 2 +- sql/tztime.cc | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/timezone2.result b/mysql-test/r/timezone2.result index 2948bb8ecec..e2e337628ce 100644 --- a/mysql-test/r/timezone2.result +++ b/mysql-test/r/timezone2.result @@ -296,4 +296,16 @@ CONVERT_TZ(NOW(), 'UTC', 'Europe/Moscow') IS NULL UPDATE t1 SET t = CONVERT_TZ(t, 'UTC', 'Europe/Moscow'); UNLOCK TABLES; DROP TABLE t1; +# +# Bug #55424: convert_tz crashes when fed invalid data +# +CREATE TABLE t1 (a SET('x') NOT NULL); +INSERT INTO t1 VALUES (''); +SELECT CONVERT_TZ(1, a, 1) FROM t1; +CONVERT_TZ(1, a, 1) +NULL +SELECT CONVERT_TZ(1, 1, a) FROM t1; +CONVERT_TZ(1, 1, a) +NULL +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/t/timezone2.test b/mysql-test/t/timezone2.test index 15ddceb8d68..c4445da107c 100644 --- a/mysql-test/t/timezone2.test +++ b/mysql-test/t/timezone2.test @@ -273,5 +273,14 @@ UNLOCK TABLES; DROP TABLE t1; +--echo # +--echo # Bug #55424: convert_tz crashes when fed invalid data +--echo # + +CREATE TABLE t1 (a SET('x') NOT NULL); +INSERT INTO t1 VALUES (''); +SELECT CONVERT_TZ(1, a, 1) FROM t1; +SELECT CONVERT_TZ(1, 1, a) FROM t1; +DROP TABLE t1; --echo End of 5.1 tests diff --git a/sql/sql_string.h b/sql/sql_string.h index d62908e5d66..bb7d69aeccc 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -97,7 +97,7 @@ public: inline uint32 alloced_length() const { return Alloced_length;} inline char& operator [] (uint32 i) const { return Ptr[i]; } inline void length(uint32 len) { str_length=len ; } - inline bool is_empty() { return (str_length == 0); } + inline bool is_empty() const { return (str_length == 0); } inline void mark_as_const() { Alloced_length= 0;} inline const char *ptr() const { return Ptr; } inline char *c_ptr() diff --git a/sql/tztime.cc b/sql/tztime.cc index c7a4ad049ec..7ebb8eb392a 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2259,7 +2259,7 @@ my_tz_find(THD *thd, const String *name) DBUG_PRINT("enter", ("time zone name='%s'", name ? ((String *)name)->c_ptr_safe() : "NULL")); - if (!name) + if (!name || name->is_empty()) DBUG_RETURN(0); VOID(pthread_mutex_lock(&tz_LOCK)); From 5bde03c8e12ac32da42d385112c6cdf265a5798d Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Tue, 10 Aug 2010 10:43:12 +0200 Subject: [PATCH 014/183] Bug#55458: Partitioned MyISAM table gets crashed by multi-table update Problem was that the handler call ::extra(HA_EXTRA_CACHE) was cached but the ::extra(HA_EXTRA_PREPARE_FOR_UPDATE) was not. Solution was to also cache the other call and forward it when moving to a new partition to scan. --- mysql-test/r/partition.result | 25 +++++++++++++++++++++++++ mysql-test/t/partition.test | 27 +++++++++++++++++++++++++++ sql/ha_partition.cc | 27 ++++++++++++++++++++++++--- sql/ha_partition.h | 2 ++ 4 files changed, 78 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 23a485dc5ed..bb1635b8621 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1,4 +1,29 @@ drop table if exists t1, t2; +# +# Bug#55458: Partitioned MyISAM table gets crashed by multi-table update +# +CREATE TABLE t1 ( +`id` int NOT NULL, +`user_num` int DEFAULT NULL, +PRIMARY KEY (`id`) +) ENGINE=MyISAM CHARSET=latin1; +INSERT INTO t1 VALUES (1,8601); +INSERT INTO t1 VALUES (2,8601); +INSERT INTO t1 VALUES (3,8601); +INSERT INTO t1 VALUES (4,8601); +CREATE TABLE t2 ( +`id` int(11) NOT NULL, +`user_num` int DEFAULT NULL, +`name` varchar(64) NOT NULL, +PRIMARY KEY (`id`) +) ENGINE=MyISAM CHARSET=latin1 +PARTITION BY HASH (id) +PARTITIONS 2; +INSERT INTO t2 VALUES (1,8601,'John'); +INSERT INTO t2 VALUES (2,8601,'JS'); +INSERT INTO t2 VALUES (3,8601,'John S'); +UPDATE t1, t2 SET t2.name = 'John Smith' WHERE t1.user_num = t2.user_num; +DROP TABLE t1, t2; CREATE TABLE t1 (a INT, b INT) PARTITION BY LIST (a) SUBPARTITION BY HASH (b) diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 22124cc1847..95d702ee6b8 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -14,6 +14,33 @@ drop table if exists t1, t2; --enable_warnings +--echo # +--echo # Bug#55458: Partitioned MyISAM table gets crashed by multi-table update +--echo # +CREATE TABLE t1 ( + `id` int NOT NULL, + `user_num` int DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM CHARSET=latin1; +INSERT INTO t1 VALUES (1,8601); +INSERT INTO t1 VALUES (2,8601); +INSERT INTO t1 VALUES (3,8601); +INSERT INTO t1 VALUES (4,8601); +CREATE TABLE t2 ( + `id` int(11) NOT NULL, + `user_num` int DEFAULT NULL, + `name` varchar(64) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM CHARSET=latin1 +PARTITION BY HASH (id) +PARTITIONS 2; +INSERT INTO t2 VALUES (1,8601,'John'); +INSERT INTO t2 VALUES (2,8601,'JS'); +INSERT INTO t2 VALUES (3,8601,'John S'); + +UPDATE t1, t2 SET t2.name = 'John Smith' WHERE t1.user_num = t2.user_num; + +DROP TABLE t1, t2; # # Bug#48276: can't add column if subpartition exists CREATE TABLE t1 (a INT, b INT) diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index a87c7fbf7b8..3d3ae33be4b 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -232,6 +232,7 @@ void ha_partition::init_handler_variables() m_innodb= FALSE; m_extra_cache= FALSE; m_extra_cache_size= 0; + m_extra_prepare_for_update= FALSE; m_handler_status= handler_not_initialized; m_low_byte_first= 1; m_part_field_array= NULL; @@ -5549,9 +5550,20 @@ int ha_partition::extra(enum ha_extra_function operation) case HA_EXTRA_PREPARE_FOR_RENAME: DBUG_RETURN(prepare_for_rename()); break; + case HA_EXTRA_PREPARE_FOR_UPDATE: + DBUG_ASSERT(m_extra_cache); + /* + Needs to be run on the first partition in the range now, and + later in late_extra_cache, when switching to a new partition to scan. + */ + m_extra_prepare_for_update= TRUE; + if (m_part_spec.start_part != NO_CURRENT_PART_ID) + { + VOID(m_file[m_part_spec.start_part]->extra(HA_EXTRA_PREPARE_FOR_UPDATE)); + } + break; case HA_EXTRA_NORMAL: case HA_EXTRA_QUICK: - case HA_EXTRA_PREPARE_FOR_UPDATE: case HA_EXTRA_FORCE_REOPEN: case HA_EXTRA_PREPARE_FOR_DROP: case HA_EXTRA_FLUSH_CACHE: @@ -5578,6 +5590,7 @@ int ha_partition::extra(enum ha_extra_function operation) { m_extra_cache= FALSE; m_extra_cache_size= 0; + m_extra_prepare_for_update= FALSE; DBUG_RETURN(loop_extra(operation)); } case HA_EXTRA_IGNORE_NO_KEY: @@ -5705,6 +5718,7 @@ int ha_partition::extra_opt(enum ha_extra_function operation, ulong cachesize) void ha_partition::prepare_extra_cache(uint cachesize) { DBUG_ENTER("ha_partition::prepare_extra_cache()"); + DBUG_PRINT("info", ("cachesize %u", cachesize)); m_extra_cache= TRUE; m_extra_cache_size= cachesize; @@ -5793,14 +5807,21 @@ void ha_partition::late_extra_cache(uint partition_id) { handler *file; DBUG_ENTER("ha_partition::late_extra_cache"); + DBUG_PRINT("info", ("extra_cache %u partid %u size %u", m_extra_cache, + partition_id, m_extra_cache_size)); - if (!m_extra_cache) + if (!m_extra_cache && !m_extra_prepare_for_update) DBUG_VOID_RETURN; file= m_file[partition_id]; if (m_extra_cache_size == 0) VOID(file->extra(HA_EXTRA_CACHE)); else VOID(file->extra_opt(HA_EXTRA_CACHE, m_extra_cache_size)); + if (m_extra_prepare_for_update) + { + DBUG_ASSERT(m_extra_cache); + VOID(file->extra(HA_EXTRA_PREPARE_FOR_UPDATE)); + } DBUG_VOID_RETURN; } @@ -5821,7 +5842,7 @@ void ha_partition::late_extra_no_cache(uint partition_id) handler *file; DBUG_ENTER("ha_partition::late_extra_no_cache"); - if (!m_extra_cache) + if (!m_extra_cache && !m_extra_prepare_for_update) DBUG_VOID_RETURN; file= m_file[partition_id]; VOID(file->extra(HA_EXTRA_NO_CACHE)); diff --git a/sql/ha_partition.h b/sql/ha_partition.h index e3dc7d17c6d..013341e4df3 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -154,6 +154,8 @@ private: */ bool m_extra_cache; uint m_extra_cache_size; + /* The same goes for HA_EXTRA_PREPARE_FOR_UPDATE */ + bool m_extra_prepare_for_update; void init_handler_variables(); /* From 3ca814b76065c8c251128fc4d187f60d90cec679 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Tue, 10 Aug 2010 12:13:58 +0200 Subject: [PATCH 015/183] Bug #55413 mysqltest gives parse error for lines matching "^let.*\\.*;$" Allow escaped quotes also in statements not starting with -- But will not support single unescaped ' or ` --- client/mysqltest.cc | 10 ++++++++-- mysql-test/r/mysqltest.result | 3 +++ mysql-test/t/mysqltest.test | 10 ++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index d7a302912b4..d8c921e8f18 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5507,6 +5507,8 @@ int read_line(char *buf, int size) char c, UNINIT_VAR(last_quote); char *p= buf, *buf_end= buf + size - 1; int skip_char= 0; + my_bool have_slash= FALSE; + enum {R_NORMAL, R_Q, R_SLASH_IN_Q, R_COMMENT, R_LINE_START} state= R_LINE_START; DBUG_ENTER("read_line"); @@ -5578,9 +5580,13 @@ int read_line(char *buf, int size) } else if (c == '\'' || c == '"' || c == '`') { - last_quote= c; - state= R_Q; + if (! have_slash) + { + last_quote= c; + state= R_Q; + } } + have_slash= (c == '\\'); break; case R_COMMENT: diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index e4f68d68c3f..1044127b06e 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -262,6 +262,9 @@ a long \$where variable content banana = banana Not a banana: ba\$cat\$cat +with\`some"escaped\'quotes +with\`some"escaped\'quotes +single'tick`backtick mysqltest: At line 1: Missing arguments to let mysqltest: At line 1: Missing variable name in let mysqltest: At line 1: Missing assignment operator in let diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 031c51a0720..9da19ec00e0 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -701,6 +701,16 @@ echo banana = $cat; let $cat=ba\\\$cat\\\$cat; echo Not a banana: $cat; +# Bug #55413 would cause this to fail +let $escape= with\`some\"escaped\'quotes; +echo $escape; + +--let $escape= with\`some\"escaped\'quotes +echo $escape; + +# This only works with "--let" syntax +--let $tick= single'tick`backtick +echo $tick; # Test illegal uses of let From a557509653a9909bf5bc27734a2d538254c9b1bc Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 13 Aug 2010 14:18:46 +0300 Subject: [PATCH 016/183] Bug #55615 and bug #55564 An user assignment variable expression that's evaluated in a logical expression context (Item::val_bool()) can be pre-calculated in a temporary table for GROUP BY. However when the expression value is used after the temp table creation it was re-evaluated instead of being read from the temp table due to a missing val_bool_result() method. Fixed by implementing the method. --- mysql-test/r/user_var.result | 17 +++++++++++++++++ mysql-test/t/user_var.test | 18 ++++++++++++++++++ sql/item_func.cc | 8 ++++++++ sql/item_func.h | 1 + 4 files changed, 44 insertions(+) diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index be10bd9954b..56266a46e20 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -430,4 +430,21 @@ CREATE TRIGGER t_after_insert AFTER INSERT ON t1 FOR EACH ROW SET @bug42188 = 10 INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1); DROP TABLE t1; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (0),(0); +# BUG#55615 : should not crash +SELECT (@a:=(SELECT @a:=1 FROM t1 LIMIT 1)) AND COUNT(1) FROM t1 GROUP BY @a; +(@a:=(SELECT @a:=1 FROM t1 LIMIT 1)) AND COUNT(1) +1 +1 +# BUG#55564 : should not crash +SELECT IF( +@v:=LEAST((SELECT 1 FROM t1 t2 LEFT JOIN t1 ON (@v) GROUP BY t1.a), a), +count(*), 1) +FROM t1 GROUP BY a LIMIT 1; +IF( +@v:=LEAST((SELECT 1 FROM t1 t2 LEFT JOIN t1 ON (@v) GROUP BY t1.a), a), +count(*), 1) +1 +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index b6b58e7bd46..4f27866de23 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -328,4 +328,22 @@ INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1); DROP TABLE t1; +# +# Bug #55615: debug assertion after using variable in assignment and +# referred to +# Bug #55564: crash with user variables, assignments, joins... +# + +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (0),(0); +--echo # BUG#55615 : should not crash +SELECT (@a:=(SELECT @a:=1 FROM t1 LIMIT 1)) AND COUNT(1) FROM t1 GROUP BY @a; +--echo # BUG#55564 : should not crash +SELECT IF( + @v:=LEAST((SELECT 1 FROM t1 t2 LEFT JOIN t1 ON (@v) GROUP BY t1.a), a), + count(*), 1) +FROM t1 GROUP BY a LIMIT 1; + +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/sql/item_func.cc b/sql/item_func.cc index 1b13297c951..eecdc801512 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4263,6 +4263,14 @@ longlong Item_func_set_user_var::val_int_result() return entry->val_int(&null_value); } +bool Item_func_set_user_var::val_bool_result() +{ + DBUG_ASSERT(fixed == 1); + check(TRUE); + update(); // Store expression + return entry->val_int(&null_value) != 0; +} + String *Item_func_set_user_var::str_result(String *str) { DBUG_ASSERT(fixed == 1); diff --git a/sql/item_func.h b/sql/item_func.h index 71168c64e4b..256348eee08 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1353,6 +1353,7 @@ public: my_decimal *val_decimal(my_decimal *); double val_result(); longlong val_int_result(); + bool val_bool_result(); String *str_result(String *str); my_decimal *val_decimal_result(my_decimal *); bool is_null_result(); From 2ecc81cb308fd978dfa3719d3b88825ee5c7f76e Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 13 Aug 2010 14:20:49 +0300 Subject: [PATCH 017/183] merge --- mysql-test/r/user_var.result | 17 +++++++++++++++++ mysql-test/t/user_var.test | 18 ++++++++++++++++++ sql/item_func.cc | 8 ++++++++ sql/item_func.h | 1 + 4 files changed, 44 insertions(+) diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index 29c05a60166..a680e837cae 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -428,6 +428,23 @@ CREATE TRIGGER t_after_insert AFTER INSERT ON t1 FOR EACH ROW SET @bug42188 = 10 INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1); DROP TABLE t1; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (0),(0); +# BUG#55615 : should not crash +SELECT (@a:=(SELECT @a:=1 FROM t1 LIMIT 1)) AND COUNT(1) FROM t1 GROUP BY @a; +(@a:=(SELECT @a:=1 FROM t1 LIMIT 1)) AND COUNT(1) +1 +1 +# BUG#55564 : should not crash +SELECT IF( +@v:=LEAST((SELECT 1 FROM t1 t2 LEFT JOIN t1 ON (@v) GROUP BY t1.a), a), +count(*), 1) +FROM t1 GROUP BY a LIMIT 1; +IF( +@v:=LEAST((SELECT 1 FROM t1 t2 LEFT JOIN t1 ON (@v) GROUP BY t1.a), a), +count(*), 1) +1 +DROP TABLE t1; End of 5.1 tests DROP TABLE IF EXISTS t1; CREATE TABLE t1(f1 INT AUTO_INCREMENT, PRIMARY KEY(f1)); diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index fc4bc61f526..06508c43766 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -326,6 +326,24 @@ INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1); DROP TABLE t1; +# +# Bug #55615: debug assertion after using variable in assignment and +# referred to +# Bug #55564: crash with user variables, assignments, joins... +# + +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (0),(0); +--echo # BUG#55615 : should not crash +SELECT (@a:=(SELECT @a:=1 FROM t1 LIMIT 1)) AND COUNT(1) FROM t1 GROUP BY @a; +--echo # BUG#55564 : should not crash +SELECT IF( + @v:=LEAST((SELECT 1 FROM t1 t2 LEFT JOIN t1 ON (@v) GROUP BY t1.a), a), + count(*), 1) +FROM t1 GROUP BY a LIMIT 1; + +DROP TABLE t1; + --echo End of 5.1 tests # diff --git a/sql/item_func.cc b/sql/item_func.cc index 7812460bd2b..22dc0b173c4 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4621,6 +4621,14 @@ longlong Item_func_set_user_var::val_int_result() return entry->val_int(&null_value); } +bool Item_func_set_user_var::val_bool_result() +{ + DBUG_ASSERT(fixed == 1); + check(TRUE); + update(); // Store expression + return entry->val_int(&null_value) != 0; +} + String *Item_func_set_user_var::str_result(String *str) { DBUG_ASSERT(fixed == 1); diff --git a/sql/item_func.h b/sql/item_func.h index 834ecd60e21..15730516c71 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1416,6 +1416,7 @@ public: my_decimal *val_decimal(my_decimal *); double val_result(); longlong val_int_result(); + bool val_bool_result(); String *str_result(String *str); my_decimal *val_decimal_result(my_decimal *); bool is_null_result(); From bfca4bb9bf14efd4d8862d1edd8da8d8f155da15 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Fri, 13 Aug 2010 15:52:11 +0300 Subject: [PATCH 018/183] Manually merge a changeset from mysql-5.1-security: ------------------------------------------------------------ revno: 3475 revision-id: jimmy.yang@oracle.com-20100804103744-vbpeghipkz6pyc9z parent: jimmy.yang@oracle.com-20100804101133-c38qqbm0fkwn9jhc committer: Jimmy Yang branch nick: mysql-5.1-security timestamp: Wed 2010-08-04 03:37:44 -0700 message: Fix bug #54678, InnoDB, TRUNCATE, ALTER, I_S SELECT, crash or deadlock rb://399 approved by Sunny Bains modified: storage/innodb_plugin/ChangeLog 2425@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2FChangeLog storage/innodb_plugin/include/dict0dict.h 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fdict0dict.h storage/innodb_plugin/include/dict0dict.ic 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fdict0dict.ic storage/innodb_plugin/row/row0mysql.c 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Frow%2Frow0mysql.c --- storage/innobase/include/dict0dict.h | 16 ++++++++++ storage/innobase/include/dict0dict.ic | 42 +++++++++++++++++++++++++++ storage/innobase/row/row0mysql.c | 14 +++++++++ 3 files changed, 72 insertions(+) diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 971173a65a5..029cf408141 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -707,6 +707,22 @@ ulint dict_table_zip_size( /*================*/ const dict_table_t* table); /*!< in: table */ +/*********************************************************************//** +Obtain exclusive locks on all index trees of the table. This is to prevent +accessing index trees while InnoDB is updating internal metadata for +operations such as truncate tables. */ +UNIV_INLINE +void +dict_table_x_lock_indexes( +/*======================*/ + dict_table_t* table); /*!< in: table */ +/*********************************************************************//** +Release the exclusive locks on all index tree. */ +UNIV_INLINE +void +dict_table_x_unlock_indexes( +/*========================*/ + dict_table_t* table); /*!< in: table */ /********************************************************************//** Checks if a column is in the ordering columns of the clustered index of a table. Column prefixes are treated like whole columns. diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic index 09f967aa74a..42f124dedfc 100644 --- a/storage/innobase/include/dict0dict.ic +++ b/storage/innobase/include/dict0dict.ic @@ -490,6 +490,48 @@ dict_table_zip_size( return(dict_table_flags_to_zip_size(table->flags)); } +/*********************************************************************//** +Obtain exclusive locks on all index trees of the table. This is to prevent +accessing index trees while InnoDB is updating internal metadata for +operations such as truncate tables. */ +UNIV_INLINE +void +dict_table_x_lock_indexes( +/*======================*/ + dict_table_t* table) /*!< in: table */ +{ + dict_index_t* index; + + ut_a(table); + ut_ad(mutex_own(&(dict_sys->mutex))); + + /* Loop through each index of the table and lock them */ + for (index = dict_table_get_first_index(table); + index != NULL; + index = dict_table_get_next_index(index)) { + rw_lock_x_lock(dict_index_get_lock(index)); + } +} + +/*********************************************************************//** +Release the exclusive locks on all index tree. */ +UNIV_INLINE +void +dict_table_x_unlock_indexes( +/*========================*/ + dict_table_t* table) /*!< in: table */ +{ + dict_index_t* index; + + ut_a(table); + ut_ad(mutex_own(&(dict_sys->mutex))); + + for (index = dict_table_get_first_index(table); + index != NULL; + index = dict_table_get_next_index(index)) { + rw_lock_x_unlock(dict_index_get_lock(index)); + } +} /********************************************************************//** Gets the number of fields in the internal representation of an index, including fields added by the dictionary system. diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index 1262ac71e98..fc71f52096f 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -2808,6 +2808,15 @@ row_truncate_table_for_mysql( trx->table_id = table->id; + /* Lock all index trees for this table, as we will + truncate the table/index and possibly change their metadata. + All DML/DDL are blocked by table level lock, with + a few exceptions such as queries into information schema + about the table, MySQL could try to access index stats + for this kind of query, we need to use index locks to + sync up */ + dict_table_x_lock_indexes(table); + if (table->space && !table->dir_path_of_temp_table) { /* Discard and create the single-table tablespace. */ ulint space = table->space; @@ -2824,6 +2833,7 @@ row_truncate_table_for_mysql( || fil_create_new_single_table_tablespace( space, table->name, FALSE, flags, FIL_IBD_FILE_INITIAL_SIZE) != DB_SUCCESS) { + dict_table_x_unlock_indexes(table); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: TRUNCATE TABLE %s failed to" @@ -2927,6 +2937,10 @@ next_rec: mem_heap_free(heap); + /* Done with index truncation, release index tree locks, + subsequent work relates to table level metadata change */ + dict_table_x_unlock_indexes(table); + dict_hdr_get_new_id(&new_id, NULL, NULL); info = pars_info_create(); From 62aa8943b8b0603fe4a01a4248f5fa89a133cf9f Mon Sep 17 00:00:00 2001 From: Sunny Bains Date: Mon, 16 Aug 2010 10:12:22 +1000 Subject: [PATCH 019/183] Add test to the plugin branch from fix for bug# 55277. --- .../suite/innodb_plugin/r/innodb-autoinc.result | 13 +++++++++++++ .../suite/innodb_plugin/t/innodb-autoinc.test | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/mysql-test/suite/innodb_plugin/r/innodb-autoinc.result b/mysql-test/suite/innodb_plugin/r/innodb-autoinc.result index a36b3a1a865..350c7ebd541 100644 --- a/mysql-test/suite/innodb_plugin/r/innodb-autoinc.result +++ b/mysql-test/suite/innodb_plugin/r/innodb-autoinc.result @@ -1244,3 +1244,16 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`c1`) ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 DROP TABLE t1; +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1(c1 BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (18446744073709551615); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB AUTO_INCREMENT=18446744073709551615 DEFAULT CHARSET=latin1 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_plugin/t/innodb-autoinc.test b/mysql-test/suite/innodb_plugin/t/innodb-autoinc.test index 49394a019d0..3d67fe5738d 100644 --- a/mysql-test/suite/innodb_plugin/t/innodb-autoinc.test +++ b/mysql-test/suite/innodb_plugin/t/innodb-autoinc.test @@ -667,6 +667,18 @@ SELECT * FROM t1; SHOW CREATE TABLE t1; DROP TABLE t1; +## +# 55277: Failing assertion: auto_inc > 0 +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(c1 BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (18446744073709551615); +# Restart the server +-- source include/restart_mysqld.inc +SHOW CREATE TABLE t1; +DROP TABLE t1; + # # restore environment to the state it was before this test execution # From 787f0c54cb5b33fe8263afcbb7c812805d525a8d Mon Sep 17 00:00:00 2001 From: Sunny Bains Date: Mon, 16 Aug 2010 11:59:43 +1000 Subject: [PATCH 020/183] Fix Bug #55277 - Failing assertion: auto_inc > 0 Handle overflow when reading value from SELECT MAX(C) FROM T; Call ha_innobase::info() after initializing the autoinc value in ha_innobase::open(). Fix for both the builtin and plugin. rb://402 Merge from mysql-5.1-security. --- .../suite/innodb/r/innodb-autoinc.result | 13 ++++++++++++ mysql-test/suite/innodb/t/innodb-autoinc.test | 12 ++++++++++- storage/innobase/handler/ha_innodb.cc | 21 ++++++++++++------- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-autoinc.result b/mysql-test/suite/innodb/r/innodb-autoinc.result index a36b3a1a865..350c7ebd541 100644 --- a/mysql-test/suite/innodb/r/innodb-autoinc.result +++ b/mysql-test/suite/innodb/r/innodb-autoinc.result @@ -1244,3 +1244,16 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`c1`) ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 DROP TABLE t1; +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1(c1 BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (18446744073709551615); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB AUTO_INCREMENT=18446744073709551615 DEFAULT CHARSET=latin1 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb-autoinc.test b/mysql-test/suite/innodb/t/innodb-autoinc.test index a8e853baef7..da0783bdc7c 100644 --- a/mysql-test/suite/innodb/t/innodb-autoinc.test +++ b/mysql-test/suite/innodb/t/innodb-autoinc.test @@ -665,7 +665,17 @@ SELECT * FROM t1; SHOW CREATE TABLE t1; DROP TABLE t1; - +## +# 55277: Failing assertion: auto_inc > 0 +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(c1 BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (18446744073709551615); +# Restart the server +-- source include/restart_mysqld.inc +SHOW CREATE TABLE t1; +DROP TABLE t1; # # restore environment to the state it was before this test execution # diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index ab9df9a0272..e1b9f9e224f 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -3528,12 +3528,19 @@ ha_innobase::innobase_initialize_autoinc() err = row_search_max_autoinc(index, col_name, &read_auto_inc); switch (err) { - case DB_SUCCESS: - /* At the this stage we do not know the increment - or the offset, so use a default increment of 1. */ - auto_inc = read_auto_inc + 1; - break; + case DB_SUCCESS: { + ulonglong col_max_value; + col_max_value = innobase_get_int_col_max_value(field); + + /* At the this stage we do not know the increment + nor the offset, so use a default increment of 1. */ + + auto_inc = innobase_next_autoinc( + read_auto_inc, 1, 1, col_max_value); + + break; + } case DB_RECORD_NOT_FOUND: ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: MySQL and InnoDB data " @@ -3828,8 +3835,6 @@ retry: dict_table_get_format(prebuilt->table)); } - info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST); - /* Only if the table has an AUTOINC column. */ if (prebuilt->table != NULL && table->found_next_number_field != NULL) { dict_table_autoinc_lock(prebuilt->table); @@ -3846,6 +3851,8 @@ retry: dict_table_autoinc_unlock(prebuilt->table); } + info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST); + DBUG_RETURN(0); } From 97aa1215796d6a0ed66267e229ef42e6b3d6d452 Mon Sep 17 00:00:00 2001 From: Sunny Bains Date: Mon, 16 Aug 2010 12:05:49 +1000 Subject: [PATCH 021/183] Merge from -c3476 mysql-5.1-security. ------------------------------------------------------------ revno: 3476 committer: Sunny Bains branch nick: 5.1-security timestamp: Thu 2010-08-05 19:18:17 +1000 message: Fix bug# 55543 - InnoDB Plugin: Signal 6: Assertion failure in file fil/fil0fil.c line 4306 The bug is due to a double delete of a BLOB, once via: rollback -> btr_cur_pessimistic_delete() and the second time via purge. The bug is in row_upd_clust_rec_by_insert(). There we relinquish ownership of the non-updated BLOB columns in btr_cur_mark_extern_inherited_fields() before building the row entry that will be inserted and whose contents will be logged in the UNDO log. However, we don't set the BLOB column later to INHERITED so that a possible rollback will not free the original row's non-updated BLOB entries. This is because the condition that checks for that is in : if (node->upd_ext) {}. node->upd_ext is non-NULL only if a BLOB column was updated and that column is part of some key ordering (see row_upd_replace()). This results in the non-update BLOB columns being deleted during a rollback and subsequently by purge again. rb://413 --- storage/innobase/btr/btr0cur.c | 12 +++++++++--- storage/innobase/include/btr0cur.h | 5 +++-- storage/innobase/row/row0upd.c | 9 ++++++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/storage/innobase/btr/btr0cur.c b/storage/innobase/btr/btr0cur.c index 537d5f51184..4a8ba1ade96 100644 --- a/storage/innobase/btr/btr0cur.c +++ b/storage/innobase/btr/btr0cur.c @@ -3603,9 +3603,10 @@ btr_cur_set_ownership_of_extern_field( Marks not updated extern fields as not-owned by this record. The ownership is transferred to the updated record which is inserted elsewhere in the index tree. In purge only the owner of externally stored field is allowed -to free the field. */ +to free the field. +@return TRUE if BLOB ownership was transferred */ UNIV_INTERN -void +ibool btr_cur_mark_extern_inherited_fields( /*=================================*/ page_zip_des_t* page_zip,/*!< in/out: compressed page whose uncompressed @@ -3619,13 +3620,14 @@ btr_cur_mark_extern_inherited_fields( ulint n; ulint j; ulint i; + ibool change_ownership = FALSE; ut_ad(rec_offs_validate(rec, NULL, offsets)); ut_ad(!rec_offs_comp(offsets) || !rec_get_node_ptr_flag(rec)); if (!rec_offs_any_extern(offsets)) { - return; + return(FALSE); } n = rec_offs_n_fields(offsets); @@ -3648,10 +3650,14 @@ btr_cur_mark_extern_inherited_fields( btr_cur_set_ownership_of_extern_field( page_zip, rec, index, offsets, i, FALSE, mtr); + + change_ownership = TRUE; updated: ; } } + + return(change_ownership); } /*******************************************************************//** diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h index 757477838ee..e38cb51a987 100644 --- a/storage/innobase/include/btr0cur.h +++ b/storage/innobase/include/btr0cur.h @@ -456,9 +456,10 @@ btr_estimate_number_of_different_key_vals( Marks not updated extern fields as not-owned by this record. The ownership is transferred to the updated record which is inserted elsewhere in the index tree. In purge only the owner of externally stored field is allowed -to free the field. */ +to free the field. +@return TRUE if BLOB ownership was transferred */ UNIV_INTERN -void +ibool btr_cur_mark_extern_inherited_fields( /*=================================*/ page_zip_des_t* page_zip,/*!< in/out: compressed page whose uncompressed diff --git a/storage/innobase/row/row0upd.c b/storage/innobase/row/row0upd.c index 588ee352ba0..a1004c0d2cf 100644 --- a/storage/innobase/row/row0upd.c +++ b/storage/innobase/row/row0upd.c @@ -1626,6 +1626,7 @@ row_upd_clust_rec_by_insert( dict_table_t* table; dtuple_t* entry; ulint err; + ibool change_ownership = FALSE; ut_ad(node); ut_ad(dict_index_is_clust(index)); @@ -1658,10 +1659,11 @@ row_upd_clust_rec_by_insert( index = dict_table_get_first_index(table); offsets = rec_get_offsets(rec, index, offsets_, ULINT_UNDEFINED, &heap); - btr_cur_mark_extern_inherited_fields( + change_ownership = btr_cur_mark_extern_inherited_fields( btr_cur_get_page_zip(btr_cur), rec, index, offsets, node->update, mtr); if (referenced) { + /* NOTE that the following call loses the position of pcur ! */ @@ -1694,10 +1696,11 @@ row_upd_clust_rec_by_insert( row_upd_index_entry_sys_field(entry, index, DATA_TRX_ID, trx->id); - if (node->upd_ext) { + if (change_ownership) { /* If we return from a lock wait, for example, we may have extern fields marked as not-owned in entry (marked in the - if-branch above). We must unmark them. */ + if-branch above). We must unmark them, take the ownership + back. */ btr_cur_unmark_dtuple_extern_fields(entry); From a22056e84696d295079533e80edceff410ca585b Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Mon, 16 Aug 2010 16:43:21 +0300 Subject: [PATCH 022/183] Bug #53296: LONG BLOB value types are not recognized Fixed the length of system variables to be 2^24 - 1 as it is documented for MEDIUMBLOB instead of 2^24. --- mysql-test/r/ps_2myisam.result | 272 ++++++++--------- mysql-test/r/ps_3innodb.result | 272 ++++++++--------- mysql-test/r/ps_4heap.result | 272 ++++++++--------- mysql-test/r/ps_5merge.result | 544 ++++++++++++++++----------------- sql/item_func.cc | 2 +- 5 files changed, 681 insertions(+), 681 deletions(-) diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index a91d13d11a1..56b18ff4476 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -1929,26 +1929,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 128 31 63 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 128 31 63 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 128 31 63 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 128 31 63 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 128 31 63 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 128 31 63 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 128 31 63 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 128 31 63 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday select @arg01:= c1, @arg02:= c2, @arg03:= c3, @arg04:= c4, @@ -1976,26 +1976,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 128 31 63 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 128 31 63 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 128 31 63 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 128 31 63 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 128 31 63 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 128 31 63 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 128 31 63 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 128 31 63 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select @@ -2026,26 +2026,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 128 31 63 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 128 31 63 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 128 31 63 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 128 31 63 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 128 31 63 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 128 31 63 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 128 31 63 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 128 31 63 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday set @my_key= 0 ; @@ -2066,26 +2066,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 128 31 63 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 128 31 63 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 128 31 63 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 128 31 63 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 128 31 63 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 128 31 63 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 128 31 63 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 128 31 63 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select ? := c1 from t9 where c1= 1" ; @@ -2114,26 +2114,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 128 31 63 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 128 31 63 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 128 31 63 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 128 31 63 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 128 31 63 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 128 31 63 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 128 31 63 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 128 31 63 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -2158,26 +2158,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 128 31 63 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 128 31 63 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 128 31 63 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 128 31 63 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 128 31 63 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 128 31 63 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 128 31 63 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 128 31 63 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -2204,26 +2204,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 128 31 63 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 128 31 63 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 128 31 63 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 128 31 63 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 128 31 63 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 128 31 63 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 128 31 63 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 128 31 63 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday set @my_key= 0 ; @@ -2242,26 +2242,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 128 31 63 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 128 31 63 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 128 31 63 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 128 31 63 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 128 31 63 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 128 31 63 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 128 31 63 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 128 31 63 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1 into ? from t9 where c1= 1" ; diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index 50c94d6cc4e..2cd3b2f5820 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -1912,26 +1912,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 128 31 63 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 128 31 63 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 128 31 63 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 128 31 63 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 128 31 63 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 128 31 63 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 128 31 63 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 128 31 63 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday select @arg01:= c1, @arg02:= c2, @arg03:= c3, @arg04:= c4, @@ -1959,26 +1959,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 128 31 63 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 128 31 63 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 128 31 63 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 128 31 63 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 128 31 63 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 128 31 63 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 128 31 63 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 128 31 63 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select @@ -2009,26 +2009,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 128 31 63 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 128 31 63 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 128 31 63 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 128 31 63 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 128 31 63 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 128 31 63 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 128 31 63 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 128 31 63 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday set @my_key= 0 ; @@ -2049,26 +2049,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 128 31 63 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 128 31 63 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 128 31 63 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 128 31 63 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 128 31 63 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 128 31 63 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 128 31 63 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 128 31 63 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select ? := c1 from t9 where c1= 1" ; @@ -2097,26 +2097,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 128 31 63 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 128 31 63 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 128 31 63 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 128 31 63 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 128 31 63 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 128 31 63 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 128 31 63 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 128 31 63 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -2141,26 +2141,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 128 31 63 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 128 31 63 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 128 31 63 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 128 31 63 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 128 31 63 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 128 31 63 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 128 31 63 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 128 31 63 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -2187,26 +2187,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 128 31 63 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 128 31 63 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 128 31 63 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 128 31 63 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 128 31 63 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 128 31 63 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 128 31 63 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 128 31 63 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday set @my_key= 0 ; @@ -2225,26 +2225,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 128 31 63 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 128 31 63 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 128 31 63 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 128 31 63 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 128 31 63 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 128 31 63 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 128 31 63 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 128 31 63 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1 into ? from t9 where c1= 1" ; diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index a85809d3800..414267a5616 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -1913,26 +1913,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 0 31 8 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 0 31 8 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 0 31 8 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 0 31 8 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 0 31 8 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 0 31 8 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 0 31 8 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 0 31 8 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday select @arg01:= c1, @arg02:= c2, @arg03:= c3, @arg04:= c4, @@ -1960,26 +1960,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 0 31 8 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 0 31 8 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 0 31 8 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 0 31 8 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 0 31 8 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 0 31 8 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 0 31 8 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 0 31 8 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select @@ -2010,26 +2010,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 0 31 8 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 0 31 8 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 0 31 8 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 0 31 8 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 0 31 8 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 0 31 8 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 0 31 8 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 0 31 8 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday set @my_key= 0 ; @@ -2050,26 +2050,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 0 31 8 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 0 31 8 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 0 31 8 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 0 31 8 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 0 31 8 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 0 31 8 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 0 31 8 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 0 31 8 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select ? := c1 from t9 where c1= 1" ; @@ -2098,26 +2098,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 0 31 8 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 0 31 8 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 0 31 8 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 0 31 8 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 0 31 8 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 0 31 8 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 0 31 8 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 0 31 8 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -2142,26 +2142,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 0 31 8 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 0 31 8 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 0 31 8 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 0 31 8 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 0 31 8 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 0 31 8 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 0 31 8 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 0 31 8 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -2188,26 +2188,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 0 31 8 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 0 31 8 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 0 31 8 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 0 31 8 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 0 31 8 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 0 31 8 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 0 31 8 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 0 31 8 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday set @my_key= 0 ; @@ -2226,26 +2226,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 0 31 8 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 0 31 8 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 0 31 8 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 0 31 8 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 0 31 8 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 0 31 8 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 0 31 8 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 0 31 8 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1 into ? from t9 where c1= 1" ; diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index fd1b69c0ffd..d9e14374bc5 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -1849,26 +1849,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 128 31 63 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 128 31 63 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 128 31 63 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 128 31 63 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 128 31 63 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 128 31 63 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 128 31 63 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 128 31 63 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday select @arg01:= c1, @arg02:= c2, @arg03:= c3, @arg04:= c4, @@ -1896,26 +1896,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 128 31 63 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 128 31 63 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 128 31 63 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 128 31 63 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 128 31 63 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 128 31 63 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 128 31 63 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 128 31 63 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select @@ -1946,26 +1946,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 128 31 63 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 128 31 63 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 128 31 63 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 128 31 63 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 128 31 63 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 128 31 63 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 128 31 63 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 128 31 63 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday set @my_key= 0 ; @@ -1986,26 +1986,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 128 31 63 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 128 31 63 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 128 31 63 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 128 31 63 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 128 31 63 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 128 31 63 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 128 31 63 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 128 31 63 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select ? := c1 from t9 where c1= 1" ; @@ -2034,26 +2034,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 128 31 63 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 128 31 63 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 128 31 63 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 128 31 63 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 128 31 63 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 128 31 63 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 128 31 63 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 128 31 63 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -2078,26 +2078,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 128 31 63 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 128 31 63 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 128 31 63 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 128 31 63 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 128 31 63 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 128 31 63 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 128 31 63 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 128 31 63 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -2124,26 +2124,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 128 31 63 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 128 31 63 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 128 31 63 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 128 31 63 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 128 31 63 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 128 31 63 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 128 31 63 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 128 31 63 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday set @my_key= 0 ; @@ -2162,26 +2162,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 128 31 63 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 128 31 63 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 128 31 63 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 128 31 63 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 128 31 63 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 128 31 63 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 128 31 63 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 128 31 63 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1 into ? from t9 where c1= 1" ; @@ -4871,26 +4871,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 128 31 63 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 128 31 63 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 128 31 63 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 128 31 63 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 128 31 63 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 128 31 63 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 128 31 63 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 128 31 63 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday select @arg01:= c1, @arg02:= c2, @arg03:= c3, @arg04:= c4, @@ -4918,26 +4918,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 128 31 63 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 128 31 63 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 128 31 63 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 128 31 63 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 128 31 63 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 128 31 63 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 128 31 63 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 128 31 63 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select @@ -4968,26 +4968,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 128 31 63 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 128 31 63 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 128 31 63 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 128 31 63 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 128 31 63 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 128 31 63 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 128 31 63 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 128 31 63 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday set @my_key= 0 ; @@ -5008,26 +5008,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 128 31 63 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 128 31 63 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 128 31 63 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 128 31 63 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 128 31 63 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 128 31 63 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 128 31 63 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 128 31 63 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select ? := c1 from t9 where c1= 1" ; @@ -5056,26 +5056,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 128 31 63 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 128 31 63 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 128 31 63 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 128 31 63 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 128 31 63 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 128 31 63 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 128 31 63 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 128 31 63 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -5100,26 +5100,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 128 31 63 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 128 31 63 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 128 31 63 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 128 31 63 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 128 31 63 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 128 31 63 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 128 31 63 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 128 31 63 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, @@ -5146,26 +5146,26 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 128 30 63 def @arg12 246 83 6 Y 128 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 250 16777215 10 Y 128 31 63 +def @arg14 250 16777215 19 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 8 Y 128 31 63 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 -def @arg20 251 16777216 1 Y 0 31 8 -def @arg21 251 16777216 10 Y 0 31 8 -def @arg22 251 16777216 30 Y 0 31 8 -def @arg23 251 16777216 8 Y 128 31 63 -def @arg24 251 16777216 8 Y 0 31 8 -def @arg25 251 16777216 4 Y 128 31 63 -def @arg26 251 16777216 4 Y 0 31 8 -def @arg27 251 16777216 10 Y 128 31 63 -def @arg28 251 16777216 10 Y 0 31 8 -def @arg29 251 16777216 8 Y 128 31 63 -def @arg30 251 16777216 8 Y 0 31 8 -def @arg31 251 16777216 3 Y 0 31 8 -def @arg32 251 16777216 6 Y 0 31 8 +def @arg20 250 16777215 1 Y 0 31 8 +def @arg21 250 16777215 10 Y 0 31 8 +def @arg22 250 16777215 30 Y 0 31 8 +def @arg23 250 16777215 8 Y 128 31 63 +def @arg24 250 16777215 8 Y 0 31 8 +def @arg25 250 16777215 4 Y 128 31 63 +def @arg26 250 16777215 4 Y 0 31 8 +def @arg27 250 16777215 10 Y 128 31 63 +def @arg28 250 16777215 10 Y 0 31 8 +def @arg29 250 16777215 8 Y 128 31 63 +def @arg30 250 16777215 8 Y 0 31 8 +def @arg31 250 16777215 3 Y 0 31 8 +def @arg32 250 16777215 6 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday set @my_key= 0 ; @@ -5184,26 +5184,26 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 128 30 63 def @arg12 246 83 0 Y 128 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 250 16777215 0 Y 128 31 63 +def @arg14 250 16777215 0 Y 128 31 63 +def @arg15 250 16777215 19 Y 128 31 63 +def @arg16 250 16777215 0 Y 128 31 63 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 -def @arg20 251 16777216 0 Y 0 31 8 -def @arg21 251 16777216 0 Y 0 31 8 -def @arg22 251 16777216 0 Y 0 31 8 -def @arg23 251 16777216 0 Y 128 31 63 -def @arg24 251 16777216 0 Y 0 31 8 -def @arg25 251 16777216 0 Y 128 31 63 -def @arg26 251 16777216 0 Y 0 31 8 -def @arg27 251 16777216 0 Y 128 31 63 -def @arg28 251 16777216 0 Y 0 31 8 -def @arg29 251 16777216 0 Y 128 31 63 -def @arg30 251 16777216 0 Y 0 31 8 -def @arg31 251 16777216 0 Y 0 31 8 -def @arg32 251 16777216 0 Y 0 31 8 +def @arg20 250 16777215 0 Y 0 31 8 +def @arg21 250 16777215 0 Y 0 31 8 +def @arg22 250 16777215 0 Y 0 31 8 +def @arg23 250 16777215 0 Y 128 31 63 +def @arg24 250 16777215 0 Y 0 31 8 +def @arg25 250 16777215 0 Y 128 31 63 +def @arg26 250 16777215 0 Y 0 31 8 +def @arg27 250 16777215 0 Y 128 31 63 +def @arg28 250 16777215 0 Y 0 31 8 +def @arg29 250 16777215 0 Y 128 31 63 +def @arg30 250 16777215 0 Y 0 31 8 +def @arg31 250 16777215 0 Y 0 31 8 +def @arg32 250 16777215 0 Y 0 31 8 @arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL prepare stmt1 from "select c1 into ? from t9 where c1= 1" ; diff --git a/sql/item_func.cc b/sql/item_func.cc index 1b13297c951..999c048d9e9 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4640,7 +4640,7 @@ void Item_func_get_user_var::fix_length_and_dec() decimals=0; break; case STRING_RESULT: - max_length= MAX_BLOB_WIDTH; + max_length= MAX_BLOB_WIDTH - 1; break; case DECIMAL_RESULT: max_length= DECIMAL_MAX_STR_LENGTH; From fbfbe2a6eb4f4b4d950c7c40faa05f135d6f3004 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 17 Aug 2010 22:37:18 +0300 Subject: [PATCH 023/183] Disable all innodb_plugin tests on Solaris until the problem is resolved. Track this via: Bug#56063 InnoDB Plugin mysql-tests fail on Solaris --- mysql-test/collections/default.experimental | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental index f84337660ea..6d29134316d 100644 --- a/mysql-test/collections/default.experimental +++ b/mysql-test/collections/default.experimental @@ -12,6 +12,8 @@ funcs_1.ndb* # joro : NDB tests marked as experiment funcs_2.ndb_charset # joro : NDB tests marked as experimental as agreed with bochklin +innodb_plugin.* @solaris # Bug#56063 InnoDB Plugin mysql-tests fail on Solaris + main.ctype_gbk_binlog @solaris # Bug#46010: main.ctype_gbk_binlog fails sporadically : Table 't2' already exists main.func_str @solaris # joro: Bug#40928 main.plugin_load @solaris # Bug#42144 From d3a7ef991382f41f8d71f83b13280e87fad1b73a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 18 Aug 2010 14:01:10 +0300 Subject: [PATCH 024/183] Bug#55626: MIN and MAX reading a delete-marked record from secondary index Remove a bogus debug assertion that triggered the bug. Add assertions precisely where records must not be delete-marked. And a comment to clarify when the record is allowed to be delete-marked. --- storage/innodb_plugin/row/row0sel.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/storage/innodb_plugin/row/row0sel.c b/storage/innodb_plugin/row/row0sel.c index 76c144e5a8c..aff36b65124 100644 --- a/storage/innodb_plugin/row/row0sel.c +++ b/storage/innodb_plugin/row/row0sel.c @@ -2690,7 +2690,6 @@ row_sel_store_mysql_rec( ut_ad(prebuilt->mysql_template); ut_ad(prebuilt->default_rec); ut_ad(rec_offs_validate(rec, NULL, offsets)); - ut_ad(!rec_get_deleted_flag(rec, rec_offs_comp(offsets))); if (UNIV_LIKELY_NULL(prebuilt->blob_heap)) { mem_heap_free(prebuilt->blob_heap); @@ -3611,6 +3610,7 @@ row_search_for_mysql( row_sel_try_search_shortcut_for_mysql(). The latch will not be released until mtr_commit(&mtr). */ + ut_ad(!rec_get_deleted_flag(rec, comp)); if (!row_sel_store_mysql_rec(buf, prebuilt, rec, offsets)) { @@ -4238,7 +4238,7 @@ no_gap_lock: rec = old_vers; } - } else if (!lock_sec_rec_cons_read_sees(rec, trx->read_view)) { + } else { /* We are looking into a non-clustered index, and to get the right version of the record we have to look also into the clustered index: this @@ -4246,8 +4246,12 @@ no_gap_lock: information via the clustered index record. */ ut_ad(index != clust_index); + ut_ad(!dict_index_is_clust(index)); - goto requires_clust_rec; + if (!lock_sec_rec_cons_read_sees( + rec, trx->read_view)) { + goto requires_clust_rec; + } } } @@ -4370,8 +4374,13 @@ requires_clust_rec: ULINT_UNDEFINED, &heap); result_rec = rec; } + + /* result_rec can legitimately be delete-marked + now that it has been established that it points to a + clustered index record that exists in the read view. */ } else { result_rec = rec; + ut_ad(!rec_get_deleted_flag(rec, comp)); } /* We found a qualifying record 'result_rec'. At this point, From 73c92b14081461b8fe6d1aac27e7ac812608240c Mon Sep 17 00:00:00 2001 From: Sunny Bains Date: Fri, 20 Aug 2010 12:55:52 +1000 Subject: [PATCH 025/183] Fix bug#55699 - Assertion failure in innodb plugin with large number of threads Fix a debug assertion that was missed in svnrev:2380 (fix for Bug# 35352). Approved by Marko on IRC --- storage/innodb_plugin/trx/trx0undo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/innodb_plugin/trx/trx0undo.c b/storage/innodb_plugin/trx/trx0undo.c index 3bb1b1cdf6c..eb5112c4d31 100644 --- a/storage/innodb_plugin/trx/trx0undo.c +++ b/storage/innodb_plugin/trx/trx0undo.c @@ -1938,7 +1938,8 @@ trx_undo_update_cleanup( UT_LIST_ADD_FIRST(undo_list, rseg->update_undo_cached, undo); } else { - ut_ad(undo->state == TRX_UNDO_TO_PURGE); + ut_ad(undo->state == TRX_UNDO_TO_PURGE + || undo->state == TRX_UNDO_TO_FREE); trx_undo_mem_free(undo); } From eff4a5d202faa088c13a4ea2cc966dfb830ffd18 Mon Sep 17 00:00:00 2001 From: Sunny Bains Date: Fri, 20 Aug 2010 12:57:04 +1000 Subject: [PATCH 026/183] Fix Bug #55027: assertion: mutex_own(&dict_sys->mutex) in dict_table_get_on_id() The callers should indicate that the dictionary is locked or not using the trx->dict_operation_lock_mode == RW_X_LATCH mode. Checking explicitly for system tables is unnecessary. Approved by Marko on IRC. --- storage/innobase/dict/dict0dict.c | 3 +-- storage/innodb_plugin/dict/dict0dict.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c index 9f9c4da46f4..0e323d2bf24 100644 --- a/storage/innobase/dict/dict0dict.c +++ b/storage/innobase/dict/dict0dict.c @@ -616,8 +616,7 @@ dict_table_get_on_id( { dict_table_t* table; - if (ut_dulint_cmp(table_id, DICT_FIELDS_ID) <= 0 - || trx->dict_operation_lock_mode == RW_X_LATCH) { + if (trx->dict_operation_lock_mode == RW_X_LATCH) { /* Note: An X latch implies that the transaction already owns the dictionary mutex. */ diff --git a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/dict0dict.c index fe4e058e122..a79f084e327 100644 --- a/storage/innodb_plugin/dict/dict0dict.c +++ b/storage/innodb_plugin/dict/dict0dict.c @@ -568,8 +568,7 @@ dict_table_get_on_id( { dict_table_t* table; - if (ut_dulint_cmp(table_id, DICT_FIELDS_ID) <= 0 - || trx->dict_operation_lock_mode == RW_X_LATCH) { + if (trx->dict_operation_lock_mode == RW_X_LATCH) { /* Note: An X latch implies that the transaction already owns the dictionary mutex. */ From 54fd56c5c3298af63e9a72676f2105e1e766911c Mon Sep 17 00:00:00 2001 From: Sunny Bains Date: Fri, 20 Aug 2010 17:49:43 +1000 Subject: [PATCH 027/183] Fix Bug #54538 - use of exclusive innodb dictionary lock limits performance. This patch doesn't get rid of the need to acquire the dict_sys->mutex but reduces the need to keep the mutex locked for the duration of the query to fsp_get_available_space_in_free_extents() from ha_innobase::info(). rb://390. --- storage/innobase/fil/fil0fil.c | 104 +++++++++++++++++++++----- storage/innobase/fsp/fsp0fsp.c | 49 ++++++++++++ storage/innobase/handler/ha_innodb.cc | 20 ++--- storage/innobase/include/fil0fil.h | 14 +++- storage/innobase/include/univ.i | 6 ++ 5 files changed, 160 insertions(+), 33 deletions(-) diff --git a/storage/innobase/fil/fil0fil.c b/storage/innobase/fil/fil0fil.c index 3810fefd3cb..6ca8381ebdf 100644 --- a/storage/innobase/fil/fil0fil.c +++ b/storage/innobase/fil/fil0fil.c @@ -966,6 +966,8 @@ try_again: HASH_SEARCH(name_hash, system->name_hash, ut_fold_string(name), space, 0 == strcmp(name, space->name)); if (space != NULL) { + ibool success; + ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Warning: trying to init to the" @@ -1002,9 +1004,10 @@ try_again: namesake_id = space->id; - mutex_exit(&(system->mutex)); + success = fil_space_free(namesake_id, FALSE); + ut_a(success); - fil_space_free(namesake_id); + mutex_exit(&(system->mutex)); goto try_again; } @@ -1127,6 +1130,33 @@ fil_assign_new_space_id(void) return(id); } +/*********************************************************************** +Check if the space id exists in the cache, complain to stderr if the +space id cannot be found. */ +static +fil_space_t* +fil_space_search( +/*=============*/ + /* out: file space instance*/ + ulint id) /* in: space id */ +{ + fil_space_t* space; + + ut_ad(mutex_own(&fil_system->mutex)); + + HASH_SEARCH(hash, fil_system->spaces, id, space, space->id == id); + + if (space == NULL) { + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Error: trying to remove tablespace %lu" + " from the cache but\n" + "InnoDB: it is not there.\n", (ulong) id); + } + + return(space); +} + /*********************************************************************** Frees a space object from the tablespace memory cache. Closes the files in the chain but does not delete them. There must not be any pending i/o's or @@ -1135,27 +1165,21 @@ flushes on the files. */ ibool fil_space_free( /*===========*/ - /* out: TRUE if success */ - ulint id) /* in: space id */ + /* out: TRUE if success */ + ulint id, /* in: space id */ + ibool x_latched) /* in: TRUE if caller has space->latch + in X mode */ { fil_system_t* system = fil_system; fil_space_t* space; fil_space_t* namespace; fil_node_t* fil_node; - mutex_enter(&(system->mutex)); + ut_ad(mutex_own(&fil_system->mutex)); - HASH_SEARCH(hash, system->spaces, id, space, space->id == id); - - if (!space) { - ut_print_timestamp(stderr); - fprintf(stderr, - " InnoDB: Error: trying to remove tablespace %lu" - " from the cache but\n" - "InnoDB: it is not there.\n", (ulong) id); - - mutex_exit(&(system->mutex)); + space = fil_space_search(id); + if (space == NULL) { return(FALSE); } @@ -1191,7 +1215,9 @@ fil_space_free( ut_a(0 == UT_LIST_GET_LEN(space->chain)); - mutex_exit(&(system->mutex)); + if (x_latched) { + rw_lock_x_unlock(&space->latch); + } rw_lock_free(&(space->latch)); @@ -2048,6 +2074,19 @@ try_again: path = mem_strdup(space->name); mutex_exit(&(system->mutex)); + + /* Important: We rely on the data dictionary mutex to ensure + that a race is not possible here. It should serialize the tablespace + drop/free. We acquire an X latch only to avoid a race condition + when accessing the tablespace instance via: + + fsp_get_available_space_in_free_extents(). + + There our main motivation is to reduce the contention on the + dictionary mutex and not correctness. */ + + rw_lock_x_lock(&space->latch); + #ifndef UNIV_HOTBACKUP /* Invalidate in the buffer pool all pages belonging to the tablespace. Since we have set space->is_being_deleted = TRUE, readahead @@ -2060,7 +2099,11 @@ try_again: #endif /* printf("Deleting tablespace %s id %lu\n", space->name, id); */ - success = fil_space_free(id); + mutex_enter(&system->mutex); + + success = fil_space_free(id, TRUE); + + mutex_exit(&system->mutex); if (success) { success = os_file_delete(path); @@ -2068,6 +2111,8 @@ try_again: if (!success) { success = os_file_delete_if_exists(path); } + } else { + rw_lock_x_unlock(&space->latch); } if (success) { @@ -4569,3 +4614,28 @@ fil_page_get_type( return(mach_read_from_2(page + FIL_PAGE_TYPE)); } + +/*********************************************************************** +Returns TRUE if a single-table tablespace is being deleted. */ + +ibool +fil_tablespace_is_being_deleted( +/*============================*/ + /* out: TRUE if space is being deleted */ + ulint id) /* in: space id */ +{ + fil_space_t* space; + ibool is_being_deleted; + + mutex_enter(&fil_system->mutex); + + HASH_SEARCH(hash, fil_system->spaces, id, space, space->id == id); + + ut_a(space != NULL); + + is_being_deleted = space->is_being_deleted; + + mutex_exit(&fil_system->mutex); + + return(is_being_deleted); +} diff --git a/storage/innobase/fsp/fsp0fsp.c b/storage/innobase/fsp/fsp0fsp.c index 1ec1c262a52..1f033c4b140 100644 --- a/storage/innobase/fsp/fsp0fsp.c +++ b/storage/innobase/fsp/fsp0fsp.c @@ -2842,12 +2842,61 @@ fsp_get_available_space_in_free_extents( ut_ad(!mutex_own(&kernel_mutex)); + /* The convoluted mutex acquire is to overcome latching order + issues: The problem is that the fil_mutex is at a lower level + than the tablespace latch and the buffer pool mutex. We have to + first prevent any operations on the file system by acquiring the + dictionary mutex. Then acquire the tablespace latch to obey the + latching order and then release the dictionary mutex. That way we + ensure that the tablespace instance can't be freed while we are + examining its contents (see fil_space_free()). + + However, there is one further complication, we release the fil_mutex + when we need to invalidate the the pages in the buffer pool and we + reacquire the fil_mutex when deleting and freeing the tablespace + instance in fil0fil.c. Here we need to account for that situation + too. */ + + dict_mutex_enter_for_mysql(); + + /* At this stage there is no guarantee that the tablespace even + exists in the cache. */ + + if (fil_tablespace_deleted_or_being_deleted_in_mem(space, -1)) { + + dict_mutex_exit_for_mysql(); + + return(ULLINT_UNDEFINED); + } + mtr_start(&mtr); latch = fil_space_get_latch(space); + /* This should ensure that the tablespace instance can't be freed + by another thread. However, the tablespace pages can still be freed + from the buffer pool. We need to check for that again. */ + mtr_x_lock(latch, &mtr); + dict_mutex_exit_for_mysql(); + + /* At this point it is possible for the tablespace to be deleted and + its pages removed from the buffer pool. We need to check for that + situation. However, the tablespace instance can't be deleted because + our latching above should ensure that. */ + + if (fil_tablespace_is_being_deleted(space)) { + + mtr_commit(&mtr); + + return(ULLINT_UNDEFINED); + } + + /* From here on even if the user has dropped the tablespace, the + pages _must_ still exist in the buffer pool and the tablespace + instance _must be in the file system hash table. */ + space_header = fsp_get_space_header(space, &mtr); size = mtr_read_ulint(space_header + FSP_SIZE, MLOG_4BYTES, &mtr); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 991b3a394d7..38394544c87 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -6485,20 +6485,12 @@ ha_innobase::info( so the "old" value can remain. delete_length is initialized to 0 in the ha_statistics' constructor. */ if (!(flag & HA_STATUS_NO_LOCK)) { + ullint avail_space; - /* lock the data dictionary to avoid races with - ibd_file_missing and tablespace_discarded */ - row_mysql_lock_data_dictionary(prebuilt->trx); - - /* ib_table->space must be an existent tablespace */ - if (!ib_table->ibd_file_missing - && !ib_table->tablespace_discarded) { - - stats.delete_length = - fsp_get_available_space_in_free_extents( - ib_table->space) * 1024; - } else { + avail_space = fsp_get_available_space_in_free_extents( + ib_table->space); + if (avail_space == ULLINT_UNDEFINED) { THD* thd; thd = ha_thd(); @@ -6515,9 +6507,9 @@ ha_innobase::info( ib_table->name); stats.delete_length = 0; + } else { + stats.delete_length = avail_space * 1024; } - - row_mysql_unlock_data_dictionary(prebuilt->trx); } stats.check_time = 0; diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 251d6c22547..7e85a0b412b 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -202,8 +202,10 @@ the chain but does not delete them. */ ibool fil_space_free( /*===========*/ - /* out: TRUE if success */ - ulint id); /* in: space id */ + /* out: TRUE if success */ + ulint id, /* in: space id */ + ibool x_latched); /* in: TRUE if caller has space->latch + in X mode */ /*********************************************************************** Returns the size of the space in pages. The tablespace must be cached in the memory cache. */ @@ -710,6 +712,14 @@ fil_page_get_type( written to page, the return value not defined */ byte* page); /* in: file page */ +/*********************************************************************** +Returns TRUE if a single-table tablespace is being deleted. */ + +ibool +fil_tablespace_is_being_deleted( +/*============================*/ + /* out: TRUE if space is being deleted */ + ulint id); /* in: space id */ typedef struct fil_space_struct fil_space_t; diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 97d022d284e..ce5d8a092bf 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -234,6 +234,12 @@ typedef unsigned long long int ullint; /* Maximum value for a ulint */ #define ULINT_MAX ((ulint)(-2)) +/* THe 'undefined' value for ullint */ +#define ULLINT_UNDEFINED ((ullint)(-1)) + +/* Maximum value for a ullint */ +#define ULLINT_MAX ((ullint)(-2)) + /* This 'ibool' type is used within Innobase. Remember that different included headers may define 'bool' differently. Do not assume that 'bool' is a ulint! */ #define ibool ulint From 3b36a677ba839448a25b4e4f90a1bf1caf99bb76 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 20 Aug 2010 11:52:16 +0300 Subject: [PATCH 028/183] Bug #55826: create table .. select crashes with when KILL_BAD_DATA is returned Two problems discovered with the LEAST()/GREATEST() functions: 1. The check for a null value should happen even after the second call to val_str() in the args. This is important because two subsequent calls to the same Item::val_str() may yield different results. Fixed by checking for NULL value before dereferencing the string result. 2. While looping over the arguments and evaluating them the loop should stop if there was an error evaluating so far or the statement was killed. Fixed by checking for error and bailing out. --- mysql-test/suite/innodb/r/innodb_mysql.result | 13 +++++++++++++ mysql-test/suite/innodb/t/innodb_mysql.test | 15 +++++++++++++++ sql/item_func.cc | 16 +++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result index 8765f58b120..cb0e2a35e34 100644 --- a/mysql-test/suite/innodb/r/innodb_mysql.result +++ b/mysql-test/suite/innodb/r/innodb_mysql.result @@ -2507,4 +2507,17 @@ LOCK TABLES t1 READ; ALTER TABLE t1 COMMENT 'test'; UNLOCK TABLES; DROP TABLE t1; +# +# Bug#55826: create table .. select crashes with when KILL_BAD_DATA +# is returned +# +CREATE TABLE t1(a INT) ENGINE=innodb; +INSERT INTO t1 VALUES (0); +SET SQL_MODE='STRICT_ALL_TABLES'; +CREATE TABLE t2 +SELECT LEAST((SELECT '' FROM t1),NOW()) FROM `t1`; +ERROR 22007: Incorrect datetime value: '' for column 'NOW()' at row 1 +DROP TABLE t1,t2; +ERROR 42S02: Unknown table 't2' +SET SQL_MODE=DEFAULT; End of 5.1 tests diff --git a/mysql-test/suite/innodb/t/innodb_mysql.test b/mysql-test/suite/innodb/t/innodb_mysql.test index 80f14d32eb8..c8acc6813e8 100644 --- a/mysql-test/suite/innodb/t/innodb_mysql.test +++ b/mysql-test/suite/innodb/t/innodb_mysql.test @@ -751,4 +751,19 @@ UNLOCK TABLES; DROP TABLE t1; +--echo # +--echo # Bug#55826: create table .. select crashes with when KILL_BAD_DATA +--echo # is returned +--echo # + +CREATE TABLE t1(a INT) ENGINE=innodb; +INSERT INTO t1 VALUES (0); +SET SQL_MODE='STRICT_ALL_TABLES'; +--error ER_TRUNCATED_WRONG_VALUE +CREATE TABLE t2 + SELECT LEAST((SELECT '' FROM t1),NOW()) FROM `t1`; +DROP TABLE t1,t2; +SET SQL_MODE=DEFAULT; + + --echo End of 5.1 tests diff --git a/sql/item_func.cc b/sql/item_func.cc index eecdc801512..f022a218889 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2263,7 +2263,7 @@ void Item_func_min_max::fix_length_and_dec() stored to the value pointer, if latter is provided. RETURN - 0 If one of arguments is NULL + 0 If one of arguments is NULL or there was a execution error # index of the least/greatest argument */ @@ -2277,6 +2277,14 @@ uint Item_func_min_max::cmp_datetimes(ulonglong *value) Item **arg= args + i; bool is_null; longlong res= get_datetime_value(thd, &arg, 0, datetime_item, &is_null); + + /* Check if we need to stop (because of error or KILL) and stop the loop */ + if (thd->is_error()) + { + null_value= 1; + return 0; + } + if ((null_value= args[i]->null_value)) return 0; if (i == 0 || (res < min_max ? cmp_sign : -cmp_sign) > 0) @@ -2305,6 +2313,12 @@ String *Item_func_min_max::val_str(String *str) if (null_value) return 0; str_res= args[min_max_idx]->val_str(str); + if (args[min_max_idx]->null_value) + { + // check if the call to val_str() above returns a NULL value + null_value= 1; + return NULL; + } str_res->set_charset(collation.collation); return str_res; } From 109893dac0597b5114188ce257e469ad9f85110e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 23 Aug 2010 13:28:54 +0300 Subject: [PATCH 029/183] Bug#55832: selects crash too easily when innodb_force_recovery>3 dict_update_statistics_low(): Create bogus statistics for those indexes that cannot be accessed because of the innodb_force_recovery setting. ha_innobase::info(): Calculate statistics for each index, even if innodb_force_recovery is set. Fill in bogus data for those indexes that are not accessed because of the innodb_force_recovery setting. --- storage/innobase/dict/dict0dict.c | 57 ++++++++++++++++----------- storage/innobase/handler/ha_innodb.cc | 38 ++++++++++-------- 2 files changed, 56 insertions(+), 39 deletions(-) diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c index 0e323d2bf24..b52a94c3348 100644 --- a/storage/innobase/dict/dict0dict.c +++ b/storage/innobase/dict/dict0dict.c @@ -3753,7 +3753,6 @@ dict_update_statistics_low( dictionary mutex */ { dict_index_t* index; - ulint size; ulint sum_of_index_sizes = 0; if (table->ibd_file_missing) { @@ -3769,14 +3768,6 @@ dict_update_statistics_low( return; } - /* If we have set a high innodb_force_recovery level, do not calculate - statistics, as a badly corrupted index can cause a crash in it. */ - - if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { - - return; - } - /* Find out the sizes of the indexes and how many different values for the key they approximately have */ @@ -3788,26 +3779,48 @@ dict_update_statistics_low( return; } - while (index) { - size = btr_get_size(index, BTR_TOTAL_SIZE); - index->stat_index_size = size; + do { + if (UNIV_LIKELY + (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE + || (srv_force_recovery < SRV_FORCE_NO_LOG_REDO + && (index->type & DICT_CLUSTERED)))) { + ulint size; + size = btr_get_size(index, BTR_TOTAL_SIZE); - sum_of_index_sizes += size; + index->stat_index_size = size; - size = btr_get_size(index, BTR_N_LEAF_PAGES); + sum_of_index_sizes += size; - if (size == 0) { - /* The root node of the tree is a leaf */ - size = 1; + size = btr_get_size(index, BTR_N_LEAF_PAGES); + + if (size == 0) { + /* The root node of the tree is a leaf */ + size = 1; + } + + index->stat_n_leaf_pages = size; + + btr_estimate_number_of_different_key_vals(index); + } else { + /* If we have set a high innodb_force_recovery + level, do not calculate statistics, as a badly + corrupted index can cause a crash in it. + Initialize some bogus index cardinality + statistics, so that the data can be queried in + various means, also via secondary indexes. */ + ulint i; + + sum_of_index_sizes++; + index->stat_index_size = index->stat_n_leaf_pages = 1; + + for (i = dict_index_get_n_unique(index); i; ) { + index->stat_n_diff_key_vals[i--] = 1; + } } - index->stat_n_leaf_pages = size; - - btr_estimate_number_of_different_key_vals(index); - index = dict_table_get_next_index(index); - } + } while (index); index = dict_table_get_first_index(table); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 38394544c87..4688b5fd16c 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -6365,8 +6365,6 @@ ha_innobase::info( dict_index_t* index; ha_rows rec_per_key; ib_longlong n_rows; - ulong j; - ulong i; char path[FN_REFLEN]; os_file_stat_t stat_info; @@ -6376,16 +6374,6 @@ ha_innobase::info( statistics calculation on tables, because that may crash the server if an index is badly corrupted. */ - if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { - - /* We return success (0) instead of HA_ERR_CRASHED, - because we want MySQL to process this query and not - stop, like it would do if it received the error code - HA_ERR_CRASHED. */ - - DBUG_RETURN(0); - } - /* We do not know if MySQL can call this function before calling external_lock(). To be safe, update the thd of the current table handle. */ @@ -6480,11 +6468,18 @@ ha_innobase::info( acquiring latches inside InnoDB, we do not call it if we are asked by MySQL to avoid locking. Another reason to avoid the call is that it uses quite a lot of CPU. - See Bug#38185. - We do not update delete_length if no locking is requested - so the "old" value can remain. delete_length is initialized - to 0 in the ha_statistics' constructor. */ - if (!(flag & HA_STATUS_NO_LOCK)) { + See Bug#38185. */ + if (flag & HA_STATUS_NO_LOCK) { + /* We do not update delete_length if no + locking is requested so the "old" value can + remain. delete_length is initialized to 0 in + the ha_statistics' constructor. */ + } else if (UNIV_UNLIKELY + (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE)) { + /* Avoid accessing the tablespace if + innodb_crash_recovery is set to a high value. */ + stats.delete_length = 0; + } else { ullint avail_space; avail_space = fsp_get_available_space_in_free_extents( @@ -6522,6 +6517,7 @@ ha_innobase::info( } if (flag & HA_STATUS_CONST) { + ulong i = 0; index = dict_table_get_first_index_noninline(ib_table); if (prebuilt->clust_index_was_generated) { @@ -6529,6 +6525,8 @@ ha_innobase::info( } for (i = 0; i < table->s->keys; i++) { + ulong j; + if (index == NULL) { sql_print_error("Table %s contains fewer " "indexes inside InnoDB than " @@ -6585,6 +6583,11 @@ ha_innobase::info( } } + if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { + + goto func_exit; + } + if (flag & HA_STATUS_ERRKEY) { ut_a(prebuilt->trx); ut_a(prebuilt->trx->magic_n == TRX_MAGIC_N); @@ -6597,6 +6600,7 @@ ha_innobase::info( stats.auto_increment_value = innobase_peek_autoinc(); } +func_exit: prebuilt->trx->op_info = (char*)""; DBUG_RETURN(0); From ce7d6a288ca40e8a5e253c5c2e7084cfc985534c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 24 Aug 2010 11:10:03 +0300 Subject: [PATCH 030/183] Bug#55832: selects crash too easily when innodb_force_recovery>3 dict_update_statistics_low(): Create bogus statistics for those indexes that cannot be accessed because of the innodb_force_recovery setting. ha_innobase::info(): Calculate statistics for each index, even if innodb_force_recovery is set. Fill in bogus data for those indexes that are not accessed because of the innodb_force_recovery setting. --- storage/innodb_plugin/ChangeLog | 5 ++ storage/innodb_plugin/dict/dict0dict.c | 57 +++++++++++++--------- storage/innodb_plugin/handler/ha_innodb.cc | 39 +++++++-------- 3 files changed, 60 insertions(+), 41 deletions(-) diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index 9fe5c1e7ee6..538cd40dd5b 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,8 @@ +2010-08-24 The InnoDB Team + + * handler/ha_innodb.c, dict/dict0dict.c: + Fix Bug #55832 selects crash too easily when innodb_force_recovery>3 + 2010-08-03 The InnoDB Team * include/ut0mem.h, ut/ut0mem.c: diff --git a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/dict0dict.c index a79f084e327..560534345f9 100644 --- a/storage/innodb_plugin/dict/dict0dict.c +++ b/storage/innodb_plugin/dict/dict0dict.c @@ -4191,7 +4191,6 @@ dict_update_statistics_low( dictionary mutex */ { dict_index_t* index; - ulint size; ulint sum_of_index_sizes = 0; if (table->ibd_file_missing) { @@ -4206,14 +4205,6 @@ dict_update_statistics_low( return; } - /* If we have set a high innodb_force_recovery level, do not calculate - statistics, as a badly corrupted index can cause a crash in it. */ - - if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { - - return; - } - /* Find out the sizes of the indexes and how many different values for the key they approximately have */ @@ -4225,26 +4216,48 @@ dict_update_statistics_low( return; } - while (index) { - size = btr_get_size(index, BTR_TOTAL_SIZE); - index->stat_index_size = size; + do { + if (UNIV_LIKELY + (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE + || (srv_force_recovery < SRV_FORCE_NO_LOG_REDO + && dict_index_is_clust(index)))) { + ulint size; + size = btr_get_size(index, BTR_TOTAL_SIZE); - sum_of_index_sizes += size; + index->stat_index_size = size; - size = btr_get_size(index, BTR_N_LEAF_PAGES); + sum_of_index_sizes += size; - if (size == 0) { - /* The root node of the tree is a leaf */ - size = 1; + size = btr_get_size(index, BTR_N_LEAF_PAGES); + + if (size == 0) { + /* The root node of the tree is a leaf */ + size = 1; + } + + index->stat_n_leaf_pages = size; + + btr_estimate_number_of_different_key_vals(index); + } else { + /* If we have set a high innodb_force_recovery + level, do not calculate statistics, as a badly + corrupted index can cause a crash in it. + Initialize some bogus index cardinality + statistics, so that the data can be queried in + various means, also via secondary indexes. */ + ulint i; + + sum_of_index_sizes++; + index->stat_index_size = index->stat_n_leaf_pages = 1; + + for (i = dict_index_get_n_unique(index); i; ) { + index->stat_n_diff_key_vals[i--] = 1; + } } - index->stat_n_leaf_pages = size; - - btr_estimate_number_of_different_key_vals(index); - index = dict_table_get_next_index(index); - } + } while (index); index = dict_table_get_first_index(table); diff --git a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc index a70921806b4..c7474109d4f 100644 --- a/storage/innodb_plugin/handler/ha_innodb.cc +++ b/storage/innodb_plugin/handler/ha_innodb.cc @@ -7511,28 +7511,15 @@ ha_innobase::info( dict_index_t* index; ha_rows rec_per_key; ib_int64_t n_rows; - ulong j; - ulong i; char path[FN_REFLEN]; os_file_stat_t stat_info; - DBUG_ENTER("info"); /* If we are forcing recovery at a high level, we will suppress statistics calculation on tables, because that may crash the server if an index is badly corrupted. */ - if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { - - /* We return success (0) instead of HA_ERR_CRASHED, - because we want MySQL to process this query and not - stop, like it would do if it received the error code - HA_ERR_CRASHED. */ - - DBUG_RETURN(0); - } - /* We do not know if MySQL can call this function before calling external_lock(). To be safe, update the thd of the current table handle. */ @@ -7627,12 +7614,18 @@ ha_innobase::info( acquiring latches inside InnoDB, we do not call it if we are asked by MySQL to avoid locking. Another reason to avoid the call is that it uses quite a lot of CPU. - See Bug#38185. - We do not update delete_length if no locking is requested - so the "old" value can remain. delete_length is initialized - to 0 in the ha_statistics' constructor. */ - if (!(flag & HA_STATUS_NO_LOCK)) { - + See Bug#38185. */ + if (flag & HA_STATUS_NO_LOCK) { + /* We do not update delete_length if no + locking is requested so the "old" value can + remain. delete_length is initialized to 0 in + the ha_statistics' constructor. */ + } else if (UNIV_UNLIKELY + (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE)) { + /* Avoid accessing the tablespace if + innodb_crash_recovery is set to a high value. */ + stats.delete_length = 0; + } else { /* lock the data dictionary to avoid races with ibd_file_missing and tablespace_discarded */ row_mysql_lock_data_dictionary(prebuilt->trx); @@ -7677,6 +7670,7 @@ ha_innobase::info( } if (flag & HA_STATUS_CONST) { + ulong i; /* Verify the number of index in InnoDB and MySQL matches up. If prebuilt->clust_index_was_generated holds, InnoDB defines GEN_CLUST_INDEX internally */ @@ -7693,6 +7687,7 @@ ha_innobase::info( } for (i = 0; i < table->s->keys; i++) { + ulong j; /* We could get index quickly through internal index mapping with the index translation table. The identity of index (match up index name with @@ -7758,6 +7753,11 @@ ha_innobase::info( } } + if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { + + goto func_exit; + } + if (flag & HA_STATUS_ERRKEY) { const dict_index_t* err_index; @@ -7778,6 +7778,7 @@ ha_innobase::info( stats.auto_increment_value = innobase_peek_autoinc(); } +func_exit: prebuilt->trx->op_info = (char*)""; DBUG_RETURN(0); From b3713993442461c92a51d642de79befe7d93401c Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Tue, 24 Aug 2010 11:18:48 +0200 Subject: [PATCH 031/183] Fixed tree name. --- .bzr-mysql/default.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf index 7d0379c08a0..c3fcbcf6acd 100644 --- a/.bzr-mysql/default.conf +++ b/.bzr-mysql/default.conf @@ -1,4 +1,4 @@ [MYSQL] post_commit_to = "commits@lists.mysql.com" post_push_to = "commits@lists.mysql.com" -tree_name = "mysql-5.5-bugfixing" +tree_name = "mysql-5.5-runtime" From 0e74ac50285b15fae7fda70a809c9b42027e88c2 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Tue, 24 Aug 2010 14:35:48 +0400 Subject: [PATCH 032/183] Bug #55568: user variable assignments crash server when used within query The server could crash after materializing a derived table which requires a temporary table for grouping. When destroying the temporary table used to execute a query for a derived table, JOIN::destroy() did not clean up Item_fields pointing to fields in the temporary table. This led to dereferencing a dangling pointer when printing out the items tree later in the outer SELECT. The solution is an addendum to the patch for bug37362: in addition to cleaning up items in tmp_all_fields3, do the same for items in tmp_all_fields1, since now we have an example where this is necessary. --- mysql-test/r/join.result | 51 ++++++++++++++++++++++++++++++++++++++++ mysql-test/t/join.test | 46 ++++++++++++++++++++++++++++++++++++ sql/field.cc | 2 +- sql/sql_select.cc | 22 +++++++++++------ sql/sql_select.h | 1 + 5 files changed, 114 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index c60c6bfb3c8..c3c292b2106 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -1184,4 +1184,55 @@ NULL NULL 1 DROP TABLE t1, t2, mm1; +# +# Bug #55568: user variable assignments crash server when used within +# query +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +SELECT MULTIPOINT( +1, +( +SELECT MULTIPOINT( +MULTIPOINT( +1, +(SELECT COUNT(*) FROM (SELECT 1 FROM t1 GROUP BY a,a) d) +) +) FROM t1 +) +) != COUNT(*) q FROM t1 GROUP BY a; +q +NULL +NULL +SELECT MULTIPOINT( +1, +( +SELECT MULTIPOINT( +MULTIPOINT( +1, +(SELECT COUNT(*) FROM (SELECT 1 FROM t1 GROUP BY a,a) d) +) +) FROM t1 +) +) != COUNT(*) q FROM t1 GROUP BY a; +q +NULL +NULL +DROP TABLE t1; +# +# Bug #54468: crash after item's print() function when ordering/grouping +# by subquery +# +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (), (); +SELECT 1 FROM t1 +GROUP BY +GREATEST(t1.a, +(SELECT 1 FROM +(SELECT t1.b FROM t1,t1 t2 +ORDER BY t1.a, t1.a LIMIT 1) AS d) +); +1 +1 +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index 43b373c9703..6969be6fdc4 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -851,4 +851,50 @@ ENGINE=MERGE UNION=(t1,t2); SELECT t1.a FROM mm1,t1; DROP TABLE t1, t2, mm1; +--echo # +--echo # Bug #55568: user variable assignments crash server when used within +--echo # query +--echo # + +CREATE TABLE t1 (a INT); + +INSERT INTO t1 VALUES (0), (1); + +let $i=2; +while ($i) +{ + SELECT MULTIPOINT( + 1, + ( + SELECT MULTIPOINT( + MULTIPOINT( + 1, + (SELECT COUNT(*) FROM (SELECT 1 FROM t1 GROUP BY a,a) d) + ) + ) FROM t1 + ) + ) != COUNT(*) q FROM t1 GROUP BY a; + dec $i; +} + +DROP TABLE t1; + +--echo # +--echo # Bug #54468: crash after item's print() function when ordering/grouping +--echo # by subquery +--echo # + +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (), (); + +SELECT 1 FROM t1 +GROUP BY +GREATEST(t1.a, + (SELECT 1 FROM + (SELECT t1.b FROM t1,t1 t2 + ORDER BY t1.a, t1.a LIMIT 1) AS d) + ); + +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/sql/field.cc b/sql/field.cc index c887a5f1c9b..619e6a780da 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1535,7 +1535,7 @@ void Field::make_field(Send_field *field) } else field->org_table_name= field->db_name= ""; - if (orig_table) + if (orig_table && orig_table->alias) { field->table_name= orig_table->alias; field->org_col_name= field_name; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 2fc287bbe66..fc137f5fd90 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2378,13 +2378,8 @@ JOIN::destroy() cleanup(1); /* Cleanup items referencing temporary table columns */ - if (!tmp_all_fields3.is_empty()) - { - List_iterator_fast it(tmp_all_fields3); - Item *item; - while ((item= it++)) - item->cleanup(); - } + cleanup_item_list(tmp_all_fields1); + cleanup_item_list(tmp_all_fields3); if (exec_tmp_table1) free_tmp_table(thd, exec_tmp_table1); if (exec_tmp_table2) @@ -2395,6 +2390,19 @@ JOIN::destroy() DBUG_RETURN(error); } + +void JOIN::cleanup_item_list(List &items) const +{ + if (!items.is_empty()) + { + List_iterator_fast it(items); + Item *item; + while ((item= it++)) + item->cleanup(); + } +} + + /** An entry point to single-unit select (a select without UNION). diff --git a/sql/sql_select.h b/sql/sql_select.h index b39827ef61b..007dc91957c 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -577,6 +577,7 @@ private: */ bool implicit_grouping; bool make_simple_join(JOIN *join, TABLE *tmp_table); + void cleanup_item_list(List &items) const; }; From a73b734949dde2725ed0bddaceef79c9be581ff8 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Tue, 24 Aug 2010 10:48:45 -0300 Subject: [PATCH 033/183] Bug#55846: Link tests fail on Windows - my_compiler.h missing Make the my_compiler.h header, like my_attribute.h, part of the distribution. This is required due to the dependency of the former on the latter (which can undefine __attribute__). --- include/Makefile.am | 5 +++-- scripts/make_win_bin_dist | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/Makefile.am b/include/Makefile.am index 182011c25a3..08532db1731 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -26,7 +26,8 @@ pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \ decimal.h errmsg.h my_global.h my_net.h \ my_getopt.h sslopt-longopts.h my_dir.h \ sslopt-vars.h sslopt-case.h sql_common.h keycache.h \ - m_ctype.h my_attribute.h $(HEADERS_GEN_CONFIGURE) \ + m_ctype.h my_attribute.h my_compiler.h \ + $(HEADERS_GEN_CONFIGURE) \ $(HEADERS_GEN_MAKE) noinst_HEADERS = config-win.h config-netware.h my_bit.h \ @@ -37,7 +38,7 @@ noinst_HEADERS = config-win.h config-netware.h my_bit.h \ my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \ thr_lock.h t_ctype.h violite.h my_md5.h base64.h \ my_handler.h my_time.h my_vle.h my_user.h \ - my_libwrap.h my_stacktrace.h my_compiler.h + my_libwrap.h my_stacktrace.h EXTRA_DIST = mysql.h.pp mysql/plugin.h.pp diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index a08a41bb283..22970c95ddd 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -263,6 +263,7 @@ cp include/mysql.h \ include/keycache.h \ include/m_ctype.h \ include/my_attribute.h \ + include/my_compiler.h \ include/mysqld_error.h \ include/sql_state.h \ include/mysqld_ername.h \ From 73d767644abf69bd1ac118d58e7f29dcca5c0aac Mon Sep 17 00:00:00 2001 From: Jimmy Yang Date: Tue, 24 Aug 2010 20:42:33 -0700 Subject: [PATCH 034/183] This is to resolve a hang situation in 5.1 builtin raised by bug #49251 (deadlock/crash with concurrent truncate table and index statistics calculation) by backporting a solution from #54678 fixed for 5.1 plugin and 5.5. --- storage/innobase/include/dict0dict.h | 16 ++++++++++ storage/innobase/include/dict0dict.ic | 42 +++++++++++++++++++++++++++ storage/innobase/row/row0mysql.c | 13 +++++++++ 3 files changed, 71 insertions(+) diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index e76f23d0767..369d354c520 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -588,6 +588,22 @@ dict_table_is_comp_noninline( /* out: TRUE if table uses the compact page format */ const dict_table_t* table); /* in: table */ +/*********************************************************************//** +Obtain exclusive locks on all index trees of the table. This is to prevent +accessing index trees while InnoDB is updating internal metadata for +operations such as truncate tables. */ +UNIV_INLINE +void +dict_table_x_lock_indexes( +/*======================*/ + dict_table_t* table); /* in: table */ +/*********************************************************************//** +Release the exclusive locks on all index tree. */ +UNIV_INLINE +void +dict_table_x_unlock_indexes( +/*========================*/ + dict_table_t* table); /* in: table */ /************************************************************************ Checks if a column is in the ordering columns of the clustered index of a table. Column prefixes are treated like whole columns. */ diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic index 7d38cbcd1fa..5cdbdbeb03d 100644 --- a/storage/innobase/include/dict0dict.ic +++ b/storage/innobase/include/dict0dict.ic @@ -298,6 +298,48 @@ dict_table_is_comp( return(UNIV_LIKELY(table->flags & DICT_TF_COMPACT)); } +/*********************************************************************//** +Obtain exclusive locks on all index trees of the table. This is to prevent +accessing index trees while InnoDB is updating internal metadata for +operations such as truncate tables. */ +UNIV_INLINE +void +dict_table_x_lock_indexes( +/*======================*/ + dict_table_t* table) /* in: table */ +{ + dict_index_t* index; + + ut_a(table); + ut_ad(mutex_own(&(dict_sys->mutex))); + + /* Loop through each index of the table and lock them */ + for (index = dict_table_get_first_index(table); + index != NULL; + index = dict_table_get_next_index(index)) { + rw_lock_x_lock(dict_index_get_lock(index)); + } +} + +/*********************************************************************//** +Release the exclusive locks on all index tree. */ +UNIV_INLINE +void +dict_table_x_unlock_indexes( +/*========================*/ + dict_table_t* table) /* in: table */ +{ + dict_index_t* index; + + ut_a(table); + ut_ad(mutex_own(&(dict_sys->mutex))); + + for (index = dict_table_get_first_index(table); + index != NULL; + index = dict_table_get_next_index(index)) { + rw_lock_x_unlock(dict_index_get_lock(index)); + } +} /************************************************************************ Gets the number of fields in the internal representation of an index, including fields added by the dictionary system. */ diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index 3b76ffa76f1..aae4703737b 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -2830,6 +2830,15 @@ row_truncate_table_for_mysql( trx->table_id = table->id; + /* Lock all index trees for this table, as we will + truncate the table/index and possibly change their metadata. + All DML/DDL are blocked by table level lock, with + a few exceptions such as queries into information schema + about the table, MySQL could try to access index stats + for this kind of query, we need to use index locks to + sync up */ + dict_table_x_lock_indexes(table); + /* scan SYS_INDEXES for all indexes of the table */ heap = mem_heap_create(800); @@ -2902,6 +2911,10 @@ next_rec: mem_heap_free(heap); + /* Done with index truncation, release index tree locks, + subsequent work relates to table level metadata change */ + dict_table_x_unlock_indexes(table); + new_id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID); info = pars_info_create(); From df389d0135d65ae7a05e2265fd54c7172dbb9e47 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 25 Aug 2010 19:57:53 +0400 Subject: [PATCH 035/183] Bug#55077: Assertion failed: width > 0 && to != ((void *)0), file .\dtoa.c The assertion failure was correct because the 'width' argument of my_gcvt() has the signed integer type, whereas the unsigned value UINT_MAX32 was being passed by the caller (Field_double::val_str()) leading to a negative width in my_gcvt(). The following chain of problems was found by further analysis: 1. The display width for a floating point number is calculated in Field_double::val_str() as either field_length or the maximum possible length of string representation of a floating point number, whichever is greater. Since in the bug's test case field_length is UINT_MAX32, we get the same value as the display width. This does not make any sense because for numeric values field_length only matters for ZEROFILL columns, otherwise it does not make sense to allocate that much memory just to print a number. Field_float::val_str() has a similar problem. 2. Even if the above wasn't the case, we would still get a crash on a slightly different test case when trying to allocate UINT_MAX32 bytes with String::alloc() because the latter does not handle such large input values correctly due to alignment overflows. 3. Even when String::alloc() is fixed to return an error when an alignment overflow occurs, there is still a problem because almost no callers check its return value, and Field_double::val_str() is not an exception (same for Field_float::val_str()). 4. Even if all of the above wasn't the case, creating a Field_double object with UINT_MAX32 as its field_length does not make much sense either, since the .frm code limits it to MAX_FIELD_CHARLENGTH (255) bytes. Such a beast can only be created by create_tmp_field_from_item() from an Item with REAL_RESULT as its result_type() and UINT_MAX32 as its max_length. 5. For the bug's test case, the above condition (REAL_RESULT Item with max_length = UINT_MAX32) was a result of Item_func_if::fix_length_and_dec() "shortcutting" aggregation of argument types when one of the arguments was a constant NULL. In this case, the attributes of the aggregated type were simply copied from the other, non-NULL argument, but max_length was still calculated as per the general, non-shortcut case, by choosing the greatest of argument's max_length, which is obviously not correct. The patch addresses all of the above problems, even though fixing the assertion failure for the particular test case would require only a subset of the above problems to be solved. --- client/sql_string.cc | 10 ++++++++-- mysql-test/r/func_if.result | 10 ++++++++++ mysql-test/t/func_if.test | 12 ++++++++++++ sql/field.cc | 21 ++++++++++++++++----- sql/item_cmpfunc.cc | 27 +++++++++++++++------------ sql/sql_string.cc | 10 ++++++++-- 6 files changed, 69 insertions(+), 21 deletions(-) diff --git a/client/sql_string.cc b/client/sql_string.cc index 6b749409a64..dec6ac94eb2 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -31,9 +31,12 @@ ** String functions *****************************************************************************/ -bool String::real_alloc(uint32 arg_length) +bool String::real_alloc(uint32 length) { - arg_length=ALIGN_SIZE(arg_length+1); + uint32 arg_length= ALIGN_SIZE(length + 1); + DBUG_ASSERT(arg_length > length); + if (arg_length <= length) + return TRUE; /* Overflow */ str_length=0; if (Alloced_length < arg_length) { @@ -56,6 +59,9 @@ bool String::real_alloc(uint32 arg_length) bool String::realloc(uint32 alloc_length) { uint32 len=ALIGN_SIZE(alloc_length+1); + DBUG_ASSERT(len > alloc_length); + if (len <= alloc_length) + return TRUE; /* Overflow */ if (Alloced_length < len) { char *new_ptr; diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result index 955a784f04c..c70589a27b7 100644 --- a/mysql-test/r/func_if.result +++ b/mysql-test/r/func_if.result @@ -186,3 +186,13 @@ MAX(IFNULL(CAST(c AS UNSIGNED), 0)) 12345678901234567890 DROP TABLE t1; End of 5.0 tests +# +# Bug#55077: Assertion failed: width > 0 && to != ((void *)0), file .\dtoa.c +# +CREATE TABLE t1 (a LONGBLOB, b DOUBLE); +INSERT INTO t1 VALUES (NULL, 0), (NULL, 1); +SELECT IF(b, (SELECT a FROM t1 LIMIT 1), b) c FROM t1 GROUP BY c; +c +NULL +0 +DROP TABLE t1; diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test index 4efea8e195e..91f70bb98d7 100644 --- a/mysql-test/t/func_if.test +++ b/mysql-test/t/func_if.test @@ -165,3 +165,15 @@ DROP TABLE t1; --echo End of 5.0 tests + + +--echo # +--echo # Bug#55077: Assertion failed: width > 0 && to != ((void *)0), file .\dtoa.c +--echo # + +CREATE TABLE t1 (a LONGBLOB, b DOUBLE); +INSERT INTO t1 VALUES (NULL, 0), (NULL, 1); + +SELECT IF(b, (SELECT a FROM t1 LIMIT 1), b) c FROM t1 GROUP BY c; + +DROP TABLE t1; diff --git a/sql/field.cc b/sql/field.cc index fc55426b177..0e55b624633 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4189,6 +4189,7 @@ String *Field_float::val_str(String *val_buffer, String *val_ptr __attribute__((unused))) { ASSERT_COLUMN_MARKED_FOR_READ; + DBUG_ASSERT(field_length <= MAX_FIELD_CHARLENGTH); float nr; #ifdef WORDS_BIGENDIAN if (table->s->db_low_byte_first) @@ -4199,8 +4200,13 @@ String *Field_float::val_str(String *val_buffer, #endif memcpy(&nr, ptr, sizeof(nr)); - uint to_length=max(field_length,70); - val_buffer->alloc(to_length); + uint to_length= 70; + if (val_buffer->alloc(to_length)) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0)); + return val_buffer; + } + char *to=(char*) val_buffer->ptr(); size_t len; @@ -4209,7 +4215,7 @@ String *Field_float::val_str(String *val_buffer, else { /* - We are safe here because the buffer length is >= 70, and + We are safe here because the buffer length is 70, and fabs(float) < 10^39, dec < NOT_FIXED_DEC. So the resulting string will be not longer than 69 chars + terminating '\0'. */ @@ -4506,6 +4512,7 @@ String *Field_double::val_str(String *val_buffer, String *val_ptr __attribute__((unused))) { ASSERT_COLUMN_MARKED_FOR_READ; + DBUG_ASSERT(field_length <= MAX_FIELD_CHARLENGTH); double nr; #ifdef WORDS_BIGENDIAN if (table->s->db_low_byte_first) @@ -4515,9 +4522,13 @@ String *Field_double::val_str(String *val_buffer, else #endif doubleget(nr,ptr); + uint to_length= DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE; + if (val_buffer->alloc(to_length)) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0)); + return val_buffer; + } - uint to_length=max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE); - val_buffer->alloc(to_length); char *to=(char*) val_buffer->ptr(); size_t len; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 641d3726aca..8c0f22b0947 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2560,27 +2560,30 @@ Item_func_if::fix_length_and_dec() cached_result_type= arg2_type; collation.set(args[2]->collation.collation); cached_field_type= args[2]->field_type(); + max_length= args[2]->max_length; + return; } - else if (null2) + + if (null2) { cached_result_type= arg1_type; collation.set(args[1]->collation.collation); cached_field_type= args[1]->field_type(); + max_length= args[1]->max_length; + return; + } + + agg_result_type(&cached_result_type, args + 1, 2); + if (cached_result_type == STRING_RESULT) + { + if (agg_arg_charsets_for_string_result(collation, args + 1, 2)) + return; } else { - agg_result_type(&cached_result_type, args+1, 2); - if (cached_result_type == STRING_RESULT) - { - if (agg_arg_charsets_for_string_result(collation, args + 1, 2)) - return; - } - else - { - collation.set_numeric(); // Number - } - cached_field_type= agg_field_type(args + 1, 2); + collation.set_numeric(); // Number } + cached_field_type= agg_field_type(args + 1, 2); uint32 char_length; if ((cached_result_type == DECIMAL_RESULT ) diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 762eebba031..4b7dab243d2 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -31,9 +31,12 @@ ** String functions *****************************************************************************/ -bool String::real_alloc(uint32 arg_length) +bool String::real_alloc(uint32 length) { - arg_length=ALIGN_SIZE(arg_length+1); + uint32 arg_length= ALIGN_SIZE(length + 1); + DBUG_ASSERT(arg_length > length); + if (arg_length <= length) + return TRUE; /* Overflow */ str_length=0; if (Alloced_length < arg_length) { @@ -56,6 +59,9 @@ bool String::real_alloc(uint32 arg_length) bool String::realloc(uint32 alloc_length) { uint32 len=ALIGN_SIZE(alloc_length+1); + DBUG_ASSERT(len > alloc_length); + if (len <= alloc_length) + return TRUE; /* Overflow */ if (Alloced_length < len) { char *new_ptr; From bbd7277fbef57a3142281b4430776f5f8aede3e8 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Thu, 26 Aug 2010 12:01:43 +0200 Subject: [PATCH 036/183] Bug #44171 KILL ALTER EVENT can crash the server This assert could be triggered if ALTER EVENT failed to load the event after altering it. Failing to load the event could for example happen because of KILL QUERY. The assert tested that the result of a failed load_named_event() was OP_LOAD_ERROR. However since load_named_event() returns bool, this assert did not make any sense. This patch therefore removes the assert, fixing the problem. The patch also removes enum_events_error_code since it was unused. No test case added. The bug fix is trivial and this bug was easily detected by RQG tests. Further, adding a MTR test case for this bug would require adding sync points to make the test case repeatable. --- sql/events.cc | 3 --- sql/events.h | 13 ------------- 2 files changed, 16 deletions(-) diff --git a/sql/events.cc b/sql/events.cc index 10a7535425f..e7e47801586 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -485,10 +485,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, ret= TRUE; // OOM else if ((ret= db_repository->load_named_event(thd, dbname, name, new_element))) - { - DBUG_ASSERT(ret == OP_LOAD_ERROR); delete new_element; - } else { /* diff --git a/sql/events.h b/sql/events.h index 1482e736d29..f3ebc6da4ad 100644 --- a/sql/events.h +++ b/sql/events.h @@ -44,19 +44,6 @@ class THD; typedef class Item COND; typedef struct charset_info_st CHARSET_INFO; -/* Return codes */ -enum enum_events_error_code -{ - OP_OK= 0, - OP_NOT_RUNNING, - OP_CANT_KILL, - OP_CANT_INIT, - OP_DISABLED_EVENT, - OP_LOAD_ERROR, - OP_ALREADY_EXISTS -}; - - int sortcmp_lex_string(LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs); From 6c6a3e8f44a160b6b1a9eac95a08d36d22666679 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Thu, 26 Aug 2010 14:13:02 +0400 Subject: [PATCH 037/183] Bug #53544: Server hangs during JOIN query in stored procedure called twice in a row Queries with nested joins could cause an infinite loop in the server when used from SP/PS. When flattening nested joins, simplify_joins() tracks if the name resolution list needs to be updated by setting fix_name_res to TRUE if the current loop iteration has done any transformations to the join table list. The problem was that the flag was not reset before the next loop iteration leading to unnecessary "fixing" of the name resolution list which in turn could lead to a loop (i.e. circularly-linked part) in that list. This was causing problems on subsequent execution when used together with stored procedures or prepared statements. Fixed by making sure fix_name_res is reset on every loop iteration. --- mysql-test/r/join.result | 20 ++++++++++++++++++++ mysql-test/t/join.test | 20 ++++++++++++++++++++ sql/sql_select.cc | 2 +- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index c3c292b2106..9a8b441b363 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -1235,4 +1235,24 @@ ORDER BY t1.a, t1.a LIMIT 1) AS d) 1 1 DROP TABLE t1; +# +# Bug #53544: Server hangs during JOIN query in stored procedure called +# twice in a row +# +CREATE TABLE t1(c INT); +INSERT INTO t1 VALUES (1), (2); +PREPARE stmt FROM "SELECT t2.c AS f1 FROM t1 LEFT JOIN + t1 t2 ON t1.c=t2.c RIGHT JOIN + t1 t3 ON t1.c=t3.c + GROUP BY f1;"; +EXECUTE stmt; +f1 +1 +2 +EXECUTE stmt; +f1 +1 +2 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index 6969be6fdc4..73a1ae5eb82 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -897,4 +897,24 @@ GREATEST(t1.a, DROP TABLE t1; +--echo # +--echo # Bug #53544: Server hangs during JOIN query in stored procedure called +--echo # twice in a row +--echo # + +CREATE TABLE t1(c INT); + +INSERT INTO t1 VALUES (1), (2); + +PREPARE stmt FROM "SELECT t2.c AS f1 FROM t1 LEFT JOIN + t1 t2 ON t1.c=t2.c RIGHT JOIN + t1 t3 ON t1.c=t3.c + GROUP BY f1;"; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a77c270f709..ed5123817bf 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8885,10 +8885,10 @@ simplify_joins(JOIN *join, List *join_list, COND *conds, bool top) /* Flatten nested joins that can be flattened. */ TABLE_LIST *right_neighbor= NULL; - bool fix_name_res= FALSE; li.rewind(); while ((table= li++)) { + bool fix_name_res= FALSE; nested_join= table->nested_join; if (nested_join && !table->on_expr) { From 72ec16b1d14fa1d4b2339a49d595e4acdf9d9a2b Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Thu, 26 Aug 2010 18:06:07 +0300 Subject: [PATCH 038/183] Increment InnoDB Plugin version to 1.0.12. InnoDB Plugin 1.0.11 has been released with MySQL 5.1.50. --- storage/innodb_plugin/include/univ.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innodb_plugin/include/univ.i b/storage/innodb_plugin/include/univ.i index aa56c18e44e..66b712a0355 100644 --- a/storage/innodb_plugin/include/univ.i +++ b/storage/innodb_plugin/include/univ.i @@ -46,7 +46,7 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 1 #define INNODB_VERSION_MINOR 0 -#define INNODB_VERSION_BUGFIX 11 +#define INNODB_VERSION_BUGFIX 12 /* The following is the InnoDB version as shown in SELECT plugin_version FROM information_schema.plugins; From 50150fd66aff09eb4851d555954d13096647562b Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Thu, 26 Aug 2010 17:14:18 +0200 Subject: [PATCH 039/183] Bug#53806: Wrong estimates for range query in partitioned MyISAM table Bug#46754: 'rows' field doesn't reflect partition pruning The EXPLAIN's result in 'rows' field was evaluated to number of rows when the table was opened (not from the table cache) and only the partitions left after pruning was updated with its correct number of rows. The evaluation of the 'rows' field was using handler::records() which is a potentially expensive call, and ignores the partitioning pruning. The fix was to use the handlers stats.records after updating it with ::info(HA_STATUS_VARIABLE) instead. --- mysql-test/r/partition_pruning.result | 508 ++++++++++++++------------ mysql-test/t/partition_pruning.test | 24 ++ sql/sql_select.cc | 10 +- 3 files changed, 299 insertions(+), 243 deletions(-) diff --git a/mysql-test/r/partition_pruning.result b/mysql-test/r/partition_pruning.result index 568c21b27be..01ae3876fd0 100644 --- a/mysql-test/r/partition_pruning.result +++ b/mysql-test/r/partition_pruning.result @@ -1,5 +1,29 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; # +# Bug#53806: Wrong estimates for range query in partitioned MyISAM table +# Bug#46754: 'rows' field doesn't reflect partition pruning +# +CREATE TABLE t1 (a INT PRIMARY KEY) +PARTITION BY RANGE (a) ( +PARTITION p0 VALUES LESS THAN (1), +PARTITION p1 VALUES LESS THAN (2), +PARTITION p2 VALUES LESS THAN (3), +PARTITION p3 VALUES LESS THAN (4), +PARTITION p4 VALUES LESS THAN (5), +PARTITION p5 VALUES LESS THAN (6), +PARTITION max VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (-1),(0),(1),(2),(3),(4),(5),(6),(7),(8); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1; +id select_type table partitions type possible_keys key key_len ref rows Extra +# # # # # # # # # 3 # +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7; +id select_type table partitions type possible_keys key key_len ref rows Extra +# # # # # # # # # 9 # +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1; +id select_type table partitions type possible_keys key key_len ref rows Extra +# # # # # # # # # 3 # +DROP TABLE t1; +# # Bug#49742: Partition Pruning not working correctly for RANGE # CREATE TABLE t1 (a INT PRIMARY KEY) @@ -89,7 +113,7 @@ a 1 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1 index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p0,p1 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a <= 2; a -1 @@ -98,7 +122,7 @@ a 2 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 2; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2 index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p0,p1,p2 index PRIMARY PRIMARY 4 NULL 4 Using where; Using index SELECT * FROM t1 WHERE a <= 3; a -1 @@ -108,7 +132,7 @@ a 3 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3 index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3 index PRIMARY PRIMARY 4 NULL 5 Using where; Using index SELECT * FROM t1 WHERE a <= 4; a -1 @@ -119,7 +143,7 @@ a 4 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4 index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4 index PRIMARY PRIMARY 4 NULL 6 Using where; Using index SELECT * FROM t1 WHERE a <= 5; a -1 @@ -131,7 +155,7 @@ a 5 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4,p5 index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4,p5 index PRIMARY PRIMARY 4 NULL 7 Using where; Using index SELECT * FROM t1 WHERE a <= 6; a -1 @@ -213,7 +237,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 8 Using where; Using index SELECT * FROM t1 WHERE a >= 2; a 2 @@ -225,7 +249,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 2; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 7 Using where; Using index SELECT * FROM t1 WHERE a >= 3; a 3 @@ -236,7 +260,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 6 Using where; Using index SELECT * FROM t1 WHERE a >= 4; a 4 @@ -246,7 +270,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p4,p5,max index PRIMARY PRIMARY 4 NULL 5 Using where; Using index SELECT * FROM t1 WHERE a >= 5; a 5 @@ -255,7 +279,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p5,max index PRIMARY PRIMARY 4 NULL 4 Using where; Using index SELECT * FROM t1 WHERE a >= 6; a 6 @@ -263,14 +287,14 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a >= 7; a 7 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 7; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a > 1; a 2 @@ -282,7 +306,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 7 Using where; Using index SELECT * FROM t1 WHERE a > 2; a 3 @@ -293,7 +317,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 2; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 6 Using where; Using index SELECT * FROM t1 WHERE a > 3; a 4 @@ -303,7 +327,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p4,p5,max index PRIMARY PRIMARY 4 NULL 5 Using where; Using index SELECT * FROM t1 WHERE a > 4; a 5 @@ -312,7 +336,7 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 p5,max index PRIMARY PRIMARY 4 NULL 4 Using where; Using index SELECT * FROM t1 WHERE a > 5; a 6 @@ -320,20 +344,20 @@ a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a > 6; a 7 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a > 7; a 8 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 7; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index +1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index DROP TABLE t1; CREATE TABLE t1 (a INT PRIMARY KEY) PARTITION BY RANGE (a) ( @@ -408,7 +432,7 @@ a 1 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1 index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 p0,p1 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a <= 2; a -1 @@ -417,7 +441,7 @@ a 2 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 2; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2 index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 p0,p1,p2 index PRIMARY PRIMARY 4 NULL 4 Using where; Using index SELECT * FROM t1 WHERE a <= 3; a -1 @@ -427,7 +451,7 @@ a 3 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3 index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3 index PRIMARY PRIMARY 4 NULL 5 Using where; Using index SELECT * FROM t1 WHERE a <= 4; a -1 @@ -438,7 +462,7 @@ a 4 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1,p2,p3,p4 index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 p0,p1,p2,p3,p4 index PRIMARY PRIMARY 4 NULL 6 Using where; Using index SELECT * FROM t1 WHERE a <= 5; a -1 @@ -511,7 +535,7 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p1,p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 p1,p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 7 Using where; Using index SELECT * FROM t1 WHERE a >= 2; a 2 @@ -522,7 +546,7 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 2; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 6 Using where; Using index SELECT * FROM t1 WHERE a >= 3; a 3 @@ -532,7 +556,7 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 p3,p4,max index PRIMARY PRIMARY 4 NULL 5 Using where; Using index SELECT * FROM t1 WHERE a >= 4; a 4 @@ -541,7 +565,7 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 p4,max index PRIMARY PRIMARY 4 NULL 4 Using where; Using index SELECT * FROM t1 WHERE a >= 5; a 5 @@ -549,14 +573,14 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a >= 6; a 6 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a > 1; a 2 @@ -567,7 +591,7 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 6 Using where; Using index SELECT * FROM t1 WHERE a > 2; a 3 @@ -577,7 +601,7 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 2; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 p3,p4,max index PRIMARY PRIMARY 4 NULL 5 Using where; Using index SELECT * FROM t1 WHERE a > 3; a 4 @@ -586,7 +610,7 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 p4,max index PRIMARY PRIMARY 4 NULL 4 Using where; Using index SELECT * FROM t1 WHERE a > 4; a 5 @@ -594,20 +618,20 @@ a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a > 5; a 6 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index SELECT * FROM t1 WHERE a > 6; a 7 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index +1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index DROP TABLE t1; # test of RANGE and index CREATE TABLE t1 (a DATE, KEY(a)) @@ -757,10 +781,10 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 range a a 4 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p2001-01-01 index a a 4 NULL 7 Using where; Using index +1 SIMPLE t1 pNULL,p2001-01-01 index a a 4 NULL 4 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p2001-01-01 index a a 4 NULL 7 Using where; Using index +1 SIMPLE t1 pNULL,p2001-01-01 index a a 4 NULL 4 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 pNULL ref a a 4 const 1 Using where; Using index @@ -880,34 +904,34 @@ a 1001-01-01 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p2001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL,p2001-01-01 ALL NULL NULL NULL NULL 4 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p1001-01-01 system NULL NULL NULL NULL 1 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL ALL NULL NULL NULL NULL 3 Using where # Disabling warnings for the invalid date EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra @@ -917,25 +941,25 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 ALL NULL NULL NULL NULL 7 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p2001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL,p2001-01-01 ALL NULL NULL NULL NULL 4 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p2001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL,p2001-01-01 ALL NULL NULL NULL NULL 4 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL ALL NULL NULL NULL NULL 3 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 ALL NULL NULL NULL NULL 7 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 ALL NULL NULL NULL NULL 6 Using where DROP TABLE t1; # test of LIST and index CREATE TABLE t1 (a DATE, KEY(a)) @@ -1086,10 +1110,10 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 7 Using where; Using index +1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 7 Using where; Using index +1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 pNULL ref a a 4 const 1 Using where; Using index @@ -1101,7 +1125,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 4 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p1001-01-01 index a a 4 NULL 7 Using where; Using index +1 SIMPLE t1 pNULL,p1001-01-01 index a a 4 NULL 4 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index @@ -1209,62 +1233,62 @@ a 1001-01-01 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p2001-01-01,pNULL ALL NULL NULL NULL NULL 4 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p1001-01-01 system NULL NULL NULL NULL 1 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL ALL NULL NULL NULL NULL 3 Using where # Disabling warnings for the invalid date EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p2001-01-01,pNULL ALL NULL NULL NULL NULL 4 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2001-01-01,pNULL ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p2001-01-01,pNULL ALL NULL NULL NULL NULL 4 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL ALL NULL NULL NULL NULL 3 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pNULL,p1001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 pNULL,p1001-01-01 ALL NULL NULL NULL NULL 4 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 ALL NULL NULL NULL NULL 5 Using where DROP TABLE t1; # Test with DATETIME column NOT NULL CREATE TABLE t1 ( @@ -1289,25 +1313,25 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 12 NULL 8 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 index NULL PRIMARY 12 NULL 8 Using where; Using index +1 SIMPLE t1 p20090403 index NULL PRIMARY 12 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 6 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 6 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090402 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090402 index NULL PRIMARY 12 NULL 3 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra @@ -1315,99 +1339,99 @@ id select_type table partitions type possible_keys key key_len ref rows Extra EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 6 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 12 NULL 8 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090403 index NULL PRIMARY 12 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 6 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 12 NULL 8 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090403 index NULL PRIMARY 12 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 6 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 6 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090402 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090402 index NULL PRIMARY 12 NULL 3 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p20090401,p20090402,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 13 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 6 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 12 NULL 8 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090403 index NULL PRIMARY 12 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 12 NULL 8 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 12 NULL 8 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090403 index NULL PRIMARY 12 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 12 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 6 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 12 NULL 6 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090402 index NULL PRIMARY 12 NULL 13 Using where; Using index +1 SIMPLE t1 p20090402 index NULL PRIMARY 12 NULL 3 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra @@ -1440,21 +1464,21 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 7 NULL 7 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 index NULL PRIMARY 7 NULL 7 Using where; Using index +1 SIMPLE t1 p20090403 index NULL PRIMARY 7 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090404,p20090405 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090404,p20090405 index NULL PRIMARY 7 NULL 8 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra @@ -1462,79 +1486,79 @@ id select_type table partitions type possible_keys key key_len ref rows Extra EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 7 NULL 7 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090403 index NULL PRIMARY 7 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090404,p20090405 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090404,p20090405 index NULL PRIMARY 7 NULL 8 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 7 NULL 7 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090403 index NULL PRIMARY 7 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090404,p20090405 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090404,p20090405 index NULL PRIMARY 7 NULL 8 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 7 NULL 7 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090403 index NULL PRIMARY 7 NULL 2 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090404,p20090405 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090404,p20090405 index NULL PRIMARY 7 NULL 8 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 7 NULL 7 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090402,p20090403 index NULL PRIMARY 7 NULL 7 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra @@ -1542,19 +1566,19 @@ id select_type table partitions type possible_keys key key_len ref rows Extra EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090404,p20090405 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090404,p20090405 index NULL PRIMARY 7 NULL 8 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090404,p20090405 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090404,p20090405 index NULL PRIMARY 7 NULL 8 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090402 index NULL PRIMARY 7 NULL 5 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra @@ -1562,11 +1586,11 @@ id select_type table partitions type possible_keys key key_len ref rows Extra EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 10 Using where; Using index EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 12 Using where; Using index +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 index NULL PRIMARY 7 NULL 10 Using where; Using index DROP TABLE t1; # Test with DATETIME column NULL CREATE TABLE t1 ( @@ -1590,25 +1614,25 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 8 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 8 Using where +1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 2 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090402 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090402 ALL NULL NULL NULL NULL 3 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra @@ -1616,99 +1640,99 @@ id select_type table partitions type possible_keys key key_len ref rows Extra EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 8 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 2 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 8 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 2 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090402 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090402 ALL NULL NULL NULL NULL 3 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p20090401,p20090402,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 13 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 8 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 2 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 8 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 8 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 2 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 6 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090402 ALL NULL NULL NULL NULL 13 Using where +1 SIMPLE t1 p20090402 ALL NULL NULL NULL NULL 3 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra @@ -1740,21 +1764,21 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 7 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 2 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090404,p20090405 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090404,p20090405 ALL NULL NULL NULL NULL 8 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra @@ -1762,79 +1786,79 @@ id select_type table partitions type possible_keys key key_len ref rows Extra EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 7 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 2 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090404,p20090405 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090404,p20090405 ALL NULL NULL NULL NULL 8 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 7 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 2 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090404,p20090405 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090404,p20090405 ALL NULL NULL NULL NULL 8 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 7 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090403 ALL NULL NULL NULL NULL 2 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090404,p20090405 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090404,p20090405 ALL NULL NULL NULL NULL 8 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 7 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090402,p20090403 ALL NULL NULL NULL NULL 7 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra @@ -1842,19 +1866,19 @@ id select_type table partitions type possible_keys key key_len ref rows Extra EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090404,p20090405 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090404,p20090405 ALL NULL NULL NULL NULL 8 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090404,p20090405 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090404,p20090405 ALL NULL NULL NULL NULL 8 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090402 ALL NULL NULL NULL NULL 5 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra @@ -1862,11 +1886,11 @@ id select_type table partitions type possible_keys key key_len ref rows Extra EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 12 Using where +1 SIMPLE t1 p20090401,p20090403,p20090404,p20090405 ALL NULL NULL NULL NULL 10 Using where DROP TABLE t1; # For better code coverage of the patch CREATE TABLE t1 ( @@ -1930,7 +1954,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t2 p0,p1 ALL NULL NULL NULL NULL 3 Using where explain partitions select * from t2 where a=1 and b=1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 3 Using where +1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 2 Using where create table t3 ( a int ) @@ -1988,25 +2012,25 @@ id select_type table partitions type possible_keys key key_len ref rows Extra explain partitions select * from t5 where (a=10 and b=1) or (a=10 and b=2) or (a=10 and b = 3); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t5 p0_p0sp0,p0_p0sp1 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t5 p0_p0sp0,p0_p0sp1 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t5 where (a=10 and b=2) or (a=10 and b=3) or (a=10 and b = 4); id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t5 p0_p0sp0,p0_p0sp1,p1_p1sp0,p1_p1sp1 ALL NULL NULL NULL NULL 4 Using where explain partitions select * from t5 where (c=1 and d=1); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t5 p0_p0sp0,p1_p1sp0 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t5 p0_p0sp0,p1_p1sp0 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t5 where (c=2 and d=1); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t5 p0_p0sp1,p1_p1sp1 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t5 p0_p0sp1,p1_p1sp1 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t5 where (a=10 and b=2 and c=1 and d=1) or (c=2 and d=1); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t5 p0_p0sp0,p0_p0sp1,p1_p1sp1 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t5 p0_p0sp0,p0_p0sp1,p1_p1sp1 ALL NULL NULL NULL NULL 3 Using where explain partitions select * from t5 where (a=10 and b=2 and c=1 and d=1) or (b=2 and c=2 and d=1); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t5 p0_p0sp0,p0_p0sp1,p1_p1sp1 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t5 p0_p0sp0,p0_p0sp1,p1_p1sp1 ALL NULL NULL NULL NULL 3 Using where create table t6 (a int not null) partition by LIST(a) ( partition p1 values in (1), partition p3 values in (3), @@ -2044,7 +2068,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t6 p5,p7,p9 system NULL NULL NULL NULL 1 explain partitions select * from t6 where a >= 3 and a <= 8; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t6 p3,p5,p7 ALL NULL NULL NULL NULL 3 Using where +1 SIMPLE t6 p3,p5,p7 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t6 where a > 3 and a < 5; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables @@ -2086,7 +2110,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t6 p5,p7,p9 system NULL NULL NULL NULL 1 explain partitions select * from t6 where a >= 3 and a <= 8; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t6 p3,p5,p7 ALL NULL NULL NULL NULL 3 Using where +1 SIMPLE t6 p3,p5,p7 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t6 where a > 3 and a < 5; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables @@ -2325,7 +2349,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra explain partitions select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE X p1,p2 ALL a NULL NULL NULL 4 Using where +1 SIMPLE X p1,p2 ALL a NULL NULL NULL 2 Using where 1 SIMPLE Y p1,p2 ref a a 4 test.X.a 2 drop table t1; create table t1 (a int) partition by hash(a) partitions 20; @@ -2338,7 +2362,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p1,p2 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t1 where a > 1 and a <= 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2,p3 ALL NULL NULL NULL NULL 3 Using where +1 SIMPLE t1 p2,p3 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t1 where a >= 1 and a <= 3; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p1,p2,p3 ALL NULL NULL NULL NULL 3 Using where @@ -2428,22 +2452,22 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t2 p0,p1,p2,p3,p4 ALL NULL NULL NULL NULL 1010 explain partitions select * from t2 where a < 801 and a > 200; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p1,p2,p3,p4 ALL NULL NULL NULL NULL 1010 Using where +1 SIMPLE t2 p1,p2,p3,p4 ALL NULL NULL NULL NULL 800 Using where explain partitions select * from t2 where a < 801 and a > 800; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p4 ALL NULL NULL NULL NULL 1010 Using where +1 SIMPLE t2 p4 ALL NULL NULL NULL NULL 200 Using where explain partitions select * from t2 where a > 600; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 1010 Using where +1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 400 Using where explain partitions select * from t2 where a > 600 and b = 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 1010 Using where +1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 400 Using where explain partitions select * from t2 where a > 600 and b = 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 1010 Using where +1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 400 Using where explain partitions select * from t2 where a > 600 and b = 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 1010 Using where +1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 400 Using where explain partitions select * from t2 where b = 5; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t2 p0,p1,p2,p3,p4 ALL NULL NULL NULL NULL 1010 Using where @@ -2498,19 +2522,19 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t2 p0,p1,p2,p3,p4 ALL NULL NULL NULL NULL 910 explain partitions select * from t2 where a = 101; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 910 Using where +1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 110 Using where explain partitions select * from t2 where a = 550; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p2 ALL NULL NULL NULL NULL 910 Using where +1 SIMPLE t2 p2 ALL NULL NULL NULL NULL 200 Using where explain partitions select * from t2 where a = 833; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p4 ALL NULL NULL NULL NULL 910 Using where +1 SIMPLE t2 p4 ALL NULL NULL NULL NULL 200 Using where explain partitions select * from t2 where (a = 100 OR a = 900); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p0,p4 ALL NULL NULL NULL NULL 910 Using where +1 SIMPLE t2 p0,p4 ALL NULL NULL NULL NULL 310 Using where explain partitions select * from t2 where (a > 100 AND a < 600); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p0,p1,p2 ALL NULL NULL NULL NULL 910 Using where +1 SIMPLE t2 p0,p1,p2 ALL NULL NULL NULL NULL 510 Using where explain partitions select * from t2 where b = 4; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t2 p0,p1,p2,p3,p4 ref b b 5 const 76 Using where @@ -2796,17 +2820,17 @@ id select_type table partitions type possible_keys key key_len ref rows Extra explain partitions select * from t1 where a >= 18446744073709551000-1 and a <= 18446744073709551000+1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p3,p4 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t1 p3,p4 ALL NULL NULL NULL NULL 3 Using where explain partitions select * from t1 where a between 18446744073709551001 and 18446744073709551002; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t1 where a = 18446744073709551000; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t1 where a = 18446744073709551613; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t1 where a = 18446744073709551614; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables @@ -2833,10 +2857,10 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t1 where a=0xFE; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t1 p2 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t2 where a=0xFE; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p2 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t2 p2 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t1 where a > 0xFE AND a <= 0xFF; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables @@ -2845,22 +2869,22 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables explain partitions select * from t1 where a >= 0xFE AND a <= 0xFF; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t1 p2 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t2 where a >= 0xFE AND a <= 0xFF; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p2 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t2 p2 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t1 where a < 64 AND a >= 63; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t2 where a < 64 AND a >= 63; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t1 where a <= 64 AND a >= 63; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 6 Using where +1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 4 Using where explain partitions select * from t2 where a <= 64 AND a >= 63; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t2 p0,p1 ALL NULL NULL NULL NULL 6 Using where +1 SIMPLE t2 p0,p1 ALL NULL NULL NULL NULL 4 Using where drop table t1; drop table t2; create table t1(a bigint unsigned not null) partition by range(a+0) ( diff --git a/mysql-test/t/partition_pruning.test b/mysql-test/t/partition_pruning.test index 358832496e5..db544d4643f 100644 --- a/mysql-test/t/partition_pruning.test +++ b/mysql-test/t/partition_pruning.test @@ -8,6 +8,30 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; --enable_warnings +--echo # +--echo # Bug#53806: Wrong estimates for range query in partitioned MyISAM table +--echo # Bug#46754: 'rows' field doesn't reflect partition pruning +--echo # +CREATE TABLE t1 (a INT PRIMARY KEY) +PARTITION BY RANGE (a) ( +PARTITION p0 VALUES LESS THAN (1), +PARTITION p1 VALUES LESS THAN (2), +PARTITION p2 VALUES LESS THAN (3), +PARTITION p3 VALUES LESS THAN (4), +PARTITION p4 VALUES LESS THAN (5), +PARTITION p5 VALUES LESS THAN (6), +PARTITION max VALUES LESS THAN MAXVALUE); + +INSERT INTO t1 VALUES (-1),(0),(1),(2),(3),(4),(5),(6),(7),(8); + +--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 11 # +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1; +--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 11 # +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7; +--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 11 # +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1; +DROP TABLE t1; + --echo # --echo # Bug#49742: Partition Pruning not working correctly for RANGE --echo # diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7ee1762295f..9a824b0810a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -16640,7 +16640,15 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, if (tab->select && tab->select->quick) examined_rows= tab->select->quick->records; else if (tab->type == JT_NEXT || tab->type == JT_ALL) - examined_rows= tab->limit ? tab->limit : tab->table->file->records(); + { + if (tab->limit) + examined_rows= tab->limit; + else + { + tab->table->file->info(HA_STATUS_VARIABLE); + examined_rows= tab->table->file->stats.records; + } + } else examined_rows=(ha_rows)join->best_positions[i].records_read; From 0142c14a6b3fd551e5b8e8dc5fd61e215910c72f Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Fri, 27 Aug 2010 12:39:01 +0400 Subject: [PATCH 040/183] Bug#27480 (Extend CREATE TEMPORARY TABLES privilege to allow temp table operations) -- prerequisite patch #1. Move a piece of code that initialiazes TABLE instance after it was successfully opened into a separate function. This function will be reused in the following patches. --- sql/sql_base.cc | 36 +++---------------------------- sql/table.cc | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ sql/table.h | 1 + 3 files changed, 61 insertions(+), 33 deletions(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 01ab0b6dec5..c14f2f41809 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -3023,41 +3023,11 @@ retry_share: table->reginfo.lock_type=TL_READ; /* Assume read */ reset: - DBUG_ASSERT(table->s->ref_count > 0 || table->s->tmp_table != NO_TMP_TABLE); - - if (thd->lex->need_correct_ident()) - table->alias_name_used= my_strcasecmp(table_alias_charset, - table->s->table_name.str, alias); - /* Fix alias if table name changes */ - if (strcmp(table->alias, alias)) - { - uint length=(uint) strlen(alias)+1; - table->alias= (char*) my_realloc((char*) table->alias, length, - MYF(MY_WME)); - memcpy((char*) table->alias, alias, length); - } - table->tablenr=thd->current_tablenr++; - table->used_fields=0; - table->const_table=0; - table->null_row= table->maybe_null= 0; - table->force_index= table->force_index_order= table->force_index_group= 0; - table->status=STATUS_NO_RECORD; - table->insert_values= 0; - table->fulltext_searched= 0; - table->file->ft_handler= 0; - table->reginfo.impossible_range= 0; - /* Catch wrong handling of the auto_increment_field_not_null. */ - DBUG_ASSERT(!table->auto_increment_field_not_null); - table->auto_increment_field_not_null= FALSE; - if (table->timestamp_field) - table->timestamp_field_type= table->timestamp_field->get_auto_set_type(); - table->pos_in_table_list= table_list; table_list->updatable= 1; // It is not derived table nor non-updatable VIEW - table->clear_column_bitmaps(); table_list->table= table; - DBUG_ASSERT(table->key_read == 0); - /* Tables may be reused in a sub statement. */ - DBUG_ASSERT(! table->file->extra(HA_EXTRA_IS_ATTACHED_CHILDREN)); + + table->init(thd, table_list); + DBUG_RETURN(FALSE); err_lock: diff --git a/sql/table.cc b/sql/table.cc index f08a0aa84ca..5cdc0ce9042 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3223,6 +3223,63 @@ bool TABLE_SHARE::wait_for_old_version(THD *thd, struct timespec *abstime, } +/** + Initialize TABLE instance and prepare it to be used further. + Set the 'alias' attribute from the specified TABLE_LIST element. + Remember the TABLE_LIST element in the 'pos_in_table_list' member. + + @param thd Thread context. + @param tl TABLE_LIST element. +*/ + +void TABLE::init(THD *thd, TABLE_LIST *tl) +{ + DBUG_ASSERT(s->ref_count > 0 || s->tmp_table != NO_TMP_TABLE); + + if (thd->lex->need_correct_ident()) + alias_name_used= my_strcasecmp(table_alias_charset, + s->table_name.str, + tl->alias); + /* Fix alias if table name changes. */ + if (strcmp(alias, tl->alias)) + { + uint length= (uint) strlen(tl->alias)+1; + alias= (char*) my_realloc((char*) alias, length, MYF(MY_WME)); + memcpy((char*) alias, tl->alias, length); + } + + tablenr= thd->current_tablenr++; + used_fields= 0; + const_table= 0; + null_row= 0; + maybe_null= 0; + force_index= 0; + force_index_order= 0; + force_index_group= 0; + status= STATUS_NO_RECORD; + insert_values= 0; + fulltext_searched= 0; + file->ft_handler= 0; + reginfo.impossible_range= 0; + + /* Catch wrong handling of the auto_increment_field_not_null. */ + DBUG_ASSERT(!auto_increment_field_not_null); + auto_increment_field_not_null= FALSE; + + if (timestamp_field) + timestamp_field_type= timestamp_field->get_auto_set_type(); + + pos_in_table_list= tl; + + clear_column_bitmaps(); + + DBUG_ASSERT(key_read == 0); + + /* Tables may be reused in a sub statement. */ + DBUG_ASSERT(!file->extra(HA_EXTRA_IS_ATTACHED_CHILDREN)); +} + + /* Create Item_field for each column in the table. diff --git a/sql/table.h b/sql/table.h index bce1124fbb3..aa177c99856 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1097,6 +1097,7 @@ public: #endif MDL_ticket *mdl_ticket; + void init(THD *thd, TABLE_LIST *tl); bool fill_item_list(List *item_list) const; void reset_item_list(List *item_list) const; void clear_column_bitmaps(void); From 380c9d0daecfd1fca6872be0affb6426877cbf43 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Fri, 27 Aug 2010 10:43:51 +0200 Subject: [PATCH 041/183] Bug#53806: Wrong estimates for range query in partitioned MyISAM table Bug#46754: 'rows' field doesn't reflect partition pruning Update of test results after fixing the above bugs. (fix in separate commit). --- mysql-test/r/partition.result | 2 +- mysql-test/r/partition_hash.result | 12 +++---- mysql-test/r/partition_innodb.result | 18 +++++----- mysql-test/r/partition_range.result | 12 +++---- .../parts/r/partition_alter3_innodb.result | 36 +++++++++---------- .../parts/r/partition_alter3_myisam.result | 36 +++++++++---------- 6 files changed, 58 insertions(+), 58 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 23a485dc5ed..90b4bf92af5 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1382,7 +1382,7 @@ NULL 2 explain partitions select * from t1 where a is null or a < 0 or a > 1; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pn,p2 ALL NULL NULL NULL NULL 4 Using where +1 SIMPLE t1 pn,p2 ALL NULL NULL NULL NULL 2 Using where drop table t1; CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, name VARCHAR(20)) ENGINE=MyISAM DEFAULT CHARSET=latin1 diff --git a/mysql-test/r/partition_hash.result b/mysql-test/r/partition_hash.result index 19da70db5a0..94fefe77a77 100644 --- a/mysql-test/r/partition_hash.result +++ b/mysql-test/r/partition_hash.result @@ -69,25 +69,25 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p0,p1,p2,p3 ALL NULL NULL NULL NULL 9 Using where explain partitions select * from t1 where a is null or (a >= 5 and a <= 7); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p2,p3 ALL NULL NULL NULL NULL 9 Using where +1 SIMPLE t1 p0,p2,p3 ALL NULL NULL NULL NULL 7 Using where explain partitions select * from t1 where a is null; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 9 Using where +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 3 Using where explain partitions select * from t1 where a is not null; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p0,p1,p2,p3 ALL NULL NULL NULL NULL 9 Using where explain partitions select * from t1 where a >= 1 and a < 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 9 Using where +1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 5 Using where explain partitions select * from t1 where a >= 3 and a <= 5; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p1,p2 ALL NULL NULL NULL NULL 9 Using where +1 SIMPLE t1 p1,p2 ALL NULL NULL NULL NULL 4 Using where explain partitions select * from t1 where a > 2 and a < 4; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p1 ALL NULL NULL NULL NULL 9 Using where +1 SIMPLE t1 p1 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t1 where a > 3 and a <= 6; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p2,p3 ALL NULL NULL NULL NULL 9 Using where +1 SIMPLE t1 p2,p3 ALL NULL NULL NULL NULL 4 Using where explain partitions select * from t1 where a > 5; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p0,p1,p2,p3 ALL NULL NULL NULL NULL 9 Using where diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result index 2a04aafe554..238fbf4662c 100644 --- a/mysql-test/r/partition_innodb.result +++ b/mysql-test/r/partition_innodb.result @@ -22,31 +22,31 @@ insert INTO t1 VALUES (110); ERROR HY000: Table has no partition for value 110 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 90; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 0 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 90; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 0 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 90; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 0 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 89; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p90 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p90 ALL NULL NULL NULL NULL 3 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 89; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p90 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 p90 ALL NULL NULL NULL NULL 3 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 89; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 0 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 100; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 0 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 100; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 0 Using where EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 100; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 0 Using where DROP TABLE t1; # # Bug#50104: Partitioned table with just 1 partion works with fk diff --git a/mysql-test/r/partition_range.result b/mysql-test/r/partition_range.result index 7a3ff4861cc..58945b563dc 100644 --- a/mysql-test/r/partition_range.result +++ b/mysql-test/r/partition_range.result @@ -73,13 +73,13 @@ id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 pnull system NULL NULL NULL NULL 1 explain partitions select * from t1 where a >= 0; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 3 Using where +1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t1 where a < 0; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables explain partitions select * from t1 where a <= 0; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pnull,p0 ALL NULL NULL NULL NULL 3 Using where +1 SIMPLE t1 pnull,p0 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t1 where a > 1; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables @@ -112,16 +112,16 @@ select * from t1 where a > 1; a b explain partitions select * from t1 where a is null; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 6 Using where +1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t1 where a >= 0; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0_p0sp0,p0_p0sp1,p1_p1sp0,p1_p1sp1 ALL NULL NULL NULL NULL 6 Using where +1 SIMPLE t1 p0_p0sp0,p0_p0sp1,p1_p1sp0,p1_p1sp1 ALL NULL NULL NULL NULL 4 Using where explain partitions select * from t1 where a < 0; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 6 Using where +1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 2 Using where explain partitions select * from t1 where a <= 0; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1,p0_p0sp0,p0_p0sp1 ALL NULL NULL NULL NULL 6 Using where +1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1,p0_p0sp0,p0_p0sp1 ALL NULL NULL NULL NULL 4 Using where explain partitions select * from t1 where a > 1; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables diff --git a/mysql-test/suite/parts/r/partition_alter3_innodb.result b/mysql-test/suite/parts/r/partition_alter3_innodb.result index cb104d4be54..7825a2350b0 100644 --- a/mysql-test/suite/parts/r/partition_alter3_innodb.result +++ b/mysql-test/suite/parts/r/partition_alter3_innodb.result @@ -141,7 +141,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 7 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -165,7 +165,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 5 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -190,7 +190,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 3 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -226,7 +226,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 3 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -248,7 +248,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 4 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -269,7 +269,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -289,7 +289,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 5 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -308,7 +308,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 7 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -326,7 +326,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 10 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -452,7 +452,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 7 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -476,7 +476,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 5 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -504,7 +504,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 3 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -538,7 +538,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -563,7 +563,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 3 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -587,7 +587,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 23 Using where +1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 10 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -610,7 +610,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 5 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -632,7 +632,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 7 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -653,7 +653,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 10 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 diff --git a/mysql-test/suite/parts/r/partition_alter3_myisam.result b/mysql-test/suite/parts/r/partition_alter3_myisam.result index 374b108b57e..a5dec48e85c 100644 --- a/mysql-test/suite/parts/r/partition_alter3_myisam.result +++ b/mysql-test/suite/parts/r/partition_alter3_myisam.result @@ -155,7 +155,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 7 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -187,7 +187,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 5 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -228,7 +228,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 3 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -278,7 +278,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 3 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -312,7 +312,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 4 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -343,7 +343,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -371,7 +371,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 5 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -396,7 +396,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 7 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -418,7 +418,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 10 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -552,7 +552,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 7 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -584,7 +584,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 5 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -628,7 +628,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 3 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -676,7 +676,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -713,7 +713,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 3 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -747,7 +747,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 10 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -778,7 +778,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 5 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -806,7 +806,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 7 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 @@ -831,7 +831,7 @@ t1.frm t1.par EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 10 Using where # check read single success: 1 # check read all success: 1 # check read row by row success: 1 From 9c6143ef800b2689ac8e0e602823059ed271bf57 Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Mon, 30 Aug 2010 11:51:46 +0400 Subject: [PATCH 042/183] Fix for bug #51875: crash when loading data into geometry function polyfromwkb Check for number of line strings in the incoming polygon data (wkb) and for number of points in the incoming linestring wkb. --- mysql-test/r/gis.result | 7 +++++++ mysql-test/t/gis.test | 10 ++++++++++ sql/spatial.cc | 6 ++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 3e28227d542..d39afa6f315 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -1057,4 +1057,11 @@ NULL SELECT Polygon(12345123,''); Polygon(12345123,'') NULL +# +# BUG#51875: crash when loading data into geometry function polyfromwkb +# +SET @a=0x00000000030000000100000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440; +SET @a=POLYFROMWKB(@a); +SET @a=0x00000000030000000000000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440; +SET @a=POLYFROMWKB(@a); End of 5.1 tests diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index bc0695aaa93..236b31efb79 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -722,4 +722,14 @@ SELECT Polygon(123451,''); SELECT Polygon(1234512,''); SELECT Polygon(12345123,''); + +--echo # +--echo # BUG#51875: crash when loading data into geometry function polyfromwkb +--echo # +SET @a=0x00000000030000000100000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440; +SET @a=POLYFROMWKB(@a); +SET @a=0x00000000030000000000000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440; +SET @a=POLYFROMWKB(@a); + + --echo End of 5.1 tests diff --git a/sql/spatial.cc b/sql/spatial.cc index 2305a8eb97d..8b869a5b1ca 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -528,7 +528,7 @@ uint Gis_line_string::init_from_wkb(const char *wkb, uint len, n_points= wkb_get_uint(wkb, bo); proper_length= 4 + n_points * POINT_DATA_SIZE; - if (len < proper_length || res->reserve(proper_length)) + if (!n_points || len < proper_length || res->reserve(proper_length)) return 0; res->q_append(n_points); @@ -746,7 +746,9 @@ uint Gis_polygon::init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, if (len < 4) return 0; - n_linear_rings= wkb_get_uint(wkb, bo); + if (!(n_linear_rings= wkb_get_uint(wkb, bo))) + return 0; + if (res->reserve(4, 512)) return 0; wkb+= 4; From fd9b6b8e079e34ce14872a2633ed67786a4e5919 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Mon, 30 Aug 2010 11:25:10 +0200 Subject: [PATCH 043/183] Bug #55178 Set timeout on test-to-test-basis Allow --testcase-timeout= to be set in .opt file for test --- mysql-test/lib/mtr_cases.pm | 7 +++++++ mysql-test/mysql-test-run.pl | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index 07a26a1cdf4..7d25a72212a 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -684,6 +684,13 @@ sub process_opts_file { next; } + $value= mtr_match_prefix($opt, "--testcase-timeout="); + if ( defined $value ) { + # Overrides test case timeout for this test + $tinfo->{'case-timeout'}= $value; + next; + } + # Ok, this was a real option, add it push(@{$tinfo->{$opt_name}}, $opt); } diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 28665918e49..5e6d4206d4a 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -212,7 +212,6 @@ my $opt_suite_timeout = $ENV{MTR_SUITE_TIMEOUT} || 300; # minutes my $opt_shutdown_timeout= $ENV{MTR_SHUTDOWN_TIMEOUT} || 10; # seconds my $opt_start_timeout = $ENV{MTR_START_TIMEOUT} || 180; # seconds -sub testcase_timeout { return $opt_testcase_timeout * 60; }; sub suite_timeout { return $opt_suite_timeout * 60; }; sub check_timeout { return $opt_testcase_timeout * 6; }; @@ -241,6 +240,17 @@ my $opt_callgrind; my %mysqld_logs; my $opt_debug_sync_timeout= 300; # Default timeout for WAIT_FOR actions. +sub testcase_timeout ($) { + my ($tinfo)= @_; + if (exists $tinfo->{'case-timeout'}) { + # Return test specific timeout if *longer* that the general timeout + my $test_to= $tinfo->{'case-timeout'}; + $test_to*= 10 if $opt_valgrind; + return $test_to * 60 if $test_to > $opt_testcase_timeout; + } + return $opt_testcase_timeout * 60; +} + our $opt_warnings= 1; our $opt_skip_ndbcluster= 0; @@ -3469,7 +3479,7 @@ sub run_testcase ($) { } } - my $test_timeout= start_timer(testcase_timeout()); + my $test_timeout= start_timer(testcase_timeout($tinfo)); do_before_run_mysqltest($tinfo); @@ -3669,7 +3679,7 @@ sub run_testcase ($) { { my $log_file_name= $opt_vardir."/log/".$tinfo->{shortname}.".log"; $tinfo->{comment}= - "Test case timeout after ".testcase_timeout(). + "Test case timeout after ".testcase_timeout($tinfo). " seconds\n\n"; # Add 20 last executed commands from test case log file if (-e $log_file_name) @@ -3678,7 +3688,7 @@ sub run_testcase ($) { "== $log_file_name == \n". mtr_lastlinesfromfile($log_file_name, 20)."\n"; } - $tinfo->{'timeout'}= testcase_timeout(); # Mark as timeout + $tinfo->{'timeout'}= testcase_timeout($tinfo); # Mark as timeout run_on_all($tinfo, 'analyze-timeout'); report_failure_and_restart($tinfo); From e7dc80b8078d2f63bd1d12f0d61f13c88e96f87f Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Mon, 30 Aug 2010 17:33:55 +0200 Subject: [PATCH 044/183] Bug#50036: Inconsistent errors when using TIMESTAMP columns/expressions It was hard to understand what the error really meant. The error checking in partitioning is done in several different parts during the execution of a query which can make it hard to return useful errors. Added a new error for bad VALUES part in the per PARTITION clause. Using the more verbose error that a column is not allowed in the partitioning function instead of just that the function is not allowed. --- mysql-test/r/partition.result | 4 +- mysql-test/r/partition_error.result | 130 +++++++++++++++++++++- mysql-test/std_data/parts/t1TIMESTAMP.frm | Bin 0 -> 8554 bytes mysql-test/t/partition.test | 4 +- mysql-test/t/partition_error.test | 102 ++++++++++++++++- sql/partition_info.cc | 66 +++++++++-- sql/partition_info.h | 11 +- sql/share/errmsg-utf8.txt | 4 + sql/sql_partition.cc | 18 +-- sql/sql_yacc.yy | 2 +- 10 files changed, 302 insertions(+), 39 deletions(-) create mode 100644 mysql-test/std_data/parts/t1TIMESTAMP.frm diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 55366bd2e07..693c338fc76 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -520,12 +520,12 @@ create table t1 (a bigint) partition by range (a) (partition p0 values less than (0xFFFFFFFFFFFFFFFF), partition p1 values less than (10)); -ERROR HY000: VALUES value must be of same type as partition function +ERROR HY000: VALUES value for partition 'p0' must have type INT create table t1 (a bigint) partition by list (a) (partition p0 values in (0xFFFFFFFFFFFFFFFF), partition p1 values in (10)); -ERROR HY000: VALUES value must be of same type as partition function +ERROR HY000: VALUES value for partition 'p0' must have type INT create table t1 (a bigint unsigned) partition by range (a) (partition p0 values less than (100), diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result index 25addd7fdea..830ca4bee10 100644 --- a/mysql-test/r/partition_error.result +++ b/mysql-test/r/partition_error.result @@ -1,4 +1,124 @@ -drop table if exists t1; +drop table if exists t1, t2; +# +# Bug#50036: Inconsistent errors when using TIMESTAMP +# columns/expressions +# 1. correct and appropriate errors in light of +# the fix for BUG#42849: +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY RANGE (TO_DAYS(c)) +(PARTITION p0 VALUES LESS THAN (10000), +PARTITION p1 VALUES LESS THAN (MAXVALUE)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t2 (c TIMESTAMP); +ALTER TABLE t2 +PARTITION BY RANGE (TO_DAYS(c)) +(PARTITION p0 VALUES LESS THAN (10000), +PARTITION p1 VALUES LESS THAN (MAXVALUE)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY RANGE COLUMNS(c) +(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'), +PARTITION p1 VALUES LESS THAN (MAXVALUE)); +ERROR HY000: Field 'c' is of a not allowed type for this type of partitioning +ALTER TABLE t2 PARTITION BY RANGE COLUMNS(c) +(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'), +PARTITION p1 VALUES LESS THAN (MAXVALUE)); +ERROR HY000: Field 'c' is of a not allowed type for this type of partitioning +DROP TABLE t2; +# 2. These errors where questionable before the fix: +# VALUES clause are checked first, clearified the error message. +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY RANGE (c) +(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'), +PARTITION p1 VALUES LESS THAN (MAXVALUE)); +ERROR HY000: VALUES value for partition 'p0' must have type INT +# TIMESTAMP is not INT (e.g. UNIX_TIMESTAMP). +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY RANGE (UNIX_TIMESTAMP(c)) +(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'), +PARTITION p1 VALUES LESS THAN (MAXVALUE)); +ERROR HY000: VALUES value for partition 'p0' must have type INT +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY RANGE (UNIX_TIMESTAMP(c)) +(PARTITION p0 VALUES LESS THAN (UNIX_TIMESTAMP('2000-01-01 00:00:00')), +PARTITION p1 VALUES LESS THAN (MAXVALUE)); +DROP TABLE t1; +# Changed error from ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY HASH (c) PARTITIONS 4; +ERROR HY000: Field 'c' is of a not allowed type for this type of partitioning +# Added test with existing TIMESTAMP partitioning (when it was allowed). +CREATE TABLE t1 (a TIMESTAMP) +PARTITION BY HASH (UNIX_TIMESTAMP(a)); +INSERT INTO t1 VALUES ('2000-01-02 03:04:05'); +SELECT * FROM t1; +a +2000-01-02 03:04:05 +FLUSH TABLES; +SELECT * FROM t1; +a +2000-01-02 03:04:05 +Warning 1486 Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +Warnings: +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (TO_DAYS(a)) */ +INSERT INTO t1 VALUES ('2001-02-03 04:05:06'); +SELECT * FROM t1; +a +2000-01-02 03:04:05 +2001-02-03 04:05:06 +ALTER TABLE t1 ADD PARTITION PARTITIONS 2; +ALTER TABLE t1 +PARTITION BY RANGE (TO_DAYS(a)) +(PARTITION p0 VALUES LESS THAN (10000), +PARTITION p1 VALUES LESS THAN (MAXVALUE)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (TO_DAYS(a)) +PARTITIONS 3 */ +Warnings: +Warning 1486 Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t2 LIKE t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (TO_DAYS(a)) +PARTITIONS 3 */ +Warnings: +Warning 1486 Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +DROP TABLE t2; +CREATE TABLE t2 SELECT * FROM t1; +DROP TABLE t2; +ALTER TABLE t1 PARTITION BY HASH (UNIX_TIMESTAMP(a)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (UNIX_TIMESTAMP(a)) */ +ALTER TABLE t1 ADD PARTITION PARTITIONS 2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (UNIX_TIMESTAMP(a)) +PARTITIONS 3 */ +SELECT * FROM t1; +a +2000-01-02 03:04:05 +2001-02-03 04:05:06 +DROP TABLE t1; # # Bug#49161: Out of memory; restart server and try again (needed 2 bytes) # @@ -497,7 +617,7 @@ partition by range (a) partitions 2 (partition x1 values less than (4.0) tablespace ts1, partition x2 values less than (8) tablespace ts2); -ERROR HY000: VALUES value must be of same type as partition function +ERROR HY000: VALUES value for partition 'x1' must have type INT CREATE TABLE t1 ( a int not null, b int not null, @@ -736,7 +856,7 @@ partition by list (a) partitions 2 (partition x1 values in (4.0, 12+8), partition x2 values in (3, 21)); -ERROR HY000: VALUES value must be of same type as partition function +ERROR HY000: VALUES value for partition 'x1' must have type INT CREATE TABLE t1 ( a int not null, b int not null, @@ -796,12 +916,12 @@ CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY) PARTITION BY RANGE (a) ( PARTITION p VALUES LESS THAN (20080819), PARTITION pmax VALUES LESS THAN MAXVALUE); -ERROR HY000: The PARTITION function returns the wrong type +ERROR HY000: Field 'a' is of a not allowed type for this type of partitioning ALTER TABLE old PARTITION BY RANGE (a) ( PARTITION p VALUES LESS THAN (20080819), PARTITION pmax VALUES LESS THAN MAXVALUE); -ERROR HY000: The PARTITION function returns the wrong type +ERROR HY000: Field 'a' is of a not allowed type for this type of partitioning CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY) PARTITION BY RANGE (a+0) ( PARTITION p VALUES LESS THAN (20080819), diff --git a/mysql-test/std_data/parts/t1TIMESTAMP.frm b/mysql-test/std_data/parts/t1TIMESTAMP.frm new file mode 100644 index 0000000000000000000000000000000000000000..c9fc49d86a918b24ba07232be14dd9266ecec281 GIT binary patch literal 8554 zcmeI%F%JPT7{>8`i*TFdgi%K~5s8(Y7+AP)i%D)|K*TrnJ$w|WahIEo63;XAecPr@ z^IQ8eL8k_710!E(P{p=rQ7rgcr0vV|0prg!fZ-5av8Pc25|DrdBp?9^NI(J-kbndv zAb}qiu;kV2$}ZrV-R{Tx@pA6_J(tAWbd|0)Yd7D!WxQLuLAp6C;{9%rMNxHHjRYhh z0SQPz0uqpb1SB8<2}nQ!zbJ4r{?q@DV=znzy+DI{>0n9dmi+{4Y$tMG#@}Hx>NX6q MFr^308RS{c8xS%aYybcN literal 0 HcmV?d00001 diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 1224dee24ed..fe2ef8cea1f 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -430,12 +430,12 @@ drop table t1; # # BUG 16002: Handle unsigned integer functions properly # ---error ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR +--error ER_VALUES_IS_NOT_INT_TYPE_ERROR create table t1 (a bigint) partition by range (a) (partition p0 values less than (0xFFFFFFFFFFFFFFFF), partition p1 values less than (10)); ---error ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR +--error ER_VALUES_IS_NOT_INT_TYPE_ERROR create table t1 (a bigint) partition by list (a) (partition p0 values in (0xFFFFFFFFFFFFFFFF), diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index 1496a626796..1afb65d496c 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -5,11 +5,103 @@ -- source include/have_partition.inc --disable_warnings -drop table if exists t1; +drop table if exists t1, t2; --enable_warnings let $MYSQLD_DATADIR= `SELECT @@datadir`; +--echo # +--echo # Bug#50036: Inconsistent errors when using TIMESTAMP +--echo # columns/expressions + +--echo # 1. correct and appropriate errors in light of +--echo # the fix for BUG#42849: +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY RANGE (TO_DAYS(c)) +(PARTITION p0 VALUES LESS THAN (10000), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); +CREATE TABLE t2 (c TIMESTAMP); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +ALTER TABLE t2 +PARTITION BY RANGE (TO_DAYS(c)) +(PARTITION p0 VALUES LESS THAN (10000), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); + +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY RANGE COLUMNS(c) +(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD +ALTER TABLE t2 PARTITION BY RANGE COLUMNS(c) +(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); +DROP TABLE t2; + +--echo # 2. These errors where questionable before the fix: + +--echo # VALUES clause are checked first, clearified the error message. +--error ER_VALUES_IS_NOT_INT_TYPE_ERROR +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY RANGE (c) +(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); + +--echo # TIMESTAMP is not INT (e.g. UNIX_TIMESTAMP). +--error ER_VALUES_IS_NOT_INT_TYPE_ERROR +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY RANGE (UNIX_TIMESTAMP(c)) +(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); + +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY RANGE (UNIX_TIMESTAMP(c)) +(PARTITION p0 VALUES LESS THAN (UNIX_TIMESTAMP('2000-01-01 00:00:00')), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); +DROP TABLE t1; + +--echo # Changed error from ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY HASH (c) PARTITIONS 4; + +--echo # Added test with existing TIMESTAMP partitioning (when it was allowed). + +CREATE TABLE t1 (a TIMESTAMP) +PARTITION BY HASH (UNIX_TIMESTAMP(a)); +INSERT INTO t1 VALUES ('2000-01-02 03:04:05'); +--sorted_result +SELECT * FROM t1; +FLUSH TABLES; +--remove_file $MYSQLD_DATADIR/test/t1.frm +--copy_file std_data/parts/t1TIMESTAMP.frm $MYSQLD_DATADIR/test/t1.frm +--sorted_result +SELECT * FROM t1; +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES ('2001-02-03 04:05:06'); +--sorted_result +SELECT * FROM t1; +ALTER TABLE t1 ADD PARTITION PARTITIONS 2; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +ALTER TABLE t1 +PARTITION BY RANGE (TO_DAYS(a)) +(PARTITION p0 VALUES LESS THAN (10000), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); +SHOW CREATE TABLE t1; +CREATE TABLE t2 LIKE t1; +SHOW CREATE TABLE t2; +DROP TABLE t2; +CREATE TABLE t2 SELECT * FROM t1; +DROP TABLE t2; +ALTER TABLE t1 PARTITION BY HASH (UNIX_TIMESTAMP(a)); +SHOW CREATE TABLE t1; +ALTER TABLE t1 ADD PARTITION PARTITIONS 2; +SHOW CREATE TABLE t1; +--sorted_result +SELECT * FROM t1; +DROP TABLE t1; + --echo # --echo # Bug#49161: Out of memory; restart server and try again (needed 2 bytes) --echo # @@ -536,7 +628,7 @@ partitions 2 # # Partition by range, inconsistent partition function and constants # ---error ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR +--error ER_VALUES_IS_NOT_INT_TYPE_ERROR CREATE TABLE t1 ( a int not null, b int not null, @@ -849,7 +941,7 @@ partitions 2 # # Partition by list, wrong constant result type (not INT) # ---error ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR +--error ER_VALUES_IS_NOT_INT_TYPE_ERROR CREATE TABLE t1 ( a int not null, b int not null, @@ -939,13 +1031,13 @@ PARTITION pmax VALUES LESS THAN MAXVALUE); # Check that allowed arithmetic/math functions involving TIMESTAMP values result # in ER_PARTITION_FUNC_NOT_ALLOWED_ERROR when used as a partitioning function ---error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY) PARTITION BY RANGE (a) ( PARTITION p VALUES LESS THAN (20080819), PARTITION pmax VALUES LESS THAN MAXVALUE); ---error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD ALTER TABLE old PARTITION BY RANGE (a) ( PARTITION p VALUES LESS THAN (20080819), diff --git a/sql/partition_info.cc b/sql/partition_info.cc index caf28fdd83e..879e7b10023 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -742,7 +742,6 @@ bool partition_info::check_range_constants(THD *thd) longlong part_range_value; bool signed_flag= !part_expr->unsigned_flag; - part_result_type= INT_RESULT; range_int_array= (longlong*)sql_alloc(num_parts * sizeof(longlong)); if (unlikely(range_int_array == NULL)) { @@ -917,7 +916,6 @@ bool partition_info::check_list_constants(THD *thd) List_iterator list_func_it(partitions); DBUG_ENTER("partition_info::check_list_constants"); - part_result_type= INT_RESULT; num_list_values= 0; /* We begin by calculating the number of list values that have been @@ -1608,6 +1606,52 @@ id_err: return 1; } + +/** + Check what kind of error to report + + @param use_subpart_expr Use the subpart_expr instead of part_expr + @param part_str Name of partition to report error (or NULL) +*/ +void partition_info::report_part_expr_error(bool use_subpart_expr) +{ + Item *expr= part_expr; + DBUG_ENTER("partition_info::report_part_expr_error"); + if (use_subpart_expr) + expr= subpart_expr; + + if (expr->type() == Item::FIELD_ITEM) + { + partition_type type= part_type; + bool list_of_fields= list_of_part_fields; + Item_field *item_field= (Item_field*) expr; + /* + The expression consists of a single field. + It must be of integer type unless KEY or COLUMNS partitioning. + */ + if (use_subpart_expr) + { + type= subpart_type; + list_of_fields= list_of_subpart_fields; + } + if (!column_list && + item_field->field && + item_field->field->result_type() != INT_RESULT && + !(type == HASH_PARTITION && list_of_fields)) + { + my_error(ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD, MYF(0), + item_field->name); + DBUG_VOID_RETURN; + } + } + if (use_subpart_expr) + my_error(ER_PARTITION_FUNC_NOT_ALLOWED_ERROR, MYF(0), "SUBPARTITION"); + else + my_error(ER_PARTITION_FUNC_NOT_ALLOWED_ERROR, MYF(0), "PARTITION"); + DBUG_VOID_RETURN; +} + + /* Create a new column value in current list with maxvalue Called from parser @@ -1891,7 +1935,7 @@ int partition_info::reorganize_into_single_field_col_val() code. SYNOPSIS - fix_func_partition() + fix_partition_values() thd Thread object col_val Array of one value part_elem The partition instance @@ -1901,13 +1945,13 @@ int partition_info::reorganize_into_single_field_col_val() TRUE Failure FALSE Success */ -int partition_info::fix_func_partition(THD *thd, - part_elem_value *val, - partition_element *part_elem, - uint part_id) +int partition_info::fix_partition_values(THD *thd, + part_elem_value *val, + partition_element *part_elem, + uint part_id) { part_column_list_val *col_val= val->col_val_array; - DBUG_ENTER("partition_info::fix_func_partition"); + DBUG_ENTER("partition_info::fix_partition_values"); if (col_val->fixed) { @@ -1953,7 +1997,9 @@ int partition_info::fix_func_partition(THD *thd, } else if (item_expr->result_type() != INT_RESULT) { - my_error(ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR, MYF(0)); + /* VALUES clause only allowed on partitions, not subpartitions */ + my_error(ER_VALUES_IS_NOT_INT_TYPE_ERROR, MYF(0), + part_elem->partition_name); DBUG_RETURN(TRUE); } if (part_type == RANGE_PARTITION) @@ -2168,7 +2214,7 @@ int partition_info::fix_parser_data(THD *thd) } else { - if (fix_func_partition(thd, val, part_elem, i)) + if (fix_partition_values(thd, val, part_elem, i)) { DBUG_RETURN(TRUE); } diff --git a/sql/partition_info.h b/sql/partition_info.h index b196d0b59a2..6ae210d9574 100644 --- a/sql/partition_info.h +++ b/sql/partition_info.h @@ -166,7 +166,6 @@ public: key_map some_fields_in_PF; handlerton *default_engine_type; - Item_result part_result_type; partition_type part_type; partition_type subpart_type; @@ -226,7 +225,6 @@ public: curr_part_elem(NULL), current_partition(NULL), curr_list_object(0), num_columns(0), default_engine_type(NULL), - part_result_type(INT_RESULT), part_type(NOT_A_PARTITION), subpart_type(NOT_A_PARTITION), part_info_len(0), part_func_len(0), subpart_func_len(0), @@ -279,10 +277,10 @@ public: void print_no_partition_found(TABLE *table); void print_debug(const char *str, uint*); Item* get_column_item(Item *item, Field *field); - int fix_func_partition(THD *thd, - part_elem_value *val, - partition_element *part_elem, - uint part_id); + int fix_partition_values(THD *thd, + part_elem_value *val, + partition_element *part_elem, + uint part_id); bool fix_column_value_functions(THD *thd, part_elem_value *val, uint part_id); @@ -299,6 +297,7 @@ public: bool init_column_part(); bool add_column_list_value(THD *thd, Item *item); void set_show_version_string(String *packet); + void report_part_expr_error(bool use_subpart_expr); private: static int list_part_cmp(const void* a, const void* b); bool set_up_default_partitions(handler *file, HA_CREATE_INFO *info, diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 9e7fdbfeae5..7b7f9024a63 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -6346,3 +6346,7 @@ ER_STORED_FUNCTION_PREVENTS_SWITCH_SQL_LOG_BIN ER_FAILED_READ_FROM_PAR_FILE eng "Failed to read from the .par file" swe "Misslyckades läsa från .par filen" + +ER_VALUES_IS_NOT_INT_TYPE_ERROR + eng "VALUES value for partition '%-.64s' must have type INT" + swe "Värden i VALUES för partition '%-.64s' måste ha typen INT" diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index b72816f8ce3..d95ba3fa71e 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1762,8 +1762,7 @@ bool fix_partition_func(THD *thd, TABLE *table, goto end; if (unlikely(part_info->subpart_expr->result_type() != INT_RESULT)) { - my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0), - subpart_str); + part_info->report_part_expr_error(TRUE); goto end; } } @@ -1790,10 +1789,9 @@ bool fix_partition_func(THD *thd, TABLE *table, goto end; if (unlikely(part_info->part_expr->result_type() != INT_RESULT)) { - my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0), part_str); + part_info->report_part_expr_error(FALSE); goto end; } - part_info->part_result_type= INT_RESULT; } part_info->fixed= TRUE; } @@ -1839,18 +1837,22 @@ bool fix_partition_func(THD *thd, TABLE *table, if (unlikely(!part_info->column_list && part_info->part_expr->result_type() != INT_RESULT)) { - my_error(ER_PARTITION_FUNC_NOT_ALLOWED_ERROR, MYF(0), part_str); + part_info->report_part_expr_error(FALSE); goto end; } } if (((part_info->part_type != HASH_PARTITION || - part_info->list_of_part_fields == FALSE) && - (!part_info->column_list && - check_part_func_fields(part_info->part_field_array, TRUE))) || + part_info->list_of_part_fields == FALSE) && + !part_info->column_list && + check_part_func_fields(part_info->part_field_array, TRUE)) || (part_info->list_of_subpart_fields == FALSE && part_info->is_sub_partitioned() && check_part_func_fields(part_info->subpart_field_array, TRUE))) { + /* + Range/List/HASH (but not KEY) and not COLUMNS or HASH subpartitioning + with columns in the partitioning expression using unallowed charset. + */ my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0)); goto end; } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 6a510c04054..70e7e21cef4 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4813,7 +4813,7 @@ part_value_expr_item: if (!lex->safe_to_cache_query) { - my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0)); + my_parse_error(ER(ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR)); MYSQL_YYABORT; } if (part_info->add_column_list_value(YYTHD, part_expr)) From 26bc3b34d5c50599bd6f9856b19c9c4e4c58d819 Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Tue, 31 Aug 2010 13:04:19 +0400 Subject: [PATCH 045/183] Bug #56137 "Assertion `thd->lock == 0' failed on upgrading from 5.1.50 to 5.5.6". Debug builds of the server aborted due to an assertion failure when DROP DATABASE statement was run on an installation which had outdated or corrupt mysql.proc table. Particularly this affected the mysql_upgrade tool which is run as part of 5.1 to 5.5 upgrade. The problem was that sp_drop_db_routines(), which was invoked during dropping of the database, could have returned without closing and unlocking mysql.proc table in cases when this table was not up-to-date with the current server. As a result further attempt to open and lock the mysql.event table, which was necessary to complete dropping of the database, ended up with an assert. This patch solves this problem by ensuring that sp_drop_db_routines() always closes mysql.proc table and releases metadata locks on it. This is achieved by changing open_proc_table_for_update() function to close tables and release metadata locks acquired by it in case of failure. This step also makes behavior of the latter function consistent with behavior of open_proc_table_for_read()/ open_and_lock_tables(). Test case for this bug was added to sp-destruct.test. --- mysql-test/r/sp-destruct.result | 16 ++++++++++++++++ mysql-test/t/sp-destruct.test | 30 ++++++++++++++++++++++++++++++ sql/sp.cc | 4 ++++ 3 files changed, 50 insertions(+) diff --git a/mysql-test/r/sp-destruct.result b/mysql-test/r/sp-destruct.result index a4933ee9800..32d0e39c5af 100644 --- a/mysql-test/r/sp-destruct.result +++ b/mysql-test/r/sp-destruct.result @@ -134,3 +134,19 @@ Warning 1405 Failed to revoke all privileges to dropped routine # Restore the procs_priv table RENAME TABLE procs_priv_backup TO mysql.procs_priv; FLUSH TABLE mysql.procs_priv; +# +# Bug #56137 "Assertion `thd->lock == 0' failed on upgrading from +# 5.1.50 to 5.5.6". +# +drop database if exists mysqltest; +# Backup mysql.proc. +flush table mysql.proc; +create database mysqltest; +# Corrupt mysql.proc to make it unusable by current version of server. +alter table mysql.proc drop column type; +# The below statement should not cause assertion failure. +drop database mysqltest; +Warnings: +Error 1547 Column count of mysql.proc is wrong. Expected 20, found 19. The table is probably corrupted +# Restore mysql.proc. +drop table mysql.proc; diff --git a/mysql-test/t/sp-destruct.test b/mysql-test/t/sp-destruct.test index b7090c01f1e..a5c287e44a8 100644 --- a/mysql-test/t/sp-destruct.test +++ b/mysql-test/t/sp-destruct.test @@ -222,3 +222,33 @@ SHOW WARNINGS; --echo # Restore the procs_priv table RENAME TABLE procs_priv_backup TO mysql.procs_priv; FLUSH TABLE mysql.procs_priv; + + +--echo # +--echo # Bug #56137 "Assertion `thd->lock == 0' failed on upgrading from +--echo # 5.1.50 to 5.5.6". +--echo # +--disable_warnings +drop database if exists mysqltest; +--enable_warnings +--echo # Backup mysql.proc. +flush table mysql.proc; +let $MYSQLD_DATADIR= `select @@datadir`; +--copy_file $MYSQLD_DATADIR/mysql/proc.frm $MYSQLTEST_VARDIR/tmp/proc.frm +--copy_file $MYSQLD_DATADIR/mysql/proc.MYD $MYSQLTEST_VARDIR/tmp/proc.MYD +--copy_file $MYSQLD_DATADIR/mysql/proc.MYI $MYSQLTEST_VARDIR/tmp/proc.MYI + +create database mysqltest; +--echo # Corrupt mysql.proc to make it unusable by current version of server. +alter table mysql.proc drop column type; +--echo # The below statement should not cause assertion failure. +drop database mysqltest; + +--echo # Restore mysql.proc. +drop table mysql.proc; +--copy_file $MYSQLTEST_VARDIR/tmp/proc.frm $MYSQLD_DATADIR/mysql/proc.frm +--copy_file $MYSQLTEST_VARDIR/tmp/proc.MYD $MYSQLD_DATADIR/mysql/proc.MYD +--copy_file $MYSQLTEST_VARDIR/tmp/proc.MYI $MYSQLD_DATADIR/mysql/proc.MYI +--remove_file $MYSQLTEST_VARDIR/tmp/proc.frm +--remove_file $MYSQLTEST_VARDIR/tmp/proc.MYD +--remove_file $MYSQLTEST_VARDIR/tmp/proc.MYI diff --git a/sql/sp.cc b/sql/sp.cc index 0265ef45a2a..8821dc9365d 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -440,6 +440,7 @@ static TABLE *open_proc_table_for_update(THD *thd) { TABLE_LIST table_list; TABLE *table; + MDL_ticket *mdl_savepoint= thd->mdl_context.mdl_savepoint(); DBUG_ENTER("open_proc_table_for_update"); table_list.init_one_table("mysql", 5, "proc", 4, "proc", TL_WRITE); @@ -450,6 +451,9 @@ static TABLE *open_proc_table_for_update(THD *thd) if (!proc_table_intact.check(table, &proc_table_def)) DBUG_RETURN(table); + close_thread_tables(thd); + thd->mdl_context.rollback_to_savepoint(mdl_savepoint); + DBUG_RETURN(NULL); } From e59b1980e6fbd9c8321bf83943784035bb335b74 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Tue, 31 Aug 2010 11:27:57 +0200 Subject: [PATCH 046/183] Bug #56383 provide option to restart mysqld after each mtr test Added --force-restart --- mysql-test/mysql-test-run.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 5e6d4206d4a..82c62ebfcf1 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -225,6 +225,7 @@ my $opt_repeat= 1; my $opt_retry= 3; my $opt_retry_failure= env_or_val(MTR_RETRY_FAILURE => 2); my $opt_reorder= 1; +my $opt_force_restart= 0; my $opt_strace_client; @@ -924,6 +925,7 @@ sub command_line_setup { 'report-features' => \$opt_report_features, 'comment=s' => \$opt_comment, 'fast' => \$opt_fast, + 'force-restart' => \$opt_force_restart, 'reorder!' => \$opt_reorder, 'enable-disabled' => \&collect_option, 'verbose+' => \$opt_verbose, @@ -4512,6 +4514,11 @@ sub server_need_restart { return 1; } + if ( $opt_force_restart ) { + mtr_verbose_restart($server, "forced restart turned on"); + return 1; + } + if ( $tinfo->{template_path} ne $current_config_name) { mtr_verbose_restart($server, "using different config file"); @@ -5541,6 +5548,7 @@ Misc options servers to exit before finishing the process fast Run as fast as possible, dont't wait for servers to shutdown etc. + force-restart Always restart servers between tests parallel=N Run tests in N parallel threads (default=1) Use parallel=auto for auto-setting of N repeat=N Run each test N number of times From a92ca267e0c3d73dbe43f339721312044e3eec47 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Tue, 31 Aug 2010 13:49:48 +0400 Subject: [PATCH 047/183] Fix TABLE::init() comment. --- sql/table.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sql/table.cc b/sql/table.cc index 5cdc0ce9042..e84991912a4 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3224,9 +3224,11 @@ bool TABLE_SHARE::wait_for_old_version(THD *thd, struct timespec *abstime, /** - Initialize TABLE instance and prepare it to be used further. - Set the 'alias' attribute from the specified TABLE_LIST element. - Remember the TABLE_LIST element in the 'pos_in_table_list' member. + Initialize TABLE instance (newly created, or coming either from table + cache or THD::temporary_tables list) and prepare it for further use + during statement execution. Set the 'alias' attribute from the specified + TABLE_LIST element. Remember the TABLE_LIST element in the + TABLE::pos_in_table_list member. @param thd Thread context. @param tl TABLE_LIST element. From 2e462c8f99c98bf525fc1105e9e6ca52a6b5c221 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Tue, 31 Aug 2010 13:52:56 +0400 Subject: [PATCH 048/183] Bug#27480 (Extend CREATE TEMPORARY TABLES privilege to allow temp table operations) -- prerequisite patch #2. Introduce a new form of find_temporary_table() function: find_temporary_table() by a table key. It will be used in further patches. Replace find_temporary_table(table_list->db, table_list->name) by more appropiate find_temporary_table(table_list) across the codebase. --- sql/sql_base.cc | 68 ++++++++++++++++++++++++++++++---------------- sql/sql_base.h | 7 +++-- sql/sql_parse.cc | 3 +- sql/sql_table.cc | 2 +- sql/sql_trigger.cc | 2 +- 5 files changed, 53 insertions(+), 29 deletions(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index c14f2f41809..feb63355353 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -247,7 +247,8 @@ static void check_unused(void) Length of key */ -uint create_table_def_key(THD *thd, char *key, TABLE_LIST *table_list, +uint create_table_def_key(THD *thd, char *key, + const TABLE_LIST *table_list, bool tmp_table) { uint key_length= (uint) (strmov(strmov(key, table_list->db)+1, @@ -1987,39 +1988,60 @@ void update_non_unique_table_error(TABLE_LIST *update, } +/** + Find temporary table specified by database and table names in the + THD::temporary_tables list. + + @return TABLE instance if a temporary table has been found; NULL otherwise. +*/ + TABLE *find_temporary_table(THD *thd, const char *db, const char *table_name) { - TABLE_LIST table_list; + TABLE_LIST tl; - table_list.db= (char*) db; - table_list.table_name= (char*) table_name; - return find_temporary_table(thd, &table_list); + tl.db= (char*) db; + tl.table_name= (char*) table_name; + + return find_temporary_table(thd, &tl); } -TABLE *find_temporary_table(THD *thd, TABLE_LIST *table_list) -{ - char key[MAX_DBKEY_LENGTH]; - uint key_length; - TABLE *table; - DBUG_ENTER("find_temporary_table"); - DBUG_PRINT("enter", ("table: '%s'.'%s'", - table_list->db, table_list->table_name)); +/** + Find a temporary table specified by TABLE_LIST instance in the + THD::temporary_tables list. - key_length= create_table_def_key(thd, key, table_list, 1); - for (table=thd->temporary_tables ; table ; table= table->next) + @return TABLE instance if a temporary table has been found; NULL otherwise. +*/ + +TABLE *find_temporary_table(THD *thd, const TABLE_LIST *tl) +{ + char key[MAX_DBKEY_LENGTH]; + uint key_length= create_table_def_key(thd, key, tl, 1); + + return find_temporary_table(thd, key, key_length); +} + + +/** + Find a temporary table specified by a key in the THD::temporary_tables list. + + @return TABLE instance if a temporary table has been found; NULL otherwise. +*/ + +TABLE *find_temporary_table(THD *thd, + const char *table_key, + uint table_key_length) +{ + for (TABLE *table= thd->temporary_tables; table; table= table->next) { - if (table->s->table_cache_key.length == key_length && - !memcmp(table->s->table_cache_key.str, key, key_length)) + if (table->s->table_cache_key.length == table_key_length && + !memcmp(table->s->table_cache_key.str, table_key, table_key_length)) { - DBUG_PRINT("info", - ("Found table. server_id: %u pseudo_thread_id: %lu", - (uint) thd->server_id, - (ulong) thd->variables.pseudo_thread_id)); - DBUG_RETURN(table); + return table; } } - DBUG_RETURN(0); // Not a temporary table + + return NULL; } diff --git a/sql/sql_base.h b/sql/sql_base.h index ff935c3fc09..1a1f2d957f3 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -79,7 +79,8 @@ void table_def_start_shutdown(void); void assign_new_table_id(TABLE_SHARE *share); uint cached_open_tables(void); uint cached_table_definitions(void); -uint create_table_def_key(THD *thd, char *key, TABLE_LIST *table_list, +uint create_table_def_key(THD *thd, char *key, + const TABLE_LIST *table_list, bool tmp_table); TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key, uint key_length, uint db_flags, int *error, @@ -159,7 +160,9 @@ TABLE_LIST *find_table_in_list(TABLE_LIST *table, const char *db_name, const char *table_name); TABLE *find_temporary_table(THD *thd, const char *db, const char *table_name); -TABLE *find_temporary_table(THD *thd, TABLE_LIST *table_list); +TABLE *find_temporary_table(THD *thd, const TABLE_LIST *tl); +TABLE *find_temporary_table(THD *thd, const char *table_key, + uint table_key_length); void close_thread_tables(THD *thd); bool fill_record_n_invoke_before_triggers(THD *thd, List &fields, List &values, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index b78815f0e52..a0b9959e626 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -177,8 +177,7 @@ static bool some_non_temp_table_to_be_updated(THD *thd, TABLE_LIST *tables) for (TABLE_LIST *table= tables; table; table= table->next_global) { DBUG_ASSERT(table->db && table->table_name); - if (table->updating && - !find_temporary_table(thd, table->db, table->table_name)) + if (table->updating && !find_temporary_table(thd, table)) return 1; } return 0; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 3f0a0326c84..06db813481d 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2008,7 +2008,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, { for (table= tables; table; table= table->next_local) if (table->open_type != OT_BASE_ONLY && - find_temporary_table(thd, table->db, table->table_name)) + find_temporary_table(thd, table)) { /* A temporary table. diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index b81461e8371..c1405015365 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -458,7 +458,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) DBUG_ASSERT(tables->next_global == 0); /* We do not allow creation of triggers on temporary tables. */ - if (create && find_temporary_table(thd, tables->db, tables->table_name)) + if (create && find_temporary_table(thd, tables)) { my_error(ER_TRG_ON_VIEW_OR_TEMP_TABLE, MYF(0), tables->alias); goto end; From 1f1eba3c68cc016c9cf832b7076dcb9f04b0dacf Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Tue, 31 Aug 2010 13:53:49 +0400 Subject: [PATCH 049/183] Remove unused enum (enum open_table_mode). It was added by mistake during backport from 6.0. --- sql/sql_base.h | 1 - sql/table.h | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/sql/sql_base.h b/sql/sql_base.h index 1a1f2d957f3..56776bde1cc 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -17,7 +17,6 @@ #define SQL_BASE_INCLUDED #include "unireg.h" // REQUIRED: for other includes -#include "table.h" /* open_table_mode */ #include "sql_trigger.h" /* trg_event_type */ #include "sql_class.h" /* enum_mark_columns */ #include "mysqld.h" /* key_map */ diff --git a/sql/table.h b/sql/table.h index aa177c99856..ea93b321b5a 100644 --- a/sql/table.h +++ b/sql/table.h @@ -83,18 +83,6 @@ enum enum_table_ref_type }; -/** - Opening modes for open_temporary_table and open_table_from_share -*/ - -enum open_table_mode -{ - OTM_OPEN= 0, - OTM_CREATE= 1, - OTM_ALTER= 2 -}; - - /*************************************************************************/ /** From 6b9371bd458ba5ae204e85d590f07b1c681cb286 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Tue, 31 Aug 2010 13:55:32 +0400 Subject: [PATCH 050/183] Polish check_grant(): name TABLE_LIST instance "tl", not "table". This allows to avoid mixing it up with pointer to TABLE object which will be introduced to this function in one of upcoming patches. --- sql/sql_acl.cc | 70 ++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 19373507955..41e4ad7a522 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -4035,7 +4035,8 @@ end: bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables, bool any_combination_will_do, uint number, bool no_errors) { - TABLE_LIST *table, *first_not_own_table= thd->lex->first_not_own_table(); + TABLE_LIST *tl; + TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table(); Security_context *sctx= thd->security_ctx; uint i; ulong orig_want_access= want_access; @@ -4052,34 +4053,32 @@ bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables, the given table list refers to the list for prelocking (contains tables of other queries). For simple queries first_not_own_table is 0. */ - for (i= 0, table= tables; - i < number && table != first_not_own_table; - table= table->next_global, i++) + for (i= 0, tl= tables; + i < number && tl != first_not_own_table; + tl= tl->next_global, i++) { /* Save a copy of the privileges without the SHOW_VIEW_ACL attribute. It will be checked during making view. */ - table->grant.orig_want_privilege= (want_access & ~SHOW_VIEW_ACL); + tl->grant.orig_want_privilege= (want_access & ~SHOW_VIEW_ACL); } mysql_rwlock_rdlock(&LOCK_grant); - for (table= tables; - table && number-- && table != first_not_own_table; - table= table->next_global) + for (tl= tables; + tl && number-- && tl != first_not_own_table; + tl= tl->next_global) { - GRANT_TABLE *grant_table; - sctx = test(table->security_ctx) ? - table->security_ctx : thd->security_ctx; + sctx = test(tl->security_ctx) ? tl->security_ctx : thd->security_ctx; - const ACL_internal_table_access *access; - access= get_cached_table_access(&table->grant.m_internal, - table->get_db_name(), - table->get_table_name()); + const ACL_internal_table_access *access= + get_cached_table_access(&tl->grant.m_internal, + tl->get_db_name(), + tl->get_table_name()); if (access) { - switch(access->check(orig_want_access, &table->grant.privilege)) + switch(access->check(orig_want_access, &tl->grant.privilege)) { case ACL_INTERNAL_ACCESS_GRANTED: /* @@ -4103,29 +4102,33 @@ bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables, if (!want_access) continue; // ok - if (!(~table->grant.privilege & want_access) || - table->is_anonymous_derived_table() || table->schema_table) + if (!(~tl->grant.privilege & want_access) || + tl->is_anonymous_derived_table() || tl->schema_table) { /* - It is subquery in the FROM clause. VIEW set table->derived after + It is subquery in the FROM clause. VIEW set tl->derived after table opening, but this function always called before table opening. */ - if (!table->referencing_view) + if (!tl->referencing_view) { /* If it's a temporary table created for a subquery in the FROM clause, or an INFORMATION_SCHEMA table, drop the request for a privilege. */ - table->grant.want_privilege= 0; + tl->grant.want_privilege= 0; } continue; } - if (!(grant_table= table_hash_search(sctx->host, sctx->ip, - table->get_db_name(), sctx->priv_user, - table->get_table_name(), FALSE))) + GRANT_TABLE *grant_table= table_hash_search(sctx->host, sctx->ip, + tl->get_db_name(), + sctx->priv_user, + tl->get_table_name(), + FALSE); + + if (!grant_table) { - want_access &= ~table->grant.privilege; + want_access &= ~tl->grant.privilege; goto err; // No grants } @@ -4136,18 +4139,17 @@ bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables, if (any_combination_will_do) continue; - table->grant.grant_table=grant_table; // Remember for column test - table->grant.version=grant_version; - table->grant.privilege|= grant_table->privs; - table->grant.want_privilege= ((want_access & COL_ACLS) - & ~table->grant.privilege); + tl->grant.grant_table= grant_table; // Remember for column test + tl->grant.version= grant_version; + tl->grant.privilege|= grant_table->privs; + tl->grant.want_privilege= ((want_access & COL_ACLS) & ~tl->grant.privilege); - if (!(~table->grant.privilege & want_access)) + if (!(~tl->grant.privilege & want_access)) continue; - if (want_access & ~(grant_table->cols | table->grant.privilege)) + if (want_access & ~(grant_table->cols | tl->grant.privilege)) { - want_access &= ~(grant_table->cols | table->grant.privilege); + want_access &= ~(grant_table->cols | tl->grant.privilege); goto err; // impossible } } @@ -4164,7 +4166,7 @@ err: command, sctx->priv_user, sctx->host_or_ip, - table ? table->get_table_name() : "unknown"); + tl ? tl->get_table_name() : "unknown"); } DBUG_RETURN(TRUE); } From 53e566a42a0203bf6b1054252da4dfea2b9442b8 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Tue, 31 Aug 2010 13:59:51 +0400 Subject: [PATCH 051/183] Remove check_merge_table_access(). check_merge_table_access() used to do two things: - set proper database for every merge table child; - check SELECT | UPDATE | DELETE for merge table children. Setting database is not needed anymore, since it's done on the parsing stage. Thus, check_merge_table_access() can be removed; needed privileges can be checked using check_table_access(). --- sql/sql_alter.cc | 13 +++++++----- sql/sql_parse.cc | 51 +++++++++--------------------------------------- sql/sql_parse.h | 3 --- 3 files changed, 17 insertions(+), 50 deletions(-) diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc index 046e09b20a3..5af01523aa7 100644 --- a/sql/sql_alter.cc +++ b/sql/sql_alter.cc @@ -13,8 +13,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "sql_parse.h" // check_access, - // check_merge_table_access +#include "sql_parse.h" // check_access #include "sql_table.h" // mysql_alter_table, // mysql_exchange_partition #include "sql_alter.h" @@ -60,11 +59,15 @@ bool Alter_table_statement::execute(THD *thd) check_access(thd, INSERT_ACL | CREATE_ACL, select_lex->db, &priv, NULL, /* Don't use first_tab->grant with sel_lex->db */ - 0, 0) || - check_merge_table_access(thd, first_table->db, - create_info.merge_list.first)) + 0, 0)) DBUG_RETURN(TRUE); /* purecov: inspected */ + /* If it is a merge table, check privileges for merge children. */ + if (create_info.merge_list.first && + check_table_access(thd, SELECT_ACL | UPDATE_ACL | DELETE_ACL, + create_info.merge_list.first, FALSE, UINT_MAX, FALSE)) + DBUG_RETURN(TRUE); + if (check_grant(thd, priv_needed, first_table, FALSE, UINT_MAX, FALSE)) DBUG_RETURN(TRUE); /* purecov: inspected */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a0b9959e626..aa9d29f3d07 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -642,45 +642,6 @@ end: } -/** - @brief Check access privs for a MERGE table and fix children lock types. - - @param[in] thd thread handle - @param[in] db database name - @param[in,out] table_list list of child tables (merge_list) - lock_type and optionally db set per table - - @return status - @retval 0 OK - @retval != 0 Error - - @detail - This function is used for write access to MERGE tables only - (CREATE TABLE, ALTER TABLE ... UNION=(...)). Set TL_WRITE for - every child. Set 'db' for every child if not present. -*/ -#ifndef NO_EMBEDDED_ACCESS_CHECKS -bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *table_list) -{ - int error= 0; - - if (table_list) - { - /* Check that all tables use the current database */ - TABLE_LIST *tlist; - - for (tlist= table_list; tlist; tlist= tlist->next_local) - { - if (!tlist->db || !tlist->db[0]) - tlist->db= db; /* purecov: inspected */ - } - error= check_table_access(thd, SELECT_ACL | UPDATE_ACL | DELETE_ACL, - table_list, FALSE, UINT_MAX, FALSE); - } - return error; -} -#endif - /* This works because items are allocated with sql_alloc() */ void free_items(Item *item) @@ -6963,10 +6924,16 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, if (check_access(thd, want_priv, create_table->db, &create_table->grant.privilege, &create_table->grant.m_internal, - 0, 0) || - check_merge_table_access(thd, create_table->db, - lex->create_info.merge_list.first)) + 0, 0)) goto err; + + /* If it is a merge table, check privileges for merge children. */ + if (lex->create_info.merge_list.first && + check_table_access(thd, SELECT_ACL | UPDATE_ACL | DELETE_ACL, + lex->create_info.merge_list.first, + FALSE, UINT_MAX, FALSE)) + goto err; + if (want_priv != CREATE_TMP_ACL && check_grant(thd, want_priv, create_table, FALSE, 1, FALSE)) goto err; diff --git a/sql/sql_parse.h b/sql/sql_parse.h index ad620544d29..c9b0f981d19 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -153,7 +153,6 @@ bool check_single_table_access(THD *thd, ulong privilege, bool check_routine_access(THD *thd,ulong want_access,char *db,char *name, bool is_proc, bool no_errors); bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table); -bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *table_list); bool check_some_routine_access(THD *thd, const char *db, const char *name, bool is_proc); bool check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, GRANT_INTERNAL_INFO *grant_internal_info, @@ -176,8 +175,6 @@ inline bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table) table->grant.privilege= want_access; return false; } -inline bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *table_list) -{ return false; } inline bool check_some_routine_access(THD *thd, const char *db, const char *name, bool is_proc) { return false; } From d2159e37f2931ac87baf956d21910a5edea1fcce Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Tue, 31 Aug 2010 14:03:36 +0400 Subject: [PATCH 052/183] Bug#27480 (Extend CREATE TEMPORARY TABLES privilege to allow temp table operations) -- prerequisite patch #3. Rename open_temporary_table() to open_table_uncached(). open_temporary_table() will be introduced in following patches to open temporary tables for a statement. --- sql/sql_base.cc | 40 +++++++++++++++++++++------------------- sql/sql_base.h | 5 +++-- sql/sql_table.cc | 19 ++++++++++++------- sql/sql_truncate.cc | 4 ++-- 4 files changed, 38 insertions(+), 30 deletions(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index feb63355353..8cd0ce4432a 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5696,35 +5696,37 @@ void close_tables_for_reopen(THD *thd, TABLE_LIST **tables, } -/* - Open a single table without table caching and don't set it in open_list +/** + Open a single table without table caching and don't add it to + THD::open_tables. Depending on the 'add_to_temporary_tables_list' value, + the opened TABLE instance will be addded to THD::temporary_tables list. - SYNPOSIS - open_temporary_table() - thd Thread object - path Path (without .frm) - db database - table_name Table name - link_in_list 1 if table should be linked into thd->temporary_tables + @param thd Thread context. + @param path Path (without .frm) + @param db Database name. + @param table_name Table name. + @param add_to_temporary_tables_list Specifies if the opened TABLE + instance should be linked into + THD::temporary_tables list. - NOTES: - Used by alter_table to open a temporary table and when creating - a temporary table with CREATE TEMPORARY ... + @note This function is used: + - by alter_table() to open a temporary table; + - when creating a temporary table with CREATE TEMPORARY TABLE. - RETURN - 0 Error - # TABLE object + @return TABLE instance for opened table. + @retval NULL on error. */ -TABLE *open_temporary_table(THD *thd, const char *path, const char *db, - const char *table_name, bool link_in_list) +TABLE *open_table_uncached(THD *thd, const char *path, const char *db, + const char *table_name, + bool add_to_temporary_tables_list) { TABLE *tmp_table; TABLE_SHARE *share; char cache_key[MAX_DBKEY_LENGTH], *saved_cache_key, *tmp_path; uint key_length; TABLE_LIST table_list; - DBUG_ENTER("open_temporary_table"); + DBUG_ENTER("open_table_uncached"); DBUG_PRINT("enter", ("table: '%s'.'%s' path: '%s' server_id: %u " "pseudo_thread_id: %lu", @@ -5767,7 +5769,7 @@ TABLE *open_temporary_table(THD *thd, const char *path, const char *db, share->tmp_table= (tmp_table->file->has_transactions() ? TRANSACTIONAL_TMP_TABLE : NON_TRANSACTIONAL_TMP_TABLE); - if (link_in_list) + if (add_to_temporary_tables_list) { /* growing temp list at the head */ tmp_table->next= thd->temporary_tables; diff --git a/sql/sql_base.h b/sql/sql_base.h index 56776bde1cc..a21850355b4 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -141,8 +141,9 @@ bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias, bool get_key_map_from_key_list(key_map *map, TABLE *table, List *index_list); -TABLE *open_temporary_table(THD *thd, const char *path, const char *db, - const char *table_name, bool link_in_list); +TABLE *open_table_uncached(THD *thd, const char *path, const char *db, + const char *table_name, + bool add_to_temporary_tables_list); TABLE *find_locked_table(TABLE *list, const char *db, const char *table_name); TABLE *find_write_locked_table(TABLE *list, const char *db, const char *table_name); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 06db813481d..9d8f59189d0 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -22,7 +22,7 @@ #include "sql_rename.h" // do_rename #include "sql_parse.h" // test_if_data_home_dir #include "sql_cache.h" // query_cache_* -#include "sql_base.h" // open_temporary_table, lock_table_names +#include "sql_base.h" // open_table_uncached, lock_table_names #include "lock.h" // wait_if_global_read_lock // start_waiting_global_read_lock, // mysql_unlock_tables @@ -4224,9 +4224,14 @@ bool mysql_create_table_no_lock(THD *thd, if (create_info->options & HA_LEX_CREATE_TMP_TABLE) { - TABLE *table= NULL; - /* Open table and put in temporary table list */ - if (!(table= open_temporary_table(thd, path, db, table_name, 1))) + /* + Open a table (skipping table cache) and add it into + THD::temporary_tables list. + */ + + TABLE *table= open_table_uncached(thd, path, db, table_name, TRUE); + + if (!table) { (void) rm_temporary_table(create_info->db_type, path); goto err; @@ -6301,8 +6306,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, /* table is a normal table: Create temporary table in same directory */ build_table_filename(path, sizeof(path) - 1, new_db, tmp_name, "", FN_IS_TMP); - /* Open our intermediate table */ - new_table= open_temporary_table(thd, path, new_db, tmp_name, 1); + /* Open our intermediate table. */ + new_table= open_table_uncached(thd, path, new_db, tmp_name, TRUE); } if (!new_table) goto err_new_table_cleanup; @@ -6642,7 +6647,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, char path[FN_REFLEN]; TABLE *t_table; build_table_filename(path + 1, sizeof(path) - 1, new_db, table_name, "", 0); - t_table= open_temporary_table(thd, path, new_db, tmp_name, 0); + t_table= open_table_uncached(thd, path, new_db, tmp_name, FALSE); if (t_table) { intern_close_table(t_table); diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index a61abdafe3e..c0bc726a188 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -208,8 +208,8 @@ static bool recreate_temporary_table(THD *thd, TABLE *table) ha_create_table(thd, share->normalized_path.str, share->db.str, share->table_name.str, &create_info, 1); - if (open_temporary_table(thd, share->path.str, share->db.str, - share->table_name.str, 1)) + if (open_table_uncached(thd, share->path.str, share->db.str, + share->table_name.str, TRUE)) { error= FALSE; thd->thread_specific_used= TRUE; From f62bf940afca94c1c23d6d2c47b6b8e8c0eaef91 Mon Sep 17 00:00:00 2001 From: Daniel Fischer Date: Tue, 31 Aug 2010 13:06:56 +0200 Subject: [PATCH 053/183] Bug#56387 Create initial database in the proper location --- sql/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 224cf67af7f..9d307da364d 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -271,8 +271,7 @@ IF(WIN32 AND MYSQLD_EXECUTABLE) COMMAND ${CMAKE_COMMAND} ${CONFIG_PARAM} -P ${CMAKE_CURRENT_BINARY_DIR}/create_initial_db.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data - COMMAND ${CMAKE_COMMAND} -E touch initdb.dep - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep DEPENDS mysqld ) ADD_CUSTOM_TARGET(initial_database From 00eb62847d101e5c4b2a690286e6e9397570c570 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Tue, 31 Aug 2010 17:47:10 +0400 Subject: [PATCH 054/183] Cherry-pick patch for Bug#56120 from mysql-5.5-bugfixing. --- mysql-test/r/func_group.result | 12 +++++++++++- mysql-test/t/func_group.test | 11 ++++++++++- sql/item.cc | 9 +++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 45c93971852..a9b3e98a26f 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1715,7 +1715,7 @@ drop table t1; # End of 5.1 tests # -# Bug#55648: Server crash on MIX/MAX on maximum time value +# Bug#55648: Server crash on MIN/MAX on maximum time value # CREATE TABLE t1(c1 TIME NOT NULL); INSERT INTO t1 VALUES('837:59:59'); @@ -1725,3 +1725,13 @@ MAX(c1) 838:59:59 DROP TABLE t1; # End of the bug#55648 +# +# Bug#56120: Failed assertion on MIN/MAX on negative time value +# +CREATE TABLE t1(c1 TIME NOT NULL); +INSERT INTO t1 VALUES('-00:00:01'); +SELECT MAX(c1),MIN(c1) FROM t1; +MAX(c1) MIN(c1) +-00:00:01 -00:00:01 +DROP TABLE t1; +# End of the bug#56120 diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 2914bb15d18..04c52dd32bd 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -1086,7 +1086,7 @@ drop table t1; --echo End of 5.1 tests --echo # ---echo # Bug#55648: Server crash on MIX/MAX on maximum time value +--echo # Bug#55648: Server crash on MIN/MAX on maximum time value --echo # CREATE TABLE t1(c1 TIME NOT NULL); INSERT INTO t1 VALUES('837:59:59'); @@ -1095,3 +1095,12 @@ SELECT MAX(c1) FROM t1; DROP TABLE t1; --echo # End of the bug#55648 +--echo # +--echo # Bug#56120: Failed assertion on MIN/MAX on negative time value +--echo # +CREATE TABLE t1(c1 TIME NOT NULL); +INSERT INTO t1 VALUES('-00:00:01'); +SELECT MAX(c1),MIN(c1) FROM t1; +DROP TABLE t1; +--echo # End of the bug#56120 + diff --git a/sql/item.cc b/sql/item.cc index 24f57342668..427146e11dc 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -7510,9 +7510,14 @@ String *Item_cache_datetime::val_str(String *str) return NULL; if (cached_field_type == MYSQL_TYPE_TIME) { - ulonglong time= int_value; - DBUG_ASSERT(time <= TIME_MAX_VALUE); + longlong time= int_value; set_zero_time(<ime, MYSQL_TIMESTAMP_TIME); + if (time < 0) + { + time= -time; + ltime.neg= TRUE; + } + DBUG_ASSERT(time <= TIME_MAX_VALUE); ltime.second= time % 100; time/= 100; ltime.minute= time % 100; From 55c1da5a7e814b9cd9cc8130518fd7b7e2c524a6 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Tue, 31 Aug 2010 17:49:41 +0400 Subject: [PATCH 055/183] Cherry-picking patch for Bug#56137 from mysql-5.5-runtime. ------------------------------------------------------------ revno: 3124 revision-id: dlenev@mysql.com-20100831090419-rzr5ktekby2gspm1 parent: alik@sun.com-20100827083901-x4wvtc10u9p7gcs9 committer: Dmitry Lenev branch nick: mysql-5.5-rt-56137 timestamp: Tue 2010-08-31 13:04:19 +0400 message: Bug #56137 "Assertion `thd->lock == 0' failed on upgrading from 5.1.50 to 5.5.6". Debug builds of the server aborted due to an assertion failure when DROP DATABASE statement was run on an installation which had outdated or corrupt mysql.proc table. Particularly this affected the mysql_upgrade tool which is run as part of 5.1 to 5.5 upgrade. The problem was that sp_drop_db_routines(), which was invoked during dropping of the database, could have returned without closing and unlocking mysql.proc table in cases when this table was not up-to-date with the current server. As a result further attempt to open and lock the mysql.event table, which was necessary to complete dropping of the database, ended up with an assert. This patch solves this problem by ensuring that sp_drop_db_routines() always closes mysql.proc table and releases metadata locks on it. This is achieved by changing open_proc_table_for_update() function to close tables and release metadata locks acquired by it in case of failure. This step also makes behavior of the latter function consistent with behavior of open_proc_table_for_read()/ open_and_lock_tables(). Test case for this bug was added to sp-destruct.test. ------------------------------------------------------------ --- mysql-test/r/sp-destruct.result | 16 ++++++++++++++++ mysql-test/t/sp-destruct.test | 30 ++++++++++++++++++++++++++++++ sql/sp.cc | 4 ++++ 3 files changed, 50 insertions(+) diff --git a/mysql-test/r/sp-destruct.result b/mysql-test/r/sp-destruct.result index a4933ee9800..32d0e39c5af 100644 --- a/mysql-test/r/sp-destruct.result +++ b/mysql-test/r/sp-destruct.result @@ -134,3 +134,19 @@ Warning 1405 Failed to revoke all privileges to dropped routine # Restore the procs_priv table RENAME TABLE procs_priv_backup TO mysql.procs_priv; FLUSH TABLE mysql.procs_priv; +# +# Bug #56137 "Assertion `thd->lock == 0' failed on upgrading from +# 5.1.50 to 5.5.6". +# +drop database if exists mysqltest; +# Backup mysql.proc. +flush table mysql.proc; +create database mysqltest; +# Corrupt mysql.proc to make it unusable by current version of server. +alter table mysql.proc drop column type; +# The below statement should not cause assertion failure. +drop database mysqltest; +Warnings: +Error 1547 Column count of mysql.proc is wrong. Expected 20, found 19. The table is probably corrupted +# Restore mysql.proc. +drop table mysql.proc; diff --git a/mysql-test/t/sp-destruct.test b/mysql-test/t/sp-destruct.test index b7090c01f1e..a5c287e44a8 100644 --- a/mysql-test/t/sp-destruct.test +++ b/mysql-test/t/sp-destruct.test @@ -222,3 +222,33 @@ SHOW WARNINGS; --echo # Restore the procs_priv table RENAME TABLE procs_priv_backup TO mysql.procs_priv; FLUSH TABLE mysql.procs_priv; + + +--echo # +--echo # Bug #56137 "Assertion `thd->lock == 0' failed on upgrading from +--echo # 5.1.50 to 5.5.6". +--echo # +--disable_warnings +drop database if exists mysqltest; +--enable_warnings +--echo # Backup mysql.proc. +flush table mysql.proc; +let $MYSQLD_DATADIR= `select @@datadir`; +--copy_file $MYSQLD_DATADIR/mysql/proc.frm $MYSQLTEST_VARDIR/tmp/proc.frm +--copy_file $MYSQLD_DATADIR/mysql/proc.MYD $MYSQLTEST_VARDIR/tmp/proc.MYD +--copy_file $MYSQLD_DATADIR/mysql/proc.MYI $MYSQLTEST_VARDIR/tmp/proc.MYI + +create database mysqltest; +--echo # Corrupt mysql.proc to make it unusable by current version of server. +alter table mysql.proc drop column type; +--echo # The below statement should not cause assertion failure. +drop database mysqltest; + +--echo # Restore mysql.proc. +drop table mysql.proc; +--copy_file $MYSQLTEST_VARDIR/tmp/proc.frm $MYSQLD_DATADIR/mysql/proc.frm +--copy_file $MYSQLTEST_VARDIR/tmp/proc.MYD $MYSQLD_DATADIR/mysql/proc.MYD +--copy_file $MYSQLTEST_VARDIR/tmp/proc.MYI $MYSQLD_DATADIR/mysql/proc.MYI +--remove_file $MYSQLTEST_VARDIR/tmp/proc.frm +--remove_file $MYSQLTEST_VARDIR/tmp/proc.MYD +--remove_file $MYSQLTEST_VARDIR/tmp/proc.MYI diff --git a/sql/sp.cc b/sql/sp.cc index 0265ef45a2a..8821dc9365d 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -440,6 +440,7 @@ static TABLE *open_proc_table_for_update(THD *thd) { TABLE_LIST table_list; TABLE *table; + MDL_ticket *mdl_savepoint= thd->mdl_context.mdl_savepoint(); DBUG_ENTER("open_proc_table_for_update"); table_list.init_one_table("mysql", 5, "proc", 4, "proc", TL_WRITE); @@ -450,6 +451,9 @@ static TABLE *open_proc_table_for_update(THD *thd) if (!proc_table_intact.check(table, &proc_table_def)) DBUG_RETURN(table); + close_thread_tables(thd); + thd->mdl_context.rollback_to_savepoint(mdl_savepoint); + DBUG_RETURN(NULL); } From 157f08061432e75124bab978dbaa275090bd3718 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Tue, 31 Aug 2010 18:22:03 +0400 Subject: [PATCH 056/183] Cherry-picking patch for Bug#55980. Original changeset: ------------------------------------------------------------ revno: 3197 revision-id: alik@sun.com-20100831135426-h5a4s2w6ih1d8q2x parent: magnus.blaudd@sun.com-20100830120632-u3xzy002mdwueli8 committer: Alexander Nozdrin branch nick: mysql-5.5-bugfixing timestamp: Tue 2010-08-31 17:54:26 +0400 message: Bug#55980 Character sets: supplementary character _bin ordering is wrong Problem: - ORDER BY for utf8mb4_bin, utf16_bin and utf32_bin returned results in a wrong order, because old functions (supporting only BMP range) were used to handle these collations. - Additionally, utf16_bin did not sort supplementary characters between U+D700 and U+E000, as WL#1213 specification specified. ------------------------------------------------------------ --- include/m_ctype.h | 5 ++ mysql-test/include/ctype_filesort2.inc | 16 ++++++ mysql-test/r/ctype_utf16.result | 25 +++++++++ mysql-test/r/ctype_utf32.result | 25 +++++++++ mysql-test/r/ctype_utf8mb4.result | 25 +++++++++ mysql-test/t/ctype_utf16.test | 1 + mysql-test/t/ctype_utf32.test | 1 + mysql-test/t/ctype_utf8mb4.test | 1 + strings/ctype-ucs2.c | 12 ++-- strings/ctype-utf8.c | 76 +++++++++++++++++++++++++- 10 files changed, 178 insertions(+), 9 deletions(-) create mode 100644 mysql-test/include/ctype_filesort2.inc diff --git a/include/m_ctype.h b/include/m_ctype.h index 06cbfd779c8..42e8f88cc0e 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -539,6 +539,11 @@ size_t my_strnxfrm_unicode(CHARSET_INFO *, uchar *dst, size_t dstlen, const uchar *src, size_t srclen); +size_t my_strnxfrm_unicode_full_bin(CHARSET_INFO *, + uchar *dst, size_t dstlen, + const uchar *src, size_t srclen); +size_t my_strnxfrmlen_unicode_full_bin(CHARSET_INFO *, size_t); + int my_wildcmp_unicode(CHARSET_INFO *cs, const char *str, const char *str_end, const char *wildstr, const char *wildend, diff --git a/mysql-test/include/ctype_filesort2.inc b/mysql-test/include/ctype_filesort2.inc new file mode 100644 index 00000000000..7b09eb482a5 --- /dev/null +++ b/mysql-test/include/ctype_filesort2.inc @@ -0,0 +1,16 @@ +# +# Testing filesort for full Unicode character sets +# with supplementary characters. +# + +--echo # +--echo # Bug#55980 Character sets: supplementary character _bin ordering is wrong +--echo # +CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0; +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES (_utf8mb4 0xEFBE9D),(_utf8mb4 0xF0908E84); +INSERT INTO t1 VALUES (_utf8mb4 0xCE85),(_utf8mb4 0xF4808080); +SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a; +ALTER TABLE t1 ADD KEY(a); +SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a; +DROP TABLE IF EXISTS t1; diff --git a/mysql-test/r/ctype_utf16.result b/mysql-test/r/ctype_utf16.result index c5fd7ef1439..7cee15aecef 100644 --- a/mysql-test/r/ctype_utf16.result +++ b/mysql-test/r/ctype_utf16.result @@ -611,6 +611,31 @@ utf16_bin 00610009 utf16_bin 0061 utf16_bin 00610020 drop table t1; +# +# Bug#55980 Character sets: supplementary character _bin ordering is wrong +# +CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf16 COLLATE utf16_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (_utf8mb4 0xEFBE9D),(_utf8mb4 0xF0908E84); +INSERT INTO t1 VALUES (_utf8mb4 0xCE85),(_utf8mb4 0xF4808080); +SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a; +HEX(a) HEX(CONVERT(a USING utf8mb4)) +0385 CE85 +D800DF84 F0908E84 +DBC0DC00 F4808080 +FF9D EFBE9D +ALTER TABLE t1 ADD KEY(a); +SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a; +HEX(a) HEX(CONVERT(a USING utf8mb4)) +0385 CE85 +D800DF84 F0908E84 +DBC0DC00 F4808080 +FF9D EFBE9D +DROP TABLE IF EXISTS t1; select @@collation_connection; @@collation_connection utf16_bin diff --git a/mysql-test/r/ctype_utf32.result b/mysql-test/r/ctype_utf32.result index 79e714eab47..94a73093154 100644 --- a/mysql-test/r/ctype_utf32.result +++ b/mysql-test/r/ctype_utf32.result @@ -610,6 +610,31 @@ utf32_bin 0000006100000009 utf32_bin 00000061 utf32_bin 0000006100000020 drop table t1; +# +# Bug#55980 Character sets: supplementary character _bin ordering is wrong +# +CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf32 COLLATE utf32_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (_utf8mb4 0xEFBE9D),(_utf8mb4 0xF0908E84); +INSERT INTO t1 VALUES (_utf8mb4 0xCE85),(_utf8mb4 0xF4808080); +SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a; +HEX(a) HEX(CONVERT(a USING utf8mb4)) +00000385 CE85 +0000FF9D EFBE9D +00010384 F0908E84 +00100000 F4808080 +ALTER TABLE t1 ADD KEY(a); +SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a; +HEX(a) HEX(CONVERT(a USING utf8mb4)) +00000385 CE85 +0000FF9D EFBE9D +00010384 F0908E84 +00100000 F4808080 +DROP TABLE IF EXISTS t1; select @@collation_connection; @@collation_connection utf32_bin diff --git a/mysql-test/r/ctype_utf8mb4.result b/mysql-test/r/ctype_utf8mb4.result index 454c9d4bfbb..3b9abbc5412 100644 --- a/mysql-test/r/ctype_utf8mb4.result +++ b/mysql-test/r/ctype_utf8mb4.result @@ -987,6 +987,31 @@ utf8mb4_bin 6109 utf8mb4_bin 61 utf8mb4_bin 6120 drop table t1; +# +# Bug#55980 Character sets: supplementary character _bin ordering is wrong +# +CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (_utf8mb4 0xEFBE9D),(_utf8mb4 0xF0908E84); +INSERT INTO t1 VALUES (_utf8mb4 0xCE85),(_utf8mb4 0xF4808080); +SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a; +HEX(a) HEX(CONVERT(a USING utf8mb4)) +CE85 CE85 +EFBE9D EFBE9D +F0908E84 F0908E84 +F4808080 F4808080 +ALTER TABLE t1 ADD KEY(a); +SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a; +HEX(a) HEX(CONVERT(a USING utf8mb4)) +CE85 CE85 +EFBE9D EFBE9D +F0908E84 F0908E84 +F4808080 F4808080 +DROP TABLE IF EXISTS t1; select @@collation_connection; @@collation_connection utf8mb4_bin diff --git a/mysql-test/t/ctype_utf16.test b/mysql-test/t/ctype_utf16.test index e9c7e569250..ef705474eee 100644 --- a/mysql-test/t/ctype_utf16.test +++ b/mysql-test/t/ctype_utf16.test @@ -326,6 +326,7 @@ SET collation_connection='utf16_general_ci'; SET NAMES latin1; SET collation_connection='utf16_bin'; -- source include/ctype_filesort.inc +-- source include/ctype_filesort2.inc -- source include/ctype_like_escape.inc # diff --git a/mysql-test/t/ctype_utf32.test b/mysql-test/t/ctype_utf32.test index 668b3b033bd..b113403944a 100644 --- a/mysql-test/t/ctype_utf32.test +++ b/mysql-test/t/ctype_utf32.test @@ -328,6 +328,7 @@ SET collation_connection='utf32_general_ci'; SET NAMES latin1; SET collation_connection='utf32_bin'; -- source include/ctype_filesort.inc +-- source include/ctype_filesort2.inc -- source include/ctype_like_escape.inc # diff --git a/mysql-test/t/ctype_utf8mb4.test b/mysql-test/t/ctype_utf8mb4.test index 8fcba92ff47..03696f385b5 100644 --- a/mysql-test/t/ctype_utf8mb4.test +++ b/mysql-test/t/ctype_utf8mb4.test @@ -733,6 +733,7 @@ SET collation_connection='utf8mb4_general_ci'; -- source include/ctype_german.inc SET collation_connection='utf8mb4_bin'; -- source include/ctype_filesort.inc +-- source include/ctype_filesort2.inc -- source include/ctype_like_escape.inc # diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index d3b0b93a939..ecfac3170d1 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1469,7 +1469,7 @@ my_strnncoll_utf16_bin(CHARSET_INFO *cs, } if (s_wc != t_wc) { - return s_wc > t_wc ? 1 : -1; + return my_bincmp(s, s + s_res, t, t + t_res); } s+= s_res; @@ -1511,7 +1511,7 @@ my_strnncollsp_utf16_bin(CHARSET_INFO *cs, if (s_wc != t_wc) { - return s_wc > t_wc ? 1 : -1; + return my_bincmp(s, s + s_res, t, t + t_res); } s+= s_res; @@ -1684,8 +1684,8 @@ static MY_COLLATION_HANDLER my_collation_utf16_bin_handler = NULL, /* init */ my_strnncoll_utf16_bin, my_strnncollsp_utf16_bin, - my_strnxfrm_unicode, - my_strnxfrmlen_simple, + my_strnxfrm_unicode_full_bin, + my_strnxfrmlen_unicode_full_bin, my_like_range_utf16, my_wildcmp_utf16_bin, my_strcasecmp_mb2_or_mb4, @@ -2711,8 +2711,8 @@ static MY_COLLATION_HANDLER my_collation_utf32_bin_handler = NULL, /* init */ my_strnncoll_utf32_bin, my_strnncollsp_utf32_bin, - my_strnxfrm_unicode, - my_strnxfrmlen_utf32, + my_strnxfrm_unicode_full_bin, + my_strnxfrmlen_unicode_full_bin, my_like_range_utf32, my_wildcmp_utf32_bin, my_strcasecmp_mb2_or_mb4, diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index ace39130c12..76fff72290b 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1893,7 +1893,13 @@ my_wildcmp_unicode(CHARSET_INFO *cs, /* - This function is shared between utf8mb3/utf8mb4/ucs2/utf16/utf32 + Store sorting weights using 2 bytes per character. + + This function is shared between + - utf8mb3_general_ci, utf8_bin, ucs2_general_ci, ucs2_bin + which support BMP only (U+0000..U+FFFF). + - utf8mb4_general_ci, utf16_general_ci, utf32_general_ci, + which map all supplementary characters to weight 0xFFFD. */ size_t my_strnxfrm_unicode(CHARSET_INFO *cs, @@ -1937,6 +1943,70 @@ my_strnxfrm_unicode(CHARSET_INFO *cs, } +/* + Store sorting weights using 3 bytes per character. + This function is shared between utf8mb4_bin, utf16_bin, utf32_bin. +*/ +size_t +my_strnxfrm_unicode_full_bin(CHARSET_INFO *cs, + uchar *dst, size_t dstlen, + const uchar *src, size_t srclen) +{ + my_wc_t wc; + uchar *de= dst + dstlen; + uchar *de_beg= de - 2; /* The beginning of the last chunk */ + const uchar *se = src + srclen; + + LINT_INIT(wc); + DBUG_ASSERT(src); + DBUG_ASSERT(cs->state & MY_CS_BINSORT); + + while (dst < de_beg) + { + int res; + if ((res= cs->cset->mb_wc(cs, &wc, src, se)) <= 0) + break; + src+= res; + if (cs->mbminlen == 2) /* utf16_bin */ + { + /* + Reorder code points to weights as follows: + U+0000..U+D7FF -> [00][00][00]..[00][D7][FF] BMP part #1 + U+10000..U+10FFFF -> [01][00][00]..[10][FF][FF] Supplementary + U+E000..U+FFFF -> [20][E0][00]..[20][FF][FF] BMP part #2 + */ + if (wc >= 0xE000 && wc <= 0xFFFF) + wc+= 0x200000; + } + *dst++= (uchar) (wc >> 16); + *dst++= (uchar) ((wc >> 8) & 0xFF); + *dst++= (uchar) (wc & 0xFF); + } + + while (dst < de_beg) /* Fill the tail with keys for space character */ + { + *dst++= 0x00; + *dst++= 0x00; + *dst++= 0x20; + } + + /* Clear the last one or two bytes, if "dstlen" was not divisible by 3 */ + if (dst < de) + { + *dst++= 0x00; + if (dst < de) + *dst= 0x00; + } + + return dstlen; +} + + +size_t +my_strnxfrmlen_unicode_full_bin(CHARSET_INFO *cs, size_t len) +{ + return ((len + 3) / cs->mbmaxlen) * 3; +} #endif /* HAVE_UNIDATA */ @@ -5067,8 +5137,8 @@ static MY_COLLATION_HANDLER my_collation_utf8mb4_bin_handler = NULL, /* init */ my_strnncoll_mb_bin, my_strnncollsp_mb_bin, - my_strnxfrm_unicode, - my_strnxfrmlen_utf8mb4, + my_strnxfrm_unicode_full_bin, + my_strnxfrmlen_unicode_full_bin, my_like_range_mb, my_wildcmp_mb_bin, my_strcasecmp_mb_bin, From 0ce793faf6ac6aa21bdb0dd687c8bf20b8e17833 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Tue, 31 Aug 2010 11:28:22 -0300 Subject: [PATCH 057/183] Bug#55846: Link tests fail on Windows - my_compiler.h missing Make the my_compiler.h header, like my_attribute.h, part of the distribution. This is required due to the dependency of the former on the latter (which can undefine __attribute__). --- include/CMakeLists.txt | 1 + include/Makefile.am | 7 ++++--- scripts/make_win_bin_dist | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index aee7561d242..5334fc0f5ae 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -54,6 +54,7 @@ SET(HEADERS keycache.h m_ctype.h my_attribute.h + my_compiler.h ${HEADERS_GEN_CONFIGURE} ) diff --git a/include/Makefile.am b/include/Makefile.am index e30588de065..b0e2402d46c 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -30,8 +30,9 @@ pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \ decimal.h errmsg.h my_global.h my_net.h \ my_getopt.h sslopt-longopts.h my_dir.h \ sslopt-vars.h sslopt-case.h sql_common.h keycache.h \ - m_ctype.h my_attribute.h $(HEADERS_GEN_CONFIGURE) \ - $(HEADERS_GEN_MAKE) probes_mysql.h probes_mysql_nodtrace.h + m_ctype.h my_attribute.h my_compiler.h \ + $(HEADERS_GEN_CONFIGURE) $(HEADERS_GEN_MAKE) \ + probes_mysql.h probes_mysql_nodtrace.h noinst_HEADERS = lf.h my_bit.h \ heap.h my_bitmap.h my_uctype.h password.h \ @@ -45,7 +46,7 @@ noinst_HEADERS = lf.h my_bit.h \ my_user.h my_atomic.h atomic/nolock.h \ atomic/rwlock.h atomic/x86-gcc.h atomic/generic-msvc.h \ atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \ - atomic/solaris.h mysql/innodb_priv.h my_compiler.h + atomic/solaris.h mysql/innodb_priv.h pkgpsiinclude_HEADERS = mysql/psi/psi.h mysql/psi/mysql_thread.h \ mysql/psi/mysql_file.h diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index 4fb57b06d71..aa106a3dfc4 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -260,6 +260,7 @@ cp include/mysql.h \ include/keycache.h \ include/m_ctype.h \ include/my_attribute.h \ + include/my_compiler.h \ include/mysqld_error.h \ include/sql_state.h \ include/mysqld_ername.h \ From f919f9e327020121579b4d54e9a6ede05cedf5f4 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Tue, 31 Aug 2010 18:33:19 +0400 Subject: [PATCH 058/183] Cherry-picking patch for Bug#55846. Original changeset: ------------------------------------------------------------ revno: 3186 revision-id: davi.arnaut@oracle.com-20100831142822-2qhufn3hho4xqr4p parent: gshchepa@mysql.com-20100830222201-ie7n43mjy4irlllk committer: Davi Arnaut branch nick: mysql-5.5-merge timestamp: Tue 2010-08-31 11:28:22 -0300 message: Bug#55846: Link tests fail on Windows - my_compiler.h missing Make the my_compiler.h header, like my_attribute.h, part of the distribution. This is required due to the dependency of the former on the latter (which can undefine __attribute__). ------------------------------------------------------------ --- include/CMakeLists.txt | 1 + include/Makefile.am | 7 ++++--- scripts/make_win_bin_dist | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index aee7561d242..5334fc0f5ae 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -54,6 +54,7 @@ SET(HEADERS keycache.h m_ctype.h my_attribute.h + my_compiler.h ${HEADERS_GEN_CONFIGURE} ) diff --git a/include/Makefile.am b/include/Makefile.am index e30588de065..b0e2402d46c 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -30,8 +30,9 @@ pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \ decimal.h errmsg.h my_global.h my_net.h \ my_getopt.h sslopt-longopts.h my_dir.h \ sslopt-vars.h sslopt-case.h sql_common.h keycache.h \ - m_ctype.h my_attribute.h $(HEADERS_GEN_CONFIGURE) \ - $(HEADERS_GEN_MAKE) probes_mysql.h probes_mysql_nodtrace.h + m_ctype.h my_attribute.h my_compiler.h \ + $(HEADERS_GEN_CONFIGURE) $(HEADERS_GEN_MAKE) \ + probes_mysql.h probes_mysql_nodtrace.h noinst_HEADERS = lf.h my_bit.h \ heap.h my_bitmap.h my_uctype.h password.h \ @@ -45,7 +46,7 @@ noinst_HEADERS = lf.h my_bit.h \ my_user.h my_atomic.h atomic/nolock.h \ atomic/rwlock.h atomic/x86-gcc.h atomic/generic-msvc.h \ atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \ - atomic/solaris.h mysql/innodb_priv.h my_compiler.h + atomic/solaris.h mysql/innodb_priv.h pkgpsiinclude_HEADERS = mysql/psi/psi.h mysql/psi/mysql_thread.h \ mysql/psi/mysql_file.h diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index 4fb57b06d71..aa106a3dfc4 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -260,6 +260,7 @@ cp include/mysql.h \ include/keycache.h \ include/m_ctype.h \ include/my_attribute.h \ + include/my_compiler.h \ include/mysqld_error.h \ include/sql_state.h \ include/mysqld_ername.h \ From 24fc7ca4c8899c71a4a6572987d7567e17eefcec Mon Sep 17 00:00:00 2001 From: Magne Mahre Date: Wed, 1 Sep 2010 19:38:34 +0200 Subject: [PATCH 059/183] Bug#39932 "create table fails if column for FK is in different case than in corr index". Server was unable to find existing or explicitly created supporting index for foreign key if corresponding statement clause used field names in case different than one used in key specification and created yet another supporting index. In cases when name of constraint (and thus name of generated index) was the same as name of existing/explicitly created index this led to duplicate key name error. The problem was that unlike all other code Key_part_spec::operator==() compared field names in case sensitive fashion. As result routines responsible for getting rid of redundant generated supporting indexes for foreign key were not working properly for versions of field names using different cases. (backported from mysql-trunk) --- mysql-test/suite/innodb/r/innodb_mysql.result | 20 +++++++++++++++++++ mysql-test/suite/innodb/t/innodb_mysql.test | 18 +++++++++++++++++ sql/sql_class.cc | 4 +++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result index ba8ac0ba86c..0a76a1fbcec 100644 --- a/mysql-test/suite/innodb/r/innodb_mysql.result +++ b/mysql-test/suite/innodb/r/innodb_mysql.result @@ -2588,3 +2588,23 @@ Extra Using index DROP TABLE t1; # End of 5.1 tests +# +# Test for bug #39932 "create table fails if column for FK is in different +# case than in corr index". +# +drop tables if exists t1, t2; +create table t1 (pk int primary key) engine=InnoDB; +# Even although the below statement uses uppercased field names in +# foreign key definition it still should be able to find explicitly +# created supporting index. So it should succeed and should not +# create any additional supporting indexes. +create table t2 (fk int, key x (fk), +constraint x foreign key (FK) references t1 (PK)) engine=InnoDB; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `fk` int(11) DEFAULT NULL, + KEY `x` (`fk`), + CONSTRAINT `x` FOREIGN KEY (`fk`) REFERENCES `t1` (`pk`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t2, t1; diff --git a/mysql-test/suite/innodb/t/innodb_mysql.test b/mysql-test/suite/innodb/t/innodb_mysql.test index ae03bebfbe3..cb534068c6e 100644 --- a/mysql-test/suite/innodb/t/innodb_mysql.test +++ b/mysql-test/suite/innodb/t/innodb_mysql.test @@ -813,3 +813,21 @@ DROP TABLE t1; --echo End of 5.1 tests + + +--echo # +--echo # Test for bug #39932 "create table fails if column for FK is in different +--echo # case than in corr index". +--echo # +--disable_warnings +drop tables if exists t1, t2; +--enable_warnings +create table t1 (pk int primary key) engine=InnoDB; +--echo # Even although the below statement uses uppercased field names in +--echo # foreign key definition it still should be able to find explicitly +--echo # created supporting index. So it should succeed and should not +--echo # create any additional supporting indexes. +create table t2 (fk int, key x (fk), + constraint x foreign key (FK) references t1 (PK)) engine=InnoDB; +show create table t2; +drop table t2, t1; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7c52e6957cc..44bb6d51c6c 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -91,7 +91,9 @@ extern "C" void free_user_var(user_var_entry *entry) bool Key_part_spec::operator==(const Key_part_spec& other) const { - return length == other.length && !strcmp(field_name, other.field_name); + return length == other.length && + !my_strcasecmp(system_charset_info, field_name, + other.field_name); } /** From 1ce9eb084f6ea6b5024cdbe36ad291d2761fcdd9 Mon Sep 17 00:00:00 2001 From: Alfranio Correia Date: Thu, 2 Sep 2010 14:05:06 +0100 Subject: [PATCH 060/183] BUG#55961 Savepoint Identifier should be enclosed with backticks Added backticks to the savepoint identifier. --- .../suite/binlog/r/binlog_row_mix_innodb_myisam.result | 8 ++++---- .../suite/binlog/r/binlog_stm_mix_innodb_myisam.result | 8 ++++---- mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result | 8 ++++---- mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result | 2 +- sql/log.cc | 8 ++++++-- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result index 8b42cadf6cb..8ee531c6ce2 100644 --- a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result +++ b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result @@ -48,12 +48,12 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # SAVEPOINT my_savepoint +master-bin.000001 # Query # # SAVEPOINT `my_savepoint` master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK TO my_savepoint +master-bin.000001 # Query # # ROLLBACK TO `my_savepoint` master-bin.000001 # Xid # # COMMIT /* XID */ delete from t1; delete from t2; @@ -77,12 +77,12 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # SAVEPOINT my_savepoint +master-bin.000001 # Query # # SAVEPOINT `my_savepoint` master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK TO my_savepoint +master-bin.000001 # Query # # ROLLBACK TO `my_savepoint` master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ diff --git a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result index a26fcc1dc1a..d2f47e56c61 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result +++ b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result @@ -44,10 +44,10 @@ show binlog events from ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(3) -master-bin.000001 # Query # # SAVEPOINT my_savepoint +master-bin.000001 # Query # # SAVEPOINT `my_savepoint` master-bin.000001 # Query # # use `test`; insert into t1 values(4) master-bin.000001 # Query # # use `test`; insert into t2 select * from t1 -master-bin.000001 # Query # # ROLLBACK TO my_savepoint +master-bin.000001 # Query # # ROLLBACK TO `my_savepoint` master-bin.000001 # Xid # # COMMIT /* XID */ delete from t1; delete from t2; @@ -70,10 +70,10 @@ show binlog events from ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(5) -master-bin.000001 # Query # # SAVEPOINT my_savepoint +master-bin.000001 # Query # # SAVEPOINT `my_savepoint` master-bin.000001 # Query # # use `test`; insert into t1 values(6) master-bin.000001 # Query # # use `test`; insert into t2 select * from t1 -master-bin.000001 # Query # # ROLLBACK TO my_savepoint +master-bin.000001 # Query # # ROLLBACK TO `my_savepoint` master-bin.000001 # Query # # use `test`; insert into t1 values(7) master-bin.000001 # Xid # # COMMIT /* XID */ delete from t1; diff --git a/mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result b/mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result index 3bf33044d75..f826136e81e 100644 --- a/mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result +++ b/mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result @@ -139,14 +139,14 @@ show binlog events from ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO db1.t1 VALUES(20) -master-bin.000001 # Query # # SAVEPOINT has_comment +master-bin.000001 # Query # # SAVEPOINT `has_comment` master-bin.000001 # Query # # use `db1`; INSERT INTO db1.t1 VALUES(30) master-bin.000001 # Query # # use `db1`; INSERT INTO db1.t2 VALUES("in savepoint has_comment") -master-bin.000001 # Query # # SAVEPOINT mixed_cases +master-bin.000001 # Query # # SAVEPOINT `mixed_cases` master-bin.000001 # Query # # use `db1`; INSERT INTO db1.t2 VALUES("in savepoint mixed_cases") master-bin.000001 # Query # # use `db1`; INSERT INTO db1.t1 VALUES(40) -master-bin.000001 # Query # # ROLLBACK TO mixed_cases -master-bin.000001 # Query # # ROLLBACK TO has_comment +master-bin.000001 # Query # # ROLLBACK TO `mixed_cases` +master-bin.000001 # Query # # ROLLBACK TO `has_comment` master-bin.000001 # Query # # use `db1`; INSERT INTO db1.t2 VALUES("after rollback to") master-bin.000001 # Query # # use `db1`; INSERT INTO db1.t1 VALUES(50) master-bin.000001 # Xid # # COMMIT /* XID */ diff --git a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result index 7fc940f25e0..d076a24e1f0 100644 --- a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result +++ b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result @@ -997,7 +997,7 @@ master-bin.000001 # Query # # use `test_rpl`; INSERT INTO t1 VALUES (3, 'before master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test_rpl`; INSERT INTO t1 VALUES (5, 'before savepoint s2') -master-bin.000001 # Query # # SAVEPOINT s2 +master-bin.000001 # Query # # SAVEPOINT `s2` master-bin.000001 # Query # # use `test_rpl`; INSERT INTO t1 VALUES (6, 'after savepoint s2') master-bin.000001 # Table_map # # table_id: # (test_rpl.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F diff --git a/sql/log.cc b/sql/log.cc index 156c293e3aa..503b3bb5cff 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1712,7 +1712,9 @@ static int binlog_savepoint_set(handlerton *hton, THD *thd, void *sv) String log_query; if (log_query.append(STRING_WITH_LEN("SAVEPOINT ")) || - log_query.append(thd->lex->ident.str, thd->lex->ident.length)) + log_query.append("`") || + log_query.append(thd->lex->ident.str, thd->lex->ident.length) || + log_query.append("`")) DBUG_RETURN(1); int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(), @@ -1734,7 +1736,9 @@ static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv) { String log_query; if (log_query.append(STRING_WITH_LEN("ROLLBACK TO ")) || - log_query.append(thd->lex->ident.str, thd->lex->ident.length)) + log_query.append("`") || + log_query.append(thd->lex->ident.str, thd->lex->ident.length) || + log_query.append("`")) DBUG_RETURN(1); int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(), From aad96fccada6d9077505117731a379cd2be8109a Mon Sep 17 00:00:00 2001 From: Joerg Bruehe Date: Thu, 2 Sep 2010 17:44:25 +0200 Subject: [PATCH 061/183] Check the build mechanisms: Do they support a "-rc" suffix? --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 59d08f0a9e5..eab7c32c068 100644 --- a/configure.in +++ b/configure.in @@ -27,7 +27,7 @@ dnl dnl When changing the major version number please also check the switch dnl statement in mysqlbinlog::check_master_version(). You may also need dnl to update version.c in ndb. -AC_INIT([MySQL Server], [5.5.6-m3], [], [mysql]) +AC_INIT([MySQL Server], [5.5.6-rc], [], [mysql]) AC_CONFIG_SRCDIR([sql/mysqld.cc]) AC_CANONICAL_SYSTEM From 8fd74f66a9e20c1f36ae28306c279eab2ce01aeb Mon Sep 17 00:00:00 2001 From: Joerg Bruehe Date: Mon, 6 Sep 2010 13:26:23 +0200 Subject: [PATCH 062/183] Fix bug#56547 mysql client interprets commands in comments The problem was not caused by a change in the client, rather by the tests using the Windows built-in "echo" and not the one built by MySQL. This again happened because the binary was missing in the package, caused by the wrong macro being used to build it in "cmake". --- client/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 771ebf290f1..e39e8d7178a 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -64,7 +64,10 @@ MYSQL_ADD_EXECUTABLE(mysqlslap mysqlslap.c) SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS") TARGET_LINK_LIBRARIES(mysqlslap mysqlclient) -ADD_EXECUTABLE(echo echo.c) +# "WIN32" also covers 64 bit. "echo" is used in some files below "mysql-test/". +IF(WIN32) + MYSQL_ADD_EXECUTABLE(echo echo.c) +ENDIF(WIN32) SET_TARGET_PROPERTIES (mysqlcheck mysqldump mysqlimport mysql_upgrade mysqlshow mysqlslap PROPERTIES HAS_CXX TRUE) From ac35157899451309a8d21becd983d584d221fbb7 Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Mon, 6 Sep 2010 21:29:02 +0400 Subject: [PATCH 063/183] A temporary workaround for bug #56405 "Deadlock in the MDL deadlock detector". Deadlock could have occurred when workload containing mix of DML, DDL and FLUSH TABLES statements affecting same set of tables was executed in heavily concurrent environment. This deadlock occurred when several connections tried to perform deadlock detection in metadata locking subsystem. The first connection started traversing wait-for graph, encountered sub-graph representing wait for flush, acquired LOCK_open and dived into sub-graph inspection. When it has encounterd sub-graph corresponding to wait for metadata lock and blocked while trying to acquire rd-lock on MDL_lock::m_rwlock (*) protecting this subgraph, since some other thread had wr-lock on it. When this wr-lock was released it could have happened (if there was other pending wr-lock against this rwlock) that rd-lock from the first connection was left unsatisfied but at the same time new rd-lock request from the second connection sneaked in and was satisfied (for this to be possible second rd- request should come exactly after wr-lock is released but before pending wr-lock manages to grab rwlock, which is possible both on Linux and in our own rwlock implementation). If this second connection continued traversing wait-for graph and encountered sub-graph representing wait for flush it tried to acquire LOCK_open and thus deadlock was created. This patch tries to workaround this problem but not allowing deadlock detector to lock LOCK_open mutex if some other thread doing deadlock detection already owns it and current search depth is greater than 0. Instead deadlock is reported. Other possible solutions are either known to have negative effects on performance or require much more time for proper implementation and testing. No test case is provided as this bug is very hard to repeat in MTR environment but is repeatable with the help of RQG tests. --- sql/mdl.cc | 34 ++++++++++++++++++++++++---------- sql/mdl.h | 16 +++++++++++++++- sql/sql_base.cc | 4 ++++ sql/sql_base.h | 2 ++ sql/table.cc | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 11 deletions(-) diff --git a/sql/mdl.cc b/sql/mdl.cc index d53ddcee0c8..aa7c2a4b7f2 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -124,7 +124,6 @@ public: Deadlock_detection_visitor(MDL_context *start_node_arg) : m_start_node(start_node_arg), m_victim(NULL), - m_current_search_depth(0), m_found_deadlock(FALSE) {} virtual bool enter_node(MDL_context *node); @@ -133,6 +132,8 @@ public: virtual bool inspect_edge(MDL_context *dest); MDL_context *get_victim() const { return m_victim; } + + void abort_traversal(MDL_context *node); private: /** Change the deadlock victim to a new one if it has lower deadlock @@ -147,13 +148,6 @@ private: MDL_context *m_start_node; /** If a deadlock is found, the context that identifies the victim. */ MDL_context *m_victim; - /** Set to the 0 at start. Increased whenever - we descend into another MDL context (aka traverse to the next - wait-for graph node). When MAX_SEARCH_DEPTH is reached, we - assume that a deadlock is found, even if we have not found a - loop. - */ - uint m_current_search_depth; /** TRUE if we found a deadlock. */ bool m_found_deadlock; /** @@ -187,7 +181,7 @@ private: bool Deadlock_detection_visitor::enter_node(MDL_context *node) { - m_found_deadlock= ++m_current_search_depth >= MAX_SEARCH_DEPTH; + m_found_deadlock= m_current_search_depth >= MAX_SEARCH_DEPTH; if (m_found_deadlock) { DBUG_ASSERT(! m_victim); @@ -207,7 +201,6 @@ bool Deadlock_detection_visitor::enter_node(MDL_context *node) void Deadlock_detection_visitor::leave_node(MDL_context *node) { - --m_current_search_depth; if (m_found_deadlock) opt_change_victim_to(node); } @@ -251,6 +244,21 @@ Deadlock_detection_visitor::opt_change_victim_to(MDL_context *new_victim) } +/** + Abort traversal of a wait-for graph and report a deadlock. + + @param node Node which we were about to visit when abort + was initiated. +*/ + +void Deadlock_detection_visitor::abort_traversal(MDL_context *node) +{ + DBUG_ASSERT(! m_victim); + m_found_deadlock= TRUE; + opt_change_victim_to(node); +} + + /** Get a bit corresponding to enum_mdl_type value in a granted/waiting bitmaps and compatibility matrices. @@ -2056,8 +2064,13 @@ bool MDL_lock::visit_subgraph(MDL_ticket *waiting_ticket, are visiting it but this is OK: in the worst case we might do some extra work and one more context might be chosen as a victim. */ + ++gvisitor->m_current_search_depth; + if (gvisitor->enter_node(src_ctx)) + { + --gvisitor->m_current_search_depth; goto end; + } /* We do a breadth-first search first -- that is, inspect all @@ -2114,6 +2127,7 @@ bool MDL_lock::visit_subgraph(MDL_ticket *waiting_ticket, end_leave_node: gvisitor->leave_node(src_ctx); + --gvisitor->m_current_search_depth; end: mysql_prlock_unlock(&m_rwlock); diff --git a/sql/mdl.h b/sql/mdl.h index 7938d833eac..e1d4cf74dd6 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -385,7 +385,10 @@ public: virtual bool inspect_edge(MDL_context *dest) = 0; virtual ~MDL_wait_for_graph_visitor(); - MDL_wait_for_graph_visitor() :m_lock_open_count(0) {} + MDL_wait_for_graph_visitor() :m_lock_open_count(0), + m_current_search_depth(0) + { } + virtual void abort_traversal(MDL_context *node) = 0; public: /** XXX, hack: During deadlock search, we may need to @@ -396,6 +399,17 @@ public: LOCK_open since it has significant performance impacts. */ uint m_lock_open_count; + /** + Set to the 0 at start. Increased whenever + we descend into another MDL context (aka traverse to the next + wait-for graph node). When MAX_SEARCH_DEPTH is reached, we + assume that a deadlock is found, even if we have not found a + loop. + + XXX: This member belongs to this class only temporarily until + bug #56405 is fixed. + */ + uint m_current_search_depth; }; /** diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 01ab0b6dec5..b168f561954 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -100,6 +100,8 @@ bool No_such_table_error_handler::safely_trapped_errors() TABLE_SHAREs, refresh_version and the table id counter. */ mysql_mutex_t LOCK_open; +mysql_mutex_t LOCK_dd_owns_lock_open; +uint dd_owns_lock_open= 0; #ifdef HAVE_PSI_INTERFACE static PSI_mutex_key key_LOCK_open; @@ -298,6 +300,7 @@ bool table_def_init(void) init_tdc_psi_keys(); #endif mysql_mutex_init(key_LOCK_open, &LOCK_open, MY_MUTEX_INIT_FAST); + mysql_mutex_init(NULL, &LOCK_dd_owns_lock_open, MY_MUTEX_INIT_FAST); oldest_unused_share= &end_of_unused_share; end_of_unused_share.prev= &oldest_unused_share; @@ -341,6 +344,7 @@ void table_def_free(void) table_def_inited= 0; /* Free table definitions. */ my_hash_free(&table_def_cache); + mysql_mutex_destroy(&LOCK_dd_owns_lock_open); mysql_mutex_destroy(&LOCK_open); } DBUG_VOID_RETURN; diff --git a/sql/sql_base.h b/sql/sql_base.h index ff935c3fc09..2e4554313e5 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -71,6 +71,8 @@ enum enum_tdc_remove_table_type {TDC_RT_REMOVE_ALL, TDC_RT_REMOVE_NOT_OWN, bool check_dup(const char *db, const char *name, TABLE_LIST *tables); extern mysql_mutex_t LOCK_open; +extern mysql_mutex_t LOCK_dd_owns_lock_open; +extern uint dd_owns_lock_open; bool table_cache_init(void); void table_cache_free(void); bool table_def_init(void); diff --git a/sql/table.cc b/sql/table.cc index f08a0aa84ca..030de6719c7 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3085,7 +3085,30 @@ bool TABLE_SHARE::visit_subgraph(Wait_for_flush *wait_for_flush, holding a write-lock on MDL_lock::m_rwlock. */ if (gvisitor->m_lock_open_count++ == 0) + { + /* + To circumvent bug #56405 "Deadlock in the MDL deadlock detector" + we don't try to lock LOCK_open mutex if some thread doing + deadlock detection already owns it and current search depth is + greater than 0. Instead we report a deadlock. + + TODO/FIXME: The proper fix for this bug is to use rwlocks for + protection of table shares/instead of LOCK_open. + Unfortunately it requires more effort/has significant + performance effect. + */ + mysql_mutex_lock(&LOCK_dd_owns_lock_open); + if (gvisitor->m_current_search_depth > 0 && dd_owns_lock_open > 0) + { + mysql_mutex_unlock(&LOCK_dd_owns_lock_open); + --gvisitor->m_lock_open_count; + gvisitor->abort_traversal(src_ctx); + return TRUE; + } + ++dd_owns_lock_open; + mysql_mutex_unlock(&LOCK_dd_owns_lock_open); mysql_mutex_lock(&LOCK_open); + } I_P_List_iterator tables_it(used_tables); @@ -3100,8 +3123,12 @@ bool TABLE_SHARE::visit_subgraph(Wait_for_flush *wait_for_flush, goto end; } + ++gvisitor->m_current_search_depth; if (gvisitor->enter_node(src_ctx)) + { + --gvisitor->m_current_search_depth; goto end; + } while ((table= tables_it++)) { @@ -3124,10 +3151,16 @@ bool TABLE_SHARE::visit_subgraph(Wait_for_flush *wait_for_flush, end_leave_node: gvisitor->leave_node(src_ctx); + --gvisitor->m_current_search_depth; end: if (gvisitor->m_lock_open_count-- == 1) + { mysql_mutex_unlock(&LOCK_open); + mysql_mutex_lock(&LOCK_dd_owns_lock_open); + --dd_owns_lock_open; + mysql_mutex_unlock(&LOCK_dd_owns_lock_open); + } return result; } From 1566c3657eff0af145ff4dc2420985d55df97d33 Mon Sep 17 00:00:00 2001 From: Jimmy Yang Date: Mon, 6 Sep 2010 22:41:37 -0700 Subject: [PATCH 064/183] Port fix for bug #53756 from 5.1 built-in to 5.1 plugin. --- .../innodb_plugin/r/innodb_bug53756.result | 118 +++++++++++ .../t/innodb_bug53756-master.opt | 1 + .../innodb_plugin/t/innodb_bug53756.test | 184 ++++++++++++++++++ storage/innodb_plugin/ChangeLog | 4 + storage/innodb_plugin/dict/dict0load.c | 27 ++- 5 files changed, 320 insertions(+), 14 deletions(-) create mode 100644 mysql-test/suite/innodb_plugin/r/innodb_bug53756.result create mode 100644 mysql-test/suite/innodb_plugin/t/innodb_bug53756-master.opt create mode 100644 mysql-test/suite/innodb_plugin/t/innodb_bug53756.test diff --git a/mysql-test/suite/innodb_plugin/r/innodb_bug53756.result b/mysql-test/suite/innodb_plugin/r/innodb_bug53756.result new file mode 100644 index 00000000000..37453be8201 --- /dev/null +++ b/mysql-test/suite/innodb_plugin/r/innodb_bug53756.result @@ -0,0 +1,118 @@ +DROP TABLE IF EXISTS bug_53756 ; +CREATE TABLE bug_53756 (pk INT, c1 INT) ENGINE=InnoDB; +ALTER TABLE bug_53756 ADD PRIMARY KEY (pk); +INSERT INTO bug_53756 VALUES(1, 11), (2, 22), (3, 33), (4, 44); + +# Select a less restrictive isolation level. +SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +COMMIT; + +# Start a transaction in the default connection for isolation. +START TRANSACTION; +SELECT @@tx_isolation; +@@tx_isolation +READ-COMMITTED +SELECT * FROM bug_53756; +pk c1 +1 11 +2 22 +3 33 +4 44 + +# connection con1 deletes row 1 +START TRANSACTION; +SELECT @@tx_isolation; +@@tx_isolation +READ-COMMITTED +DELETE FROM bug_53756 WHERE pk=1; + +# connection con2 deletes row 2 +START TRANSACTION; +SELECT @@tx_isolation; +@@tx_isolation +READ-COMMITTED +DELETE FROM bug_53756 WHERE pk=2; + +# connection con3 updates row 3 +START TRANSACTION; +SELECT @@tx_isolation; +@@tx_isolation +READ-COMMITTED +UPDATE bug_53756 SET c1=77 WHERE pk=3; + +# connection con4 updates row 4 +START TRANSACTION; +SELECT @@tx_isolation; +@@tx_isolation +READ-COMMITTED +UPDATE bug_53756 SET c1=88 WHERE pk=4; + +# connection con5 inserts row 5 +START TRANSACTION; +SELECT @@tx_isolation; +@@tx_isolation +READ-COMMITTED +INSERT INTO bug_53756 VALUES(5, 55); + +# connection con6 inserts row 6 +START TRANSACTION; +SELECT @@tx_isolation; +@@tx_isolation +READ-COMMITTED +INSERT INTO bug_53756 VALUES(6, 66); + +# connection con1 commits. +COMMIT; + +# connection con3 commits. +COMMIT; + +# connection con4 rolls back. +ROLLBACK; + +# connection con6 rolls back. +ROLLBACK; + +# The connections 2 and 5 stay open. + +# connection default selects resulting data. +# Delete of row 1 was committed. +# Update of row 3 was committed. +# Due to isolation level read committed, these should be included. +# All other changes should not be included. +SELECT * FROM bug_53756; +pk c1 +2 22 +3 77 +4 44 + +# connection default +# +# Crash server. +START TRANSACTION; +INSERT INTO bug_53756 VALUES (666,666); +SET SESSION debug="+d,crash_commit_before"; +COMMIT; +ERROR HY000: Lost connection to MySQL server during query + +# +# disconnect con1, con2, con3, con4, con5, con6. +# +# Restart server. + +# +# Select recovered data. +# Delete of row 1 was committed. +# Update of row 3 was committed. +# These should be included. +# All other changes should not be included. +# Delete of row 2 and insert of row 5 should be rolled back +SELECT * FROM bug_53756; +pk c1 +2 22 +3 77 +4 44 + +# Clean up. +DROP TABLE bug_53756; diff --git a/mysql-test/suite/innodb_plugin/t/innodb_bug53756-master.opt b/mysql-test/suite/innodb_plugin/t/innodb_bug53756-master.opt new file mode 100644 index 00000000000..425fda95086 --- /dev/null +++ b/mysql-test/suite/innodb_plugin/t/innodb_bug53756-master.opt @@ -0,0 +1 @@ +--skip-stack-trace --skip-core-file diff --git a/mysql-test/suite/innodb_plugin/t/innodb_bug53756.test b/mysql-test/suite/innodb_plugin/t/innodb_bug53756.test new file mode 100644 index 00000000000..0623be1d0ae --- /dev/null +++ b/mysql-test/suite/innodb_plugin/t/innodb_bug53756.test @@ -0,0 +1,184 @@ +# This is the test case for bug #53756. Alter table operation could +# leave a deleted record for the temp table (later renamed to the altered +# table) in the SYS_TABLES secondary index, we should ignore this row and +# find the first non-deleted row for the specified table_id when load table +# metadata in the function dict_load_table_on_id() during crash recovery. + +# +# innobackup needs to connect to the server. Not supported in embedded. +--source include/not_embedded.inc +# +# This test case needs to crash the server. Needs a debug server. +--source include/have_debug.inc +# +# Don't test this under valgrind, memory leaks will occur. +--source include/not_valgrind.inc +# +# This test case needs InnoDB. +-- source include/have_innodb_plugin.inc + +# +# Precautionary clean up. +# +--disable_warnings +DROP TABLE IF EXISTS bug_53756 ; +--enable_warnings + +# +# Create test data. +# +CREATE TABLE bug_53756 (pk INT, c1 INT) ENGINE=InnoDB; +ALTER TABLE bug_53756 ADD PRIMARY KEY (pk); +INSERT INTO bug_53756 VALUES(1, 11), (2, 22), (3, 33), (4, 44); + +--echo +--echo # Select a less restrictive isolation level. +# Don't use user variables. They won't survive server crash. +--let $global_isolation= `SELECT @@global.tx_isolation`; +--let $session_isolation= `SELECT @@session.tx_isolation`; +SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +COMMIT; + +--echo +--echo # Start a transaction in the default connection for isolation. +START TRANSACTION; +SELECT @@tx_isolation; +SELECT * FROM bug_53756; + +--echo +--echo # connection con1 deletes row 1 +--connect (con1,localhost,root,,) +START TRANSACTION; +SELECT @@tx_isolation; +DELETE FROM bug_53756 WHERE pk=1; + +--echo +--echo # connection con2 deletes row 2 +--connect (con2,localhost,root,,) +START TRANSACTION; +SELECT @@tx_isolation; +DELETE FROM bug_53756 WHERE pk=2; + +--echo +--echo # connection con3 updates row 3 +--connect (con3,localhost,root,,) +START TRANSACTION; +SELECT @@tx_isolation; +UPDATE bug_53756 SET c1=77 WHERE pk=3; + +--echo +--echo # connection con4 updates row 4 +--connect (con4,localhost,root,,) +START TRANSACTION; +SELECT @@tx_isolation; +UPDATE bug_53756 SET c1=88 WHERE pk=4; + +--echo +--echo # connection con5 inserts row 5 +--connect (con5,localhost,root,,) +START TRANSACTION; +SELECT @@tx_isolation; +INSERT INTO bug_53756 VALUES(5, 55); + +--echo +--echo # connection con6 inserts row 6 +--connect (con6,localhost,root,,) +START TRANSACTION; +SELECT @@tx_isolation; +INSERT INTO bug_53756 VALUES(6, 66); + +--echo +--echo # connection con1 commits. +--connection con1 +COMMIT; + +--echo +--echo # connection con3 commits. +--connection con3 +COMMIT; + +--echo +--echo # connection con4 rolls back. +--connection con4 +ROLLBACK; + +--echo +--echo # connection con6 rolls back. +--connection con6 +ROLLBACK; + +--echo +--echo # The connections 2 and 5 stay open. + +--echo +--echo # connection default selects resulting data. +--echo # Delete of row 1 was committed. +--echo # Update of row 3 was committed. +--echo # Due to isolation level read committed, these should be included. +--echo # All other changes should not be included. +--connection default +SELECT * FROM bug_53756; + +--echo +--echo # connection default +--connection default +--echo # +--echo # Crash server. +# +# Write file to make mysql-test-run.pl expect the "crash", but don't start +# it until it's told to +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +# +START TRANSACTION; +INSERT INTO bug_53756 VALUES (666,666); +# +# Request a crash on next execution of commit. +SET SESSION debug="+d,crash_commit_before"; +# +# Execute the statement that causes the crash. +--error 2013 +COMMIT; +--echo +--echo # +--echo # disconnect con1, con2, con3, con4, con5, con6. +--disconnect con1 +--disconnect con2 +--disconnect con3 +--disconnect con4 +--disconnect con5 +--disconnect con6 +--echo # +--echo # Restart server. +# +# Write file to make mysql-test-run.pl start up the server again +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +# +# Turn on reconnect +--enable_reconnect +# +# Call script that will poll the server waiting for it to be back online again +--source include/wait_until_connected_again.inc +# +# Turn off reconnect again +--disable_reconnect +--echo + +--echo # +--echo # Select recovered data. +--echo # Delete of row 1 was committed. +--echo # Update of row 3 was committed. +--echo # These should be included. +--echo # All other changes should not be included. +--echo # Delete of row 2 and insert of row 5 should be rolled back +SELECT * FROM bug_53756; + +--echo +--echo # Clean up. +DROP TABLE bug_53756; + +--disable_query_log +eval SET GLOBAL tx_isolation= '$global_isolation'; +eval SET SESSION tx_isolation= '$session_isolation'; +--enable_query_log + diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index 538cd40dd5b..19ff64562fc 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,7 @@ +2010-09-06 The InnoDB Team + * dict/dict0load.c, innodb_bug53756.test innodb_bug53756.result + Fix Bug #53756 ALTER TABLE ADD PRIMARY KEY affects crash recovery + 2010-08-24 The InnoDB Team * handler/ha_innodb.c, dict/dict0dict.c: diff --git a/storage/innodb_plugin/dict/dict0load.c b/storage/innodb_plugin/dict/dict0load.c index 3c495d21786..e20c9c57379 100644 --- a/storage/innodb_plugin/dict/dict0load.c +++ b/storage/innodb_plugin/dict/dict0load.c @@ -1072,6 +1072,8 @@ dict_load_table_on_id( ut_ad(mutex_own(&(dict_sys->mutex))); + table = NULL; + /* NOTE that the operation of this function is protected by the dictionary mutex, and therefore no deadlocks can occur with other dictionary operations. */ @@ -1098,15 +1100,17 @@ dict_load_table_on_id( BTR_SEARCH_LEAF, &pcur, &mtr); rec = btr_pcur_get_rec(&pcur); - if (!btr_pcur_is_on_user_rec(&pcur) - || rec_get_deleted_flag(rec, 0)) { + if (!btr_pcur_is_on_user_rec(&pcur)) { /* Not found */ + goto func_exit; + } - btr_pcur_close(&pcur); - mtr_commit(&mtr); - mem_heap_free(heap); - - return(NULL); + /* Find the first record that is not delete marked */ + while (rec_get_deleted_flag(rec, 0)) { + if (!btr_pcur_move_to_next_user_rec(&pcur, &mtr)) { + goto func_exit; + } + rec = btr_pcur_get_rec(&pcur); } /*---------------------------------------------------*/ @@ -1119,19 +1123,14 @@ dict_load_table_on_id( /* Check if the table id in record is the one searched for */ if (ut_dulint_cmp(table_id, mach_read_from_8(field)) != 0) { - - btr_pcur_close(&pcur); - mtr_commit(&mtr); - mem_heap_free(heap); - - return(NULL); + goto func_exit; } /* Now we get the table name from the record */ field = rec_get_nth_field_old(rec, 1, &len); /* Load the table definition to memory */ table = dict_load_table(mem_heap_strdupl(heap, (char*) field, len)); - +func_exit: btr_pcur_close(&pcur); mtr_commit(&mtr); mem_heap_free(heap); From 14dbc7e4e6e18c44dff136313dd85f94f8ae0118 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Tue, 7 Sep 2010 14:18:01 +0700 Subject: [PATCH 065/183] Fixed bug #47485 - mysql_store_result returns a not NULL result set for a prepared statement. --- include/mysql.h | 3 +- include/mysql.h.pp | 3 +- libmysql/libmysql.c | 6 ++- tests/mysql_client_test.c | 102 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 4 deletions(-) diff --git a/include/mysql.h b/include/mysql.h index dcf3e167e6a..699bd1f1b7f 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -224,7 +224,8 @@ struct st_mysql_options { enum mysql_status { - MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,MYSQL_STATUS_USE_RESULT + MYSQL_STATUS_READY, MYSQL_STATUS_GET_RESULT, MYSQL_STATUS_USE_RESULT, + MYSQL_STATUS_STATEMENT_GET_RESULT }; enum mysql_protocol_type diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 0a397863022..ceb4b2d591c 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -293,7 +293,8 @@ struct st_mysql_options { }; enum mysql_status { - MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,MYSQL_STATUS_USE_RESULT + MYSQL_STATUS_READY, MYSQL_STATUS_GET_RESULT, MYSQL_STATUS_USE_RESULT, + MYSQL_STATUS_STATEMENT_GET_RESULT }; enum mysql_protocol_type { diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 362ad5de6c4..8c612b6894e 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2503,6 +2503,8 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length) set_stmt_errmsg(stmt, net); DBUG_RETURN(1); } + else if (mysql->status == MYSQL_STATUS_GET_RESULT) + stmt->mysql->status= MYSQL_STATUS_STATEMENT_GET_RESULT; DBUG_RETURN(0); } @@ -2641,7 +2643,7 @@ static int stmt_read_row_unbuffered(MYSQL_STMT *stmt, unsigned char **row) set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate, NULL); return 1; } - if (mysql->status != MYSQL_STATUS_GET_RESULT) + if (mysql->status != MYSQL_STATUS_STATEMENT_GET_RESULT) { set_stmt_error(stmt, stmt->unbuffered_fetch_cancelled ? CR_FETCH_CANCELED : CR_COMMANDS_OUT_OF_SYNC, @@ -4847,7 +4849,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) DBUG_RETURN(1); } } - else if (mysql->status != MYSQL_STATUS_GET_RESULT) + else if (mysql->status != MYSQL_STATUS_STATEMENT_GET_RESULT) { set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate, NULL); DBUG_RETURN(1); diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 87c35666ac6..3bfcf3ee233 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -18297,6 +18297,107 @@ static void test_bug54041() } +/** + Bug#47485: mysql_store_result returns a result set for a prepared statement +*/ +static void test_bug47485() +{ + MYSQL_STMT *stmt; + MYSQL_RES *res; + MYSQL_BIND bind[2]; + int rc; + const char* sql_select = "SELECT 1, 'a'"; + int int_data; + char str_data[16]; + my_bool is_null[2]; + my_bool error[2]; + unsigned long length[2]; + + DBUG_ENTER("test_bug47485"); + myheader("test_bug47485"); + + stmt= mysql_stmt_init(mysql); + check_stmt(stmt); + rc= mysql_stmt_prepare(stmt, sql_select, strlen(sql_select)); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + res = mysql_store_result(mysql); + DIE_UNLESS(res == NULL); + + mysql_stmt_reset(stmt); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + res = mysql_use_result(mysql); + DIE_UNLESS(res == NULL); + + mysql_stmt_reset(stmt); + + memset(bind, 0, sizeof(bind)); + bind[0].buffer_type= MYSQL_TYPE_LONG; + bind[0].buffer= (char *)&int_data; + bind[0].is_null= &is_null[0]; + bind[0].length= &length[0]; + bind[0].error= &error[0]; + + bind[1].buffer_type= MYSQL_TYPE_STRING; + bind[1].buffer= (char *)str_data; + bind[1].buffer_length= sizeof(str_data); + bind[1].is_null= &is_null[1]; + bind[1].length= &length[1]; + bind[1].error= &error[1]; + + rc= mysql_stmt_bind_result(stmt, bind); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + rc= mysql_stmt_store_result(stmt); + check_execute(stmt, rc); + + while (!(rc= mysql_stmt_fetch(stmt))) + ; + + DIE_UNLESS(rc == MYSQL_NO_DATA); + + mysql_stmt_reset(stmt); + + memset(bind, 0, sizeof(bind)); + bind[0].buffer_type= MYSQL_TYPE_LONG; + bind[0].buffer= (char *)&int_data; + bind[0].is_null= &is_null[0]; + bind[0].length= &length[0]; + bind[0].error= &error[0]; + + bind[1].buffer_type= MYSQL_TYPE_STRING; + bind[1].buffer= (char *)str_data; + bind[1].buffer_length= sizeof(str_data); + bind[1].is_null= &is_null[1]; + bind[1].length= &length[1]; + bind[1].error= &error[1]; + + rc= mysql_stmt_bind_result(stmt, bind); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + while (!(rc= mysql_stmt_fetch(stmt))) + ; + + DIE_UNLESS(rc == MYSQL_NO_DATA); + + mysql_stmt_close(stmt); + + DBUG_VOID_RETURN; +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -18622,6 +18723,7 @@ static struct my_tests_st my_tests[]= { { "test_bug44495", test_bug44495 }, { "test_bug42373", test_bug42373 }, { "test_bug54041", test_bug54041 }, + { "test_bug47485", test_bug47485 }, { 0, 0 } }; From 3d5b9792e61d0a5afba550fabd7bfbb3b35a4073 Mon Sep 17 00:00:00 2001 From: Martin Hansson Date: Tue, 7 Sep 2010 09:58:05 +0200 Subject: [PATCH 066/183] Bug#54543: update ignore with incorrect subquery leads to assertion failure: inited==INDEX When an error occurs while sending the data in a temporary table there was no cleanup performed. This caused a failed assertion in the case when different access methods were used for populating the table vs. retrieving the data from the table if IGNORE was specified and sql_safe_updates = 0. In this case execution continues, but the handler expects to continue with the access method used for row retrieval. Fixed by doing the cleanup even if errors occur. --- mysql-test/r/multi_update.result | 20 ++++++++++++++++++++ mysql-test/t/multi_update.test | 21 +++++++++++++++++++++ sql/sql_select.cc | 18 ++++++++---------- 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index ae72f416c79..d77ad1d2953 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -639,4 +639,24 @@ SET SESSION sql_safe_updates = 1; UPDATE IGNORE t1, t1 t1a SET t1.a = 1 WHERE t1a.a = 1; ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column DROP TABLE t1; +# +# Bug#54543: update ignore with incorrect subquery leads to assertion +# failure: inited==INDEX +# +SET SESSION sql_safe_updates = 0; +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES (1), (2); +CREATE TABLE t2 ( a INT ); +INSERT INTO t2 VALUES (1), (2); +CREATE TABLE t3 ( a INT ); +INSERT INTO t3 VALUES (1), (2); +# Should not crash +UPDATE IGNORE +( SELECT ( SELECT COUNT(*) FROM t1 GROUP BY a, @v ) a FROM t2 ) x, t3 +SET t3.a = 0; +Warnings: +Error 1242 Subquery returns more than 1 row +Error 1242 Subquery returns more than 1 row +DROP TABLE t1, t2, t3; +SET SESSION sql_safe_updates = DEFAULT; end of tests diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 559408eb90e..85d2ed19fda 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -651,5 +651,26 @@ SET SESSION sql_safe_updates = 1; UPDATE IGNORE t1, t1 t1a SET t1.a = 1 WHERE t1a.a = 1; DROP TABLE t1; +--echo # +--echo # Bug#54543: update ignore with incorrect subquery leads to assertion +--echo # failure: inited==INDEX +--echo # +SET SESSION sql_safe_updates = 0; +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES (1), (2); + +CREATE TABLE t2 ( a INT ); +INSERT INTO t2 VALUES (1), (2); + +CREATE TABLE t3 ( a INT ); +INSERT INTO t3 VALUES (1), (2); + +--echo # Should not crash +UPDATE IGNORE + ( SELECT ( SELECT COUNT(*) FROM t1 GROUP BY a, @v ) a FROM t2 ) x, t3 +SET t3.a = 0; + +DROP TABLE t1, t2, t3; +SET SESSION sql_safe_updates = DEFAULT; --echo end of tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 4a32ca34790..f550f75c8b8 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -11157,22 +11157,20 @@ do_select(JOIN *join,List *fields,TABLE *table,Procedure *procedure) if (error == NESTED_LOOP_NO_MORE_ROWS) error= NESTED_LOOP_OK; + if (table == NULL) // If sending data to client + /* + The following will unlock all cursors if the command wasn't an + update command + */ + join->join_free(); // Unlock all cursors if (error == NESTED_LOOP_OK) { /* Sic: this branch works even if rc != 0, e.g. when send_data above returns an error. */ - if (!table) // If sending data to client - { - /* - The following will unlock all cursors if the command wasn't an - update command - */ - join->join_free(); // Unlock all cursors - if (join->result->send_eof()) - rc= 1; // Don't send error - } + if (table == NULL && join->result->send_eof()) // If sending data to client + rc= 1; // Don't send error DBUG_PRINT("info",("%ld records output", (long) join->send_records)); } else From 70807d147396b8a0a698a38f4033a91a3b8be90a Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Tue, 7 Sep 2010 15:53:46 +0700 Subject: [PATCH 067/183] Fixed bug #55421 - Protocol::end_statement(): Assertion `0' on multi-table UPDATE IGNORE. The problem was that if there was an active SELECT statement during trigger execution, an error risen during the execution may cause a crash. The fix is to temporary reset LEX::current_select before trigger execution and restore it afterwards. This way errors risen during the trigger execution are processed as if there was no active SELECT. --- mysql-test/r/trigger_notembedded.result | 21 +++++++++++ mysql-test/t/trigger_notembedded.test | 48 +++++++++++++++++++++++++ sql/sql_trigger.cc | 9 +++++ 3 files changed, 78 insertions(+) diff --git a/mysql-test/r/trigger_notembedded.result b/mysql-test/r/trigger_notembedded.result index d66308a9bd7..cba41660ced 100644 --- a/mysql-test/r/trigger_notembedded.result +++ b/mysql-test/r/trigger_notembedded.result @@ -474,4 +474,25 @@ SHOW CREATE TRIGGER db1.trg; ERROR 42000: Access denied; you need the TRIGGER privilege for this operation DROP USER 'no_rights'@'localhost'; DROP DATABASE db1; +DROP DATABASE IF EXISTS mysqltest_db1; +CREATE DATABASE mysqltest_db1; +USE mysqltest_db1; +GRANT ALL ON mysqltest_db1.* TO mysqltest_u1@localhost; +CREATE TABLE t1 ( +a1 int, +a2 int +); +INSERT INTO t1 VALUES (1, 20); +CREATE TRIGGER mysqltest_db1.upd_t1 +BEFORE UPDATE ON t1 FOR EACH ROW SET new.a2 = 200; +CREATE TABLE t2 ( +a1 int +); +INSERT INTO t2 VALUES (2); +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost; +UPDATE IGNORE t1, t2 SET t1.a1 = 2, t2.a1 = 3 WHERE t1.a1 = 1 AND t2.a1 = 2; +ERROR 42000: TRIGGER command denied to user 'mysqltest_u1'@'localhost' for table 't1' +DROP DATABASE mysqltest_db1; +DROP USER mysqltest_u1@localhost; +USE test; End of 5.1 tests. diff --git a/mysql-test/t/trigger_notembedded.test b/mysql-test/t/trigger_notembedded.test index 7a7e6c6bc85..387944ffb47 100644 --- a/mysql-test/t/trigger_notembedded.test +++ b/mysql-test/t/trigger_notembedded.test @@ -932,4 +932,52 @@ disconnect con1; DROP USER 'no_rights'@'localhost'; DROP DATABASE db1; +# +# Bug#55421 Protocol::end_statement(): Assertion `0' on multi-table UPDATE IGNORE +# To reproduce a crash we need to provoke a trigger execution with +# the following conditions: +# - active SELECT statement during trigger execution +# (i.e. LEX::current_select != NULL); +# - IGNORE option (i.e. LEX::current_select->no_error == TRUE); +--disable_warnings +DROP DATABASE IF EXISTS mysqltest_db1; +--enable_warnings + +CREATE DATABASE mysqltest_db1; +USE mysqltest_db1; + +GRANT ALL ON mysqltest_db1.* TO mysqltest_u1@localhost; + +--connect(con1,localhost,mysqltest_u1,,mysqltest_db1) + +CREATE TABLE t1 ( + a1 int, + a2 int +); +INSERT INTO t1 VALUES (1, 20); + +CREATE TRIGGER mysqltest_db1.upd_t1 +BEFORE UPDATE ON t1 FOR EACH ROW SET new.a2 = 200; + +CREATE TABLE t2 ( + a1 int +); + +INSERT INTO t2 VALUES (2); + +--connection default + +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost; + +--error ER_TABLEACCESS_DENIED_ERROR +UPDATE IGNORE t1, t2 SET t1.a1 = 2, t2.a1 = 3 WHERE t1.a1 = 1 AND t2.a1 = 2; +# Cleanup + +DROP DATABASE mysqltest_db1; +DROP USER mysqltest_u1@localhost; + +--disconnect con1 +--connection default +USE test; + --echo End of 5.1 tests. diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index bf4a46a4c67..9348feaa22a 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1989,6 +1989,7 @@ bool Table_triggers_list::process_triggers(THD *thd, bool err_status; Sub_statement_state statement_state; sp_head *sp_trigger= bodies[event][time_type]; + SELECT_LEX *save_current_select; if (sp_trigger == NULL) return FALSE; @@ -2012,11 +2013,19 @@ bool Table_triggers_list::process_triggers(THD *thd, thd->reset_sub_statement_state(&statement_state, SUB_STMT_TRIGGER); + /* + Reset current_select before call execute_trigger() and + restore it after return from one. This way error is set + in case of failure during trigger execution. + */ + save_current_select= thd->lex->current_select; + thd->lex->current_select= NULL; err_status= sp_trigger->execute_trigger(thd, &trigger_table->s->db, &trigger_table->s->table_name, &subject_table_grants[event][time_type]); + thd->lex->current_select= save_current_select; thd->restore_sub_statement_state(&statement_state); From babebf9cebd2218fcc29e7d0cdbecb501f6fec30 Mon Sep 17 00:00:00 2001 From: Martin Hansson Date: Tue, 7 Sep 2010 11:21:09 +0200 Subject: [PATCH 068/183] Bug#51070: Query with a NOT IN subquery predicate returns a wrong result set The EXISTS transformation has additional switches to catch the known corner cases that appear when transforming an IN predicate into EXISTS. Guarded conditions are used which are deactivated when a NULL value is seen in the outer expression's row. When the inner query block supplies NULL values, however, they are filtered out because no distinction is made between the guarded conditions; guarded NOT x IS NULL conditions in the HAVING clause that filter out NULL values cannot be de-activated in isolation from those that match values or from the outer expression or NULL's. The above problem is handled by making the guarded conditions remember whether they have rejected a NULL value or not, and index access methods are taking this into account as well. The bug consisted of 1) Not resetting the property for every nested loop iteration on the inner query's result. 2) Not propagating the NULL result properly from inner query to IN optimizer. 3) A hack that may or may not have been needed at some point. According to a comment it was aimed to fix #2 by returning NULL when FALSE was actually the result. This caused failures when #2 was properly fixed. The hack is now removed. The fix resolves all three points. --- mysql-test/r/subselect4.result | 86 ++++++++++++++++++++++++++++++++++ mysql-test/t/subselect4.test | 62 ++++++++++++++++++++++++ sql/item_cmpfunc.cc | 79 +++++++++++++++++++++++++++++-- sql/item_subselect.cc | 48 ++++++++----------- 4 files changed, 243 insertions(+), 32 deletions(-) diff --git a/mysql-test/r/subselect4.result b/mysql-test/r/subselect4.result index fad65d3f000..63265970c4b 100644 --- a/mysql-test/r/subselect4.result +++ b/mysql-test/r/subselect4.result @@ -77,6 +77,92 @@ Note 1249 Select 2 was reduced during optimization CREATE VIEW v1 AS SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); CREATE VIEW v2 AS SELECT 1 LIKE '%' ESCAPE ( 1 IN ( SELECT 1 ) ); DROP VIEW v1, v2; +# +# Bug#51070: Query with a NOT IN subquery predicate returns a wrong +# result set +# +CREATE TABLE t1 ( a INT, b INT ); +INSERT INTO t1 VALUES ( 1, NULL ), ( 2, NULL ); +CREATE TABLE t2 ( c INT, d INT ); +INSERT INTO t2 VALUES ( NULL, 3 ), ( NULL, 4 ); +CREATE TABLE t3 ( e INT, f INT ); +INSERT INTO t3 VALUES ( NULL, NULL ), ( NULL, NULL ); +CREATE TABLE t4 ( a INT ); +INSERT INTO t4 VALUES (1), (2), (3); +CREATE TABLE t5 ( a INT ); +INSERT INTO t5 VALUES (NULL), (2); +EXPLAIN +SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ); +id select_type table type possible_keys key key_len ref rows Extra +x PRIMARY x x x x x x x x +x DEPENDENT SUBQUERY x x x x x x x x +SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ); +a b +EXPLAIN +SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS NULL; +a b +1 NULL +2 NULL +SELECT * FROM t1 WHERE ( a, b ) IN ( SELECT c, d FROM t2 ) IS NULL; +a b +1 NULL +2 NULL +SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS UNKNOWN; +a b +1 NULL +2 NULL +SELECT * FROM t1 WHERE (( a, b ) NOT IN ( SELECT c, d FROM t2 )) IS UNKNOWN; +a b +1 NULL +2 NULL +SELECT * FROM t1 WHERE 1 = 1 AND ( a, b ) NOT IN ( SELECT c, d FROM t2 ); +a b +EXPLAIN +SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT e, f FROM t3 ); +id select_type table type possible_keys key key_len ref rows Extra +x PRIMARY x x x x x x x x +x DEPENDENT SUBQUERY x x x x x x x x +SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT e, f FROM t3 ); +a b +EXPLAIN +SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT a, b FROM t1 ); +id select_type table type possible_keys key key_len ref rows Extra +x PRIMARY x x x x x x x x +x DEPENDENT SUBQUERY x x x x x x x x +SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT a, b FROM t1 ); +c d +EXPLAIN +SELECT * FROM t3 WHERE ( e, f ) NOT IN ( SELECT c, d FROM t2 ); +id select_type table type possible_keys key key_len ref rows Extra +x PRIMARY x x x x x x x x +x DEPENDENT SUBQUERY x x x x x x x x +SELECT * FROM t3 WHERE ( e, f ) NOT IN ( SELECT c, d FROM t2 ); +e f +EXPLAIN +SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT e, f FROM t3 ); +id select_type table type possible_keys key key_len ref rows Extra +x PRIMARY x x x x x x x x +x DEPENDENT SUBQUERY x x x x x x x x +SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT e, f FROM t3 ); +c d +SELECT * FROM t1 WHERE ( a, b ) NOT IN +( SELECT c, d FROM t2 WHERE c = 1 AND c <> 1 ); +a b +1 NULL +2 NULL +SELECT * FROM t1 WHERE b NOT IN ( SELECT c FROM t2 WHERE c = 1 ); +a b +1 NULL +2 NULL +SELECT * FROM t1 WHERE NULL NOT IN ( SELECT c FROM t2 WHERE c = 1 AND c <> 1 ); +a b +1 NULL +2 NULL +DROP TABLE t1, t2, t3, t4, t5; # # End of 5.1 tests. # diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test index 2c6efdbaac2..eb8baf9bac8 100644 --- a/mysql-test/t/subselect4.test +++ b/mysql-test/t/subselect4.test @@ -74,6 +74,68 @@ CREATE VIEW v1 AS SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); CREATE VIEW v2 AS SELECT 1 LIKE '%' ESCAPE ( 1 IN ( SELECT 1 ) ); DROP VIEW v1, v2; +--echo # +--echo # Bug#51070: Query with a NOT IN subquery predicate returns a wrong +--echo # result set +--echo # +CREATE TABLE t1 ( a INT, b INT ); +INSERT INTO t1 VALUES ( 1, NULL ), ( 2, NULL ); + +CREATE TABLE t2 ( c INT, d INT ); +INSERT INTO t2 VALUES ( NULL, 3 ), ( NULL, 4 ); + +CREATE TABLE t3 ( e INT, f INT ); +INSERT INTO t3 VALUES ( NULL, NULL ), ( NULL, NULL ); + +CREATE TABLE t4 ( a INT ); +INSERT INTO t4 VALUES (1), (2), (3); + +CREATE TABLE t5 ( a INT ); +INSERT INTO t5 VALUES (NULL), (2); + +--replace_column 1 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x +EXPLAIN +SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ); +SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ); + +EXPLAIN +SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS NULL; +SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS NULL; +SELECT * FROM t1 WHERE ( a, b ) IN ( SELECT c, d FROM t2 ) IS NULL; +SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS UNKNOWN; +SELECT * FROM t1 WHERE (( a, b ) NOT IN ( SELECT c, d FROM t2 )) IS UNKNOWN; + +SELECT * FROM t1 WHERE 1 = 1 AND ( a, b ) NOT IN ( SELECT c, d FROM t2 ); + +--replace_column 1 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x +EXPLAIN +SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT e, f FROM t3 ); +SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT e, f FROM t3 ); + +--replace_column 1 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x +EXPLAIN +SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT a, b FROM t1 ); +SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT a, b FROM t1 ); + +--replace_column 1 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x +EXPLAIN +SELECT * FROM t3 WHERE ( e, f ) NOT IN ( SELECT c, d FROM t2 ); +SELECT * FROM t3 WHERE ( e, f ) NOT IN ( SELECT c, d FROM t2 ); + +--replace_column 1 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x +EXPLAIN +SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT e, f FROM t3 ); +SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT e, f FROM t3 ); + +SELECT * FROM t1 WHERE ( a, b ) NOT IN + ( SELECT c, d FROM t2 WHERE c = 1 AND c <> 1 ); + +SELECT * FROM t1 WHERE b NOT IN ( SELECT c FROM t2 WHERE c = 1 ); + +SELECT * FROM t1 WHERE NULL NOT IN ( SELECT c FROM t2 WHERE c = 1 AND c <> 1 ); + +DROP TABLE t1, t2, t3, t4, t5; + --echo # --echo # End of 5.1 tests. diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index fe4616f64d7..605d12742f8 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1751,6 +1751,76 @@ bool Item_in_optimizer::fix_fields(THD *thd, Item **ref) } +/** + The implementation of optimized \ [NOT] IN \ + predicates. The implementation works as follows. + + For the current value of the outer expression + + - If it contains only NULL values, the original (before rewrite by the + Item_in_subselect rewrite methods) inner subquery is non-correlated and + was previously executed, there is no need to re-execute it, and the + previous return value is returned. + + - If it contains NULL values, check if there is a partial match for the + inner query block by evaluating it. For clarity we repeat here the + transformation previously performed on the sub-query. The expression + + + ( oc_1, ..., oc_n ) + \ + ( SELECT ic_1, ..., ic_n + FROM \ + WHERE \ + ) + + + was transformed into + + + ( oc_1, ..., oc_n ) + \ + ( SELECT ic_1, ..., ic_n + FROM \ + WHERE \ AND ... ( ic_k = oc_k OR ic_k IS NULL ) + HAVING ... NOT ic_k IS NULL + ) + + + The evaluation will now proceed according to special rules set up + elsewhere. These rules include: + + - The HAVING NOT \ IS NULL conditions added by the + aforementioned rewrite methods will detect whether they evaluated (and + rejected) a NULL value and if so, will cause the subquery to evaluate + to NULL. + + - The added WHERE and HAVING conditions are present only for those inner + columns that correspond to outer column that are not NULL at the moment. + + - If there is an eligible index for executing the subquery, the special + access method "Full scan on NULL key" is employed which ensures that + the inner query will detect if there are NULL values resulting from the + inner query. This access method will quietly resort to table scan if it + needs to find NULL values as well. + + - Under these conditions, the sub-query need only be evaluated in order to + find out whether it produced any rows. + + - If it did, we know that there was a partial match since there are + NULL values in the outer row expression. + + - If it did not, the result is FALSE or UNKNOWN. If at least one of the + HAVING sub-predicates rejected a NULL value corresponding to an outer + non-NULL, and hence the inner query block returns UNKNOWN upon + evaluation, there was a partial match and the result is UNKNOWN. + + - If it contains no NULL values, the call is forwarded to the inner query + block. + + @see Item_in_subselect::val_bool() + @see Item_is_not_null_test::val_int() + */ longlong Item_in_optimizer::val_int() { bool tmp; @@ -1804,7 +1874,7 @@ longlong Item_in_optimizer::val_int() all_left_cols_null= false; } - if (!((Item_in_subselect*)args[1])->is_correlated && + if (!item_subs->is_correlated && all_left_cols_null && result_for_null_param != UNKNOWN) { /* @@ -1818,8 +1888,11 @@ longlong Item_in_optimizer::val_int() else { /* The subquery has to be evaluated */ - (void) args[1]->val_bool_result(); - null_value= !item_subs->engine->no_rows(); + (void) item_subs->val_bool_result(); + if (item_subs->engine->no_rows()) + null_value= item_subs->null_value; + else + null_value= TRUE; if (all_left_cols_null) result_for_null_param= null_value; } diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index b93ea6f241b..d0c933df845 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -47,7 +47,7 @@ Item_subselect::Item_subselect(): item value is NULL if select_subselect not changed this value (i.e. some rows will be found returned) */ - null_value= 1; + null_value= TRUE; } @@ -427,9 +427,9 @@ void Item_maxmin_subselect::print(String *str, enum_query_type query_type) void Item_singlerow_subselect::reset() { - null_value= 1; + null_value= TRUE; if (value) - value->null_value= 1; + value->null_value= TRUE; } @@ -574,7 +574,7 @@ double Item_singlerow_subselect::val_real() DBUG_ASSERT(fixed == 1); if (!exec() && !value->null_value) { - null_value= 0; + null_value= FALSE; return value->val_real(); } else @@ -589,7 +589,7 @@ longlong Item_singlerow_subselect::val_int() DBUG_ASSERT(fixed == 1); if (!exec() && !value->null_value) { - null_value= 0; + null_value= FALSE; return value->val_int(); } else @@ -603,7 +603,7 @@ String *Item_singlerow_subselect::val_str(String *str) { if (!exec() && !value->null_value) { - null_value= 0; + null_value= FALSE; return value->val_str(str); } else @@ -618,7 +618,7 @@ my_decimal *Item_singlerow_subselect::val_decimal(my_decimal *decimal_value) { if (!exec() && !value->null_value) { - null_value= 0; + null_value= FALSE; return value->val_decimal(decimal_value); } else @@ -633,7 +633,7 @@ bool Item_singlerow_subselect::val_bool() { if (!exec() && !value->null_value) { - null_value= 0; + null_value= FALSE; return value->val_bool(); } else @@ -651,7 +651,7 @@ Item_exists_subselect::Item_exists_subselect(st_select_lex *select_lex): bool val_bool(); init(select_lex, new select_exists_subselect(this)); max_columns= UINT_MAX; - null_value= 0; //can't be NULL + null_value= FALSE; //can't be NULL maybe_null= 0; //can't be NULL value= 0; DBUG_VOID_RETURN; @@ -814,15 +814,14 @@ double Item_in_subselect::val_real() */ DBUG_ASSERT(0); DBUG_ASSERT(fixed == 1); - null_value= 0; + null_value= was_null= FALSE; if (exec()) { reset(); - null_value= 1; return 0; } if (was_null && !value) - null_value= 1; + null_value= TRUE; return (double) value; } @@ -835,15 +834,14 @@ longlong Item_in_subselect::val_int() */ DBUG_ASSERT(0); DBUG_ASSERT(fixed == 1); - null_value= 0; + null_value= was_null= FALSE; if (exec()) { reset(); - null_value= 1; return 0; } if (was_null && !value) - null_value= 1; + null_value= TRUE; return value; } @@ -856,16 +854,15 @@ String *Item_in_subselect::val_str(String *str) */ DBUG_ASSERT(0); DBUG_ASSERT(fixed == 1); - null_value= 0; + null_value= was_null= FALSE; if (exec()) { reset(); - null_value= 1; return 0; } if (was_null && !value) { - null_value= 1; + null_value= TRUE; return 0; } str->set((ulonglong)value, &my_charset_bin); @@ -876,20 +873,14 @@ String *Item_in_subselect::val_str(String *str) bool Item_in_subselect::val_bool() { DBUG_ASSERT(fixed == 1); - null_value= 0; + null_value= was_null= FALSE; if (exec()) { reset(); - /* - Must mark the IN predicate as NULL so as to make sure an enclosing NOT - predicate will return FALSE. See the comments in - subselect_uniquesubquery_engine::copy_ref_key for further details. - */ - null_value= 1; return 0; } if (was_null && !value) - null_value= 1; + null_value= TRUE; return value; } @@ -900,16 +891,15 @@ my_decimal *Item_in_subselect::val_decimal(my_decimal *decimal_value) method should not be used */ DBUG_ASSERT(0); - null_value= 0; + null_value= was_null= FALSE; DBUG_ASSERT(fixed == 1); if (exec()) { reset(); - null_value= 1; return 0; } if (was_null && !value) - null_value= 1; + null_value= TRUE; int2my_decimal(E_DEC_FATAL_ERROR, value, 0, decimal_value); return decimal_value; } From 5caea4a995130cd7c82574acc591ff7c46d9d978 Mon Sep 17 00:00:00 2001 From: Kristofer Pettersson Date: Tue, 7 Sep 2010 11:37:46 +0200 Subject: [PATCH 069/183] Bug#55531 crash with conversions of geometry types / strings Convertion from a floating point number to a string caused a crash. During rare circumstances a String object could crash when it was requested to allocate new memory. A crash could occcur in Field_double::val_str() because of a pointer referencing memory inside a String object which was of unknown size. And finally, the geometric collection should not accept arguments which are non geometric. --- mysql-test/r/gis.result | 60 ++++------------------------------------- mysql-test/t/gis.test | 42 ++++++++++++++++++----------- sql/field.cc | 2 +- sql/item_geofunc.h | 13 +++++++++ 4 files changed, 46 insertions(+), 71 deletions(-) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 3e28227d542..565563237d1 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -707,10 +707,7 @@ numgeometries(b) IS NULL, numinteriorrings(b) IS NULL, numpoints(b) IS NULL, area(b) IS NULL, glength(b) IS NULL, srid(b) IS NULL, x(b) IS NULL, y(b) IS NULL from t1; -geometryfromtext(b) IS NULL geometryfromwkb(b) IS NULL astext(b) IS NULL aswkb(b) IS NULL geometrytype(b) IS NULL centroid(b) IS NULL envelope(b) IS NULL startpoint(b) IS NULL endpoint(b) IS NULL exteriorring(b) IS NULL pointn(b, 1) IS NULL geometryn(b, 1) IS NULL interiorringn(b, 1) IS NULL multipoint(b) IS NULL isempty(b) IS NULL issimple(b) IS NULL isclosed(b) IS NULL dimension(b) IS NULL numgeometries(b) IS NULL numinteriorrings(b) IS NULL numpoints(b) IS NULL area(b) IS NULL glength(b) IS NULL srid(b) IS NULL x(b) IS NULL y(b) IS NULL -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +ERROR 22007: Illegal non geometric '' value found during parsing select within(b, b) IS NULL, contains(b, b) IS NULL, overlaps(b, b) IS NULL, equals(b, b) IS NULL, disjoint(b, b) IS NULL, touches(b, b) IS NULL, @@ -725,10 +722,7 @@ point(b, b) IS NULL, linestring(b) IS NULL, polygon(b) IS NULL, multipoint(b) IS multilinestring(b) IS NULL, multipolygon(b) IS NULL, geometrycollection(b) IS NULL from t1; -point(b, b) IS NULL linestring(b) IS NULL polygon(b) IS NULL multipoint(b) IS NULL multilinestring(b) IS NULL multipolygon(b) IS NULL geometrycollection(b) IS NULL -0 1 1 1 1 1 1 -1 1 1 1 1 1 1 -0 1 1 1 1 1 1 +ERROR 22007: Illegal non geometric '' value found during parsing drop table t1; CREATE TABLE t1(a POINT) ENGINE=MyISAM; INSERT INTO t1 VALUES (NULL); @@ -1010,51 +1004,7 @@ f5 datetime YES NULL drop view v1; drop table t1; SELECT MultiPoint(12345,''); -MultiPoint(12345,'') -NULL -SELECT MultiPoint(123451,''); -MultiPoint(123451,'') -NULL -SELECT MultiPoint(1234512,''); -MultiPoint(1234512,'') -NULL -SELECT MultiPoint(12345123,''); -MultiPoint(12345123,'') -NULL -SELECT MultiLineString(12345,''); -MultiLineString(12345,'') -NULL -SELECT MultiLineString(123451,''); -MultiLineString(123451,'') -NULL -SELECT MultiLineString(1234512,''); -MultiLineString(1234512,'') -NULL -SELECT MultiLineString(12345123,''); -MultiLineString(12345123,'') -NULL -SELECT LineString(12345,''); -LineString(12345,'') -NULL -SELECT LineString(123451,''); -LineString(123451,'') -NULL -SELECT LineString(1234512,''); -LineString(1234512,'') -NULL -SELECT LineString(12345123,''); -LineString(12345123,'') -NULL -SELECT Polygon(12345,''); -Polygon(12345,'') -NULL -SELECT Polygon(123451,''); -Polygon(123451,'') -NULL -SELECT Polygon(1234512,''); -Polygon(1234512,'') -NULL -SELECT Polygon(12345123,''); -Polygon(12345123,'') -NULL +ERROR 22007: Illegal non geometric '12345' value found during parsing +SELECT 1 FROM (SELECT GREATEST(1,GEOMETRYCOLLECTION('00000','00000')) b FROM DUAL) AS d WHERE (LINESTRING(d.b)); +ERROR 22007: Illegal non geometric '' value found during parsing End of 5.1 tests diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index bc0695aaa93..5a367188163 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -401,6 +401,7 @@ create table t1 (a int, b blob); insert into t1 values (1, ''), (2, NULL), (3, '1'); select * from t1; +--error ER_ILLEGAL_VALUE_FOR_TYPE select geometryfromtext(b) IS NULL, geometryfromwkb(b) IS NULL, astext(b) IS NULL, aswkb(b) IS NULL, geometrytype(b) IS NULL, centroid(b) IS NULL, @@ -419,6 +420,7 @@ select intersects(b, b) IS NULL, crosses(b, b) IS NULL from t1; +--error ER_ILLEGAL_VALUE_FOR_TYPE select point(b, b) IS NULL, linestring(b) IS NULL, polygon(b) IS NULL, multipoint(b) IS NULL, multilinestring(b) IS NULL, multipolygon(b) IS NULL, @@ -702,24 +704,34 @@ drop table t1; # Bug#44684: valgrind reports invalid reads in # Item_func_spatial_collection::val_str # +--error ER_ILLEGAL_VALUE_FOR_TYPE SELECT MultiPoint(12345,''); -SELECT MultiPoint(123451,''); -SELECT MultiPoint(1234512,''); -SELECT MultiPoint(12345123,''); +#SELECT MultiPoint(123451,''); +#SELECT MultiPoint(1234512,''); +#SELECT MultiPoint(12345123,''); -SELECT MultiLineString(12345,''); -SELECT MultiLineString(123451,''); -SELECT MultiLineString(1234512,''); -SELECT MultiLineString(12345123,''); +--error ER_ILLEGAL_VALUE_FOR_TYPE +#SELECT MultiLineString(12345,''); +#SELECT MultiLineString(123451,''); +#SELECT MultiLineString(1234512,''); +#SELECT MultiLineString(12345123,''); -SELECT LineString(12345,''); -SELECT LineString(123451,''); -SELECT LineString(1234512,''); -SELECT LineString(12345123,''); +--error ER_ILLEGAL_VALUE_FOR_TYPE +#SELECT LineString(12345,''); +#SELECT LineString(123451,''); +#SELECT LineString(1234512,''); +#SELECT LineString(12345123,''); -SELECT Polygon(12345,''); -SELECT Polygon(123451,''); -SELECT Polygon(1234512,''); -SELECT Polygon(12345123,''); +--error ER_ILLEGAL_VALUE_FOR_TYPE +#SELECT Polygon(12345,''); +#SELECT Polygon(123451,''); +#SELECT Polygon(1234512,''); +#SELECT Polygon(12345123,''); + +# +# Bug55531 crash with conversions of geometry types / strings +# +--error ER_ILLEGAL_VALUE_FOR_TYPE +SELECT 1 FROM (SELECT GREATEST(1,GEOMETRYCOLLECTION('00000','00000')) b FROM DUAL) AS d WHERE (LINESTRING(d.b)); --echo End of 5.1 tests diff --git a/sql/field.cc b/sql/field.cc index 619e6a780da..724f8e0af73 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4561,7 +4561,7 @@ String *Field_double::val_str(String *val_buffer, #endif doubleget(nr,ptr); - uint to_length=max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE); + uint to_length= DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE; val_buffer->alloc(to_length); char *to=(char*) val_buffer->ptr(); diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index edbe104e307..070c2cd26fc 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -175,6 +175,19 @@ public: item_type=it; } String *val_str(String *); + void fix_length_and_dec() + { + for( unsigned int i=0; ifixed && args[i]->field_type() != MYSQL_TYPE_GEOMETRY) + { + String str; + args[i]->val_str(&str); + my_error(ER_ILLEGAL_VALUE_FOR_TYPE,MYF(0),"non geometric",str.c_ptr()); + } + } + } + const char *func_name() const { return "multipoint"; } }; From dc285eb7cd1e22fe8f6feac065b03602a6d804c3 Mon Sep 17 00:00:00 2001 From: Kristofer Pettersson Date: Tue, 7 Sep 2010 15:43:00 +0200 Subject: [PATCH 070/183] Post fix following fix for bug55531: Disabling testcase for bug 55568 because {1} isn't a valid geometry for a geometry collection. --- mysql-test/r/join.result | 35 -------------------------- mysql-test/t/join.test | 54 +++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 60 deletions(-) diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index 9a8b441b363..96504df4b1e 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -1185,41 +1185,6 @@ NULL 1 DROP TABLE t1, t2, mm1; # -# Bug #55568: user variable assignments crash server when used within -# query -# -CREATE TABLE t1 (a INT); -INSERT INTO t1 VALUES (0), (1); -SELECT MULTIPOINT( -1, -( -SELECT MULTIPOINT( -MULTIPOINT( -1, -(SELECT COUNT(*) FROM (SELECT 1 FROM t1 GROUP BY a,a) d) -) -) FROM t1 -) -) != COUNT(*) q FROM t1 GROUP BY a; -q -NULL -NULL -SELECT MULTIPOINT( -1, -( -SELECT MULTIPOINT( -MULTIPOINT( -1, -(SELECT COUNT(*) FROM (SELECT 1 FROM t1 GROUP BY a,a) d) -) -) FROM t1 -) -) != COUNT(*) q FROM t1 GROUP BY a; -q -NULL -NULL -DROP TABLE t1; -# # Bug #54468: crash after item's print() function when ordering/grouping # by subquery # diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index 73a1ae5eb82..05d630edfb2 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -851,33 +851,37 @@ ENGINE=MERGE UNION=(t1,t2); SELECT t1.a FROM mm1,t1; DROP TABLE t1, t2, mm1; ---echo # ---echo # Bug #55568: user variable assignments crash server when used within ---echo # query ---echo # +#--echo # +#--echo # Bug #55568: user variable assignments crash server when used within +#--echo # query +#--echo # +# +# +# This test case is invalidated because of fix of bug 55531 +# The reason is that {1} is not a valid geometric collection. +# +#CREATE TABLE t1 (a INT); -CREATE TABLE t1 (a INT); +#INSERT INTO t1 VALUES (0), (1); -INSERT INTO t1 VALUES (0), (1); - -let $i=2; -while ($i) -{ - SELECT MULTIPOINT( - 1, - ( - SELECT MULTIPOINT( - MULTIPOINT( - 1, - (SELECT COUNT(*) FROM (SELECT 1 FROM t1 GROUP BY a,a) d) - ) - ) FROM t1 - ) - ) != COUNT(*) q FROM t1 GROUP BY a; - dec $i; -} - -DROP TABLE t1; +#let $i=2; +#while ($i) +#{ +# SELECT MULTIPOINT( +# 1, +# ( +# SELECT MULTIPOINT( +# MULTIPOINT( +# 1, +# (SELECT COUNT(*) FROM (SELECT 1 FROM t1 GROUP BY a,a) d) +# ) +# ) FROM t1 +# ) +# ) != COUNT(*) q FROM t1 GROUP BY a; +# dec $i; +#} +# +#DROP TABLE t1; --echo # --echo # Bug #54468: crash after item's print() function when ordering/grouping From e6a3c8c458bc626f8c7977868afdb6b9ae8019c3 Mon Sep 17 00:00:00 2001 From: Joerg Bruehe Date: Tue, 7 Sep 2010 17:05:16 +0200 Subject: [PATCH 071/183] Fix bug#56574: After installation from RPM, server is run under root, not mysql user The problem was that in the cmake way of building the variable "MYSQLD_USER" was not set and propagated. In the script "mysqld_safe" its value is used as the name of the user who should run the server process. The fix is to explicitly set this variable to "mysql" and propagate it in the build process. It was analyzed and proposed by Jonathan Perkin. --- scripts/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 4fc5f3f9b0d..0c9177c79c5 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -139,6 +139,7 @@ ELSE() ENDIF() SET(HOSTNAME "hostname") +SET(MYSQLD_USER "mysql") # Required for mysqlbug until autotools are deprecated, once done remove these # and expand default cmake variables From 063a34b68145d1ebb314d619fdba87982a60ea63 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Tue, 7 Sep 2010 17:56:43 +0200 Subject: [PATCH 072/183] Bug#55458: Partitioned MyISAM table gets crashed by multi-table update Updated according to reviewers comments. --- sql/ha_partition.cc | 40 ++++++++++++++++++++++++++++------------ sql/ha_partition.h | 2 ++ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 3d3ae33be4b..4fff6cc703c 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -233,6 +233,7 @@ void ha_partition::init_handler_variables() m_extra_cache= FALSE; m_extra_cache_size= 0; m_extra_prepare_for_update= FALSE; + m_extra_cache_part_id= NO_CURRENT_PART_ID; m_handler_status= handler_not_initialized; m_low_byte_first= 1; m_part_field_array= NULL; @@ -5376,9 +5377,6 @@ void ha_partition::get_dynamic_partition_info(PARTITION_INFO *stat_info, when performing the sequential scan we will check this recorded value and call extra_opt whenever we start scanning a new partition. - monty: Neads to be fixed so that it's passed to all handlers when we - move to another partition during table scan. - HA_EXTRA_NO_CACHE: When performing a UNION SELECT HA_EXTRA_NO_CACHE is called from the flush method in the select_union class. @@ -5390,7 +5388,7 @@ void ha_partition::get_dynamic_partition_info(PARTITION_INFO *stat_info, for. If no cache is in use they will quickly return after finding this out. And we also ensure that all caches are disabled and no one is left by mistake. - In the future this call will probably be deleted an we will instead call + In the future this call will probably be deleted and we will instead call ::reset(); HA_EXTRA_WRITE_CACHE: @@ -5402,8 +5400,9 @@ void ha_partition::get_dynamic_partition_info(PARTITION_INFO *stat_info, This is called as part of a multi-table update. When the table to be updated is also scanned then this informs MyISAM handler to drop any caches if dynamic records are used (fixed size records do not care - about this call). We pass this along to all underlying MyISAM handlers - and ignore it for the rest. + about this call). We pass this along to the first partition to scan, and + flag that it is to be called after HA_EXTRA_CACHE when moving to the next + partition to scan. HA_EXTRA_PREPARE_FOR_DROP: Only used by MyISAM, called in preparation for a DROP TABLE. @@ -5559,6 +5558,7 @@ int ha_partition::extra(enum ha_extra_function operation) m_extra_prepare_for_update= TRUE; if (m_part_spec.start_part != NO_CURRENT_PART_ID) { + DBUG_ASSERT(m_extra_cache_part_id == m_part_spec.start_part); VOID(m_file[m_part_spec.start_part]->extra(HA_EXTRA_PREPARE_FOR_UPDATE)); } break; @@ -5586,11 +5586,22 @@ int ha_partition::extra(enum ha_extra_function operation) break; } case HA_EXTRA_NO_CACHE: + { + int ret= 0; + if (m_extra_cache_part_id != NO_CURRENT_PART_ID) + ret= m_file[m_extra_cache_part_id]->extra(HA_EXTRA_NO_CACHE); + m_extra_cache= FALSE; + m_extra_cache_size= 0; + m_extra_prepare_for_update= FALSE; + m_extra_cache_part_id= NO_CURRENT_PART_ID; + DBUG_RETURN(ret); + } case HA_EXTRA_WRITE_CACHE: { m_extra_cache= FALSE; m_extra_cache_size= 0; m_extra_prepare_for_update= FALSE; + m_extra_cache_part_id= NO_CURRENT_PART_ID; DBUG_RETURN(loop_extra(operation)); } case HA_EXTRA_IGNORE_NO_KEY: @@ -5777,16 +5788,18 @@ int ha_partition::loop_extra(enum ha_extra_function operation) { int result= 0, tmp; handler **file; + bool is_select; DBUG_ENTER("ha_partition::loop_extra()"); - /* - TODO, 5.2: this is where you could possibly add optimisations to add the bitmap - _if_ a SELECT. - */ + is_select= (thd_sql_command(ha_thd()) == SQLCOM_SELECT); for (file= m_file; *file; file++) { - if ((tmp= (*file)->extra(operation))) - result= tmp; + if (!is_select || + bitmap_is_set(&(m_part_info->used_partitions), file - m_file)) + { + if ((tmp= (*file)->extra(operation))) + result= tmp; + } } DBUG_RETURN(result); } @@ -5822,6 +5835,7 @@ void ha_partition::late_extra_cache(uint partition_id) DBUG_ASSERT(m_extra_cache); VOID(file->extra(HA_EXTRA_PREPARE_FOR_UPDATE)); } + m_extra_cache_part_id= partition_id; DBUG_VOID_RETURN; } @@ -5846,6 +5860,8 @@ void ha_partition::late_extra_no_cache(uint partition_id) DBUG_VOID_RETURN; file= m_file[partition_id]; VOID(file->extra(HA_EXTRA_NO_CACHE)); + DBUG_ASSERT(partition_id == m_extra_cache_part_id); + m_extra_cache_part_id= NO_CURRENT_PART_ID; DBUG_VOID_RETURN; } diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 013341e4df3..feb2ddb9cfc 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -156,6 +156,8 @@ private: uint m_extra_cache_size; /* The same goes for HA_EXTRA_PREPARE_FOR_UPDATE */ bool m_extra_prepare_for_update; + /* Which partition has active cache */ + uint m_extra_cache_part_id; void init_handler_variables(); /* From f7da62d2ad5e585af2adb3cae78885114cc64393 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Wed, 8 Sep 2010 00:16:10 +0400 Subject: [PATCH 073/183] main.gis-rtree, main.type_float and main.type_newdecimal were marked as experimental due to BUG38965. --- mysql-test/collections/default.experimental | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental index 8da83d8ae97..91dada3ee05 100644 --- a/mysql-test/collections/default.experimental +++ b/mysql-test/collections/default.experimental @@ -45,3 +45,6 @@ parts.partition_syntax_ndb # joro : NDB tests marked as experiment parts.partition_value_ndb # joro : NDB tests marked as experimental as agreed with bochklin main.mysqlhotcopy_myisam # horst: due to bug#54129 main.mysqlhotcopy_archive # horst: due to bug#54129 +main.gis-rtree # svoj: due to BUG#38965 +main.type_float # svoj: due to BUG#38965 +main.type_newdecimal # svoj: due to BUG#38965 From 51a3375c98138cee6f51eec807c9a120a84da87a Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Wed, 8 Sep 2010 10:25:37 +0200 Subject: [PATCH 074/183] Bug #56292 Deadlock with ALTER TABLE and MERGE tables ALTER TABLE on a MERGE table could cause a deadlock with two other connections if we reached a situation where: 1) A connection doing ALTER TABLE can't upgrade to MDL_EXCLUSIVE on the parent table, but holds TL_READ_NO_INSERT on the child tables. 2) A connection doing DELETE on a child table can't get TL_WRITE on it since ALTER TABLE holds TL_READ_NO_INSERT. 3) A connection doing SELECT on the parent table can't get TL_READ on the child tables since TL_WRITE is ahead in the lock queue, but holds MDL_SHARED_READ on the parent table preventing ALTER TABLE from upgrading. For regular tables, this deadlock is avoided by having ALTER TABLE take a MDL_SHARED_NO_WRITE metadata lock on the table. This prevents DELETE from acquiring MDL_SHARED_WRITE on the table before ALTER TABLE tries to upgrade to MDL_EXCLUSIVE. In the example above, SELECT would therefore not be blocked by the pending DELETE as DELETE would not be able to enter TL_WRITE in the table lock queue. This patch fixes the problem for merge tables by using the same metadata lock type for child tables as for the parent table. The child tables will in this case therefore be locked with MDL_SHARED_NO_WRITE, preventing DELETE from acquiring a metadata lock and enter into the table lock queue. Change in behavior: By taking the same metadata lock for child tables as for the parent table, LOCK TABLE on the parent table will now also implicitly lock the child tables. Since LOCK TABLE on the parent table now takes more than one metadata lock, it is possible for LOCK TABLE ... WRITE on the parent table or child tables to give ER_LOCK_DEADLOCK error. Test case added to mdl_sync.test. Merge.test/.result has been updated to reflect the change to LOCK TABLE. --- mysql-test/r/mdl_sync.result | 38 +++++++++++++++++++ mysql-test/r/merge.result | 3 +- mysql-test/t/mdl_sync.test | 62 +++++++++++++++++++++++++++++++ mysql-test/t/merge.test | 3 +- storage/myisammrg/ha_myisammrg.cc | 2 + 5 files changed, 104 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/mdl_sync.result b/mysql-test/r/mdl_sync.result index d484ab77701..de57e3859b7 100644 --- a/mysql-test/r/mdl_sync.result +++ b/mysql-test/r/mdl_sync.result @@ -2913,3 +2913,41 @@ UNLOCK TABLES; # Connection default UNLOCK TABLES; DROP DATABASE db1; +# +# Bug#56292 Deadlock with ALTER TABLE and MERGE tables +# +DROP TABLE IF EXISTS t1, t2, m1; +CREATE TABLE t1(a INT) engine=MyISAM; +CREATE TABLE t2(a INT) engine=MyISAM; +CREATE TABLE m1(a INT) engine=MERGE UNION=(t1, t2); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (3), (4); +# Connection con1 +SET DEBUG_SYNC= 'mdl_upgrade_shared_lock_to_exclusive SIGNAL upgrade WAIT_FOR continue'; +# Sending: +ALTER TABLE m1 engine=MERGE UNION=(t2, t1); +# Connection con2 +# Waiting for ALTER TABLE to try lock upgrade +SET DEBUG_SYNC= 'now WAIT_FOR upgrade'; +# Sending: +DELETE FROM t2 WHERE a = 3; +# Connection default +# Check that DELETE is waiting on a metadata lock and not a table lock. +# Now that DELETE blocks on a metadata lock, we should be able to do +# SELECT * FROM m1 here. SELECT used to be blocked by a DELETE table +# lock request. +SELECT * FROM m1; +a +1 +2 +3 +4 +# Resuming ALTER TABLE +SET DEBUG_SYNC= 'now SIGNAL continue'; +# Connection con1 +# Reaping: ALTER TABLE m1 engine=MERGE UNION=(t2, t1) +# Connection con2 +# Reaping: DELETE FROM t2 WHERE a = 3 +# Connection default +DROP TABLE m1, t1, t2; +SET DEBUG_SYNC= 'RESET'; diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index c7e54288f8b..5d96970ce74 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -3444,13 +3444,12 @@ ALTER TABLE m1 ADD INDEX (c1); UNLOCK TABLES; DROP TABLE m1, t1; # -# If children are to be altered, they need an explicit lock. +# Locking the merge table will implicitly lock children. # CREATE TABLE t1 (c1 INT); CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1); LOCK TABLE m1 WRITE; ALTER TABLE t1 ADD INDEX (c1); -ERROR HY000: Table 't1' was locked with a READ lock and can't be updated LOCK TABLE m1 WRITE, t1 WRITE; ALTER TABLE t1 ADD INDEX (c1); UNLOCK TABLES; diff --git a/mysql-test/t/mdl_sync.test b/mysql-test/t/mdl_sync.test index 55c04d7870b..f7780d2003a 100644 --- a/mysql-test/t/mdl_sync.test +++ b/mysql-test/t/mdl_sync.test @@ -4532,6 +4532,68 @@ disconnect con2; disconnect con3; +--echo # +--echo # Bug#56292 Deadlock with ALTER TABLE and MERGE tables +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1, t2, m1; +--enable_warnings + +CREATE TABLE t1(a INT) engine=MyISAM; +CREATE TABLE t2(a INT) engine=MyISAM; +CREATE TABLE m1(a INT) engine=MERGE UNION=(t1, t2); + +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (3), (4); + +connect(con1, localhost, root); +connect(con2, localhost, root); + +--echo # Connection con1 +connection con1; +SET DEBUG_SYNC= 'mdl_upgrade_shared_lock_to_exclusive SIGNAL upgrade WAIT_FOR continue'; +--echo # Sending: +--send ALTER TABLE m1 engine=MERGE UNION=(t2, t1) + +--echo # Connection con2 +connection con2; +--echo # Waiting for ALTER TABLE to try lock upgrade +SET DEBUG_SYNC= 'now WAIT_FOR upgrade'; +--echo # Sending: +--send DELETE FROM t2 WHERE a = 3 + +--echo # Connection default +connection default; +--echo # Check that DELETE is waiting on a metadata lock and not a table lock. +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist + WHERE state = "Waiting for table metadata lock" AND + info = "DELETE FROM t2 WHERE a = 3"; +--source include/wait_condition.inc +--echo # Now that DELETE blocks on a metadata lock, we should be able to do +--echo # SELECT * FROM m1 here. SELECT used to be blocked by a DELETE table +--echo # lock request. +SELECT * FROM m1; +--echo # Resuming ALTER TABLE +SET DEBUG_SYNC= 'now SIGNAL continue'; + +--echo # Connection con1 +connection con1; +--echo # Reaping: ALTER TABLE m1 engine=MERGE UNION=(t2, t1) +--reap +--echo # Connection con2 +connection con2; +--echo # Reaping: DELETE FROM t2 WHERE a = 3 +--reap +--echo # Connection default +connection default; +DROP TABLE m1, t1, t2; +SET DEBUG_SYNC= 'RESET'; +disconnect con1; +disconnect con2; + + # Check that all connections opened by test cases in this file are really # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index b6ad3324d19..1553d7f29c5 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -2519,12 +2519,11 @@ UNLOCK TABLES; DROP TABLE m1, t1; --echo # ---echo # If children are to be altered, they need an explicit lock. +--echo # Locking the merge table will implicitly lock children. --echo # CREATE TABLE t1 (c1 INT); CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1); LOCK TABLE m1 WRITE; ---error ER_TABLE_NOT_LOCKED_FOR_WRITE ALTER TABLE t1 ADD INDEX (c1); LOCK TABLE m1 WRITE, t1 WRITE; ALTER TABLE t1 ADD INDEX (c1); diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index f62aff4e383..466c66ec769 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -478,6 +478,8 @@ int ha_myisammrg::add_children_list(void) /* Set the expected table version, to not cause spurious re-prepare. */ child_l->set_table_ref_id(mrg_child_def->get_child_table_ref_type(), mrg_child_def->get_child_def_version()); + /* Use the same metadata lock type for children. */ + child_l->mdl_request.set_type(parent_l->mdl_request.type); /* Link TABLE_LIST object into the children list. */ if (this->children_last_l) child_l->prev_global= this->children_last_l; From 9080f681b4b543797e9f592aefc09977b9770b75 Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Thu, 9 Sep 2010 13:40:17 +0400 Subject: [PATCH 075/183] Fix for bug#56679: gis.test: valgrind error Item_func_spatial_collection::fix_length_and_dec() changed to use argument's print() method to print the ER_ILLEGAL_VALUE_FOR_TYPE error. --- mysql-test/r/gis.result | 6 +++--- sql/item_geofunc.h | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 02c8afc2d77..3b18ee61336 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -707,7 +707,7 @@ numgeometries(b) IS NULL, numinteriorrings(b) IS NULL, numpoints(b) IS NULL, area(b) IS NULL, glength(b) IS NULL, srid(b) IS NULL, x(b) IS NULL, y(b) IS NULL from t1; -ERROR 22007: Illegal non geometric '' value found during parsing +ERROR 22007: Illegal non geometric '`test`.`t1`.`b`' value found during parsing select within(b, b) IS NULL, contains(b, b) IS NULL, overlaps(b, b) IS NULL, equals(b, b) IS NULL, disjoint(b, b) IS NULL, touches(b, b) IS NULL, @@ -722,7 +722,7 @@ point(b, b) IS NULL, linestring(b) IS NULL, polygon(b) IS NULL, multipoint(b) IS multilinestring(b) IS NULL, multipolygon(b) IS NULL, geometrycollection(b) IS NULL from t1; -ERROR 22007: Illegal non geometric '' value found during parsing +ERROR 22007: Illegal non geometric '`test`.`t1`.`b`' value found during parsing drop table t1; CREATE TABLE t1(a POINT) ENGINE=MyISAM; INSERT INTO t1 VALUES (NULL); @@ -1006,7 +1006,7 @@ drop table t1; SELECT MultiPoint(12345,''); ERROR 22007: Illegal non geometric '12345' value found during parsing SELECT 1 FROM (SELECT GREATEST(1,GEOMETRYCOLLECTION('00000','00000')) b FROM DUAL) AS d WHERE (LINESTRING(d.b)); -ERROR 22007: Illegal non geometric '' value found during parsing +ERROR 22007: Illegal non geometric ''00000'' value found during parsing # # BUG#51875: crash when loading data into geometry function polyfromwkb # diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index 070c2cd26fc..b3ecbc39933 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -177,13 +177,15 @@ public: String *val_str(String *); void fix_length_and_dec() { - for( unsigned int i=0; ifixed && args[i]->field_type() != MYSQL_TYPE_GEOMETRY) + if (args[i]->fixed && args[i]->field_type() != MYSQL_TYPE_GEOMETRY) { String str; - args[i]->val_str(&str); - my_error(ER_ILLEGAL_VALUE_FOR_TYPE,MYF(0),"non geometric",str.c_ptr()); + args[i]->print(&str, QT_ORDINARY); + str.append('\0'); + my_error(ER_ILLEGAL_VALUE_FOR_TYPE, MYF(0), "non geometric", + str.ptr()); } } } From d88a11a76687b8c7ae4cb0642a0977b7ca420ad0 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Thu, 9 Sep 2010 19:36:57 +0700 Subject: [PATCH 076/183] Fix mysql_client_test failure introduced by a patch for Bug#47485. The problem was that mysql_stmt_next_result() (new to 5.5) was not properly updated. --- libmysql/libmysql.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 231b6e2ef76..a44395578c6 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -4874,6 +4874,9 @@ int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt) DBUG_RETURN(rc); } + if (mysql->status == MYSQL_STATUS_GET_RESULT) + mysql->status= MYSQL_STATUS_STATEMENT_GET_RESULT; + stmt->state= MYSQL_STMT_EXECUTE_DONE; stmt->bind_result_done= FALSE; From 9066714c817fc0816333cde52bead2652125d118 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Thu, 9 Sep 2010 16:46:13 +0400 Subject: [PATCH 077/183] Bug #54190: Comparison to row subquery produces incorrect result Row subqueries producing no rows were not handled as UNKNOWN values in row comparison expressions. That was a result of the following two problems: 1. Item_singlerow_subselect did not mark the resulting row value as NULL/UNKNOWN when no rows were produced. 2. Arg_comparator::compare_row() did not take into account that a whole argument may be NULL rather than just individual scalar values. Before bug#34384 was fixed, the above problems were hidden because an uninitialized (i.e. without any stored value) cached object would appear as NULL for scalar values in a row subquery returning an empty result. After the fix Arg_comparator::compare_row() would try to evaluate uninitialized cached objects. Fixed by removing the aforementioned problems. --- mysql-test/r/row.result | 23 +++++++++++++++++++++++ mysql-test/r/subselect.result | 4 ++-- mysql-test/t/row.test | 19 +++++++++++++++++++ sql/item_cmpfunc.cc | 7 +++++++ sql/item_subselect.cc | 5 ++++- 5 files changed, 55 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/row.result b/mysql-test/r/row.result index 2962123fcb2..789b9c4f383 100644 --- a/mysql-test/r/row.result +++ b/mysql-test/r/row.result @@ -466,3 +466,26 @@ SELECT 1 FROM t1 WHERE ROW(a, b) >= ROW('1', (SELECT 1 FROM t1 WHERE a > 1234)); 1 DROP TABLE t1; +# +# Bug #54190: Comparison to row subquery produces incorrect result +# +SELECT ROW(1,2) = (SELECT 1,2 FROM DUAL WHERE 1 = 0); +ROW(1,2) = (SELECT 1,2 FROM DUAL WHERE 1 = 0) +NULL +SELECT ROW(1,2) = (SELECT 1,3 FROM DUAL WHERE 1 = 0); +ROW(1,2) = (SELECT 1,3 FROM DUAL WHERE 1 = 0) +NULL +CREATE TABLE t1 (i INT); +INSERT INTO t1 () VALUES (1), (2), (3); +SELECT ROW(1,2) = (SELECT 1,2 FROM t1 WHERE 1 = 0); +ROW(1,2) = (SELECT 1,2 FROM t1 WHERE 1 = 0) +NULL +SELECT ROW(1,2) = (SELECT 1,3 FROM t1 WHERE 1 = 0); +ROW(1,2) = (SELECT 1,3 FROM t1 WHERE 1 = 0) +NULL +SELECT i FROM t1 WHERE ROW(1,2) = (SELECT 1,2 FROM DUAL WHERE 1 = 0); +i +SELECT i FROM t1 WHERE ROW(1,2) = (SELECT 1,3 FROM DUAL WHERE 1 = 0); +i +DROP TABLE t1; +End of 5.1 tests diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 47a89897daf..dc40e42275b 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -922,7 +922,7 @@ select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,2,'a'),(select c from t a (select a,b,c from t1 where t1.a=t2.a) = ROW(a,2,'a') (select c from t1 where a=t2.a) 1 1 a 2 0 b -NULL 0 NULL +NULL NULL NULL select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,3,'b'),(select c from t1 where a=t2.a) from t2; a (select a,b,c from t1 where t1.a=t2.a) = ROW(a,3,'b') (select c from t1 where a=t2.a) 1 0 a @@ -932,7 +932,7 @@ select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,4,'c'),(select c from t a (select a,b,c from t1 where t1.a=t2.a) = ROW(a,4,'c') (select c from t1 where a=t2.a) 1 0 a 2 0 b -NULL 0 NULL +NULL NULL NULL drop table t1,t2; create table t1 (a int, b real, c varchar(10)); insert into t1 values (1, 1, 'a'), (2,2,'b'), (NULL, 2, 'b'); diff --git a/mysql-test/t/row.test b/mysql-test/t/row.test index cec44078279..fb49ce23644 100644 --- a/mysql-test/t/row.test +++ b/mysql-test/t/row.test @@ -266,3 +266,22 @@ SELECT 1 FROM t1 WHERE ROW(a, b) >= ROW('1', (SELECT 1 FROM t1 WHERE a > 1234)); --enable_warnings DROP TABLE t1; + +--echo # +--echo # Bug #54190: Comparison to row subquery produces incorrect result +--echo # + +SELECT ROW(1,2) = (SELECT 1,2 FROM DUAL WHERE 1 = 0); +SELECT ROW(1,2) = (SELECT 1,3 FROM DUAL WHERE 1 = 0); + +CREATE TABLE t1 (i INT); +INSERT INTO t1 () VALUES (1), (2), (3); + +SELECT ROW(1,2) = (SELECT 1,2 FROM t1 WHERE 1 = 0); +SELECT ROW(1,2) = (SELECT 1,3 FROM t1 WHERE 1 = 0); +SELECT i FROM t1 WHERE ROW(1,2) = (SELECT 1,2 FROM DUAL WHERE 1 = 0); +SELECT i FROM t1 WHERE ROW(1,2) = (SELECT 1,3 FROM DUAL WHERE 1 = 0); + +DROP TABLE t1; + +--echo End of 5.1 tests diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index fe4616f64d7..b2ed2df0f45 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1583,6 +1583,13 @@ int Arg_comparator::compare_row() bool was_null= 0; (*a)->bring_value(); (*b)->bring_value(); + + if ((*a)->null_value || (*b)->null_value) + { + owner->null_value= 1; + return -1; + } + uint n= (*a)->cols(); for (uint i= 0; i Date: Thu, 9 Sep 2010 18:29:14 +0400 Subject: [PATCH 078/183] Fix for bug #55273 "FLUSH TABLE tm WITH READ LOCK for Merge table causes assert failure". Attempting to use FLUSH TABLE table_list WITH READ LOCK statement for a MERGE table led to an assertion failure if one of its children was not present in the list of tables to be flushed. The problem was not visible in non-debug builds. The assertion failure was caused by the fact that in such situations FLUSH TABLES table_list WITH READ LOCK implementation tried to use (e.g. lock) such child tables without acquiring metadata lock on them. This happened because when opening tables we assumed metadata locks on all tables were already acquired earlier during statement execution and a such assumption was false for MERGE children. This patch fixes the problem by ensuring at open_tables() time that we try to acquire metadata locks on all tables to be opened. For normal tables such requests are satisfied instantly since locks are already acquired for them. For MERGE children metadata locks are acquired in normal fashion. Note that FLUSH TABLES merge_table WITH READ LOCK will lock for read both the MERGE table and its children but will flush only the MERGE table. To flush children one has to mention them in table list explicitly. This is expected behavior and it is consistent with usage patterns for this statement (e.g. in mysqlhotcopy script). --- mysql-test/r/flush.result | 50 +++++++++++++++++++++++++++++++++++++++ mysql-test/t/flush.test | 31 ++++++++++++++++++++++++ sql/sql_base.cc | 6 +++-- sql/sql_base.h | 5 ++++ sql/sql_reload.cc | 42 +++++++++++++++++--------------- sql/sql_yacc.yy | 4 ++++ 6 files changed, 117 insertions(+), 21 deletions(-) diff --git a/mysql-test/r/flush.result b/mysql-test/r/flush.result index aee18d91edf..ced8306c3ab 100644 --- a/mysql-test/r/flush.result +++ b/mysql-test/r/flush.result @@ -373,3 +373,53 @@ commit; # --> connection con2 # --> connection default drop table t1; +# +# Test for bug #55273 "FLUSH TABLE tm WITH READ LOCK for Merge table +# causes assert failure". +# +drop table if exists t1, t2, tm; +create table t1 (i int); +create table t2 (i int); +create table tm (i int) engine=merge union=(t1, t2); +insert into t1 values (1), (2); +insert into t2 values (3), (4); +# The below statement should succeed and lock merge +# table for read. Only merge table gets flushed and +# not underlying tables. +flush tables tm with read lock; +select * from tm; +i +1 +2 +3 +4 +# Check that underlying tables are locked. +select * from t1; +i +1 +2 +select * from t2; +i +3 +4 +unlock tables; +# This statement should succeed as well and flush +# all tables in the list. +flush tables tm, t1, t2 with read lock; +select * from tm; +i +1 +2 +3 +4 +# Naturally, underlying tables should be locked in this case too. +select * from t1; +i +1 +2 +select * from t2; +i +3 +4 +unlock tables; +drop tables tm, t1, t2; diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test index d4c3533847d..1cafbe3e6bd 100644 --- a/mysql-test/t/flush.test +++ b/mysql-test/t/flush.test @@ -546,3 +546,34 @@ disconnect con2; connection default; drop table t1; + +--echo # +--echo # Test for bug #55273 "FLUSH TABLE tm WITH READ LOCK for Merge table +--echo # causes assert failure". +--echo # +--disable_warnings +drop table if exists t1, t2, tm; +--enable_warnings +create table t1 (i int); +create table t2 (i int); +create table tm (i int) engine=merge union=(t1, t2); +insert into t1 values (1), (2); +insert into t2 values (3), (4); +--echo # The below statement should succeed and lock merge +--echo # table for read. Only merge table gets flushed and +--echo # not underlying tables. +flush tables tm with read lock; +select * from tm; +--echo # Check that underlying tables are locked. +select * from t1; +select * from t2; +unlock tables; +--echo # This statement should succeed as well and flush +--echo # all tables in the list. +flush tables tm, t1, t2 with read lock; +select * from tm; +--echo # Naturally, underlying tables should be locked in this case too. +select * from t1; +select * from t2; +unlock tables; +drop tables tm, t1, t2; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 8cd0ce4432a..e2eb836a958 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4522,13 +4522,15 @@ lock_table_names(THD *thd, ! (flags & MYSQL_OPEN_SKIP_TEMPORARY) && find_temporary_table(thd, table)))) { - if (schema_set.insert(table)) + if (! (flags & MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK) && + schema_set.insert(table)) return TRUE; mdl_requests.push_front(&table->mdl_request); } } - if (! mdl_requests.is_empty()) + if (! (flags & MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK) && + ! mdl_requests.is_empty()) { /* Scoped locks: Take intention exclusive locks on all involved diff --git a/sql/sql_base.h b/sql/sql_base.h index a21850355b4..b1a730ad277 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -122,6 +122,11 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update, (LONG_TIMEOUT = 1 year) rather than the user-supplied timeout value. */ #define MYSQL_LOCK_IGNORE_TIMEOUT 0x0800 +/** + When acquiring "strong" (SNW, SNRW, X) metadata locks on tables to + be open do not acquire global and schema-scope IX locks. +*/ +#define MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK 0x1000 /** Please refer to the internals manual. */ #define MYSQL_OPEN_REOPEN (MYSQL_OPEN_IGNORE_FLUSH |\ diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index bf38af78536..35f27408247 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -328,7 +328,6 @@ bool reload_acl_and_cache(THD *thd, unsigned long options, ------------------------------------- - you can't flush WITH READ LOCK a non-existent table - you can't flush WITH READ LOCK under LOCK TABLES - - currently incompatible with the GRL (@todo: fix) Effect on views and temporary tables. ------------------------------------ @@ -338,6 +337,13 @@ bool reload_acl_and_cache(THD *thd, unsigned long options, if there is a base table, it's used, otherwise ER_NO_SUCH_TABLE is returned. + Handling of MERGE tables + ------------------------ + For MERGE table this statement will open and lock child tables + for read (it is impossible to lock parent table without it). + Child tables won't be flushed unless they are explicitly present + in the statement's table list. + Implicit commit --------------- This statement causes an implicit commit before and @@ -354,7 +360,6 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) { Lock_tables_prelocking_strategy lock_tables_prelocking_strategy; TABLE_LIST *table_list; - MDL_request_list mdl_requests; /* This is called from SQLCOM_FLUSH, the transaction has @@ -368,17 +373,13 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) } /* - Acquire SNW locks on tables to be flushed. We can't use - lock_table_names() here as this call will also acquire global IX - and database-scope IX locks on the tables, and this will make + Acquire SNW locks on tables to be flushed. Don't acquire global + IX and database-scope IX locks on the tables as this will make this statement incompatible with FLUSH TABLES WITH READ LOCK. */ - for (table_list= all_tables; table_list; - table_list= table_list->next_global) - mdl_requests.push_front(&table_list->mdl_request); - - if (thd->mdl_context.acquire_locks(&mdl_requests, - thd->variables.lock_wait_timeout)) + if (lock_table_names(thd, all_tables, NULL, + thd->variables.lock_wait_timeout, + MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK)) goto error; DEBUG_SYNC(thd,"flush_tables_with_read_lock_after_acquire_locks"); @@ -390,21 +391,24 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED, table_list->db, table_list->table_name, FALSE); - - /* Skip views and temporary tables. */ - table_list->required_type= FRMTYPE_TABLE; /* Don't try to flush views. */ - table_list->open_type= OT_BASE_ONLY; /* Ignore temporary tables. */ + /* Reset ticket to satisfy asserts in open_tables(). */ + table_list->mdl_request.ticket= NULL; } /* Before opening and locking tables the below call also waits for old shares to go away, so the fact that we don't pass MYSQL_LOCK_IGNORE_FLUSH flag to it is important. + Also we don't pass MYSQL_OPEN_HAS_MDL_LOCK flag as we want + to open underlying tables if merge table is flushed. + For underlying tables of the merge the below call has to + acquire SNW locks to ensure that they can be locked for + read without further waiting. */ - if (open_and_lock_tables(thd, all_tables, FALSE, - MYSQL_OPEN_HAS_MDL_LOCK, - &lock_tables_prelocking_strategy) || - thd->locked_tables_list.init_locked_tables(thd)) + if (open_and_lock_tables(thd, all_tables, FALSE, + MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK, + &lock_tables_prelocking_strategy) || + thd->locked_tables_list.init_locked_tables(thd)) { goto error; } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 83e9078f5cb..2ee2d83f9d2 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -11278,7 +11278,11 @@ opt_with_read_lock: TABLE_LIST *tables= Lex->query_tables; Lex->type|= REFRESH_READ_LOCK; for (; tables; tables= tables->next_global) + { tables->mdl_request.set_type(MDL_SHARED_NO_WRITE); + tables->required_type= FRMTYPE_TABLE; /* Don't try to flush views. */ + tables->open_type= OT_BASE_ONLY; /* Ignore temporary tables. */ + } } ; From f563a012cebf217f32710b6d07f6b1ea58431146 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Thu, 9 Sep 2010 18:44:53 +0400 Subject: [PATCH 079/183] Addendum patch for bug #54190. The patch caused some test failures when merged to 5.5 because, unlike 5.1, it utilizes Item_cache_row to actually cache row values. The problem was that Item_cache_row::bring_value() essentially did nothing. In particular, it did not update its null_value, so all Item_cache_row objects were always having their null_values set to TRUE. This went unnoticed previously, but now when Arg_comparator::compare_row() actually depends on the row's null_value to evaluate the comparison, the problem has surfaced. Fixed by calling the underlying item's bring_value() and updating null_value in Item_cache_row::bring_value(). Since the problem also exists in 5.1 code (albeit hidden, since the relevant code is not used anywhere), the addendum patch is against 5.1. --- sql/item.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sql/item.cc b/sql/item.cc index 66c5314c16e..29529abe7b9 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -7404,9 +7404,12 @@ bool Item_cache_row::null_inside() void Item_cache_row::bring_value() { + if (!example) + return; + example->bring_value(); + null_value= example->null_value; for (uint i= 0; i < item_count; i++) values[i]->bring_value(); - return; } From 821ac1e93389323088f63866b829096985227ff8 Mon Sep 17 00:00:00 2001 From: Alfranio Correia Date: Fri, 10 Sep 2010 11:49:57 +0100 Subject: [PATCH 080/183] BUG#55675 rpl.rpl_log_pos fails sporadically with error binlog truncated in the middle Disabled the test case. --- mysql-test/suite/rpl/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/rpl/t/disabled.def b/mysql-test/suite/rpl/t/disabled.def index ef77c54e067..5b150288935 100644 --- a/mysql-test/suite/rpl/t/disabled.def +++ b/mysql-test/suite/rpl/t/disabled.def @@ -11,3 +11,4 @@ ############################################################################## rpl_row_create_table : Bug#51574 Feb 27 2010 andrei failed different way than earlier with bug#45576 +rpl_log_pos : BUG#55675 Sep 10 2010 27 2010 alfranio rpl.rpl_log_pos fails sporadically with error binlog truncated in the middle From 79c1faa05ef64110746d2f33af428473b6511cdb Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Mon, 13 Sep 2010 11:18:35 +0400 Subject: [PATCH 081/183] Bug #55779: select does not work properly in mysql server Version "5.1.42 SUSE MySQL RPM" When a query was using a DATE or DATETIME value formatted using different formatting than "yyyy-mm-dd HH:MM:SS", a query with a greater-or-equal '>=' condition matched only greater values in an indexed TIMESTAMP column. The problem was introduced by the fix for the bug 46362 and partially solved (for DATE and DATETIME columns only) by the fix for the bug 47925. The stored_field_cmp_to_item function has been modified to take into account TIMESTAMP columns like we do for DATE and DATETIME columns. --- mysql-test/r/type_timestamp.result | 21 +++++++++++++++++++++ mysql-test/t/type_timestamp.test | 17 +++++++++++++++++ sql/item.cc | 6 ++++-- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result index e26c2e68775..e88d3462466 100644 --- a/mysql-test/r/type_timestamp.result +++ b/mysql-test/r/type_timestamp.result @@ -527,3 +527,24 @@ f1 f2-f3 5 0 DROP TABLE t1; End of 5.0 tests +# +# Bug #55779: select does not work properly in mysql server +# Version "5.1.42 SUSE MySQL RPM" +# +CREATE TABLE t1 (a TIMESTAMP, KEY (a)); +INSERT INTO t1 VALUES ('2000-01-01 00:00:00'), ('2000-01-01 00:00:00'), +('2000-01-01 00:00:01'), ('2000-01-01 00:00:01'); +SELECT a FROM t1 WHERE a >= 20000101000000; +a +2000-01-01 00:00:00 +2000-01-01 00:00:00 +2000-01-01 00:00:01 +2000-01-01 00:00:01 +SELECT a FROM t1 WHERE a >= '20000101000000'; +a +2000-01-01 00:00:00 +2000-01-01 00:00:00 +2000-01-01 00:00:01 +2000-01-01 00:00:01 +DROP TABLE t1; +End of 5.1 tests diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test index e8374e0ebfc..602f6f089c2 100644 --- a/mysql-test/t/type_timestamp.test +++ b/mysql-test/t/type_timestamp.test @@ -357,3 +357,20 @@ SELECT f1,f2-f3 FROM t1; DROP TABLE t1; --echo End of 5.0 tests + +--echo # +--echo # Bug #55779: select does not work properly in mysql server +--echo # Version "5.1.42 SUSE MySQL RPM" +--echo # + +CREATE TABLE t1 (a TIMESTAMP, KEY (a)); + +INSERT INTO t1 VALUES ('2000-01-01 00:00:00'), ('2000-01-01 00:00:00'), + ('2000-01-01 00:00:01'), ('2000-01-01 00:00:01'); + +SELECT a FROM t1 WHERE a >= 20000101000000; +SELECT a FROM t1 WHERE a >= '20000101000000'; + +DROP TABLE t1; + +--echo End of 5.1 tests diff --git a/sql/item.cc b/sql/item.cc index 29529abe7b9..61dd8a97dcb 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6970,14 +6970,16 @@ int stored_field_cmp_to_item(THD *thd, Field *field, Item *item) enum_field_types field_type= field->type(); - if (field_type == MYSQL_TYPE_DATE || field_type == MYSQL_TYPE_DATETIME) + if (field_type == MYSQL_TYPE_DATE || field_type == MYSQL_TYPE_DATETIME || + field_type == MYSQL_TYPE_TIMESTAMP) { enum_mysql_timestamp_type type= MYSQL_TIMESTAMP_ERROR; if (field_type == MYSQL_TYPE_DATE) type= MYSQL_TIMESTAMP_DATE; - if (field_type == MYSQL_TYPE_DATETIME) + if (field_type == MYSQL_TYPE_DATETIME || + field_type == MYSQL_TYPE_TIMESTAMP) type= MYSQL_TIMESTAMP_DATETIME; const char *field_name= field->field_name; From 91392cd8931fc1d63868a292f1d42df15bd59dcf Mon Sep 17 00:00:00 2001 From: Joerg Bruehe Date: Mon, 13 Sep 2010 12:14:48 +0200 Subject: [PATCH 082/183] Selective transfer of a bugfix patch into 5.5.6-rc. The first part is the functional change, the second is needed as a compile fix on Windows (header file order). | committer: Marc Alff | branch nick: mysql-5.5-bugfixing-56521 | timestamp: Thu 2010-09-09 14:28:47 -0600 | message: | Bug#56521 Assertion failed: (m_state == 2), function allocated_to_free, pfs_lock.h (138) | | Before this fix, it was possible to build the server: | - with the performance schema | - with a dummy implementation of my_atomic (MY_ATOMIC_MODE_DUMMY). | | In this case, the resulting binary will just crash, | as this configuration is not supported. | | This fix enforces that the build will fail with a compilation error in this | configuration, instead of resulting in a broken binary. | committer: Tor Didriksen | branch nick: 5.5-bugfixing-56521 | timestamp: Fri 2010-09-10 11:10:38 +0200 | message: | Header files should be self-contained --- storage/perfschema/ha_perfschema.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/storage/perfschema/ha_perfschema.cc b/storage/perfschema/ha_perfschema.cc index 0fac734f7a0..e5e324d6c6b 100644 --- a/storage/perfschema/ha_perfschema.cc +++ b/storage/perfschema/ha_perfschema.cc @@ -20,6 +20,7 @@ #include "my_global.h" #include "my_pthread.h" +#include "my_atomic.h" #include "sql_plugin.h" #include "mysql/plugin.h" #include "ha_perfschema.h" @@ -28,6 +29,17 @@ #include "pfs_instr_class.h" #include "pfs_instr.h" +#ifdef MY_ATOMIC_MODE_DUMMY +/* + The performance schema can can not function with MY_ATOMIC_MODE_DUMMY, + a fully functional implementation of MY_ATOMIC should be used instead. + If the build fails with this error message: + - either use a different ./configure --with-atomic-ops option + - or do not build with the performance schema. +*/ +#error "The performance schema needs a functional MY_ATOMIC implementation." +#endif + handlerton *pfs_hton= NULL; static handler* pfs_create_handler(handlerton *hton, From 20b7be9263683db32623d07aa53b52fda867c45b Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Mon, 13 Sep 2010 13:31:22 +0200 Subject: [PATCH 083/183] Bug #56448 Assertion failed: ! is_set() with second xa end The problem was that issuing XA END when the XA transaction was already ended, caused an assertion. This assertion tests that the server does not try to send OK to the client if there has already been an error reported. The bug was only noticeable on debug versions of the server. The reason for the problem was that the trans_xa_end() function reported success if the transaction was at XA_IDLE state at the end regardless of any errors occured during processing of trans_xa_end(). So if the transaction state was XA_IDLE already, reported errors would be ignored. This patch fixes the problem by having trans_xa_end() take into consideration any reported errors. The patch also fixes a similar bug with XA PREPARE. Test case added to xa.test. --- mysql-test/r/xa.result | 11 +++++++++++ mysql-test/t/xa.test | 17 +++++++++++++++++ sql/transaction.cc | 6 ++++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/xa.result b/mysql-test/r/xa.result index fedbb43ea2a..6ef3bf392d9 100644 --- a/mysql-test/r/xa.result +++ b/mysql-test/r/xa.result @@ -131,3 +131,14 @@ XA START 'xid1'; XA END 'xid1'; XA ROLLBACK 'xid1'; DROP TABLE t1; +# +# Bug#56448 Assertion failed: ! is_set() with second xa end +# +XA START 'x'; +XA END 'x'; +XA END 'x'; +ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state +XA PREPARE 'x'; +XA PREPARE 'x'; +ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state +XA ROLLBACK 'x'; diff --git a/mysql-test/t/xa.test b/mysql-test/t/xa.test index fe36af60c27..3fd243398a9 100644 --- a/mysql-test/t/xa.test +++ b/mysql-test/t/xa.test @@ -228,6 +228,23 @@ XA ROLLBACK 'xid1'; disconnect con1; DROP TABLE t1; + +--echo # +--echo # Bug#56448 Assertion failed: ! is_set() with second xa end +--echo # + +XA START 'x'; +XA END 'x'; +# Second XA END caused an assertion. +--error ER_XAER_RMFAIL +XA END 'x'; +XA PREPARE 'x'; +# Second XA PREPARE also caused an assertion. +--error ER_XAER_RMFAIL +XA PREPARE 'x'; +XA ROLLBACK 'x'; + + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc diff --git a/sql/transaction.cc b/sql/transaction.cc index a28fba8805d..d3e3ba142b9 100644 --- a/sql/transaction.cc +++ b/sql/transaction.cc @@ -565,7 +565,8 @@ bool trans_xa_end(THD *thd) else if (!xa_trans_rolled_back(&thd->transaction.xid_state)) thd->transaction.xid_state.xa_state= XA_IDLE; - DBUG_RETURN(thd->transaction.xid_state.xa_state != XA_IDLE); + DBUG_RETURN(thd->is_error() || + thd->transaction.xid_state.xa_state != XA_IDLE); } @@ -596,7 +597,8 @@ bool trans_xa_prepare(THD *thd) else thd->transaction.xid_state.xa_state= XA_PREPARED; - DBUG_RETURN(thd->transaction.xid_state.xa_state != XA_PREPARED); + DBUG_RETURN(thd->is_error() || + thd->transaction.xid_state.xa_state != XA_PREPARED); } From 20bdf7636b115c53bfb57417af43db3b1494a6da Mon Sep 17 00:00:00 2001 From: Martin Hansson Date: Mon, 13 Sep 2010 13:33:19 +0200 Subject: [PATCH 084/183] Bug #50394: Regression in EXPLAIN with index scan, LIMIT, GROUP BY and ORDER BY computed col GROUP BY implies ORDER BY in the MySQL dialect of SQL. Therefore, when an index on the first table in the query is used, and that index satisfies ordering according to the GROUP BY clause, the query optimizer estimates the number of tuples that need to be read from this index. If there is a LIMIT clause, table statistics on tables following this 'sort table' are employed. There may be a separate ORDER BY clause however, which mandates reading the whole 'sort table' anyway. But the previous estimate was left untouched. Fixed by removing the estimate from EXPLAIN output if GROUP BY is used in conjunction with an ORDER BY clause that mandates using a temporary table. --- mysql-test/r/order_by.result | 21 +++++++++++++++++++++ mysql-test/t/order_by.test | 25 +++++++++++++++++++++++++ sql/sql_select.cc | 9 +++++++++ 3 files changed, 55 insertions(+) diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 6827fd0bc76..ba639fa9763 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -1617,4 +1617,25 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range a a 5 NULL 2 Using where; Using temporary; Using filesort 1 SIMPLE t2 ALL NULL NULL NULL NULL 10 Using join buffer DROP TABLE t1, t2; +# +# Bug #50394: Regression in EXPLAIN with index scan, LIMIT, GROUP BY and +# ORDER BY computed col +# +CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, KEY( a, b ) ); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t1 SELECT a + 5, b + 5 FROM t1; +CREATE TABLE t2( a INT PRIMARY KEY, b INT ); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t2 SELECT a + 5, b + 5 FROM t2; +EXPLAIN +SELECT count(*) AS c, t1.a +FROM t1 JOIN t2 ON t1.b = t2.a +WHERE t2.b = 1 +GROUP BY t1.a +ORDER by c +LIMIT 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 8 NULL 10 Using index; Using temporary; Using filesort +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 Using where +DROP TABLE t1, t2; End of 5.1 tests diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 36b6015c5d8..a8a6ad00648 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -1467,4 +1467,29 @@ SELECT * FROM t1 FORCE INDEX FOR JOIN (a), t2 WHERE t1.a < 2 ORDER BY t1.a; DROP TABLE t1, t2; +--echo # +--echo # Bug #50394: Regression in EXPLAIN with index scan, LIMIT, GROUP BY and +--echo # ORDER BY computed col +--echo # +CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, KEY( a, b ) ); + +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t1 SELECT a + 5, b + 5 FROM t1; + +CREATE TABLE t2( a INT PRIMARY KEY, b INT ); + +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t2 SELECT a + 5, b + 5 FROM t2; + +EXPLAIN +SELECT count(*) AS c, t1.a +FROM t1 JOIN t2 ON t1.b = t2.a +WHERE t2.b = 1 +GROUP BY t1.a +ORDER by c +LIMIT 2; + +DROP TABLE t1, t2; + + --echo End of 5.1 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f550f75c8b8..605819a1646 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1486,6 +1486,15 @@ JOIN::optimize() } if (order) { + /* + Do we need a temporary table due to the ORDER BY not being equal to + the GROUP BY? The call to test_if_skip_sort_order above tests for the + GROUP BY clause only and hence is not valid in this case. So the + estimated number of rows to be read from the first table is not valid. + We clear it here so that it doesn't show up in EXPLAIN. + */ + if (need_tmp && (select_options & SELECT_DESCRIBE) != 0) + join_tab[const_tables].limit= 0; /* Force using of tmp table if sorting by a SP or UDF function due to their expensive and probably non-deterministic nature. From 39827fdc9bac4292e0f7ced8dc0e759dc7acce5c Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Mon, 13 Sep 2010 16:33:25 +0300 Subject: [PATCH 085/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: storage/innobase/include/ut0rnd.ic:70:8: error: variable 'n_bits' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/include/ut0rnd.ic | 3 --- 1 file changed, 3 deletions(-) diff --git a/storage/innobase/include/ut0rnd.ic b/storage/innobase/include/ut0rnd.ic index 625c378489a..dc4c0d62f56 100644 --- a/storage/innobase/include/ut0rnd.ic +++ b/storage/innobase/include/ut0rnd.ic @@ -67,9 +67,6 @@ ut_rnd_gen_ulint(void) /* out: the 'random' number */ { ulint rnd; - ulint n_bits; - - n_bits = 8 * sizeof(ulint); ut_rnd_ulint_counter = UT_RND1 * ut_rnd_ulint_counter + UT_RND2; From 5ff27ae1a0f6761af59cebe315d738eca6ad32b9 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Mon, 13 Sep 2010 16:39:40 +0300 Subject: [PATCH 086/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: btr/btr0btr.c:2063:9: error: variable 'level' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/btr/btr0btr.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innobase/btr/btr0btr.c b/storage/innobase/btr/btr0btr.c index 5e8831b5d5e..b1b59227883 100644 --- a/storage/innobase/btr/btr0btr.c +++ b/storage/innobase/btr/btr0btr.c @@ -2060,7 +2060,6 @@ btr_compress( ulint n_recs; ulint max_ins_size; ulint max_ins_size_reorg; - ulint level; ulint comp; page = btr_cur_get_page(cursor); @@ -2072,7 +2071,6 @@ btr_compress( MTR_MEMO_X_LOCK)); ut_ad(mtr_memo_contains(mtr, buf_block_align(page), MTR_MEMO_PAGE_X_FIX)); - level = btr_page_get_level(page, mtr); space = dict_index_get_space(index); left_page_no = btr_page_get_prev(page, mtr); From a01a739c971fe302029abc7df608b2d26f43177f Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 11:37:21 +0300 Subject: [PATCH 087/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warnings: btr/btr0cur.c: In function 'btr_store_big_rec_extern_fields': btr/btr0cur.c:3368:10: error: variable 'rec_page' set but not used [-Werror=unused-but-set-variable] btr/btr0cur.c: In function 'btr_free_externally_stored_field': btr/btr0cur.c:3542:8: error: variable 'offset' set but not used [-Werror=unused-but-set-variable] btr/btr0cur.c:3539:10: error: variable 'rec_page' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/btr/btr0cur.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/storage/innobase/btr/btr0cur.c b/storage/innobase/btr/btr0cur.c index d2a2e4d2157..a7160d74a32 100644 --- a/storage/innobase/btr/btr0cur.c +++ b/storage/innobase/btr/btr0cur.c @@ -3365,7 +3365,9 @@ btr_store_big_rec_extern_fields( page_t* page; ulint space_id; page_t* prev_page; +#ifdef UNIV_SYNC_DEBUG page_t* rec_page; +#endif /* UNIV_SYNC_DEBUG */ ulint prev_page_no; ulint hint_page_no; ulint i; @@ -3460,9 +3462,12 @@ btr_store_big_rec_extern_fields( extern_len -= store_len; - rec_page = buf_page_get(space_id, - buf_frame_get_page_no(data), - RW_X_LATCH, &mtr); +#ifdef UNIV_SYNC_DEBUG + rec_page = +#endif /* UNIV_SYNC_DEBUG */ + buf_page_get(space_id, + buf_frame_get_page_no(data), + RW_X_LATCH, &mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(rec_page, SYNC_NO_ORDER_CHECK); #endif /* UNIV_SYNC_DEBUG */ @@ -3536,10 +3541,11 @@ btr_free_externally_stored_field( X-latch to the index tree */ { page_t* page; +#ifdef UNIV_SYNC_DEBUG page_t* rec_page; +#endif /* UNIV_SYNC_DEBUG */ ulint space_id; ulint page_no; - ulint offset; ulint extern_len; ulint next_page_no; ulint part_len; @@ -3556,9 +3562,12 @@ btr_free_externally_stored_field( for (;;) { mtr_start(&mtr); - rec_page = buf_page_get(buf_frame_get_space_id(data), - buf_frame_get_page_no(data), - RW_X_LATCH, &mtr); +#ifdef UNIV_SYNC_DEBUG + rec_page = +#endif /* UNIV_SYNC_DEBUG */ + buf_page_get(buf_frame_get_space_id(data), + buf_frame_get_page_no(data), + RW_X_LATCH, &mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(rec_page, SYNC_NO_ORDER_CHECK); #endif /* UNIV_SYNC_DEBUG */ @@ -3568,8 +3577,6 @@ btr_free_externally_stored_field( page_no = mach_read_from_4(data + local_len + BTR_EXTERN_PAGE_NO); - offset = mach_read_from_4(data + local_len - + BTR_EXTERN_OFFSET); extern_len = mach_read_from_4(data + local_len + BTR_EXTERN_LEN + 4); From 1859761222572d36811cd6dae225751c1df4e59e Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 11:38:59 +0300 Subject: [PATCH 088/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warnings: btr/btr0pcur.c: In function 'btr_pcur_move_backward_from_page': btr/btr0pcur.c:432:8: error: variable 'space' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/btr/btr0pcur.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innobase/btr/btr0pcur.c b/storage/innobase/btr/btr0pcur.c index 65b3c90c809..f73e82fb597 100644 --- a/storage/innobase/btr/btr0pcur.c +++ b/storage/innobase/btr/btr0pcur.c @@ -429,7 +429,6 @@ btr_pcur_move_backward_from_page( mtr_t* mtr) /* in: mtr */ { ulint prev_page_no; - ulint space; page_t* page; page_t* prev_page; ulint latch_mode; @@ -465,7 +464,6 @@ btr_pcur_move_backward_from_page( page = btr_pcur_get_page(cursor); prev_page_no = btr_page_get_prev(page, mtr); - space = buf_frame_get_space_id(page); if (btr_pcur_is_before_first_on_page(cursor, mtr) && (prev_page_no != FIL_NULL)) { From ee41fb98cdc067605aceb530b6f93aac88eac3f9 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 11:39:34 +0300 Subject: [PATCH 089/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warnings: btr/btr0sea.c: In function 'btr_search_update_hash_on_delete': btr/btr0sea.c:1404:9: error: variable 'found' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/btr/btr0sea.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/innobase/btr/btr0sea.c b/storage/innobase/btr/btr0sea.c index 84ad0e27110..97c9f89db72 100644 --- a/storage/innobase/btr/btr0sea.c +++ b/storage/innobase/btr/btr0sea.c @@ -1401,7 +1401,6 @@ btr_search_update_hash_on_delete( rec_t* rec; ulint fold; dulint index_id; - ibool found; ulint offsets_[REC_OFFS_NORMAL_SIZE]; mem_heap_t* heap = NULL; *offsets_ = (sizeof offsets_) / sizeof *offsets_; @@ -1433,7 +1432,7 @@ btr_search_update_hash_on_delete( } rw_lock_x_lock(&btr_search_latch); - found = ha_search_and_delete_if_found(table, fold, rec); + ha_search_and_delete_if_found(table, fold, rec); rw_lock_x_unlock(&btr_search_latch); } From 3684641cd986e2bfa3850c4353ac945d02f4fe64 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 12:00:58 +0300 Subject: [PATCH 090/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: buf/buf0flu.c: In function 'buf_flush_batch': buf/buf0flu.c:844:9: error: variable 'old_page_count' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/buf/buf0flu.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/storage/innobase/buf/buf0flu.c b/storage/innobase/buf/buf0flu.c index 7533205d695..24fa306c127 100644 --- a/storage/innobase/buf/buf0flu.c +++ b/storage/innobase/buf/buf0flu.c @@ -841,7 +841,6 @@ buf_flush_batch( { buf_block_t* block; ulint page_count = 0; - ulint old_page_count; ulint space; ulint offset; ibool found; @@ -913,15 +912,9 @@ buf_flush_batch( mutex_exit(&block->mutex); mutex_exit(&(buf_pool->mutex)); - old_page_count = page_count; - /* Try to flush also all the neighbors */ page_count += buf_flush_try_neighbors( space, offset, flush_type); - /* fprintf(stderr, - "Flush type %lu, page no %lu, neighb %lu\n", - flush_type, offset, - page_count - old_page_count); */ mutex_enter(&(buf_pool->mutex)); From 70a1e896352331ff5520d19e82ba5b1c654ec699 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 12:06:47 +0300 Subject: [PATCH 091/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: eval/eval0eval.c: In function 'eval_notfound': eval/eval0eval.c:371:14: error: variable 'arg2' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/eval/eval0eval.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innobase/eval/eval0eval.c b/storage/innobase/eval/eval0eval.c index cbc47ec508f..fb4e72a511f 100644 --- a/storage/innobase/eval/eval0eval.c +++ b/storage/innobase/eval/eval0eval.c @@ -368,13 +368,11 @@ eval_notfound( func_node_t* func_node) /* in: function node */ { que_node_t* arg1; - que_node_t* arg2; sym_node_t* cursor; sel_node_t* sel_node; ibool ibool_val; arg1 = func_node->args; - arg2 = que_node_get_next(arg1); ut_ad(func_node->func == PARS_NOTFOUND_TOKEN); From e92ef01fc4db6eb65a236725fac69df52902494e Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 12:11:00 +0300 Subject: [PATCH 092/183] Remove redundant variable --- storage/innobase/eval/eval0eval.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/storage/innobase/eval/eval0eval.c b/storage/innobase/eval/eval0eval.c index fb4e72a511f..52e9923fc05 100644 --- a/storage/innobase/eval/eval0eval.c +++ b/storage/innobase/eval/eval0eval.c @@ -367,16 +367,13 @@ eval_notfound( /*==========*/ func_node_t* func_node) /* in: function node */ { - que_node_t* arg1; sym_node_t* cursor; sel_node_t* sel_node; ibool ibool_val; - arg1 = func_node->args; - ut_ad(func_node->func == PARS_NOTFOUND_TOKEN); - cursor = arg1; + cursor = func_node->args; ut_ad(que_node_get_type(cursor) == QUE_NODE_SYMBOL); From 5cc0173acb984399e83ee06db8047f076dbfcda9 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 12:37:03 +0300 Subject: [PATCH 093/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: lock/lock0lock.c: In function 'lock_print_info_all_transactions': lock/lock0lock.c:4299:10: error: variable 'page' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/lock/lock0lock.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c index 04240960b3a..57df99fb401 100644 --- a/storage/innobase/lock/lock0lock.c +++ b/storage/innobase/lock/lock0lock.c @@ -4296,7 +4296,6 @@ lock_print_info_all_transactions( lock_t* lock; ulint space; ulint page_no; - page_t* page; ibool load_page_first = TRUE; ulint nth_trx = 0; ulint nth_lock = 0; @@ -4410,8 +4409,7 @@ loop: mtr_start(&mtr); - page = buf_page_get_with_no_latch( - space, page_no, &mtr); + buf_page_get_with_no_latch(space, page_no, &mtr); mtr_commit(&mtr); From f57fd93258703f565380f19b940648f6b3cbdf01 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 12:41:00 +0300 Subject: [PATCH 094/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: log/log0recv.c: In function 'recv_recovery_from_checkpoint_start': log/log0recv.c:2509:10: error: variable 'archived_lsn' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/log/log0recv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storage/innobase/log/log0recv.c b/storage/innobase/log/log0recv.c index e6524eeefbf..f896b11a519 100644 --- a/storage/innobase/log/log0recv.c +++ b/storage/innobase/log/log0recv.c @@ -2506,7 +2506,9 @@ recv_recovery_from_checkpoint_start( dulint old_scanned_lsn; dulint group_scanned_lsn; dulint contiguous_lsn; +#ifdef UNIV_LOG_ARCHIVE dulint archived_lsn; +#endif /* UNIV_LOG_ARCHIVE */ ulint capacity; byte* buf; byte log_hdr_buf[LOG_FILE_HDR_SIZE]; @@ -2552,7 +2554,9 @@ recv_recovery_from_checkpoint_start( checkpoint_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_LSN); checkpoint_no = mach_read_from_8(buf + LOG_CHECKPOINT_NO); +#ifdef UNIV_LOG_ARCHIVE archived_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN); +#endif /* UNIV_LOG_ARCHIVE */ /* Read the first log file header to print a note if this is a recovery from a restored InnoDB Hot Backup */ From 3be2fd88410bd739c838ea53e7331ebdecbe9807 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 12:46:23 +0300 Subject: [PATCH 095/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: log/log0recv.c: In function 'recv_synchronize_groups': log/log0recv.c:403:10: error: variable 'limit_lsn' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/log/log0recv.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innobase/log/log0recv.c b/storage/innobase/log/log0recv.c index f896b11a519..6e1ca58cb15 100644 --- a/storage/innobase/log/log0recv.c +++ b/storage/innobase/log/log0recv.c @@ -400,10 +400,8 @@ recv_synchronize_groups( dulint start_lsn; dulint end_lsn; dulint recovered_lsn; - dulint limit_lsn; recovered_lsn = recv_sys->recovered_lsn; - limit_lsn = recv_sys->limit_lsn; /* Read the last recovered log block to the recovery system buffer: the block is always incomplete */ From 100c5f010d7fa2debea368aed14832ed52b71452 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 13:01:25 +0300 Subject: [PATCH 096/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warnings: os/os0file.c: In function 'os_file_create': os/os0file.c:1318:14: error: variable 'purpose_str' set but not used [-Werror=unused-but-set-variable] os/os0file.c:1317:14: error: variable 'type_str' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/os/os0file.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/storage/innobase/os/os0file.c b/storage/innobase/os/os0file.c index 3396d1adf2f..a995aee5fab 100644 --- a/storage/innobase/os/os0file.c +++ b/storage/innobase/os/os0file.c @@ -1314,8 +1314,6 @@ try_again: int create_flag; ibool retry; const char* mode_str = NULL; - const char* type_str = NULL; - const char* purpose_str = NULL; try_again: ut_a(name); @@ -1335,26 +1333,9 @@ try_again: ut_error; } - if (type == OS_LOG_FILE) { - type_str = "LOG"; - } else if (type == OS_DATA_FILE) { - type_str = "DATA"; - } else { - ut_error; - } + ut_a(type == OS_LOG_FILE || type == OS_DATA_FILE); + ut_a(purpose == OS_FILE_AIO || purpose == OS_FILE_NORMAL); - if (purpose == OS_FILE_AIO) { - purpose_str = "AIO"; - } else if (purpose == OS_FILE_NORMAL) { - purpose_str = "NORMAL"; - } else { - ut_error; - } - -#if 0 - fprintf(stderr, "Opening file %s, mode %s, type %s, purpose %s\n", - name, mode_str, type_str, purpose_str); -#endif #ifdef O_SYNC /* We let O_SYNC only affect log files; note that we map O_DSYNC to O_SYNC because the datasync options seemed to corrupt files in 2001 From 52dc49e4ef68e9a1d812ad1c6379ec97eb3234fe Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 13:38:21 +0300 Subject: [PATCH 097/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: que/que0que.c: In function 'que_run_threads_low': que/que0que.c:1295:9: error: variable 'cumul_resource' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/que/que0que.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/storage/innobase/que/que0que.c b/storage/innobase/que/que0que.c index bf83f28f04e..9b5c25d4680 100644 --- a/storage/innobase/que/que0que.c +++ b/storage/innobase/que/que0que.c @@ -1292,18 +1292,13 @@ que_run_threads_low( que_thr_t* thr) /* in: query thread */ { que_thr_t* next_thr; - ulint cumul_resource; ulint loop_count; ut_ad(thr->state == QUE_THR_RUNNING); ut_a(thr_get_trx(thr)->error_state == DB_SUCCESS); ut_ad(!mutex_own(&kernel_mutex)); - /* cumul_resource counts how much resources the OS thread (NOT the - query thread) has spent in this function */ - loop_count = QUE_MAX_LOOPS_WITHOUT_CHECK; - cumul_resource = 0; loop: /* Check that there is enough space in the log to accommodate possible log entries by this query step; if the operation can touch From 4a4c7b92758c74132f11485812a55865b36dc488 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 13:39:52 +0300 Subject: [PATCH 098/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: que/que0que.c: In function 'que_thr_dec_refer_count': que/que0que.c:805:11: error: variable 'sess' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/que/que0que.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innobase/que/que0que.c b/storage/innobase/que/que0que.c index 9b5c25d4680..1a76823ca4d 100644 --- a/storage/innobase/que/que0que.c +++ b/storage/innobase/que/que0que.c @@ -802,13 +802,11 @@ que_thr_dec_refer_count( { que_fork_t* fork; trx_t* trx; - sess_t* sess; ulint fork_type; ibool stopped; fork = thr->common.parent; trx = thr_get_trx(thr); - sess = trx->sess; mutex_enter(&kernel_mutex); From 4c0f9c5d3302a927043f77ca5f70179703d5a186 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 13:56:29 +0300 Subject: [PATCH 099/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: row/row0purge.c: In function 'row_purge_step': row/row0purge.c:660:9: error: variable 'err' set but not used [-Werror=unused-but-set-variable] (row_purge() always returns DB_SUCCESS) --- storage/innobase/row/row0purge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/row/row0purge.c b/storage/innobase/row/row0purge.c index 1fef47da13f..deec3b0a454 100644 --- a/storage/innobase/row/row0purge.c +++ b/storage/innobase/row/row0purge.c @@ -667,7 +667,7 @@ row_purge_step( err = row_purge(node, thr); - ut_ad(err == DB_SUCCESS); + ut_a(err == DB_SUCCESS); return(thr); } From 6f8d5d6180f0788ff949341c4eaa1aa582b5a045 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 14:09:36 +0300 Subject: [PATCH 100/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: row/row0umod.c: In function 'row_undo_mod_clust_low': row/row0umod.c:92:9: error: variable 'success' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/row/row0umod.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/storage/innobase/row/row0umod.c b/storage/innobase/row/row0umod.c index 68139da116e..a3333fcc536 100644 --- a/storage/innobase/row/row0umod.c +++ b/storage/innobase/row/row0umod.c @@ -89,12 +89,17 @@ row_undo_mod_clust_low( btr_pcur_t* pcur; btr_cur_t* btr_cur; ulint err; +#ifdef UNIV_DEBUG ibool success; +#endif /* UNIV_DEBUG */ pcur = &(node->pcur); btr_cur = btr_pcur_get_btr_cur(pcur); - success = btr_pcur_restore_position(mode, pcur, mtr); +#ifdef UNIV_DEBUG + success = +#endif /* UNIV_DEBUG */ + btr_pcur_restore_position(mode, pcur, mtr); ut_ad(success); From aa5ac11d2aa49cd0589c511c4043f096249039d6 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 14:46:13 +0300 Subject: [PATCH 101/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: row/row0upd.c: In function 'row_upd_in_place_in_select': row/row0upd.c:2040:9: error: variable 'err' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/row/row0upd.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/storage/innobase/row/row0upd.c b/storage/innobase/row/row0upd.c index c91cc449b96..034b7010410 100644 --- a/storage/innobase/row/row0upd.c +++ b/storage/innobase/row/row0upd.c @@ -2037,7 +2037,9 @@ row_upd_in_place_in_select( upd_node_t* node; btr_pcur_t* pcur; btr_cur_t* btr_cur; +#ifdef UNIV_DEBUG ulint err; +#endif /* UNIV_DEBUG */ mem_heap_t* heap = NULL; ulint offsets_[REC_OFFS_NORMAL_SIZE]; *offsets_ = (sizeof offsets_) / sizeof *offsets_; @@ -2074,8 +2076,11 @@ row_upd_in_place_in_select( ut_ad(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE); ut_ad(node->select_will_do_update); - err = btr_cur_update_in_place(BTR_NO_LOCKING_FLAG, btr_cur, - node->update, node->cmpl_info, - thr, mtr); +#ifdef UNIV_DEBUG + err = +#endif /* UNIV_DEBUG */ + btr_cur_update_in_place(BTR_NO_LOCKING_FLAG, btr_cur, + node->update, node->cmpl_info, + thr, mtr); ut_ad(err == DB_SUCCESS); } From e454b9e2abdb3db06e669abcf290159920fbbf13 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 14:50:13 +0300 Subject: [PATCH 102/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: row/row0vers.c: In function 'row_vers_impl_x_locked_off_kernel': row/row0vers.c:62:9: error: variable 'err' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/row/row0vers.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/storage/innobase/row/row0vers.c b/storage/innobase/row/row0vers.c index 03d9a2f1203..f4adfa855df 100644 --- a/storage/innobase/row/row0vers.c +++ b/storage/innobase/row/row0vers.c @@ -59,7 +59,9 @@ row_vers_impl_x_locked_off_kernel( trx_t* trx; ulint vers_del; ulint rec_del; +#ifdef UNIV_DEBUG ulint err; +#endif /* UNIV_DEBUG */ mtr_t mtr; ulint comp; @@ -152,9 +154,12 @@ row_vers_impl_x_locked_off_kernel( heap2 = heap; heap = mem_heap_create(1024); - err = trx_undo_prev_version_build(clust_rec, &mtr, version, - clust_index, clust_offsets, - heap, &prev_version); +#ifdef UNIV_DEBUG + err = +#endif /* UNIV_DEBUG */ + trx_undo_prev_version_build(clust_rec, &mtr, version, + clust_index, clust_offsets, + heap, &prev_version); mem_heap_free(heap2); /* free version and clust_offsets */ if (prev_version) { From 2245d41627d879bc83d0b32a9aa21aac085d16d2 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 15:04:03 +0300 Subject: [PATCH 103/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: trx/trx0purge.c: In function 'trx_purge_add_update_undo_to_history': trx/trx0purge.c:254:16: error: variable 'page_header' set but not used [-Werror=unused-but-set-variable] trx/trx0purge.c:252:15: error: variable 'seg_header' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/trx/trx0purge.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/storage/innobase/trx/trx0purge.c b/storage/innobase/trx/trx0purge.c index f0f300d918e..caeb98484af 100644 --- a/storage/innobase/trx/trx0purge.c +++ b/storage/innobase/trx/trx0purge.c @@ -249,9 +249,10 @@ trx_purge_add_update_undo_to_history( trx_undo_t* undo; trx_rseg_t* rseg; trx_rsegf_t* rseg_header; +#ifdef UNIV_DEBUG trx_usegf_t* seg_header; +#endif /* UNIV_DEBUG */ trx_ulogf_t* undo_header; - trx_upagef_t* page_header; ulint hist_size; undo = trx->update_undo; @@ -265,8 +266,9 @@ trx_purge_add_update_undo_to_history( rseg_header = trx_rsegf_get(rseg->space, rseg->page_no, mtr); undo_header = undo_page + undo->hdr_offset; +#ifdef UNIV_DEBUG seg_header = undo_page + TRX_UNDO_SEG_HDR; - page_header = undo_page + TRX_UNDO_PAGE_HDR; +#endif /* UNIV_DEBUG */ if (undo->state != TRX_UNDO_CACHED) { /* The undo log segment will not be reused */ From dff449bc97fcc5506eb97110202161b3ee7cec2a Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 15:17:48 +0300 Subject: [PATCH 104/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: trx/trx0purge.c: In function 'trx_purge_rseg_get_next_history_log': trx/trx0purge.c:599:15: error: variable 'seg_hdr' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/trx/trx0purge.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innobase/trx/trx0purge.c b/storage/innobase/trx/trx0purge.c index caeb98484af..3e77efccde7 100644 --- a/storage/innobase/trx/trx0purge.c +++ b/storage/innobase/trx/trx0purge.c @@ -596,7 +596,6 @@ trx_purge_rseg_get_next_history_log( { page_t* undo_page; trx_ulogf_t* log_hdr; - trx_usegf_t* seg_hdr; fil_addr_t prev_log_addr; dulint trx_no; ibool del_marks; @@ -617,7 +616,6 @@ trx_purge_rseg_get_next_history_log( undo_page = trx_undo_page_get_s_latched(rseg->space, rseg->last_page_no, &mtr); log_hdr = undo_page + rseg->last_offset; - seg_hdr = undo_page + TRX_UNDO_SEG_HDR; /* Increase the purge page count by one for every handled log */ From 2869f5376b44770556353f5c7ad2f806c3d36bd9 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 15:19:04 +0300 Subject: [PATCH 105/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: trx/trx0purge.c: In function 'trx_purge_rec_release': trx/trx0purge.c:1007:18: error: variable 'arr' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/trx/trx0purge.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/storage/innobase/trx/trx0purge.c b/storage/innobase/trx/trx0purge.c index 3e77efccde7..9e09efc82b2 100644 --- a/storage/innobase/trx/trx0purge.c +++ b/storage/innobase/trx/trx0purge.c @@ -1004,12 +1004,8 @@ trx_purge_rec_release( /*==================*/ trx_undo_inf_t* cell) /* in: storage cell */ { - trx_undo_arr_t* arr; - mutex_enter(&(purge_sys->mutex)); - arr = purge_sys->arr; - trx_purge_arr_remove_info(cell); mutex_exit(&(purge_sys->mutex)); From eb362b90c382586b68616025eca5166a59bf0d7a Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 15:21:32 +0300 Subject: [PATCH 106/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warnings: trx/trx0roll.c: In function 'trx_undo_arr_remove_info': trx/trx0roll.c:717:9: error: variable 'n' set but not used [-Werror=unused-but-set-variable] trx/trx0roll.c:716:9: error: variable 'n_used' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/trx/trx0roll.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/storage/innobase/trx/trx0roll.c b/storage/innobase/trx/trx0roll.c index 8934fe87c7e..285e30796a5 100644 --- a/storage/innobase/trx/trx0roll.c +++ b/storage/innobase/trx/trx0roll.c @@ -713,13 +713,8 @@ trx_undo_arr_remove_info( dulint undo_no)/* in: undo number */ { trx_undo_inf_t* cell; - ulint n_used; - ulint n; ulint i; - n_used = arr->n_used; - n = 0; - for (i = 0;; i++) { cell = trx_undo_arr_get_nth_info(arr, i); From 67b412652f42b01fbc2a4de1517d3409309ad0e2 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 15:28:48 +0300 Subject: [PATCH 107/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: trx/trx0sys.c: In function 'trx_sys_create_doublewrite_buf': trx/trx0sys.c:168:10: error: variable 'new_page' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/trx/trx0sys.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/storage/innobase/trx/trx0sys.c b/storage/innobase/trx/trx0sys.c index f732aca93f5..137771b71ed 100644 --- a/storage/innobase/trx/trx0sys.c +++ b/storage/innobase/trx/trx0sys.c @@ -165,7 +165,9 @@ trx_sys_create_doublewrite_buf(void) { page_t* page; page_t* page2; +#ifdef UNIV_SYNC_DEBUG page_t* new_page; +#endif /* UNIV_SYNC_DEBUG */ byte* doublewrite; byte* fseg_header; ulint page_no; @@ -271,8 +273,11 @@ start_again: the page position in the tablespace, then the page has not been written to in doublewrite. */ - new_page = buf_page_get(TRX_SYS_SPACE, page_no, - RW_X_LATCH, &mtr); +#ifdef UNIV_SYNC_DEBUG + new_page = +#endif /* UNIV_SYNC_DEBUG */ + buf_page_get(TRX_SYS_SPACE, page_no, + RW_X_LATCH, &mtr); #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(new_page, SYNC_NO_ORDER_CHECK); #endif /* UNIV_SYNC_DEBUG */ From 6a163cde4eba6cb2981ceb65e1ce553a51e425bc Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 15:30:26 +0300 Subject: [PATCH 108/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: trx/trx0trx.c: In function 'trx_prepare_off_kernel': trx/trx0trx.c:1830:11: error: variable 'update_hdr_page' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/trx/trx0trx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/innobase/trx/trx0trx.c b/storage/innobase/trx/trx0trx.c index 545226a5994..21f75e0818f 100644 --- a/storage/innobase/trx/trx0trx.c +++ b/storage/innobase/trx/trx0trx.c @@ -1827,7 +1827,6 @@ trx_prepare_off_kernel( /*===================*/ trx_t* trx) /* in: transaction */ { - page_t* update_hdr_page; trx_rseg_t* rseg; ibool must_flush_log = FALSE; dulint lsn; @@ -1863,7 +1862,7 @@ trx_prepare_off_kernel( } if (trx->update_undo) { - update_hdr_page = trx_undo_set_state_at_prepare( + trx_undo_set_state_at_prepare( trx, trx->update_undo, &mtr); } From d947f567d4f2443abaa55edf6a48384ae94c7ee3 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 17:53:49 +0300 Subject: [PATCH 109/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: trx/trx0undo.c: In function 'trx_undo_truncate_end': trx/trx0undo.c:1015:14: error: variable 'rseg' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/trx/trx0undo.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/storage/innobase/trx/trx0undo.c b/storage/innobase/trx/trx0undo.c index deb6c85e6e3..e47abe2c08a 100644 --- a/storage/innobase/trx/trx0undo.c +++ b/storage/innobase/trx/trx0undo.c @@ -1012,14 +1012,11 @@ trx_undo_truncate_end( ulint last_page_no; trx_undo_rec_t* rec; trx_undo_rec_t* trunc_here; - trx_rseg_t* rseg; mtr_t mtr; ut_ad(mutex_own(&(trx->undo_mutex))); ut_ad(mutex_own(&(trx->rseg->mutex))); - rseg = trx->rseg; - for (;;) { mtr_start(&mtr); From b88a2c4752fcb2543d9c077d201cc5ccbce2319e Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 17:55:44 +0300 Subject: [PATCH 110/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: trx/trx0undo.c: In function 'trx_undo_set_state_at_prepare': trx/trx0undo.c:1798:16: error: variable 'page_hdr' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/trx/trx0undo.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innobase/trx/trx0undo.c b/storage/innobase/trx/trx0undo.c index e47abe2c08a..4547ee9ea64 100644 --- a/storage/innobase/trx/trx0undo.c +++ b/storage/innobase/trx/trx0undo.c @@ -1795,7 +1795,6 @@ trx_undo_set_state_at_prepare( mtr_t* mtr) /* in: mtr */ { trx_usegf_t* seg_hdr; - trx_upagef_t* page_hdr; trx_ulogf_t* undo_header; page_t* undo_page; ulint offset; @@ -1812,7 +1811,6 @@ trx_undo_set_state_at_prepare( undo_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr); seg_hdr = undo_page + TRX_UNDO_SEG_HDR; - page_hdr = undo_page + TRX_UNDO_PAGE_HDR; /*------------------------------*/ undo->state = TRX_UNDO_PREPARED; From 150c19ee03ce9b9b9ac60a6e27729128e1792ec7 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 18:22:30 +0300 Subject: [PATCH 111/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: handler/ha_innodb.cc: In function 'void innobase_drop_database(handlerton*, char*)': handler/ha_innodb.cc:5969:6: error: variable 'error' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/handler/ha_innodb.cc | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 4688b5fd16c..4027a908fb3 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -5966,7 +5966,6 @@ innobase_drop_database( trx_t* parent_trx; trx_t* trx; char* ptr; - int error; char* namebuf; THD* thd = current_thd; @@ -6004,7 +6003,7 @@ innobase_drop_database( trx->check_foreigns = FALSE; } - error = row_drop_database_for_mysql(namebuf, trx); + row_drop_database_for_mysql(namebuf, trx); my_free(namebuf, MYF(0)); /* Flush the log to reduce probability that the .frm files and @@ -6020,13 +6019,7 @@ innobase_drop_database( innobase_commit_low(trx); trx_free_for_mysql(trx); -#ifdef NO_LONGER_INTERESTED_IN_DROP_DB_ERROR - error = convert_error_code_to_mysql(error, NULL); - - return(error); -#else return; -#endif } /************************************************************************* From e5e4c2d6a95ace49f3ae996724b52b1a4d3c6a90 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 18:25:41 +0300 Subject: [PATCH 112/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: handler/ha_innodb.cc: In function 'bool innodb_show_status(handlerton*, THD*, bool (*)(THD*, const char*, uint, const char*, uint, const char*, uint))': handler/ha_innodb.cc:7539:7: error: variable 'result' set but not used [-Werror=unused-but-set-variable] --- storage/innobase/handler/ha_innodb.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 4027a908fb3..cfd4b229ce0 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -7536,12 +7536,9 @@ innodb_show_status( mutex_exit_noninline(&srv_monitor_file_mutex); - bool result = FALSE; + stat_print(thd, innobase_hton_name, (uint) strlen(innobase_hton_name), + STRING_WITH_LEN(""), str, flen); - if (stat_print(thd, innobase_hton_name, (uint) strlen(innobase_hton_name), - STRING_WITH_LEN(""), str, flen)) { - result= TRUE; - } my_free(str, MYF(0)); DBUG_RETURN(FALSE); From 1fb4a120fa7371f0c54fe29e972caba6b6de647b Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 20:58:02 +0300 Subject: [PATCH 113/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: ./include/ut0rnd.ic: In function 'ut_rnd_gen_ulint': ./include/ut0rnd.ic:88:8: error: variable 'n_bits' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/include/ut0rnd.ic | 3 --- 1 file changed, 3 deletions(-) diff --git a/storage/innodb_plugin/include/ut0rnd.ic b/storage/innodb_plugin/include/ut0rnd.ic index c3dbd86923c..a33813037ea 100644 --- a/storage/innodb_plugin/include/ut0rnd.ic +++ b/storage/innodb_plugin/include/ut0rnd.ic @@ -85,9 +85,6 @@ ut_rnd_gen_ulint(void) /*==================*/ { ulint rnd; - ulint n_bits; - - n_bits = 8 * sizeof(ulint); ut_rnd_ulint_counter = UT_RND1 * ut_rnd_ulint_counter + UT_RND2; From 5be7145798f9c8740084df475d57e7055dd08239 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 21:12:19 +0300 Subject: [PATCH 114/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: btr/btr0btr.c: In function 'btr_page_split_and_insert': btr/btr0btr.c:1898:11: error: variable 'insert_page' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/btr/btr0btr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/storage/innodb_plugin/btr/btr0btr.c b/storage/innodb_plugin/btr/btr0btr.c index 02677e0a71c..11b6782d5d6 100644 --- a/storage/innodb_plugin/btr/btr0btr.c +++ b/storage/innodb_plugin/btr/btr0btr.c @@ -1895,7 +1895,6 @@ btr_page_split_and_insert( buf_block_t* left_block; buf_block_t* right_block; buf_block_t* insert_block; - page_t* insert_page; page_cur_t* page_cursor; rec_t* first_rec; byte* buf = 0; /* remove warning */ @@ -2153,8 +2152,6 @@ insert_empty: insert_block = right_block; } - insert_page = buf_block_get_frame(insert_block); - /* 7. Reposition the cursor for insert and try insertion */ page_cursor = btr_cur_get_page_cur(cursor); @@ -2166,8 +2163,12 @@ insert_empty: #ifdef UNIV_ZIP_DEBUG { + page_t* insert_page + = buf_block_get_frame(insert_block); + page_zip_des_t* insert_page_zip = buf_block_get_page_zip(insert_block); + ut_a(!insert_page_zip || page_zip_validate(insert_page_zip, insert_page)); } From a46914db1b2cb2bb991cf7f9b5b256b2ce911774 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 21:14:42 +0300 Subject: [PATCH 115/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: btr/btr0btr.c: In function 'btr_compress': btr/btr0btr.c:2564:9: error: variable 'level' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/btr/btr0btr.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innodb_plugin/btr/btr0btr.c b/storage/innodb_plugin/btr/btr0btr.c index 11b6782d5d6..29cd470e650 100644 --- a/storage/innodb_plugin/btr/btr0btr.c +++ b/storage/innodb_plugin/btr/btr0btr.c @@ -2561,7 +2561,6 @@ btr_compress( ulint n_recs; ulint max_ins_size; ulint max_ins_size_reorg; - ulint level; block = btr_cur_get_block(cursor); page = btr_cur_get_page(cursor); @@ -2571,7 +2570,6 @@ btr_compress( ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index), MTR_MEMO_X_LOCK)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); - level = btr_page_get_level(page, mtr); space = dict_index_get_space(index); zip_size = dict_table_zip_size(index->table); From b0c95a9a6dc6bbfc4e0037098e1bf794ad4c5400 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 21:30:37 +0300 Subject: [PATCH 116/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: btr/btr0cur.c: In function 'btr_cur_optimistic_update': btr/btr0cur.c:1839:10: error: variable 'orig_rec' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/btr/btr0cur.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0cur.c index 7fa7d42320a..7f4b5ffaf64 100644 --- a/storage/innodb_plugin/btr/btr0cur.c +++ b/storage/innodb_plugin/btr/btr0cur.c @@ -1836,7 +1836,6 @@ btr_cur_optimistic_update( page_t* page; page_zip_des_t* page_zip; rec_t* rec; - rec_t* orig_rec; ulint max_size; ulint new_rec_size; ulint old_rec_size; @@ -1850,7 +1849,7 @@ btr_cur_optimistic_update( block = btr_cur_get_block(cursor); page = buf_block_get_frame(block); - orig_rec = rec = btr_cur_get_rec(cursor); + rec = btr_cur_get_rec(cursor); index = cursor->index; ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); From 74cb6707b56ff2f6b1170ad7e36aa706be92911f Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 21:33:02 +0300 Subject: [PATCH 117/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: btr/btr0cur.c: In function 'btr_free_externally_stored_field': btr/btr0cur.c:4281:16: error: variable 'rec_block' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/btr/btr0cur.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0cur.c index 7f4b5ffaf64..884b7fed8dd 100644 --- a/storage/innodb_plugin/btr/btr0cur.c +++ b/storage/innodb_plugin/btr/btr0cur.c @@ -4278,12 +4278,17 @@ btr_free_externally_stored_field( } for (;;) { +#ifdef UNIV_SYNC_DEBUG buf_block_t* rec_block; +#endif /* UNIV_SYNC_DEBUG */ buf_block_t* ext_block; mtr_start(&mtr); - rec_block = buf_page_get(page_get_space_id( +#ifdef UNIV_SYNC_DEBUG + rec_block = +#endif /* UNIV_SYNC_DEBUG */ + buf_page_get(page_get_space_id( page_align(field_ref)), rec_zip_size, page_get_page_no( From ab2c49b4adb332280236bb8aef8f014aa5aef052 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 21:35:37 +0300 Subject: [PATCH 118/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: btr/btr0pcur.c: In function 'btr_pcur_move_backward_from_page': btr/btr0pcur.c:455:9: error: variable 'space' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/btr/btr0pcur.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innodb_plugin/btr/btr0pcur.c b/storage/innodb_plugin/btr/btr0pcur.c index 658901208ef..056896c7927 100644 --- a/storage/innodb_plugin/btr/btr0pcur.c +++ b/storage/innodb_plugin/btr/btr0pcur.c @@ -452,7 +452,6 @@ btr_pcur_move_backward_from_page( mtr_t* mtr) /*!< in: mtr */ { ulint prev_page_no; - ulint space; page_t* page; buf_block_t* prev_block; ulint latch_mode; @@ -488,7 +487,6 @@ btr_pcur_move_backward_from_page( page = btr_pcur_get_page(cursor); prev_page_no = btr_page_get_prev(page, mtr); - space = buf_block_get_space(btr_pcur_get_block(cursor)); if (prev_page_no == FIL_NULL) { } else if (btr_pcur_is_before_first_on_page(cursor)) { From 32c39f1a1d2512689bfc78557d2f4737fce185f0 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 14 Sep 2010 21:36:29 +0300 Subject: [PATCH 119/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: btr/btr0sea.c: In function 'btr_search_update_hash_on_delete': btr/btr0sea.c:1498:9: error: variable 'found' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/btr/btr0sea.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/innodb_plugin/btr/btr0sea.c b/storage/innodb_plugin/btr/btr0sea.c index f3ffe07a951..035fdbb61d2 100644 --- a/storage/innodb_plugin/btr/btr0sea.c +++ b/storage/innodb_plugin/btr/btr0sea.c @@ -1495,7 +1495,6 @@ btr_search_update_hash_on_delete( rec_t* rec; ulint fold; dulint index_id; - ibool found; ulint offsets_[REC_OFFS_NORMAL_SIZE]; mem_heap_t* heap = NULL; rec_offs_init(offsets_); @@ -1528,7 +1527,7 @@ btr_search_update_hash_on_delete( } rw_lock_x_lock(&btr_search_latch); - found = ha_search_and_delete_if_found(table, fold, rec); + ha_search_and_delete_if_found(table, fold, rec); rw_lock_x_unlock(&btr_search_latch); } From bde21e58108a1f311d15088c50414bb43ab45d62 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Wed, 15 Sep 2010 10:22:12 +0200 Subject: [PATCH 120/183] Bug#56659: Mismatch of CAPITAL vs small letters in "unified filelist" partitioning output Bug#56657: Test still uses "--exec rm -f ..." which is non-portable Bug#56601: Test uses Unix path for temporary file, fails, and writes misleading message Several tests that was written in a non portable way (failed on windows) Fixed by 1) backporting the fix for replace_result to also apply to list_files (mysqltest from mysql-trunk) 2) replacing all #p#/#sp#/#tmp# to #P#/#SP#/#TMP#/ (innodb always converts filenames to lower case in windows). 3) replacing '--exec rm -f' with '--remove_files_wildcard' 4) replacing a perl snippet with '--write_file' --- client/mysqltest.cc | 8 +++++--- mysql-test/suite/parts/inc/partition_check_drop.inc | 9 +++++---- mysql-test/suite/parts/inc/partition_crash.inc | 6 +++--- mysql-test/suite/parts/inc/partition_fail.inc | 2 ++ mysql-test/suite/parts/inc/partition_layout.inc | 2 +- .../suite/parts/inc/partition_layout_check1.inc | 2 +- .../suite/parts/inc/partition_layout_check2.inc | 2 +- .../suite/parts/r/partition_recover_myisam.result | 2 +- .../suite/parts/r/partition_special_myisam.result | 2 +- .../suite/parts/t/part_supported_sql_func_innodb.test | 3 +++ .../suite/parts/t/partition_alter1_1_2_innodb.test | 3 +++ .../suite/parts/t/partition_alter1_2_innodb.test | 3 +++ .../suite/parts/t/partition_alter2_1_1_innodb.test | 3 +++ .../suite/parts/t/partition_alter2_1_2_innodb.test | 3 +++ .../suite/parts/t/partition_alter2_2_2_innodb.test | 3 +++ mysql-test/suite/parts/t/partition_alter4_innodb.test | 3 +++ .../suite/parts/t/partition_debug_sync_innodb.test | 2 ++ .../suite/parts/t/partition_recover_myisam.test | 2 +- .../suite/parts/t/partition_special_myisam.test | 11 ++++++----- 19 files changed, 50 insertions(+), 21 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index ca9217bf428..abe845b3710 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -447,7 +447,7 @@ struct st_command char *query, *query_buf,*first_argument,*last_argument,*end; DYNAMIC_STRING content; int first_word_len, query_len; - my_bool abort_on_error; + my_bool abort_on_error, used_replace; struct st_expected_errors expected_errors; char require_file[FN_REFLEN]; enum enum_commands type; @@ -3414,7 +3414,7 @@ static int get_list_files(DYNAMIC_STRING *ds, const DYNAMIC_STRING *ds_dirname, if (ds_wild && ds_wild->length && wild_compare(file->name, ds_wild->str, 0)) continue; - dynstr_append(ds, file->name); + replace_dynstr_append(ds, file->name); dynstr_append(ds, "\n"); } set_wild_chars(0); @@ -3444,6 +3444,7 @@ static void do_list_files(struct st_command *command) {"file", ARG_STRING, FALSE, &ds_wild, "Filename (incl. wildcard)"} }; DBUG_ENTER("do_list_files"); + command->used_replace= 1; check_command_args(command, command->first_argument, list_files_args, @@ -3485,6 +3486,7 @@ static void do_list_files_write_file_command(struct st_command *command, {"file", ARG_STRING, FALSE, &ds_wild, "Filename (incl. wildcard)"} }; DBUG_ENTER("do_list_files_write_file"); + command->used_replace= 1; check_command_args(command, command->first_argument, list_files_args, @@ -8473,7 +8475,7 @@ int main(int argc, char **argv) memset(&saved_expected_errors, 0, sizeof(saved_expected_errors)); } - if (command_executed != last_command_executed) + if (command_executed != last_command_executed || command->used_replace) { /* As soon as any command has been executed, diff --git a/mysql-test/suite/parts/inc/partition_check_drop.inc b/mysql-test/suite/parts/inc/partition_check_drop.inc index daaa5e541c7..0941cd9703b 100644 --- a/mysql-test/suite/parts/inc/partition_check_drop.inc +++ b/mysql-test/suite/parts/inc/partition_check_drop.inc @@ -26,10 +26,12 @@ if ($do_file_tests) { let $ls_file= $MYSQLD_DATADIR/test/tmp2; # List the files belonging to the table t1 + --replace_result $MYSQLTEST_VARDIR \$MYSQLTEST_VARDIR #p# #P# #sp# #SP# --list_files_write_file $ls_file $MYSQLD_DATADIR/test t1* --chmod 0644 $ls_file if ($with_directories) { + --replace_result $MYSQLTEST_VARDIR \$MYSQLTEST_VARDIR #p# #P# #sp# #SP# --list_files_append_file $ls_file $MYSQLTEST_VARDIR/tmp t1* } eval SET @aux = load_file('$ls_file'); @@ -60,16 +62,15 @@ if ($found_garbage) --echo # worked incomplete. --echo # We found: # Print the list of files into the protocol - eval SELECT REPLACE(file_list,'$MYSQLTEST_VARDIR','\$MYSQLTEST_VARDIR') - AS "unified filelist" + eval SELECT file_list AS "unified filelist" FROM t0_definition WHERE state = 'old'; } # Do a manual cleanup, because the following tests should not suffer from # remaining files - --exec rm -f $MYSQLD_DATADIR/test/t1* || true + --remove_files_wildcard $MYSQLD_DATADIR/test t1* if ($with_directories) { - --exec rm -f $MYSQLTEST_VARDIR/tmp/t1* || true + --remove_files_wildcard $MYSQLTEST_VARDIR/tmp t1* } } --enable_query_log diff --git a/mysql-test/suite/parts/inc/partition_crash.inc b/mysql-test/suite/parts/inc/partition_crash.inc index f18b8728784..b8a7c61792b 100644 --- a/mysql-test/suite/parts/inc/partition_crash.inc +++ b/mysql-test/suite/parts/inc/partition_crash.inc @@ -3,7 +3,7 @@ --eval $create_statement --eval $insert_statement --echo # State before crash ---replace_result #p# #P# +--replace_result #p# #P# #sp# #SP# --list_files $DATADIR/test SHOW CREATE TABLE t1; --sorted_result @@ -14,13 +14,13 @@ SELECT * FROM t1; --error 2013 --eval $crash_statement --echo # State after crash (before recovery) ---replace_regex /sqlx.*\./sqlx-nnnn_nnnn./ /#p#/#P#/ +--replace_regex /sqlx.*\./sqlx-nnnn_nnnn./ /#p#/#P#/ /#sp#/#SP#/ /#tmp#/#TMP#/ --list_files $DATADIR/test --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc --echo # State after crash recovery ---replace_result #p# #P# +--replace_result #p# #P# #sp# #SP# --list_files $DATADIR/test SHOW CREATE TABLE t1; --sorted_result diff --git a/mysql-test/suite/parts/inc/partition_fail.inc b/mysql-test/suite/parts/inc/partition_fail.inc index 6942b40042a..2c154a90499 100644 --- a/mysql-test/suite/parts/inc/partition_fail.inc +++ b/mysql-test/suite/parts/inc/partition_fail.inc @@ -3,6 +3,7 @@ --eval $create_statement --eval $insert_statement --echo # State before failure +--replace_result #p# #P# #sp# #SP# --list_files $DATADIR/test SHOW CREATE TABLE t1; --sorted_result @@ -11,6 +12,7 @@ SELECT * FROM t1; --eval $fail_statement --enable_abort_on_error --echo # State after failure +--replace_result #p# #P# #sp# #SP# --list_files $DATADIR/test SHOW CREATE TABLE t1; --sorted_result diff --git a/mysql-test/suite/parts/inc/partition_layout.inc b/mysql-test/suite/parts/inc/partition_layout.inc index 67d0fd4c0e9..12fbfb9a46a 100644 --- a/mysql-test/suite/parts/inc/partition_layout.inc +++ b/mysql-test/suite/parts/inc/partition_layout.inc @@ -10,6 +10,6 @@ eval SHOW CREATE TABLE t1; if ($ls) { let $MYSQLD_DATADIR= `select @@datadir`; - --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR + --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR #p# #P# #sp# #SP# --list_files $MYSQLD_DATADIR/test t1* } diff --git a/mysql-test/suite/parts/inc/partition_layout_check1.inc b/mysql-test/suite/parts/inc/partition_layout_check1.inc index bca41b6f9c7..1b0b24f1088 100644 --- a/mysql-test/suite/parts/inc/partition_layout_check1.inc +++ b/mysql-test/suite/parts/inc/partition_layout_check1.inc @@ -69,7 +69,7 @@ if ($do_file_tests) if ($ls) { # Print the list of files into the protocol - replace_result $MYSQLD_DATADIR MYSQLD_DATADIR $MYSQLTEST_VARDIR MYSQLTEST_VARDIR; + replace_result $MYSQLD_DATADIR MYSQLD_DATADIR $MYSQLTEST_VARDIR MYSQLTEST_VARDIR #p# #P# #sp# #SP# part_n part_N; SELECT file_list AS "unified filelist" FROM t0_definition WHERE state = 'old'; } diff --git a/mysql-test/suite/parts/inc/partition_layout_check2.inc b/mysql-test/suite/parts/inc/partition_layout_check2.inc index 7ff871a4c45..b1ec56ceedd 100644 --- a/mysql-test/suite/parts/inc/partition_layout_check2.inc +++ b/mysql-test/suite/parts/inc/partition_layout_check2.inc @@ -65,7 +65,7 @@ let $run= `SELECT @aux`; if ($run) { --vertical_results - --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR #p# #P# #sp# #SP# SELECT state, REPLACE(create_command,'\n',' ') AS "Table definition", REPLACE(file_list ,'\n',' ') AS "File list" diff --git a/mysql-test/suite/parts/r/partition_recover_myisam.result b/mysql-test/suite/parts/r/partition_recover_myisam.result index f4cdc2a418a..3c73817ef2e 100644 --- a/mysql-test/suite/parts/r/partition_recover_myisam.result +++ b/mysql-test/suite/parts/r/partition_recover_myisam.result @@ -1,4 +1,4 @@ -call mtr.add_suppression("./test/t1_will_crash"); +call mtr.add_suppression("t1_will_crash"); call mtr.add_suppression("Got an error from unknown thread"); CREATE TABLE t1_will_crash (a INT, KEY (a)) ENGINE=MyISAM; INSERT INTO t1_will_crash VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11); diff --git a/mysql-test/suite/parts/r/partition_special_myisam.result b/mysql-test/suite/parts/r/partition_special_myisam.result index f8618fcbb6d..bc8036ba861 100644 --- a/mysql-test/suite/parts/r/partition_special_myisam.result +++ b/mysql-test/suite/parts/r/partition_special_myisam.result @@ -214,7 +214,7 @@ SET lock_wait_timeout = 2; ALTER TABLE t1 COALESCE PARTITION 2; ERROR HY000: Lock wait timeout exceeded; try restarting transaction # Connection 3 tries to load into the table: -LOAD DATA LOCAL INFILE '/tmp/load.in' INTO TABLE t1 (f); +LOAD DATA INFILE 'load.in' INTO TABLE t1 (f); # Connection 1 commits the transaction COMMIT; # Connection 3... diff --git a/mysql-test/suite/parts/t/part_supported_sql_func_innodb.test b/mysql-test/suite/parts/t/part_supported_sql_func_innodb.test index e8d263e369c..002da3c8f37 100644 --- a/mysql-test/suite/parts/t/part_supported_sql_func_innodb.test +++ b/mysql-test/suite/parts/t/part_supported_sql_func_innodb.test @@ -28,6 +28,9 @@ let $do_long_tests= 1; # The server must support partitioning. --source include/have_partition.inc +# This test takes long time, so only run it with the --big mtr-flag. +--source include/big_test.inc + #------------------------------------------------------------------------------# # Engine specific settings and requirements diff --git a/mysql-test/suite/parts/t/partition_alter1_1_2_innodb.test b/mysql-test/suite/parts/t/partition_alter1_1_2_innodb.test index 8e3dde286cf..6ac1803a972 100644 --- a/mysql-test/suite/parts/t/partition_alter1_1_2_innodb.test +++ b/mysql-test/suite/parts/t/partition_alter1_1_2_innodb.test @@ -46,6 +46,9 @@ let $more_pk_ui_tests= 0; # The server must support partitioning. --source include/have_partition.inc +# This test takes long time, so only run it with the --big mtr-flag. +--source include/big_test.inc + #------------------------------------------------------------------------------# # Engine specific settings and requirements diff --git a/mysql-test/suite/parts/t/partition_alter1_2_innodb.test b/mysql-test/suite/parts/t/partition_alter1_2_innodb.test index 76fe7eb0223..2cbe0ab77ab 100644 --- a/mysql-test/suite/parts/t/partition_alter1_2_innodb.test +++ b/mysql-test/suite/parts/t/partition_alter1_2_innodb.test @@ -46,6 +46,9 @@ let $more_pk_ui_tests= 0; # The server must support partitioning. --source include/have_partition.inc +# This test takes long time, so only run it with the --big mtr-flag. +--source include/big_test.inc + #------------------------------------------------------------------------------# # Engine specific settings and requirements diff --git a/mysql-test/suite/parts/t/partition_alter2_1_1_innodb.test b/mysql-test/suite/parts/t/partition_alter2_1_1_innodb.test index 9500f05b173..37e1cb4a099 100644 --- a/mysql-test/suite/parts/t/partition_alter2_1_1_innodb.test +++ b/mysql-test/suite/parts/t/partition_alter2_1_1_innodb.test @@ -45,6 +45,9 @@ let $only_part_1= 1; # The server must support partitioning. --source include/have_partition.inc +# This test takes long time, so only run it with the --big mtr-flag. +--source include/big_test.inc + #------------------------------------------------------------------------------# # Engine specific settings and requirements diff --git a/mysql-test/suite/parts/t/partition_alter2_1_2_innodb.test b/mysql-test/suite/parts/t/partition_alter2_1_2_innodb.test index 28bbcb3115b..6448a8ac734 100644 --- a/mysql-test/suite/parts/t/partition_alter2_1_2_innodb.test +++ b/mysql-test/suite/parts/t/partition_alter2_1_2_innodb.test @@ -45,6 +45,9 @@ let $only_part_2= 1; # The server must support partitioning. --source include/have_partition.inc +# This test takes long time, so only run it with the --big mtr-flag. +--source include/big_test.inc + #------------------------------------------------------------------------------# # Engine specific settings and requirements diff --git a/mysql-test/suite/parts/t/partition_alter2_2_2_innodb.test b/mysql-test/suite/parts/t/partition_alter2_2_2_innodb.test index a356b4e31a3..e3544c382a3 100644 --- a/mysql-test/suite/parts/t/partition_alter2_2_2_innodb.test +++ b/mysql-test/suite/parts/t/partition_alter2_2_2_innodb.test @@ -45,6 +45,9 @@ let $only_part_2= 1; # The server must support partitioning. --source include/have_partition.inc +# This test takes long time, so only run it with the --big mtr-flag. +--source include/big_test.inc + #------------------------------------------------------------------------------# # Engine specific settings and requirements diff --git a/mysql-test/suite/parts/t/partition_alter4_innodb.test b/mysql-test/suite/parts/t/partition_alter4_innodb.test index 3061e5c9e7f..1e28a2fc812 100644 --- a/mysql-test/suite/parts/t/partition_alter4_innodb.test +++ b/mysql-test/suite/parts/t/partition_alter4_innodb.test @@ -43,6 +43,9 @@ let $more_pk_ui_tests= 0; # The server must support partitioning. --source include/have_partition.inc +# This test takes long time, so only run it with the --big mtr-flag. +--source include/big_test.inc + #------------------------------------------------------------------------------# # Engine specific settings and requirements diff --git a/mysql-test/suite/parts/t/partition_debug_sync_innodb.test b/mysql-test/suite/parts/t/partition_debug_sync_innodb.test index 915a3f2ceb6..fce26132030 100644 --- a/mysql-test/suite/parts/t/partition_debug_sync_innodb.test +++ b/mysql-test/suite/parts/t/partition_debug_sync_innodb.test @@ -56,6 +56,7 @@ partition by range (a) insert into t1 values (1), (11), (21), (33); SELECT * FROM t1; SHOW CREATE TABLE t1; +--replace_result #p# #P# #sp# #SP# --list_files $MYSQLD_DATADIR/test SET DEBUG_SYNC='before_open_in_get_all_tables SIGNAL parked WAIT_FOR open'; @@ -78,6 +79,7 @@ ALTER TABLE t1 REORGANIZE PARTITION p0 INTO disconnect con1; connection default; --reap +--replace_result #p# #P# #sp# #SP# --list_files $MYSQLD_DATADIR/test SHOW CREATE TABLE t1; SELECT * FROM t1; diff --git a/mysql-test/suite/parts/t/partition_recover_myisam.test b/mysql-test/suite/parts/t/partition_recover_myisam.test index d06e1914949..ecc83629768 100644 --- a/mysql-test/suite/parts/t/partition_recover_myisam.test +++ b/mysql-test/suite/parts/t/partition_recover_myisam.test @@ -1,6 +1,6 @@ # test the auto-recover (--myisam-recover) of partitioned myisam tables -call mtr.add_suppression("./test/t1_will_crash"); +call mtr.add_suppression("t1_will_crash"); call mtr.add_suppression("Got an error from unknown thread"); --source include/have_partition.inc diff --git a/mysql-test/suite/parts/t/partition_special_myisam.test b/mysql-test/suite/parts/t/partition_special_myisam.test index 032722cbb7d..2eac5b3bf16 100644 --- a/mysql-test/suite/parts/t/partition_special_myisam.test +++ b/mysql-test/suite/parts/t/partition_special_myisam.test @@ -62,13 +62,14 @@ ALTER TABLE t1 COALESCE PARTITION 2; --connect (con3,localhost,root,,) -perl; -open( LD, ">" . "/tmp/load.in" ) || die "Could not open file for writing " . $ENV{'MYSQLTEST_DATADIR'} . "/test/load.in"; -print LD "1\n2\n3\n"; -close( LD ); +--let $MYSQLD_DATADIR= `SELECT @@datadir` +--write_file $MYSQLD_DATADIR/test/load.in +1 +2 +3 EOF --echo # Connection 3 tries to load into the table: -send LOAD DATA LOCAL INFILE '/tmp/load.in' INTO TABLE t1 (f); +send LOAD DATA INFILE 'load.in' INTO TABLE t1 (f); --connection default --real_sleep 1 From 969cdde8e2be4af36325277141a178fd1c44e4c9 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 11:29:51 +0300 Subject: [PATCH 121/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: buf/buf0flu.c: In function 'buf_flush_delete_from_flush_rbt': buf/buf0flu.c:131:8: error: variable 'ret' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/buf/buf0flu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/storage/innodb_plugin/buf/buf0flu.c b/storage/innodb_plugin/buf/buf0flu.c index d8c0497fa1e..a911fe3ee66 100644 --- a/storage/innodb_plugin/buf/buf0flu.c +++ b/storage/innodb_plugin/buf/buf0flu.c @@ -128,10 +128,15 @@ buf_flush_delete_from_flush_rbt( buf_page_t* bpage) /*!< in: bpage to be removed. */ { +#ifdef UNIV_DEBUG ibool ret = FALSE; +#endif /* UNIV_DEBUG */ ut_ad(buf_pool_mutex_own()); - ret = rbt_delete(buf_pool->flush_rbt, &bpage); +#ifdef UNIV_DEBUG + ret = +#endif /* UNIV_DEBUG */ + rbt_delete(buf_pool->flush_rbt, &bpage); ut_ad(ret); } From c1bd1a8de955a20d2bbeb6e73d5ee5332b17b7f0 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 11:30:57 +0300 Subject: [PATCH 122/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: buf/buf0flu.c: In function 'buf_flush_batch': buf/buf0flu.c:1274:9: error: variable 'old_page_count' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/buf/buf0flu.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/storage/innodb_plugin/buf/buf0flu.c b/storage/innodb_plugin/buf/buf0flu.c index a911fe3ee66..747ce65879d 100644 --- a/storage/innodb_plugin/buf/buf0flu.c +++ b/storage/innodb_plugin/buf/buf0flu.c @@ -1271,7 +1271,6 @@ buf_flush_batch( { buf_page_t* bpage; ulint page_count = 0; - ulint old_page_count; ulint space; ulint offset; @@ -1343,15 +1342,9 @@ flush_next: buf_pool_mutex_exit(); - old_page_count = page_count; - /* Try to flush also all the neighbors */ page_count += buf_flush_try_neighbors( space, offset, flush_type); - /* fprintf(stderr, - "Flush type %lu, page no %lu, neighb %lu\n", - flush_type, offset, - page_count - old_page_count); */ buf_pool_mutex_enter(); goto flush_next; From 18c2f25c17c7f7a843977e0b3673ca0ef9315fe5 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 11:33:49 +0300 Subject: [PATCH 123/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: dict/dict0crea.c: In function 'dict_create_index_tree_step': dict/dict0crea.c:630:16: error: variable 'table' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/dict/dict0crea.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innodb_plugin/dict/dict0crea.c b/storage/innodb_plugin/dict/dict0crea.c index 09353c45c8c..e63f8bc3e6a 100644 --- a/storage/innodb_plugin/dict/dict0crea.c +++ b/storage/innodb_plugin/dict/dict0crea.c @@ -627,7 +627,6 @@ dict_create_index_tree_step( { dict_index_t* index; dict_table_t* sys_indexes; - dict_table_t* table; dtuple_t* search_tuple; ulint zip_size; btr_pcur_t pcur; @@ -636,7 +635,6 @@ dict_create_index_tree_step( ut_ad(mutex_own(&(dict_sys->mutex))); index = node->index; - table = node->table; sys_indexes = dict_sys->sys_indexes; From 6d5065a9f4b6accf51906f5c5e38325dfb4707e8 Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Wed, 15 Sep 2010 18:15:31 +0400 Subject: [PATCH 124/183] Fix for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables". Attempting to issue an INSERT DELAYED statement for a MERGE table might have caused a deadlock if it happened as part of a transaction or under LOCK TABLES, and there was a concurrent DDL or LOCK TABLES ... WRITE statement which tried to lock one of its underlying tables. The problem occurred when a delayed insert handler thread tried to open a MERGE table and discovered that to do this it had also to open all underlying tables and hence acquire metadata locks on them. Since metadata locks on the underlying tables were not pre-acquired by the connection thread executing INSERT DELAYED, attempts to do so might lead to waiting. In this case the connection thread had to wait for the delayed insert thread. If the thread which was preventing the lock on the underlying table from being acquired had to wait for the connection thread (due to this or other metadata locks), a deadlock occurred. This deadlock was not detected by the MDL deadlock detector since waiting for the handler thread by the connection thread is not represented in the wait-for graph. This patch solves the problem by ensuring that the delayed insert handler thread never tries to open underlying tables of a MERGE table. Instead open_tables() is aborted right after the parent table is opened and a ER_DELAYED_NOT_SUPPORTED error is emitted (which is passed to the connection thread and ultimately to the user). --- mysql-test/r/merge.result | 28 ++++++++++++++ mysql-test/t/merge.test | 56 ++++++++++++++++++++++++++++ sql/sql_base.cc | 8 +++- sql/sql_base.h | 13 ++++++- sql/sql_insert.cc | 77 ++++++++++++++++++++++++++++++++++----- 5 files changed, 170 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index 5d96970ce74..0481ee8f49a 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -3575,4 +3575,32 @@ ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'm1 drop view v1; drop temporary table tmp; drop table t1, t2, t3, m1, m2; +# +# Test for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables". +# +drop table if exists t1, t2, tm; +create table t1(a int); +create table t2(a int); +create table tm(a int) engine=merge union=(t1, t2); +begin; +select * from t1; +a +# Connection 'con1'. +# Sending: +alter table t1 comment 'test'; +# Connection 'default'. +# Wait until ALTER TABLE blocks and starts waiting +# for connection 'default'. It should wait with a +# pending SNW lock on 't1'. +# Attempt to perform delayed insert into 'tm' should not lead +# to a deadlock. Instead error ER_DELAYED_NOT_SUPPORTED should +# be emitted. +insert delayed into tm values (1); +ERROR HY000: DELAYED option not supported for table 'tm' +# Unblock ALTER TABLE. +commit; +# Connection 'con1'. +# Reaping ALTER TABLE: +# Connection 'default'. +drop tables tm, t1, t2; End of 6.0 tests diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 1553d7f29c5..3633a8b30ad 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -2,6 +2,9 @@ # Test of MERGE TABLES # +# Save the initial number of concurrent sessions. +--source include/count_sessions.inc + # MERGE tables require MyISAM tables let $default=`select @@global.storage_engine`; set global storage_engine=myisam; @@ -2664,6 +2667,55 @@ drop view v1; drop temporary table tmp; drop table t1, t2, t3, m1, m2; + +--echo # +--echo # Test for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables". +--echo # +connect (con1,localhost,root,,); +connection default; +--disable_warnings +drop table if exists t1, t2, tm; +--enable_warnings +create table t1(a int); +create table t2(a int); +create table tm(a int) engine=merge union=(t1, t2); +begin; +select * from t1; + +--echo # Connection 'con1'. +connection con1; +--echo # Sending: +--send alter table t1 comment 'test' + +--echo # Connection 'default'. +connection default; +--echo # Wait until ALTER TABLE blocks and starts waiting +--echo # for connection 'default'. It should wait with a +--echo # pending SNW lock on 't1'. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table metadata lock" and + info = "alter table t1 comment 'test'"; +--source include/wait_condition.inc +--echo # Attempt to perform delayed insert into 'tm' should not lead +--echo # to a deadlock. Instead error ER_DELAYED_NOT_SUPPORTED should +--echo # be emitted. +--error ER_DELAYED_NOT_SUPPORTED +insert delayed into tm values (1); +--echo # Unblock ALTER TABLE. +commit; + +--echo # Connection 'con1'. +connection con1; +--echo # Reaping ALTER TABLE: +--reap + +--echo # Connection 'default'. +connection default; +disconnect con1; +drop tables tm, t1, t2; + + --echo End of 6.0 tests --disable_result_log @@ -2671,3 +2723,7 @@ drop table t1, t2, t3, m1, m2; eval set global storage_engine=$default; --enable_result_log --enable_query_log + +# Check that all connections opened by test cases in this file are really +# gone so execution of other tests won't be affected by their presence. +--source include/wait_until_count_sessions.inc diff --git a/sql/sql_base.cc b/sql/sql_base.cc index e2eb836a958..8305283cd17 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5165,6 +5165,8 @@ static bool check_lock_and_start_stmt(THD *thd, @param[in] lock_type lock to use for table @param[in] flags options to be used while opening and locking table (see open_table(), mysql_lock_tables()) + @param[in] prelocking_strategy Strategy which specifies how prelocking + algorithm should work for this statement. @return table @retval != NULL OK, opened table returned @@ -5190,7 +5192,8 @@ static bool check_lock_and_start_stmt(THD *thd, */ TABLE *open_n_lock_single_table(THD *thd, TABLE_LIST *table_l, - thr_lock_type lock_type, uint flags) + thr_lock_type lock_type, uint flags, + Prelocking_strategy *prelocking_strategy) { TABLE_LIST *save_next_global; DBUG_ENTER("open_n_lock_single_table"); @@ -5206,7 +5209,8 @@ TABLE *open_n_lock_single_table(THD *thd, TABLE_LIST *table_l, table_l->required_type= FRMTYPE_TABLE; /* Open the table. */ - if (open_and_lock_tables(thd, table_l, FALSE, flags)) + if (open_and_lock_tables(thd, table_l, FALSE, flags, + prelocking_strategy)) table_l->table= NULL; /* Just to be sure. */ /* Restore list. */ diff --git a/sql/sql_base.h b/sql/sql_base.h index b1a730ad277..7ae3971942b 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -246,7 +246,8 @@ bool open_and_lock_tables(THD *thd, TABLE_LIST *tables, int open_and_lock_tables_derived(THD *thd, TABLE_LIST *tables, bool derived); /* simple open_and_lock_tables without derived handling for single table */ TABLE *open_n_lock_single_table(THD *thd, TABLE_LIST *table_l, - thr_lock_type lock_type, uint flags); + thr_lock_type lock_type, uint flags, + Prelocking_strategy *prelocking_strategy); bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags); bool lock_tables(THD *thd, TABLE_LIST *tables, uint counter, uint flags); int decide_logging_format(THD *thd, TABLE_LIST *tables); @@ -455,6 +456,16 @@ open_tables(THD *thd, TABLE_LIST **tables, uint *counter, uint flags) } +inline TABLE *open_n_lock_single_table(THD *thd, TABLE_LIST *table_l, + thr_lock_type lock_type, uint flags) +{ + DML_prelocking_strategy prelocking_strategy; + + return open_n_lock_single_table(thd, table_l, lock_type, flags, + &prelocking_strategy); +} + + /* open_and_lock_tables with derived handling */ inline bool open_and_lock_tables(THD *thd, TABLE_LIST *tables, bool derived, uint flags) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index adbdc1ffbc8..ad324fed4fe 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2495,6 +2495,65 @@ void kill_delayed_threads(void) } +/** + A strategy for the prelocking algorithm which prevents the + delayed insert thread from opening tables with engines which + do not support delayed inserts. + + Particularly it allows to abort open_tables() as soon as we + discover that we have opened a MERGE table, without acquiring + metadata locks on underlying tables. +*/ + +class Delayed_prelocking_strategy : public Prelocking_strategy +{ +public: + virtual bool handle_routine(THD *thd, Query_tables_list *prelocking_ctx, + Sroutine_hash_entry *rt, sp_head *sp, + bool *need_prelocking); + virtual bool handle_table(THD *thd, Query_tables_list *prelocking_ctx, + TABLE_LIST *table_list, bool *need_prelocking); + virtual bool handle_view(THD *thd, Query_tables_list *prelocking_ctx, + TABLE_LIST *table_list, bool *need_prelocking); +}; + + +bool Delayed_prelocking_strategy:: +handle_table(THD *thd, Query_tables_list *prelocking_ctx, + TABLE_LIST *table_list, bool *need_prelocking) +{ + DBUG_ASSERT(table_list->lock_type == TL_WRITE_DELAYED); + + if (!(table_list->table->file->ha_table_flags() & HA_CAN_INSERT_DELAYED)) + { + my_error(ER_DELAYED_NOT_SUPPORTED, MYF(0), table_list->table_name); + return TRUE; + } + return FALSE; +} + + +bool Delayed_prelocking_strategy:: +handle_routine(THD *thd, Query_tables_list *prelocking_ctx, + Sroutine_hash_entry *rt, sp_head *sp, + bool *need_prelocking) +{ + /* LEX used by the delayed insert thread has no routines. */ + DBUG_ASSERT(0); + return FALSE; +} + + +bool Delayed_prelocking_strategy:: +handle_view(THD *thd, Query_tables_list *prelocking_ctx, + TABLE_LIST *table_list, bool *need_prelocking) +{ + /* We don't open views in the delayed insert thread. */ + DBUG_ASSERT(0); + return FALSE; +} + + /** Open and lock table for use by delayed thread and check that this table is suitable for delayed inserts. @@ -2505,21 +2564,21 @@ void kill_delayed_threads(void) bool Delayed_insert::open_and_lock_table() { + Delayed_prelocking_strategy prelocking_strategy; + + /* + Use special prelocking strategy to get ER_DELAYED_NOT_SUPPORTED + error for tables with engines which don't support delayed inserts. + */ if (!(table= open_n_lock_single_table(&thd, &table_list, TL_WRITE_DELAYED, - MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK))) + MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK, + &prelocking_strategy))) { thd.fatal_error(); // Abort waiting inserts return TRUE; } - if (!(table->file->ha_table_flags() & HA_CAN_INSERT_DELAYED)) - { - /* To rollback InnoDB statement transaction. */ - trans_rollback_stmt(&thd); - my_error(ER_DELAYED_NOT_SUPPORTED, MYF(ME_FATALERROR), - table_list.table_name); - return TRUE; - } + if (table->triggers) { /* From d74d42d5690dd7349bd485f5bc6388fa1ecaccb3 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 18:00:49 +0300 Subject: [PATCH 125/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: dict/dict0dict.c: In function 'dict_index_print_low': dict/dict0dict.c:4444:14: error: variable 'type_string' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/dict/dict0dict.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/dict0dict.c index 560534345f9..a3575c283cd 100644 --- a/storage/innodb_plugin/dict/dict0dict.c +++ b/storage/innodb_plugin/dict/dict0dict.c @@ -4441,7 +4441,6 @@ dict_index_print_low( { ib_int64_t n_vals; ulint i; - const char* type_string; ut_ad(mutex_own(&(dict_sys->mutex))); @@ -4456,14 +4455,6 @@ dict_index_print_low( dict_index_stat_mutex_exit(index); - if (dict_index_is_clust(index)) { - type_string = "clustered index"; - } else if (dict_index_is_unique(index)) { - type_string = "unique index"; - } else { - type_string = "secondary index"; - } - fprintf(stderr, " INDEX: name %s, id %lu %lu, fields %lu/%lu," " uniq %lu, type %lu\n" From 4a78171bf4b9d32f5744c1f0b77f5c6fba8effc8 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 18:02:26 +0300 Subject: [PATCH 126/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: eval/eval0eval.c: In function 'eval_notfound': eval/eval0eval.c:388:14: error: variable 'arg2' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/eval/eval0eval.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innodb_plugin/eval/eval0eval.c b/storage/innodb_plugin/eval/eval0eval.c index 589b0fa1576..2aad7951535 100644 --- a/storage/innodb_plugin/eval/eval0eval.c +++ b/storage/innodb_plugin/eval/eval0eval.c @@ -385,13 +385,11 @@ eval_notfound( func_node_t* func_node) /*!< in: function node */ { que_node_t* arg1; - que_node_t* arg2; sym_node_t* cursor; sel_node_t* sel_node; ibool ibool_val; arg1 = func_node->args; - arg2 = que_node_get_next(arg1); ut_ad(func_node->func == PARS_NOTFOUND_TOKEN); From 2f773fccc09a6bf844bf82ad76d69fa7ab90b338 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 18:03:24 +0300 Subject: [PATCH 127/183] Remove redundant variable --- storage/innodb_plugin/eval/eval0eval.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/storage/innodb_plugin/eval/eval0eval.c b/storage/innodb_plugin/eval/eval0eval.c index 2aad7951535..dcd416adeee 100644 --- a/storage/innodb_plugin/eval/eval0eval.c +++ b/storage/innodb_plugin/eval/eval0eval.c @@ -384,16 +384,13 @@ eval_notfound( /*==========*/ func_node_t* func_node) /*!< in: function node */ { - que_node_t* arg1; sym_node_t* cursor; sel_node_t* sel_node; ibool ibool_val; - arg1 = func_node->args; - ut_ad(func_node->func == PARS_NOTFOUND_TOKEN); - cursor = arg1; + cursor = func_node->args; ut_ad(que_node_get_type(cursor) == QUE_NODE_SYMBOL); From 8ea70a6f1a20ab9a1c8bbc179c214c448a031000 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 18:06:46 +0300 Subject: [PATCH 128/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: handler/ha_innodb.cc: In function 'bool innodb_show_status(handlerton*, THD*, bool (*)(THD*, const char*, uint, const char*, uint, const char*, uint))': handler/ha_innodb.cc:8851:7: error: variable 'result' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/handler/ha_innodb.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc index c7474109d4f..485c706d7c1 100644 --- a/storage/innodb_plugin/handler/ha_innodb.cc +++ b/storage/innodb_plugin/handler/ha_innodb.cc @@ -8848,12 +8848,9 @@ innodb_show_status( mutex_exit(&srv_monitor_file_mutex); - bool result = FALSE; + stat_print(thd, innobase_hton_name, (uint) strlen(innobase_hton_name), + STRING_WITH_LEN(""), str, flen); - if (stat_print(thd, innobase_hton_name, (uint) strlen(innobase_hton_name), - STRING_WITH_LEN(""), str, flen)) { - result= TRUE; - } my_free(str, MYF(0)); DBUG_RETURN(FALSE); From 3afaeb8895af4a150abf6454721038101b129116 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 18:10:10 +0300 Subject: [PATCH 129/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: handler/ha_innodb.cc: In function 'void innobase_drop_database(handlerton*, char*)': handler/ha_innodb.cc:7010:6: error: variable 'error' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/handler/ha_innodb.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc index 485c706d7c1..a7635a402a6 100644 --- a/storage/innodb_plugin/handler/ha_innodb.cc +++ b/storage/innodb_plugin/handler/ha_innodb.cc @@ -7007,7 +7007,6 @@ innobase_drop_database( ulint len = 0; trx_t* trx; char* ptr; - int error; char* namebuf; THD* thd = current_thd; @@ -7050,7 +7049,7 @@ innobase_drop_database( #else trx = innobase_trx_allocate(thd); #endif - error = row_drop_database_for_mysql(namebuf, trx); + row_drop_database_for_mysql(namebuf, trx); my_free(namebuf, MYF(0)); /* Flush the log to reduce probability that the .frm files and From ceb87e20d9a3e583956132c2c1c3d06f6ee7761c Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 18:25:24 +0300 Subject: [PATCH 130/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: handler/i_s.cc: In function 'int trx_i_s_common_fill_table(THD*, TABLE_LIST*, COND*)': handler/i_s.cc:931:8: error: variable 'ret' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/handler/i_s.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/innodb_plugin/handler/i_s.cc b/storage/innodb_plugin/handler/i_s.cc index 524fe696de2..1ac79860351 100644 --- a/storage/innodb_plugin/handler/i_s.cc +++ b/storage/innodb_plugin/handler/i_s.cc @@ -1013,6 +1013,7 @@ trx_i_s_common_fill_table( see http://bugs.mysql.com/29900 ; when that bug is resolved we can enable the DBUG_RETURN(ret) above */ DBUG_RETURN(0); + ret++; // silence a gcc46 warning #endif } From 34ccdc3ac94ca01cc90ec0be6a8baa6b6cb87dc7 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 18:31:16 +0300 Subject: [PATCH 131/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: log/log0recv.c: In function 'recv_recovery_from_checkpoint_start_func': log/log0recv.c:2894:14: error: variable 'archived_lsn' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/log/log0recv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storage/innodb_plugin/log/log0recv.c b/storage/innodb_plugin/log/log0recv.c index a727d6be768..9e31eb1b4e0 100644 --- a/storage/innodb_plugin/log/log0recv.c +++ b/storage/innodb_plugin/log/log0recv.c @@ -2891,7 +2891,9 @@ recv_recovery_from_checkpoint_start_func( ib_uint64_t old_scanned_lsn; ib_uint64_t group_scanned_lsn; ib_uint64_t contiguous_lsn; +#ifdef UNIV_LOG_ARCHIVE ib_uint64_t archived_lsn; +#endif /* UNIV_LOG_ARCHIVE */ byte* buf; byte log_hdr_buf[LOG_FILE_HDR_SIZE]; ulint err; @@ -2946,7 +2948,9 @@ recv_recovery_from_checkpoint_start_func( checkpoint_lsn = mach_read_ull(buf + LOG_CHECKPOINT_LSN); checkpoint_no = mach_read_ull(buf + LOG_CHECKPOINT_NO); +#ifdef UNIV_LOG_ARCHIVE archived_lsn = mach_read_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN); +#endif /* UNIV_LOG_ARCHIVE */ /* Read the first log file header to print a note if this is a recovery from a restored InnoDB Hot Backup */ From c137d1e5323164816f7d1eac288973e4ea2ace14 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 18:32:12 +0300 Subject: [PATCH 132/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: log/log0recv.c: In function 'recv_synchronize_groups': log/log0recv.c:562:14: error: variable 'limit_lsn' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/log/log0recv.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innodb_plugin/log/log0recv.c b/storage/innodb_plugin/log/log0recv.c index 9e31eb1b4e0..c1d12dad413 100644 --- a/storage/innodb_plugin/log/log0recv.c +++ b/storage/innodb_plugin/log/log0recv.c @@ -559,10 +559,8 @@ recv_synchronize_groups( ib_uint64_t start_lsn; ib_uint64_t end_lsn; ib_uint64_t recovered_lsn; - ib_uint64_t limit_lsn; recovered_lsn = recv_sys->recovered_lsn; - limit_lsn = recv_sys->limit_lsn; /* Read the last recovered log block to the recovery system buffer: the block is always incomplete */ From cd4075ffda6224af9a8d63be13a785bf5b82c806 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 18:35:11 +0300 Subject: [PATCH 133/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warnings: os/os0file.c: In function 'os_file_create': os/os0file.c:1371:14: error: variable 'purpose_str' set but not used [-Werror=unused-but-set-variable] os/os0file.c:1370:14: error: variable 'type_str' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/os/os0file.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/storage/innodb_plugin/os/os0file.c b/storage/innodb_plugin/os/os0file.c index 9f937b9def2..6a0d6ea5363 100644 --- a/storage/innodb_plugin/os/os0file.c +++ b/storage/innodb_plugin/os/os0file.c @@ -1367,8 +1367,6 @@ try_again: int create_flag; ibool retry; const char* mode_str = NULL; - const char* type_str = NULL; - const char* purpose_str = NULL; try_again: ut_a(name); @@ -1388,26 +1386,9 @@ try_again: ut_error; } - if (type == OS_LOG_FILE) { - type_str = "LOG"; - } else if (type == OS_DATA_FILE) { - type_str = "DATA"; - } else { - ut_error; - } + ut_a(type == OS_LOG_FILE || type == OS_DATA_FILE); + ut_a(purpose == OS_FILE_AIO || purpose == OS_FILE_NORMAL); - if (purpose == OS_FILE_AIO) { - purpose_str = "AIO"; - } else if (purpose == OS_FILE_NORMAL) { - purpose_str = "NORMAL"; - } else { - ut_error; - } - -#if 0 - fprintf(stderr, "Opening file %s, mode %s, type %s, purpose %s\n", - name, mode_str, type_str, purpose_str); -#endif #ifdef O_SYNC /* We let O_SYNC only affect log files; note that we map O_DSYNC to O_SYNC because the datasync options seemed to corrupt files in 2001 From aafc9dc143fe9151ffb2c939a99e58f2b2ca07bd Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 18:35:59 +0300 Subject: [PATCH 134/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: que/que0que.c: In function 'que_run_threads_low': que/que0que.c:1287:9: error: variable 'cumul_resource' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/que/que0que.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/storage/innodb_plugin/que/que0que.c b/storage/innodb_plugin/que/que0que.c index 2fe046fa9b8..b616b3d9c14 100644 --- a/storage/innodb_plugin/que/que0que.c +++ b/storage/innodb_plugin/que/que0que.c @@ -1284,18 +1284,13 @@ que_run_threads_low( que_thr_t* thr) /*!< in: query thread */ { que_thr_t* next_thr; - ulint cumul_resource; ulint loop_count; ut_ad(thr->state == QUE_THR_RUNNING); ut_a(thr_get_trx(thr)->error_state == DB_SUCCESS); ut_ad(!mutex_own(&kernel_mutex)); - /* cumul_resource counts how much resources the OS thread (NOT the - query thread) has spent in this function */ - loop_count = QUE_MAX_LOOPS_WITHOUT_CHECK; - cumul_resource = 0; loop: /* Check that there is enough space in the log to accommodate possible log entries by this query step; if the operation can touch From d54a4948ceae547d3942622f3b3f813f76a86a1b Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 18:37:24 +0300 Subject: [PATCH 135/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: row/row0purge.c: In function 'row_purge_step': row/row0purge.c:687:9: error: variable 'err' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/row/row0purge.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/storage/innodb_plugin/row/row0purge.c b/storage/innodb_plugin/row/row0purge.c index 835af990672..31b255cf2d4 100644 --- a/storage/innodb_plugin/row/row0purge.c +++ b/storage/innodb_plugin/row/row0purge.c @@ -684,7 +684,9 @@ row_purge_step( que_thr_t* thr) /*!< in: query thread */ { purge_node_t* node; +#ifdef UNIV_DEBUG ulint err; +#endif /* UNIV_DEBUG */ ut_ad(thr); @@ -692,7 +694,10 @@ row_purge_step( ut_ad(que_node_get_type(node) == QUE_NODE_PURGE); - err = row_purge(node, thr); +#ifdef UNIV_DEBUG + err = +#endif /* UNIV_DEBUG */ + row_purge(node, thr); ut_ad(err == DB_SUCCESS); From 3ca8b186f1efd082c33b2a4136485724aa70842c Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 18:41:35 +0300 Subject: [PATCH 136/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: row/row0umod.c: In function 'row_undo_mod_clust_low': row/row0umod.c:117:9: error: variable 'success' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/row/row0umod.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/storage/innodb_plugin/row/row0umod.c b/storage/innodb_plugin/row/row0umod.c index 8464b0f95cc..5998dadd16d 100644 --- a/storage/innodb_plugin/row/row0umod.c +++ b/storage/innodb_plugin/row/row0umod.c @@ -114,12 +114,17 @@ row_undo_mod_clust_low( btr_pcur_t* pcur; btr_cur_t* btr_cur; ulint err; +#ifdef UNIV_DEBUG ibool success; +#endif /* UNIV_DEBUG */ pcur = &(node->pcur); btr_cur = btr_pcur_get_btr_cur(pcur); - success = btr_pcur_restore_position(mode, pcur, mtr); +#ifdef UNIV_DEBUG + success = +#endif /* UNIV_DEBUG */ + btr_pcur_restore_position(mode, pcur, mtr); ut_ad(success); From 66b9f11a38edb8aebfdfd8b9afbbd48ed9a84d33 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 18:43:07 +0300 Subject: [PATCH 137/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: row/row0vers.c: In function 'row_vers_impl_x_locked_off_kernel': row/row0vers.c:74:9: error: variable 'err' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/row/row0vers.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/storage/innodb_plugin/row/row0vers.c b/storage/innodb_plugin/row/row0vers.c index a4fbb5289aa..b6d35363f08 100644 --- a/storage/innodb_plugin/row/row0vers.c +++ b/storage/innodb_plugin/row/row0vers.c @@ -71,7 +71,9 @@ row_vers_impl_x_locked_off_kernel( warning */ trx_t* trx; ulint rec_del; +#ifdef UNIV_DEBUG ulint err; +#endif /* UNIV_DEBUG */ mtr_t mtr; ulint comp; @@ -169,9 +171,12 @@ row_vers_impl_x_locked_off_kernel( heap2 = heap; heap = mem_heap_create(1024); - err = trx_undo_prev_version_build(clust_rec, &mtr, version, - clust_index, clust_offsets, - heap, &prev_version); +#ifdef UNIV_DEBUG + err = +#endif /* UNIV_DEBUG */ + trx_undo_prev_version_build(clust_rec, &mtr, version, + clust_index, clust_offsets, + heap, &prev_version); mem_heap_free(heap2); /* free version and clust_offsets */ if (prev_version == NULL) { From 3cd051e8212c7c786bc973a308c66c8a8a7861ce Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 18:44:55 +0300 Subject: [PATCH 138/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: trx/trx0purge.c: In function 'trx_purge_add_update_undo_to_history': trx/trx0purge.c:309:16: error: variable 'page_header' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/trx/trx0purge.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innodb_plugin/trx/trx0purge.c b/storage/innodb_plugin/trx/trx0purge.c index abbfa3d7f81..09c9755c74c 100644 --- a/storage/innodb_plugin/trx/trx0purge.c +++ b/storage/innodb_plugin/trx/trx0purge.c @@ -306,7 +306,6 @@ trx_purge_add_update_undo_to_history( trx_rsegf_t* rseg_header; trx_usegf_t* seg_header; trx_ulogf_t* undo_header; - trx_upagef_t* page_header; ulint hist_size; undo = trx->update_undo; @@ -322,7 +321,6 @@ trx_purge_add_update_undo_to_history( undo_header = undo_page + undo->hdr_offset; seg_header = undo_page + TRX_UNDO_SEG_HDR; - page_header = undo_page + TRX_UNDO_PAGE_HDR; if (undo->state != TRX_UNDO_CACHED) { /* The undo log segment will not be reused */ From 71630f36387af58f3bcbb8930985a629a870059e Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 18:45:57 +0300 Subject: [PATCH 139/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: trx/trx0purge.c: In function 'trx_purge_add_update_undo_to_history': trx/trx0purge.c:307:15: error: variable 'seg_header' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/trx/trx0purge.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storage/innodb_plugin/trx/trx0purge.c b/storage/innodb_plugin/trx/trx0purge.c index 09c9755c74c..43dd051c2ee 100644 --- a/storage/innodb_plugin/trx/trx0purge.c +++ b/storage/innodb_plugin/trx/trx0purge.c @@ -304,7 +304,9 @@ trx_purge_add_update_undo_to_history( trx_undo_t* undo; trx_rseg_t* rseg; trx_rsegf_t* rseg_header; +#ifdef UNIV_DEBUG trx_usegf_t* seg_header; +#endif /* UNIV_DEBUG */ trx_ulogf_t* undo_header; ulint hist_size; @@ -320,7 +322,9 @@ trx_purge_add_update_undo_to_history( rseg->page_no, mtr); undo_header = undo_page + undo->hdr_offset; +#ifdef UNIV_DEBUG seg_header = undo_page + TRX_UNDO_SEG_HDR; +#endif /* UNIV_DEBUG */ if (undo->state != TRX_UNDO_CACHED) { /* The undo log segment will not be reused */ From 0c43681b43947c71fa083cdc2ef72bd389b9cf1c Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 18:47:14 +0300 Subject: [PATCH 140/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: trx/trx0purge.c: In function 'trx_purge_rseg_get_next_history_log': trx/trx0purge.c:660:15: error: variable 'seg_hdr' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/trx/trx0purge.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innodb_plugin/trx/trx0purge.c b/storage/innodb_plugin/trx/trx0purge.c index 43dd051c2ee..38966cb5db5 100644 --- a/storage/innodb_plugin/trx/trx0purge.c +++ b/storage/innodb_plugin/trx/trx0purge.c @@ -657,7 +657,6 @@ trx_purge_rseg_get_next_history_log( { page_t* undo_page; trx_ulogf_t* log_hdr; - trx_usegf_t* seg_hdr; fil_addr_t prev_log_addr; trx_id_t trx_no; ibool del_marks; @@ -678,7 +677,6 @@ trx_purge_rseg_get_next_history_log( undo_page = trx_undo_page_get_s_latched(rseg->space, rseg->zip_size, rseg->last_page_no, &mtr); log_hdr = undo_page + rseg->last_offset; - seg_hdr = undo_page + TRX_UNDO_SEG_HDR; /* Increase the purge page count by one for every handled log */ From a0492a44255db33288c95678ce37243694114818 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 19:05:35 +0300 Subject: [PATCH 141/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: trx/trx0purge.c: In function 'trx_purge_rec_release': trx/trx0purge.c:1071:18: error: variable 'arr' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/trx/trx0purge.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/storage/innodb_plugin/trx/trx0purge.c b/storage/innodb_plugin/trx/trx0purge.c index 38966cb5db5..1a70750083a 100644 --- a/storage/innodb_plugin/trx/trx0purge.c +++ b/storage/innodb_plugin/trx/trx0purge.c @@ -1068,12 +1068,8 @@ trx_purge_rec_release( /*==================*/ trx_undo_inf_t* cell) /*!< in: storage cell */ { - trx_undo_arr_t* arr; - mutex_enter(&(purge_sys->mutex)); - arr = purge_sys->arr; - trx_purge_arr_remove_info(cell); mutex_exit(&(purge_sys->mutex)); From 2aa70d99c6fa226a612269119d21a84cdd6de003 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 19:06:31 +0300 Subject: [PATCH 142/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warnings: trx/trx0roll.c: In function 'trx_undo_arr_remove_info': trx/trx0roll.c:744:9: error: variable 'n' set but not used [-Werror=unused-but-set-variable] trx/trx0roll.c:743:9: error: variable 'n_used' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/trx/trx0roll.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/storage/innodb_plugin/trx/trx0roll.c b/storage/innodb_plugin/trx/trx0roll.c index c925478cdf4..1a43e419214 100644 --- a/storage/innodb_plugin/trx/trx0roll.c +++ b/storage/innodb_plugin/trx/trx0roll.c @@ -740,13 +740,8 @@ trx_undo_arr_remove_info( undo_no_t undo_no)/*!< in: undo number */ { trx_undo_inf_t* cell; - ulint n_used; - ulint n; ulint i; - n_used = arr->n_used; - n = 0; - for (i = 0;; i++) { cell = trx_undo_arr_get_nth_info(arr, i); From 7fafd6408da7b6d6335e3291d9f06ad543b77e89 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 19:47:35 +0300 Subject: [PATCH 143/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: trx/trx0sys.c: In function 'trx_sys_create_doublewrite_buf': trx/trx0sys.c:244:15: error: variable 'new_block' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/trx/trx0sys.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/storage/innodb_plugin/trx/trx0sys.c b/storage/innodb_plugin/trx/trx0sys.c index 410c55f132d..d20f436b71b 100644 --- a/storage/innodb_plugin/trx/trx0sys.c +++ b/storage/innodb_plugin/trx/trx0sys.c @@ -241,7 +241,9 @@ trx_sys_create_doublewrite_buf(void) { buf_block_t* block; buf_block_t* block2; +#ifdef UNIV_DEBUG buf_block_t* new_block; +#endif /* UNIV_DEBUG */ byte* doublewrite; byte* fseg_header; ulint page_no; @@ -344,8 +346,11 @@ start_again: the page position in the tablespace, then the page has not been written to in doublewrite. */ - new_block = buf_page_get(TRX_SYS_SPACE, 0, page_no, - RW_X_LATCH, &mtr); +#ifdef UNIV_DEBUG + new_block = +#endif /* UNIV_DEBUG */ + buf_page_get(TRX_SYS_SPACE, 0, page_no, + RW_X_LATCH, &mtr); buf_block_dbg_add_level(new_block, SYNC_NO_ORDER_CHECK); From b13a9c99a2b60b3e69dc3618867353a68ecb034d Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 19:48:37 +0300 Subject: [PATCH 144/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: trx/trx0trx.c: In function 'trx_prepare_off_kernel': trx/trx0trx.c:1808:11: error: variable 'update_hdr_page' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/trx/trx0trx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/innodb_plugin/trx/trx0trx.c b/storage/innodb_plugin/trx/trx0trx.c index 9722bb59a5e..ee744fd58b1 100644 --- a/storage/innodb_plugin/trx/trx0trx.c +++ b/storage/innodb_plugin/trx/trx0trx.c @@ -1805,7 +1805,6 @@ trx_prepare_off_kernel( /*===================*/ trx_t* trx) /*!< in: transaction */ { - page_t* update_hdr_page; trx_rseg_t* rseg; ib_uint64_t lsn = 0; mtr_t mtr; @@ -1838,7 +1837,7 @@ trx_prepare_off_kernel( } if (trx->update_undo) { - update_hdr_page = trx_undo_set_state_at_prepare( + trx_undo_set_state_at_prepare( trx, trx->update_undo, &mtr); } From c97283c20719b6796e95ba8bd3679913f5856f07 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 19:49:25 +0300 Subject: [PATCH 145/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: trx/trx0undo.c: In function 'trx_undo_set_state_at_prepare': trx/trx0undo.c:1871:16: error: variable 'page_hdr' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/trx/trx0undo.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innodb_plugin/trx/trx0undo.c b/storage/innodb_plugin/trx/trx0undo.c index eb5112c4d31..32f51b79a74 100644 --- a/storage/innodb_plugin/trx/trx0undo.c +++ b/storage/innodb_plugin/trx/trx0undo.c @@ -1868,7 +1868,6 @@ trx_undo_set_state_at_prepare( mtr_t* mtr) /*!< in: mtr */ { trx_usegf_t* seg_hdr; - trx_upagef_t* page_hdr; trx_ulogf_t* undo_header; page_t* undo_page; ulint offset; @@ -1886,7 +1885,6 @@ trx_undo_set_state_at_prepare( undo->hdr_page_no, mtr); seg_hdr = undo_page + TRX_UNDO_SEG_HDR; - page_hdr = undo_page + TRX_UNDO_PAGE_HDR; /*------------------------------*/ undo->state = TRX_UNDO_PREPARED; From e00e1aba61df5eb20c78c6d99d56cd2bc1fbf5a1 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 19:50:05 +0300 Subject: [PATCH 146/183] (partially) Fix Bug#55227 Fix compiler warnings in innodb with gcc 4.6 Fix compiler warning: trx/trx0undo.c: In function 'trx_undo_truncate_end': trx/trx0undo.c:1069:14: error: variable 'rseg' set but not used [-Werror=unused-but-set-variable] --- storage/innodb_plugin/trx/trx0undo.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/storage/innodb_plugin/trx/trx0undo.c b/storage/innodb_plugin/trx/trx0undo.c index 32f51b79a74..c8a4b15e48b 100644 --- a/storage/innodb_plugin/trx/trx0undo.c +++ b/storage/innodb_plugin/trx/trx0undo.c @@ -1066,14 +1066,11 @@ trx_undo_truncate_end( ulint last_page_no; trx_undo_rec_t* rec; trx_undo_rec_t* trunc_here; - trx_rseg_t* rseg; mtr_t mtr; ut_ad(mutex_own(&(trx->undo_mutex))); ut_ad(mutex_own(&(trx->rseg->mutex))); - rseg = trx->rseg; - for (;;) { mtr_start(&mtr); From d972a31ea89ff98d80105692f0331611112413a7 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 15 Sep 2010 19:58:36 +0300 Subject: [PATCH 147/183] Fix typo, should be UNIV_SYNC_DEBUG. --- storage/innodb_plugin/trx/trx0sys.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/storage/innodb_plugin/trx/trx0sys.c b/storage/innodb_plugin/trx/trx0sys.c index d20f436b71b..6eb356947cc 100644 --- a/storage/innodb_plugin/trx/trx0sys.c +++ b/storage/innodb_plugin/trx/trx0sys.c @@ -241,9 +241,9 @@ trx_sys_create_doublewrite_buf(void) { buf_block_t* block; buf_block_t* block2; -#ifdef UNIV_DEBUG +#ifdef UNIV_SYNC_DEBUG buf_block_t* new_block; -#endif /* UNIV_DEBUG */ +#endif /* UNIV_SYNC_DEBUG */ byte* doublewrite; byte* fseg_header; ulint page_no; @@ -346,9 +346,9 @@ start_again: the page position in the tablespace, then the page has not been written to in doublewrite. */ -#ifdef UNIV_DEBUG +#ifdef UNIV_SYNC_DEBUG new_block = -#endif /* UNIV_DEBUG */ +#endif /* UNIV_SYNC_DEBUG */ buf_page_get(TRX_SYS_SPACE, 0, page_no, RW_X_LATCH, &mtr); buf_block_dbg_add_level(new_block, From f601c035c51cfd467faf681925ee5d0178384100 Mon Sep 17 00:00:00 2001 From: Mikael Ronstrom Date: Thu, 16 Sep 2010 08:53:58 +0200 Subject: [PATCH 148/183] Updated build_mccge.sh and added support for more cpu's in check-cpu --- BUILD/build_mccge.sh | 633 ++++++++++++++++++++++++++++++++----------- BUILD/check-cpu | 58 +++- 2 files changed, 523 insertions(+), 168 deletions(-) diff --git a/BUILD/build_mccge.sh b/BUILD/build_mccge.sh index eb37323c570..e5e0d5da01b 100755 --- a/BUILD/build_mccge.sh +++ b/BUILD/build_mccge.sh @@ -63,41 +63,50 @@ sysadmin_usage() cat < ./build_mccge.sh + shell> BUILD/build_mccge.sh This performs the following operations: 1) Detects the operating system. Currently, Linux, FreeBSD, Solaris - 10/11, and Mac OS X are supported by this script. + 8/9/10/11, and Mac OS X are supported by this script. 2) Detect the type of CPU being used. Currently supported processors are: x86 for all supported operating systems, Itanium for Linux - with GCC, and SPARC for Solaris using the Forte compiler. + with GCC, and x86 + SPARC for Solaris using the Forte compiler and + finally x86 on Linux using the Intel compiler. 3) Invokes the GCC compiler. - 4) Builds a set of MySQL Cluster Carrier Grade Edition binaries; for + 4) Builds a set of MySQL/MySQL Cluster binaries; for more information about these, see --extended-help. + 5) Default compiler is always gcc. The default version assumes that you have a source code tarball from which you are building, and thus autoconf and automake do not need to be run. If you have downloaded a BitKeeper tree then you should read --developer-help. - If you are building MySQL Cluster Carrier Grade Edition for commercial + If you are building MySQL/MySQL Cluster for commercial use then you need to set the --commercial flag to ensure that the commercial libraries are compiled in, rather than the GPL-only libraries. The default is to build a GPL version of MySQL Cluster Carrier Grade Edition. - If your building on a Solaris SPARC machine you must set + If your building on a Solaris SPARC machine and you want to compile + using SunStudio you must set --compiler=forte; if you want to build using the Intel compiler on Linux, you need to set --compiler=icc. + A synonym for forte is SunStudio, so one can also use + --compiler=SunStudio. + If you want to make sure that a 64-bit version is built then you should add the flag --64. This is always set on Solaris machines and when check-cpu is able to discover that a 64-bit CPU is being used. If @@ -120,7 +129,7 @@ cat < 32-bit binary - x86_64 => 64 bit binary unless Mac OS X + --compiler=[gcc|icc|forte|SunStudio] Select compiler + --cpu=[x86|x86_64|sparc|itanium] Select CPU type + x86 => x86 and 32-bit binary + x86_64 => x86 and 64 bit binary --warning-mode=[extra|pedantic|normal|no] Set warning mode level --warnings Set warning mode to normal --32 Build a 32-bit binary even if CPU is 64-bit @@ -170,8 +186,9 @@ Usage: $0 [options] --error-inject Enable error injection into MySQL Server and data nodes --valgrind Build with valgrind - --fast Optimise for CPU architecture buildt on + --fast Optimise for CPU architecture built on --static-linking Statically link system libraries into binaries + --use-tcmalloc Link with tcmalloc instead of standard malloc (Linux only) --with-flags * Pass extra --with-xxx options to configure EOF if test "x$1" != "x" ; then @@ -186,13 +203,14 @@ extended_usage() Extended help text for this script: ----------------------------------- This script is intended to make it easier for customers using MySQL - Cluster Carrier Grade Edition to build the product from source on - these platforms/compilers: Linux/x86 (32-bit and 64-bit), - Solaris 10 and 11/x86/gcc, Solaris 9/Sparc/Forte, and MacOSX/x86/gcc. - The script automatically detects CPU type and operating system; in - most cases this also determines which compiler to use, the exception - being Linux/x86 where you can choose between gcc and icc (gcc is the - default). + Cluster Carrier Grade Edition, customers using performance-optimised + MySQL versions and developers to build the product from source on + these platforms/compilers: Linux/x86 (32-bit and 64-bit) (either using + gcc or icc), Linux Itanium, Solaris 8,9,10 and 11 x86 and SPARC using + gcc or SunStudio and MacOSX/x86/gcc. + + The script automatically detects CPU type and operating system; The + default compiler is always gcc. To build on other platforms you can use the --print-only option on a supported platform and edit the output for a proper set of commands on @@ -213,7 +231,7 @@ extended_usage() --package=cge storage engines: - ARCHIVE, BLACKHOLE, CSV, EXAMPLE, FEDERATED, MYISAM, NDB + ARCHIVE, BLACKHOLE, CSV, FEDERATED, MYISAM, NDB (All storage engines except InnoDB) comment: MySQL Cluster Carrier Grade Edition GPL/Commercial version built from source @@ -221,7 +239,7 @@ extended_usage() --package=extended storage engines: - ARCHIVE, BLACKHOLE, CSV, EXAMPLE, FEDERATED, MYISAM, INNODB, NDB + ARCHIVE, BLACKHOLE, CSV, FEDERATED, MYISAM, INNODB, NDB (All storage engines) comment: MySQL Cluster Carrier Grade Extended Edition GPL/Commercial version built from source @@ -229,7 +247,7 @@ extended_usage() --package=pro storage engines: - ARCHIVE, BLACKHOLE, CSV, EXAMPLE, FEDERATED, INNODB, MYISAM + ARCHIVE, BLACKHOLE, CSV, FEDERATED, INNODB, MYISAM (All storage engines except NDB) comment: MySQL Pro GPL/Commercial version built from source @@ -291,11 +309,16 @@ extended_usage() by MySQL (cannot be overridden). --with-ssl: Enable use of yaSSL library included in the MySQL source + if possible (GCC and same CC and CXX). (cannot be overridden). --with-pic: Build all binaries using position independent assembler to avoid problems with dynamic linkers (cannot be overridden). + --without-example-engine: Ensure that the example engine isn't built, + it cannot do any useful things, it's merely intended as documentation. + (cannot be overridden) + --with-csv-storage-engine: Ensure that the CSV storage engine is included in all builds. Since CSV is required for log tables in MySQL 5.1, this option cannot be overridden. @@ -314,10 +337,6 @@ extended_usage() In addition there are some configure options that are specific to Linux operating systems: - --with-fast-mutexes - Include an alternative implementation of mutexes that is faster on - Linux systems - --enable-assembler Include assembler code optimisations for a number of mostly string methods. Used for x86 processors only. @@ -364,17 +383,24 @@ extended_usage() --with-mysqld-libs=-lmtmalloc Used on Solaris to ensure that the proper malloc library is used. + Investigations have shown mtmalloc to be the best choice on Solaris, + also umem has good performance on Solaris but better debugging + capabilities. Compiler options: ----------------- - This section describes the compiler options for each of the different - platforms supported by thisscript. + This section describes the compiler options for each of the different + platforms supported by this script. - The --fast option adds -mtune=cpu_arg to the C/C++ flags (provides - support for Nocona, K8, and other processors). + The --fast option adds -mtune=cpu_arg to the C/C++ flags (provides + support for Nocona, K8, and other processors). - Use of the --debug option adds -g to the C/C++ flags. + Use of the --debug option adds -g to the C/C++ flags. + + In all cases it is possible to override the definition of CC and CXX + by calling the script as follows: + CC="/usr/local/bin/gcc" CXX="/usr/local/bin/gcc" BUILD/build_mccge.sh FreeBSD/x86/gcc --------------- @@ -383,8 +409,7 @@ extended_usage() Linux/x86+Itanium/gcc ------------- - No flags are used. Instead the configure script determines the - proper flags to use for both normal and debug builds. Discovery of a + For debug builds -O is used and otherwise -O3 is used.Discovery of a Nocona or Core 2 Duo CPU causes a 64-bit binary to be built; otherwise, the binary is 32-bit. To build a 64-bit binary, -m64 is added to the C/C++ flags. (To build a 32-bit binary on a 64-bit CPU, @@ -393,48 +418,105 @@ extended_usage() Linux/x86+Itanium/icc ------------- Flags used: - CC = icc -static-libgcc -static-libcxa -i-static - C++ = icpc -static-libgcc -static-libcxa -i-static + CC = icc -static-libgcc -static-intel + C++ = icpc -static-libgcc -static-intel C/C++ flags = -mp -restrict - On Itanium we also add -no-ftz and -no-prefetch to CC and C++ flags. + On Itanium we also add -no-ftz and to CC and C++ flags. - The non-debug versions also add the following: - C/C++ flags += -O3 unroll2 -ip + Note that if the user of this script sets CC or CXX explicitly then + also -static-libgcc and -static-intel needs to be set in the CC and + CXX. - The fast version adds: - C/C++ flags += -ipo + The non-debug versions also add the following: + C/C++ flags += -O3 unroll2 -ip - On discovery of a Core 2 Duo architecture while using icc, -xT is also - added to the C/C++ flags; this provides optimisations specific to Core - 2 Duo. This is added only when the --fast flag is set. + The fast version adds (if --with-link-time-optimizer is used): + C/C++ flags += -ipo + + On discovery of a Core 2 Duo architecture while using icc, -xT is also + added to the C/C++ flags; this provides optimisations specific to Core + 2 Duo. This is added only when the --fast flag is set. Solaris/x86/gcc --------------- - All builds on Solaris are 64-bit, so -m64 is always used in the - C/C++ flags. LDFLAGS is set to -m64 -static-libgcc -O/-O2. + All builds on Solaris are by default 64-bit, so -m64 is always used in + the C/C++ flags. LDFLAGS is set to -m64 -O/-O2/-O3. If for + some reason a 32-bit Solaris is used it is necessary to add the flag + --32 to the script invocation. Due to bugs in compiling with -O3 on + Solaris only -O2 is used by default, when --fast flag is used -O3 will + be used instead. + + Sets -m64 (default) or -m32 (if specifically set) in LDFLAGS and + C/C++ flags. Solaris/Sparc/Forte ------------------- - Uses cc-5.0 as CC - Sets ASFLAGS=LDFLAGS=xarch=v9, so that we compile Sparc v9 binaries - C flags = -Xa -strconst -xc99=none + Uses cc as CC and CC as CXX + Note that SunStudio uses different binaries for C and C++ compilers. + + Set -m64 (default) or -m32 (if specifically set) in ASFLAGS, + LDFLAGS and C/C++ flags. + + Sets ASFLAGS=LDFLAGS=compiler flags=xarch=sparc, so that we compile + Sparc v9 binaries, also -mt is set in all those since we're always + building a multithreaded program. + + C flags = -xstrconst This flag is set only on SPARC C++ flags = -noex - C/C++ flags = -mt -D_FORTEC -xarch=v9 - For non-debug builds, the following flags are also used: + Set the following C/C++ flags: + -fsimple=1 + -ftrap=%none + -nofstore This flag is set only on x86 + -xbuiltin=%all + -xlibmil + -xlibmopt - C/C++ flags = -xO3 + Set the C++ flag: + -noex + -features=no%except This flag is set only on x86 + + When compiling with fast we set (-ipo only used if we have + set --with-link-time-optimizer): + C/C++ flags: -xtarget=native -xunroll=3 -xipo + LDFLAGS: -xipo + + When not compiling with fast we always set -xtarget=generic + + When compiling with fast on SPARC we also set: + C/C++ flags: -xbinopt=prepare + LDFLAGS: -xbinopt=prepare + + When compiling with fast on x86 we also set: + C/C++ flags: -xregs=frameptr + When not compiling with fast we set on x86 + C/C++ flags: -xregs=no%frameptr + + On SPARC we set + ASFLAGS = LDFLAGS = C/C++ flags = -xarch=sparc + + The optimisation level is + -xO Debug builds + -xO2 Production build on SPARC + -xO3 Production build on x86 + -xO4 Fast builds on SPARC/x86 MacOSX/x86/gcc -------------- - C/C++ flags include -fno-common -arch i386. + C/C++ flags include -fno-common -arch i386. + When 64-bits builds then i386 is replaced by x86_64. - Non-debug versions also add -Os -felide-constructors, where "-Os" - means the build is space-optimised as long as the space optimisations - do not negatively affect performance. Debug versions use -O. + Non-debug versions also add -Os -felide-constructors, where "-Os" + means the build is space-optimised as long as the space optimisations + do not negatively affect performance. Debug versions use -O. + + Mac OS X builds will always be 32-bit by default, when --64 is added + the build will be 64 bit instead. Thus the flag --m64 is added only + when specifically given as an option. EOF } + with_usage() { cat < /dev/null 2>&1 && test "$USING_GCOV" != "1" @@ -994,7 +1095,7 @@ set_with_debug_flags() if test "x$with_debug_flag" = "xyes" ; then if test "x$developer_flag" = "xyes" ; then loc_debug_flags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS " - loc_debug_flags="$loc_debug_cflags -DSAFEMALLOC -DPEDANTIC_SAFEMALLOC" + loc_debug_flags="$loc_debug_flags -DSAFEMALLOC -DPEDANTIC_SAFEMALLOC" compiler_flags="$compiler_flags $loc_debug_flags" fi fi @@ -1023,6 +1124,18 @@ set_debug_flag() fi } +# +# We compile in SSL support if we can, this isn't possible if CXX +# and CC aren't the same and we're not using GCC. +# +set_ssl() +{ + if test "x$compiler" = "xgcc" && \ + test "x$CC" = "x$CXX" ; then + base_configs="$base_configs --with-ssl" + fi +} + # # Base options used by all packages # @@ -1048,9 +1161,12 @@ set_base_configs() base_configs="$base_configs --enable-thread-safe-client" base_configs="$base_configs --with-big-tables" base_configs="$base_configs --with-extra-charsets=all" - base_configs="$base_configs --with-ssl" + if test "x$with_fast_mutexes" = "xyes" ; then + base_configs="$base_configs --with-fast-mutexes" + fi base_configs="$base_configs --with-pic" base_configs="$base_configs --with-csv-storage-engine" + base_configs="$base_configs --with-perfschema" } # @@ -1060,18 +1176,30 @@ set_base_configs() # set_base_engines() { - engine_configs="$engine_configs --with-archive-storage-engine" + engine_configs="--with-archive-storage-engine" engine_configs="$engine_configs --with-blackhole-storage-engine" - engine_configs="$engine_configs --with-example-storage-engine" + engine_configs="$engine_configs --without-example-storage-engine" engine_configs="$engine_configs --with-federated-storage-engine" engine_configs="$engine_configs --with-partition" + base_configs="$base_configs $engine_configs" +} + +set_innodb_engine() +{ + base_configs="$base_configs --with-innodb" +} + +set_ndb_engine() +{ + base_configs="$base_configs --with-ndbcluster" + base_configs="$base_configs --without-ndb-debug" } set_pro_package() { - base_configs="$base_configs $engine_configs" - base_configs="$base_configs --with-innodb" - base_configs="$base_configs --with-comment=\"MySQL Pro $version_text built from source\"" + if test "x$without_comment" != "xyes" ; then + base_configs="$base_configs --with-comment=\"MySQL Enterprise Pro $version_text built from source\"" + fi if test "x$with_debug_flag" = "xyes" ; then base_configs="$base_configs --with-server-suffix=\"-debug\"" fi @@ -1079,40 +1207,37 @@ set_pro_package() set_cge_extended_package() { - if test "x$gpl" = "xno" ; then - echo "Cannot build Extended Carrier Grade Edition as Commercial version" + if test "x$without_comment" != "xyes" ; then + base_configs="$base_configs --with-comment=\"MySQL Cluster Carrier Grade Extended Edition $version_text built from source\"" fi - base_configs="$base_configs --with-ndbcluster" - base_configs="$base_configs --without-ndb-debug" - base_configs="$base_configs $engine_configs" - base_configs="$base_configs --with-innodb" - base_configs="$base_configs --with-comment=\"MySQL Cluster Carrier Grade Extended Edition $version_text built from source\"" if test "x$with_debug_flag" = "xyes" ; then base_configs="$base_configs --with-server-suffix=\"-cge-extended-debug\"" else - base_configs="$base_configs --with-server-suffix=\"-cge-extended"\" + base_configs="$base_configs --with-server-suffix=\"-cge-extended\"" fi } set_cge_package() { - base_configs="$base_configs --with-ndbcluster" - base_configs="$base_configs --without-ndb-debug" - base_configs="$base_configs $engine_configs" - base_configs="$base_configs --with-comment=\"MySQL Cluster Carrier Grade Edition $version_text built from source\"" + if test "x$without_comment" != "xyes" ; then + base_configs="$base_configs --with-comment=\"MySQL Cluster Carrier Grade Edition $version_text built from source\"" + fi if test "x$with_debug_flag" = "xyes" ; then base_configs="$base_configs --with-server-suffix=\"-cge-debug\"" else - base_configs="$base_configs --with-server-suffix=\"-cge"\" + base_configs="$base_configs --with-server-suffix=\"-cge\"" fi } set_classic_package() { - base_configs="$base_configs --with-comment=\"MySQL Classic $version_text built from source\"" + if test "x$without_comment" != "xyes" ; then + base_configs="$base_configs --with-comment=\"MySQL Classic $version_text built from source\"" + fi if test "x$with_debug_flag" = "xyes" ; then base_configs="$base_configs --with-server-suffix=\"-debug\"" fi + base_configs="$base_configs --without-example-storage-engine" } # @@ -1140,6 +1265,36 @@ set_gcc_special_options() fi } +set_cc_and_cxx_for_gcc() +{ + if test "x$CC" = "x" ; then + CC="gcc -static-libgcc -fno-exceptions" + fi + if test "x$CXX" = "x" ; then + CXX="gcc -static-libgcc -fno-exceptions" + fi +} + +set_cc_and_cxx_for_icc() +{ + if test "x$CC" = "x" ; then + CC="icc -static-intel -static-libgcc" + fi + if test "x$CXX" = "x" ; then + CXX="icpc -static-intel -static-libgcc" + fi +} + +set_cc_and_cxx_for_forte() +{ + if test "x$CC" = "x" ; then + CC="cc" + fi + if test "x$CXX" = "x" ; then + CXX="CC" + fi +} + # # If we discover a Core 2 Duo architecture and we have enabled the fast # flag, we enable a compile especially optimised for Core 2 Duo. This @@ -1167,10 +1322,69 @@ set_bsd_configs() exit 1 fi base_configs="$base_configs --enable-assembler" - CC="gcc" - CXX="gcc" + if test "x$fast_flag" != "xno" ; then + compiler_flags="$compiler_flags -O3" + else + compiler_flags="$compiler_flags -O0" + fi + set_cc_and_cxx_for_gcc } +check_64_bits() +{ + echo "Checking for 32/64-bits compilation" + echo "int main() { return 0; }" > temp_test.c + if test "x$m64" = "xyes" ; then + cmd="$CC $compile_flags -m64 temp_test.c" + if ! $cmd 2>1 ; then + m64="no" + echo "Changing to 32-bits since 64-bits didn't work" + else + echo "Will use 64-bits" + fi + else + cmd="$CC $compile_flags -m32 temp_test.c" + if ! $cmd 2>1 ; then + m64="yes" + echo "Changing to 64-bits since 32-bits didn't work" + else + echo "Will use 32-bits" + fi + fi + rm temp_test.c +} + +# +# Get GCC version +# +get_gcc_version() +{ + # check if compiler is gcc and dump its version + cc_verno=`$cc -dumpversion 2>/dev/null` + if test "x$?" = "x0" ; then + set -- `echo $cc_verno | tr '.' ' '` + cc_ver="GCC" + cc_major=$1 + cc_minor=$2 + cc_patch=$3 + gcc_version=`expr $cc_major '*' 100 '+' $cc_minor` + fi +} + +# +# Link Time Optimizer in GCC (LTO) uses a parameter -flto +# which was added to GCC 4.5, if --with-link-time-optimizer +# is set then use this feature +# +check_for_link_time_optimizer() +{ + get_gcc_version + if test "$gcc_version" -ge 405 && \ + test "x$with_link_time_optimizer" = "xyes" ; then + compiler_flags="$compiler_flags -flto" + LDFLAGS="$LDFLAGS -flto" + fi +} # # Linux Section # @@ -1178,31 +1392,46 @@ set_linux_configs() { if test "x$cpu_base_type" != "xx86" && \ test "x$cpu_base_type" != "xitanium" ; then - usage "Only x86 and Itanium CPUs supported for 32-bit Linux" + usage "Only x86 and Itanium CPUs supported for Linux" exit 1 fi - base_configs="$base_configs --with-fast-mutexes" + if test "x$use_tcmalloc" = "xyes" ; then + base_configs="$base_configs --with-mysqld-libs=-ltcmalloc_minimal" + fi if test "x$cpu_base_type" = "xx86" ; then base_configs="$base_configs --enable-assembler" fi if test "x$compiler" = "xgcc" ; then - CC="gcc" - CXX="gcc" + set_cc_and_cxx_for_gcc + if test "x$fast_flag" != "xno" ; then + if test "x$fast_flag" = "xyes" ; then + compiler_flags="$compiler_flags -O3" + check_for_link_time_optimizer + else + compiler_flags="$compiler_flags -O2" + fi + else + compiler_flags="$compiler_flags -O0" + fi + check_64_bits if test "x$m64" = "xyes" ; then compiler_flags="$compiler_flags -m64" + else + compiler_flags="$compiler_flags -m32" fi # configure will set proper compiler flags for gcc on Linux elif test "x$compiler" = "xicc" ; then compiler_flags="$compiler_flags -mp -restrict" - CC="icc -static-intel" - CXX="icpc -static-intel" + set_cc_and_cxx_for_icc if test "x$cpu_base_type" = "xitanium" ; then compiler_flags="$compiler_flags -no-ftz" fi if test "x$fast_flag" != "xno" ; then compiler_flags="$compiler_flags -O3 -unroll2 -ip" - if test "x$fast_flag" = "xyes" ; then + if test "x$fast_flag" = "xyes" && \ + test "x$with_link_time_optimizer" = "xyes" ; then compiler_flags="$compiler_flags -ipo" + LDFLAGS="$LDFLAGS -ipo" fi fi else @@ -1216,54 +1445,112 @@ set_linux_configs() # set_solaris_configs() { - base_configs="$base_configs --with-mysqld-libs=-lmtmalloc" +# Use mtmalloc as malloc, see Tim Cook blog +# For information on optimal compiler settings, see article at +# http://developers.sun.com/solaris/articles/mysql_perf_tune.html +# by Luojia Chen at Sun. + base_configs="$base_configs --with-named-curses=-lcurses" case "`uname -a`" in - *5.10*|*5.11*) + *5.8* | *5.9* ) + ;; + + *5.10* | *5.11*) + base_configs="$base_configs --with-mysqld-libs=-lmtmalloc" ;; *) - die "Only versions 10 and 11 supported for Solaris" + usage "Only versions 8,9, 10 and 11 supported for Solaris" + exit 1 esac if test "x$cpu_base_type" != "xx86" && \ test "x$cpu_base_type" != "xsparc" ; then usage "Only x86 and Sparc CPUs supported for Solaris" exit 1 fi - if test "x$compiler" = "xgcc" ; then - CC="gcc" - CXX="gcc" - if test "x$cpu_base_type" != "xx86" ; then - usage "Only gcc supported for Solaris 10/11 on SPARC" - fi - compiler_flags="$compiler_flags -m64 -DMY_ATOMIC_MODE_RWLOCKS" - LDFLAGS="-m64 -static-libgcc" - if test "x$fast_flag" != "xno" ; then - LDFLAGS="$LDFLAGS -O2" - compiler_flags="$compiler_flags -O2" - else - LDFLAGS="$LDFLAGS -O" - compiler_flags="$compiler_flags -O" - fi - elif test "x$compiler" = "xforte" ; then - if test "x$cpu_base_type" = "xx86" ; then - usage "Only gcc supported for Solaris/x86" - fi - if test "x$cpu_base_type" != "xsparc" ; then - usage "Forte compiler supported for Solaris 9/SPARC only" - fi - CC="cc-5.0" - CXX=CC - ASFLAGS="xarch=v9" - LDFLAGS="xarch=v9" - base_cflags="$base_cflags -Xa -xstrconst -xc99=none" - base_cxxflags="$base_cxxflags -noex" - compiler_flags="$compiler_flags -mt -D_FORTEC -xarch=v9" - if test "x$fast_flag" != "xno" ; then - compiler_flags="$compiler_flags -xO3" - fi - else + if test "x$compiler" != "xgcc" && \ + test "x$compiler" != "xforte" ; then usage "Only gcc and Forte compilers supported for Solaris" exit 1 fi + if test "x$m64" = "xyes" ; then + compiler_flags="$compiler_flags -m64" + LDFLAGS="-m64" + ASFLAGS="$ASFLAGS -m64" + else + compiler_flags="$compiler_flags -m32" + LDFLAGS="-m32" + ASFLAGS="$ASFLAGS -m32" + fi + if test "x$compiler" = "xgcc" ; then + set_cc_and_cxx_for_gcc + if test "x$cpu_base_type" != "xx86" ; then + usage "gcc currently not supported for Solaris on SPARC" + exit 1 + fi + if test "x$fast_flag" = "xyes" ; then + LDFLAGS="$LDFLAGS -O3" + compiler_flags="$compiler_flags -O3" + check_for_link_time_optimizer + else + if test "x$fast_flag" = "xgeneric" ; then + LDFLAGS="$LDFLAGS -O2" + compiler_flags="$compiler_flags -O2" + else + LDFLAGS="$LDFLAGS -O0" + compiler_flags="$compiler_flags -O0" + fi + fi + else +#Using Forte compiler (SunStudio) + set_cc_and_cxx_for_forte + compiler_flags="$compiler_flags -mt" + LDFLAGS="$LDFLAGS -mt" + compiler_flags="$compiler_flags -fsimple=1" + compiler_flags="$compiler_flags -ftrap=%none" + compiler_flags="$compiler_flags -xbuiltin=%all" + compiler_flags="$compiler_flags -xlibmil" + compiler_flags="$compiler_flags -xlibmopt" + if test "x$fast_flag" = "xyes" ; then + compiler_flags="$compiler_flags -xtarget=native" + compiler_flags="$compiler_flags -xunroll=3" + if test "x$with_link_time_optimizer" = "xyes" ; then + compiler_flags="$compiler_flags -xipo" + LDFLAGS="$LDFLAGS -xipo" + fi + else + compiler_flags="$compiler_flags -xtarget=generic" + fi + if test "x$cpu_base_type" = "xx86" ; then + compiler_flags="$compiler_flags -nofstore" + base_cxx_flags="$base_cxx_flags -features=no%except" + if test "x$fast_flag" = "xyes" ; then + compiler_flags="$compiler_flags -xregs=frameptr" + compiler_flags="$compiler_flags -xO4" + else + compiler_flags="$compiler_flags -xregs=no%frameptr" + if test "x$fast_flag" = "xgeneric" ; then + compiler_flags="$compiler_flags -xO2" + else + compiler_flags="$compiler_flags -xO0" + fi + fi + else +#Using SPARC cpu with SunStudio (Forte) compiler + ASFLAGS="$ASFLAGS -xarch=sparc" + LDFLAGS="$LDFLAGS -xarch=sparc" + base_cxxflags="$base_cxxflags -noex" + base_cflags="$base_cflags -xstrconst" + compiler_flags="$compiler_flags -xarch=sparc" + if test "x$fast_flag" = "xyes" ; then + compiler_flags="$compiler_flags -xbinopt=prepare" + LDFLAGS="$LDFLAGS -xbinopt=prepare" + compiler_flags="$compiler_flags -xO4" + elif test "x$fast_flag" = "xgeneric" ; then + compiler_flags="$compiler_flags -xO3" + else + compiler_flags="$compiler_flags -xO0" + fi + fi + fi } # @@ -1271,10 +1558,7 @@ set_solaris_configs() # set_macosx_configs() { - base_cxxflags="$base_cxxflags -fno-common" - if test "x$cpu_base_type" = "xx86" && test "x$compiler" = "xgcc" ; then - compiler_flags="$compiler_flags -arch i386" - else + if test "x$cpu_base_type" != "xx86" || test "x$compiler" != "xgcc" ; then usage "Only gcc/x86 supported for Mac OS X" exit 1 fi @@ -1282,14 +1566,21 @@ set_macosx_configs() # Optimize for space as long as it doesn't affect performance, use some # optimisations also when not in fast mode. # + base_cxxflags="$base_cxxflags -felide-constructors" + compiler_flags="$compiler_flags -fno-common" + if test "x$m64" = "xyes" ; then + compiler_flags="$compiler_flags -m64" + compiler_flags="$compiler_flags -arch x86_64" + else + compiler_flags="$compiler_flags -m32" + compiler_flags="$compiler_flags -arch i386" + fi if test "x$fast_flag" != "xno" ; then compiler_flags="$compiler_flags -Os" - base_cxxflags="$base_cxxflags -felide-constructors" else - compiler_flags="$compiler_flags -O" + compiler_flags="$compiler_flags -O0" fi - CC="gcc" - CXX="gcc" + set_cc_and_cxx_for_gcc } # @@ -1370,7 +1661,7 @@ fi cpu_type= package= prefix="/usr/local/mysql" -parallelism="4" +parallelism="8" fast_flag="generic" compiler="gcc" gpl="yes" @@ -1398,11 +1689,19 @@ base_cxxflags= base_configs= debug_flags= cxxflags= -m32= m64= +explicit_size_set= datadir= commands= use_autotools= +engine_configs= +ASFLAGS= +LDFLAGS= +use_tcmalloc= +without_comment="yes" +with_fast_mutexes= +with_link_time_optimizer= +gcc_version="0" set_defaults_based_on_environment @@ -1419,7 +1718,14 @@ set -e # This call sets the cpu_arg and check_cpu_args parameters # path=`dirname $0` +if test "x$compiler" = "xgcc" ; then + compiler= +fi . "$path/check-cpu" +if test "x$compiler" = "x" ; then + compiler="gcc" +fi +check_os set_cpu_base if test "x$?" = "x1" ; then exit 1 @@ -1447,17 +1753,23 @@ set_icc_special_options # including all storage engines except InnoDB, and to use GPL libraries. # set_base_configs -set_base_engines if test "x$gpl" = "xyes" ; then version_text="GPL version" else version_text="Commercial version" fi if test "x$package" = "xpro" ; then + set_base_engines + set_innodb_engine set_pro_package elif test "x$package" = "xextended" ; then + set_base_engines + set_ndb_engine + set_innodb_engine set_cge_extended_package elif test "x$package" = "xcge" ; then + set_base_engines + set_ndb_engine set_cge_package elif test "x$package" = "xclassic" ; then set_classic_package @@ -1473,7 +1785,6 @@ set_error_inject_configs # operating systems, and processors. # -check_os if test "x$os" = "xlinux" ; then set_linux_configs elif test "x$os" = "xSolaris" ; then @@ -1485,13 +1796,13 @@ elif test "x$os" = "xbsd" ; then else die "Operating system not supported by this script" fi - +set_ssl # # Final step before setting up commands is to set up proper make and # proper libtoolize versions, and to determine whether to use ccache. # set_make_version -set_up_ccache +set_ccache_usage # # Set up commands variable from variables prepared for base diff --git a/BUILD/check-cpu b/BUILD/check-cpu index 390ba545405..90f42ef67cc 100755 --- a/BUILD/check-cpu +++ b/BUILD/check-cpu @@ -16,12 +16,14 @@ check_cpu () { # on Linux (and others?) we can get detailed CPU information out of /proc cpuinfo="cat $CPUINFO" + # detect CPU architecture + cpu_arch=`$cpuinfo | grep 'arch' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` + # detect CPU family cpu_family=`$cpuinfo | grep 'family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` if test -z "$cpu_family" ; then cpu_family=`$cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` fi - # detect CPU vendor and model cpu_vendor=`$cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` model_name=`$cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1` @@ -56,8 +58,8 @@ check_cpu () { fi ;; *) - cpu_family=`uname -m`; - model_name=`uname -p`; + cpu_family=`uname -p`; + model_name=`uname -m`; ;; esac fi @@ -65,9 +67,10 @@ check_cpu () { # detect CPU shortname as used by gcc options # this list is not complete, feel free to add further entries cpu_arg="" - case "$cpu_family--$model_name" in + low_cpu_arg="" + case "$cpu_vendor--$cpu_family--$model_name--$cpu_arch" in # DEC Alpha - Alpha*EV6*) + *Alpha*EV6*) cpu_arg="ev6"; ;; #Core 2 Duo @@ -96,6 +99,13 @@ check_cpu () { *Pentium*4*Mobile*) cpu_arg="pentium4m" ;; + *Pentium\(R\)*\ M*) + cpu_arg="pentium-m" + low_cpu_arg="pentium3" + ;; + *Pentium\(R\)*\ D*) + cpu_arg="prescott" + ;; *Pentium*4*) cpu_arg="pentium4" ;; @@ -120,6 +130,12 @@ check_cpu () { *Celeron*) cpu_arg="pentium2" ;; + *Atom*) + cpu_arg="prescott" + ;; + *GenuineIntel*) + cpu_arg="pentium" + ;; *Turion*) cpu_arg="athlon64" ;; @@ -129,9 +145,30 @@ check_cpu () { *Athlon*) cpu_arg="athlon" ;; + *AMD-K7*) + cpu_arg="athlon" + ;; + *Athlon*XP\ *) + cpu_arg="athlon-xp" + ;; + *AMD*Sempron\(tm\)*) + cpu_arg="athlon-mp" + ;; + *AMD*Athlon\(tm\)\ 64*) + cpu_arg="k8" + ;; *Opteron*) cpu_arg="opteron" ;; + *Phenom*) + cpu_arg="k8" + ;; + *AuthenticAMD*) + cpu_arg="k6" + ;; + *VIA\ *) + cpu_arg="i686" + ;; # MacOSX / Intel *i386*i486*) cpu_arg="pentium-m" @@ -143,8 +180,11 @@ check_cpu () { *Itanium*) cpu_arg="itanium" ;; + *IA-64*) + cpu_arg="itanium" + ;; # Solaris Sparc - *sparc*sun4u*) + *sparc*sun4[uv]*) cpu_arg="sparc" ;; # Power PC @@ -160,6 +200,10 @@ check_cpu () { ;; esac + if test "x$low_cpu_arg" = "x" ; then + low_cpu_arg="$cpu_arg" + fi + if test -z "$cpu_arg" ; then if test "$CPUINFO" != " " ; then # fallback to uname if necessary @@ -198,7 +242,7 @@ check_cpu () { case `gcc -dumpmachine` in i?86-* | x86_64-*) if test "$cc_comp" -lt 304 ; then - check_cpu_cflags="-mcpu=${cpu_arg}" + check_cpu_cflags="-mcpu=${low_cpu_arg}" elif test "$cc_comp" -ge 402 ; then check_cpu_cflags="-mtune=native" else From f14d947c9898569367fda8028a8287ff676777c8 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Thu, 16 Sep 2010 11:11:13 +0200 Subject: [PATCH 149/183] Bug #56595 RENAME TABLE causes assert on OS X The problem was that RENAME TABLE caused an assert if the system variable lower_case_table_names was 2 (default on Mac OS X) and the old table name was given in upper case. This caused lowercase_table2.test to fail. The assert checks that an exclusive metadata lock is held by the connection trying to do RENAME TABLE - specificially during updates of table triggers. The assert was triggered since the check is case sensitive and the lock was held on the normalized (lower case) version of the table name. This patch fixes the problem by making sure a normalized version of the table name is used for the metadata lock check, while using a non-normalized version of the table name for the rename of trigger files. The same is done for ALTER TABLE ... RENAME. Regression testing for the bug itself is already covered by lowercase_table2.test. Additional coverage added to lowercase_fs_off.test. --- mysql-test/r/lowercase_fs_off.result | 8 ++++++++ mysql-test/t/lowercase_fs_off.test | 11 +++++++++++ sql/sql_rename.cc | 1 + sql/sql_table.cc | 5 +++-- sql/sql_trigger.cc | 6 ++++-- sql/sql_trigger.h | 1 + 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/lowercase_fs_off.result b/mysql-test/r/lowercase_fs_off.result index 30f835a8ea3..c3284b225dd 100644 --- a/mysql-test/r/lowercase_fs_off.result +++ b/mysql-test/r/lowercase_fs_off.result @@ -55,3 +55,11 @@ DROP USER user_1@localhost; DROP USER USER_1@localhost; DROP DATABASE db1; use test; +# +# Extra test coverage for Bug#56595 RENAME TABLE causes assert on OS X +# +CREATE TABLE t1(a INT); +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET new.a= 1; +RENAME TABLE t1 TO T1; +ALTER TABLE T1 RENAME t1; +DROP TABLE t1; diff --git a/mysql-test/t/lowercase_fs_off.test b/mysql-test/t/lowercase_fs_off.test index 86d1e084c29..1be0351f9bc 100644 --- a/mysql-test/t/lowercase_fs_off.test +++ b/mysql-test/t/lowercase_fs_off.test @@ -91,3 +91,14 @@ DROP DATABASE db1; use test; # End of 5.0 tests + + +--echo # +--echo # Extra test coverage for Bug#56595 RENAME TABLE causes assert on OS X +--echo # + +CREATE TABLE t1(a INT); +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET new.a= 1; +RENAME TABLE t1 TO T1; +ALTER TABLE T1 RENAME t1; +DROP TABLE t1; diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 97f8e46d052..ac15239b040 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -285,6 +285,7 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name, { if ((rc= Table_triggers_list::change_table_name(thd, ren_table->db, old_alias, + ren_table->table_name, new_db, new_alias))) { diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 9d8f59189d0..d8ef6d7030a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5918,7 +5918,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, *fn_ext(new_name)=0; if (mysql_rename_table(old_db_type,db,table_name,new_db,new_alias, 0)) error= -1; - else if (Table_triggers_list::change_table_name(thd, db, table_name, + else if (Table_triggers_list::change_table_name(thd, db, + alias, table_name, new_db, new_alias)) { (void) mysql_rename_table(old_db_type, new_db, new_alias, db, @@ -6555,7 +6556,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, (need_copy_table != ALTER_TABLE_METADATA_ONLY || mysql_rename_table(save_old_db_type, db, table_name, new_db, new_alias, NO_FRM_RENAME)) && - Table_triggers_list::change_table_name(thd, db, table_name, + Table_triggers_list::change_table_name(thd, db, alias, table_name, new_db, new_alias))) { /* Try to get everything back. */ diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index c1405015365..392343eb9a3 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1874,6 +1874,7 @@ Table_triggers_list::change_table_name_in_trignames(const char *old_db_name, @param[in,out] thd Thread context @param[in] db Old database of subject table + @param[in] old_alias Old alias of subject table @param[in] old_table Old name of subject table @param[in] new_db New database for subject table @param[in] new_table New name of subject table @@ -1890,6 +1891,7 @@ Table_triggers_list::change_table_name_in_trignames(const char *old_db_name, */ bool Table_triggers_list::change_table_name(THD *thd, const char *db, + const char *old_alias, const char *old_table, const char *new_db, const char *new_table) @@ -1911,7 +1913,7 @@ bool Table_triggers_list::change_table_name(THD *thd, const char *db, MDL_EXCLUSIVE)); DBUG_ASSERT(my_strcasecmp(table_alias_charset, db, new_db) || - my_strcasecmp(table_alias_charset, old_table, new_table)); + my_strcasecmp(table_alias_charset, old_alias, new_table)); if (Table_triggers_list::check_n_load(thd, db, old_table, &table, TRUE)) { @@ -1920,7 +1922,7 @@ bool Table_triggers_list::change_table_name(THD *thd, const char *db, } if (table.triggers) { - LEX_STRING old_table_name= { (char *) old_table, strlen(old_table) }; + LEX_STRING old_table_name= { (char *) old_alias, strlen(old_alias) }; LEX_STRING new_table_name= { (char *) new_table, strlen(new_table) }; /* Since triggers should be in the same schema as their subject tables diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h index 28bf0a60877..dd954957f07 100644 --- a/sql/sql_trigger.h +++ b/sql/sql_trigger.h @@ -157,6 +157,7 @@ public: TABLE *table, bool names_only); static bool drop_all_triggers(THD *thd, char *db, char *table_name); static bool change_table_name(THD *thd, const char *db, + const char *old_alias, const char *old_table, const char *new_db, const char *new_table); From be794bc5eb1c355c86a94c8988faed0d4c40cf69 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Thu, 16 Sep 2010 17:24:27 +0700 Subject: [PATCH 150/183] Fixed bug#42503 - "Lost connection" errors when using compression protocol. The loss of connection was caused by a malformed packet sent by the server in case when query cache was in use. When storing data in the query cache, the query cache memory allocation algorithm had a tendency to reduce the amount of memory block necessary to store a result set, up to finally storing the entire result set in a single block. With a significant result set, this memory block could turn out to be quite large - 30, 40 MB and on. When such a result set was sent to the client, the entire memory block was compressed and written to network as a single network packet. However, the length of the network packet is limited by 0xFFFFFF (16MB), since the packet format only allows 3 bytes for packet length. As a result, a malformed, overly large packet with truncated length would be sent to the client and break the client/server protocol. The solution is, when sending result sets from the query cache, to ensure that the data is chopped into network packets of size <= 16MB, so that there is no corruption of packet length. This solution, however, has a shortcoming: since the result set is still stored in the query cache as a single block, at the time of sending, we've lost boundaries of individual logical packets (one logical packet = one row of the result set) and thus can end up sending a truncated logical packet in a compressed network packet. As a result, on the client we may require more memory than max_allowed_packet to keep, both, the truncated last logical packet, and the compressed next packet. This never (or in practice never) happens without compression, since without compression it's very unlikely that a) a truncated logical packet would remain on the client when it's time to read the next packet b) a subsequent logical packet that is being read would be so large that size-of-new-packet + size-of-old-packet-tail > max_allowed_packet. To remedy this issue, we send data in 1MB sized packets, that's below the current client default of 16MB for max_allowed_packet, but large enough to ensure there is no unnecessary overhead from too many syscalls per result set. --- sql/net_serv.cc | 12 +++++++++- sql/sql_cache.cc | 59 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 38ab3a70136..f3f6f1bd9a0 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -170,7 +170,17 @@ my_bool net_realloc(NET *net, size_t length) DBUG_ENTER("net_realloc"); DBUG_PRINT("enter",("length: %lu", (ulong) length)); - if (length >= net->max_packet_size) + /* + When compression is off, net->where_b is always 0. + With compression turned on, net->where_b may indicate + that we still have a piece of the previous logical + packet in the buffer, unprocessed. Take it into account + when checking that max_allowed_packet is not exceeded. + This ensures that the client treats max_allowed_packet + limit identically, regardless of compression being on + or off. + */ + if (length >= (net->max_packet_size + net->where_b)) { DBUG_PRINT("error", ("Packet too large. Max size: %lu", net->max_packet_size)); diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index fcf4edbdc22..22bdb24fb16 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1330,6 +1330,55 @@ end: } +/** + Send a single memory block from the query cache. + + Respects the client/server protocol limits for the + size of the network packet, and splits a large block + in pieces to ensure that individual piece doesn't exceed + the maximal allowed size of the network packet (16M). + + @param[in] net NET handler + @param[in] packet packet to send + @param[in] len packet length + + @return Operation status + @retval FALSE On success + @retval TRUE On error +*/ +static bool +send_data_in_chunks(NET *net, const uchar *packet, ulong len) +{ + /* + On the client we may require more memory than max_allowed_packet + to keep, both, the truncated last logical packet, and the + compressed next packet. This never (or in practice never) + happens without compression, since without compression it's very + unlikely that a) a truncated logical packet would remain on the + client when it's time to read the next packet b) a subsequent + logical packet that is being read would be so large that + size-of-new-packet + size-of-old-packet-tail > + max_allowed_packet. To remedy this issue, we send data in 1MB + sized packets, that's below the current client default of 16MB + for max_allowed_packet, but large enough to ensure there is no + unnecessary overhead from too many syscalls per result set. + */ + static const ulong MAX_CHUNK_LENGTH= 1024*1024; + + while (len > MAX_CHUNK_LENGTH) + { + if (net_real_write(net, packet, MAX_CHUNK_LENGTH)) + return TRUE; + packet+= MAX_CHUNK_LENGTH; + len-= MAX_CHUNK_LENGTH; + } + if (len && net_real_write(net, packet, len)) + return TRUE; + + return FALSE; +} + + /* Check if the query is in the cache. If it was cached, send it to the user. @@ -1635,11 +1684,11 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", ALIGN_SIZE(sizeof(Query_cache_result))))); Query_cache_result *result = result_block->result(); - if (net_real_write(&thd->net, result->data(), - result_block->used - - result_block->headers_len() - - ALIGN_SIZE(sizeof(Query_cache_result)))) - break; // Client aborted + if (send_data_in_chunks(&thd->net, result->data(), + result_block->used - + result_block->headers_len() - + ALIGN_SIZE(sizeof(Query_cache_result)))) + break; // Client aborted result_block = result_block->next; thd->net.pkt_nr= query->last_pkt_nr; // Keep packet number updated } while (result_block != first_result_block); From f43d6c2b738b12b7ff20fb6558c8b99c13d447fc Mon Sep 17 00:00:00 2001 From: Magne Mahre Date: Thu, 16 Sep 2010 12:51:08 +0200 Subject: [PATCH 151/183] Bug #54606 innodb fast alter table + pack_keys=0 prevents adding new indexes A fast alter table requires that the existing (old) table and indices are unchanged (i.e only new indices can be added). To verify this, the layout and flags of the old table/indices are compared for equality with the new. The PACK_KEYS option is a no-op in InnoDB, but the flag exists, and is used in the table compare. We need to check this (table) option flag before deciding whether an index should be packed or not. If the table has explicitly set PACK_KEYS to 0, the created indices should not be marked as packed/packable. --- .../suite/innodb_plugin/r/innodb_mysql.result | 10 ++++++++++ mysql-test/suite/innodb_plugin/t/innodb_mysql.test | 14 ++++++++++++++ sql/sql_table.cc | 1 + 3 files changed, 25 insertions(+) diff --git a/mysql-test/suite/innodb_plugin/r/innodb_mysql.result b/mysql-test/suite/innodb_plugin/r/innodb_mysql.result index b4ac88fc1c3..54a8854ecaf 100644 --- a/mysql-test/suite/innodb_plugin/r/innodb_mysql.result +++ b/mysql-test/suite/innodb_plugin/r/innodb_mysql.result @@ -2390,4 +2390,14 @@ a 2 UPDATE t1,t2 SET t1.a = t1.a + 100 WHERE t1.a = 1; DROP TABLE t1,t2; +# +# Bug#54606 innodb fast alter table + pack_keys=0 +# prevents adding new indexes +# +CREATE TABLE t1 (a INT, b CHAR(9), c INT, key(b)) +ENGINE=InnoDB +PACK_KEYS=0; +CREATE INDEX a ON t1 (a); +CREATE INDEX c on t1 (c); +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/suite/innodb_plugin/t/innodb_mysql.test b/mysql-test/suite/innodb_plugin/t/innodb_mysql.test index 3f6d9d96bb8..3d078062d43 100644 --- a/mysql-test/suite/innodb_plugin/t/innodb_mysql.test +++ b/mysql-test/suite/innodb_plugin/t/innodb_mysql.test @@ -632,4 +632,18 @@ UPDATE t1,t2 SET t1.a = t1.a + 100 WHERE t1.a = 1; DROP TABLE t1,t2; +--echo # +--echo # Bug#54606 innodb fast alter table + pack_keys=0 +--echo # prevents adding new indexes +--echo # + +CREATE TABLE t1 (a INT, b CHAR(9), c INT, key(b)) + ENGINE=InnoDB + PACK_KEYS=0; +CREATE INDEX a ON t1 (a); +CREATE INDEX c on t1 (c); + +DROP TABLE t1; + + --echo End of 5.1 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index d3ac2bf0f95..7a7446c7f79 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3325,6 +3325,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, key_part_info->length=(uint16) length; /* Use packed keys for long strings on the first column */ if (!((*db_options) & HA_OPTION_NO_PACK_KEYS) && + !((create_info->table_options & HA_OPTION_NO_PACK_KEYS)) && (length >= KEY_DEFAULT_PACK_LENGTH && (sql_field->sql_type == MYSQL_TYPE_STRING || sql_field->sql_type == MYSQL_TYPE_VARCHAR || From 86d7cbd450ab53012e4f4f892e4cdb6093a7313b Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Thu, 16 Sep 2010 16:13:53 +0400 Subject: [PATCH 152/183] Bug#50402 Optimizer producing wrong results when using Index Merge on InnoDB Subselect executes twice, at JOIN::optimize stage and at JOIN::execute stage. At optimize stage Innodb prebuilt struct which is used for the retrieval of column values is initialized in. ha_innobase::index_read(), prebuilt->sql_stat_start is true. After QUICK_ROR_INTERSECT_SELECT finished his job it restores read_set/write_set bitmaps with initial values and deactivates one of the handlers used by QUICK_ROR_INTERSECT_SELECT in JOIN::cleanup (it's the case when we reuse original handler as one of handlers required by QUICK_ROR_INTERSECT_SELECT object). On second subselect execution inactive handler is activated in QUICK_RANGE_SELECT::reset, file->ha_index_init(). In ha_index_init Innodb prebuilt struct is reinitialized with inappropriate read_set/write_set bitmaps. Further reinitialization in ha_innobase::index_read() does not happen as prebuilt->sql_stat_start is false. It leads to partial retrieval of required field values and we get a mix of field values from different records in the record buffer. The fix is to reset read_set/write_set bitmaps as these values are required for proper intialization of internal InnoDB struct which is used for the retrieval of column values (see build_template(), ha_innodb.cc) --- mysql-test/include/index_merge_ror_cpk.inc | 16 ++++++++++++++++ mysql-test/r/index_merge_innodb.result | 18 ++++++++++++++++++ mysql-test/r/index_merge_myisam.result | 18 ++++++++++++++++++ sql/opt_range.cc | 11 ++++++++--- 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/mysql-test/include/index_merge_ror_cpk.inc b/mysql-test/include/index_merge_ror_cpk.inc index cfc2ed3885e..3912aa34026 100644 --- a/mysql-test/include/index_merge_ror_cpk.inc +++ b/mysql-test/include/index_merge_ror_cpk.inc @@ -126,3 +126,19 @@ WHERE drop table t1; +--echo # +--echo # Bug#50402 Optimizer producing wrong results when using Index Merge on InnoDB +--echo # +CREATE TABLE t1 (f1 INT, PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (f1 INT, f2 INT, f3 char(1), + PRIMARY KEY (f1), KEY (f2), KEY (f3) ); +INSERT INTO t2 VALUES (1, 1, 'h'), (2, 3, 'h'), (3, 2, ''), (4, 2, ''); + +SELECT t1.f1 FROM t1 +WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2; + +EXPLAIN SELECT t1.f1 FROM t1 +WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2; + +DROP TABLE t1,t2; diff --git a/mysql-test/r/index_merge_innodb.result b/mysql-test/r/index_merge_innodb.result index 588de70e6e5..58ed99b1e67 100644 --- a/mysql-test/r/index_merge_innodb.result +++ b/mysql-test/r/index_merge_innodb.result @@ -581,3 +581,21 @@ WHERE `RUNID`= '' AND `SUBMITNR`= '' AND `ORDERNR`='' AND `PROGRAMM`='' AND `TESTID`='' AND `UCCHECK`=''; drop table t1; +# +# Bug#50402 Optimizer producing wrong results when using Index Merge on InnoDB +# +CREATE TABLE t1 (f1 INT, PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (f1 INT, f2 INT, f3 char(1), +PRIMARY KEY (f1), KEY (f2), KEY (f3) ); +INSERT INTO t2 VALUES (1, 1, 'h'), (2, 3, 'h'), (3, 2, ''), (4, 2, ''); +SELECT t1.f1 FROM t1 +WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2; +f1 +2 +EXPLAIN SELECT t1.f1 FROM t1 +WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1 Using index +2 DEPENDENT SUBQUERY t2 index_merge f2,f3 f3,f2 2,5 NULL 1 Using intersect(f3,f2); Using where; Using index +DROP TABLE t1,t2; diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result index c639b20de91..6bfec69fad9 100644 --- a/mysql-test/r/index_merge_myisam.result +++ b/mysql-test/r/index_merge_myisam.result @@ -1416,6 +1416,24 @@ WHERE `TESTID`='' AND `UCCHECK`=''; drop table t1; # +# Bug#50402 Optimizer producing wrong results when using Index Merge on InnoDB +# +CREATE TABLE t1 (f1 INT, PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (f1 INT, f2 INT, f3 char(1), +PRIMARY KEY (f1), KEY (f2), KEY (f3) ); +INSERT INTO t2 VALUES (1, 1, 'h'), (2, 3, 'h'), (3, 2, ''), (4, 2, ''); +SELECT t1.f1 FROM t1 +WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2; +f1 +2 +EXPLAIN SELECT t1.f1 FROM t1 +WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ref f2,f3 f2 5 1 Using where +DROP TABLE t1,t2; +# # Generic @@optimizer_switch tests (move those into a separate file if # we get another @@optimizer_switch user) # diff --git a/sql/opt_range.cc b/sql/opt_range.cc index eae79e63c19..d4a2bc3b138 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -8451,9 +8451,14 @@ int QUICK_RANGE_SELECT::reset() in_range= FALSE; cur_range= (QUICK_RANGE**) ranges.buffer; - if (file->inited == handler::NONE && (error= file->ha_index_init(index,1))) - DBUG_RETURN(error); - + if (file->inited == handler::NONE) + { + if (in_ror_merged_scan) + head->column_bitmaps_set_no_signal(&column_bitmap, &column_bitmap); + if ((error= file->ha_index_init(index,1))) + DBUG_RETURN(error); + } + /* Do not allocate the buffers twice. */ if (multi_range_length) { From 355b74d2a622722aa028c806d44f8b9c4495094d Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Thu, 16 Sep 2010 18:06:46 +0400 Subject: [PATCH 153/183] Fix for merge.test failures in mysql-5.5-runtime tree for embedded server Test case for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables" can't be run against embedded server. Embedded server converts all DELAYED INSERTs into ordinary INSERTs and this test can't work properly if such conversion happens. Moved this test from merge.test to delayed.test which is skipped if test suite is run with --embedded-server option. --- mysql-test/r/delayed.result | 28 +++++++++++++++++++++ mysql-test/r/merge.result | 28 --------------------- mysql-test/t/delayed.test | 49 +++++++++++++++++++++++++++++++++++++ mysql-test/t/merge.test | 48 ------------------------------------ 4 files changed, 77 insertions(+), 76 deletions(-) diff --git a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result index 4cb97719ff2..77aa0d49407 100644 --- a/mysql-test/r/delayed.result +++ b/mysql-test/r/delayed.result @@ -422,3 +422,31 @@ UNLOCK TABLES; # Connection con1 # Connection default DROP TABLE t1, t2, t3; +# +# Test for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables". +# +drop table if exists t1, t2, tm; +create table t1(a int); +create table t2(a int); +create table tm(a int) engine=merge union=(t1, t2); +begin; +select * from t1; +a +# Connection 'con1'. +# Sending: +alter table t1 comment 'test'; +# Connection 'default'. +# Wait until ALTER TABLE blocks and starts waiting +# for connection 'default'. It should wait with a +# pending SNW lock on 't1'. +# Attempt to perform delayed insert into 'tm' should not lead +# to a deadlock. Instead error ER_DELAYED_NOT_SUPPORTED should +# be emitted. +insert delayed into tm values (1); +ERROR HY000: DELAYED option not supported for table 'tm' +# Unblock ALTER TABLE. +commit; +# Connection 'con1'. +# Reaping ALTER TABLE: +# Connection 'default'. +drop tables tm, t1, t2; diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index 0481ee8f49a..5d96970ce74 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -3575,32 +3575,4 @@ ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'm1 drop view v1; drop temporary table tmp; drop table t1, t2, t3, m1, m2; -# -# Test for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables". -# -drop table if exists t1, t2, tm; -create table t1(a int); -create table t2(a int); -create table tm(a int) engine=merge union=(t1, t2); -begin; -select * from t1; -a -# Connection 'con1'. -# Sending: -alter table t1 comment 'test'; -# Connection 'default'. -# Wait until ALTER TABLE blocks and starts waiting -# for connection 'default'. It should wait with a -# pending SNW lock on 't1'. -# Attempt to perform delayed insert into 'tm' should not lead -# to a deadlock. Instead error ER_DELAYED_NOT_SUPPORTED should -# be emitted. -insert delayed into tm values (1); -ERROR HY000: DELAYED option not supported for table 'tm' -# Unblock ALTER TABLE. -commit; -# Connection 'con1'. -# Reaping ALTER TABLE: -# Connection 'default'. -drop tables tm, t1, t2; End of 6.0 tests diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index 5f56cdf54e1..3a2bc982ad3 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -552,3 +552,52 @@ disconnect con1; connection default; DROP TABLE t1, t2, t3; --enable_ps_protocol + + +--echo # +--echo # Test for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables". +--echo # +connect (con1,localhost,root,,); +connection default; +--disable_warnings +drop table if exists t1, t2, tm; +--enable_warnings +create table t1(a int); +create table t2(a int); +create table tm(a int) engine=merge union=(t1, t2); +begin; +select * from t1; + +--echo # Connection 'con1'. +connection con1; +--echo # Sending: +--send alter table t1 comment 'test' + +--echo # Connection 'default'. +connection default; +--echo # Wait until ALTER TABLE blocks and starts waiting +--echo # for connection 'default'. It should wait with a +--echo # pending SNW lock on 't1'. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table metadata lock" and + info = "alter table t1 comment 'test'"; +--source include/wait_condition.inc +--echo # Attempt to perform delayed insert into 'tm' should not lead +--echo # to a deadlock. Instead error ER_DELAYED_NOT_SUPPORTED should +--echo # be emitted. +--error ER_DELAYED_NOT_SUPPORTED +insert delayed into tm values (1); +--echo # Unblock ALTER TABLE. +commit; + +--echo # Connection 'con1'. +connection con1; +--echo # Reaping ALTER TABLE: +--reap + +disconnect con1; +--source include/wait_until_disconnected.inc +--echo # Connection 'default'. +connection default; +drop tables tm, t1, t2; diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 3633a8b30ad..51c4ca51a29 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -2668,54 +2668,6 @@ drop temporary table tmp; drop table t1, t2, t3, m1, m2; ---echo # ---echo # Test for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables". ---echo # -connect (con1,localhost,root,,); -connection default; ---disable_warnings -drop table if exists t1, t2, tm; ---enable_warnings -create table t1(a int); -create table t2(a int); -create table tm(a int) engine=merge union=(t1, t2); -begin; -select * from t1; - ---echo # Connection 'con1'. -connection con1; ---echo # Sending: ---send alter table t1 comment 'test' - ---echo # Connection 'default'. -connection default; ---echo # Wait until ALTER TABLE blocks and starts waiting ---echo # for connection 'default'. It should wait with a ---echo # pending SNW lock on 't1'. -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Waiting for table metadata lock" and - info = "alter table t1 comment 'test'"; ---source include/wait_condition.inc ---echo # Attempt to perform delayed insert into 'tm' should not lead ---echo # to a deadlock. Instead error ER_DELAYED_NOT_SUPPORTED should ---echo # be emitted. ---error ER_DELAYED_NOT_SUPPORTED -insert delayed into tm values (1); ---echo # Unblock ALTER TABLE. -commit; - ---echo # Connection 'con1'. -connection con1; ---echo # Reaping ALTER TABLE: ---reap - ---echo # Connection 'default'. -connection default; -disconnect con1; -drop tables tm, t1, t2; - - --echo End of 6.0 tests --disable_result_log From be348787eb4acb5eaa1a55971f5030e53b34a8c5 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 17 Sep 2010 17:34:15 -0300 Subject: [PATCH 154/183] Bug#52419: x86 assembly based atomic CAS causes test failures The problem was that the x86 assembly based atomic CAS (compare and swap) implementation could copy the wrong value to the ebx register, where the cmpxchg8b expects to see part of the "comparand" value. Since the original value in the ebx register is saved in the stack (that is, the push instruction causes the stack pointer to change), a wrong offset could be used if the compiler decides to put the source of the comparand value in the stack. The solution is to copy the comparand value directly from memory. Since the comparand value is 64-bits wide, it is copied in two steps over to the ebx and ecx registers. --- include/atomic/x86-gcc.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h index 8baa84e110e..90602ef900c 100644 --- a/include/atomic/x86-gcc.h +++ b/include/atomic/x86-gcc.h @@ -111,9 +111,9 @@ On some platforms (e.g. Mac OS X and Solaris) the ebx register is held as a pointer to the global offset table. Thus we're not allowed to use the b-register on those platforms when compiling - PIC code, to avoid this we push ebx and pop ebx and add a movl - instruction to avoid having ebx in the interface of the assembler - instruction. + PIC code, to avoid this we push ebx and pop ebx. The new value + is copied directly from memory to avoid problems with a implicit + manipulation of the stack pointer by the push. cmpxchg8b works on both 32-bit platforms and 64-bit platforms but the code here is only used on 32-bit platforms, on 64-bit @@ -121,11 +121,13 @@ fine. */ #define make_atomic_cas_body64 \ - int32 ebx=(set & 0xFFFFFFFF), ecx=(set >> 32); \ - asm volatile ("push %%ebx; movl %3, %%ebx;" \ - LOCK_prefix "; cmpxchg8b %0; setz %2; pop %%ebx" \ - : "=m" (*a), "+A" (*cmp), "=c" (ret) \ - : "m" (ebx), "c" (ecx), "m" (*a) \ + asm volatile ("push %%ebx;" \ + "movl (%%ecx), %%ebx;" \ + "movl 4(%%ecx), %%ecx;" \ + LOCK_prefix "; cmpxchg8b %0;" \ + "setz %2; pop %%ebx" \ + : "=m" (*a), "+A" (*cmp), "=c" (ret) \ + : "c" (&set), "m" (*a) \ : "memory", "esp") #endif From 5d06dddff34475c1a2b76be2b16d804e63a2f32b Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Wed, 22 Sep 2010 10:15:41 +0200 Subject: [PATCH 155/183] Bug #56494 Segfault in upgrade_shared_lock_to_exclusive() for REPAIR of merge table Bug #56422 CHECK TABLE run when the table is locked reports corruption along with timeout The crash happened if a table maintenance statement (ANALYZE TABLE, REPAIR TABLE, etc.) was executed on a MERGE table and opening and locking a child table failed. This could for example happen if a child table did not exist or if a lock timeout happened while waiting for a conflicting metadata lock to disappear. Since opening and locking the MERGE table and its children failed, the tables would be closed and the metadata locks released. However, TABLE_LIST::table for the MERGE table would still be set, with its value invalid since the tables had been closed. This caused the table maintenance statement to try to continue and upgrade the metadata lock on the MERGE table. But since the lock already had been released, this caused a segfault. This patch fixes the problem by setting TABLE_LIST::table to NULL if open_and_lock_tables() fails. This prevents maintenance statements from continuing and trying to upgrade the metadata lock. The patch includes a 5.5 version of the fix for Bug #46339 crash on REPAIR TABLE merge table USE_FRM. This bug caused REPAIR TABLE ... USE_FRM to give an assert when used on merge tables. The patch also enables the CHECK TABLE statement for log tables. Before, CHECK TABLE for log tables gave ER_CANT_LOCK_LOG_TABLE, yet still counted the statement as successfully executed. With the changes to table maintenance statement error handling in this patch, CHECK TABLE would no longer be considered as successful in this case. This would have caused upgrade scripts to mistakenly think that the general and slow logs are corrupted and have to be repaired. Enabling CHECK TABLES for log tables prevents this from happening. Finally, the patch changes the error message from "Corrupt" to "Operation failed" for a number of issues not related to table corruption. For example "Lock wait timeout exceeded" and "Deadlock found trying to get lock". Test cases added to merge.test and check.test. --- mysql-test/r/check.result | 16 ++++ mysql-test/r/log_tables_upgrade.result | 8 +- mysql-test/r/merge.result | 88 +++++++++++++++++++- mysql-test/r/myisampack.result | 10 +-- mysql-test/r/mysql_upgrade.result | 48 +++-------- mysql-test/r/mysql_upgrade_ssl.result | 8 +- mysql-test/t/check.test | 24 ++++++ mysql-test/t/merge.test | 108 +++++++++++++++++++++++++ sql/sql_admin.cc | 46 +++++++++-- sql/sql_parse.cc | 2 +- 10 files changed, 295 insertions(+), 63 deletions(-) diff --git a/mysql-test/r/check.result b/mysql-test/r/check.result index 0bff34dba20..ac9c7bca9d7 100644 --- a/mysql-test/r/check.result +++ b/mysql-test/r/check.result @@ -23,3 +23,19 @@ REPAIR TABLE t1; Table Op Msg_type Msg_text test.t1 repair status OK DROP TABLE t1; +# +# Bug#56422 CHECK TABLE run when the table is locked reports corruption +# along with timeout +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(a INT); +LOCK TABLE t1 WRITE; +# Connection con1 +SET lock_wait_timeout= 1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check Error Lock wait timeout exceeded; try restarting transaction +test.t1 check status Operation failed +# Connection default +UNLOCK TABLES; +DROP TABLE t1; diff --git a/mysql-test/r/log_tables_upgrade.result b/mysql-test/r/log_tables_upgrade.result index 5d9be85a48a..814ebd7d5dc 100644 --- a/mysql-test/r/log_tables_upgrade.result +++ b/mysql-test/r/log_tables_upgrade.result @@ -17,9 +17,7 @@ mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK -mysql.general_log -Error : You can't use locks with log tables. -status : OK +mysql.general_log OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -31,9 +29,7 @@ mysql.proc OK mysql.procs_priv OK mysql.renamed_general_log OK mysql.servers OK -mysql.slow_log -Error : You can't use locks with log tables. -status : OK +mysql.slow_log OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index 5d96970ce74..bb6af084f38 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -2358,6 +2358,48 @@ t2 WHERE b SOUNDS LIKE e AND d = 1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables DROP TABLE t2, t1; +# +# Bug#46339 - crash on REPAIR TABLE merge table USE_FRM +# +DROP TABLE IF EXISTS m1, t1; +CREATE TABLE t1 (c1 INT) ENGINE=MYISAM; +CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1) INSERT_METHOD=LAST; +LOCK TABLE m1 READ; +REPAIR TABLE m1 USE_FRM; +Table Op Msg_type Msg_text +test.m1 repair Error Table 'm1' was locked with a READ lock and can't be updated +test.m1 repair status Operation failed +UNLOCK TABLES; +REPAIR TABLE m1 USE_FRM; +Table Op Msg_type Msg_text +test.m1 repair note The storage engine for the table doesn't support repair +DROP TABLE m1,t1; +CREATE TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1); +REPAIR TABLE m1 USE_FRM; +Table Op Msg_type Msg_text +test.m1 repair Warning Can't open table +test.m1 repair error Corrupt +CREATE TABLE t1 (f1 BIGINT) ENGINE = MyISAM; +REPAIR TABLE m1 USE_FRM; +Table Op Msg_type Msg_text +test.m1 repair note The storage engine for the table doesn't support repair +REPAIR TABLE m1; +Table Op Msg_type Msg_text +test.m1 repair note The storage engine for the table doesn't support repair +DROP TABLE m1, t1; +CREATE TEMPORARY TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1); +REPAIR TABLE m1 USE_FRM; +Table Op Msg_type Msg_text +test.m1 repair Error Table 'test.m1' doesn't exist +test.m1 repair error Corrupt +CREATE TEMPORARY TABLE t1 (f1 BIGINT) ENGINE=MyISAM; +REPAIR TABLE m1 USE_FRM; +Table Op Msg_type Msg_text +m1 repair error Cannot repair temporary table from .frm file +REPAIR TABLE m1; +Table Op Msg_type Msg_text +test.m1 repair note The storage engine for the table doesn't support repair +DROP TABLE m1, t1; End of 5.1 tests # # An additional test case for Bug#27430 Crash in subquery code @@ -2677,7 +2719,7 @@ OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize Error Table 'test.t_not_exists' doesn't exist test.t1 optimize Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -test.t1 optimize note The storage engine for the table doesn't support optimize +test.t1 optimize error Corrupt DROP TABLE t1; # # Bug#36171 - CREATE TEMPORARY TABLE and MERGE engine @@ -3575,4 +3617,48 @@ ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'm1 drop view v1; drop temporary table tmp; drop table t1, t2, t3, m1, m2; +# +# Bug#56494 Segfault in upgrade_shared_lock_to_exclusive() for +# REPAIR of merge table +# +DROP TABLE IF EXISTS t1, t2, t_not_exists; +CREATE TABLE t1(a INT); +ALTER TABLE t1 engine= MERGE UNION (t_not_exists); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze Error Table 'test.t_not_exists' doesn't exist +test.t1 analyze Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +test.t1 analyze error Corrupt +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check Error Table 'test.t_not_exists' doesn't exist +test.t1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +test.t1 check error Corrupt +CHECKSUM TABLE t1; +Table Checksum +test.t1 NULL +Warnings: +Error 1146 Table 'test.t_not_exists' doesn't exist +Error 1168 Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize Error Table 'test.t_not_exists' doesn't exist +test.t1 optimize Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +test.t1 optimize error Corrupt +REPAIR TABLE t1; +Table Op Msg_type Msg_text +test.t1 repair Error Table 'test.t_not_exists' doesn't exist +test.t1 repair Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +test.t1 repair error Corrupt +REPAIR TABLE t1 USE_FRM; +Table Op Msg_type Msg_text +test.t1 repair Warning Can't open table +test.t1 repair error Corrupt +DROP TABLE t1; +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT) engine= MERGE UNION (t1); +REPAIR TABLE t2 USE_FRM; +Table Op Msg_type Msg_text +test.t2 repair note The storage engine for the table doesn't support repair +DROP TABLE t1, t2; End of 6.0 tests diff --git a/mysql-test/r/myisampack.result b/mysql-test/r/myisampack.result index dd14c31f32e..91700701139 100644 --- a/mysql-test/r/myisampack.result +++ b/mysql-test/r/myisampack.result @@ -46,14 +46,12 @@ insert into t1 select * from t1; flush tables; optimize table t1; Table Op Msg_type Msg_text -test.t1 optimize error Table 'test.t1' is read only -Warnings: -Error 1036 Table 't1' is read only +test.t1 optimize Error Table 't1' is read only +test.t1 optimize status Operation failed repair table t1; Table Op Msg_type Msg_text -test.t1 repair error Table 'test.t1' is read only -Warnings: -Error 1036 Table 't1' is read only +test.t1 repair Error Table 't1' is read only +test.t1 repair status Operation failed drop table t1; # # BUG#41541 - Valgrind warnings on packed MyISAM table diff --git a/mysql-test/r/mysql_upgrade.result b/mysql-test/r/mysql_upgrade.result index 58f6ffd4040..5252d5f0c17 100644 --- a/mysql-test/r/mysql_upgrade.result +++ b/mysql-test/r/mysql_upgrade.result @@ -5,9 +5,7 @@ mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK -mysql.general_log -Error : You can't use locks with log tables. -status : OK +mysql.general_log OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -18,9 +16,7 @@ mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.servers OK -mysql.slow_log -Error : You can't use locks with log tables. -status : OK +mysql.slow_log OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK @@ -37,9 +33,7 @@ mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK -mysql.general_log -Error : You can't use locks with log tables. -status : OK +mysql.general_log OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -50,9 +44,7 @@ mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.servers OK -mysql.slow_log -Error : You can't use locks with log tables. -status : OK +mysql.slow_log OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK @@ -69,9 +61,7 @@ mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK -mysql.general_log -Error : You can't use locks with log tables. -status : OK +mysql.general_log OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -82,9 +72,7 @@ mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.servers OK -mysql.slow_log -Error : You can't use locks with log tables. -status : OK +mysql.slow_log OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK @@ -103,9 +91,7 @@ mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK -mysql.general_log -Error : You can't use locks with log tables. -status : OK +mysql.general_log OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -116,9 +102,7 @@ mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.servers OK -mysql.slow_log -Error : You can't use locks with log tables. -status : OK +mysql.slow_log OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK @@ -141,9 +125,7 @@ mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK -mysql.general_log -Error : You can't use locks with log tables. -status : OK +mysql.general_log OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -154,9 +136,7 @@ mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.servers OK -mysql.slow_log -Error : You can't use locks with log tables. -status : OK +mysql.slow_log OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK @@ -182,9 +162,7 @@ mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK -mysql.general_log -Error : You can't use locks with log tables. -status : OK +mysql.general_log OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -195,9 +173,7 @@ mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.servers OK -mysql.slow_log -Error : You can't use locks with log tables. -status : OK +mysql.slow_log OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK diff --git a/mysql-test/r/mysql_upgrade_ssl.result b/mysql-test/r/mysql_upgrade_ssl.result index f1229c4a405..b89862966b5 100644 --- a/mysql-test/r/mysql_upgrade_ssl.result +++ b/mysql-test/r/mysql_upgrade_ssl.result @@ -7,9 +7,7 @@ mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK -mysql.general_log -Error : You can't use locks with log tables. -status : OK +mysql.general_log OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -20,9 +18,7 @@ mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.servers OK -mysql.slow_log -Error : You can't use locks with log tables. -status : OK +mysql.slow_log OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK diff --git a/mysql-test/t/check.test b/mysql-test/t/check.test index ff23b352b5a..2234d2c680f 100644 --- a/mysql-test/t/check.test +++ b/mysql-test/t/check.test @@ -53,5 +53,29 @@ REPAIR TABLE t1; DROP TABLE t1; +--echo # +--echo # Bug#56422 CHECK TABLE run when the table is locked reports corruption +--echo # along with timeout +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1(a INT); +LOCK TABLE t1 WRITE; + +--echo # Connection con1 +connect(con1, localhost, root); +SET lock_wait_timeout= 1; +CHECK TABLE t1; + +--echo # Connection default +connection default; +UNLOCK TABLES; +DROP TABLE t1; +disconnect con1; + + # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 51c4ca51a29..34d0b5bf237 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -1734,6 +1734,84 @@ t2 WHERE b SOUNDS LIKE e AND d = 1; DROP TABLE t2, t1; +--echo # +--echo # Bug#46339 - crash on REPAIR TABLE merge table USE_FRM +--echo # +--disable_warnings +DROP TABLE IF EXISTS m1, t1; +--enable_warnings +# +# Test derived from a proposal of Shane Bester. +# +CREATE TABLE t1 (c1 INT) ENGINE=MYISAM; +CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1) INSERT_METHOD=LAST; +# +# REPAIR ... USE_FRM with LOCK TABLES. +# +LOCK TABLE m1 READ; +REPAIR TABLE m1 USE_FRM; +UNLOCK TABLES; +# +# REPAIR ... USE_FRM without LOCK TABLES. +# +# This statement crashed the server (Bug#46339). +# +REPAIR TABLE m1 USE_FRM; +# +DROP TABLE m1,t1; +# +# Test derived from a proposal of Matthias Leich. +# +# Base table is missing. +# +CREATE TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1); +# +# This statement crashed the server (Bug#46339). +# +REPAIR TABLE m1 USE_FRM; +# +# Create base table. +# +CREATE TABLE t1 (f1 BIGINT) ENGINE = MyISAM; +# +# This statement crashed the server (Bug#46339). +# +REPAIR TABLE m1 USE_FRM; +# +# Normal repair as reference. +# +REPAIR TABLE m1; +# +# Cleanup. +# +DROP TABLE m1, t1; +# +# Same with temporary tables. +# +# Base table is missing. +# +CREATE TEMPORARY TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1); +# +# This statement crashed the server (Bug#46339). +# +REPAIR TABLE m1 USE_FRM; +# +# Create base table. +# +CREATE TEMPORARY TABLE t1 (f1 BIGINT) ENGINE=MyISAM; +# +# This statement crashed the server (Bug#46339). +# +REPAIR TABLE m1 USE_FRM; +# +# Normal repair as reference. +# +REPAIR TABLE m1; +# +# Cleanup. +# +DROP TABLE m1, t1; + --echo End of 5.1 tests --echo # @@ -2668,6 +2746,36 @@ drop temporary table tmp; drop table t1, t2, t3, m1, m2; +--echo # +--echo # Bug#56494 Segfault in upgrade_shared_lock_to_exclusive() for +--echo # REPAIR of merge table +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1, t2, t_not_exists; +--enable_warnings + +CREATE TABLE t1(a INT); +ALTER TABLE t1 engine= MERGE UNION (t_not_exists); +# This caused the segfault +ANALYZE TABLE t1; +CHECK TABLE t1; +CHECKSUM TABLE t1; +OPTIMIZE TABLE t1; +REPAIR TABLE t1; + +# This caused an assert +REPAIR TABLE t1 USE_FRM; + +DROP TABLE t1; +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT) engine= MERGE UNION (t1); +# This caused an assert +REPAIR TABLE t2 USE_FRM; + +DROP TABLE t1, t2; + + --echo End of 6.0 tests --disable_result_log diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 1f96f1cf0e4..21a05a5baca 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -111,9 +111,6 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list, table= &tmp_table; } - /* A MERGE table must not come here. */ - DBUG_ASSERT(table->file->ht->db_type != DB_TYPE_MRG_MYISAM); - /* REPAIR TABLE ... USE_FRM for temporary tables makes little sense. */ @@ -151,6 +148,9 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list, if (!ext[0] || !ext[1]) goto end; // No data file + /* A MERGE table must not come here. */ + DBUG_ASSERT(table->file->ht->db_type != DB_TYPE_MRG_MYISAM); + // Name of data file strxmov(from, table->s->normalized_path.str, ext[1], NullS); if (!mysql_file_stat(key_file_misc, from, &stat_info, MYF(0))) @@ -231,6 +231,26 @@ end: } +/** + Check if a given error is something that could occur during + open_and_lock_tables() that does not indicate table corruption. + + @param sql_errno Error number to check. + + @retval TRUE Error does not indicate table corruption. + @retval FALSE Error could indicate table corruption. +*/ + +static inline bool table_not_corrupt_error(uint sql_errno) +{ + return (sql_errno == ER_NO_SUCH_TABLE || + sql_errno == ER_FILE_NOT_FOUND || + sql_errno == ER_LOCK_WAIT_TIMEOUT || + sql_errno == ER_LOCK_DEADLOCK || + sql_errno == ER_CANT_LOCK_LOG_TABLE || + sql_errno == ER_OPEN_AS_READONLY); +} + /* RETURN VALUES @@ -311,7 +331,13 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, lex->query_tables= table; lex->query_tables_last= &table->next_global; lex->query_tables_own_last= 0; - thd->no_warnings_for_error= no_warnings_for_error; + /* + Under locked tables, we know that the table can be opened, + so any errors opening the table are logical errors. + In these cases it makes sense to report them. + */ + if (!thd->locked_tables_mode) + thd->no_warnings_for_error= no_warnings_for_error; if (view_operator_func == NULL) table->required_type=FRMTYPE_TABLE; @@ -320,6 +346,14 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, table->next_global= save_next_global; table->next_local= save_next_local; thd->open_options&= ~extra_open_options; + + /* + If open_and_lock_tables() failed, close_thread_tables() will close + the table and table->table can therefore be invalid. + */ + if (open_error) + table->table= NULL; + /* Under locked tables, we know that the table can be opened, so any errors opening the table are logical errors. @@ -418,9 +452,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_VIEW_CHECKSUM, ER(ER_VIEW_CHECKSUM)); if (thd->stmt_da->is_error() && - (thd->stmt_da->sql_errno() == ER_NO_SUCH_TABLE || - thd->stmt_da->sql_errno() == ER_FILE_NOT_FOUND)) - /* A missing table is just issued as a failed command */ + table_not_corrupt_error(thd->stmt_da->sql_errno())) result_code= HA_ADMIN_FAILED; else /* Default failure code is corrupt table */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index aa9d29f3d07..23a5f35d967 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -401,6 +401,7 @@ void init_update_queries(void) sql_command_flags[SQLCOM_REPAIR]= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS; sql_command_flags[SQLCOM_OPTIMIZE]|= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS; sql_command_flags[SQLCOM_ANALYZE]= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS; + sql_command_flags[SQLCOM_CHECK]= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS; sql_command_flags[SQLCOM_CREATE_USER]|= CF_AUTO_COMMIT_TRANS; sql_command_flags[SQLCOM_DROP_USER]|= CF_AUTO_COMMIT_TRANS; @@ -414,7 +415,6 @@ void init_update_queries(void) sql_command_flags[SQLCOM_FLUSH]= CF_AUTO_COMMIT_TRANS; sql_command_flags[SQLCOM_RESET]= CF_AUTO_COMMIT_TRANS; - sql_command_flags[SQLCOM_CHECK]= CF_AUTO_COMMIT_TRANS; sql_command_flags[SQLCOM_CREATE_SERVER]= CF_AUTO_COMMIT_TRANS; sql_command_flags[SQLCOM_ALTER_SERVER]= CF_AUTO_COMMIT_TRANS; sql_command_flags[SQLCOM_DROP_SERVER]= CF_AUTO_COMMIT_TRANS; From c7ccc7265e8ff1a4bca27928a36d434574551fec Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Wed, 22 Sep 2010 19:53:06 +0700 Subject: [PATCH 156/183] Fixed bug#56821 - failure to start the MySQL Service. --- sql/log.cc | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 503b3bb5cff..56f151fe2ab 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -5072,10 +5072,32 @@ extern "C" my_bool reopen_fstreams(const char *filename, FILE *outstream, FILE *errstream) { int handle_fd; - int stream_fd; + int err_fd, out_fd; HANDLE osfh; - DBUG_ASSERT(filename && (outstream || errstream)); + DBUG_ASSERT(filename && errstream); + + // Services don't have stdout/stderr on Windows, so _fileno returns -1. + err_fd= _fileno(errstream); + if (err_fd < 0) + { + if (!freopen(filename, "a+", errstream)) + return TRUE; + + setbuf(errstream, NULL); + err_fd= _fileno(errstream); + } + + if (outstream) + { + out_fd= _fileno(outstream); + if (out_fd < 0) + { + if (!freopen(filename, "a+", outstream)) + return TRUE; + out_fd= _fileno(outstream); + } + } if ((osfh= CreateFile(filename, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | @@ -5091,24 +5113,16 @@ extern "C" my_bool reopen_fstreams(const char *filename, return TRUE; } - if (outstream) + if (_dup2(handle_fd, err_fd) < 0) { - stream_fd= _fileno(outstream); - if (_dup2(handle_fd, stream_fd) < 0) - { - CloseHandle(osfh); - return TRUE; - } + CloseHandle(osfh); + return TRUE; } - if (errstream) + if (outstream && _dup2(handle_fd, out_fd) < 0) { - stream_fd= _fileno(errstream); - if (_dup2(handle_fd, stream_fd) < 0) - { - CloseHandle(osfh); - return TRUE; - } + CloseHandle(osfh); + return TRUE; } _close(handle_fd); From a1f1e77c38147778ac76b3232ca10861cffb3dad Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 22 Sep 2010 23:33:18 +0400 Subject: [PATCH 157/183] Bug #56709: Memory leaks at running the 5.1 test suite Fixed a number of memory leaks discovered by valgrind. --- dbug/dbug.c | 13 ++++--------- mysql-test/r/partition_error.result | 10 ++++++++++ mysql-test/r/variables_debug.result | 13 +++++++++++++ mysql-test/t/partition_error.test | 14 ++++++++++++++ mysql-test/t/variables_debug.test | 13 +++++++++++++ sql/item_timefunc.cc | 4 ++-- sql/item_timefunc.h | 1 - sql/sql_load.cc | 12 +++++------- 8 files changed, 61 insertions(+), 19 deletions(-) diff --git a/dbug/dbug.c b/dbug/dbug.c index 8fa5ed9af6b..76723fa8767 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -455,13 +455,8 @@ static void DbugParse(CODE_STATE *cs, const char *control) rel= control[0] == '+' || control[0] == '-'; if ((!rel || (!stack->out_file && !stack->next))) { - /* - We need to free what's already in init_settings, because unlike - the thread related stack frames there's a chance that something - is in these variables already. - */ - if (stack == &init_settings) - FreeState(cs, stack, 0); + /* Free memory associated with the state before resetting its members */ + FreeState(cs, stack, 0); stack->flags= 0; stack->delay= 0; stack->maxdepth= 0; @@ -1447,8 +1442,8 @@ static void PushState(CODE_STATE *cs) struct settings *new_malloc; new_malloc= (struct settings *) DbugMalloc(sizeof(struct settings)); + bzero(new_malloc, sizeof(struct settings)); new_malloc->next= cs->stack; - new_malloc->out_file= NULL; cs->stack= new_malloc; } @@ -1957,7 +1952,7 @@ static FILE *OpenProfile(CODE_STATE *cs, const char *name) static void DBUGCloseFile(CODE_STATE *cs, FILE *fp) { - if (fp != stderr && fp != stdout && fclose(fp) == EOF) + if (fp != NULL && fp != stderr && fp != stdout && fclose(fp) == EOF) { pthread_mutex_lock(&THR_LOCK_dbug); (void) fprintf(cs->stack->out_file, ERR_CLOSE, cs->process); diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result index 16428fba4d9..ea74f476ceb 100644 --- a/mysql-test/r/partition_error.result +++ b/mysql-test/r/partition_error.result @@ -1008,4 +1008,14 @@ PARTITION p VALUES LESS THAN (1219089600), PARTITION pmax VALUES LESS THAN MAXVALUE); ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed DROP TABLE old; +# +# Bug #56709: Memory leaks at running the 5.1 test suite +# +CREATE TABLE t1 (a TIMESTAMP NOT NULL PRIMARY KEY); +ALTER TABLE t1 +PARTITION BY RANGE (EXTRACT(DAY FROM a)) ( +PARTITION p VALUES LESS THAN (18), +PARTITION pmax VALUES LESS THAN MAXVALUE); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/r/variables_debug.result b/mysql-test/r/variables_debug.result index d578fa957fc..41d77007b26 100644 --- a/mysql-test/r/variables_debug.result +++ b/mysql-test/r/variables_debug.result @@ -24,4 +24,17 @@ SELECT @@global.debug; @@global.debug SET GLOBAL debug=@old_debug; +# +# Bug #56709: Memory leaks at running the 5.1 test suite +# +SET @old_local_debug = @@debug; +SET @@debug='d,foo'; +SELECT @@debug; +@@debug +d,foo +SET @@debug=''; +SELECT @@debug; +@@debug + +SET @@debug = @old_local_debug; End of 5.1 tests diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index 434392c2e28..d3f10628254 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -1252,4 +1252,18 @@ PARTITION pmax VALUES LESS THAN MAXVALUE); DROP TABLE old; +--echo # +--echo # Bug #56709: Memory leaks at running the 5.1 test suite +--echo # + +CREATE TABLE t1 (a TIMESTAMP NOT NULL PRIMARY KEY); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +ALTER TABLE t1 +PARTITION BY RANGE (EXTRACT(DAY FROM a)) ( +PARTITION p VALUES LESS THAN (18), +PARTITION pmax VALUES LESS THAN MAXVALUE); + +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/mysql-test/t/variables_debug.test b/mysql-test/t/variables_debug.test index 12f5d2e6ca5..e6f1bbddc2a 100644 --- a/mysql-test/t/variables_debug.test +++ b/mysql-test/t/variables_debug.test @@ -25,4 +25,17 @@ SELECT @@global.debug; SET GLOBAL debug=@old_debug; +--echo # +--echo # Bug #56709: Memory leaks at running the 5.1 test suite +--echo # + +SET @old_local_debug = @@debug; + +SET @@debug='d,foo'; +SELECT @@debug; +SET @@debug=''; +SELECT @@debug; + +SET @@debug = @old_local_debug; + --echo End of 5.1 tests diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index dff4d20f347..103bd96efd4 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2270,8 +2270,6 @@ void Item_extract::print(String *str, enum_query_type query_type) void Item_extract::fix_length_and_dec() { - value.alloc(32); // alloc buffer - maybe_null=1; // If wrong date switch (int_type) { case INTERVAL_YEAR: max_length=4; date_value=1; break; @@ -2314,6 +2312,8 @@ longlong Item_extract::val_int() } else { + char buf[40]; + String value(buf, sizeof(buf), &my_charset_bin);; String *res= args[0]->val_str(&value); if (!res || str_to_time_with_warn(res->ptr(), res->length(), <ime)) { diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 11eed70f399..ef86406e1be 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -702,7 +702,6 @@ public: class Item_extract :public Item_int_func { - String value; bool date_value; public: const interval_type int_type; // keep it public diff --git a/sql/sql_load.cc b/sql/sql_load.cc index f9386206dce..4b68f2a3821 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -1116,6 +1116,7 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs, MYF(MY_WME))) { my_free((uchar*) buffer,MYF(0)); /* purecov: inspected */ + buffer= NULL; error=1; } else @@ -1142,13 +1143,10 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs, READ_INFO::~READ_INFO() { - if (!error) - { - if (need_end_io_cache) - ::end_io_cache(&cache); - my_free((uchar*) buffer,MYF(0)); - error=1; - } + if (!error && need_end_io_cache) + ::end_io_cache(&cache); + + my_free(buffer, MYF(MY_ALLOW_ZERO_PTR)); } From 9b9299f8d53b8d67b2f39e2526343fd250cd9d3e Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Thu, 23 Sep 2010 11:13:21 +0200 Subject: [PATCH 158/183] Followup to Bug #56422 CHECK TABLE run when the table is locked reports corruption along with timeout This patch updates the result file for the parts.partition_special_innodb test case which was, by mistake, not updated in the original patch. --- mysql-test/suite/parts/r/partition_special_innodb.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/parts/r/partition_special_innodb.result b/mysql-test/suite/parts/r/partition_special_innodb.result index b8dffd61fbe..0738f45b012 100644 --- a/mysql-test/suite/parts/r/partition_special_innodb.result +++ b/mysql-test/suite/parts/r/partition_special_innodb.result @@ -242,7 +242,7 @@ ERROR HY000: Lock wait timeout exceeded; try restarting transaction CHECK TABLE t1; Table Op Msg_type Msg_text test.t1 check Error Lock wait timeout exceeded; try restarting transaction -test.t1 check error Corrupt +test.t1 check status Operation failed UNLOCK TABLES; DROP TABLE t1; CREATE TABLE t2 ( i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f INT ) From 11c4d8ba1f66a3173c51b6be678b9f2607adb4cc Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Fri, 24 Sep 2010 09:18:16 +0200 Subject: [PATCH 159/183] Bug #54920 Stored functions are allowed in HANDLER statements, but broken. Before this patch, it was allowed to use stored functions in HANDLER ... READ statements. The problem was that this functionality was not really supported by the code. Proper locking would for example not be performed, and it was also possible to break replication by having stored functions that performed updates. This patch disallows the use of stored functions in HANDLER ... READ. Any such statement will now give an ER_NOT_SUPPORTED_YET error. This is an incompatible change and should be reflected in the documentation. Test case added to handler_myisam/handler_innodb.test. --- mysql-test/include/handler.inc | 25 ++++++++++++++++++++++++- mysql-test/r/handler_innodb.result | 17 ++++++++++++++++- mysql-test/r/handler_myisam.result | 17 ++++++++++++++++- sql/sql_yacc.yy | 7 +++++++ 4 files changed, 63 insertions(+), 3 deletions(-) diff --git a/mysql-test/include/handler.inc b/mysql-test/include/handler.inc index 65e9e61d077..b86d5d9287f 100644 --- a/mysql-test/include/handler.inc +++ b/mysql-test/include/handler.inc @@ -1809,9 +1809,32 @@ CREATE TABLE t1(a INT); INSERT INTO t1 VALUES (1); HANDLER t1 OPEN; # This used to cause the assert ---error ER_NO_SUCH_TABLE +--error ER_NOT_SUPPORTED_YET HANDLER t1 READ FIRST WHERE f1() = 1; HANDLER t1 CLOSE; DROP FUNCTION f1; DROP TABLE t1; + + +--echo # +--echo # Bug#54920 Stored functions are allowed in HANDLER statements, +--echo # but broken. +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +--enable_warnings + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +CREATE FUNCTION f1() RETURNS INT RETURN 1; +HANDLER t1 OPEN; + +--error ER_NOT_SUPPORTED_YET +HANDLER t1 READ FIRST WHERE f1() = 1; + +HANDLER t1 CLOSE; +DROP FUNCTION f1; +DROP TABLE t1; diff --git a/mysql-test/r/handler_innodb.result b/mysql-test/r/handler_innodb.result index 121cfa89f1c..66914285733 100644 --- a/mysql-test/r/handler_innodb.result +++ b/mysql-test/r/handler_innodb.result @@ -1726,7 +1726,22 @@ CREATE TABLE t1(a INT); INSERT INTO t1 VALUES (1); HANDLER t1 OPEN; HANDLER t1 READ FIRST WHERE f1() = 1; -ERROR 42S02: Table 'test.t2' doesn't exist +ERROR 42000: This version of MySQL doesn't yet support 'stored functions in HANDLER ... READ' +HANDLER t1 CLOSE; +DROP FUNCTION f1; +DROP TABLE t1; +# +# Bug#54920 Stored functions are allowed in HANDLER statements, +# but broken. +# +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +CREATE FUNCTION f1() RETURNS INT RETURN 1; +HANDLER t1 OPEN; +HANDLER t1 READ FIRST WHERE f1() = 1; +ERROR 42000: This version of MySQL doesn't yet support 'stored functions in HANDLER ... READ' HANDLER t1 CLOSE; DROP FUNCTION f1; DROP TABLE t1; diff --git a/mysql-test/r/handler_myisam.result b/mysql-test/r/handler_myisam.result index fd08fd12f15..d5d43ca0717 100644 --- a/mysql-test/r/handler_myisam.result +++ b/mysql-test/r/handler_myisam.result @@ -1722,7 +1722,22 @@ CREATE TABLE t1(a INT); INSERT INTO t1 VALUES (1); HANDLER t1 OPEN; HANDLER t1 READ FIRST WHERE f1() = 1; -ERROR 42S02: Table 'test.t2' doesn't exist +ERROR 42000: This version of MySQL doesn't yet support 'stored functions in HANDLER ... READ' +HANDLER t1 CLOSE; +DROP FUNCTION f1; +DROP TABLE t1; +# +# Bug#54920 Stored functions are allowed in HANDLER statements, +# but broken. +# +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +CREATE FUNCTION f1() RETURNS INT RETURN 1; +HANDLER t1 OPEN; +HANDLER t1 READ FIRST WHERE f1() = 1; +ERROR 42000: This version of MySQL doesn't yet support 'stored functions in HANDLER ... READ' HANDLER t1 CLOSE; DROP FUNCTION f1; DROP TABLE t1; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 2ee2d83f9d2..006a416d9e4 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -13245,6 +13245,13 @@ handler: handler_read_or_scan where_clause opt_limit_clause { Lex->expr_allows_subselect= TRUE; + /* Stored functions are not supported for HANDLER READ. */ + if (Lex->uses_stored_routines()) + { + my_error(ER_NOT_SUPPORTED_YET, MYF(0), + "stored functions in HANDLER ... READ"); + MYSQL_YYABORT; + } } ; From 71affc142d0b77dcfaa54c7d1d71666adf131b4e Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Fri, 24 Sep 2010 10:44:09 +0200 Subject: [PATCH 160/183] Bug #56678 Valgrind warnings from binlog.binlog_unsafe After the patch for Bug#54579, multi inserts done with INSERT DELAYED are binlogged as normal INSERT. During processing of the statement, a new query string without the DELAYED keyword is made. The problem was that this new string was incorrectly made when the INSERT DELAYED was part of a prepared statement - data was read outside the allocated buffer. The reason for this bug was that a pointer to the position of the DELAYED keyword inside the query string was stored when parsing the statement. This pointer was then later (at runtime) used (via pointer subtraction) to find the number of characters to skip when making a new query string without DELAYED. But when the statement was re-executed as part of a prepared statement, the original pointer would be invalid and the pointer subtraction would give a wrong/random result. This patch fixes the problem by instead storing the offsets from the beginning of the query string to the start and end of the DELAYED keyword. These values will not depend on the memory position of the query string at runtime and therefore not give wrong results when the statement is executed in a prepared statement. This bug was a regression introduced by the patch for Bug#54579. No test case added as this bug is already covered by the existing binlog.binlog_unsafe test case when running with valgrind. --- sql/sql_insert.cc | 12 +++++------- sql/sql_lex.h | 12 ++++++++---- sql/sql_yacc.yy | 10 ++++++++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index ad324fed4fe..cccb715bd5e 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -634,14 +634,12 @@ bool open_and_lock_for_insert_delayed(THD *thd, TABLE_LIST *table_list) static int create_insert_stmt_from_insert_delayed(THD *thd, String *buf) { - /* Append the part of thd->query before "DELAYED" keyword */ - if (buf->append(thd->query(), - thd->lex->keyword_delayed_begin - thd->query())) + /* Make a copy of thd->query() and then remove the "DELAYED" keyword */ + if (buf->append(thd->query()) || + buf->replace(thd->lex->keyword_delayed_begin_offset, + thd->lex->keyword_delayed_end_offset - + thd->lex->keyword_delayed_begin_offset, 0)) return 1; - /* Append the part of thd->query after "DELAYED" keyword */ - if (buf->append(thd->lex->keyword_delayed_begin + 7)) - return 1; - return 0; } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 1f4c9420102..2055b609ad5 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -2355,15 +2355,19 @@ struct LEX: public Query_tables_list This pointer is required to add possibly omitted DEFINER-clause to the DDL-statement before dumping it to the binlog. - keyword_delayed_begin points to the begin of the DELAYED keyword in - INSERT DELAYED statement. + keyword_delayed_begin_offset is the offset to the beginning of the DELAYED + keyword in INSERT DELAYED statement. keyword_delayed_end_offset is the + offset to the character right after the DELAYED keyword. */ union { const char *stmt_definition_begin; - const char *keyword_delayed_begin; + uint keyword_delayed_begin_offset; }; - const char *stmt_definition_end; + union { + const char *stmt_definition_end; + uint keyword_delayed_end_offset; + }; /** During name resolution search only in the table list given by diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 006a416d9e4..4bf211bf5c1 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -10447,7 +10447,10 @@ insert_lock_option: | LOW_PRIORITY { $$= TL_WRITE_LOW_PRIORITY; } | DELAYED_SYM { - Lex->keyword_delayed_begin= YYLIP->get_tok_start(); + Lex->keyword_delayed_begin_offset= (uint)(YYLIP->get_tok_start() - + YYTHD->query()); + Lex->keyword_delayed_end_offset= Lex->keyword_delayed_begin_offset + + YYLIP->yyLength() + 1; $$= TL_WRITE_DELAYED; } | HIGH_PRIORITY { $$= TL_WRITE; } @@ -10457,7 +10460,10 @@ replace_lock_option: opt_low_priority { $$= $1; } | DELAYED_SYM { - Lex->keyword_delayed_begin= YYLIP->get_tok_start(); + Lex->keyword_delayed_begin_offset= (uint)(YYLIP->get_tok_start() - + YYTHD->query()); + Lex->keyword_delayed_end_offset= Lex->keyword_delayed_begin_offset + + YYLIP->yyLength() + 1; $$= TL_WRITE_DELAYED; } ; From 3c8814cbc8cf4eb80f1bd0b46ed0c121d88d1a15 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Fri, 24 Sep 2010 11:39:47 +0200 Subject: [PATCH 161/183] Bug#56659: Mismatch of CAPITAL vs small letters in "unified filelist" partitioning output Update to previous patch according to reviewers comments. Removing parts.partition_alter4_innodb from default.experimental (Also closed bug#45299 as a duplicate of bug#56659 as a result of this.) Adding run of tests requiring --big-test flag to default.weekly to keep the coverage. --- mysql-test/collections/default.experimental | 2 -- mysql-test/collections/default.weekly | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental index a8047ae9ed9..ca634d58cea 100644 --- a/mysql-test/collections/default.experimental +++ b/mysql-test/collections/default.experimental @@ -24,8 +24,6 @@ main.sp @solaris # Bug#47791 2010-01-20 alik Several tes main.type_float @freebsd # Bug#38965 2010-05-04 alik test cases gis-rtree, type_float, type_newdecimal fail in embedded server main.wait_timeout @solaris # Bug#51244 2010-04-26 alik wait_timeout fails on OpenSolaris -parts.partition_alter4_innodb # Bug#45299 2010-06-28 alik Test "partition_alter4_innodb" is taking too long, timeout - rpl.rpl_heartbeat_basic # BUG#54820 2010-06-26 alik rpl.rpl_heartbeat_basic fails sporadically again rpl.rpl_heartbeat_2slaves # BUG#43828 2009-10-22 luis fails sporadically rpl.rpl_innodb_bug28430* # Bug#46029 diff --git a/mysql-test/collections/default.weekly b/mysql-test/collections/default.weekly index 452a79eacbd..d874c2f4519 100644 --- a/mysql-test/collections/default.weekly +++ b/mysql-test/collections/default.weekly @@ -1 +1,2 @@ -perl mysql-test-run.pl --timer --force --comment=1st --experimental=collections/default.experimental 1st +perl mysql-test-run.pl --timer --force --comment=1st --experimental=collections/default.experimental 1st +perl mysql-test-run.pl --timer --force --comment=big-tests --experimental=collections/default.experimental --vardir=var-big-tests --big-test --testcase-timeout=60 --suite-timeout=600 parts.part_supported_sql_func_innodb parts.partition_alter1_1_2_innodb parts.partition_alter1_1_2_ndb parts.partition_alter1_1_ndb parts.partition_alter1_2_innodb parts.partition_alter1_2_ndb parts.partition_alter2_1_1_innodb parts.partition_alter2_1_2_innodb parts.partition_alter2_2_2_innodb parts.partition_alter4_innodb main.variables-big rpl_ndb.rpl_truncate_7ndb_2 From f14d8c28961033bf93d33a19519692d346a590b1 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Fri, 24 Sep 2010 19:03:28 +0700 Subject: [PATCH 162/183] Follow-up for Bug#42503: fix a compilation warning. --- sql/sql_cache.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 22bdb24fb16..befeecb1902 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1330,6 +1330,7 @@ end: } +#ifndef EMBEDDED_LIBRARY /** Send a single memory block from the query cache. @@ -1377,6 +1378,7 @@ send_data_in_chunks(NET *net, const uchar *packet, ulong len) return FALSE; } +#endif /* From 77a0ae9a9a1ca649b6b317587cabe0925d2441aa Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 24 Sep 2010 09:36:31 -0300 Subject: [PATCH 163/183] Bug#45288: pb2 returns a lot of compilation warnings on linux Temporarily disable strict aliasing warnings in order to get wider coverage for optimized builds. Once the violations are fixed and false-positives silenced, this flag should be removed. --- config/ac-macros/maintainer.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/ac-macros/maintainer.m4 b/config/ac-macros/maintainer.m4 index 1b7df75d6f7..24be31395f2 100644 --- a/config/ac-macros/maintainer.m4 +++ b/config/ac-macros/maintainer.m4 @@ -16,7 +16,7 @@ AC_DEFUN([MY_MAINTAINER_MODE], [ AC_DEFUN([MY_MAINTAINER_MODE_WARNINGS], [ # Setup GCC warning options. AS_IF([test "$GCC" = "yes"], [ - C_WARNINGS="-Wall -Wextra -Wunused -Wwrite-strings -Werror" + C_WARNINGS="-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror" CXX_WARNINGS="${C_WARNINGS} -Wno-unused-parameter" ]) From afa568c24b3899d096f15041246467920654cbbd Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Fri, 24 Sep 2010 20:26:24 +0400 Subject: [PATCH 164/183] Fix compile warning about passing NULL to non-pointer argument of inline_mysql_mutex_init in sql_base.cc. When initializing LOCK_dd_owns_lock_open mutex pass correct PSI key instead of NULL value. --- .../suite/perfschema/r/dml_setup_instruments.result | 2 +- sql/sql_base.cc | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/perfschema/r/dml_setup_instruments.result b/mysql-test/suite/perfschema/r/dml_setup_instruments.result index 2338252976c..7f203118346 100644 --- a/mysql-test/suite/perfschema/r/dml_setup_instruments.result +++ b/mysql-test/suite/perfschema/r/dml_setup_instruments.result @@ -13,7 +13,7 @@ wait/synch/mutex/sql/LOCK_active_mi YES YES wait/synch/mutex/sql/LOCK_audit_mask YES YES wait/synch/mutex/sql/LOCK_connection_count YES YES wait/synch/mutex/sql/LOCK_crypt YES YES -wait/synch/mutex/sql/LOCK_delayed_create YES YES +wait/synch/mutex/sql/LOCK_dd_owns_lock_open YES YES select * from performance_schema.SETUP_INSTRUMENTS where name like 'Wait/Synch/Rwlock/sql/%' and name not in ('wait/synch/rwlock/sql/CRYPTO_dynlock_value::lock') diff --git a/sql/sql_base.cc b/sql/sql_base.cc index b168f561954..c0ea60cac3b 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -104,9 +104,10 @@ mysql_mutex_t LOCK_dd_owns_lock_open; uint dd_owns_lock_open= 0; #ifdef HAVE_PSI_INTERFACE -static PSI_mutex_key key_LOCK_open; +static PSI_mutex_key key_LOCK_open, key_LOCK_dd_owns_lock_open; static PSI_mutex_info all_tdc_mutexes[]= { - { &key_LOCK_open, "LOCK_open", PSI_FLAG_GLOBAL } + { &key_LOCK_open, "LOCK_open", PSI_FLAG_GLOBAL }, + { &key_LOCK_dd_owns_lock_open, "LOCK_dd_owns_lock_open", PSI_FLAG_GLOBAL } }; /** @@ -300,7 +301,8 @@ bool table_def_init(void) init_tdc_psi_keys(); #endif mysql_mutex_init(key_LOCK_open, &LOCK_open, MY_MUTEX_INIT_FAST); - mysql_mutex_init(NULL, &LOCK_dd_owns_lock_open, MY_MUTEX_INIT_FAST); + mysql_mutex_init(key_LOCK_dd_owns_lock_open, &LOCK_dd_owns_lock_open, + MY_MUTEX_INIT_FAST); oldest_unused_share= &end_of_unused_share; end_of_unused_share.prev= &oldest_unused_share; From 5713e1398cc1541318e76e8f4dbfed0fc241dd21 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 24 Sep 2010 17:04:36 -0300 Subject: [PATCH 165/183] Bug#45288: pb2 returns a lot of compilation warnings on linux Use UNINIT_VAR workaround instead of LINT_INIT. The former is also used in non-debug builds as it doesn't cause changes. --- mysys/my_getopt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 4faaadb3f70..2ea39080cff 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -153,7 +153,7 @@ int handle_options(int *argc, char ***argv, const struct my_option *longopts, my_get_one_option get_one_option) { - uint opt_found, argvpos= 0, length; + uint UNINIT_VAR(opt_found), argvpos= 0, length; my_bool end_of_options= 0, must_be_var, set_maximum_value, option_is_loose; char **pos, **pos_end, *optend, *opt_str, key_name[FN_REFLEN]; @@ -163,7 +163,6 @@ int handle_options(int *argc, char ***argv, int error, i; my_bool is_cmdline_arg= 1; - LINT_INIT(opt_found); /* handle_options() assumes arg0 (program name) always exists */ DBUG_ASSERT(argc && *argc >= 1); DBUG_ASSERT(argv && *argv); From d47e8991cb7c950d5cf22b864f3dbd257b2b2dad Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 24 Sep 2010 19:13:51 -0300 Subject: [PATCH 166/183] Bug#45288: pb2 returns a lot of compilation warnings on linux Use UNINIT_VAR workaround instead of LINT_INIT. The former can also be used to silence false-positives in non-debug builds as it actually does not cause new code to be generated. --- mysys/my_getopt.c | 3 +-- storage/myisam/mi_range.c | 3 +-- storage/myisam/mi_search.c | 10 +++------- storage/myisam/rt_index.c | 8 ++------ storage/myisam/rt_split.c | 11 +++-------- 5 files changed, 10 insertions(+), 25 deletions(-) diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 0327db33e98..069626ba004 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -112,7 +112,7 @@ int handle_options(int *argc, char ***argv, const struct my_option *longopts, my_get_one_option get_one_option) { - uint opt_found, argvpos= 0, length; + uint UNINIT_VAR(opt_found), argvpos= 0, length; my_bool end_of_options= 0, must_be_var, set_maximum_value, option_is_loose; char **pos, **pos_end, *optend, *opt_str, key_name[FN_REFLEN]; @@ -121,7 +121,6 @@ int handle_options(int *argc, char ***argv, void *value; int error, i; - LINT_INIT(opt_found); /* handle_options() assumes arg0 (program name) always exists */ DBUG_ASSERT(argc && *argc >= 1); DBUG_ASSERT(argv && *argv); diff --git a/storage/myisam/mi_range.c b/storage/myisam/mi_range.c index dc6dc9d62b7..e4205f36557 100644 --- a/storage/myisam/mi_range.c +++ b/storage/myisam/mi_range.c @@ -193,12 +193,11 @@ static double _mi_search_pos(register MI_INFO *info, register my_off_t pos) { int flag; - uint nod_flag,keynr,max_keynr; + uint nod_flag,keynr,UNINIT_VAR(max_keynr); my_bool after_key; uchar *keypos,*buff; double offset; DBUG_ENTER("_mi_search_pos"); - LINT_INIT(max_keynr); if (pos == HA_OFFSET_ERROR) DBUG_RETURN(0.5); diff --git a/storage/myisam/mi_search.c b/storage/myisam/mi_search.c index 9c842fba544..66ea82b7643 100644 --- a/storage/myisam/mi_search.c +++ b/storage/myisam/mi_search.c @@ -296,9 +296,9 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, flag is the value returned by ha_key_cmp and as treated as final */ int flag=0, my_flag=-1; - uint nod_flag, length, len, matched, cmplen, kseg_len; - uint prefix_len,suffix_len; - int key_len_skip, seg_len_pack, key_len_left; + uint nod_flag, UNINIT_VAR(length), len, matched, cmplen, kseg_len; + uint UNINIT_VAR(prefix_len), suffix_len; + int key_len_skip, UNINIT_VAR(seg_len_pack), key_len_left; uchar *end, *kseg, *vseg; uchar *sort_order=keyinfo->seg->charset->sort_order; uchar tt_buff[MI_MAX_KEY_BUFF+2], *t_buff=tt_buff+2; @@ -308,10 +308,6 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, uint length_pack; DBUG_ENTER("_mi_prefix_search"); - LINT_INIT(length); - LINT_INIT(prefix_len); - LINT_INIT(seg_len_pack); - t_buff[0]=0; /* Avoid bugs */ end= page+mi_getint(page); nod_flag=mi_test_if_nod(page); diff --git a/storage/myisam/rt_index.c b/storage/myisam/rt_index.c index 410badd3145..3f712c2dd06 100644 --- a/storage/myisam/rt_index.c +++ b/storage/myisam/rt_index.c @@ -481,17 +481,13 @@ static uchar *rtree_pick_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, uint key_length, uchar *page_buf, uint nod_flag) { double increase; - double best_incr; + double UNINIT_VAR(best_incr); double area; - double best_area; + double UNINIT_VAR(best_area); uchar *best_key= NULL; uchar *k = rt_PAGE_FIRST_KEY(page_buf, nod_flag); uchar *last = rt_PAGE_END(page_buf); - LINT_INIT(best_area); - LINT_INIT(best_key); - LINT_INIT(best_incr); - for (; k < last; k = rt_PAGE_NEXT_KEY(k, key_length, nod_flag)) { /* The following is safe as -1.0 is an exact number */ diff --git a/storage/myisam/rt_split.c b/storage/myisam/rt_split.c index 03d22de68fa..0b7cc43e062 100644 --- a/storage/myisam/rt_split.c +++ b/storage/myisam/rt_split.c @@ -178,18 +178,13 @@ static int split_rtree_node(SplitStruct *node, int n_entries, double **d_buffer, int n_dim) { SplitStruct *cur; - SplitStruct *a; - SplitStruct *b; + SplitStruct *UNINIT_VAR(a), *UNINIT_VAR(b); double *g1 = reserve_coords(d_buffer, n_dim); double *g2 = reserve_coords(d_buffer, n_dim); - SplitStruct *next; - int next_node; + SplitStruct *UNINIT_VAR(next); + int UNINIT_VAR(next_node); int i; SplitStruct *end = node + n_entries; - LINT_INIT(a); - LINT_INIT(b); - LINT_INIT(next); - LINT_INIT(next_node); if (all_size < min_size * 2) { From 4a2dd398e20dced5ba3bcb0763a5351687da69bb Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Mon, 27 Sep 2010 15:18:10 +0500 Subject: [PATCH 167/183] log_tables_debug.test fix. per-file comments: mysql-test/t/log_tables_debug.test This test shouldn't be run at the embedded server. --- mysql-test/t/log_tables_debug.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/t/log_tables_debug.test b/mysql-test/t/log_tables_debug.test index 19a62614608..78a1289b689 100644 --- a/mysql-test/t/log_tables_debug.test +++ b/mysql-test/t/log_tables_debug.test @@ -7,6 +7,7 @@ # changed (see explanation in log_state.test) let $fixed_bug38124 = 0; +--source include/not_embedded.inc --source include/have_debug.inc # Several subtests modify global variables. Save the initial values only here, From 68e34ab13344a6ebefa6f9ba8600158f11e8307a Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 28 Sep 2010 11:12:34 +0300 Subject: [PATCH 168/183] Silence a GCC warning about reaching the end of non-void func Spotted by: Marko --- storage/innodb_plugin/handler/i_s.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innodb_plugin/handler/i_s.cc b/storage/innodb_plugin/handler/i_s.cc index 1ac79860351..9ad2d656365 100644 --- a/storage/innodb_plugin/handler/i_s.cc +++ b/storage/innodb_plugin/handler/i_s.cc @@ -1012,8 +1012,8 @@ trx_i_s_common_fill_table( deadlock occurs between the mysqld server and mysql client, see http://bugs.mysql.com/29900 ; when that bug is resolved we can enable the DBUG_RETURN(ret) above */ - DBUG_RETURN(0); ret++; // silence a gcc46 warning + DBUG_RETURN(0); #endif } From 92b247814a988e24b61a553a175af4ba6398e687 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Tue, 28 Sep 2010 11:07:58 +0200 Subject: [PATCH 169/183] Bug #46165 server crash in dbug This crash occured if the same debug trace file was closed twice, leading to the same memory being free'd twice. This could occur if the "debug" server system variable refered to the same trace file in both global and session scope. Example of an order of events that would lead to a crash: 1) Enable debug tracing to a trace file (global scope) 2) Enable debug tracing to the same trace file (session scope) 3) Reset debug settings (global scope) 4) Reset debug settings (session scope) This caused a crash because the trace file was, by mistake, closed in 3), leading to the same memory being free'd twice when the file was closed again in 4). Internally, the debug settings are stored in a stack, with session settings (if any) on top and the global settings below. Each connection has its own stack. When a set of settings is changed, it must be determined if its debug trace file is to be closed. Before, this was done by only checking below on the settings stack. So if the global settings were changed, an existing debug trace file reference in session settings would be missed. This caused the file to be closed even if it was in use, leading to a crash later when it was closed again. This patch fixes the problem by preventing the trace file from being shared between global and session settings. If session debug settings are set without specifying a new trace file, stderr is used for output. This is a change in behaviour and should be reflected in the documentation. Test case added to variables.test. --- dbug/dbug.c | 10 ++++- mysql-test/r/variables.result | 44 ++++++++++++++++++++ mysql-test/t/variables.test | 75 +++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 2 deletions(-) diff --git a/dbug/dbug.c b/dbug/dbug.c index 4968d9e0568..5029bbb8d61 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -515,11 +515,16 @@ int DbugParse(CODE_STATE *cs, const char *control) stack->maxdepth= stack->next->maxdepth; stack->sub_level= stack->next->sub_level; strcpy(stack->name, stack->next->name); - stack->out_file= stack->next->out_file; stack->prof_file= stack->next->prof_file; if (stack->next == &init_settings) { - /* never share with the global parent - it can change under your feet */ + /* + Never share with the global parent - it can change under your feet. + + Reset out_file to stderr to prevent sharing of trace files between + global and session settings. + */ + stack->out_file= stderr; stack->functions= ListCopy(init_settings.functions); stack->p_functions= ListCopy(init_settings.p_functions); stack->keywords= ListCopy(init_settings.keywords); @@ -527,6 +532,7 @@ int DbugParse(CODE_STATE *cs, const char *control) } else { + stack->out_file= stack->next->out_file; stack->functions= stack->next->functions; stack->p_functions= stack->next->p_functions; stack->keywords= stack->next->keywords; diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index be81afe1a43..971e4caf516 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -1699,3 +1699,47 @@ set @@session.autocommit=t1_min(), @@session.autocommit=t1_max(), drop table t1; drop function t1_min; drop function t1_max; +# +# Bug#46165 server crash in dbug +# +SET @old_globaldebug = @@global.debug; +SET @old_sessiondebug= @@session.debug; +# Test 1 - Bug test case, single connection +SET GLOBAL debug= '+O,../../log/bug46165.1.trace'; +SET SESSION debug= '-d:-t:-i'; +SET GLOBAL debug= ''; +SET SESSION debug= ''; +# Test 2 - Bug test case, two connections +# Connection default +SET GLOBAL debug= '+O,../../log/bug46165.2.trace'; +SET SESSION debug= '-d:-t:-i'; +# Connection con1 +SET GLOBAL debug= ''; +# Connection default +SET SESSION debug= ''; +# Connection con1 +# Connection default +SET GLOBAL debug= ''; +# Test 3 - Active session trace file on disconnect +# Connection con1 +SET GLOBAL debug= '+O,../../log/bug46165.3.trace'; +SET SESSION debug= '-d:-t:-i'; +SET GLOBAL debug= ''; +# Test 4 - Active session trace file on two connections +# Connection default +SET GLOBAL debug= '+O,../../log/bug46165.4.trace'; +SET SESSION debug= '-d:-t:-i'; +# Connection con1 +SET SESSION debug= '-d:-t:-i'; +SET GLOBAL debug= ''; +SET SESSION debug= ''; +# Connection default +SET SESSION debug= ''; +# Connection con1 +# Connection default +# Test 5 - Different trace files +SET SESSION debug= '+O,../../log/bug46165.5.trace'; +SET SESSION debug= '+O,../../log/bug46165.6.trace'; +SET SESSION debug= '-O'; +SET GLOBAL debug= @old_globaldebug; +SET SESSION debug= @old_sessiondebug; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 75099523062..0209fb00a77 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -1432,3 +1432,78 @@ drop function t1_max; ########################################################################### + + +--echo # +--echo # Bug#46165 server crash in dbug +--echo # + +SET @old_globaldebug = @@global.debug; +SET @old_sessiondebug= @@session.debug; + +--echo # Test 1 - Bug test case, single connection +SET GLOBAL debug= '+O,../../log/bug46165.1.trace'; +SET SESSION debug= '-d:-t:-i'; + +SET GLOBAL debug= ''; +SET SESSION debug= ''; + +--echo # Test 2 - Bug test case, two connections +--echo # Connection default +connection default; +SET GLOBAL debug= '+O,../../log/bug46165.2.trace'; +SET SESSION debug= '-d:-t:-i'; + +--echo # Connection con1 +connect (con1, localhost, root); +SET GLOBAL debug= ''; + +--echo # Connection default +connection default; +SET SESSION debug= ''; +--echo # Connection con1 +connection con1; +disconnect con1; +--source include/wait_until_disconnected.inc +--echo # Connection default +connection default; +SET GLOBAL debug= ''; + +--echo # Test 3 - Active session trace file on disconnect +--echo # Connection con1 +connect (con1, localhost, root); +SET GLOBAL debug= '+O,../../log/bug46165.3.trace'; +SET SESSION debug= '-d:-t:-i'; +SET GLOBAL debug= ''; +disconnect con1; +--source include/wait_until_disconnected.inc + +--echo # Test 4 - Active session trace file on two connections +--echo # Connection default +connection default; +SET GLOBAL debug= '+O,../../log/bug46165.4.trace'; +SET SESSION debug= '-d:-t:-i'; + +--echo # Connection con1 +connect (con1, localhost, root); +SET SESSION debug= '-d:-t:-i'; +SET GLOBAL debug= ''; +SET SESSION debug= ''; + +--echo # Connection default +connection default; +SET SESSION debug= ''; +--echo # Connection con1 +connection con1; +disconnect con1; +--source include/wait_until_disconnected.inc +--echo # Connection default +connection default; + +--echo # Test 5 - Different trace files +SET SESSION debug= '+O,../../log/bug46165.5.trace'; +SET SESSION debug= '+O,../../log/bug46165.6.trace'; +SET SESSION debug= '-O'; + +SET GLOBAL debug= @old_globaldebug; +SET SESSION debug= @old_sessiondebug; From 3b0b15c5aa4041d19ac87af287f5293597f73484 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 28 Sep 2010 15:31:33 +0300 Subject: [PATCH 170/183] Increment InnoDB Plugin version to 1.0.13. InnoDB Plugin 1.0.12 has been released with MySQL 5.1.51. --- storage/innodb_plugin/include/univ.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innodb_plugin/include/univ.i b/storage/innodb_plugin/include/univ.i index 66b712a0355..ee77582d7f1 100644 --- a/storage/innodb_plugin/include/univ.i +++ b/storage/innodb_plugin/include/univ.i @@ -46,7 +46,7 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 1 #define INNODB_VERSION_MINOR 0 -#define INNODB_VERSION_BUGFIX 12 +#define INNODB_VERSION_BUGFIX 13 /* The following is the InnoDB version as shown in SELECT plugin_version FROM information_schema.plugins; From 4228b8bbdd93cc905b75432c1e9d23316f2430e6 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Wed, 29 Sep 2010 10:07:56 +0200 Subject: [PATCH 171/183] Followup to Bug#46165 server crash in dbug This patch moves the regression test from variables.test to variables_debug.test as the debug system variable is not available on release builds. --- mysql-test/r/variables.result | 44 ----------------- mysql-test/r/variables_debug.result | 44 +++++++++++++++++ mysql-test/t/variables.test | 75 ----------------------------- mysql-test/t/variables_debug.test | 75 +++++++++++++++++++++++++++++ 4 files changed, 119 insertions(+), 119 deletions(-) diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 971e4caf516..be81afe1a43 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -1699,47 +1699,3 @@ set @@session.autocommit=t1_min(), @@session.autocommit=t1_max(), drop table t1; drop function t1_min; drop function t1_max; -# -# Bug#46165 server crash in dbug -# -SET @old_globaldebug = @@global.debug; -SET @old_sessiondebug= @@session.debug; -# Test 1 - Bug test case, single connection -SET GLOBAL debug= '+O,../../log/bug46165.1.trace'; -SET SESSION debug= '-d:-t:-i'; -SET GLOBAL debug= ''; -SET SESSION debug= ''; -# Test 2 - Bug test case, two connections -# Connection default -SET GLOBAL debug= '+O,../../log/bug46165.2.trace'; -SET SESSION debug= '-d:-t:-i'; -# Connection con1 -SET GLOBAL debug= ''; -# Connection default -SET SESSION debug= ''; -# Connection con1 -# Connection default -SET GLOBAL debug= ''; -# Test 3 - Active session trace file on disconnect -# Connection con1 -SET GLOBAL debug= '+O,../../log/bug46165.3.trace'; -SET SESSION debug= '-d:-t:-i'; -SET GLOBAL debug= ''; -# Test 4 - Active session trace file on two connections -# Connection default -SET GLOBAL debug= '+O,../../log/bug46165.4.trace'; -SET SESSION debug= '-d:-t:-i'; -# Connection con1 -SET SESSION debug= '-d:-t:-i'; -SET GLOBAL debug= ''; -SET SESSION debug= ''; -# Connection default -SET SESSION debug= ''; -# Connection con1 -# Connection default -# Test 5 - Different trace files -SET SESSION debug= '+O,../../log/bug46165.5.trace'; -SET SESSION debug= '+O,../../log/bug46165.6.trace'; -SET SESSION debug= '-O'; -SET GLOBAL debug= @old_globaldebug; -SET SESSION debug= @old_sessiondebug; diff --git a/mysql-test/r/variables_debug.result b/mysql-test/r/variables_debug.result index a02d285b15b..8abdbdaed12 100644 --- a/mysql-test/r/variables_debug.result +++ b/mysql-test/r/variables_debug.result @@ -32,3 +32,47 @@ SELECT @@global.debug; SET GLOBAL debug=@old_debug; End of 5.1 tests +# +# Bug#46165 server crash in dbug +# +SET @old_globaldebug = @@global.debug; +SET @old_sessiondebug= @@session.debug; +# Test 1 - Bug test case, single connection +SET GLOBAL debug= '+O,../../log/bug46165.1.trace'; +SET SESSION debug= '-d:-t:-i'; +SET GLOBAL debug= ''; +SET SESSION debug= ''; +# Test 2 - Bug test case, two connections +# Connection default +SET GLOBAL debug= '+O,../../log/bug46165.2.trace'; +SET SESSION debug= '-d:-t:-i'; +# Connection con1 +SET GLOBAL debug= ''; +# Connection default +SET SESSION debug= ''; +# Connection con1 +# Connection default +SET GLOBAL debug= ''; +# Test 3 - Active session trace file on disconnect +# Connection con1 +SET GLOBAL debug= '+O,../../log/bug46165.3.trace'; +SET SESSION debug= '-d:-t:-i'; +SET GLOBAL debug= ''; +# Test 4 - Active session trace file on two connections +# Connection default +SET GLOBAL debug= '+O,../../log/bug46165.4.trace'; +SET SESSION debug= '-d:-t:-i'; +# Connection con1 +SET SESSION debug= '-d:-t:-i'; +SET GLOBAL debug= ''; +SET SESSION debug= ''; +# Connection default +SET SESSION debug= ''; +# Connection con1 +# Connection default +# Test 5 - Different trace files +SET SESSION debug= '+O,../../log/bug46165.5.trace'; +SET SESSION debug= '+O,../../log/bug46165.6.trace'; +SET SESSION debug= '-O'; +SET GLOBAL debug= @old_globaldebug; +SET SESSION debug= @old_sessiondebug; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 0209fb00a77..75099523062 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -1432,78 +1432,3 @@ drop function t1_max; ########################################################################### - - ---echo # ---echo # Bug#46165 server crash in dbug ---echo # - -SET @old_globaldebug = @@global.debug; -SET @old_sessiondebug= @@session.debug; - ---echo # Test 1 - Bug test case, single connection -SET GLOBAL debug= '+O,../../log/bug46165.1.trace'; -SET SESSION debug= '-d:-t:-i'; - -SET GLOBAL debug= ''; -SET SESSION debug= ''; - ---echo # Test 2 - Bug test case, two connections ---echo # Connection default -connection default; -SET GLOBAL debug= '+O,../../log/bug46165.2.trace'; -SET SESSION debug= '-d:-t:-i'; - ---echo # Connection con1 -connect (con1, localhost, root); -SET GLOBAL debug= ''; - ---echo # Connection default -connection default; -SET SESSION debug= ''; ---echo # Connection con1 -connection con1; -disconnect con1; ---source include/wait_until_disconnected.inc ---echo # Connection default -connection default; -SET GLOBAL debug= ''; - ---echo # Test 3 - Active session trace file on disconnect ---echo # Connection con1 -connect (con1, localhost, root); -SET GLOBAL debug= '+O,../../log/bug46165.3.trace'; -SET SESSION debug= '-d:-t:-i'; -SET GLOBAL debug= ''; -disconnect con1; ---source include/wait_until_disconnected.inc - ---echo # Test 4 - Active session trace file on two connections ---echo # Connection default -connection default; -SET GLOBAL debug= '+O,../../log/bug46165.4.trace'; -SET SESSION debug= '-d:-t:-i'; - ---echo # Connection con1 -connect (con1, localhost, root); -SET SESSION debug= '-d:-t:-i'; -SET GLOBAL debug= ''; -SET SESSION debug= ''; - ---echo # Connection default -connection default; -SET SESSION debug= ''; ---echo # Connection con1 -connection con1; -disconnect con1; ---source include/wait_until_disconnected.inc ---echo # Connection default -connection default; - ---echo # Test 5 - Different trace files -SET SESSION debug= '+O,../../log/bug46165.5.trace'; -SET SESSION debug= '+O,../../log/bug46165.6.trace'; -SET SESSION debug= '-O'; - -SET GLOBAL debug= @old_globaldebug; -SET SESSION debug= @old_sessiondebug; diff --git a/mysql-test/t/variables_debug.test b/mysql-test/t/variables_debug.test index 8fa2124137a..63c34acc876 100644 --- a/mysql-test/t/variables_debug.test +++ b/mysql-test/t/variables_debug.test @@ -36,3 +36,78 @@ SELECT @@global.debug; SET GLOBAL debug=@old_debug; --echo End of 5.1 tests + + +--echo # +--echo # Bug#46165 server crash in dbug +--echo # + +SET @old_globaldebug = @@global.debug; +SET @old_sessiondebug= @@session.debug; + +--echo # Test 1 - Bug test case, single connection +SET GLOBAL debug= '+O,../../log/bug46165.1.trace'; +SET SESSION debug= '-d:-t:-i'; + +SET GLOBAL debug= ''; +SET SESSION debug= ''; + +--echo # Test 2 - Bug test case, two connections +--echo # Connection default +connection default; +SET GLOBAL debug= '+O,../../log/bug46165.2.trace'; +SET SESSION debug= '-d:-t:-i'; + +--echo # Connection con1 +connect (con1, localhost, root); +SET GLOBAL debug= ''; + +--echo # Connection default +connection default; +SET SESSION debug= ''; +--echo # Connection con1 +connection con1; +disconnect con1; +--source include/wait_until_disconnected.inc +--echo # Connection default +connection default; +SET GLOBAL debug= ''; + +--echo # Test 3 - Active session trace file on disconnect +--echo # Connection con1 +connect (con1, localhost, root); +SET GLOBAL debug= '+O,../../log/bug46165.3.trace'; +SET SESSION debug= '-d:-t:-i'; +SET GLOBAL debug= ''; +disconnect con1; +--source include/wait_until_disconnected.inc + +--echo # Test 4 - Active session trace file on two connections +--echo # Connection default +connection default; +SET GLOBAL debug= '+O,../../log/bug46165.4.trace'; +SET SESSION debug= '-d:-t:-i'; + +--echo # Connection con1 +connect (con1, localhost, root); +SET SESSION debug= '-d:-t:-i'; +SET GLOBAL debug= ''; +SET SESSION debug= ''; + +--echo # Connection default +connection default; +SET SESSION debug= ''; +--echo # Connection con1 +connection con1; +disconnect con1; +--source include/wait_until_disconnected.inc +--echo # Connection default +connection default; + +--echo # Test 5 - Different trace files +SET SESSION debug= '+O,../../log/bug46165.5.trace'; +SET SESSION debug= '+O,../../log/bug46165.6.trace'; +SET SESSION debug= '-O'; + +SET GLOBAL debug= @old_globaldebug; +SET SESSION debug= @old_sessiondebug; From bc684baba2ca07b9138d790de264dddc3c74c695 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 29 Sep 2010 11:42:35 +0200 Subject: [PATCH 172/183] Rename CMAKE_PARSE_ARGUMENTS macro to avoid name collision with CMake 2.8.3 builtin macro --- cmake/cmake_parse_arguments.cmake | 2 +- cmake/install_macros.cmake | 6 +++--- cmake/libutils.cmake | 2 +- cmake/mysql_add_executable.cmake | 2 +- cmake/plugin.cmake | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmake/cmake_parse_arguments.cmake b/cmake/cmake_parse_arguments.cmake index ea601f916a8..db540ae9020 100644 --- a/cmake/cmake_parse_arguments.cmake +++ b/cmake/cmake_parse_arguments.cmake @@ -15,7 +15,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Handy macro to parse macro arguments -MACRO(CMAKE_PARSE_ARGUMENTS prefix arg_names option_names) +MACRO(MYSQL_PARSE_ARGUMENTS prefix arg_names option_names) SET(DEFAULT_ARGS) FOREACH(arg_name ${arg_names}) SET(${prefix}_${arg_name}) diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake index 56a540fde89..bc8d9945690 100644 --- a/cmake/install_macros.cmake +++ b/cmake/install_macros.cmake @@ -83,7 +83,7 @@ FUNCTION(INSTALL_MANPAGE file) ENDFUNCTION() FUNCTION(INSTALL_SCRIPT) - CMAKE_PARSE_ARGUMENTS(ARG + MYSQL_PARSE_ARGUMENTS(ARG "DESTINATION;COMPONENT" "" ${ARGN} @@ -205,7 +205,7 @@ ENDMACRO() # FUNCTION(MYSQL_INSTALL_TARGETS) - CMAKE_PARSE_ARGUMENTS(ARG + MYSQL_PARSE_ARGUMENTS(ARG "DESTINATION;COMPONENT" "" ${ARGN} @@ -249,7 +249,7 @@ SET(DEBUGBUILDDIR "${BINARY_PARENTDIR}/debug" CACHE INTERNAL "Directory of debug FUNCTION(INSTALL_DEBUG_TARGET target) - CMAKE_PARSE_ARGUMENTS(ARG + MYSQL_PARSE_ARGUMENTS(ARG "DESTINATION;RENAME;PDB_DESTINATION;COMPONENT" "" ${ARGN} diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake index ba63df71428..0cc8895f43e 100644 --- a/cmake/libutils.cmake +++ b/cmake/libutils.cmake @@ -213,7 +213,7 @@ ENDMACRO() # [OUTPUT_NAME output_name] #) MACRO(MERGE_LIBRARIES) - CMAKE_PARSE_ARGUMENTS(ARG + MYSQL_PARSE_ARGUMENTS(ARG "EXPORTS;OUTPUT_NAME;COMPONENT" "STATIC;SHARED;MODULE;NOINSTALL" ${ARGN} diff --git a/cmake/mysql_add_executable.cmake b/cmake/mysql_add_executable.cmake index 86301c2eec8..b49a737716c 100644 --- a/cmake/mysql_add_executable.cmake +++ b/cmake/mysql_add_executable.cmake @@ -28,7 +28,7 @@ INCLUDE(cmake_parse_arguments) FUNCTION (MYSQL_ADD_EXECUTABLE) # Pass-through arguments for ADD_EXECUTABLE - CMAKE_PARSE_ARGUMENTS(ARG + MYSQL_PARSE_ARGUMENTS(ARG "WIN32;MACOSX_BUNDLE;EXCLUDE_FROM_ALL;DESTINATION;COMPONENT" "" ${ARGN} diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 138901dfa8a..94fdc8bf1e9 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -28,7 +28,7 @@ INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake) # [DEPENDENCIES target1...targetN] MACRO(MYSQL_ADD_PLUGIN) - CMAKE_PARSE_ARGUMENTS(ARG + MYSQL_PARSE_ARGUMENTS(ARG "LINK_LIBRARIES;DEPENDENCIES;MODULE_OUTPUT_NAME;STATIC_OUTPUT_NAME" "STORAGE_ENGINE;STATIC_ONLY;MODULE_ONLY;MANDATORY;DEFAULT;DISABLED;RECOMPILE_FOR_EMBEDDED" ${ARGN} From 49406b97dfe1d54709eae4aa1234d0071b6667ad Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Wed, 29 Sep 2010 16:09:07 +0400 Subject: [PATCH 173/183] A better fix for bug #56405 "Deadlock in the MDL deadlock detector" that doesn't introduce bug #56715 "Concurrent transactions + FLUSH result in sporadical unwarranted deadlock errors". Deadlock could have occurred when workload containing a mix of DML, DDL and FLUSH TABLES statements affecting the same set of tables was executed in a heavily concurrent environment. This deadlock occurred when several connections tried to perform deadlock detection in the metadata locking subsystem. The first connection started traversing wait-for graph, encountered a sub-graph representing a wait for flush, acquired LOCK_open and dived into sub-graph inspection. Then it encountered sub-graph corresponding to wait for metadata lock and blocked while trying to acquire a rd-lock on MDL_lock::m_rwlock, since some,other thread had a wr-lock on it. When this wr-lock was released it could have happened (if there was another pending wr-lock against this rwlock) that the rd-lock from the first connection was left unsatisfied but at the same time the new rd-lock request from the second connection sneaked in and was satisfied (for this to be possible the second rd-request should come exactly after the wr-lock is released but before pending the wr-lock manages to grab rwlock, which is possible both on Linux and in our own rwlock implementation). If this second connection continued traversing the wait-for graph and encountered a sub-graph representing a wait for flush it tried to acquire LOCK_open and thus the deadlock was created. The previous patch tried to workaround this problem by not allowing the deadlock detector to lock LOCK_open mutex if some other thread doing deadlock detection already owns it and current search depth is greater than 0. Instead deadlock was reported. As a result it has introduced bug #56715. This patch solves this problem in a different way. It introduces a new rw_pr_lock_t implementation to be used by MDL subsystem instead of one based on Linux rwlocks or our own rwlock implementation. This new implementation never allows situation in which an rwlock is rd-locked and there is a blocked pending rd-lock. Thus the situation which has caused this bug becomes impossible with this implementation. Due to fact that this implementation is optimized for wr-lock/unlock scenario which is most common in the MDL subsystem it doesn't introduce noticeable performance regressions in sysbench tests. Moreover it significantly improves situation for POINT_SELECT test when many connections are used. No test case is provided as this bug is very hard to repeat in MTR environment but is repeatable with the help of RQG tests. This patch also doesn't include a test for bug #56715 "Concurrent transactions + FLUSH result in sporadical unwarranted deadlock errors" as it takes too much time to be run as part of normal test-suite runs. --- config.h.cmake | 1 - configure.cmake | 1 - configure.in | 2 +- include/my_pthread.h | 104 ++++++++++++++-------- include/mysql/psi/mysql_thread.h | 88 ------------------- mysys/thr_rwlock.c | 145 +++++++++++++++++++++++++------ 6 files changed, 188 insertions(+), 153 deletions(-) diff --git a/config.h.cmake b/config.h.cmake index c484edb65a5..7047cc6bbf5 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -220,7 +220,6 @@ #cmakedefine HAVE_PTHREAD_KEY_DELETE 1 #cmakedefine HAVE_PTHREAD_KILL 1 #cmakedefine HAVE_PTHREAD_RWLOCK_RDLOCK 1 -#cmakedefine HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP 1 #cmakedefine HAVE_PTHREAD_SETPRIO_NP 1 #cmakedefine HAVE_PTHREAD_SETSCHEDPARAM 1 #cmakedefine HAVE_PTHREAD_SIGMASK 1 diff --git a/configure.cmake b/configure.cmake index c2e1dc4647b..91c39fc5b09 100644 --- a/configure.cmake +++ b/configure.cmake @@ -346,7 +346,6 @@ CHECK_FUNCTION_EXISTS (pthread_condattr_setclock HAVE_PTHREAD_CONDATTR_SETCLOCK) CHECK_FUNCTION_EXISTS (pthread_init HAVE_PTHREAD_INIT) CHECK_FUNCTION_EXISTS (pthread_key_delete HAVE_PTHREAD_KEY_DELETE) CHECK_FUNCTION_EXISTS (pthread_rwlock_rdlock HAVE_PTHREAD_RWLOCK_RDLOCK) -CHECK_FUNCTION_EXISTS (pthread_rwlockattr_setkind_np HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP) CHECK_FUNCTION_EXISTS (pthread_sigmask HAVE_PTHREAD_SIGMASK) CHECK_FUNCTION_EXISTS (pthread_threadmask HAVE_PTHREAD_THREADMASK) CHECK_FUNCTION_EXISTS (pthread_yield_np HAVE_PTHREAD_YIELD_NP) diff --git a/configure.in b/configure.in index 1f56d958a7f..48385ba2491 100644 --- a/configure.in +++ b/configure.in @@ -2169,7 +2169,7 @@ AC_CHECK_FUNCS(alarm bfill bmove bsearch bzero \ mkstemp mlockall perror poll pread pthread_attr_create mmap mmap64 getpagesize \ pthread_attr_getstacksize pthread_attr_setstacksize pthread_condattr_create \ pthread_getsequence_np pthread_key_delete pthread_rwlock_rdlock \ - pthread_rwlockattr_setkind_np pthread_sigmask \ + pthread_sigmask \ readlink realpath rename rint rwlock_init setupterm \ shmget shmat shmdt shmctl sigaction sigemptyset sigaddset \ sighold sigset sigthreadmask port_create sleep thr_yield \ diff --git a/include/my_pthread.h b/include/my_pthread.h index 5cf181596ad..27ab5ba23fe 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -594,7 +594,7 @@ int my_pthread_fastmutex_lock(my_pthread_fastmutex_t *mp); /* Use our own version of read/write locks */ #define NEED_MY_RW_LOCK 1 #define rw_lock_t my_rw_lock_t -#define my_rwlock_init(A,B) my_rw_init((A), 0) +#define my_rwlock_init(A,B) my_rw_init((A)) #define rw_rdlock(A) my_rw_rdlock((A)) #define rw_wrlock(A) my_rw_wrlock((A)) #define rw_tryrdlock(A) my_rw_tryrdlock((A)) @@ -606,49 +606,82 @@ int my_pthread_fastmutex_lock(my_pthread_fastmutex_t *mp); #endif /* USE_MUTEX_INSTEAD_OF_RW_LOCKS */ -/* - Portable read-write locks which prefer readers. +/** + Portable implementation of special type of read-write locks. - Required by some algorithms in order to provide correctness. + These locks have two properties which are unusual for rwlocks: + 1) They "prefer readers" in the sense that they do not allow + situations in which rwlock is rd-locked and there is a + pending rd-lock which is blocked (e.g. due to pending + request for wr-lock). + This is a stronger guarantee than one which is provided for + PTHREAD_RWLOCK_PREFER_READER_NP rwlocks in Linux. + MDL subsystem deadlock detector relies on this property for + its correctness. + 2) They are optimized for uncontended wr-lock/unlock case. + This is scenario in which they are most oftenly used + within MDL subsystem. Optimizing for it gives significant + performance improvements in some of tests involving many + connections. + + Another important requirement imposed on this type of rwlock + by the MDL subsystem is that it should be OK to destroy rwlock + object which is in unlocked state even though some threads might + have not yet fully left unlock operation for it (of course there + is an external guarantee that no thread will try to lock rwlock + which is destroyed). + Putting it another way the unlock operation should not access + rwlock data after changing its state to unlocked. + + TODO/FIXME: We should consider alleviating this requirement as + it blocks us from doing certain performance optimizations. */ -#if defined(HAVE_PTHREAD_RWLOCK_RDLOCK) && defined(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP) -/* - On systems which have a way to specify that readers should - be preferred through attribute mechanism (e.g. Linux) we use - system implementation of read/write locks. -*/ -#define rw_pr_lock_t pthread_rwlock_t +typedef struct st_rw_pr_lock_t { + /** + Lock which protects the structure. + Also held for the duration of wr-lock. + */ + pthread_mutex_t lock; + /** + Condition variable which is used to wake-up + writers waiting for readers to go away. + */ + pthread_cond_t no_active_readers; + /** Number of active readers. */ + uint active_readers; + /** Number of writers waiting for readers to go away. */ + uint writers_waiting_readers; + /** Indicates whether there is an active writer. */ + my_bool active_writer; +#ifdef SAFE_MUTEX + /** Thread holding wr-lock (for debug purposes only). */ + pthread_t writer_thread; +#endif +} rw_pr_lock_t; + extern int rw_pr_init(rw_pr_lock_t *); -#define rw_pr_rdlock(A) pthread_rwlock_rdlock(A) -#define rw_pr_wrlock(A) pthread_rwlock_wrlock(A) -#define rw_pr_tryrdlock(A) pthread_rwlock_tryrdlock(A) -#define rw_pr_trywrlock(A) pthread_rwlock_trywrlock(A) -#define rw_pr_unlock(A) pthread_rwlock_unlock(A) -#define rw_pr_destroy(A) pthread_rwlock_destroy(A) +extern int rw_pr_rdlock(rw_pr_lock_t *); +extern int rw_pr_wrlock(rw_pr_lock_t *); +extern int rw_pr_unlock(rw_pr_lock_t *); +extern int rw_pr_destroy(rw_pr_lock_t *); +#ifdef SAFE_MUTEX +#define rw_pr_lock_assert_write_owner(A) \ + DBUG_ASSERT((A)->active_writer && pthread_equal(pthread_self(), \ + (A)->writer_thread)) +#define rw_pr_lock_assert_not_write_owner(A) \ + DBUG_ASSERT(! (A)->active_writer || ! pthread_equal(pthread_self(), \ + (A)->writer_thread)) +#else #define rw_pr_lock_assert_write_owner(A) #define rw_pr_lock_assert_not_write_owner(A) -#else -/* Otherwise we have to use our own implementation of read/write locks. */ -#define NEED_MY_RW_LOCK 1 -struct st_my_rw_lock_t; -#define rw_pr_lock_t my_rw_lock_t -extern int rw_pr_init(struct st_my_rw_lock_t *); -#define rw_pr_rdlock(A) my_rw_rdlock((A)) -#define rw_pr_wrlock(A) my_rw_wrlock((A)) -#define rw_pr_tryrdlock(A) my_rw_tryrdlock((A)) -#define rw_pr_trywrlock(A) my_rw_trywrlock((A)) -#define rw_pr_unlock(A) my_rw_unlock((A)) -#define rw_pr_destroy(A) my_rw_destroy((A)) -#define rw_pr_lock_assert_write_owner(A) my_rw_lock_assert_write_owner((A)) -#define rw_pr_lock_assert_not_write_owner(A) my_rw_lock_assert_not_write_owner((A)) -#endif /* defined(HAVE_PTHREAD_RWLOCK_RDLOCK) && defined(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP) */ +#endif /* SAFE_MUTEX */ #ifdef NEED_MY_RW_LOCK /* - On systems which don't support native read/write locks, or don't support - read/write locks which prefer readers we have to use own implementation. + On systems which don't support native read/write locks we have + to use own implementation. */ typedef struct st_my_rw_lock_t { pthread_mutex_t lock; /* lock for structure */ @@ -656,13 +689,12 @@ typedef struct st_my_rw_lock_t { pthread_cond_t writers; /* waiting writers */ int state; /* -1:writer,0:free,>0:readers */ int waiters; /* number of waiting writers */ - my_bool prefer_readers; #ifdef SAFE_MUTEX pthread_t write_thread; #endif } my_rw_lock_t; -extern int my_rw_init(my_rw_lock_t *, my_bool *); +extern int my_rw_init(my_rw_lock_t *); extern int my_rw_destroy(my_rw_lock_t *); extern int my_rw_rdlock(my_rw_lock_t *); extern int my_rw_wrlock(my_rw_lock_t *); diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h index 60b4f5d6ef4..5b8ea3dc5dc 100644 --- a/include/mysql/psi/mysql_thread.h +++ b/include/mysql/psi/mysql_thread.h @@ -141,9 +141,7 @@ typedef struct st_mysql_rwlock mysql_rwlock_t; @c mysql_prlock_t is a drop-in replacement for @c rw_pr_lock_t. @sa mysql_prlock_init @sa mysql_prlock_rdlock - @sa mysql_prlock_tryrdlock @sa mysql_prlock_wrlock - @sa mysql_prlock_trywrlock @sa mysql_prlock_unlock @sa mysql_prlock_destroy */ @@ -420,20 +418,6 @@ typedef struct st_mysql_cond mysql_cond_t; inline_mysql_rwlock_tryrdlock(RW) #endif -/** - @def mysql_prlock_tryrdlock(RW) - Instrumented rw_pr_tryrdlock. - @c mysql_prlock_tryrdlock is a drop-in replacement - for @c rw_pr_tryrdlock. -*/ -#ifdef HAVE_PSI_INTERFACE - #define mysql_prlock_tryrdlock(RW) \ - inline_mysql_prlock_tryrdlock(RW, __FILE__, __LINE__) -#else - #define mysql_prlock_tryrdlock(RW) \ - inline_mysql_prlock_tryrdlock(RW) -#endif - /** @def mysql_rwlock_trywrlock(RW) Instrumented rwlock_trywrlock. @@ -448,20 +432,6 @@ typedef struct st_mysql_cond mysql_cond_t; inline_mysql_rwlock_trywrlock(RW) #endif -/** - @def mysql_prlock_trywrlock(RW) - Instrumented rw_pr_trywrlock. - @c mysql_prlock_trywrlock is a drop-in replacement - for @c rw_pr_trywrlock. -*/ -#ifdef HAVE_PSI_INTERFACE - #define mysql_prlock_trywrlock(RW) \ - inline_mysql_prlock_trywrlock(RW, __FILE__, __LINE__) -#else - #define mysql_prlock_trywrlock(RW) \ - inline_mysql_prlock_trywrlock(RW) -#endif - /** @def mysql_rwlock_unlock(RW) Instrumented rwlock_unlock. @@ -905,35 +875,6 @@ static inline int inline_mysql_rwlock_tryrdlock( return result; } -#ifndef DISABLE_MYSQL_PRLOCK_H -static inline int inline_mysql_prlock_tryrdlock( - mysql_prlock_t *that -#ifdef HAVE_PSI_INTERFACE - , const char *src_file, uint src_line -#endif - ) -{ - int result; -#ifdef HAVE_PSI_INTERFACE - struct PSI_rwlock_locker *locker= NULL; - PSI_rwlock_locker_state state; - if (likely(PSI_server && that->m_psi)) - { - locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, - PSI_RWLOCK_TRYREADLOCK); - if (likely(locker != NULL)) - PSI_server->start_rwlock_rdwait(locker, src_file, src_line); - } -#endif - result= rw_pr_tryrdlock(&that->m_prlock); -#ifdef HAVE_PSI_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_rwlock_rdwait(locker, result); -#endif - return result; -} -#endif - static inline int inline_mysql_rwlock_trywrlock( mysql_rwlock_t *that #ifdef HAVE_PSI_INTERFACE @@ -961,35 +902,6 @@ static inline int inline_mysql_rwlock_trywrlock( return result; } -#ifndef DISABLE_MYSQL_PRLOCK_H -static inline int inline_mysql_prlock_trywrlock( - mysql_prlock_t *that -#ifdef HAVE_PSI_INTERFACE - , const char *src_file, uint src_line -#endif - ) -{ - int result; -#ifdef HAVE_PSI_INTERFACE - struct PSI_rwlock_locker *locker= NULL; - PSI_rwlock_locker_state state; - if (likely(PSI_server && that->m_psi)) - { - locker= PSI_server->get_thread_rwlock_locker(&state, that->m_psi, - PSI_RWLOCK_TRYWRITELOCK); - if (likely(locker != NULL)) - PSI_server->start_rwlock_wrwait(locker, src_file, src_line); - } -#endif - result= rw_pr_trywrlock(&that->m_prlock); -#ifdef HAVE_PSI_INTERFACE - if (likely(locker != NULL)) - PSI_server->end_rwlock_wrwait(locker, result); -#endif - return result; -} -#endif - static inline int inline_mysql_rwlock_unlock( mysql_rwlock_t *that) { diff --git a/mysys/thr_rwlock.c b/mysys/thr_rwlock.c index ecd12849822..218cfb251c8 100644 --- a/mysys/thr_rwlock.c +++ b/mysys/thr_rwlock.c @@ -59,7 +59,7 @@ * Mountain View, California 94043 */ -int my_rw_init(my_rw_lock_t *rwp, my_bool *prefer_readers_attr) +int my_rw_init(my_rw_lock_t *rwp) { pthread_condattr_t cond_attr; @@ -74,8 +74,6 @@ int my_rw_init(my_rw_lock_t *rwp, my_bool *prefer_readers_attr) #ifdef SAFE_MUTEX rwp->write_thread = 0; #endif - /* If attribute argument is NULL use default value - prefer writers. */ - rwp->prefer_readers= prefer_readers_attr ? *prefer_readers_attr : FALSE; return(0); } @@ -96,8 +94,7 @@ int my_rw_rdlock(my_rw_lock_t *rwp) pthread_mutex_lock(&rwp->lock); /* active or queued writers */ - while (( rwp->state < 0 ) || - (rwp->waiters && ! rwp->prefer_readers)) + while (( rwp->state < 0 ) || rwp->waiters) pthread_cond_wait( &rwp->readers, &rwp->lock); rwp->state++; @@ -109,8 +106,7 @@ int my_rw_tryrdlock(my_rw_lock_t *rwp) { int res; pthread_mutex_lock(&rwp->lock); - if ((rwp->state < 0 ) || - (rwp->waiters && ! rwp->prefer_readers)) + if ((rwp->state < 0 ) || rwp->waiters) res= EBUSY; /* Can't get lock */ else { @@ -192,30 +188,127 @@ int my_rw_unlock(my_rw_lock_t *rwp) return(0); } +#endif /* defined(NEED_MY_RW_LOCK) */ -int rw_pr_init(struct st_my_rw_lock_t *rwlock) -{ - my_bool prefer_readers_attr= TRUE; - return my_rw_init(rwlock, &prefer_readers_attr); -} - -#else - -/* - We are on system which has native read/write locks which support - preferring of readers. -*/ int rw_pr_init(rw_pr_lock_t *rwlock) { - pthread_rwlockattr_t rwlock_attr; - - pthread_rwlockattr_init(&rwlock_attr); - pthread_rwlockattr_setkind_np(&rwlock_attr, PTHREAD_RWLOCK_PREFER_READER_NP); - pthread_rwlock_init(rwlock, NULL); - pthread_rwlockattr_destroy(&rwlock_attr); + pthread_mutex_init(&rwlock->lock, NULL); + pthread_cond_init(&rwlock->no_active_readers, NULL); + rwlock->active_readers= 0; + rwlock->writers_waiting_readers= 0; + rwlock->active_writer= FALSE; +#ifdef SAFE_MUTEX + rwlock->writer_thread= 0; +#endif return 0; } -#endif /* defined(NEED_MY_RW_LOCK) */ + +int rw_pr_destroy(rw_pr_lock_t *rwlock) +{ + pthread_cond_destroy(&rwlock->no_active_readers); + pthread_mutex_destroy(&rwlock->lock); + return 0; +} + + +int rw_pr_rdlock(rw_pr_lock_t *rwlock) +{ + pthread_mutex_lock(&rwlock->lock); + /* + The fact that we were able to acquire 'lock' mutex means + that there are no active writers and we can acquire rd-lock. + Increment active readers counter to prevent requests for + wr-lock from succeeding and unlock mutex. + */ + rwlock->active_readers++; + pthread_mutex_unlock(&rwlock->lock); + return 0; +} + + +int rw_pr_wrlock(rw_pr_lock_t *rwlock) +{ + pthread_mutex_lock(&rwlock->lock); + + if (rwlock->active_readers != 0) + { + /* There are active readers. We have to wait until they are gone. */ + rwlock->writers_waiting_readers++; + + while (rwlock->active_readers != 0) + pthread_cond_wait(&rwlock->no_active_readers, &rwlock->lock); + + rwlock->writers_waiting_readers--; + } + + /* + We own 'lock' mutex so there is no active writers. + Also there are no active readers. + This means that we can grant wr-lock. + Not releasing 'lock' mutex until unlock will block + both requests for rd and wr-locks. + Set 'active_writer' flag to simplify unlock. + + Thanks to the fact wr-lock/unlock in the absence of + contention from readers is essentially mutex lock/unlock + with a few simple checks make this rwlock implementation + wr-lock optimized. + */ + rwlock->active_writer= TRUE; +#ifdef SAFE_MUTEX + rwlock->writer_thread= pthread_self(); +#endif + return 0; +} + + +int rw_pr_unlock(rw_pr_lock_t *rwlock) +{ + if (rwlock->active_writer) + { + /* We are unlocking wr-lock. */ +#ifdef SAFE_MUTEX + rwlock->writer_thread= 0; +#endif + rwlock->active_writer= FALSE; + if (rwlock->writers_waiting_readers) + { + /* + Avoid expensive cond signal in case when there is no contention + or it is wr-only. + + Note that from view point of performance it would be better to + signal on the condition variable after unlocking mutex (as it + reduces number of contex switches). + + Unfortunately this would mean that such rwlock can't be safely + used by MDL subsystem, which relies on the fact that it is OK + to destroy rwlock once it is in unlocked state. + */ + pthread_cond_signal(&rwlock->no_active_readers); + } + pthread_mutex_unlock(&rwlock->lock); + } + else + { + /* We are unlocking rd-lock. */ + pthread_mutex_lock(&rwlock->lock); + rwlock->active_readers--; + if (rwlock->active_readers == 0 && + rwlock->writers_waiting_readers) + { + /* + If we are last reader and there are waiting + writers wake them up. + */ + pthread_cond_signal(&rwlock->no_active_readers); + } + pthread_mutex_unlock(&rwlock->lock); + } + return 0; +} + + #endif /* defined(THREAD) */ From d70cbd6c616b935437e0b64cd9c7fe4a5ff8a5d3 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Thu, 30 Sep 2010 13:26:18 +0300 Subject: [PATCH 174/183] Fix a potential bug when using __sync_lock_test_and_set() TYPE __sync_lock_test_and_set (TYPE *ptr, TYPE value, ...) it is not documented what happens if the two arguments are of different type like it was before: the first one was lock_word_t (byte) and the second one was 1 or 0 (int). Approved by: Marko (via IRC) --- storage/innodb_plugin/include/os0sync.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innodb_plugin/include/os0sync.h b/storage/innodb_plugin/include/os0sync.h index 0c22162b900..f32e7ab710a 100644 --- a/storage/innodb_plugin/include/os0sync.h +++ b/storage/innodb_plugin/include/os0sync.h @@ -330,7 +330,7 @@ amount of increment. */ Returns the old value of *ptr, atomically sets *ptr to new_val */ # define os_atomic_test_and_set_byte(ptr, new_val) \ - __sync_lock_test_and_set(ptr, new_val) + __sync_lock_test_and_set(ptr, (byte) new_val) #elif defined(HAVE_IB_SOLARIS_ATOMICS) From e9bd5900f50a1c4b903e037ed03264f4df458132 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Thu, 30 Sep 2010 15:48:44 +0300 Subject: [PATCH 175/183] Fix Bug#56340 innodb updates index stats too frequently after non-index updates This is a simple optimization issue. All stats are related to only indexed columns, index size or number of rows in the whole table. UPDATEs that touch only non-indexed columns cannot affect stats and we can avoid calling the function row_update_statistics_if_needed() which may result in unnecessary I/O. Approved by: Marko (rb://466) --- storage/innobase/row/row0mysql.c | 7 ++++++- storage/innodb_plugin/row/row0mysql.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index 4a834c4efc2..2058363c786 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -1447,7 +1447,12 @@ run_again: srv_n_rows_updated++; } - row_update_statistics_if_needed(prebuilt->table); + /* We update table statistics only if it is a DELETE or UPDATE + that changes indexed columns, UPDATEs that change only non-indexed + columns would not affect statistics. */ + if (node->is_delete || !(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) { + row_update_statistics_if_needed(prebuilt->table); + } trx->op_info = ""; diff --git a/storage/innodb_plugin/row/row0mysql.c b/storage/innodb_plugin/row/row0mysql.c index feeb7fc80b7..813a99049fc 100644 --- a/storage/innodb_plugin/row/row0mysql.c +++ b/storage/innodb_plugin/row/row0mysql.c @@ -1422,7 +1422,12 @@ run_again: srv_n_rows_updated++; } - row_update_statistics_if_needed(prebuilt->table); + /* We update table statistics only if it is a DELETE or UPDATE + that changes indexed columns, UPDATEs that change only non-indexed + columns would not affect statistics. */ + if (node->is_delete || !(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) { + row_update_statistics_if_needed(prebuilt->table); + } trx->op_info = ""; From 8322cad0150bf1389bb4a3344772ef1bd30c0b36 Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Thu, 30 Sep 2010 17:29:12 +0400 Subject: [PATCH 176/183] Reverted a temporary workaround for bug #56405 "Deadlock in the MDL deadlock detector". It is no longer needed as a better fix for this bug has been pushed. --- .../perfschema/r/dml_setup_instruments.result | 2 +- sql/mdl.cc | 34 ++++++------------- sql/mdl.h | 16 +-------- sql/sql_base.cc | 10 ++---- sql/sql_base.h | 2 -- sql/table.cc | 33 ------------------ 6 files changed, 14 insertions(+), 83 deletions(-) diff --git a/mysql-test/suite/perfschema/r/dml_setup_instruments.result b/mysql-test/suite/perfschema/r/dml_setup_instruments.result index 7f203118346..2338252976c 100644 --- a/mysql-test/suite/perfschema/r/dml_setup_instruments.result +++ b/mysql-test/suite/perfschema/r/dml_setup_instruments.result @@ -13,7 +13,7 @@ wait/synch/mutex/sql/LOCK_active_mi YES YES wait/synch/mutex/sql/LOCK_audit_mask YES YES wait/synch/mutex/sql/LOCK_connection_count YES YES wait/synch/mutex/sql/LOCK_crypt YES YES -wait/synch/mutex/sql/LOCK_dd_owns_lock_open YES YES +wait/synch/mutex/sql/LOCK_delayed_create YES YES select * from performance_schema.SETUP_INSTRUMENTS where name like 'Wait/Synch/Rwlock/sql/%' and name not in ('wait/synch/rwlock/sql/CRYPTO_dynlock_value::lock') diff --git a/sql/mdl.cc b/sql/mdl.cc index aa7c2a4b7f2..d53ddcee0c8 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -124,6 +124,7 @@ public: Deadlock_detection_visitor(MDL_context *start_node_arg) : m_start_node(start_node_arg), m_victim(NULL), + m_current_search_depth(0), m_found_deadlock(FALSE) {} virtual bool enter_node(MDL_context *node); @@ -132,8 +133,6 @@ public: virtual bool inspect_edge(MDL_context *dest); MDL_context *get_victim() const { return m_victim; } - - void abort_traversal(MDL_context *node); private: /** Change the deadlock victim to a new one if it has lower deadlock @@ -148,6 +147,13 @@ private: MDL_context *m_start_node; /** If a deadlock is found, the context that identifies the victim. */ MDL_context *m_victim; + /** Set to the 0 at start. Increased whenever + we descend into another MDL context (aka traverse to the next + wait-for graph node). When MAX_SEARCH_DEPTH is reached, we + assume that a deadlock is found, even if we have not found a + loop. + */ + uint m_current_search_depth; /** TRUE if we found a deadlock. */ bool m_found_deadlock; /** @@ -181,7 +187,7 @@ private: bool Deadlock_detection_visitor::enter_node(MDL_context *node) { - m_found_deadlock= m_current_search_depth >= MAX_SEARCH_DEPTH; + m_found_deadlock= ++m_current_search_depth >= MAX_SEARCH_DEPTH; if (m_found_deadlock) { DBUG_ASSERT(! m_victim); @@ -201,6 +207,7 @@ bool Deadlock_detection_visitor::enter_node(MDL_context *node) void Deadlock_detection_visitor::leave_node(MDL_context *node) { + --m_current_search_depth; if (m_found_deadlock) opt_change_victim_to(node); } @@ -244,21 +251,6 @@ Deadlock_detection_visitor::opt_change_victim_to(MDL_context *new_victim) } -/** - Abort traversal of a wait-for graph and report a deadlock. - - @param node Node which we were about to visit when abort - was initiated. -*/ - -void Deadlock_detection_visitor::abort_traversal(MDL_context *node) -{ - DBUG_ASSERT(! m_victim); - m_found_deadlock= TRUE; - opt_change_victim_to(node); -} - - /** Get a bit corresponding to enum_mdl_type value in a granted/waiting bitmaps and compatibility matrices. @@ -2064,13 +2056,8 @@ bool MDL_lock::visit_subgraph(MDL_ticket *waiting_ticket, are visiting it but this is OK: in the worst case we might do some extra work and one more context might be chosen as a victim. */ - ++gvisitor->m_current_search_depth; - if (gvisitor->enter_node(src_ctx)) - { - --gvisitor->m_current_search_depth; goto end; - } /* We do a breadth-first search first -- that is, inspect all @@ -2127,7 +2114,6 @@ bool MDL_lock::visit_subgraph(MDL_ticket *waiting_ticket, end_leave_node: gvisitor->leave_node(src_ctx); - --gvisitor->m_current_search_depth; end: mysql_prlock_unlock(&m_rwlock); diff --git a/sql/mdl.h b/sql/mdl.h index e1d4cf74dd6..7938d833eac 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -385,10 +385,7 @@ public: virtual bool inspect_edge(MDL_context *dest) = 0; virtual ~MDL_wait_for_graph_visitor(); - MDL_wait_for_graph_visitor() :m_lock_open_count(0), - m_current_search_depth(0) - { } - virtual void abort_traversal(MDL_context *node) = 0; + MDL_wait_for_graph_visitor() :m_lock_open_count(0) {} public: /** XXX, hack: During deadlock search, we may need to @@ -399,17 +396,6 @@ public: LOCK_open since it has significant performance impacts. */ uint m_lock_open_count; - /** - Set to the 0 at start. Increased whenever - we descend into another MDL context (aka traverse to the next - wait-for graph node). When MAX_SEARCH_DEPTH is reached, we - assume that a deadlock is found, even if we have not found a - loop. - - XXX: This member belongs to this class only temporarily until - bug #56405 is fixed. - */ - uint m_current_search_depth; }; /** diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 634d950cab7..8305283cd17 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -100,14 +100,11 @@ bool No_such_table_error_handler::safely_trapped_errors() TABLE_SHAREs, refresh_version and the table id counter. */ mysql_mutex_t LOCK_open; -mysql_mutex_t LOCK_dd_owns_lock_open; -uint dd_owns_lock_open= 0; #ifdef HAVE_PSI_INTERFACE -static PSI_mutex_key key_LOCK_open, key_LOCK_dd_owns_lock_open; +static PSI_mutex_key key_LOCK_open; static PSI_mutex_info all_tdc_mutexes[]= { - { &key_LOCK_open, "LOCK_open", PSI_FLAG_GLOBAL }, - { &key_LOCK_dd_owns_lock_open, "LOCK_dd_owns_lock_open", PSI_FLAG_GLOBAL } + { &key_LOCK_open, "LOCK_open", PSI_FLAG_GLOBAL } }; /** @@ -302,8 +299,6 @@ bool table_def_init(void) init_tdc_psi_keys(); #endif mysql_mutex_init(key_LOCK_open, &LOCK_open, MY_MUTEX_INIT_FAST); - mysql_mutex_init(key_LOCK_dd_owns_lock_open, &LOCK_dd_owns_lock_open, - MY_MUTEX_INIT_FAST); oldest_unused_share= &end_of_unused_share; end_of_unused_share.prev= &oldest_unused_share; @@ -347,7 +342,6 @@ void table_def_free(void) table_def_inited= 0; /* Free table definitions. */ my_hash_free(&table_def_cache); - mysql_mutex_destroy(&LOCK_dd_owns_lock_open); mysql_mutex_destroy(&LOCK_open); } DBUG_VOID_RETURN; diff --git a/sql/sql_base.h b/sql/sql_base.h index 509760909da..7ae3971942b 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -70,8 +70,6 @@ enum enum_tdc_remove_table_type {TDC_RT_REMOVE_ALL, TDC_RT_REMOVE_NOT_OWN, bool check_dup(const char *db, const char *name, TABLE_LIST *tables); extern mysql_mutex_t LOCK_open; -extern mysql_mutex_t LOCK_dd_owns_lock_open; -extern uint dd_owns_lock_open; bool table_cache_init(void); void table_cache_free(void); bool table_def_init(void); diff --git a/sql/table.cc b/sql/table.cc index 21545f9ec75..e84991912a4 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3085,30 +3085,7 @@ bool TABLE_SHARE::visit_subgraph(Wait_for_flush *wait_for_flush, holding a write-lock on MDL_lock::m_rwlock. */ if (gvisitor->m_lock_open_count++ == 0) - { - /* - To circumvent bug #56405 "Deadlock in the MDL deadlock detector" - we don't try to lock LOCK_open mutex if some thread doing - deadlock detection already owns it and current search depth is - greater than 0. Instead we report a deadlock. - - TODO/FIXME: The proper fix for this bug is to use rwlocks for - protection of table shares/instead of LOCK_open. - Unfortunately it requires more effort/has significant - performance effect. - */ - mysql_mutex_lock(&LOCK_dd_owns_lock_open); - if (gvisitor->m_current_search_depth > 0 && dd_owns_lock_open > 0) - { - mysql_mutex_unlock(&LOCK_dd_owns_lock_open); - --gvisitor->m_lock_open_count; - gvisitor->abort_traversal(src_ctx); - return TRUE; - } - ++dd_owns_lock_open; - mysql_mutex_unlock(&LOCK_dd_owns_lock_open); mysql_mutex_lock(&LOCK_open); - } I_P_List_iterator tables_it(used_tables); @@ -3123,12 +3100,8 @@ bool TABLE_SHARE::visit_subgraph(Wait_for_flush *wait_for_flush, goto end; } - ++gvisitor->m_current_search_depth; if (gvisitor->enter_node(src_ctx)) - { - --gvisitor->m_current_search_depth; goto end; - } while ((table= tables_it++)) { @@ -3151,16 +3124,10 @@ bool TABLE_SHARE::visit_subgraph(Wait_for_flush *wait_for_flush, end_leave_node: gvisitor->leave_node(src_ctx); - --gvisitor->m_current_search_depth; end: if (gvisitor->m_lock_open_count-- == 1) - { mysql_mutex_unlock(&LOCK_open); - mysql_mutex_lock(&LOCK_dd_owns_lock_open); - --dd_owns_lock_open; - mysql_mutex_unlock(&LOCK_dd_owns_lock_open); - } return result; } From 2dd56c26cb727c737794535d96e291e843c83fb1 Mon Sep 17 00:00:00 2001 From: "Bernt M. Johnsen" Date: Thu, 30 Sep 2010 15:52:39 +0200 Subject: [PATCH 177/183] Bug#56375 Ignore socket path since it may vary. Added some comments to inline perl in the test. --- mysql-test/include/mysqld--help.inc | 16 ++++++++++++++-- mysql-test/r/mysqld--help-notwin.result | 1 - 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/mysql-test/include/mysqld--help.inc b/mysql-test/include/mysqld--help.inc index 3c50e50ac0e..5d20cff2c13 100644 --- a/mysql-test/include/mysqld--help.inc +++ b/mysql-test/include/mysqld--help.inc @@ -7,15 +7,27 @@ # force lower-case-table-names=1 (linux/macosx have different defaults) # force symbolic-links=0 (valgrind build has a different default) # + exec $MYSQLD_BOOTSTRAP_CMD --symbolic-links=0 --lower-case-table-names=1 --help --verbose > $MYSQL_TMP_DIR/mysqld--help.txt 2>&1; +# The inline perl code below will copy $MYSQL_TMP_DIR/mysqld--help.txt +# to output, but filter away some variable stuff (e.g. paths). + perl; + # Variables which we don't want to display in the result file since + # their paths may vary: @skipvars=qw/basedir open-files-limit general-log-file log plugin-dir log-slow-queries pid-file slow-query-log-file - datadir slave-load-tmpdir tmpdir/; + datadir slave-load-tmpdir tmpdir socket/; + + # Plugins which may or may not be there: @plugins=qw/innodb ndb archive blackhole federated partition ndbcluster debug temp-pool ssl des-key-file thread-concurrency super-large-pages mutex-deadlock-detector null-audit/; - @env=qw/MYSQLTEST_VARDIR MYSQL_TEST_DIR MYSQL_LIBDIR MYSQL_CHARSETSDIR MYSQL_SHAREDIR /; + + # And substitute the content some environment variables with their + # names: + @env=qw/MYSQLTEST_VARDIR MYSQL_TEST_DIR MYSQL_LIBDIR MYSQL_CHARSETSDIR MYSQL_SHAREDIR/; + $re1=join('|', @skipvars, @plugins); $re2=join('|', @plugins); $skip=0; diff --git a/mysql-test/r/mysqld--help-notwin.result b/mysql-test/r/mysqld--help-notwin.result index 025f67082ec..63e17e1c188 100644 --- a/mysql-test/r/mysqld--help-notwin.result +++ b/mysql-test/r/mysqld--help-notwin.result @@ -913,7 +913,6 @@ slave-transaction-retries 10 slave-type-conversions slow-launch-time 2 slow-query-log FALSE -socket /tmp/mysql.sock sort-buffer-size 2097152 sporadic-binlog-dump-fail FALSE sql-mode From d7bfd59a5a7c94ca337714377975c5927b09b69a Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Thu, 30 Sep 2010 15:57:33 +0200 Subject: [PATCH 178/183] Bug#55458: Partitioned MyISAM table gets crashed by multi-table update Bug#57113: ha_partition::extra(ha_extra_function): Assertion `m_extra_cache' failed Fix for bug#55458 included DBUG_ASSERTS causing debug builds of the server to crash on another multi-table update. Removed the asserts since they where wrong. (updated after testing the patch in 5.5). --- mysql-test/r/partition.result | 15 +++++++++++++++ mysql-test/t/partition.test | 22 ++++++++++++++++++++++ sql/ha_partition.cc | 18 +++++++++++------- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index bb1635b8621..1267ec70b0a 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1,5 +1,20 @@ drop table if exists t1, t2; # +# Bug#57113: ha_partition::extra(ha_extra_function): +# Assertion `m_extra_cache' failed +CREATE TABLE t1 +(id INT NOT NULL PRIMARY KEY, +name VARCHAR(16) NOT NULL, +year YEAR, +INDEX name (name(8)) +) +PARTITION BY HASH(id) PARTITIONS 2; +INSERT INTO t1 VALUES ( 1, 'FooBar', '1924' ); +CREATE TABLE t2 (id INT); +INSERT INTO t2 VALUES (1),(2); +UPDATE t1, t2 SET t1.year = '1955' WHERE t1.name = 'FooBar'; +DROP TABLE t1, t2; +# # Bug#55458: Partitioned MyISAM table gets crashed by multi-table update # CREATE TABLE t1 ( diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 95d702ee6b8..86e2603cd01 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -14,6 +14,28 @@ drop table if exists t1, t2; --enable_warnings +--echo # +--echo # Bug#57113: ha_partition::extra(ha_extra_function): +--echo # Assertion `m_extra_cache' failed +CREATE TABLE t1 +(id INT NOT NULL PRIMARY KEY, + name VARCHAR(16) NOT NULL, + year YEAR, + INDEX name (name(8)) +) +PARTITION BY HASH(id) PARTITIONS 2; + +INSERT INTO t1 VALUES ( 1, 'FooBar', '1924' ); + +CREATE TABLE t2 (id INT); + +INSERT INTO t2 VALUES (1),(2); + +UPDATE t1, t2 SET t1.year = '1955' WHERE t1.name = 'FooBar'; + +DROP TABLE t1, t2; + + --echo # --echo # Bug#55458: Partitioned MyISAM table gets crashed by multi-table update --echo # diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 4fff6cc703c..42920ef18f7 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -5550,7 +5550,6 @@ int ha_partition::extra(enum ha_extra_function operation) DBUG_RETURN(prepare_for_rename()); break; case HA_EXTRA_PREPARE_FOR_UPDATE: - DBUG_ASSERT(m_extra_cache); /* Needs to be run on the first partition in the range now, and later in late_extra_cache, when switching to a new partition to scan. @@ -5558,6 +5557,8 @@ int ha_partition::extra(enum ha_extra_function operation) m_extra_prepare_for_update= TRUE; if (m_part_spec.start_part != NO_CURRENT_PART_ID) { + if (!m_extra_cache) + m_extra_cache_part_id= m_part_spec.start_part; DBUG_ASSERT(m_extra_cache_part_id == m_part_spec.start_part); VOID(m_file[m_part_spec.start_part]->extra(HA_EXTRA_PREPARE_FOR_UPDATE)); } @@ -5820,19 +5821,22 @@ void ha_partition::late_extra_cache(uint partition_id) { handler *file; DBUG_ENTER("ha_partition::late_extra_cache"); - DBUG_PRINT("info", ("extra_cache %u partid %u size %u", m_extra_cache, + DBUG_PRINT("info", ("extra_cache %u prepare %u partid %u size %u", + m_extra_cache, m_extra_prepare_for_update, partition_id, m_extra_cache_size)); if (!m_extra_cache && !m_extra_prepare_for_update) DBUG_VOID_RETURN; file= m_file[partition_id]; - if (m_extra_cache_size == 0) - VOID(file->extra(HA_EXTRA_CACHE)); - else - VOID(file->extra_opt(HA_EXTRA_CACHE, m_extra_cache_size)); + if (m_extra_cache) + { + if (m_extra_cache_size == 0) + VOID(file->extra(HA_EXTRA_CACHE)); + else + VOID(file->extra_opt(HA_EXTRA_CACHE, m_extra_cache_size)); + } if (m_extra_prepare_for_update) { - DBUG_ASSERT(m_extra_cache); VOID(file->extra(HA_EXTRA_PREPARE_FOR_UPDATE)); } m_extra_cache_part_id= partition_id; From 2a67a3a7f5ec9339fd0c31aa7071f32e3b8a75de Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Fri, 1 Oct 2010 13:22:11 +0200 Subject: [PATCH 179/183] Bug#56172: Server crashes in ha_partition::reset on REBUILD PARTITION under LOCK TABLE Collapsed patch including updates from the reviews. In case of failure in ALTER ... PARTITION under LOCK TABLE the server could crash, due to it had modified the locked table object, which was not reverted in case of failure, resulting in a bad table definition used after the failed command. Solved by instead of altering the locked table object and its partition_info struct, creating an internal temporary intermediate table object used for altering, just like the non partitioned mysql_alter_table. So if an error occur before the alter operation is complete, the original table is not modified at all. But if the alter operation have succeeded so far that it must be completed as whole, the table is properly closed and reopened. (The completion on failure is done by the ddl_log.) --- mysql-test/suite/parts/inc/partition_fail.inc | 20 + .../parts/r/partition_debug_innodb.result | 1886 ++++++++++++++- .../parts/r/partition_debug_myisam.result | 2016 ++++++++++++++++- .../parts/r/partition_special_innodb.result | 5 +- .../parts/t/partition_special_innodb.test | 2 +- sql/sql_partition.cc | 428 ++-- sql/sql_partition.h | 8 +- sql/sql_table.cc | 17 +- 8 files changed, 4164 insertions(+), 218 deletions(-) diff --git a/mysql-test/suite/parts/inc/partition_fail.inc b/mysql-test/suite/parts/inc/partition_fail.inc index 6942b40042a..995a1f895e4 100644 --- a/mysql-test/suite/parts/inc/partition_fail.inc +++ b/mysql-test/suite/parts/inc/partition_fail.inc @@ -16,3 +16,23 @@ SHOW CREATE TABLE t1; --sorted_result SELECT * FROM t1; DROP TABLE t1; + +--echo # Same test under LOCK TABLE +--eval $create_statement +--eval $insert_statement +--echo # State before failure +--list_files $DATADIR/test +SHOW CREATE TABLE t1; +--sorted_result +SELECT * FROM t1; +LOCK TABLE t1 WRITE; +--disable_abort_on_error +--eval $fail_statement +--enable_abort_on_error +--echo # State after failure +--list_files $DATADIR/test +SHOW CREATE TABLE t1; +--sorted_result +SELECT * FROM t1; +UNLOCK TABLES; +DROP TABLE t1; diff --git a/mysql-test/suite/parts/r/partition_debug_innodb.result b/mysql-test/suite/parts/r/partition_debug_innodb.result index eb2218e204e..49d863bca8e 100644 --- a/mysql-test/suite/parts/r/partition_debug_innodb.result +++ b/mysql-test/suite/parts/r/partition_debug_innodb.result @@ -747,6 +747,67 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_1"; SET SESSION debug="+d,fail_add_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -807,6 +868,67 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_2"; SET SESSION debug="+d,fail_add_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -867,6 +989,67 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_3"; SET SESSION debug="+d,fail_add_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -927,6 +1110,67 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_4"; SET SESSION debug="+d,fail_add_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -987,6 +1231,67 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_5"; SET SESSION debug="+d,fail_add_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -1047,6 +1352,67 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_6"; SET SESSION debug="+d,fail_add_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -1107,6 +1473,67 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_7"; SET SESSION debug="+d,fail_add_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -1169,6 +1596,69 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1#P#p20.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_8"; SET SESSION debug="+d,fail_add_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -1231,6 +1721,69 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1#P#p20.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_9"; SET SESSION debug="+d,fail_add_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -1293,6 +1846,69 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1#P#p20.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_10"; # Test DROP PARTITION SET SESSION debug="+d,crash_drop_partition_1"; @@ -1902,6 +2518,66 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_1"; SET SESSION debug="+d,fail_drop_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -1961,6 +2637,66 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_2"; SET SESSION debug="+d,fail_drop_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -2020,6 +2756,66 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_3"; SET SESSION debug="+d,fail_drop_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -2073,6 +2869,60 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_4"; SET SESSION debug="+d,fail_drop_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -2126,6 +2976,60 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_5"; SET SESSION debug="+d,fail_drop_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -2179,6 +3083,60 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_6"; SET SESSION debug="+d,fail_drop_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -2232,6 +3190,60 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_7"; SET SESSION debug="+d,fail_drop_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -2285,6 +3297,60 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_8"; SET SESSION debug="+d,fail_drop_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -2338,6 +3404,60 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_9"; # Test change partition (REORGANIZE/REBUILD/COALESCE # or ADD HASH PARTITION). @@ -2730,6 +3850,7 @@ t1.par # State after crash recovery t1#P#p0.ibd t1#P#p10.ibd +t1#P#p20.ibd t1.frm t1.par SHOW CREATE TABLE t1; @@ -2740,7 +3861,8 @@ t1 CREATE TABLE `t1` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, - PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = InnoDB, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = InnoDB) */ SELECT * FROM t1; a b 1 Original from partition p0 @@ -2861,8 +3983,6 @@ ALTER TABLE t1 REORGANIZE PARTITION p10 INTO PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); ERROR HY000: Lost connection to MySQL server during query # State after crash (before recovery) -#sql-t1.frm -#sql-t1.par t1#P#p0.ibd t1#P#p10#TMP#.ibd t1#P#p10.ibd @@ -3237,6 +4357,68 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_1"; SET SESSION debug="+d,fail_change_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -3298,6 +4480,68 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_2"; SET SESSION debug="+d,fail_change_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -3359,6 +4603,68 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_3"; SET SESSION debug="+d,fail_change_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -3420,6 +4726,68 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_4"; SET SESSION debug="+d,fail_change_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -3481,6 +4849,68 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_5"; SET SESSION debug="+d,fail_change_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -3520,6 +4950,40 @@ ERROR HY000: Unknown error # State after failure t1#P#p0.ibd t1#P#p10.ibd +t1#P#p20.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = InnoDB, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd t1.frm t1.par SHOW CREATE TABLE t1; @@ -3541,6 +5005,38 @@ a b 2 Original from partition p0 3 Original from partition p0 4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1#P#p20.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = InnoDB, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_6"; SET SESSION debug="+d,fail_change_partition_7"; @@ -3605,6 +5101,70 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1#P#p20.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = InnoDB, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_7"; SET SESSION debug="+d,fail_change_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -3668,6 +5228,70 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1#P#p20.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = InnoDB, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_8"; SET SESSION debug="+d,fail_change_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -3731,6 +5355,70 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1#P#p20.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = InnoDB, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_9"; SET SESSION debug="+d,fail_change_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -3794,6 +5482,70 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1#P#p20.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = InnoDB, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_10"; SET SESSION debug="+d,fail_change_partition_11"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -3857,6 +5609,70 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1#P#p20.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = InnoDB, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_11"; SET SESSION debug="+d,fail_change_partition_12"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -3920,4 +5736,68 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'InnoDB' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.ibd +t1#P#p10.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.ibd +t1#P#p10.ibd +t1#P#p20.ibd +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = InnoDB, + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = InnoDB, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = InnoDB) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_12"; diff --git a/mysql-test/suite/parts/r/partition_debug_myisam.result b/mysql-test/suite/parts/r/partition_debug_myisam.result index d3f40aedee5..ca3dd708972 100644 --- a/mysql-test/suite/parts/r/partition_debug_myisam.result +++ b/mysql-test/suite/parts/r/partition_debug_myisam.result @@ -817,6 +817,71 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_1"; SET SESSION debug="+d,fail_add_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -881,6 +946,71 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_2"; SET SESSION debug="+d,fail_add_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -945,6 +1075,71 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_3"; SET SESSION debug="+d,fail_add_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -1009,6 +1204,71 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_4"; SET SESSION debug="+d,fail_add_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -1073,6 +1333,71 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_5"; SET SESSION debug="+d,fail_add_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -1137,6 +1462,71 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_6"; SET SESSION debug="+d,fail_add_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -1201,6 +1591,71 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_7"; SET SESSION debug="+d,fail_add_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -1268,6 +1723,74 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1#P#p20.MYD +t1#P#p20.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_8"; SET SESSION debug="+d,fail_add_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -1335,6 +1858,74 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1#P#p20.MYD +t1#P#p20.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_9"; SET SESSION debug="+d,fail_add_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -1402,6 +1993,74 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD PARTITION +(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1#P#p20.MYD +t1#P#p20.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_add_partition_10"; # Test DROP PARTITION SET SESSION debug="+d,crash_drop_partition_1"; @@ -2061,6 +2720,70 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_1"; SET SESSION debug="+d,fail_drop_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -2124,6 +2847,70 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_2"; SET SESSION debug="+d,fail_drop_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -2187,6 +2974,70 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_3"; SET SESSION debug="+d,fail_drop_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -2243,6 +3094,63 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_4"; SET SESSION debug="+d,fail_drop_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -2299,6 +3207,63 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_5"; SET SESSION debug="+d,fail_drop_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -2355,6 +3320,63 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_6"; SET SESSION debug="+d,fail_drop_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -2411,6 +3433,63 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_7"; SET SESSION debug="+d,fail_drop_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -2467,6 +3546,63 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_8"; SET SESSION debug="+d,fail_drop_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -2523,6 +3659,63 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 DROP PARTITION p10; +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_drop_partition_9"; # Test change partition (REORGANIZE/REBUILD/COALESCE # or ADD HASH PARTITION). @@ -2957,6 +4150,8 @@ t1#P#p0.MYD t1#P#p0.MYI t1#P#p10.MYD t1#P#p10.MYI +t1#P#p20.MYD +t1#P#p20.MYI t1.frm t1.par SHOW CREATE TABLE t1; @@ -2967,7 +4162,8 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, - PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = MyISAM, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = MyISAM) */ SELECT * FROM t1; a b 1 Original from partition p0 @@ -3099,8 +4295,6 @@ ALTER TABLE t1 REORGANIZE PARTITION p10 INTO PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); ERROR HY000: Lost connection to MySQL server during query # State after crash (before recovery) -#sql-t1.frm -#sql-t1.par t1#P#p0.MYD t1#P#p0.MYI t1#P#p10#TMP#.MYD @@ -3520,6 +4714,72 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_1"; SET SESSION debug="+d,fail_change_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -3585,6 +4845,72 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_2"; SET SESSION debug="+d,fail_change_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -3650,6 +4976,72 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_3"; SET SESSION debug="+d,fail_change_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -3715,6 +5107,72 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_4"; SET SESSION debug="+d,fail_change_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -3780,6 +5238,72 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_5"; SET SESSION debug="+d,fail_change_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -3823,6 +5347,43 @@ t1#P#p0.MYD t1#P#p0.MYI t1#P#p10.MYD t1#P#p10.MYI +t1#P#p20.MYD +t1#P#p20.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = MyISAM, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI t1.frm t1.par SHOW CREATE TABLE t1; @@ -3844,6 +5405,41 @@ a b 2 Original from partition p0 3 Original from partition p0 4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1#P#p20.MYD +t1#P#p20.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = MyISAM, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_6"; SET SESSION debug="+d,fail_change_partition_7"; @@ -3913,6 +5509,75 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1#P#p20.MYD +t1#P#p20.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = MyISAM, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_7"; SET SESSION debug="+d,fail_change_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -3981,6 +5646,75 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1#P#p20.MYD +t1#P#p20.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = MyISAM, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_8"; SET SESSION debug="+d,fail_change_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -4049,6 +5783,75 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1#P#p20.MYD +t1#P#p20.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = MyISAM, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_9"; SET SESSION debug="+d,fail_change_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -4117,6 +5920,75 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1#P#p20.MYD +t1#P#p20.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = MyISAM, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_10"; SET SESSION debug="+d,fail_change_partition_11"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -4185,6 +6057,75 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1#P#p20.MYD +t1#P#p20.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = MyISAM, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_11"; SET SESSION debug="+d,fail_change_partition_12"; CREATE TABLE t1 (a INT, b VARCHAR(64)) @@ -4253,4 +6194,73 @@ a b 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; +# Same test under LOCK TABLE +CREATE TABLE t1 (a INT, b VARCHAR(64)) +ENGINE = 'MyISAM' +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9), +PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19)); +INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1"); +# State before failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +LOCK TABLE t1 WRITE; +ALTER TABLE t1 REORGANIZE PARTITION p10 INTO +(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19), +PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29)); +ERROR HY000: Unknown error +# State after failure +t1#P#p0.MYD +t1#P#p0.MYI +t1#P#p10.MYD +t1#P#p10.MYI +t1#P#p20.MYD +t1#P#p20.MYI +t1.frm +t1.par +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9) ENGINE = MyISAM, + PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19) ENGINE = MyISAM, + PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29) ENGINE = MyISAM) */ +SELECT * FROM t1; +a b +1 Original from partition p0 +11 Original from partition p1 +12 Original from partition p1 +13 Original from partition p1 +14 Original from partition p1 +2 Original from partition p0 +3 Original from partition p0 +4 Original from partition p0 +UNLOCK TABLES; +DROP TABLE t1; SET SESSION debug="-d,fail_change_partition_12"; diff --git a/mysql-test/suite/parts/r/partition_special_innodb.result b/mysql-test/suite/parts/r/partition_special_innodb.result index b8dffd61fbe..c1213e86afc 100644 --- a/mysql-test/suite/parts/r/partition_special_innodb.result +++ b/mysql-test/suite/parts/r/partition_special_innodb.result @@ -238,11 +238,10 @@ LOCK TABLE t1 READ; # Third attempt: says that the table does not exist ALTER TABLE t1 ADD PARTITION PARTITIONS 2; ERROR HY000: Lock wait timeout exceeded; try restarting transaction -# Check table returns the same +# Check table returns the same (not after fixing bug#56172!) CHECK TABLE t1; Table Op Msg_type Msg_text -test.t1 check Error Lock wait timeout exceeded; try restarting transaction -test.t1 check error Corrupt +test.t1 check status OK UNLOCK TABLES; DROP TABLE t1; CREATE TABLE t2 ( i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f INT ) diff --git a/mysql-test/suite/parts/t/partition_special_innodb.test b/mysql-test/suite/parts/t/partition_special_innodb.test index 9c26ab6fdb4..1c36299f4bd 100644 --- a/mysql-test/suite/parts/t/partition_special_innodb.test +++ b/mysql-test/suite/parts/t/partition_special_innodb.test @@ -111,7 +111,7 @@ LOCK TABLE t1 READ; --echo # Third attempt: says that the table does not exist --error ER_LOCK_WAIT_TIMEOUT ALTER TABLE t1 ADD PARTITION PARTITIONS 2; ---echo # Check table returns the same +--echo # Check table returns the same (not after fixing bug#56172!) CHECK TABLE t1; --connection con1 diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index b72816f8ce3..f7aba395ed8 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -70,6 +70,7 @@ #ifdef WITH_PARTITION_STORAGE_ENGINE #include "ha_partition.h" +/* TODO: Change abort() to DBUG_SUICIDE() when bug#52002 is pushed */ #define ERROR_INJECT_CRASH(code) \ DBUG_EVALUATE_IF(code, (abort(), 0), 0) #define ERROR_INJECT_ERROR(code) \ @@ -4353,43 +4354,31 @@ set_engine_all_partitions(partition_info *part_info, } } while (++i < part_info->num_parts); } -/* - SYNOPSIS - fast_end_partition() - thd Thread object - out:copied Number of records copied - out:deleted Number of records deleted - table_list Table list with the one table in it - empty Has nothing been done - lpt Struct to be used by error handler - RETURN VALUES - FALSE Success - TRUE Failure - DESCRIPTION - Support routine to handle the successful cases for partition - management. +/** + Support routine to handle the successful cases for partition management. + + @param thd Thread object + @param copied Number of records copied + @param deleted Number of records deleted + @param table_list Table list with the one table in it + + @return Operation status + @retval FALSE Success + @retval TRUE Failure */ static int fast_end_partition(THD *thd, ulonglong copied, ulonglong deleted, - TABLE_LIST *table_list, bool is_empty, - ALTER_PARTITION_PARAM_TYPE *lpt, - bool written_bin_log) + TABLE_LIST *table_list) { char tmp_name[80]; DBUG_ENTER("fast_end_partition"); thd->proc_info="end"; - if (!is_empty) - query_cache_invalidate3(thd, table_list, 0); - - if ((!is_empty) && (!written_bin_log) && - (!thd->lex->no_write_to_binlog) && - write_bin_log(thd, FALSE, thd->query(), thd->query_length())) - DBUG_RETURN(TRUE); + query_cache_invalidate3(thd, table_list, 0); my_snprintf(tmp_name, sizeof(tmp_name), ER(ER_INSERT_INFO), (ulong) (copied + deleted), @@ -4511,29 +4500,25 @@ uint set_part_state(Alter_info *alter_info, partition_info *tab_part_info, } -/* +/** Prepare for ALTER TABLE of partition structure - SYNOPSIS - prep_alter_part_table() - thd Thread object - table Table object - inout:alter_info Alter information - inout:create_info Create info for CREATE TABLE - old_db_type Old engine type - out:partition_changed Boolean indicating whether partition changed - out:fast_alter_partition Boolean indicating whether fast partition - change is requested + @param[in] thd Thread object + @param[in] table Table object + @param[in,out] alter_info Alter information + @param[in,out] create_info Create info for CREATE TABLE + @param[in] old_db_type Old engine type + @param[out] partition_changed Boolean indicating whether partition changed + @param[out] fast_alter_table Internal temporary table allowing fast + partition change or NULL if not possible - RETURN VALUES - TRUE Error - FALSE Success - partition_changed - fast_alter_partition + @return Operation status + @retval TRUE Error + @retval FALSE Success - DESCRIPTION + @note This method handles all preparations for ALTER TABLE for partitioned - tables + tables. We need to handle both partition management command such as Add Partition and others here as well as an ALTER TABLE that completely changes the partitioning and yet others that don't change anything at all. We start @@ -4545,8 +4530,12 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, HA_CREATE_INFO *create_info, handlerton *old_db_type, bool *partition_changed, - uint *fast_alter_partition) + char *db, + const char *table_name, + const char *path, + TABLE **fast_alter_table) { + TABLE *new_table= NULL; DBUG_ENTER("prep_alter_part_table"); /* Foreign keys on partitioned tables are not supported, waits for WL#148 */ @@ -4555,15 +4544,9 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, my_error(ER_FOREIGN_KEY_ON_PARTITIONED, MYF(0)); DBUG_RETURN(TRUE); } - /* - We are going to manipulate the partition info on the table object - so we need to ensure that the table instance is removed from the - table cache. - */ - if (table->part_info) - table->m_needs_reopen= TRUE; thd->work_part_info= thd->lex->part_info; + if (thd->work_part_info && !(thd->work_part_info= thd->lex->part_info->get_clone())) DBUG_RETURN(TRUE); @@ -4576,7 +4559,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, ALTER_COALESCE_PARTITION | ALTER_REORGANIZE_PARTITION | ALTER_TABLE_REORG | ALTER_REBUILD_PARTITION)) { - partition_info *tab_part_info= table->part_info; + partition_info *tab_part_info; partition_info *alt_part_info= thd->work_part_info; uint flags= 0; bool is_last_partition_reorged= FALSE; @@ -4584,11 +4567,32 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, part_elem_value *alt_max_elem_val= NULL; longlong tab_max_range= 0, alt_max_range= 0; - if (!tab_part_info) + if (!table->part_info) { my_error(ER_PARTITION_MGMT_ON_NONPARTITIONED, MYF(0)); DBUG_RETURN(TRUE); } + + /* + Open our intermediate table, we will operate on a temporary instance + of the original table, to be able to skip copying all partitions. + Open it as a copy of the original table, and modify its partition_info + object to allow fast_alter_partition_table to perform the changes. + */ + DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, table_name, + MDL_INTENTION_EXCLUSIVE)); + new_table= open_temporary_table(thd, path, db, table_name, 0); + if (!new_table) + DBUG_RETURN(TRUE); + + /* + This table may be used for copy rows between partitions + and also read/write columns when fixing the partition_info struct. + */ + new_table->use_all_columns(); + + tab_part_info= new_table->part_info; + if (alter_info->flags & ALTER_TABLE_REORG) { uint new_part_no, curr_part_no; @@ -4596,9 +4600,9 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, tab_part_info->use_default_num_partitions) { my_error(ER_REORG_NO_PARAM_ERROR, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } - new_part_no= table->file->get_default_no_partitions(create_info); + new_part_no= new_table->file->get_default_no_partitions(create_info); curr_part_no= tab_part_info->num_parts; if (new_part_no == curr_part_no) { @@ -4607,7 +4611,8 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, after the change as before. Thus we can reply ok immediately without any changes at all. */ - *fast_alter_partition= TRUE; + *fast_alter_table= new_table; + thd->work_part_info= tab_part_info; DBUG_RETURN(FALSE); } else if (new_part_no > curr_part_no) @@ -4629,15 +4634,15 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, alter_info->num_parts= curr_part_no - new_part_no; } } - if (!(flags= table->file->alter_table_flags(alter_info->flags))) + if (!(flags= new_table->file->alter_table_flags(alter_info->flags))) { my_error(ER_PARTITION_FUNCTION_FAILURE, MYF(0)); - DBUG_RETURN(1); + goto err; } - *fast_alter_partition= - ((flags & (HA_FAST_CHANGE_PARTITION | HA_PARTITION_ONE_PHASE)) != 0); - DBUG_PRINT("info", ("*fast_alter_partition: %d flags: 0x%x", - *fast_alter_partition, flags)); + if ((flags & (HA_FAST_CHANGE_PARTITION | HA_PARTITION_ONE_PHASE)) != 0) + *fast_alter_table= new_table; + DBUG_PRINT("info", ("*fast_alter_table: %p flags: 0x%x", + *fast_alter_table, flags)); if ((alter_info->flags & ALTER_ADD_PARTITION) || (alter_info->flags & ALTER_REORGANIZE_PARTITION)) { @@ -4648,12 +4653,12 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, if (tab_part_info->part_type == RANGE_PARTITION) { my_error(ER_PARTITIONS_MUST_BE_DEFINED_ERROR, MYF(0), "RANGE"); - DBUG_RETURN(TRUE); + goto err; } else if (tab_part_info->part_type == LIST_PARTITION) { my_error(ER_PARTITIONS_MUST_BE_DEFINED_ERROR, MYF(0), "LIST"); - DBUG_RETURN(TRUE); + goto err; } /* Hash partitions can be altered without parser finds out about @@ -4684,7 +4689,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), "LIST", "IN"); } - DBUG_RETURN(TRUE); + goto err; } } if ((tab_part_info->column_list && @@ -4698,12 +4703,12 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, alt_part_info->num_columns != 0)) { my_error(ER_PARTITION_COLUMN_LIST_ERROR, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } alt_part_info->column_list= tab_part_info->column_list; if (alt_part_info->fix_parser_data(thd)) { - DBUG_RETURN(TRUE); + goto err; } } if (alter_info->flags & ALTER_ADD_PARTITION) @@ -4726,17 +4731,17 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, tab_part_info->part_type != HASH_PARTITION) { my_error(ER_NO_BINLOG_ERROR, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } if (tab_part_info->defined_max_value) { my_error(ER_PARTITION_MAXVALUE_ERROR, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } if (num_new_partitions == 0) { my_error(ER_ADD_PARTITION_NO_NEW_PARTITION, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } if (tab_part_info->is_sub_partitioned()) { @@ -4745,7 +4750,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, else if (alt_part_info->num_subparts != tab_part_info->num_subparts) { my_error(ER_ADD_PARTITION_SUBPART_ERROR, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } check_total_partitions= new_total_partitions* alt_part_info->num_subparts; @@ -4753,15 +4758,15 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, if (check_total_partitions > MAX_PARTITIONS) { my_error(ER_TOO_MANY_PARTITIONS_ERROR, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } alt_part_info->part_type= tab_part_info->part_type; alt_part_info->subpart_type= tab_part_info->subpart_type; - if (alt_part_info->set_up_defaults_for_partitioning(table->file, + if (alt_part_info->set_up_defaults_for_partitioning(new_table->file, ULL(0), tab_part_info->num_parts)) { - DBUG_RETURN(TRUE); + goto err; } /* Handling of on-line cases: @@ -4825,7 +4830,7 @@ adding and copying partitions, the second after completing the adding and copying and finally the third line after also dropping the partitions that are reorganised. */ - if (*fast_alter_partition && + if (*fast_alter_table && tab_part_info->part_type == HASH_PARTITION) { uint part_no= 0, start_part= 1, start_sec_part= 1; @@ -4930,12 +4935,12 @@ that are reorganised. do { partition_element *part_elem= alt_it++; - if (*fast_alter_partition) + if (*fast_alter_table) part_elem->part_state= PART_TO_BE_ADDED; if (tab_part_info->partitions.push_back(part_elem)) { mem_alloc_error(1); - DBUG_RETURN(TRUE); + goto err; } } while (++part_count < num_new_partitions); tab_part_info->num_parts+= num_new_partitions; @@ -4976,12 +4981,12 @@ that are reorganised. tab_part_info->part_type == LIST_PARTITION)) { my_error(ER_ONLY_ON_RANGE_LIST_PARTITION, MYF(0), "DROP"); - DBUG_RETURN(TRUE); + goto err; } if (num_parts_dropped >= tab_part_info->num_parts) { my_error(ER_DROP_LAST_PARTITION, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } do { @@ -4999,12 +5004,12 @@ that are reorganised. if (num_parts_found != num_parts_dropped) { my_error(ER_DROP_PARTITION_NON_EXISTENT, MYF(0), "DROP"); - DBUG_RETURN(TRUE); + goto err; } - if (table->file->is_fk_defined_on_table_or_index(MAX_KEY)) + if (new_table->file->is_fk_defined_on_table_or_index(MAX_KEY)) { my_error(ER_ROW_IS_REFERENCED, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } tab_part_info->num_parts-= num_parts_dropped; } @@ -5017,12 +5022,12 @@ that are reorganised. (!(alter_info->flags & ALTER_ALL_PARTITION))) { my_error(ER_DROP_PARTITION_NON_EXISTENT, MYF(0), "REBUILD"); - DBUG_RETURN(TRUE); + goto err; } - if (!(*fast_alter_partition)) + if (!(*fast_alter_table)) { - table->file->print_error(HA_ERR_WRONG_COMMAND, MYF(0)); - DBUG_RETURN(TRUE); + new_table->file->print_error(HA_ERR_WRONG_COMMAND, MYF(0)); + goto err; } } else if (alter_info->flags & ALTER_COALESCE_PARTITION) @@ -5033,17 +5038,17 @@ that are reorganised. if (tab_part_info->part_type != HASH_PARTITION) { my_error(ER_COALESCE_ONLY_ON_HASH_PARTITION, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } if (num_parts_coalesced == 0) { my_error(ER_COALESCE_PARTITION_NO_PARTITION, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } if (num_parts_coalesced >= tab_part_info->num_parts) { my_error(ER_DROP_LAST_PARTITION, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } /* Online handling: @@ -5082,7 +5087,7 @@ state of p1. uint part_count= 0, start_part= 1, start_sec_part= 1; uint end_part= 0, end_sec_part= 0; bool all_parts= TRUE; - if (*fast_alter_partition && + if (*fast_alter_table && tab_part_info->linear_hash_ind) { uint upper_2n= tab_part_info->linear_hash_mask + 1; @@ -5108,14 +5113,14 @@ state of p1. do { partition_element *p_elem= part_it++; - if (*fast_alter_partition && + if (*fast_alter_table && (all_parts || (part_count >= start_part && part_count <= end_part) || (part_count >= start_sec_part && part_count <= end_sec_part))) p_elem->part_state= PART_CHANGED; if (++part_count > num_parts_remain) { - if (*fast_alter_partition) + if (*fast_alter_table) p_elem->part_state= PART_REORGED_DROPPED; else part_it.remove(); @@ -5150,38 +5155,38 @@ state of p1. if (num_parts_reorged > tab_part_info->num_parts) { my_error(ER_REORG_PARTITION_NOT_EXIST, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } if (!(tab_part_info->part_type == RANGE_PARTITION || tab_part_info->part_type == LIST_PARTITION) && (num_parts_new != num_parts_reorged)) { my_error(ER_REORG_HASH_ONLY_ON_SAME_NO, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } if (tab_part_info->is_sub_partitioned() && alt_part_info->num_subparts && alt_part_info->num_subparts != tab_part_info->num_subparts) { my_error(ER_PARTITION_WRONG_NO_SUBPART_ERROR, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } check_total_partitions= tab_part_info->num_parts + num_parts_new; check_total_partitions-= num_parts_reorged; if (check_total_partitions > MAX_PARTITIONS) { my_error(ER_TOO_MANY_PARTITIONS_ERROR, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } alt_part_info->part_type= tab_part_info->part_type; alt_part_info->subpart_type= tab_part_info->subpart_type; alt_part_info->num_subparts= tab_part_info->num_subparts; DBUG_ASSERT(!alt_part_info->use_default_partitions); - if (alt_part_info->set_up_defaults_for_partitioning(table->file, + if (alt_part_info->set_up_defaults_for_partitioning(new_table->file, ULL(0), 0)) { - DBUG_RETURN(TRUE); + goto err; } /* Online handling: @@ -5240,13 +5245,13 @@ the generated partition syntax in a correct manner. } else tab_max_range= part_elem->range_value; - if (*fast_alter_partition && + if (*fast_alter_table && tab_part_info->temp_partitions.push_back(part_elem)) { mem_alloc_error(1); - DBUG_RETURN(TRUE); + goto err; } - if (*fast_alter_partition) + if (*fast_alter_table) part_elem->part_state= PART_TO_BE_REORGED; if (!found_first) { @@ -5266,7 +5271,7 @@ the generated partition syntax in a correct manner. else alt_max_range= alt_part_elem->range_value; - if (*fast_alter_partition) + if (*fast_alter_table) alt_part_elem->part_state= PART_TO_BE_ADDED; if (alt_part_count == 0) tab_it.replace(alt_part_elem); @@ -5277,7 +5282,7 @@ the generated partition syntax in a correct manner. else if (found_last) { my_error(ER_CONSECUTIVE_REORG_PARTITIONS, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } else tab_it.remove(); @@ -5291,7 +5296,7 @@ the generated partition syntax in a correct manner. if (drop_count != num_parts_reorged) { my_error(ER_DROP_PARTITION_NON_EXISTENT, MYF(0), "REORGANIZE"); - DBUG_RETURN(TRUE); + goto err; } tab_part_info->num_parts= check_total_partitions; } @@ -5312,9 +5317,9 @@ the generated partition syntax in a correct manner. tab_part_info->use_default_num_subpartitions= FALSE; } if (tab_part_info->check_partition_info(thd, (handlerton**)NULL, - table->file, ULL(0), TRUE)) + new_table->file, ULL(0), TRUE)) { - DBUG_RETURN(TRUE); + goto err; } /* The check below needs to be performed after check_partition_info @@ -5346,7 +5351,7 @@ the generated partition syntax in a correct manner. to create "holes". */ my_error(ER_REORG_OUTSIDE_RANGE, MYF(0)); - DBUG_RETURN(TRUE); + goto err; } } } @@ -5463,7 +5468,7 @@ the generated partition syntax in a correct manner. *partition_changed= TRUE; if (thd->work_part_info->fix_parser_data(thd)) { - DBUG_RETURN(TRUE); + goto err; } } /* @@ -5484,7 +5489,7 @@ the generated partition syntax in a correct manner. if (check_native_partitioned(create_info, &is_native_partitioned, part_info, thd)) { - DBUG_RETURN(TRUE); + goto err; } if (!is_native_partitioned) { @@ -5494,6 +5499,17 @@ the generated partition syntax in a correct manner. } } DBUG_RETURN(FALSE); +err: + if (new_table) + { + /* + Only remove the intermediate table object and its share object, + do not remove the .frm file, since it is the original one. + */ + close_temporary(new_table, 1, 0); + } + *fast_alter_table= NULL; + DBUG_RETURN(TRUE); } @@ -5536,6 +5552,11 @@ static bool mysql_change_partitions(ALTER_PARTITION_PARAM_TYPE *lpt) if(mysql_trans_prepare_alter_copy_data(thd)) DBUG_RETURN(TRUE); + if (file->ha_external_lock(thd, F_WRLCK)) + DBUG_RETURN(TRUE); + + /* TODO: test if bulk_insert would increase the performance */ + if ((error= file->ha_change_partitions(lpt->create_info, path, &lpt->copied, &lpt->deleted, lpt->pack_frm_data, lpt->pack_frm_len))) @@ -5544,7 +5565,10 @@ static bool mysql_change_partitions(ALTER_PARTITION_PARAM_TYPE *lpt) } if (mysql_trans_commit_alter_copy_data(thd)) - DBUG_RETURN(TRUE); /* The error has been reported */ + error= 1; /* The error has been reported */ + + if (file->ha_external_lock(thd, F_UNLCK)) + error= 1; DBUG_RETURN(test(error)); } @@ -6294,8 +6318,18 @@ static void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt) { THD *thd= lpt->thd; - close_all_tables_for_name(thd, lpt->table->s, FALSE); + if (lpt->old_table) + close_all_tables_for_name(thd, lpt->old_table->s, FALSE); + if (lpt->table) + { + /* + Only remove the intermediate table object and its share object, + do not remove the .frm file, since it is the original one. + */ + close_temporary(lpt->table, 1, 0); + } lpt->table= 0; + lpt->old_table= 0; lpt->table_list->table= 0; if (thd->locked_tables_list.reopen_tables(thd)) sql_print_warning("We failed to reacquire LOCKs in ALTER TABLE"); @@ -6307,62 +6341,40 @@ static void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt) SYNOPSIS alter_close_tables() lpt Struct carrying parameters + close_old Close original table too RETURN VALUES 0 */ -static int alter_close_tables(ALTER_PARTITION_PARAM_TYPE *lpt) +static int alter_close_tables(ALTER_PARTITION_PARAM_TYPE *lpt, bool close_old) { - TABLE_SHARE *share= lpt->table->s; - THD *thd= lpt->thd; - TABLE *table; DBUG_ENTER("alter_close_tables"); - /* - We must keep LOCK_open while manipulating with thd->open_tables. - Another thread may be working on it. - */ - mysql_mutex_lock(&LOCK_open); - /* - We can safely remove locks for all tables with the same name: - later they will all be closed anyway in - alter_partition_lock_handling(). - */ - for (table= thd->open_tables; table ; table= table->next) + if (lpt->table->db_stat) { - if (!strcmp(table->s->table_name.str, share->table_name.str) && - !strcmp(table->s->db.str, share->db.str)) - { - mysql_lock_remove(thd, thd->lock, table); - table->file->close(); - table->db_stat= 0; // Mark file closed - /* - Ensure that we won't end up with a crippled table instance - in the table cache if an error occurs before we reach - alter_partition_lock_handling() and the table is closed - by close_thread_tables() instead. - */ - tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED, - table->s->db.str, - table->s->table_name.str, TRUE); - } + lpt->table->file->close(); + lpt->table->db_stat= 0; // Mark file closed + } + if (close_old && lpt->old_table) + { + close_all_tables_for_name(lpt->thd, lpt->old_table->s, FALSE); + lpt->old_table= 0; } - mysql_mutex_unlock(&LOCK_open); DBUG_RETURN(0); } -/* - Handle errors for ALTER TABLE for partitioning - SYNOPSIS - handle_alter_part_error() - lpt Struct carrying parameters - not_completed Was request in complete phase when error occurred - RETURN VALUES - NONE +/** + Handle errors for ALTER TABLE for partitioning. + + @param lpt Struct carrying parameters + @param action_completed The action must be completed, NOT reverted + @param drop_partition Partitions has not been dropped yet + @param frm_install The shadow frm-file has not yet been installed + @param close_table Table is still open, close it before reverting */ void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt, - bool not_completed, + bool action_completed, bool drop_partition, bool frm_install, bool close_table) @@ -6379,7 +6391,7 @@ void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt, so we clone it first to have a copy. */ part_info= lpt->part_info->get_clone(); - alter_close_tables(lpt); + alter_close_tables(lpt, action_completed); } if (part_info->first_log_entry && @@ -6392,7 +6404,7 @@ void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt, */ write_log_completed(lpt, FALSE); release_log_entries(part_info); - if (not_completed) + if (!action_completed) { if (drop_partition) { @@ -6457,7 +6469,7 @@ void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt, else { release_log_entries(part_info); - if (not_completed) + if (!action_completed) { /* We hit an error before things were completed but managed @@ -6500,25 +6512,24 @@ static void downgrade_mdl_if_lock_tables_mode(THD *thd, MDL_ticket *ticket, } -/* +/** Actually perform the change requested by ALTER TABLE of partitions previously prepared. - SYNOPSIS - fast_alter_partition_table() - thd Thread object - table Table object - alter_info ALTER TABLE info - create_info Create info for CREATE TABLE - table_list List of the table involved - db Database name of new table - table_name Table name of new table + @param thd Thread object + @param table Original table object + @param alter_info ALTER TABLE info + @param create_info Create info for CREATE TABLE + @param table_list List of the table involved + @param db Database name of new table + @param table_name Table name of new table + @param fast_alter_table Prepared table object - RETURN VALUES - TRUE Error - FALSE Success + @return Operation status + @retval TRUE Error + @retval FALSE Success - DESCRIPTION + @note Perform all ALTER TABLE operations for partitioned tables that can be performed fast without a full copy of the original table. */ @@ -6529,19 +6540,20 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, TABLE_LIST *table_list, char *db, const char *table_name, - uint fast_alter_partition) + TABLE *fast_alter_table) { /* Set-up struct used to write frm files */ - partition_info *part_info= table->part_info; + partition_info *part_info; ALTER_PARTITION_PARAM_TYPE lpt_obj; ALTER_PARTITION_PARAM_TYPE *lpt= &lpt_obj; - bool written_bin_log= TRUE; - bool not_completed= TRUE; + bool action_completed= FALSE; bool close_table_on_failure= FALSE; bool frm_install= FALSE; MDL_ticket *mdl_ticket= table->mdl_ticket; + DBUG_ASSERT(fast_alter_table); DBUG_ENTER("fast_alter_partition_table"); + part_info= fast_alter_table->part_info; lpt->thd= thd; lpt->table_list= table_list; lpt->part_info= part_info; @@ -6550,7 +6562,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, lpt->db_options= create_info->table_options; if (create_info->row_type == ROW_TYPE_DYNAMIC) lpt->db_options|= HA_OPTION_PACK_RECORD; - lpt->table= table; + lpt->table= fast_alter_table; + lpt->old_table= table; lpt->key_info_buffer= 0; lpt->key_count= 0; lpt->db= db; @@ -6559,12 +6572,12 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, lpt->deleted= 0; lpt->pack_frm_data= NULL; lpt->pack_frm_len= 0; - thd->work_part_info= part_info; /* Never update timestamp columns when alter */ - table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET; + lpt->table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET; - if (fast_alter_partition & HA_PARTITION_ONE_PHASE) + if (table->file->alter_table_flags(alter_info->flags) & + HA_PARTITION_ONE_PHASE) { /* In the case where the engine supports one phase online partition @@ -6681,11 +6694,11 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ERROR_INJECT_ERROR("fail_drop_partition_3") || (close_table_on_failure= TRUE, FALSE) || write_log_drop_partition(lpt) || + (action_completed= TRUE, FALSE) || ERROR_INJECT_CRASH("crash_drop_partition_4") || ERROR_INJECT_ERROR("fail_drop_partition_4") || + alter_close_tables(lpt, action_completed) || (close_table_on_failure= FALSE, FALSE) || - (not_completed= FALSE, FALSE) || - alter_close_tables(lpt) || ERROR_INJECT_CRASH("crash_drop_partition_5") || ERROR_INJECT_ERROR("fail_drop_partition_5") || ((!thd->lex->no_write_to_binlog) && @@ -6706,7 +6719,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ERROR_INJECT_ERROR("fail_drop_partition_9") || (alter_partition_lock_handling(lpt), FALSE)) { - handle_alter_part_error(lpt, not_completed, TRUE, frm_install, + handle_alter_part_error(lpt, action_completed, TRUE, frm_install, close_table_on_failure); goto err; } @@ -6761,7 +6774,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ERROR_INJECT_CRASH("crash_add_partition_5") || ERROR_INJECT_ERROR("fail_add_partition_5") || (close_table_on_failure= FALSE, FALSE) || - alter_close_tables(lpt) || + alter_close_tables(lpt, action_completed) || ERROR_INJECT_CRASH("crash_add_partition_6") || ERROR_INJECT_ERROR("fail_add_partition_6") || ((!thd->lex->no_write_to_binlog) && @@ -6770,11 +6783,12 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ERROR_INJECT_CRASH("crash_add_partition_7") || ERROR_INJECT_ERROR("fail_add_partition_7") || write_log_rename_frm(lpt) || - (frm_install= TRUE, FALSE) || - (not_completed= FALSE, FALSE) || + (action_completed= TRUE, FALSE) || ERROR_INJECT_CRASH("crash_add_partition_8") || ERROR_INJECT_ERROR("fail_add_partition_8") || + (frm_install= TRUE, FALSE) || mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) || + (frm_install= FALSE, FALSE) || ERROR_INJECT_CRASH("crash_add_partition_9") || ERROR_INJECT_ERROR("fail_add_partition_9") || (write_log_completed(lpt, FALSE), FALSE) || @@ -6782,7 +6796,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ERROR_INJECT_ERROR("fail_add_partition_10") || (alter_partition_lock_handling(lpt), FALSE)) { - handle_alter_part_error(lpt, not_completed, FALSE, frm_install, + handle_alter_part_error(lpt, action_completed, FALSE, frm_install, close_table_on_failure); goto err; } @@ -6831,10 +6845,10 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, can release all other locks on the table and since no one can open the table, there can be no new threads accessing the table. They will be hanging on this exclusive lock. - 5) Close all instances of the table and remove them from the table cache. - 6) Log that operation is completed and log all complete actions + 5) Log that operation is completed and log all complete actions needed to complete operation from here - 7) Write bin log + 6) Write bin log + 7) Close all instances of the table and remove them from the table cache. 8) Prepare handlers for rename and delete of partitions 9) Rename and drop the reorged partitions such that they are no longer used and rename those added to their real new names. @@ -6858,27 +6872,28 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN) || ERROR_INJECT_CRASH("crash_change_partition_5") || ERROR_INJECT_ERROR("fail_change_partition_5") || - alter_close_tables(lpt) || - (close_table_on_failure= FALSE) || + write_log_final_change_partition(lpt) || + (action_completed= TRUE, FALSE) || ERROR_INJECT_CRASH("crash_change_partition_6") || ERROR_INJECT_ERROR("fail_change_partition_6") || - write_log_final_change_partition(lpt) || - (not_completed= FALSE) || - ERROR_INJECT_CRASH("crash_change_partition_7") || - ERROR_INJECT_ERROR("fail_change_partition_7") || ((!thd->lex->no_write_to_binlog) && (write_bin_log(thd, FALSE, thd->query(), thd->query_length()), FALSE)) || + ERROR_INJECT_CRASH("crash_change_partition_7") || + ERROR_INJECT_ERROR("fail_change_partition_7") || + ((frm_install= TRUE), FALSE) || + mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) || + (frm_install= FALSE, FALSE) || ERROR_INJECT_CRASH("crash_change_partition_8") || ERROR_INJECT_ERROR("fail_change_partition_8") || - mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) || + alter_close_tables(lpt, action_completed) || + (close_table_on_failure= FALSE, FALSE) || ERROR_INJECT_CRASH("crash_change_partition_9") || ERROR_INJECT_ERROR("fail_change_partition_9") || mysql_drop_partitions(lpt) || ERROR_INJECT_CRASH("crash_change_partition_10") || ERROR_INJECT_ERROR("fail_change_partition_10") || mysql_rename_partitions(lpt) || - ((frm_install= TRUE), FALSE) || ERROR_INJECT_CRASH("crash_change_partition_11") || ERROR_INJECT_ERROR("fail_change_partition_11") || (write_log_completed(lpt, FALSE), FALSE) || @@ -6886,7 +6901,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ERROR_INJECT_ERROR("fail_change_partition_12") || (alter_partition_lock_handling(lpt), FALSE)) { - handle_alter_part_error(lpt, not_completed, FALSE, frm_install, + handle_alter_part_error(lpt, action_completed, FALSE, frm_install, close_table_on_failure); goto err; } @@ -6896,12 +6911,25 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, A final step is to write the query to the binlog and send ok to the user */ - DBUG_RETURN(fast_end_partition(thd, lpt->copied, lpt->deleted, - table_list, FALSE, NULL, - written_bin_log)); + DBUG_RETURN(fast_end_partition(thd, lpt->copied, lpt->deleted, table_list)); err: + if (action_completed) + { + /* + Although error occurred, the action was forced to retry for completion. + Therefore we must close+reopen all instances of the table. + */ + (void) alter_partition_lock_handling(lpt); + } + else + { + /* + The failed action was reverted, leave the original table as is and + close/destroy the intermediate table object and its share. + */ + close_temporary(lpt->table, 1, 0); + } downgrade_mdl_if_lock_tables_mode(thd, mdl_ticket, MDL_SHARED_NO_READ_WRITE); - table->m_needs_reopen= TRUE; DBUG_RETURN(TRUE); } #endif diff --git a/sql/sql_partition.h b/sql/sql_partition.h index c644e63794c..9a9a0bd56fa 100644 --- a/sql/sql_partition.h +++ b/sql/sql_partition.h @@ -54,6 +54,7 @@ typedef struct st_lock_param_type HA_CREATE_INFO *create_info; Alter_info *alter_info; TABLE *table; + TABLE *old_table; KEY *key_info_buffer; const char *db; const char *table_name; @@ -252,14 +253,17 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, TABLE_LIST *table_list, char *db, const char *table_name, - uint fast_alter_partition); + TABLE *fast_alter_table); uint set_part_state(Alter_info *alter_info, partition_info *tab_part_info, enum partition_state part_state); uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, HA_CREATE_INFO *create_info, handlerton *old_db_type, bool *partition_changed, - uint *fast_alter_partition); + char *db, + const char *table_name, + const char *path, + TABLE **fast_alter_table); char *generate_partition_syntax(partition_info *part_info, uint *buf_length, bool use_sql_alloc, bool show_partition_options, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 3f0a0326c84..0b66352c056 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1725,8 +1725,6 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) CHF_DELETE_FLAG, NULL) || deactivate_ddl_log_entry(part_info->frm_log_entry->entry_pos) || (sync_ddl_log(), FALSE) || -#endif -#ifdef WITH_PARTITION_STORAGE_ENGINE mysql_file_rename(key_file_frm, shadow_frm_name, frm_name, MYF(MY_WME)) || lpt->table->file->ha_create_handler_files(path, shadow_path, @@ -5599,7 +5597,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, handlerton *old_db_type, *new_db_type, *save_old_db_type; enum_alter_table_change_level need_copy_table= ALTER_TABLE_METADATA_ONLY; #ifdef WITH_PARTITION_STORAGE_ENGINE - uint fast_alter_partition= 0; + TABLE *table_for_fast_alter_partition= NULL; bool partition_changed= FALSE; #endif bool need_lock_for_indexes= TRUE; @@ -5968,7 +5966,9 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, #ifdef WITH_PARTITION_STORAGE_ENGINE if (prep_alter_part_table(thd, table, alter_info, create_info, old_db_type, - &partition_changed, &fast_alter_partition)) + &partition_changed, + db, table_name, path, + &table_for_fast_alter_partition)) goto err; #endif /* @@ -6201,12 +6201,12 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, create_info->frm_only= 1; #ifdef WITH_PARTITION_STORAGE_ENGINE - if (fast_alter_partition) + if (table_for_fast_alter_partition) { DBUG_RETURN(fast_alter_partition_table(thd, table, alter_info, create_info, table_list, db, table_name, - fast_alter_partition)); + table_for_fast_alter_partition)); } #endif @@ -6686,6 +6686,11 @@ err_new_table_cleanup: create_info->frm_only ? FN_IS_TMP | FRM_ONLY : FN_IS_TMP); err: +#ifdef WITH_PARTITION_STORAGE_ENGINE + /* If prep_alter_part_table created an intermediate table, destroy it. */ + if (table_for_fast_alter_partition) + close_temporary(table_for_fast_alter_partition, 1, 0); +#endif /* WITH_PARTITION_STORAGE_ENGINE */ /* No default value was provided for a DATE/DATETIME field, the current sql_mode doesn't allow the '0000-00-00' value and From a01773dbee1318e0894057daed544188b14f90c8 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Fri, 1 Oct 2010 13:39:04 +0200 Subject: [PATCH 180/183] Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Problem was that both partitioning and myisam used the same table_share->mutex for different protections (auto inc and repair). Solved by adding a specific mutex for the partitioning auto_increment. Also adding destroying the ha_data structure in free_table_share (which is to be propagated into 5.5). This is a 5.1 ONLY patch, already fixed in 5.5+. --- mysql-test/r/partition_binlog_stmt.result | 13 ++++++++++++ mysql-test/t/partition_binlog_stmt.test | 26 +++++++++++++++++++++++ sql/ha_partition.cc | 17 +++++++++++++++ sql/ha_partition.h | 7 ++++-- sql/table.cc | 10 +++++++++ sql/table.h | 1 + 6 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 mysql-test/r/partition_binlog_stmt.result create mode 100644 mysql-test/t/partition_binlog_stmt.test diff --git a/mysql-test/r/partition_binlog_stmt.result b/mysql-test/r/partition_binlog_stmt.result new file mode 100644 index 00000000000..9be23636ca6 --- /dev/null +++ b/mysql-test/r/partition_binlog_stmt.result @@ -0,0 +1,13 @@ +DROP TABLE IF EXISTS t1; +# +# Bug#51851: Server with SBR locks mutex twice on LOAD DATA into +# partitioned MyISAM table +CREATE TABLE t1 +(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +name TINYBLOB NOT NULL, +modified TIMESTAMP DEFAULT '0000-00-00 00:00:00', +INDEX namelocs (name(255))) ENGINE = MyISAM +PARTITION BY HASH(id) PARTITIONS 2; +LOAD DATA LOCAL INFILE 'init_file.txt' +INTO TABLE t1 (name); +DROP TABLE t1; diff --git a/mysql-test/t/partition_binlog_stmt.test b/mysql-test/t/partition_binlog_stmt.test new file mode 100644 index 00000000000..c426de9f303 --- /dev/null +++ b/mysql-test/t/partition_binlog_stmt.test @@ -0,0 +1,26 @@ +--source include/have_partition.inc +--source include/have_binlog_format_statement.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +--echo # +--echo # Bug#51851: Server with SBR locks mutex twice on LOAD DATA into +--echo # partitioned MyISAM table +--write_file init_file.txt +abcd +EOF + +CREATE TABLE t1 +(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + name TINYBLOB NOT NULL, + modified TIMESTAMP DEFAULT '0000-00-00 00:00:00', + INDEX namelocs (name(255))) ENGINE = MyISAM +PARTITION BY HASH(id) PARTITIONS 2; + +LOAD DATA LOCAL INFILE 'init_file.txt' +INTO TABLE t1 (name); + +--remove_file init_file.txt +DROP TABLE t1; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 624ef1aff5b..6806e9c5ac0 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2449,6 +2449,21 @@ err1: /**************************************************************************** MODULE open/close object ****************************************************************************/ + + +/** + A destructor for partition-specific TABLE_SHARE data. +*/ + +void ha_data_partition_destroy(void *ha_data) +{ + if (ha_data) + { + HA_DATA_PARTITION *ha_part_data= (HA_DATA_PARTITION*) ha_data; + pthread_mutex_destroy(&ha_part_data->LOCK_auto_inc); + } +} + /* Open handler object @@ -2605,6 +2620,8 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked) } DBUG_PRINT("info", ("table_share->ha_data 0x%p", ha_data)); bzero(ha_data, sizeof(HA_DATA_PARTITION)); + table_share->ha_data_destroy= ha_data_partition_destroy; + VOID(pthread_mutex_init(&ha_data->LOCK_auto_inc, MY_MUTEX_INIT_FAST)); } if (is_not_tmp_table) pthread_mutex_unlock(&table_share->mutex); diff --git a/sql/ha_partition.h b/sql/ha_partition.h index e3dc7d17c6d..cb5440a0b69 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -44,6 +44,7 @@ typedef struct st_partition_share typedef struct st_ha_data_partition { ulonglong next_auto_inc_val; /**< first non reserved value */ + pthread_mutex_t LOCK_auto_inc; bool auto_inc_initialized; } HA_DATA_PARTITION; @@ -944,8 +945,9 @@ private: DBUG_ASSERT(table_share->ha_data && !auto_increment_lock); if(table_share->tmp_table == NO_TMP_TABLE) { + HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data; auto_increment_lock= TRUE; - pthread_mutex_lock(&table_share->mutex); + pthread_mutex_lock(&ha_data->LOCK_auto_inc); } } virtual void unlock_auto_increment() @@ -958,7 +960,8 @@ private: */ if(auto_increment_lock && !auto_increment_safe_stmt_log_lock) { - pthread_mutex_unlock(&table_share->mutex); + HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data; + pthread_mutex_unlock(&ha_data->LOCK_auto_inc); auto_increment_lock= FALSE; } } diff --git a/sql/table.cc b/sql/table.cc index e989ab039a0..18523f08551 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -425,6 +425,11 @@ void free_table_share(TABLE_SHARE *share) key_info->flags= 0; } } + if (share->ha_data_destroy) + { + share->ha_data_destroy(share->ha_data); + share->ha_data_destroy= NULL; + } /* We must copy mem_root from share because share is allocated through it */ memcpy((char*) &mem_root, (char*) &share->mem_root, sizeof(mem_root)); free_root(&mem_root, MYF(0)); // Free's share @@ -1616,6 +1621,11 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, delete crypted; delete handler_file; hash_free(&share->name_hash); + if (share->ha_data_destroy) + { + share->ha_data_destroy(share->ha_data); + share->ha_data_destroy= NULL; + } open_table_error(share, error, share->open_errno, errarg); DBUG_RETURN(error); diff --git a/sql/table.h b/sql/table.h index bbb39aae6f7..132279169cb 100644 --- a/sql/table.h +++ b/sql/table.h @@ -463,6 +463,7 @@ typedef struct st_table_share /** place to store storage engine specific data */ void *ha_data; + void (*ha_data_destroy)(void *); /* An optional destructor for ha_data. */ /* From 7ecc1077573f0d8c6c66c9b06f7768a5807ba5db Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Fri, 1 Oct 2010 15:30:16 +0200 Subject: [PATCH 181/183] removed a comment according to the review --- sql/partition_info.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 879e7b10023..b54339db354 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -1997,7 +1997,6 @@ int partition_info::fix_partition_values(THD *thd, } else if (item_expr->result_type() != INT_RESULT) { - /* VALUES clause only allowed on partitions, not subpartitions */ my_error(ER_VALUES_IS_NOT_INT_TYPE_ERROR, MYF(0), part_elem->partition_name); DBUG_RETURN(TRUE); From 790dd097c3942ee0962eabcf571364bdd81efb61 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Fri, 1 Oct 2010 18:10:45 +0200 Subject: [PATCH 182/183] minor test result update after merge --- mysql-test/r/partition_error.result | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result index 830ca4bee10..a1e95727235 100644 --- a/mysql-test/r/partition_error.result +++ b/mysql-test/r/partition_error.result @@ -72,6 +72,8 @@ a 2000-01-02 03:04:05 2001-02-03 04:05:06 ALTER TABLE t1 ADD PARTITION PARTITIONS 2; +Warnings: +Warning 1486 Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed ALTER TABLE t1 PARTITION BY RANGE (TO_DAYS(a)) (PARTITION p0 VALUES LESS THAN (10000), @@ -84,8 +86,6 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (TO_DAYS(a)) PARTITIONS 3 */ -Warnings: -Warning 1486 Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed CREATE TABLE t2 LIKE t1; SHOW CREATE TABLE t2; Table Create Table From 16076e6a6f13fe43a8f55100aa7f1a2fff44ff30 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Fri, 1 Oct 2010 21:32:40 +0200 Subject: [PATCH 183/183] Minor update of test to pass both with and without --ps-protocol --- mysql-test/r/partition_error.result | 5 +++-- mysql-test/t/partition_error.test | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result index a1e95727235..27f34730463 100644 --- a/mysql-test/r/partition_error.result +++ b/mysql-test/r/partition_error.result @@ -55,11 +55,12 @@ SELECT * FROM t1; a 2000-01-02 03:04:05 FLUSH TABLES; +# replacing t1.frm with TO_DAYS(a) which was allowed earlier. +# Disable warnings, since the result would differ when running with +# --ps-protocol (only for the 'SELECT * FROM t1' statement). SELECT * FROM t1; a 2000-01-02 03:04:05 -Warning 1486 Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed -Warnings: SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index 1afb65d496c..73afa9b5216 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -74,10 +74,15 @@ INSERT INTO t1 VALUES ('2000-01-02 03:04:05'); --sorted_result SELECT * FROM t1; FLUSH TABLES; +--echo # replacing t1.frm with TO_DAYS(a) which was allowed earlier. --remove_file $MYSQLD_DATADIR/test/t1.frm --copy_file std_data/parts/t1TIMESTAMP.frm $MYSQLD_DATADIR/test/t1.frm +--echo # Disable warnings, since the result would differ when running with +--echo # --ps-protocol (only for the 'SELECT * FROM t1' statement). +--disable_warnings --sorted_result SELECT * FROM t1; +--enable_warnings SHOW CREATE TABLE t1; INSERT INTO t1 VALUES ('2001-02-03 04:05:06'); --sorted_result