From ebdd52838299fbb036b8399b53dd347400644a8d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Jun 2010 19:21:25 +0200 Subject: [PATCH 001/118] Set version number for mysql-5.1.46sp1 release --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 904c54abb5f..9098ed1f3cb 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.46], [], [mysql]) +AC_INIT([MySQL Server], [5.1.46sp1], [], [mysql]) AC_CONFIG_SRCDIR([sql/mysqld.cc]) AC_CANONICAL_SYSTEM From eea50ea20dcdae7fe8c3bb182d030cdb79e8c1e0 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Tue, 22 Jun 2010 21:42:14 +0200 Subject: [PATCH 002/118] Backport into build-201006221614-5.1.46sp1 > ------------------------------------------------------------ > revno: 3362 > revision-id: davi.arnaut@sun.com-20100401131522-895y8uzvv8ag44gs > parent: ramil@mysql.com-20100429045409-r7r5lcyiruis15v7 > committer: Davi Arnaut > branch nick: 50755-5.1 > timestamp: Thu 2010-04-01 10:15:22 -0300 > message: > Bug#50755: Crash if stored routine def contains version comments > > The problem was that a syntactically invalid trigger could cause > the server to crash when trying to list triggers. The crash would > happen due to a mishap in the backup/restore procedure that should > protect parser items which are not associated with the trigger. The > backup/restore is used to isolate the parse tree (and context) of > a statement from the load (and parsing) of a trigger. In this case, > a error during the parsing of a trigger could cause the improper > backup/restore sequence. > > The solution is to properly restore the original statement context > before the parser is exited due to syntax errors in the trigger body. --- mysql-test/r/trigger.result | 23 +++++++++++++++++++++++ mysql-test/t/trigger.test | 31 +++++++++++++++++++++++++++++++ sql/sp_head.cc | 36 ++++++++++++++---------------------- sql/sp_head.h | 4 ---- sql/sql_lex.cc | 1 + 5 files changed, 69 insertions(+), 26 deletions(-) diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index 3446babbb52..e3c0b0e1dd9 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -2128,4 +2128,27 @@ Warning 1048 Column 'id' cannot be null Warning 1048 Column 'id' cannot be null DROP TRIGGER t1_bu; DROP TABLE t1,t2; +# +# Bug#50755: Crash if stored routine def contains version comments +# +DROP DATABASE IF EXISTS db1; +DROP TRIGGER IF EXISTS trg1; +DROP TABLE IF EXISTS t1, t2; +CREATE DATABASE db1; +USE db1; +CREATE TABLE t1 (b INT); +CREATE TABLE t2 (a INT); +CREATE TRIGGER trg1 BEFORE INSERT ON t2 FOR EACH ROW INSERT/*!INTO*/t1 VALUES (1); +# Used to crash +SHOW TRIGGERS IN db1; +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +Warnings: +Warning 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VALUES (1)' at line 1 +INSERT INTO t2 VALUES (1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VALUES (1)' at line 1 +SELECT * FROM t1; +b +# Work around Bug#45235 +DROP DATABASE db1; +USE test; End of 5.1 tests. diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 368271f1fb2..bcbca4d2139 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -2439,4 +2439,35 @@ UPDATE t1 SET id=NULL; DROP TRIGGER t1_bu; DROP TABLE t1,t2; +--echo # +--echo # Bug#50755: Crash if stored routine def contains version comments +--echo # + +--disable_warnings +DROP DATABASE IF EXISTS db1; +DROP TRIGGER IF EXISTS trg1; +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + +CREATE DATABASE db1; +USE db1; + +CREATE TABLE t1 (b INT); +CREATE TABLE t2 (a INT); + +CREATE TRIGGER trg1 BEFORE INSERT ON t2 FOR EACH ROW INSERT/*!INTO*/t1 VALUES (1); +--echo # Used to crash +SHOW TRIGGERS IN db1; +--error ER_PARSE_ERROR +INSERT INTO t2 VALUES (1); +SELECT * FROM t1; + +--echo # Work around Bug#45235 +let $MYSQLD_DATADIR = `select @@datadir`; +--remove_file $MYSQLD_DATADIR/db1/t2.TRG +--remove_file $MYSQLD_DATADIR/db1/trg1.TRN + +DROP DATABASE db1; +USE test; + --echo End of 5.1 tests. diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 11d5e5f830b..cadda38053c 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -745,21 +745,12 @@ sp_head::create(THD *thd) sp_head::~sp_head() { - DBUG_ENTER("sp_head::~sp_head"); - destroy(); - delete m_next_cached_sp; - if (m_thd) - restore_thd_mem_root(m_thd); - DBUG_VOID_RETURN; -} - -void -sp_head::destroy() -{ - sp_instr *i; LEX *lex; - DBUG_ENTER("sp_head::destroy"); - DBUG_PRINT("info", ("name: %s", m_name.str)); + sp_instr *i; + DBUG_ENTER("sp_head::~sp_head"); + + /* sp_head::restore_thd_mem_root() must already have been called. */ + DBUG_ASSERT(m_thd == NULL); for (uint ip = 0 ; (i = get_instr(ip)) ; ip++) delete i; @@ -770,21 +761,22 @@ sp_head::destroy() /* If we have non-empty LEX stack then we just came out of parser with error. Now we should delete all auxilary LEXes and restore original - THD::lex (In this case sp_head::restore_thd_mem_root() was not called - too, so m_thd points to the current thread context). - It is safe to not update LEX::ptr because further query string parsing - and execution will be stopped anyway. + THD::lex. It is safe to not update LEX::ptr because further query + string parsing and execution will be stopped anyway. */ - DBUG_ASSERT(m_lex.is_empty() || m_thd); while ((lex= (LEX *)m_lex.pop())) { - lex_end(m_thd->lex); - delete m_thd->lex; - m_thd->lex= lex; + THD *thd= lex->thd; + lex_end(thd->lex); + delete thd->lex; + thd->lex= lex; } hash_free(&m_sptabs); hash_free(&m_sroutines); + + delete m_next_cached_sp; + DBUG_VOID_RETURN; } diff --git a/sql/sp_head.h b/sql/sp_head.h index 00c96d44f70..d422adc8927 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -289,10 +289,6 @@ public: virtual ~sp_head(); - /// Free memory - void - destroy(); - bool execute_trigger(THD *thd, const LEX_STRING *db_name, diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 5097ca2ad5b..a3776f59241 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2106,6 +2106,7 @@ void st_lex::cleanup_lex_after_parse_error(THD *thd) */ if (thd->lex->sphead) { + thd->lex->sphead->restore_thd_mem_root(thd); delete thd->lex->sphead; thd->lex->sphead= NULL; } From d2c104fd129c648b6b89d612d9144b4594525732 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Tue, 22 Jun 2010 21:50:47 +0200 Subject: [PATCH 003/118] Backport into build-201006221614-5.1.46sp1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > ------------------------------------------------------------ > revno: 3351.14.50 > revision-id: marko.makela@oracle.com-20100421185359-8qaxoa2yyrpzwdd7 > parent: marko.makela@oracle.com-20100421102723-0i80uezbyu0ekj5d > committer: Marko Mäkelä > branch nick: 5.1-innodb > timestamp: Wed 2010-04-21 21:53:59 +0300 > message: > btr_page_split_and_insert(): Avoid an infinite loop. (Bug #52964) > > btr_page_tuple_smaller(): New function, refactored from > btr_page_split_and_insert(). > > btr_page_get_split_rec(): Renamed from btr_page_get_sure_split_rec(). > Note that a NULL return may mean that the tuple is to be inserted into > either the lower or upper page, to be determined by btr_page_tuple_smaller(). > > btr_page_split_and_insert(): When btr_page_get_split_rec() returns NULL, > invoke btr_page_tuple_smaller() to determine which half-page the tuple > belongs to. > > Reviewed by Sunny Bains --- storage/innodb_plugin/btr/btr0btr.c | 91 +++++++++++++++++++---------- 1 file changed, 59 insertions(+), 32 deletions(-) diff --git a/storage/innodb_plugin/btr/btr0btr.c b/storage/innodb_plugin/btr/btr0btr.c index fa4fc05d96b..cd8f42b3818 100644 --- a/storage/innodb_plugin/btr/btr0btr.c +++ b/storage/innodb_plugin/btr/btr0btr.c @@ -1451,11 +1451,11 @@ Calculates a split record such that the tuple will certainly fit on its half-page when the split is performed. We assume in this function only that the cursor page has at least one user record. @return split record, or NULL if tuple will be the first record on -upper half-page */ +the lower or upper half-page (determined by btr_page_tuple_smaller()) */ static rec_t* -btr_page_get_sure_split_rec( -/*========================*/ +btr_page_get_split_rec( +/*===================*/ btr_cur_t* cursor, /*!< in: cursor at which insert should be made */ const dtuple_t* tuple, /*!< in: tuple to insert */ ulint n_ext) /*!< in: number of externally stored columns */ @@ -1831,6 +1831,37 @@ btr_attach_half_pages( btr_page_set_next(upper_page, upper_page_zip, next_page_no, mtr); } +/*************************************************************//** +Determine if a tuple is smaller than any record on the page. +@return TRUE if smaller */ +static +ibool +btr_page_tuple_smaller( +/*===================*/ + btr_cur_t* cursor, /*!< in: b-tree cursor */ + const dtuple_t* tuple, /*!< in: tuple to consider */ + ulint* offsets,/*!< in/out: temporary storage */ + ulint n_uniq, /*!< in: number of unique fields + in the index page records */ + mem_heap_t** heap) /*!< in/out: heap for offsets */ +{ + buf_block_t* block; + const rec_t* first_rec; + page_cur_t pcur; + + /* Read the first user record in the page. */ + block = btr_cur_get_block(cursor); + page_cur_set_before_first(block, &pcur); + page_cur_move_to_next(&pcur); + first_rec = page_cur_get_rec(&pcur); + + offsets = rec_get_offsets( + first_rec, cursor->index, offsets, + n_uniq, heap); + + return(cmp_dtuple_rec(tuple, first_rec, offsets) < 0); +} + /*************************************************************//** Splits an index page to halves and inserts the tuple. It is assumed that mtr holds an x-latch to the index tree. NOTE: the tree x-latch is @@ -1905,49 +1936,45 @@ func_start: if (n_iterations > 0) { direction = FSP_UP; hint_page_no = page_no + 1; - split_rec = btr_page_get_sure_split_rec(cursor, tuple, n_ext); + split_rec = btr_page_get_split_rec(cursor, tuple, n_ext); + if (UNIV_UNLIKELY(split_rec == NULL)) { + insert_left = btr_page_tuple_smaller( + cursor, tuple, offsets, n_uniq, &heap); + } } else if (btr_page_get_split_rec_to_right(cursor, &split_rec)) { direction = FSP_UP; hint_page_no = page_no + 1; + insert_left = FALSE; } else if (btr_page_get_split_rec_to_left(cursor, &split_rec)) { direction = FSP_DOWN; hint_page_no = page_no - 1; + ut_ad(split_rec); } else { direction = FSP_UP; hint_page_no = page_no + 1; - if (page_get_n_recs(page) == 1) { - page_cur_t pcur; + /* If there is only one record in the index page, we + can't split the node in the middle by default. We need + to determine whether the new record will be inserted + to the left or right. */ - /* There is only one record in the index page - therefore we can't split the node in the middle - by default. We need to determine whether the - new record will be inserted to the left or right. */ - - /* Read the first (and only) record in the page. */ - page_cur_set_before_first(block, &pcur); - page_cur_move_to_next(&pcur); - first_rec = page_cur_get_rec(&pcur); - - offsets = rec_get_offsets( - first_rec, cursor->index, offsets, - n_uniq, &heap); - - /* If the new record is less than the existing record - the split in the middle will copy the existing - record to the new node. */ - if (cmp_dtuple_rec(tuple, first_rec, offsets) < 0) { - split_rec = page_get_middle_rec(page); - } else { - split_rec = NULL; - } - } else { + if (page_get_n_recs(page) > 1) { split_rec = page_get_middle_rec(page); + } else if (btr_page_tuple_smaller(cursor, tuple, + offsets, n_uniq, &heap)) { + split_rec = page_rec_get_next( + page_get_infimum_rec(page)); + } else { + split_rec = NULL; + insert_left = FALSE; } } + /* At this point, insert_left is initialized if split_rec == NULL + and may be uninitialized otherwise. */ + /* 2. Allocate a new page to the index */ new_block = btr_page_alloc(cursor->index, hint_page_no, direction, btr_page_get_level(page, mtr), mtr); @@ -1974,11 +2001,11 @@ func_start: avoid further splits by inserting the record to an empty page. */ split_rec = NULL; - goto insert_right; + goto insert_empty; } } else { -insert_right: - insert_left = FALSE; +insert_empty: + ut_ad(!split_rec); buf = mem_alloc(rec_get_converted_size(cursor->index, tuple, n_ext)); From 65379cccc84bb5324413dfd6d3fd09b496612361 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Tue, 22 Jun 2010 21:52:43 +0200 Subject: [PATCH 004/118] Backport into build-201006221614-5.1.46sp1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > ------------------------------------------------------------ > revno: 3351.14.74 > revision-id: marko.makela@oracle.com-20100504093128-44v6glupe1dsh0ug > parent: marko.makela@oracle.com-20100503122859-k73bl51re93o0mt4 > committer: Marko Mäkelä > branch nick: 5.1-innodb > timestamp: Tue 2010-05-04 12:31:28 +0300 > message: > btr_page_split_and_insert(): Correct the fix of Bug #52964. > When split_rec==NULL, choose the correct node pointer key (first_rec). --- storage/innodb_plugin/btr/btr0btr.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/storage/innodb_plugin/btr/btr0btr.c b/storage/innodb_plugin/btr/btr0btr.c index cd8f42b3818..1d6b4f5a0e6 100644 --- a/storage/innodb_plugin/btr/btr0btr.c +++ b/storage/innodb_plugin/btr/btr0btr.c @@ -2003,9 +2003,13 @@ func_start: split_rec = NULL; goto insert_empty; } + } else if (UNIV_UNLIKELY(insert_left)) { + first_rec = page_rec_get_next(page_get_infimum_rec(page)); + move_limit = page_rec_get_next(btr_cur_get_rec(cursor)); } else { insert_empty: ut_ad(!split_rec); + ut_ad(!insert_left); buf = mem_alloc(rec_get_converted_size(cursor->index, tuple, n_ext)); @@ -2029,7 +2033,11 @@ insert_empty: && btr_page_insert_fits(cursor, split_rec, offsets, tuple, n_ext, heap); } else { - mem_free(buf); + if (!insert_left) { + mem_free(buf); + buf = NULL; + } + insert_will_fit = !new_page_zip && btr_page_insert_fits(cursor, NULL, NULL, tuple, n_ext, heap); From 1cab479221f6d9fbe0fc44414b5b6a9bc7c9f009 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Tue, 22 Jun 2010 21:54:41 +0200 Subject: [PATCH 005/118] Backport into build-201006221614-5.1.46sp1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > ------------------------------------------------------------ > revno: 3351.47.1 > revision-id: marko.makela@oracle.com-20100511104500-c6kzd0bg5s42p8e9 > parent: vasil.dimov@oracle.com-20100510132852-cz457uqvj8iiy9mm > committer: Marko Mäkelä > branch nick: mysql-5.1-innodb2 > timestamp: Tue 2010-05-11 13:45:00 +0300 > message: > Remove a stray expression. Spotted by Sunny Bains. --- storage/innodb_plugin/page/page0zip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innodb_plugin/page/page0zip.c b/storage/innodb_plugin/page/page0zip.c index aa5e39ff04a..a64a41ea518 100644 --- a/storage/innodb_plugin/page/page0zip.c +++ b/storage/innodb_plugin/page/page0zip.c @@ -571,7 +571,7 @@ page_zip_dir_encode( /* Traverse the list of stored records in the collation order, starting from the first user record. */ - rec = page + PAGE_NEW_INFIMUM, TRUE; + rec = page + PAGE_NEW_INFIMUM; i = 0; From e87a2d917b39043ce7124aae8788e8247e611211 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Tue, 22 Jun 2010 21:56:18 +0200 Subject: [PATCH 006/118] Backport into build-201006221614-5.1.46sp1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > ------------------------------------------------------------ > revno: 3351.47.2 > revision-id: marko.makela@oracle.com-20100511104910-nim8kgguawpis7zo > parent: marko.makela@oracle.com-20100511104500-c6kzd0bg5s42p8e9 > committer: Marko Mäkelä > branch nick: mysql-5.1-innodb2 > timestamp: Tue 2010-05-11 13:49:10 +0300 > message: > btr_page_split_and_insert(): Add an assertion > suggested by Sunny Bains when reviewing Bug #52964. --- storage/innodb_plugin/btr/btr0btr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/innodb_plugin/btr/btr0btr.c b/storage/innodb_plugin/btr/btr0btr.c index 1d6b4f5a0e6..0fd209e0216 100644 --- a/storage/innodb_plugin/btr/btr0btr.c +++ b/storage/innodb_plugin/btr/btr0btr.c @@ -2004,6 +2004,7 @@ func_start: goto insert_empty; } } else if (UNIV_UNLIKELY(insert_left)) { + ut_a(n_iterations > 0); first_rec = page_rec_get_next(page_get_infimum_rec(page)); move_limit = page_rec_get_next(btr_cur_get_rec(cursor)); } else { From f5a0316a3962ce34f3586574be5598d2bacd5ccb Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Tue, 22 Jun 2010 21:59:35 +0200 Subject: [PATCH 007/118] Backport into build-201006221614-5.1.46sp1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > ------------------------------------------------------------ > revno: 3351.14.47 > revision-id: marko.makela@oracle.com-20100421095033-0acvzxb8um8cms0a > parent: marko.makela@oracle.com-20100421094032-ir4glqk46qvg2ywn > committer: Marko Mäkelä > branch nick: 5.1-innodb > timestamp: Wed 2010-04-21 12:50:33 +0300 > message: > dtuple_convert_big_rec(): Store locally any fields whose maximum length > is less than 256 bytes. (Bug #52745) > Add related comments and debug assertions to the "offsets" > functions in rem0rec.c. > Approved by Sunny Bains --- storage/innodb_plugin/data/data0data.c | 15 +++++++ storage/innodb_plugin/rem/rem0rec.c | 59 +++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/storage/innodb_plugin/data/data0data.c b/storage/innodb_plugin/data/data0data.c index e3c1f1b4f23..0715b49bf9c 100644 --- a/storage/innodb_plugin/data/data0data.c +++ b/storage/innodb_plugin/data/data0data.c @@ -666,6 +666,21 @@ dtuple_convert_big_rec( goto skip_field; } + /* In DYNAMIC and COMPRESSED format, store + locally any non-BLOB columns whose maximum + length does not exceed 256 bytes. This is + because there is no room for the "external + storage" flag when the maximum length is 255 + bytes or less. This restriction trivially + holds in REDUNDANT and COMPACT format, because + there we always store locally columns whose + length is up to local_len == 788 bytes. + @see rec_init_offsets_comp_ordinary */ + if (ifield->col->mtype != DATA_BLOB + && ifield->col->len < 256) { + goto skip_field; + } + longest_i = i; longest = savings; diff --git a/storage/innodb_plugin/rem/rem0rec.c b/storage/innodb_plugin/rem/rem0rec.c index 27c11dacc8c..59cf6e887d1 100644 --- a/storage/innodb_plugin/rem/rem0rec.c +++ b/storage/innodb_plugin/rem/rem0rec.c @@ -212,6 +212,13 @@ rec_get_n_extern_new( const dict_col_t* col = dict_field_get_col(field); len = *lens--; + /* If the maximum length of the field is up + to 255 bytes, the actual length is always + stored in one byte. If the maximum length is + more than 255 bytes, the actual length is + stored in one byte for 0..127. The length + will be encoded in two bytes when it is 128 or + more, or when the field is stored externally. */ if (UNIV_UNLIKELY(col->len > 255) || UNIV_UNLIKELY(col->mtype == DATA_BLOB)) { if (len & 0x80) { @@ -294,6 +301,13 @@ rec_init_offsets_comp_ordinary( const dict_col_t* col = dict_field_get_col(field); len = *lens--; + /* If the maximum length of the field is up + to 255 bytes, the actual length is always + stored in one byte. If the maximum length is + more than 255 bytes, the actual length is + stored in one byte for 0..127. The length + will be encoded in two bytes when it is 128 or + more, or when the field is stored externally. */ if (UNIV_UNLIKELY(col->len > 255) || UNIV_UNLIKELY(col->mtype == DATA_BLOB)) { @@ -425,6 +439,15 @@ rec_init_offsets( const dict_col_t* col = dict_field_get_col(field); len = *lens--; + /* If the maximum length of the field + is up to 255 bytes, the actual length + is always stored in one byte. If the + maximum length is more than 255 bytes, + the actual length is stored in one + byte for 0..127. The length will be + encoded in two bytes when it is 128 or + more, or when the field is stored + externally. */ if (UNIV_UNLIKELY(col->len > 255) || UNIV_UNLIKELY(col->mtype == DATA_BLOB)) { @@ -647,6 +670,13 @@ rec_get_offsets_reverse( const dict_col_t* col = dict_field_get_col(field); len = *lens++; + /* If the maximum length of the field is up + to 255 bytes, the actual length is always + stored in one byte. If the maximum length is + more than 255 bytes, the actual length is + stored in one byte for 0..127. The length + will be encoded in two bytes when it is 128 or + more, or when the field is stored externally. */ if (UNIV_UNLIKELY(col->len > 255) || UNIV_UNLIKELY(col->mtype == DATA_BLOB)) { if (len & 0x80) { @@ -781,12 +811,20 @@ rec_get_converted_size_comp_prefix( ut_ad(len <= col->len || col->mtype == DATA_BLOB); + /* If the maximum length of a variable-length field + is up to 255 bytes, the actual length is always stored + in one byte. If the maximum length is more than 255 + bytes, the actual length is stored in one byte for + 0..127. The length will be encoded in two bytes when + it is 128 or more, or when the field is stored externally. */ + if (field->fixed_len) { ut_ad(len == field->fixed_len); /* dict_index_add_col() should guarantee this */ ut_ad(!field->prefix_len || field->fixed_len == field->prefix_len); } else if (dfield_is_ext(&fields[i])) { + ut_ad(col->len >= 256 || col->mtype == DATA_BLOB); extra_size += 2; } else if (len < 128 || (col->len < 256 && col->mtype != DATA_BLOB)) { @@ -1086,6 +1124,8 @@ rec_convert_dtuple_to_rec_comp( /* Store the data and the offsets */ for (i = 0, field = fields; i < n_fields; i++, field++) { + const dict_field_t* ifield; + type = dfield_get_type(field); len = dfield_get_len(field); @@ -1120,12 +1160,20 @@ rec_convert_dtuple_to_rec_comp( /* only nullable fields can be null */ ut_ad(!dfield_is_null(field)); - fixed_len = dict_index_get_nth_field(index, i)->fixed_len; - + ifield = dict_index_get_nth_field(index, i); + fixed_len = ifield->fixed_len; + /* If the maximum length of a variable-length field + is up to 255 bytes, the actual length is always stored + in one byte. If the maximum length is more than 255 + bytes, the actual length is stored in one byte for + 0..127. The length will be encoded in two bytes when + it is 128 or more, or when the field is stored externally. */ if (fixed_len) { ut_ad(len == fixed_len); ut_ad(!dfield_is_ext(field)); } else if (dfield_is_ext(field)) { + ut_ad(ifield->col->len >= 256 + || ifield->col->mtype == DATA_BLOB); ut_ad(len <= REC_MAX_INDEX_COL_LEN + BTR_EXTERN_FIELD_REF_SIZE); *lens-- = (byte) (len >> 8) | 0xc0; @@ -1402,6 +1450,13 @@ rec_copy_prefix_to_buf( prefix_len += field->fixed_len; } else { ulint len = *lens--; + /* If the maximum length of the column is up + to 255 bytes, the actual length is always + stored in one byte. If the maximum length is + more than 255 bytes, the actual length is + stored in one byte for 0..127. The length + will be encoded in two bytes when it is 128 or + more, or when the column is stored externally. */ if (col->len > 255 || col->mtype == DATA_BLOB) { if (len & 0x80) { /* 1exxxxxx */ From 4f066e52694cb41ed950ed0a92d4518de9cd89bf Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Tue, 22 Jun 2010 22:09:31 +0200 Subject: [PATCH 008/118] Backport into 5.1.46sp1: > revno: 3351.14.56 > committer: Marko Mdkeld > branch nick: 5.1-innodb > timestamp: Mon 2010-04-26 14:08:56 +0300 > message: > Add a test case for Bug #52745. --- .../innodb_plugin/r/innodb_bug52745.result | 130 ++++++++++++++++++ .../innodb_plugin/t/innodb_bug52745.test | 109 +++++++++++++++ 2 files changed, 239 insertions(+) create mode 100644 mysql-test/suite/innodb_plugin/r/innodb_bug52745.result create mode 100644 mysql-test/suite/innodb_plugin/t/innodb_bug52745.test diff --git a/mysql-test/suite/innodb_plugin/r/innodb_bug52745.result b/mysql-test/suite/innodb_plugin/r/innodb_bug52745.result new file mode 100644 index 00000000000..254c6525257 --- /dev/null +++ b/mysql-test/suite/innodb_plugin/r/innodb_bug52745.result @@ -0,0 +1,130 @@ +SET GLOBAL innodb_file_format='Barracuda'; +SET GLOBAL innodb_file_per_table=on; +CREATE TABLE bug52745 ( +a2 int(10) unsigned DEFAULT NULL, +col37 time DEFAULT NULL, +col38 char(229) CHARACTER SET utf8 DEFAULT NULL, +col39 text, +col40 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, +col41 int(10) unsigned DEFAULT NULL, +col42 varchar(248) CHARACTER SET utf8 DEFAULT NULL, +col43 smallint(5) unsigned zerofill DEFAULT NULL, +col44 varchar(150) CHARACTER SET utf8 DEFAULT NULL, +col45 float unsigned zerofill DEFAULT NULL, +col46 binary(1) DEFAULT NULL, +col47 tinyint(4) DEFAULT NULL, +col48 tinyint(1) DEFAULT NULL, +col49 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', +col50 binary(1) DEFAULT NULL, +col51 double unsigned zerofill DEFAULT NULL, +col52 int(10) unsigned DEFAULT NULL, +col53 time DEFAULT NULL, +col54 double unsigned DEFAULT NULL, +col55 time DEFAULT NULL, +col56 mediumtext CHARACTER SET latin2, +col57 blob, +col58 decimal(52,16) unsigned zerofill NOT NULL DEFAULT '000000000000000000000000000000000000.0000000000000000', +col59 binary(1) DEFAULT NULL, +col60 longblob, +col61 time DEFAULT NULL, +col62 longtext CHARACTER SET utf8 COLLATE utf8_persian_ci, +col63 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', +col64 int(10) unsigned DEFAULT NULL, +col65 date DEFAULT NULL, +col66 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', +col67 binary(1) DEFAULT NULL, +col68 tinyblob, +col69 date DEFAULT NULL, +col70 tinyint(3) unsigned zerofill DEFAULT NULL, +col71 varchar(44) CHARACTER SET utf8 DEFAULT NULL, +col72 datetime DEFAULT NULL, +col73 smallint(5) unsigned zerofill DEFAULT NULL, +col74 longblob, +col75 bit(34) DEFAULT NULL, +col76 float unsigned zerofill DEFAULT NULL, +col77 year(2) DEFAULT NULL, +col78 tinyint(3) unsigned DEFAULT NULL, +col79 set('msfheowh','tbpxbgf','by','wahnrjw','myqfasxz','rsokyumrt') CHARACTER SET latin2 DEFAULT NULL, +col80 datetime DEFAULT NULL, +col81 smallint(6) DEFAULT NULL, +col82 enum('xtaurnqfqz','rifrse','kuzwpbvb','niisabk','zxavro','rbvasv','','uulrfaove','','') DEFAULT NULL, +col83 bigint(20) unsigned zerofill DEFAULT NULL, +col84 float unsigned zerofill DEFAULT NULL, +col85 double DEFAULT NULL, +col86 enum('ylannv','','vlkhycqc','snke','cxifustp','xiaxaswzp','oxl') CHARACTER SET latin1 COLLATE latin1_german2_ci DEFAULT NULL, +col87 varbinary(221) DEFAULT NULL, +col88 double unsigned DEFAULT NULL, +col89 float unsigned zerofill DEFAULT NULL, +col90 tinyblob +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +Warnings: +Note 1291 Column 'col82' has duplicated value '' in ENUM +Note 1291 Column 'col82' has duplicated value '' in ENUM +INSERT INTO bug52745 SET +col40='0000-00-00 00:00:00', +col51=16547, +col53='7711484', +col54=-28604, +col55='7112612', +col56='wakefulness\'', +col57=repeat('absorbefacient\'',106), +col58=11027, +col59='AM09gW7', +col60=repeat('Noelani\'',16), +col61='2520576', +col62='substitutiv', +col63='19950106155112', +col64=-12038, +col65='86238806', +col66='19600719080256', +col68=repeat('Sagittarius\'',54), +col69='38943902', +col70=1232, +col71='Elora\'', +col74=repeat('zipp',11), +col75='0', +col76=23254, +col78=13247, +col79='56219', +col80='20500609035724', +col81=11632, +col82=7, +col84=-23863, +col85=6341, +col87='HZdkf.4 s7t,5Rmq 8so fmr,ruGLUG25TrtI.yQ 2SuHq0ML7rw7.4 b2yf2E5TJxOtBBZImezDnzpj,uPYfznnEUDN1e9aQoO 2DsplB7TFWy oQJ br HLF :F,eQ p4i1oWsr lL3PG,hjCz6hYqN h1QTjLCjrv:QCdSzpYBibJAtZCxLOk3l6Blsh.W', +col88=16894, +col89=6161, +col90=repeat('gale',48); +Warnings: +Warning 1265 Data truncated for column 'col53' at row 1 +Warning 1264 Out of range value for column 'col54' at row 1 +Warning 1265 Data truncated for column 'col59' at row 1 +Warning 1265 Data truncated for column 'col61' at row 1 +Warning 1264 Out of range value for column 'col64' at row 1 +Warning 1265 Data truncated for column 'col65' at row 1 +Warning 1264 Out of range value for column 'col66' at row 1 +Warning 1265 Data truncated for column 'col68' at row 1 +Warning 1265 Data truncated for column 'col69' at row 1 +Warning 1264 Out of range value for column 'col70' at row 1 +Warning 1264 Out of range value for column 'col78' at row 1 +Warning 1265 Data truncated for column 'col79' at row 1 +Warning 1264 Out of range value for column 'col84' at row 1 +SHOW WARNINGS; +Level Code Message +Warning 1265 Data truncated for column 'col53' at row 1 +Warning 1264 Out of range value for column 'col54' at row 1 +Warning 1265 Data truncated for column 'col59' at row 1 +Warning 1265 Data truncated for column 'col61' at row 1 +Warning 1264 Out of range value for column 'col64' at row 1 +Warning 1265 Data truncated for column 'col65' at row 1 +Warning 1264 Out of range value for column 'col66' at row 1 +Warning 1265 Data truncated for column 'col68' at row 1 +Warning 1265 Data truncated for column 'col69' at row 1 +Warning 1264 Out of range value for column 'col70' at row 1 +Warning 1264 Out of range value for column 'col78' at row 1 +Warning 1265 Data truncated for column 'col79' at row 1 +Warning 1264 Out of range value for column 'col84' at row 1 +DROP TABLE bug52745; +SET GLOBAL innodb_file_format=Antelope; +SET GLOBAL innodb_file_format_check=Antelope; +SET GLOBAL innodb_file_per_table=0; diff --git a/mysql-test/suite/innodb_plugin/t/innodb_bug52745.test b/mysql-test/suite/innodb_plugin/t/innodb_bug52745.test new file mode 100644 index 00000000000..b20a993a2d1 --- /dev/null +++ b/mysql-test/suite/innodb_plugin/t/innodb_bug52745.test @@ -0,0 +1,109 @@ +-- source include/have_innodb_plugin.inc + +let $file_format=`select @@innodb_file_format`; +let $file_format_check=`select @@innodb_file_format_check`; +let $file_per_table=`select @@innodb_file_per_table`; +SET GLOBAL innodb_file_format='Barracuda'; +SET GLOBAL innodb_file_per_table=on; + +CREATE TABLE bug52745 ( + a2 int(10) unsigned DEFAULT NULL, + col37 time DEFAULT NULL, + col38 char(229) CHARACTER SET utf8 DEFAULT NULL, + col39 text, + col40 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + col41 int(10) unsigned DEFAULT NULL, + col42 varchar(248) CHARACTER SET utf8 DEFAULT NULL, + col43 smallint(5) unsigned zerofill DEFAULT NULL, + col44 varchar(150) CHARACTER SET utf8 DEFAULT NULL, + col45 float unsigned zerofill DEFAULT NULL, + col46 binary(1) DEFAULT NULL, + col47 tinyint(4) DEFAULT NULL, + col48 tinyint(1) DEFAULT NULL, + col49 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + col50 binary(1) DEFAULT NULL, + col51 double unsigned zerofill DEFAULT NULL, + col52 int(10) unsigned DEFAULT NULL, + col53 time DEFAULT NULL, + col54 double unsigned DEFAULT NULL, + col55 time DEFAULT NULL, + col56 mediumtext CHARACTER SET latin2, + col57 blob, + col58 decimal(52,16) unsigned zerofill NOT NULL DEFAULT '000000000000000000000000000000000000.0000000000000000', + col59 binary(1) DEFAULT NULL, + col60 longblob, + col61 time DEFAULT NULL, + col62 longtext CHARACTER SET utf8 COLLATE utf8_persian_ci, + col63 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + col64 int(10) unsigned DEFAULT NULL, + col65 date DEFAULT NULL, + col66 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + col67 binary(1) DEFAULT NULL, + col68 tinyblob, + col69 date DEFAULT NULL, + col70 tinyint(3) unsigned zerofill DEFAULT NULL, + col71 varchar(44) CHARACTER SET utf8 DEFAULT NULL, + col72 datetime DEFAULT NULL, + col73 smallint(5) unsigned zerofill DEFAULT NULL, + col74 longblob, + col75 bit(34) DEFAULT NULL, + col76 float unsigned zerofill DEFAULT NULL, + col77 year(2) DEFAULT NULL, + col78 tinyint(3) unsigned DEFAULT NULL, + col79 set('msfheowh','tbpxbgf','by','wahnrjw','myqfasxz','rsokyumrt') CHARACTER SET latin2 DEFAULT NULL, + col80 datetime DEFAULT NULL, + col81 smallint(6) DEFAULT NULL, + col82 enum('xtaurnqfqz','rifrse','kuzwpbvb','niisabk','zxavro','rbvasv','','uulrfaove','','') DEFAULT NULL, + col83 bigint(20) unsigned zerofill DEFAULT NULL, + col84 float unsigned zerofill DEFAULT NULL, + col85 double DEFAULT NULL, + col86 enum('ylannv','','vlkhycqc','snke','cxifustp','xiaxaswzp','oxl') CHARACTER SET latin1 COLLATE latin1_german2_ci DEFAULT NULL, + col87 varbinary(221) DEFAULT NULL, + col88 double unsigned DEFAULT NULL, + col89 float unsigned zerofill DEFAULT NULL, + col90 tinyblob +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +INSERT INTO bug52745 SET +col40='0000-00-00 00:00:00', +col51=16547, +col53='7711484', +col54=-28604, +col55='7112612', +col56='wakefulness\'', +col57=repeat('absorbefacient\'',106), +col58=11027, +col59='AM09gW7', +col60=repeat('Noelani\'',16), +col61='2520576', +col62='substitutiv', +col63='19950106155112', +col64=-12038, +col65='86238806', +col66='19600719080256', +col68=repeat('Sagittarius\'',54), +col69='38943902', +col70=1232, +col71='Elora\'', +col74=repeat('zipp',11), +col75='0', +col76=23254, +col78=13247, +col79='56219', +col80='20500609035724', +col81=11632, +col82=7, +col84=-23863, +col85=6341, +col87='HZdkf.4 s7t,5Rmq 8so fmr,ruGLUG25TrtI.yQ 2SuHq0ML7rw7.4 b2yf2E5TJxOtBBZImezDnzpj,uPYfznnEUDN1e9aQoO 2DsplB7TFWy oQJ br HLF :F,eQ p4i1oWsr lL3PG,hjCz6hYqN h1QTjLCjrv:QCdSzpYBibJAtZCxLOk3l6Blsh.W', +col88=16894, +col89=6161, +col90=repeat('gale',48); + +SHOW WARNINGS; + +DROP TABLE bug52745; + +EVAL SET GLOBAL innodb_file_format=$file_format; +EVAL SET GLOBAL innodb_file_format_check=$file_format_check; +EVAL SET GLOBAL innodb_file_per_table=$file_per_table; From 01490413d26cd31f319928e30724bd5a28e82e42 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Tue, 22 Jun 2010 22:34:48 +0200 Subject: [PATCH 009/118] Backport into build-201006221614-5.1.46sp1 > ------------------------------------------------------------ > revno: 1810.3987.13 > revision-id: ramil@mysql.com-20100429044232-f0pkyx8fnpszf142 > parent: alexey.kopytov@sun.com-20100426200600-op06qy98llzpzgl1 > committer: Ramil Kalimullin > branch nick: b53237-5.0-bugteam > timestamp: Thu 2010-04-29 08:42:32 +0400 > message: > Fix for bug #53237: mysql_list_fields/COM_FIELD_LIST stack smashing > > Problem: "COM_FIELD_LIST is an old command of the MySQL server, before there was real move to only > SQL. Seems that the data sent to COM_FIELD_LIST( mysql_list_fields() function) is not > checked for sanity. By sending long data for the table a buffer is overflown, which can > be used deliberately to include code that harms". > > Fix: check incoming data length. The patch did not apply cleanly: - Line numbers are completely off, roughly it is 2030 -> 1313 - What is called "pend" in the patch, is "arg_end" in the source. --- sql/sql_parse.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 5228a37f490..11481933c8a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1300,8 +1300,16 @@ bool dispatch_command(enum enum_server_command command, THD *thd, We have name + wildcard in packet, separated by endzero */ arg_end= strend(packet); + uint arg_length= arg_end - packet; + + /* Check given table name length. */ + if (arg_length >= packet_length || arg_length > NAME_LEN) + { + my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); + break; + } thd->convert_string(&conv_name, system_charset_info, - packet, (uint) (arg_end - packet), thd->charset()); + packet, arg_length, thd->charset()); table_list.alias= table_list.table_name= conv_name.str; packet= arg_end + 1; From fb8791e2bc36c3da93540b68d86ff1f2c3ddb2b2 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Tue, 22 Jun 2010 22:51:35 +0200 Subject: [PATCH 010/118] Backport into build-201006221614-5.1.46sp1 > ------------------------------------------------------------ > revno: 1810.3987.14 > revision-id: davi.arnaut@sun.com-20100429132816-ictyul6d75itek22 > parent: ramil@mysql.com-20100429044232-f0pkyx8fnpszf142 > committer: Davi Arnaut > branch nick: 50974-5.0 > timestamp: Thu 2010-04-29 10:28:16 -0300 > message: > Bug#50974: Server keeps receiving big (> max_allowed_packet) packets indefinitely. > > The server could be tricked to read packets indefinitely if it > received a packet larger than the maximum size of one packet. > This problem is aggravated by the fact that it can be triggered > before authentication. > > The solution is to no skip big packets for non-authenticated > sessions. If a big packet is sent before a session is authen- > ticated, a error is returned and the connection is closed. > ------------------------------------------------------------ > revno: 3363 [merge] > revision-id: davi.arnaut@sun.com-20100429231819-i3anwzrdasjmezvt > parent: davi.arnaut@sun.com-20100401131522-895y8uzvv8ag44gs > parent: davi.arnaut@sun.com-20100429132816-ictyul6d75itek22 > committer: Davi Arnaut > branch nick: mysql-5.1-bugteam > timestamp: Thu 2010-04-29 20:18:19 -0300 > message: > Manual merge. > ------------------------------------------------------------ > Use --include-merges or -n0 to see merged revisions. --- include/mysql_com.h | 10 ++++++++++ sql/net_serv.cc | 4 ++++ sql/sql_connect.cc | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/include/mysql_com.h b/include/mysql_com.h index db5a5eb8741..7d3dd3d4f34 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -277,6 +277,16 @@ typedef struct st_net { /** Client library sqlstate buffer. Set along with the error message. */ char sqlstate[SQLSTATE_LENGTH+1]; void *extension; +#if defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY) + /* + Controls whether a big packet should be skipped. + + Initially set to FALSE by default. Unauthenticated sessions must have + this set to FALSE so that the server can't be tricked to read packets + indefinitely. + */ + my_bool skip_big_packet; +#endif } NET; diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 73892f31ccf..15c0c581108 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -136,6 +136,9 @@ my_bool my_net_init(NET *net, Vio* vio) #else net->query_cache_query= 0; #endif +#if defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY) + net->skip_big_packet= FALSE; +#endif if (vio != 0) /* If real connection */ { @@ -949,6 +952,7 @@ my_real_read(NET *net, size_t *complen) { #if defined(MYSQL_SERVER) && !defined(NO_ALARM) if (!net->compress && + net->skip_big_packet && !my_net_skip_rest(net, (uint32) len, &alarmed, &alarm_buff)) net->error= 3; /* Successfully skiped packet */ #endif diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 16f11fe22c4..2039c7f7449 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -471,6 +471,13 @@ check_user(THD *thd, enum enum_server_command command, } my_ok(thd); thd->password= test(passwd_len); // remember for error messages + /* + Allow the network layer to skip big packets. Although a malicious + authenticated session might use this to trick the server to read + big packets indefinitely, this is a previously established behavior + that needs to be preserved as to not break backwards compatibility. + */ + thd->net.skip_big_packet= TRUE; /* Ready to handle queries */ DBUG_RETURN(0); } From a0a850318b964ca92b660e0127c35061ad8f7a54 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Tue, 22 Jun 2010 22:53:01 +0200 Subject: [PATCH 011/118] Backport into build-201006221614-5.1.46sp1 > ------------------------------------------------------------ > revno: 3351.41.1 > revision-id: alexey.kopytov@sun.com-20100430111048-jdls6ofn4kkmpt09 > parent: sergey.glukhov@sun.com-20100329134249-03wyhzp5k92dzhcb > committer: Alexey Kopytov > branch nick: my51-bug48419 > timestamp: Fri 2010-04-30 15:10:48 +0400 > message: > Bug #48419: another explain crash.. > > WHERE predicates containing references to empty tables in a > subquery were handled incorrectly by the optimizer when > executing EXPLAIN. As a result, the optimizer could try to > evaluate such predicates rather than just stop with > "Impossible WHERE noticed after reading const tables" as > it would do in a non-subquery case. This led to valgrind > errors and crashes. > > Fixed the code checking the above condition so that subqueries > are not excluded and hence are handled in the same way as top > level SELECTs. --- mysql-test/r/explain.result | 12 ++++++++++++ mysql-test/r/ps.result | 12 ++++++------ mysql-test/t/explain.test | 15 +++++++++++++++ sql/sql_select.cc | 3 +-- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result index b8db8b53e06..8f2d704b312 100644 --- a/mysql-test/r/explain.result +++ b/mysql-test/r/explain.result @@ -226,4 +226,16 @@ Warnings: Note 1276 Field or reference 'test.t1.c' of SELECT #2 was resolved in SELECT #1 Note 1003 select (select 1 from `test`.`t2` where (`test`.`t2`.`d` = NULL)) AS `(SELECT 1 FROM t2 WHERE d = c)` from `test`.`t1` DROP TABLE t1, t2; +# +# Bug #48419: another explain crash.. +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b BLOB, KEY b(b(100))); +INSERT INTO t2 VALUES ('1'), ('2'), ('3'); +FLUSH TABLES; +EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT 1 FROM t1 t JOIN t2 WHERE b <= 1 AND t.a); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +DROP TABLE t1, t2; End of 5.1 tests. diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index cf08d763e5c..84b9cdf930c 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -155,24 +155,24 @@ execute stmt1 ; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 6 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table -5 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found -4 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found +5 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +4 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables execute stmt1 ; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 6 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table -5 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found -4 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found +5 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +4 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables explain SELECT (SELECT SUM(c1 + c12 + 0.0) FROM t2 where (t1.c2 - 0e-3) = t2.c2 GROUP BY t1.c15 LIMIT 1) as scalar_s, exists (select 1.0e+0 from t2 where t2.c3 * 9.0000000000 = t1.c4) as exists_s, c5 * 4 in (select c6 + 0.3e+1 from t2) as in_s, (c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_s FROM t1, (select c25 x, c32 y from t2) tt WHERE x * 1 = c25; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 6 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table -5 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found -4 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found +5 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +4 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables deallocate prepare stmt1; diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test index 3c2f7bbbe96..ba6be72dbdc 100644 --- a/mysql-test/t/explain.test +++ b/mysql-test/t/explain.test @@ -198,4 +198,19 @@ INSERT INTO t2 VALUES (NULL), (0); EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1; DROP TABLE t1, t2; + +--echo # +--echo # Bug #48419: another explain crash.. +--echo # + +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b BLOB, KEY b(b(100))); +INSERT INTO t2 VALUES ('1'), ('2'), ('3'); + +FLUSH TABLES; + +EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT 1 FROM t1 t JOIN t2 WHERE b <= 1 AND t.a); + +DROP TABLE t1, t2; + --echo End of 5.1 tests. diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a426f4b68a1..291432c2bb6 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1107,8 +1107,7 @@ JOIN::optimize() } if (conds && const_table_map != found_const_table_map && - (select_options & SELECT_DESCRIBE) && - select_lex->master_unit() == &thd->lex->unit) // upper level SELECT + (select_options & SELECT_DESCRIBE)) { conds=new Item_int((longlong) 0,1); // Always false } From c658c3ed34b99e8fef0c41898ad295b1223071f3 Mon Sep 17 00:00:00 2001 From: sunanda Date: Wed, 23 Jun 2010 12:03:22 +0200 Subject: [PATCH 012/118] Backport into build-201006221614-5.1.46sp1 > ------------------------------------------------------------ > revno: 3367 [merge] > revision-id: joro@sun.com-20100504140328-srxf3c088j2twnq6 > parent: kristofer.pettersson@sun.com-20100503172109-f9hracq5pqsaomb1 > parent: joro@sun.com-20100503151651-nakknn8amrapmdp7 > committer: Georgi Kodinov > branch nick: B53371-5.1-bugteam > timestamp: Tue 2010-05-04 17:03:28 +0300 > message: > Bug #53371: COM_FIELD_LIST can be abused to bypass table level grants. > > This is the 5.1 merge and extension of the fix. > The server was happily accepting paths in table name in all places a table > name is accepted (e.g. a SELECT). This allowed all users that have some > privilege over some database to read all tables in all databases in all > mysql server instances that the server file system has access to. > Fixed by : > 1. making sure no path elements are allowed in quoted table name when > constructing the path (note that the path symbols are still valid in table names > when they're properly escaped by the server). > 2. checking the #mysql50# prefixed names the same way they're checked for > path elements in mysql-5.0. > ------------------------------------------------------------ > Use --include-merges or -n0 to see merged revisions. --- mysql-test/r/grant.result | 16 ++++++++++++++ mysql-test/t/grant.test | 25 ++++++++++++++++++++++ sql/mysql_priv.h | 2 +- sql/partition_info.cc | 4 ++-- sql/sql_parse.cc | 9 +++++++- sql/sql_table.cc | 14 ++++++++++++ sql/sql_yacc.yy | 2 +- sql/table.cc | 29 ++++++++++++++++++++++--- tests/mysql_client_test.c | 45 +++++++++++++++++++++++++++++++++++++++ 9 files changed, 138 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 92beccd2a9e..6831ef6183d 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -1413,3 +1413,19 @@ DROP USER 'user1'; DROP USER 'user1'@'localhost'; DROP USER 'user2'; DROP DATABASE db1; +CREATE DATABASE db1; +CREATE DATABASE db2; +GRANT SELECT ON db1.* to 'testbug'@localhost; +USE db2; +CREATE TABLE t1 (a INT); +USE test; +SELECT * FROM `../db2/tb2`; +ERROR 42S02: Table 'db1.../db2/tb2' doesn't exist +SELECT * FROM `../db2`.tb2; +ERROR 42000: SELECT command denied to user 'testbug'@'localhost' for table 'tb2' +SELECT * FROM `#mysql50#/../db2/tb2`; +ERROR 42S02: Table 'db1.#mysql50#/../db2/tb2' doesn't exist +DROP USER 'testbug'@localhost; +DROP TABLE db2.t1; +DROP DATABASE db1; +DROP DATABASE db2; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index bcd393bd6ab..cb8d3c63be8 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -1525,5 +1525,30 @@ DROP USER 'user1'@'localhost'; DROP USER 'user2'; DROP DATABASE db1; + +# +# Bug #53371: COM_FIELD_LIST can be abused to bypass table level grants. +# + +CREATE DATABASE db1; +CREATE DATABASE db2; +GRANT SELECT ON db1.* to 'testbug'@localhost; +USE db2; +CREATE TABLE t1 (a INT); +USE test; +connect (con1,localhost,testbug,,db1); +--error ER_NO_SUCH_TABLE +SELECT * FROM `../db2/tb2`; +--error ER_TABLEACCESS_DENIED_ERROR +SELECT * FROM `../db2`.tb2; +--error ER_NO_SUCH_TABLE +SELECT * FROM `#mysql50#/../db2/tb2`; +connection default; +disconnect con1; +DROP USER 'testbug'@localhost; +DROP TABLE db2.t1; +DROP DATABASE db1; +DROP DATABASE db2; + # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 56175d069c5..3ecbef4d456 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -2263,7 +2263,7 @@ void update_create_info_from_table(HA_CREATE_INFO *info, TABLE *form); int rename_file_ext(const char * from,const char * to,const char * ext); bool check_db_name(LEX_STRING *db); bool check_column_name(const char *name); -bool check_table_name(const char *name, uint length); +bool check_table_name(const char *name, uint length, bool check_for_path_chars); char *get_field(MEM_ROOT *mem, Field *field); bool get_field(MEM_ROOT *mem, Field *field, class String *res); int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr); diff --git a/sql/partition_info.cc b/sql/partition_info.cc index ba9ea0e876e..6e2f7dfad26 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -972,7 +972,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, part_elem->engine_type= default_engine_type; } if (check_table_name(part_elem->partition_name, - strlen(part_elem->partition_name))) + strlen(part_elem->partition_name), FALSE)) { my_error(ER_WRONG_PARTITION_NAME, MYF(0)); goto end; @@ -990,7 +990,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, { sub_elem= sub_it++; if (check_table_name(sub_elem->partition_name, - strlen(sub_elem->partition_name))) + strlen(sub_elem->partition_name), FALSE)) { my_error(ER_WRONG_PARTITION_NAME, MYF(0)); goto end; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 11481933c8a..93d80164ffb 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1310,6 +1310,13 @@ bool dispatch_command(enum enum_server_command command, THD *thd, } thd->convert_string(&conv_name, system_charset_info, packet, arg_length, thd->charset()); + if (check_table_name(conv_name.str, conv_name.length, FALSE)) + { + /* this is OK due to convert_string() null-terminating the string */ + my_error(ER_WRONG_TABLE_NAME, MYF(0), conv_name.str); + break; + } + table_list.alias= table_list.table_name= conv_name.str; packet= arg_end + 1; @@ -6233,7 +6240,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, DBUG_RETURN(0); // End of memory alias_str= alias ? alias->str : table->table.str; if (!test(table_options & TL_OPTION_ALIAS) && - check_table_name(table->table.str, table->table.length)) + check_table_name(table->table.str, table->table.length, FALSE)) { my_error(ER_WRONG_TABLE_NAME, MYF(0), table->table.str); DBUG_RETURN(0); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ad72cab664e..84e6c721d72 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -435,7 +435,21 @@ uint tablename_to_filename(const char *from, char *to, uint to_length) DBUG_PRINT("enter", ("from '%s'", from)); if ((length= check_n_cut_mysql50_prefix(from, to, to_length))) + { + /* + Check if the name supplied is a valid mysql 5.0 name and + make the name a zero length string if it's not. + Note that just returning zero length is not enough : + a lot of places don't check the return value and expect + a zero terminated string. + */ + if (check_table_name(to, length, TRUE)) + { + to[0]= 0; + length= 0; + } DBUG_RETURN(length); + } length= strconvert(system_charset_info, from, &my_charset_filename, to, to_length, &errors); if (check_if_legal_tablename(to) && diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 4f43ab8bebd..f815da006b1 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -6133,7 +6133,7 @@ alter_list_item: { MYSQL_YYABORT; } - if (check_table_name($3->table.str,$3->table.length) || + if (check_table_name($3->table.str,$3->table.length, FALSE) || ($3->db.str && check_db_name(&$3->db))) { my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str); diff --git a/sql/table.cc b/sql/table.cc index a4e2c59fb87..04d7b3a8d0a 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -494,6 +494,26 @@ inline bool is_system_table_name(const char *name, uint length) } +/** + Check if a string contains path elements +*/ + +static inline bool has_disabled_path_chars(const char *str) +{ + for (; *str; str++) + switch (*str) + { + case FN_EXTCHAR: + case '/': + case '\\': + case '~': + case '@': + return TRUE; + } + return FALSE; +} + + /* Read table definition from a binary / text based .frm file @@ -549,7 +569,8 @@ int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags) This kind of tables must have been opened only by the my_open() above. */ - if (strchr(share->table_name.str, '@') || + if (has_disabled_path_chars(share->table_name.str) || + has_disabled_path_chars(share->db.str) || !strncmp(share->db.str, MYSQL50_TABLE_NAME_PREFIX, MYSQL50_TABLE_NAME_PREFIX_LENGTH) || !strncmp(share->table_name.str, MYSQL50_TABLE_NAME_PREFIX, @@ -2711,7 +2732,6 @@ bool check_db_name(LEX_STRING *org_name) (name_length > NAME_CHAR_LEN)); /* purecov: inspected */ } - /* Allow anything as a table name, as long as it doesn't contain an ' ' at the end @@ -2719,7 +2739,7 @@ bool check_db_name(LEX_STRING *org_name) */ -bool check_table_name(const char *name, uint length) +bool check_table_name(const char *name, uint length, bool check_for_path_chars) { uint name_length= 0; // name length in symbols const char *end= name+length; @@ -2746,6 +2766,9 @@ bool check_table_name(const char *name, uint length) continue; } } + if (check_for_path_chars && + (*name == '/' || *name == '\\' || *name == '~' || *name == FN_EXTCHAR)) + return 1; #endif name++; name_length++; diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index f65e549fd96..b99461ecd06 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -18049,6 +18049,50 @@ static void test_bug44495() DBUG_VOID_RETURN; } +static void test_bug53371() +{ + int rc; + MYSQL_RES *result; + + myheader("test_bug53371"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + myquery(rc); + rc= mysql_query(mysql, "DROP DATABASE IF EXISTS bug53371"); + myquery(rc); + rc= mysql_query(mysql, "DROP USER 'testbug'@localhost"); + + rc= mysql_query(mysql, "CREATE TABLE t1 (a INT)"); + myquery(rc); + rc= mysql_query(mysql, "CREATE DATABASE bug53371"); + myquery(rc); + rc= mysql_query(mysql, "GRANT SELECT ON bug53371.* to 'testbug'@localhost"); + myquery(rc); + + rc= mysql_change_user(mysql, "testbug", NULL, "bug53371"); + myquery(rc); + + rc= mysql_query(mysql, "SHOW COLUMNS FROM client_test_db.t1"); + DIE_UNLESS(rc); + DIE_UNLESS(mysql_errno(mysql) == 1142); + + result= mysql_list_fields(mysql, "../client_test_db/t1", NULL); + DIE_IF(result); + + result= mysql_list_fields(mysql, "#mysql50#/../client_test_db/t1", NULL); + DIE_IF(result); + + rc= mysql_change_user(mysql, opt_user, opt_password, current_db); + myquery(rc); + rc= mysql_query(mysql, "DROP TABLE t1"); + myquery(rc); + rc= mysql_query(mysql, "DROP DATABASE bug53371"); + myquery(rc); + rc= mysql_query(mysql, "DROP USER 'testbug'@localhost"); + myquery(rc); +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -18358,6 +18402,7 @@ static struct my_tests_st my_tests[]= { { "test_bug30472", test_bug30472 }, { "test_bug20023", test_bug20023 }, { "test_bug45010", test_bug45010 }, + { "test_bug53371", test_bug53371 }, { "test_bug31418", test_bug31418 }, { "test_bug31669", test_bug31669 }, { "test_bug28386", test_bug28386 }, From 12c4c7a0ee06685e727d1fb0b8d6d5560a732816 Mon Sep 17 00:00:00 2001 From: sunanda Date: Wed, 23 Jun 2010 12:14:23 +0200 Subject: [PATCH 013/118] Backport into build-201006221614-5.1.46sp1 > ------------------------------------------------------------ > revno: 3386 > revision-id: sergey.glukhov@sun.com-20100518082821-yajhvbv1ghmlpu1n > parent: aelkin@mysql.com-20100516170332-x8priwrdjwolc065 > committer: Sergey Glukhov > branch nick: mysql-5.1-bugteam > timestamp: Tue 2010-05-18 13:28:21 +0500 > message: > Bug#48729 SELECT ... FROM INFORMATION_SCHEMA.ROUTINES causes memory to grow > Analysis showed that in case of accessing I_S table > ROUTINES we perform unnecessary allocations > with get_field() function for every processed row that > in their turn causes significant memory growth. > the fix is to avoid use of get_field(). --- sql/sql_show.cc | 74 ++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index cb60027842d..b4881125b14 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -4180,24 +4180,37 @@ int fill_schema_coll_charset_app(THD *thd, TABLE_LIST *tables, COND *cond) } +static inline void copy_field_as_string(Field *to_field, Field *from_field) +{ + char buff[MAX_FIELD_WIDTH]; + String tmp_str(buff, sizeof(buff), system_charset_info); + from_field->val_str(&tmp_str); + to_field->store(tmp_str.ptr(), tmp_str.length(), system_charset_info); +} + + bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, const char *wild, bool full_access, const char *sp_user) { - String tmp_string; - String sp_db, sp_name, definer; MYSQL_TIME time; LEX *lex= thd->lex; CHARSET_INFO *cs= system_charset_info; - get_field(thd->mem_root, proc_table->field[0], &sp_db); - get_field(thd->mem_root, proc_table->field[1], &sp_name); - get_field(thd->mem_root, proc_table->field[11], &definer); + char sp_db_buff[NAME_LEN + 1], sp_name_buff[NAME_LEN + 1], + definer_buff[USERNAME_LENGTH + HOSTNAME_LENGTH + 2]; + String sp_db(sp_db_buff, sizeof(sp_db_buff), cs); + String sp_name(sp_name_buff, sizeof(sp_name_buff), cs); + String definer(definer_buff, sizeof(definer_buff), cs); + + proc_table->field[0]->val_str(&sp_db); + proc_table->field[1]->val_str(&sp_name); + proc_table->field[11]->val_str(&definer); + if (!full_access) - full_access= !strcmp(sp_user, definer.ptr()); - if (!full_access && check_some_routine_access(thd, sp_db.ptr(), - sp_name.ptr(), - proc_table->field[2]-> - val_int() == - TYPE_ENUM_PROCEDURE)) + full_access= !strcmp(sp_user, definer.c_ptr_safe()); + if (!full_access && + check_some_routine_access(thd, sp_db.c_ptr_safe(), sp_name.c_ptr_safe(), + proc_table->field[2]->val_int() == + TYPE_ENUM_PROCEDURE)) return 0; if ((lex->sql_command == SQLCOM_SHOW_STATUS_PROC && @@ -4207,55 +4220,42 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0) { restore_record(table, s->default_values); - if (!wild || !wild[0] || !wild_compare(sp_name.ptr(), wild, 0)) + if (!wild || !wild[0] || !wild_compare(sp_name.c_ptr_safe(), wild, 0)) { int enum_idx= (int) proc_table->field[5]->val_int(); table->field[3]->store(sp_name.ptr(), sp_name.length(), cs); - get_field(thd->mem_root, proc_table->field[3], &tmp_string); - table->field[0]->store(tmp_string.ptr(), tmp_string.length(), cs); + copy_field_as_string(table->field[0], proc_table->field[3]); table->field[2]->store(sp_db.ptr(), sp_db.length(), cs); - get_field(thd->mem_root, proc_table->field[2], &tmp_string); - table->field[4]->store(tmp_string.ptr(), tmp_string.length(), cs); + copy_field_as_string(table->field[4], proc_table->field[2]); if (proc_table->field[2]->val_int() == TYPE_ENUM_FUNCTION) { - get_field(thd->mem_root, proc_table->field[9], &tmp_string); - table->field[5]->store(tmp_string.ptr(), tmp_string.length(), cs); + copy_field_as_string(table->field[5], proc_table->field[9]); table->field[5]->set_notnull(); } if (full_access) { - get_field(thd->mem_root, proc_table->field[19], &tmp_string); - table->field[7]->store(tmp_string.ptr(), tmp_string.length(), cs); + copy_field_as_string(table->field[7], proc_table->field[19]); table->field[7]->set_notnull(); } table->field[6]->store(STRING_WITH_LEN("SQL"), cs); table->field[10]->store(STRING_WITH_LEN("SQL"), cs); - get_field(thd->mem_root, proc_table->field[6], &tmp_string); - table->field[11]->store(tmp_string.ptr(), tmp_string.length(), cs); + copy_field_as_string(table->field[11], proc_table->field[6]); table->field[12]->store(sp_data_access_name[enum_idx].str, sp_data_access_name[enum_idx].length , cs); - get_field(thd->mem_root, proc_table->field[7], &tmp_string); - table->field[14]->store(tmp_string.ptr(), tmp_string.length(), cs); + copy_field_as_string(table->field[14], proc_table->field[7]); + bzero((char *)&time, sizeof(time)); ((Field_timestamp *) proc_table->field[12])->get_time(&time); table->field[15]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); bzero((char *)&time, sizeof(time)); ((Field_timestamp *) proc_table->field[13])->get_time(&time); table->field[16]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); - get_field(thd->mem_root, proc_table->field[14], &tmp_string); - table->field[17]->store(tmp_string.ptr(), tmp_string.length(), cs); - get_field(thd->mem_root, proc_table->field[15], &tmp_string); - table->field[18]->store(tmp_string.ptr(), tmp_string.length(), cs); + copy_field_as_string(table->field[17], proc_table->field[14]); + copy_field_as_string(table->field[18], proc_table->field[15]); table->field[19]->store(definer.ptr(), definer.length(), cs); - - get_field(thd->mem_root, proc_table->field[16], &tmp_string); - table->field[20]->store(tmp_string.ptr(), tmp_string.length(), cs); - - get_field(thd->mem_root, proc_table->field[17], &tmp_string); - table->field[21]->store(tmp_string.ptr(), tmp_string.length(), cs); - - get_field(thd->mem_root, proc_table->field[18], &tmp_string); - table->field[22]->store(tmp_string.ptr(), tmp_string.length(), cs); + copy_field_as_string(table->field[20], proc_table->field[16]); + copy_field_as_string(table->field[21], proc_table->field[17]); + copy_field_as_string(table->field[22], proc_table->field[18]); return schema_table_store_record(thd, table); } From 1c87c8b1eeaf06e77a2651bbff80ec1a0170547d Mon Sep 17 00:00:00 2001 From: sunanda Date: Wed, 23 Jun 2010 12:22:05 +0200 Subject: [PATCH 014/118] Backport into build-201006221614-5.1.46sp1 > ------------------------------------------------------------ > revno: 3392.1.1 > revision-id: gshchepa@mysql.com-20100521184732-0jvpzinv0uwyvr2d > parent: sven.sandberg@sun.com-20100520153801-yyhujm1qqa4eyfn0 > committer: Gleb Shchepa > branch nick: 53804-5.1 > timestamp: Fri 2010-05-21 22:47:32 +0400 > message: > Bug #53804: serious flaws in the alter database .. upgrade > data directory name command > > The check_db_name function has been modified to validate tails of > #mysql50#-prefixed database names for compliance with MySQL 5.0 > database name encoding rules (the check_table_name function call > has been reused). --- mysql-test/r/renamedb.result | 2 +- mysql-test/r/upgrade.result | 28 ++++++++++++++++++++++++++++ mysql-test/t/renamedb.test | 2 +- mysql-test/t/upgrade.test | 34 ++++++++++++++++++++++++++++++++++ sql/mysql_priv.h | 1 + sql/sql_table.cc | 23 ++++++++++++++++++++--- sql/table.cc | 34 ++++++++++------------------------ 7 files changed, 95 insertions(+), 29 deletions(-) diff --git a/mysql-test/r/renamedb.result b/mysql-test/r/renamedb.result index ff8f89592fc..e77aca0d0b7 100644 --- a/mysql-test/r/renamedb.result +++ b/mysql-test/r/renamedb.result @@ -7,6 +7,6 @@ ERROR HY000: Incorrect usage of ALTER DATABASE UPGRADE DATA DIRECTORY NAME and n ALTER DATABASE `#mysql51#not-yet` UPGRADE DATA DIRECTORY NAME; ERROR HY000: Incorrect usage of ALTER DATABASE UPGRADE DATA DIRECTORY NAME and name ALTER DATABASE `#mysql50#` UPGRADE DATA DIRECTORY NAME; -ERROR HY000: Incorrect usage of ALTER DATABASE UPGRADE DATA DIRECTORY NAME and name +ERROR 42000: Incorrect database name '#mysql50#' ALTER DATABASE `#mysql50#upgrade-me` UPGRADE DATA DIRECTORY NAME; ERROR 42000: Unknown database '#mysql50#upgrade-me' diff --git a/mysql-test/r/upgrade.result b/mysql-test/r/upgrade.result index 034242079b1..da2f55b5bb1 100644 --- a/mysql-test/r/upgrade.result +++ b/mysql-test/r/upgrade.result @@ -112,3 +112,31 @@ select * from `a-b-c`.v1; f1 drop database `a-b-c`; use test; +# End of 5.0 tests +# +# Bug #53804: serious flaws in the alter database .. upgrade data +# directory name command +# +ALTER DATABASE `#mysql50#:` UPGRADE DATA DIRECTORY NAME; +ERROR 42000: Unknown database '#mysql50#:' +ALTER DATABASE `#mysql50#.` UPGRADE DATA DIRECTORY NAME; +ERROR 42000: Incorrect database name '#mysql50#.' +ALTER DATABASE `#mysql50#../` UPGRADE DATA DIRECTORY NAME; +ERROR 42000: Incorrect database name '#mysql50#../' +ALTER DATABASE `#mysql50#../..` UPGRADE DATA DIRECTORY NAME; +ERROR 42000: Incorrect database name '#mysql50#../..' +ALTER DATABASE `#mysql50#../../` UPGRADE DATA DIRECTORY NAME; +ERROR 42000: Incorrect database name '#mysql50#../../' +ALTER DATABASE `#mysql50#./blablabla` UPGRADE DATA DIRECTORY NAME; +ERROR 42000: Incorrect database name '#mysql50#./blablabla' +ALTER DATABASE `#mysql50#../blablabla` UPGRADE DATA DIRECTORY NAME; +ERROR 42000: Incorrect database name '#mysql50#../blablabla' +ALTER DATABASE `#mysql50#/` UPGRADE DATA DIRECTORY NAME; +ERROR 42000: Incorrect database name '#mysql50#/' +ALTER DATABASE `#mysql50#/.` UPGRADE DATA DIRECTORY NAME; +ERROR 42000: Incorrect database name '#mysql50#/.' +USE `#mysql50#.`; +ERROR 42000: Incorrect database name '#mysql50#.' +USE `#mysql50#../blablabla`; +ERROR 42000: Incorrect database name '#mysql50#../blablabla' +# End of 5.1 tests diff --git a/mysql-test/t/renamedb.test b/mysql-test/t/renamedb.test index 84315090b7a..71d0c127058 100644 --- a/mysql-test/t/renamedb.test +++ b/mysql-test/t/renamedb.test @@ -44,7 +44,7 @@ ALTER DATABASE `#mysql41#not-supported` UPGRADE DATA DIRECTORY NAME; --error ER_WRONG_USAGE ALTER DATABASE `#mysql51#not-yet` UPGRADE DATA DIRECTORY NAME; ---error ER_WRONG_USAGE +--error ER_WRONG_DB_NAME ALTER DATABASE `#mysql50#` UPGRADE DATA DIRECTORY NAME; --error ER_BAD_DB_ERROR diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test index e390e8a1253..a7b9a1531ff 100644 --- a/mysql-test/t/upgrade.test +++ b/mysql-test/t/upgrade.test @@ -137,3 +137,37 @@ select * from `a-b-c`.v1; --enable_ps_protocol drop database `a-b-c`; use test; + +--echo # End of 5.0 tests + +--echo # +--echo # Bug #53804: serious flaws in the alter database .. upgrade data +--echo # directory name command +--echo # + +--error ER_BAD_DB_ERROR +ALTER DATABASE `#mysql50#:` UPGRADE DATA DIRECTORY NAME; +--error ER_WRONG_DB_NAME +ALTER DATABASE `#mysql50#.` UPGRADE DATA DIRECTORY NAME; +--error ER_WRONG_DB_NAME +ALTER DATABASE `#mysql50#../` UPGRADE DATA DIRECTORY NAME; +--error ER_WRONG_DB_NAME +ALTER DATABASE `#mysql50#../..` UPGRADE DATA DIRECTORY NAME; +--error ER_WRONG_DB_NAME +ALTER DATABASE `#mysql50#../../` UPGRADE DATA DIRECTORY NAME; +--error ER_WRONG_DB_NAME +ALTER DATABASE `#mysql50#./blablabla` UPGRADE DATA DIRECTORY NAME; +--error ER_WRONG_DB_NAME +ALTER DATABASE `#mysql50#../blablabla` UPGRADE DATA DIRECTORY NAME; +--error ER_WRONG_DB_NAME +ALTER DATABASE `#mysql50#/` UPGRADE DATA DIRECTORY NAME; +--error ER_WRONG_DB_NAME +ALTER DATABASE `#mysql50#/.` UPGRADE DATA DIRECTORY NAME; + +--error ER_WRONG_DB_NAME +USE `#mysql50#.`; +--error ER_WRONG_DB_NAME +USE `#mysql50#../blablabla`; + +--echo # End of 5.1 tests + diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 3ecbef4d456..30f3a1af437 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -2287,6 +2287,7 @@ uint explain_filename(THD* thd, const char *from, char *to, uint to_length, uint filename_to_tablename(const char *from, char *to, uint to_length); uint tablename_to_filename(const char *from, char *to, uint to_length); uint check_n_cut_mysql50_prefix(const char *from, char *to, uint to_length); +bool check_mysql50_prefix(const char *name); #endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */ #ifdef MYSQL_SERVER uint build_table_filename(char *buff, size_t bufflen, const char *db, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 84e6c721d72..babc025db87 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -391,6 +391,25 @@ uint filename_to_tablename(const char *from, char *to, uint to_length) } +/** + Check if given string begins with "#mysql50#" prefix + + @param name string to check cut + + @retval + FALSE no prefix found + @retval + TRUE prefix found +*/ + +bool check_mysql50_prefix(const char *name) +{ + return (name[0] == '#' && + !strncmp(name, MYSQL50_TABLE_NAME_PREFIX, + MYSQL50_TABLE_NAME_PREFIX_LENGTH)); +} + + /** Check if given string begins with "#mysql50#" prefix, cut it if so. @@ -406,9 +425,7 @@ uint filename_to_tablename(const char *from, char *to, uint to_length) uint check_n_cut_mysql50_prefix(const char *from, char *to, uint to_length) { - if (from[0] == '#' && - !strncmp(from, MYSQL50_TABLE_NAME_PREFIX, - MYSQL50_TABLE_NAME_PREFIX_LENGTH)) + if (check_mysql50_prefix(from)) return (uint) (strmake(to, from + MYSQL50_TABLE_NAME_PREFIX_LENGTH, to_length - 1) - to); return 0; diff --git a/sql/table.cc b/sql/table.cc index 04d7b3a8d0a..23d41760495 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2701,44 +2701,30 @@ bool check_db_name(LEX_STRING *org_name) { char *name= org_name->str; uint name_length= org_name->length; + bool check_for_path_chars; if (!name_length || name_length > NAME_LEN) return 1; + if ((check_for_path_chars= check_mysql50_prefix(name))) + { + name+= MYSQL50_TABLE_NAME_PREFIX_LENGTH; + name_length-= MYSQL50_TABLE_NAME_PREFIX_LENGTH; + } + if (lower_case_table_names && name != any_db) my_casedn_str(files_charset_info, name); -#if defined(USE_MB) && defined(USE_MB_IDENT) - if (use_mb(system_charset_info)) - { - name_length= 0; - bool last_char_is_space= TRUE; - char *end= name + org_name->length; - while (name < end) - { - int len; - last_char_is_space= my_isspace(system_charset_info, *name); - len= my_ismbchar(system_charset_info, name, end); - if (!len) - len= 1; - name+= len; - name_length++; - } - return (last_char_is_space || name_length > NAME_CHAR_LEN); - } - else -#endif - return ((org_name->str[org_name->length - 1] != ' ') || - (name_length > NAME_CHAR_LEN)); /* purecov: inspected */ + return check_table_name(name, name_length, check_for_path_chars); } + /* Allow anything as a table name, as long as it doesn't contain an ' ' at the end returns 1 on error */ - bool check_table_name(const char *name, uint length, bool check_for_path_chars) { uint name_length= 0; // name length in symbols @@ -2766,10 +2752,10 @@ bool check_table_name(const char *name, uint length, bool check_for_path_chars) continue; } } +#endif if (check_for_path_chars && (*name == '/' || *name == '\\' || *name == '~' || *name == FN_EXTCHAR)) return 1; -#endif name++; name_length++; } From f801ca68c65167a82f0dc2619540ef1c83e7826b Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 9 Jul 2010 16:37:52 -0300 Subject: [PATCH 015/118] Use UNINIT_VAR workaround instead of LINT_INIT. --- client/mysqlshow.c | 3 +-- regex/regcomp.c | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 2f5582cb668..8c64d61ded2 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -669,8 +669,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table, char query[1024],*end; MYSQL_RES *result; MYSQL_ROW row; - ulong rows; - LINT_INIT(rows); + ulong UNINIT_VAR(rows); if (mysql_select_db(mysql,db)) { diff --git a/regex/regcomp.c b/regex/regcomp.c index 8280fbfd6c8..81c435ed552 100644 --- a/regex/regcomp.c +++ b/regex/regcomp.c @@ -1563,13 +1563,13 @@ struct parse *p; register struct re_guts *g; { register sop *scan; - sop *start; - register sop *newstart; + sop *UNINIT_VAR(start); + register sop *UNINIT_VAR(newstart); register sopno newlen; register sop s; register char *cp; register sopno i; - LINT_INIT(start); LINT_INIT(newstart); + /* avoid making error situations worse */ if (p->error != 0) return; From 266ca421da5903a97a7a52fed2032afab5df74d6 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 9 Jul 2010 14:11:12 +0300 Subject: [PATCH 016/118] Bug #52274 : Missing path to mysql in mysql_secure_installation Added some code to try to find the mysql command line in the most common places and stop if it's not there. --- scripts/mysql_secure_installation.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/mysql_secure_installation.sh b/scripts/mysql_secure_installation.sh index 25d6343ee2c..188cd030dba 100644 --- a/scripts/mysql_secure_installation.sh +++ b/scripts/mysql_secure_installation.sh @@ -17,6 +17,7 @@ config=".my.cnf.$$" command=".mysql.$$" +mysql_client="" trap "interrupt" 2 @@ -37,10 +38,26 @@ prepare() { chmod 600 $config $command } +find_mysql_client() +{ + for n in ./bin/mysql mysql + do + $n --no-defaults --help > /dev/null 2>&1 + status=$? + if test $status -eq 0 + then + mysql_client=$n + return + fi + done + echo "Can't find a 'mysql' client in PATH or ./bin" + exit 1 +} + do_query() { echo "$1" >$command #sed 's,^,> ,' < $command # Debugging - mysql --defaults-file=$config <$command + $mysql_client --defaults-file=$config <$command return $? } @@ -204,6 +221,7 @@ cleanup() { # The actual script starts here prepare +find_mysql_client set_echo_compat echo From 1919414fbea08e73d326b92356b89133ed447e1d Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 14 Jul 2010 13:53:49 +0300 Subject: [PATCH 017/118] Bug #54004 : mysql_secure_installation identifies "local host" incorrectly The removal of non-local root users is overzealous in mysql_secure_installation. (Bug #54004) --- scripts/mysql_secure_installation.pl.in | 2 +- scripts/mysql_secure_installation.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mysql_secure_installation.pl.in b/scripts/mysql_secure_installation.pl.in index 25339f9b916..0cd99267cdb 100755 --- a/scripts/mysql_secure_installation.pl.in +++ b/scripts/mysql_secure_installation.pl.in @@ -208,7 +208,7 @@ sub remove_anonymous_users { } sub remove_remote_root { - if (do_query("DELETE FROM mysql.user WHERE User='root' AND Host!='localhost';")) { + if (do_query("DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');")) { print " ... Success!\n"; } else { print " ... Failed!\n"; diff --git a/scripts/mysql_secure_installation.sh b/scripts/mysql_secure_installation.sh index 188cd030dba..ed789677bf0 100644 --- a/scripts/mysql_secure_installation.sh +++ b/scripts/mysql_secure_installation.sh @@ -164,7 +164,7 @@ remove_anonymous_users() { } remove_remote_root() { - do_query "DELETE FROM mysql.user WHERE User='root' AND Host!='localhost';" + do_query "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');" if [ $? -eq 0 ]; then echo " ... Success!" else From 678640019debce6c77109dc5f52e323eaee45a9f Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 14 Jul 2010 11:50:17 +0300 Subject: [PATCH 018/118] Bug #53493 : add_to_status does not handle the longlong fields in STATUS_VAR bytes_received/bytes_sent are ulonglong so they cannot be handled by the ulong handling code in add_to_status/add_diff_to_status(). Fixed by adding code to handle these two variables in add_to_status()/add_diff_to_status() and making sure they are not a subject to the ulong handling code. --- sql/sql_class.cc | 6 ++++++ sql/sql_class.h | 17 ++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 2ce03708a9a..1028a9fccf4 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1063,6 +1063,9 @@ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var) while (to != end) *(to++)+= *(from++); + + to_var->bytes_received+= from_var->bytes_received; + to_var->bytes_sent+= from_var->bytes_sent; } /* @@ -1088,6 +1091,9 @@ void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var, while (to != end) *(to++)+= *(from++) - *(dec++); + + to_var->bytes_received+= from_var->bytes_received - dec_var->bytes_received;; + to_var->bytes_sent+= from_var->bytes_sent - dec_var->bytes_sent; } diff --git a/sql/sql_class.h b/sql/sql_class.h index 5155ffe0603..1627b6ec02d 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -405,12 +405,14 @@ struct system_variables }; -/* per thread status variables */ +/** + Per thread status variables. + Must be long/ulong up to last_system_status_var so that + add_to_status/add_diff_to_status can work. +*/ typedef struct system_status_var { - ulonglong bytes_received; - ulonglong bytes_sent; ulong com_other; ulong com_stat[(uint) SQLCOM_END]; ulong created_tmp_disk_tables; @@ -466,13 +468,14 @@ typedef struct system_status_var Number of statements sent from the client */ ulong questions; + + ulonglong bytes_received; + ulonglong bytes_sent; /* IMPORTANT! SEE last_system_status_var DEFINITION BELOW. - Below 'last_system_status_var' are all variables which doesn't make any - sense to add to the /global/ status variable counter. - Status variables which it does not make sense to add to - global status variable counter + Below 'last_system_status_var' are all variables that cannot be handled + automatically by add_to_status()/add_diff_to_status(). */ double last_query_cost; } STATUS_VAR; From dbb643d64e0981f56b6c7b35586f430b08091834 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 14 Jul 2010 14:54:51 +0300 Subject: [PATCH 019/118] Bug #51876: crash/memory underrun when loading data with ucs2 and reverse() function 3 problems fixed : 1. The reported problem : caused by incorrect parsing of the file as ucs data resulting in wrong length of the parsed string. Fixed by truncating the invalid trailing bytes (non-complete multibyte characters) when reading from the file 2. LOAD DATA when reading from a proper UCS2 file wasn't recognizing the new line characters. Fixed by first looking if a byte is a new line (or any other special) character before reading it as a part of a multibyte character. 3. When using user variables to hold the column data in LOAD DATA the character set of the user variable was set incorrectly to the database charset. Fixed by setting it to the charset specified by LOAD DATA (if any). --- mysql-test/r/loaddata.result | 29 +++++++++++++++++++ mysql-test/t/loaddata.test | 32 +++++++++++++++++++++ sql/item_func.cc | 5 +++- sql/sql_load.cc | 56 +++++++++++++++++++++--------------- 4 files changed, 98 insertions(+), 24 deletions(-) diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result index 665e80b8ba2..40c278380b1 100644 --- a/mysql-test/r/loaddata.result +++ b/mysql-test/r/loaddata.result @@ -503,4 +503,33 @@ DROP TABLE t1; CREATE TABLE t1 (id INT NOT NULL); LOAD DATA LOCAL INFILE 'tb.txt' INTO TABLE t1; DROP TABLE t1; +# +# Bug #51876 : crash/memory underrun when loading data with ucs2 +# and reverse() function +# +# Problem # 1 (original report): wrong parsing of ucs2 data +SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp.txt'; +CREATE TABLE t1(a INT); +LOAD DATA INFILE 'tmpp.txt' INTO TABLE t1 CHARACTER SET ucs2 +(@b) SET a=REVERSE(@b); +Warnings: +Warning 1366 Incorrect integer value: '00' for column 'a' at row 1 +Warning 1366 Incorrect integer value: '10' for column 'a' at row 2 +# should return 2 zeroes (as the value is truncated) +SELECT * FROM t1; +a +0 +0 +DROP TABLE t1; +# Problem # 2 : if you write and read ucs2 data to a file they're lost +SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp2.txt' CHARACTER SET ucs2; +CREATE TABLE t1(a INT); +LOAD DATA INFILE 'tmpp2.txt' INTO TABLE t1 CHARACTER SET ucs2 +(@b) SET a=REVERSE(@b); +# should return 0 and 1 (10 reversed) +SELECT * FROM t1; +a +0 +1 +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index e24f0b16705..821453777f5 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -580,4 +580,36 @@ DROP TABLE t1; connection default; disconnect con1; + +--echo # +--echo # Bug #51876 : crash/memory underrun when loading data with ucs2 +--echo # and reverse() function +--echo # + +--echo # Problem # 1 (original report): wrong parsing of ucs2 data +SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp.txt'; +CREATE TABLE t1(a INT); +LOAD DATA INFILE 'tmpp.txt' INTO TABLE t1 CHARACTER SET ucs2 +(@b) SET a=REVERSE(@b); +--echo # should return 2 zeroes (as the value is truncated) +SELECT * FROM t1; + +DROP TABLE t1; +let $MYSQLD_DATADIR= `select @@datadir`; +remove_file $MYSQLD_DATADIR/test/tmpp.txt; + + +--echo # Problem # 2 : if you write and read ucs2 data to a file they're lost +SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp2.txt' CHARACTER SET ucs2; +CREATE TABLE t1(a INT); +LOAD DATA INFILE 'tmpp2.txt' INTO TABLE t1 CHARACTER SET ucs2 +(@b) SET a=REVERSE(@b); +--echo # should return 0 and 1 (10 reversed) +SELECT * FROM t1; + +DROP TABLE t1; +let $MYSQLD_DATADIR= `select @@datadir`; +remove_file $MYSQLD_DATADIR/test/tmpp2.txt; + + --echo End of 5.1 tests diff --git a/sql/item_func.cc b/sql/item_func.cc index 1e31755179b..1bec4700bff 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4715,6 +4715,7 @@ bool Item_func_get_user_var::set_value(THD *thd, bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref) { DBUG_ASSERT(fixed == 0); + DBUG_ASSERT(thd->lex->exchange); if (Item::fix_fields(thd, ref) || !(entry= get_variable(&thd->user_vars, name, 1))) return TRUE; @@ -4724,7 +4725,9 @@ bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref) of fields in LOAD DATA INFILE. (Since Item_user_var_as_out_param is used only there). */ - entry->collation.set(thd->variables.collation_database); + entry->collation.set(thd->lex->exchange->cs ? + thd->lex->exchange->cs : + thd->variables.collation_database); entry->update_query_id= thd->query_id; return FALSE; } diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 552473e4fc2..ee7481234a4 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -1208,29 +1208,6 @@ int READ_INFO::read_field() while ( to < end_of_buff) { chr = GET; -#ifdef USE_MB - if ((my_mbcharlen(read_charset, chr) > 1) && - to+my_mbcharlen(read_charset, chr) <= end_of_buff) - { - uchar* p = (uchar*)to; - *to++ = chr; - int ml = my_mbcharlen(read_charset, chr); - int i; - for (i=1; i 1 && + to + my_mbcharlen(read_charset, chr) <= end_of_buff) + { + uchar* p= (uchar*) to; + int ml, i; + *to++ = chr; + + ml= my_mbcharlen(read_charset, chr); + + for (i= 1; i < ml; i++) + { + chr= GET; + if (chr == my_b_EOF) + { + /* + Need to back up the bytes already ready from illformed + multi-byte char + */ + to-= i; + goto found_eof; + } + *to++ = chr; + } + if (my_ismbchar(read_charset, + (const char *)p, + (const char *)to)) + continue; + for (i= 0; i < ml; i++) + PUSH((uchar) *--to); + chr= GET; + } +#endif *to++ = (uchar) chr; } /* From ce78970202c076b5c9967ea4e31e5add94c73d82 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Wed, 14 Jul 2010 10:10:12 -0300 Subject: [PATCH 020/118] Bug#48327: Some crashes specific to FreeBSD ("embedded") Backport fixes from ndb: Rework the constructors of some static object's to not call dbug functions since the constructors will be called before main, and consequently, before the dbug library is initialized. --- storage/ndb/src/common/portlib/NdbMutex.c | 21 ++++++--------- storage/ndb/src/ndbapi/DictCache.cpp | 32 ++++++++++++++++++----- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/storage/ndb/src/common/portlib/NdbMutex.c b/storage/ndb/src/common/portlib/NdbMutex.c index c9184e5d1f2..5595baba7c4 100644 --- a/storage/ndb/src/common/portlib/NdbMutex.c +++ b/storage/ndb/src/common/portlib/NdbMutex.c @@ -24,36 +24,31 @@ NdbMutex* NdbMutex_Create(void) { NdbMutex* pNdbMutex; int result; - DBUG_ENTER("NdbMutex_Create"); - + pNdbMutex = (NdbMutex*)NdbMem_Allocate(sizeof(NdbMutex)); - DBUG_PRINT("info",("NdbMem_Allocate 0x%lx", (long) pNdbMutex)); - + if (pNdbMutex == NULL) - DBUG_RETURN(NULL); - + return NULL; + result = pthread_mutex_init(pNdbMutex, NULL); assert(result == 0); - - DBUG_RETURN(pNdbMutex); + + return pNdbMutex; } int NdbMutex_Destroy(NdbMutex* p_mutex) { int result; - DBUG_ENTER("NdbMutex_Destroy"); if (p_mutex == NULL) - DBUG_RETURN(-1); + return -1; result = pthread_mutex_destroy(p_mutex); - DBUG_PRINT("info",("NdbMem_Free 0x%lx", (long) p_mutex)); NdbMem_Free(p_mutex); - - DBUG_RETURN(result); + return result; } diff --git a/storage/ndb/src/ndbapi/DictCache.cpp b/storage/ndb/src/ndbapi/DictCache.cpp index 04be3711847..9c66b2be9d2 100644 --- a/storage/ndb/src/ndbapi/DictCache.cpp +++ b/storage/ndb/src/ndbapi/DictCache.cpp @@ -20,8 +20,10 @@ #include #include -static NdbTableImpl f_invalid_table; -static NdbTableImpl f_altered_table; +static NdbTableImpl * f_invalid_table = 0; +static NdbTableImpl * f_altered_table = 0; + +static int ndb_dict_cache_count = 0; Ndb_local_table_info * Ndb_local_table_info::create(NdbTableImpl *table_impl, Uint32 sz) @@ -93,11 +95,29 @@ GlobalDictCache::GlobalDictCache(){ DBUG_ENTER("GlobalDictCache::GlobalDictCache"); m_tableHash.createHashTable(); m_waitForTableCondition = NdbCondition_Create(); + if (f_invalid_table == NULL) + f_invalid_table = new NdbTableImpl(); + if (f_altered_table == NULL) + f_altered_table = new NdbTableImpl(); + ndb_dict_cache_count++; DBUG_VOID_RETURN; } GlobalDictCache::~GlobalDictCache(){ DBUG_ENTER("GlobalDictCache::~GlobalDictCache"); + if (--ndb_dict_cache_count == 0) + { + if (f_invalid_table) + { + delete f_invalid_table; + f_invalid_table = 0; + } + if (f_altered_table) + { + delete f_altered_table; + f_altered_table = 0; + } + } NdbElement_t > * curr = m_tableHash.getNext(0); while(curr != 0){ Vector * vers = curr->theData; @@ -254,7 +274,7 @@ GlobalDictCache::put(const char * name, NdbTableImpl * tab) TableVersion & ver = vers->back(); if(ver.m_status != RETREIVING || !(ver.m_impl == 0 || - ver.m_impl == &f_invalid_table || ver.m_impl == &f_altered_table) || + ver.m_impl == f_invalid_table || ver.m_impl == f_altered_table) || ver.m_version != 0 || ver.m_refCount == 0){ abort(); @@ -271,7 +291,7 @@ GlobalDictCache::put(const char * name, NdbTableImpl * tab) ver.m_version = tab->m_version; ver.m_status = OK; } - else if (ver.m_impl == &f_invalid_table) + else if (ver.m_impl == f_invalid_table) { DBUG_PRINT("info", ("Table DROPPED invalid")); ver.m_impl = tab; @@ -279,7 +299,7 @@ GlobalDictCache::put(const char * name, NdbTableImpl * tab) ver.m_status = DROPPED; ver.m_impl->m_status = NdbDictionary::Object::Invalid; } - else if(ver.m_impl == &f_altered_table) + else if(ver.m_impl == f_altered_table) { DBUG_PRINT("info", ("Table DROPPED altered")); ver.m_impl = tab; @@ -440,7 +460,7 @@ GlobalDictCache::alter_table_rep(const char * name, if(i == sz - 1 && ver.m_status == RETREIVING) { - ver.m_impl = altered ? &f_altered_table : &f_invalid_table; + ver.m_impl = altered ? f_altered_table : f_invalid_table; DBUG_VOID_RETURN; } } From f317d3a6fb413cfc04c1ed005df8e859664e41d5 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Wed, 14 Jul 2010 09:27:13 -0300 Subject: [PATCH 021/118] Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. Another rather noisy violation of strict aliasing rules is the spatial code which makes use of stack-based memory (of type Geometry_buffer) to provide placement for Geometry objects. Although a placement new is allowed to dynamically change the type of a object, the object returned by the new placement was being ignored and the original stack-based object was being casted to the new type, thus violating strict aliasing rules. The solution is to reorganize the code so that the object returned by the new placement is used instead of casting the original object. Also, to ensure that the stack-based object is properly aligned with respect to the objects it provides placement for, a set of compiler-dependent macros and types are introduced so that the alignment of objects can be inquired and specified. include/Makefile.am: Add new header. include/my_compiler.h: Add new header. include/my_global.h: Remove now-unnecessary macros. sql/spatial.cc: Make object creation functions return the object whose type was dynamically changed by the new placement. Move static method from the header in order to avoid having to access a forward declaration. sql/spatial.h: Object creation callbacks now take a array of chars as the storage area. Move create_by_typeid to a source file as to not access the forward declaration of Geometry_buffer. Ensure that Geometry_buffer is properly aligned. sql/sql_show.cc: Use newly added aligned storage helper. --- include/Makefile.am | 2 +- include/my_compiler.h | 127 ++++++++++++++++++++++++++++++++++++++++++ include/my_global.h | 3 - sql/spatial.cc | 43 ++++++++------ sql/spatial.h | 28 ++++------ sql/sql_show.cc | 4 +- 6 files changed, 166 insertions(+), 41 deletions(-) create mode 100644 include/my_compiler.h diff --git a/include/Makefile.am b/include/Makefile.am index 130517a405e..182011c25a3 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -37,7 +37,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_libwrap.h my_stacktrace.h my_compiler.h EXTRA_DIST = mysql.h.pp mysql/plugin.h.pp diff --git a/include/my_compiler.h b/include/my_compiler.h new file mode 100644 index 00000000000..0a83c6587a5 --- /dev/null +++ b/include/my_compiler.h @@ -0,0 +1,127 @@ +#ifndef MY_COMPILER_INCLUDED +#define MY_COMPILER_INCLUDED + +/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** + Header for compiler-dependent features. + + Intended to contain a set of reusable wrappers for preprocessor + macros, attributes, pragmas, and any other features that are + specific to a target compiler. +*/ + +#include /* stddef.h offsetof */ + +/** + Compiler-dependent internal convenience macros. +*/ + +/* GNU C/C++ */ +#if defined __GNUC__ +/* Any after 2.95... */ +# define MY_ALIGN_EXT + +/* Microsoft Visual C++ */ +#elif defined _MSC_VER +# define MY_ALIGNOF(type) __alignof(type) +# define MY_ALIGNED(n) __declspec(align(n)) + +/* Oracle Solaris Studio */ +#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) +# if (__SUNPRO_C >= 0x590) || (__SUNPRO_CC >= 0x590) +# define MY_ALIGN_EXT +# endif + +/* IBM XL C/C++ */ +#elif defined __xlC__ +# if __xlC__ >= 0x0600 +# define MY_ALIGN_EXT +# endif + +/* HP aCC */ +#elif defined(__HP_aCC) || defined(__HP_cc) +# if (__HP_aCC >= 60000) || (__HP_cc >= 60000) +# define MY_ALIGN_EXT +# endif +#endif + +#ifdef MY_ALIGN_EXT +/** Specifies the minimum alignment of a type. */ +# define MY_ALIGNOF(type) __alignof__(type) +/** Determine the alignment requirement of a type. */ +# define MY_ALIGNED(n) __attribute__((__aligned__((n)))) +#endif + +/** + Generic compiler-dependent features. +*/ +#ifndef MY_ALIGNOF +# ifdef __cplusplus + template struct my_alignof_helper { char m1; type m2; }; + /* Invalid for non-POD types, but most compilers give the right answer. */ +# define MY_ALIGNOF(type) offsetof(my_alignof_helper, m2) +# else +# define MY_ALIGNOF(type) offsetof(struct { char m1; type m2; }, m2) +# endif +#endif + +/** + C++ Type Traits +*/ + +#ifdef __cplusplus + +/** + Opaque storage with a particular alignment. +*/ +# if defined(MY_ALIGNED) +/* Partial specialization used due to MSVC++. */ +template struct my_alignment_imp; +template<> struct MY_ALIGNED(1) my_alignment_imp<1> {}; +template<> struct MY_ALIGNED(2) my_alignment_imp<2> {}; +template<> struct MY_ALIGNED(4) my_alignment_imp<4> {}; +template<> struct MY_ALIGNED(8) my_alignment_imp<8> {}; +template<> struct MY_ALIGNED(16) my_alignment_imp<16> {}; +/* ... expand as necessary. */ +# else +template +struct my_alignment_imp { double m1; }; +# endif + +/** + A POD type with a given size and alignment. + + @remark If the compiler does not support a alignment attribute + (MY_ALIGN macro), the default alignment of a double is + used instead. + + @tparam size The minimum size. + @tparam alignment The desired alignment: 1, 2, 4, 8 or 16. +*/ +template +struct my_aligned_storage +{ + union + { + char data[size]; + my_alignment_imp align; + }; +}; + +#endif /* __cplusplus */ + +#endif /* MY_COMPILER_INCLUDED */ diff --git a/include/my_global.h b/include/my_global.h index f03ed665d5a..6723267ae50 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -941,9 +941,6 @@ typedef long long my_ptrdiff_t; #define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size) #define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B)) -#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B)) -#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))] - /* Custom version of standard offsetof() macro which can be used to get offsets of members in class for non-POD types (according to the current diff --git a/sql/spatial.cc b/sql/spatial.cc index 9114c81514d..11df6c00dc5 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -53,7 +53,7 @@ static Geometry::Class_info **ci_collection_end= Geometry::ci_collection+Geometry::wkb_last + 1; Geometry::Class_info::Class_info(const char *name, int type_id, - void(*create_func)(void *)): + create_geom_t create_func): m_type_id(type_id), m_create_func(create_func) { m_name.str= (char *) name; @@ -62,39 +62,39 @@ Geometry::Class_info::Class_info(const char *name, int type_id, ci_collection[type_id]= this; } -static void create_point(void *buffer) +static Geometry *create_point(char *buffer) { - new(buffer) Gis_point; + return new (buffer) Gis_point; } -static void create_linestring(void *buffer) +static Geometry *create_linestring(char *buffer) { - new(buffer) Gis_line_string; + return new (buffer) Gis_line_string; } -static void create_polygon(void *buffer) +static Geometry *create_polygon(char *buffer) { - new(buffer) Gis_polygon; + return new (buffer) Gis_polygon; } -static void create_multipoint(void *buffer) +static Geometry *create_multipoint(char *buffer) { - new(buffer) Gis_multi_point; + return new (buffer) Gis_multi_point; } -static void create_multipolygon(void *buffer) +static Geometry *create_multipolygon(char *buffer) { - new(buffer) Gis_multi_polygon; + return new (buffer) Gis_multi_polygon; } -static void create_multilinestring(void *buffer) +static Geometry *create_multilinestring(char *buffer) { - new(buffer) Gis_multi_line_string; + return new (buffer) Gis_multi_line_string; } -static void create_geometrycollection(void *buffer) +static Geometry *create_geometrycollection(char *buffer) { - new(buffer) Gis_geometry_collection; + return new (buffer) Gis_geometry_collection; } @@ -145,6 +145,15 @@ Geometry::Class_info *Geometry::find_class(const char *name, uint32 len) } +Geometry *Geometry::create_by_typeid(Geometry_buffer *buffer, int type_id) +{ + Class_info *ci; + if (!(ci= find_class(type_id))) + return NULL; + return (*ci->m_create_func)(buffer->data); +} + + Geometry *Geometry::construct(Geometry_buffer *buffer, const char *data, uint32 data_len) { @@ -179,9 +188,7 @@ Geometry *Geometry::create_from_wkt(Geometry_buffer *buffer, if (!(ci= find_class(name.str, name.length)) || wkt->reserve(1 + 4, 512)) return NULL; - (*ci->m_create_func)((void *)buffer); - Geometry *result= (Geometry *)buffer; - + Geometry *result= (*ci->m_create_func)(buffer->data); wkt->q_append((char) wkb_ndr); wkt->q_append((uint32) result->get_class_info()->m_type_id); if (trs->check_next_symbol('(') || diff --git a/sql/spatial.h b/sql/spatial.h index 86c2ed8c197..67edc077e04 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -16,6 +16,8 @@ #ifndef _spatial_h #define _spatial_h +#include + #ifdef HAVE_SPATIAL const uint SRID_SIZE= 4; @@ -225,15 +227,18 @@ public: { wkb_xdr= 0, /* Big Endian */ wkb_ndr= 1 /* Little Endian */ - }; + }; + + /** Callback which creates Geometry objects on top of a given placement. */ + typedef Geometry *(*create_geom_t)(char *); class Class_info { public: LEX_STRING m_name; int m_type_id; - void (*m_create_func)(void *); - Class_info(const char *name, int type_id, void(*create_func)(void *)); + create_geom_t m_create_func; + Class_info(const char *name, int type_id, create_geom_t create_func); }; virtual const Class_info *get_class_info() const=0; @@ -263,15 +268,7 @@ public: virtual int geometry_n(uint32 num, String *result) const { return -1; } public: - static Geometry *create_by_typeid(Geometry_buffer *buffer, int type_id) - { - Class_info *ci; - if (!(ci= find_class((int) type_id))) - return NULL; - (*ci->m_create_func)((void *)buffer); - return my_reinterpret_cast(Geometry *)(buffer); - } - + static Geometry *create_by_typeid(Geometry_buffer *buffer, int type_id); static Geometry *construct(Geometry_buffer *buffer, const char *data, uint32 data_len); static Geometry *create_from_wkt(Geometry_buffer *buffer, @@ -528,11 +525,8 @@ public: const Class_info *get_class_info() const; }; -const int geometry_buffer_size= sizeof(Gis_point); -struct Geometry_buffer -{ - void *arr[(geometry_buffer_size - 1)/sizeof(void *) + 1]; -}; +struct Geometry_buffer : public + my_aligned_storage {}; #endif /*HAVE_SPATAIAL*/ #endif diff --git a/sql/sql_show.cc b/sql/sql_show.cc index ca0d16697cd..091bd09aa25 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2202,8 +2202,8 @@ static bool show_status_array(THD *thd, const char *wild, bool ucase_names, COND *cond) { - MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, long); - char * const buff= (char *) &buff_data; + my_aligned_storage buffer; + char * const buff= buffer.data; char *prefix_end; /* the variable name should not be longer than 64 characters */ char name_buffer[64]; From d7944b621e895383482792df3b8aa3eed6ee5f6d Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Wed, 14 Jul 2010 16:39:40 -0300 Subject: [PATCH 022/118] Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. Post-merge fix: include my_compiler.h before my_attribute.h as the latter will undef __attribute__ if the compiler is not GCC. Based on the compiler version, in my_compiler.h we know for sure whether the aligned attribute is supported. Furthermore, undefining attribute might cause bugs if some system header uses it. include/my_compiler.h: Drop aligned attribute support from Sun Studio C++ compiler as its not clear exactly which version of it supports the attribute. --- include/my_compiler.h | 4 +++- include/my_global.h | 2 +- sql/spatial.h | 2 -- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/my_compiler.h b/include/my_compiler.h index 0a83c6587a5..1cd46ff4260 100644 --- a/include/my_compiler.h +++ b/include/my_compiler.h @@ -42,7 +42,7 @@ /* Oracle Solaris Studio */ #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) -# if (__SUNPRO_C >= 0x590) || (__SUNPRO_CC >= 0x590) +# if __SUNPRO_C >= 0x590 # define MY_ALIGN_EXT # endif @@ -124,4 +124,6 @@ struct my_aligned_storage #endif /* __cplusplus */ +#include + #endif /* MY_COMPILER_INCLUDED */ diff --git a/include/my_global.h b/include/my_global.h index 6723267ae50..ec22a57329b 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -623,7 +623,7 @@ typedef unsigned short ushort; #define my_const_cast(A) (A) #endif -#include +#include /* Wen using the embedded library, users might run into link problems, diff --git a/sql/spatial.h b/sql/spatial.h index 67edc077e04..f778acd6c34 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -16,8 +16,6 @@ #ifndef _spatial_h #define _spatial_h -#include - #ifdef HAVE_SPATIAL const uint SRID_SIZE= 4; From 25bfbf684c0fefe658f6244e1f2cf23dd0246eae Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 23 Jun 2010 19:25:31 +0300 Subject: [PATCH 023/118] Bug #53814: NUMERIC_PRECISION for unsigned bigint field is 19, should be 20 Fixed the numeric precision of the unsigned BIGINT column to be 20 instead of 19. --- mysql-test/r/information_schema.result | 17 +++++++++++++++++ mysql-test/t/information_schema.test | 16 ++++++++++++++++ sql/sql_show.cc | 5 ++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index b7b65598c6d..0da9ed40b9a 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1757,4 +1757,21 @@ WHERE INFORMATION_SCHEMA.COLUMNS.TABLE_NAME = 'variables'; COLUMN_DEFAULT TABLE_NAME NULL variables DROP TABLE variables; +# +# Bug #53814: NUMERIC_PRECISION for unsigned bigint field is 19, +# should be 20 +# +CREATE TABLE ubig (a BIGINT, b BIGINT UNSIGNED); +SELECT TABLE_NAME, COLUMN_NAME, NUMERIC_PRECISION +FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='ubig'; +TABLE_NAME COLUMN_NAME NUMERIC_PRECISION +ubig a 19 +ubig b 20 +INSERT INTO ubig VALUES (0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT length(CAST(b AS CHAR)) FROM ubig; +length(CAST(b AS CHAR)) +20 +DROP TABLE ubig; End of 5.1 tests. diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index fa4b880aead..1fa4d6da600 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1455,6 +1455,22 @@ FROM INFORMATION_SCHEMA.COLUMNS WHERE INFORMATION_SCHEMA.COLUMNS.TABLE_NAME = 'variables'; DROP TABLE variables; +--echo # +--echo # Bug #53814: NUMERIC_PRECISION for unsigned bigint field is 19, +--echo # should be 20 +--echo # + +CREATE TABLE ubig (a BIGINT, b BIGINT UNSIGNED); + +SELECT TABLE_NAME, COLUMN_NAME, NUMERIC_PRECISION + FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='ubig'; + +INSERT INTO ubig VALUES (0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF); +SELECT length(CAST(b AS CHAR)) FROM ubig; + +DROP TABLE ubig; + + --echo End of 5.1 tests. # Wait till all disconnects are completed diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 091bd09aa25..d0e76e501e2 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3965,10 +3965,13 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_LONG: - case MYSQL_TYPE_LONGLONG: case MYSQL_TYPE_INT24: field_length= field->max_display_length() - 1; break; + case MYSQL_TYPE_LONGLONG: + field_length= field->max_display_length() - + ((field->flags & UNSIGNED_FLAG) ? 0 : 1); + break; case MYSQL_TYPE_BIT: field_length= field->max_display_length(); decimals= -1; // return NULL From 0eb26fdfa83d2ddd5f3dc3f8cf6e372a55b4c270 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 2 Jul 2010 15:30:47 -0300 Subject: [PATCH 024/118] Bug#53445: Build with -Wall and fix warnings that it generates Apart strict-aliasing warnings, fix the remaining warnings generated by GCC 4.4.4 -Wall and -Wextra flags. One major source of warnings was the in-house function my_bcmp which (unconventionally) took pointers to unsigned characters as the byte sequences to be compared. Since my_bcmp and bcmp are deprecated functions whose only difference with memcmp is the return value, every use of the function is replaced with memcmp as the special return value wasn't actually being used by any caller. There were also various other warnings, mostly due to type mismatches, missing return values, missing prototypes, dead code (unreachable) and ignored return values. BUILD/SETUP.sh: Remove flags that are implied by -Wall and -Wextra. Do not warn about unused parameters in C++. BUILD/check-cpu: Print only the compiler version instead of verbose banner. Although the option is gcc specific, the check was only being used for GCC specific checks anyway. client/mysql.cc: bcmp is no longer defined. client/mysqltest.cc: Pass a string to function expecting a format string. Replace use of bcmp with memcmp. cmd-line-utils/readline/Makefile.am: Always define _GNU_SOURCE when compiling GNU readline. Required to make certain prototypes visible. cmd-line-utils/readline/input.c: Condition for the code to be meaningful. configure.in: Remove check for bcmp. extra/comp_err.c: Use appropriate type. extra/replace.c: Replace use of bcmp with memcmp. extra/yassl/src/crypto_wrapper.cpp: Do not ignore the return value of fgets. Retrieve the file position if fgets succeed -- if it fails, the function will bail out and return a error. extra/yassl/taocrypt/include/blowfish.hpp: Use a single array instead of accessing positions of the sbox_ through a subscript to pbox_. extra/yassl/taocrypt/include/runtime.hpp: One definition of such functions is enough. extra/yassl/taocrypt/src/aes.cpp: Avoid potentially ambiguous conditions. extra/yassl/taocrypt/src/algebra.cpp: Rename arguments to avoid shadowing related warnings. extra/yassl/taocrypt/src/blowfish.cpp: Avoid potentially ambiguous conditions. extra/yassl/taocrypt/src/integer.cpp: Do not define type within a anonymous union. Use a variable to return a value instead of leaving the result in a register -- compiler does not know the logic inside the asm. extra/yassl/taocrypt/src/misc.cpp: Define handler for pure virtual functions. Remove unused code. extra/yassl/taocrypt/src/twofish.cpp: Avoid potentially ambiguous conditions. extra/yassl/testsuite/test.hpp: Function must have C language linkage. include/m_string.h: Remove check which relied on bcmp being defined -- they weren't being used as bcmp is only visible when _BSD_SOURCE is defined. include/my_bitmap.h: Remove bogus helpers which were used only in a few files and were causing warnings about dead code. include/my_global.h: Due to G++ bug, always silence false-positive uninitialized variables warnings when compiling C++ code with G++. Remove bogus helper. libmysql/Makefile.shared: Remove built-in implementation of bcmp. mysql-test/lib/My/SafeProcess/safe_process.cc: Cast pid to largest possible type for a process identifier. mysys/mf_loadpath.c: Leave space of the ending nul. mysys/mf_pack.c: Replace bcmp with memcmp. mysys/my_bitmap.c: Dead code removal. mysys/my_gethwaddr.c: Remove unused variable. mysys/my_getopt.c: Silence bogus uninitialized variable warning. Do not cast away the constant qualifier. mysys/safemalloc.c: Cast to expected type. mysys/thr_lock.c: Silence bogus uninitialized variable warning. sql/field.cc: Replace bogus helper with a more appropriate logic which is used throughout the code. sql/item.cc: Remove bogus logical condition which always evaluates to TRUE. sql/item_create.cc: Simplify code to avoid signedness related warnings. sql/log_event.cc: Replace use of bcmp with memcmp. No need to use helpers for simple bit operations. sql/log_event_old.cc: Replace bmove_align with memcpy. sql/mysqld.cc: Move use declaration of variable to the ifdef block where it is used. Remove now-unnecessary casts and arguments. sql/set_var.cc: Replace bogus helpers with simple and classic bit operations. sql/slave.cc: Cast to expected type and silence bogus warning. sql/sql_class.h: Don't use enum values as bit flags, the supposed type safety is bogus as the combined bit flags are not a value in the enumeration. sql/udf_example.c: Only declare variable when necessary. sql/unireg.h: Replace use of bmove_align with memcpy. storage/innobase/os/os0file.c: Silence bogus warning. storage/myisam/mi_open.c: Remove bogus cast, DBUG_DUMP expects a pointer to unsigned char. storage/myisam/mi_page.c: Remove bogus cast, DBUG_DUMP expects a pointer to unsigned char. strings/bcmp.c: Remove built-in bcmp. strings/ctype-ucs2.c: Silence bogus warning. tests/mysql_client_test.c: Use a appropriate type as expected by simple_command(). --- BUILD/SETUP.sh | 13 ++-- BUILD/check-cpu | 23 ++++--- client/mysql.cc | 1 - client/mysqltest.cc | 21 +++--- cmd-line-utils/readline/Makefile.am | 2 +- cmd-line-utils/readline/input.c | 2 + configure.in | 2 +- extra/comp_err.c | 6 +- extra/replace.c | 12 ++-- extra/yassl/src/crypto_wrapper.cpp | 5 +- extra/yassl/taocrypt/include/blowfish.hpp | 6 +- extra/yassl/taocrypt/include/runtime.hpp | 16 +---- extra/yassl/taocrypt/src/aes.cpp | 3 +- extra/yassl/taocrypt/src/algebra.cpp | 6 +- extra/yassl/taocrypt/src/blowfish.cpp | 3 +- extra/yassl/taocrypt/src/integer.cpp | 32 +++++---- extra/yassl/taocrypt/src/misc.cpp | 23 ++++--- extra/yassl/taocrypt/src/twofish.cpp | 3 +- extra/yassl/testsuite/test.hpp | 5 ++ include/m_string.h | 21 ------ include/my_bitmap.h | 16 ----- include/my_global.h | 21 ++++-- libmysql/Makefile.shared | 2 +- libmysql/libmysql.c | 1 - mysql-test/lib/My/SafeProcess/safe_process.cc | 2 +- mysys/mf_loadpath.c | 2 +- mysys/mf_pack.c | 12 ++-- mysys/my_bitmap.c | 6 +- mysys/my_gethwaddr.c | 2 +- mysys/my_getopt.c | 14 ++-- mysys/my_handler.c | 1 - mysys/safemalloc.c | 2 +- mysys/thr_lock.c | 3 +- regex/regcomp.c | 1 - sql/field.cc | 8 ++- sql/item.cc | 3 +- sql/item_create.cc | 26 +++----- sql/log.cc | 2 +- sql/log_event.cc | 21 +++--- sql/log_event_old.cc | 6 +- sql/mysqld.cc | 31 +++++---- sql/rpl_rli.cc | 3 +- sql/set_var.cc | 35 +++++----- sql/set_var.h | 2 +- sql/slave.cc | 6 +- sql/sql_base.cc | 6 +- sql/sql_class.h | 15 +++-- sql/sql_repl.cc | 3 +- sql/udf_example.c | 2 + sql/unireg.h | 4 +- storage/heap/hp_hash.c | 4 +- storage/heap/hp_test2.c | 4 +- storage/innobase/os/os0file.c | 3 + storage/myisam/mi_open.c | 2 +- storage/myisam/mi_page.c | 2 +- storage/myisam/mi_search.c | 6 +- storage/myisam/mi_test2.c | 22 +++---- storage/myisam/mi_unique.c | 2 +- storage/myisammrg/ha_myisammrg.cc | 7 +- strings/CMakeLists.txt | 2 +- strings/Makefile.am | 8 +-- strings/bcmp.c | 66 ------------------- strings/ctype-ucs2.c | 6 +- strings/make-ccc | 2 +- strings/str_test.c | 10 +-- strings/xml.c | 8 +-- tests/mysql_client_test.c | 2 +- 67 files changed, 257 insertions(+), 362 deletions(-) delete mode 100644 strings/bcmp.c diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index 626f932e045..08ae4de2e23 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -90,22 +90,19 @@ SSL_LIBRARY=--with-ssl if [ "x$warning_mode" != "xpedantic" ]; then # Both C and C++ warnings - warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W" - warnings="$warnings -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare" - warnings="$warnings -Wwrite-strings -Wunused-function -Wunused-label -Wunused-value -Wunused-variable" + warnings="-Wall -Wextra -Wunused -Wwrite-strings" # For more warnings, uncomment the following line -# warnings="$global_warnings -Wshadow" +# warnings="$warnings -Wshadow" # C warnings - c_warnings="$warnings -Wunused-parameter" + c_warnings="$warnings" # C++ warnings - cxx_warnings="$warnings" + cxx_warnings="$warnings -Wno-unused-parameter" # cxx_warnings="$cxx_warnings -Woverloaded-virtual -Wsign-promo" - cxx_warnings="$cxx_warnings -Wreorder" cxx_warnings="$cxx_warnings -Wctor-dtor-privacy -Wnon-virtual-dtor" # Added unless --with-debug=full - debug_extra_cflags="-O0 -g3 -gdwarf-2" #1 -Wuninitialized" + debug_extra_cflags="-O0 -g3 -gdwarf-2" else warnings="-W -Wall -ansi -pedantic -Wno-long-long -Wno-unused -D_POSIX_SOURCE" c_warnings="$warnings" diff --git a/BUILD/check-cpu b/BUILD/check-cpu index c0e87a675cb..390ba545405 100755 --- a/BUILD/check-cpu +++ b/BUILD/check-cpu @@ -181,14 +181,17 @@ check_cpu () { cc=$CC fi - cc_ver=`$cc --version | sed 1q` - cc_verno=`echo $cc_ver | sed -e 's/^.*(GCC)//g; s/[^0-9. ]//g; s/^ *//g; s/ .*//g'` - set -- `echo $cc_verno | tr '.' ' '` - cc_major=$1 - cc_minor=$2 - cc_patch=$3 - cc_comp=`expr $cc_major '*' 100 '+' $cc_minor` - + # 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 + cc_comp=`expr $cc_major '*' 100 '+' $cc_minor` + fi + case "$cc_ver--$cc_verno" in *GCC*) # different gcc backends (and versions) have different CPU flags @@ -229,7 +232,7 @@ check_cpu () { fi while [ "$cpu_arg" ] ; do printf "testing $cpu_arg ... " >&2 - + # compile check eval "$cc -c $check_cpu_cflags __test.c" 2>/dev/null if test "x$?" = "x0" ; then @@ -243,5 +246,5 @@ check_cpu () { done rm __test.* } - + check_cpu diff --git a/client/mysql.cc b/client/mysql.cc index 14a6ceed51d..edcc72b60bf 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -93,7 +93,6 @@ extern "C" { #endif #endif -#undef bcmp // Fix problem with new readline #if defined(__WIN__) #include #elif !defined(__NETWARE__) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 359de9880e7..6a8d119a7c4 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5780,7 +5780,7 @@ int read_command(struct st_command** command_ptr) (struct st_command*) my_malloc(sizeof(*command), MYF(MY_WME|MY_ZEROFILL))) || insert_dynamic(&q_lines, (uchar*) &command)) - die(NullS); + die("Out of memory"); command->type= Q_UNKNOWN; read_command_buf[0]= 0; @@ -6260,7 +6260,7 @@ void init_win_path_patterns() } if (insert_dynamic(&patterns, (uchar*) &p)) - die(NullS); + die("Out of memory"); DBUG_PRINT("info", ("p: %s", p)); while (*p) @@ -9331,8 +9331,7 @@ REPLACE *init_replace(char * *from, char * *to,uint count, for (i=1 ; i <= found_sets ; i++) { pos=from[found_set[i-1].table_offset]; - rep_str[i].found= !bcmp((const uchar*) pos, - (const uchar*) "\\^", 3) ? 2 : 1; + rep_str[i].found= !memcmp(pos, "\\^", 3) ? 2 : 1; rep_str[i].replace_string=to_array[found_set[i-1].table_offset]; rep_str[i].to_offset=found_set[i-1].found_offset-start_at_word(pos); rep_str[i].from_offset=found_set[i-1].found_offset-replace_len(pos)+ @@ -9460,8 +9459,8 @@ void copy_bits(REP_SET *to,REP_SET *from) int cmp_bits(REP_SET *set1,REP_SET *set2) { - return bcmp((uchar*) set1->bits,(uchar*) set2->bits, - sizeof(uint) * set1->size_of_bits); + return memcmp(set1->bits, set2->bits, + sizeof(uint) * set1->size_of_bits); } @@ -9530,17 +9529,15 @@ int find_found(FOUND_SET *found_set,uint table_offset, int found_offset) uint start_at_word(char * pos) { - return (((!bcmp((const uchar*) pos, (const uchar*) "\\b",2) && pos[2]) || - !bcmp((const uchar*) pos, (const uchar*) "\\^", 2)) ? 1 : 0); + return (((!memcmp(pos, "\\b",2) && pos[2]) || + !memcmp(pos, "\\^", 2)) ? 1 : 0); } uint end_of_word(char * pos) { char * end=strend(pos); - return ((end > pos+2 && !bcmp((const uchar*) end-2, - (const uchar*) "\\b", 2)) || - (end >= pos+2 && !bcmp((const uchar*) end-2, - (const uchar*) "\\$",2))) ? 1 : 0; + return ((end > pos+2 && !memcmp(end-2, "\\b", 2)) || + (end >= pos+2 && !memcmp(end-2, "\\$",2))) ? 1 : 0; } /**************************************************************************** diff --git a/cmd-line-utils/readline/Makefile.am b/cmd-line-utils/readline/Makefile.am index e5f5717858d..e1e9645e238 100644 --- a/cmd-line-utils/readline/Makefile.am +++ b/cmd-line-utils/readline/Makefile.am @@ -31,7 +31,7 @@ noinst_HEADERS = readline.h chardefs.h keymaps.h \ EXTRA_DIST= emacs_keymap.c vi_keymap.c -DEFS = -DMYSQL_CLIENT_NO_THREADS -DHAVE_CONFIG_H -DNO_KILL_INTR +DEFS = -DMYSQL_CLIENT_NO_THREADS -DHAVE_CONFIG_H -DNO_KILL_INTR -D_GNU_SOURCE=1 # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/cmd-line-utils/readline/input.c b/cmd-line-utils/readline/input.c index 84c0422059a..af81d9cd3b0 100644 --- a/cmd-line-utils/readline/input.c +++ b/cmd-line-utils/readline/input.c @@ -318,7 +318,9 @@ _rl_input_available () return (_kbhit ()); #endif +#if !defined (HAVE_SELECT) return 0; +#endif } int diff --git a/configure.in b/configure.in index 74e575fad8c..539d597fd07 100644 --- a/configure.in +++ b/configure.in @@ -2102,7 +2102,7 @@ MYSQL_TYPE_QSORT AC_FUNC_UTIME_NULL AC_FUNC_VPRINTF -AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \ +AC_CHECK_FUNCS(alarm bfill bmove bsearch bzero \ chsize cuserid fchmod fcntl \ fconvert fdatasync fesetround finite fpresetsticky fpsetmask fsync ftruncate \ getcwd gethostbyaddr_r gethostbyname_r getpass getpassphrase getpwnam \ diff --git a/extra/comp_err.c b/extra/comp_err.c index bd03f20a755..c02c7ca3d2a 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -639,9 +639,9 @@ static struct message *find_message(struct errors *err, const char *lang, static ha_checksum checksum_format_specifier(const char* msg) { ha_checksum chksum= 0; - const char* p= msg; - const char* start= 0; - int num_format_specifiers= 0; + const uchar* p= (const uchar*) msg; + const uchar* start= NULL; + uint32 num_format_specifiers= 0; while (*p) { diff --git a/extra/replace.c b/extra/replace.c index 9b7695eddcb..fd2d860c212 100644 --- a/extra/replace.c +++ b/extra/replace.c @@ -648,7 +648,7 @@ static REPLACE *init_replace(char * *from, char * *to,uint count, for (i=1 ; i <= found_sets ; i++) { pos=from[found_set[i-1].table_offset]; - rep_str[i].found= (my_bool) (!bcmp(pos,"\\^",3) ? 2 : 1); + rep_str[i].found= (my_bool) (!memcmp(pos,"\\^",3) ? 2 : 1); rep_str[i].replace_string=to_array[found_set[i-1].table_offset]; rep_str[i].to_offset=found_set[i-1].found_offset-start_at_word(pos); rep_str[i].from_offset=found_set[i-1].found_offset-replace_len(pos)+ @@ -776,8 +776,8 @@ static void copy_bits(REP_SET *to,REP_SET *from) static int cmp_bits(REP_SET *set1,REP_SET *set2) { - return bcmp((uchar*) set1->bits,(uchar*) set2->bits, - sizeof(uint) * set1->size_of_bits); + return memcmp(set1->bits, set2->bits, + sizeof(uint) * set1->size_of_bits); } @@ -849,14 +849,14 @@ static short find_found(FOUND_SET *found_set,uint table_offset, static uint start_at_word(char * pos) { - return (((!bcmp(pos,"\\b",2) && pos[2]) || !bcmp(pos,"\\^",2)) ? 1 : 0); + return (((!memcmp(pos,"\\b",2) && pos[2]) || !memcmp(pos,"\\^",2)) ? 1 : 0); } static uint end_of_word(char * pos) { char * end=strend(pos); - return ((end > pos+2 && !bcmp(end-2,"\\b",2)) || - (end >= pos+2 && !bcmp(end-2,"\\$",2))) ? + return ((end > pos+2 && !memcmp(end-2,"\\b",2)) || + (end >= pos+2 && !memcmp(end-2,"\\$",2))) ? 1 : 0; } diff --git a/extra/yassl/src/crypto_wrapper.cpp b/extra/yassl/src/crypto_wrapper.cpp index 28d7f1b5693..b968ec1e6c3 100644 --- a/extra/yassl/src/crypto_wrapper.cpp +++ b/extra/yassl/src/crypto_wrapper.cpp @@ -953,8 +953,9 @@ x509* PemToDer(FILE* file, CertType type, EncryptedInfo* info) info->set = true; } } - fgets(line,sizeof(line), file); // get blank line - begin = ftell(file); + // get blank line + if (fgets(line, sizeof(line), file)) + begin = ftell(file); } } diff --git a/extra/yassl/taocrypt/include/blowfish.hpp b/extra/yassl/taocrypt/include/blowfish.hpp index 90d2c014b4c..94bbab7aea8 100644 --- a/extra/yassl/taocrypt/include/blowfish.hpp +++ b/extra/yassl/taocrypt/include/blowfish.hpp @@ -51,7 +51,7 @@ public: enum { BLOCK_SIZE = BLOWFISH_BLOCK_SIZE, ROUNDS = 16 }; Blowfish(CipherDir DIR, Mode MODE) - : Mode_BASE(BLOCK_SIZE, DIR, MODE) {} + : Mode_BASE(BLOCK_SIZE, DIR, MODE), sbox_(pbox_ + ROUNDS + 2) {} #ifdef DO_BLOWFISH_ASM void Process(byte*, const byte*, word32); @@ -62,8 +62,8 @@ private: static const word32 p_init_[ROUNDS + 2]; static const word32 s_init_[4 * 256]; - word32 pbox_[ROUNDS + 2]; - word32 sbox_[4 * 256]; + word32 pbox_[ROUNDS + 2 + 4 * 256]; + word32* sbox_; void crypt_block(const word32 in[2], word32 out[2]) const; void AsmProcess(const byte* in, byte* out) const; diff --git a/extra/yassl/taocrypt/include/runtime.hpp b/extra/yassl/taocrypt/include/runtime.hpp index 99bbe3ac8a3..9d12b253dd6 100644 --- a/extra/yassl/taocrypt/include/runtime.hpp +++ b/extra/yassl/taocrypt/include/runtime.hpp @@ -35,10 +35,7 @@ // Handler for pure virtual functions namespace __Crun { - static void pure_error(void) - { - assert("Pure virtual method called." == "Aborted"); - } + void pure_error(void); } // namespace __Crun #endif // __sun @@ -54,16 +51,7 @@ extern "C" { #else #include "kernelc.hpp" #endif - -/* Disallow inline __cxa_pure_virtual() */ -static int __cxa_pure_virtual() __attribute__((noinline, used)); -static int __cxa_pure_virtual() -{ - // oops, pure virtual called! - assert("Pure virtual method called." == "Aborted"); - return 0; -} - + int __cxa_pure_virtual () __attribute__ ((weak)); } // extern "C" #endif // __GNUC__ > 2 diff --git a/extra/yassl/taocrypt/src/aes.cpp b/extra/yassl/taocrypt/src/aes.cpp index b2b42d3dcf0..63eff1d91fc 100644 --- a/extra/yassl/taocrypt/src/aes.cpp +++ b/extra/yassl/taocrypt/src/aes.cpp @@ -51,7 +51,7 @@ void AES::Process(byte* out, const byte* in, word32 sz) out += BLOCK_SIZE; in += BLOCK_SIZE; } - else if (mode_ == CBC) + else if (mode_ == CBC) { if (dir_ == ENCRYPTION) while (blocks--) { r_[0] ^= *(word32*)in; @@ -78,6 +78,7 @@ void AES::Process(byte* out, const byte* in, word32 sz) out += BLOCK_SIZE; in += BLOCK_SIZE; } + } } #endif // DO_AES_ASM diff --git a/extra/yassl/taocrypt/src/algebra.cpp b/extra/yassl/taocrypt/src/algebra.cpp index c221ce3d6cb..47a660d5c96 100644 --- a/extra/yassl/taocrypt/src/algebra.cpp +++ b/extra/yassl/taocrypt/src/algebra.cpp @@ -186,10 +186,10 @@ Integer AbstractGroup::CascadeScalarMultiply(const Element &x, struct WindowSlider { - WindowSlider(const Integer &exp, bool fastNegate, + WindowSlider(const Integer &expIn, bool fastNegateIn, unsigned int windowSizeIn=0) - : exp(exp), windowModulus(Integer::One()), windowSize(windowSizeIn), - windowBegin(0), fastNegate(fastNegate), firstTime(true), + : exp(expIn), windowModulus(Integer::One()), windowSize(windowSizeIn), + windowBegin(0), fastNegate(fastNegateIn), firstTime(true), finished(false) { if (windowSize == 0) diff --git a/extra/yassl/taocrypt/src/blowfish.cpp b/extra/yassl/taocrypt/src/blowfish.cpp index 66ff4d829d7..2097b045278 100644 --- a/extra/yassl/taocrypt/src/blowfish.cpp +++ b/extra/yassl/taocrypt/src/blowfish.cpp @@ -53,7 +53,7 @@ void Blowfish::Process(byte* out, const byte* in, word32 sz) out += BLOCK_SIZE; in += BLOCK_SIZE; } - else if (mode_ == CBC) + else if (mode_ == CBC) { if (dir_ == ENCRYPTION) while (blocks--) { r_[0] ^= *(word32*)in; @@ -78,6 +78,7 @@ void Blowfish::Process(byte* out, const byte* in, word32 sz) out += BLOCK_SIZE; in += BLOCK_SIZE; } + } } #endif // DO_BLOWFISH_ASM diff --git a/extra/yassl/taocrypt/src/integer.cpp b/extra/yassl/taocrypt/src/integer.cpp index 85733b88aa9..b054e98bef4 100644 --- a/extra/yassl/taocrypt/src/integer.cpp +++ b/extra/yassl/taocrypt/src/integer.cpp @@ -283,21 +283,23 @@ DWord() {} word GetHighHalfAsBorrow() const {return 0-halfs_.high;} private: + struct dword_struct + { + #ifdef LITTLE_ENDIAN_ORDER + word low; + word high; + #else + word high; + word low; + #endif + }; + union { #ifdef TAOCRYPT_NATIVE_DWORD_AVAILABLE dword whole_; #endif - struct - { - #ifdef LITTLE_ENDIAN_ORDER - word low; - word high; - #else - word high; - word low; - #endif - } halfs_; + struct dword_struct halfs_; }; }; @@ -1214,20 +1216,24 @@ public: #define AS1(x) #x ";" #define AS2(x, y) #x ", " #y ";" #define AddPrologue \ + word res; \ __asm__ __volatile__ \ ( \ "push %%ebx;" /* save this manually, in case of -fPIC */ \ - "mov %2, %%ebx;" \ + "mov %3, %%ebx;" \ ".intel_syntax noprefix;" \ "push ebp;" #define AddEpilogue \ "pop ebp;" \ ".att_syntax prefix;" \ "pop %%ebx;" \ - : \ + "mov %%eax, %0;" \ + : "=g" (res) \ : "c" (C), "d" (A), "m" (B), "S" (N) \ : "%edi", "memory", "cc" \ - ); + ); \ + return res; + #define MulPrologue \ __asm__ __volatile__ \ ( \ diff --git a/extra/yassl/taocrypt/src/misc.cpp b/extra/yassl/taocrypt/src/misc.cpp index 402645c93fd..11dd4dc6d66 100644 --- a/extra/yassl/taocrypt/src/misc.cpp +++ b/extra/yassl/taocrypt/src/misc.cpp @@ -84,12 +84,23 @@ namespace STL = STL_NAMESPACE; } -#if defined(__ICC) || defined(__INTEL_COMPILER) +#ifdef __sun + +// Handler for pure virtual functions +namespace __Crun { + void pure_error() { + assert(!"Aborted: pure virtual method called."); + } +} + +#endif + +#if defined(__ICC) || defined(__INTEL_COMPILER) || (__GNUC__ > 2) extern "C" { int __cxa_pure_virtual() { - assert("Pure virtual method called." == "Aborted"); + assert(!"Aborted: pure virtual method called."); return 0; } @@ -166,14 +177,6 @@ word Crop(word value, unsigned int size) #ifdef TAOCRYPT_X86ASM_AVAILABLE -#ifndef _MSC_VER - static jmp_buf s_env; - static void SigIllHandler(int) - { - longjmp(s_env, 1); - } -#endif - bool HaveCpuId() { diff --git a/extra/yassl/taocrypt/src/twofish.cpp b/extra/yassl/taocrypt/src/twofish.cpp index 84dd35f9191..71601c08162 100644 --- a/extra/yassl/taocrypt/src/twofish.cpp +++ b/extra/yassl/taocrypt/src/twofish.cpp @@ -54,7 +54,7 @@ void Twofish::Process(byte* out, const byte* in, word32 sz) out += BLOCK_SIZE; in += BLOCK_SIZE; } - else if (mode_ == CBC) + else if (mode_ == CBC) { if (dir_ == ENCRYPTION) while (blocks--) { r_[0] ^= *(word32*)in; @@ -82,6 +82,7 @@ void Twofish::Process(byte* out, const byte* in, word32 sz) out += BLOCK_SIZE; in += BLOCK_SIZE; } + } } #endif // DO_TWOFISH_ASM diff --git a/extra/yassl/testsuite/test.hpp b/extra/yassl/testsuite/test.hpp index c921f8f9c69..970ba5bf367 100644 --- a/extra/yassl/testsuite/test.hpp +++ b/extra/yassl/testsuite/test.hpp @@ -160,6 +160,11 @@ inline void err_sys(const char* msg) } +extern "C" { + static int PasswordCallBack(char*, int, int, void*); +} + + static int PasswordCallBack(char* passwd, int sz, int rw, void* userdata) { strncpy(passwd, "12345678", sz); diff --git a/include/m_string.h b/include/m_string.h index b2a1d9ff2f4..d027047f501 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -33,10 +33,6 @@ /* need by my_vsnprintf */ #include -#ifdef _AIX -#undef HAVE_BCMP -#endif - /* This is needed for the definitions of bzero... on solaris */ #if defined(HAVE_STRINGS_H) #include @@ -60,14 +56,6 @@ /* Unixware 7 */ #if !defined(HAVE_BFILL) # define bfill(A,B,C) memset((A),(C),(B)) -# define bmove_align(A,B,C) memcpy((A),(B),(C)) -#endif - -#if !defined(HAVE_BCMP) -# define bcopy(s, d, n) memcpy((d), (s), (n)) -# define bcmp(A,B,C) memcmp((A),(B),(C)) -# define bzero(A,B) memset((A),0,(B)) -# define bmove_align(A,B,C) memcpy((A),(B),(C)) #endif #if defined(__cplusplus) @@ -120,15 +108,6 @@ extern void bfill(uchar *dst,size_t len,pchar fill); extern void bzero(uchar * dst,size_t len); #endif -#if !defined(bcmp) && !defined(HAVE_BCMP) -extern size_t bcmp(const uchar *s1,const uchar *s2,size_t len); -#endif -#ifdef HAVE_purify -extern size_t my_bcmp(const uchar *s1,const uchar *s2,size_t len); -#undef bcmp -#define bcmp(A,B,C) my_bcmp((A),(B),(C)) -#endif /* HAVE_purify */ - #ifndef bmove512 extern void bmove512(uchar *dst,const uchar *src,size_t len); #endif diff --git a/include/my_bitmap.h b/include/my_bitmap.h index 78642df3362..ab69b2d671d 100644 --- a/include/my_bitmap.h +++ b/include/my_bitmap.h @@ -159,22 +159,6 @@ static inline my_bool bitmap_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2) #define bitmap_set_all(MAP) \ (memset((MAP)->bitmap, 0xFF, 4*no_words_in_map((MAP)))) -/** - check, set and clear a bit of interest of an integer. - - If the bit is out of range @retval -1. Otherwise - bit_is_set @return 0 or 1 reflecting the bit is set or not; - bit_do_set @return 1 (bit is set 1) - bit_do_clear @return 0 (bit is cleared to 0) -*/ - -#define bit_is_set(I,B) (sizeof(I) * CHAR_BIT > (B) ? \ - (((I) & (ULL(1) << (B))) == 0 ? 0 : 1) : -1) -#define bit_do_set(I,B) (sizeof(I) * CHAR_BIT > (B) ? \ - ((I) |= (ULL(1) << (B)), 1) : -1) -#define bit_do_clear(I,B) (sizeof(I) * CHAR_BIT > (B) ? \ - ((I) &= ~(ULL(1) << (B)), 0) : -1) - #ifdef __cplusplus } #endif diff --git a/include/my_global.h b/include/my_global.h index e13c7c37b62..572df6a584d 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -556,22 +556,30 @@ int __void__; #endif #endif /* DONT_DEFINE_VOID */ -#if defined(_lint) || defined(FORCE_INIT_OF_VARS) -#define LINT_INIT(var) var=0 /* No uninitialize-warning */ +/* + Deprecated workaround for false-positive uninitialized variables + warnings. Those should be silenced using tool-specific heuristics. + + Enabled by default for g++ due to the bug referenced below. +*/ +#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || \ + (defined(__GNUC__) && defined(__cplusplus)) +#define LINT_INIT(var) var= 0 #else #define LINT_INIT(var) #endif -/* +/* Suppress uninitialized variable warning without generating code. The _cplusplus is a temporary workaround for C++ code pending a fix - for a g++ bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772). + for a g++ bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772). */ -#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || defined(__cplusplus) || \ - !defined(__GNUC__) +#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || \ + defined(__cplusplus) || !defined(__GNUC__) #define UNINIT_VAR(x) x= 0 #else +/* GCC specific self-initialization which inhibits the warning. */ #define UNINIT_VAR(x) x= x #endif @@ -595,7 +603,6 @@ typedef unsigned short ushort; #define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0) #define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0) #define test_all_bits(a,b) (((a) & (b)) == (b)) -#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1)) #define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0]))) /* Define some general constants */ diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared index 3e93b7daf84..39c1975888a 100644 --- a/libmysql/Makefile.shared +++ b/libmysql/Makefile.shared @@ -38,7 +38,7 @@ mystringsobjects = strmov.lo strxmov.lo strxnmov.lo strnmov.lo \ strmake.lo strend.lo strtod.lo \ strnlen.lo strfill.lo is_prefix.lo \ int2str.lo str2int.lo strinstr.lo strcont.lo \ - strcend.lo bcmp.lo ctype-latin1.lo \ + strcend.lo ctype-latin1.lo \ bchange.lo bmove.lo bmove_upp.lo longlong2str.lo \ strtoull.lo strtoll.lo llstr.lo my_vsnprintf.lo \ ctype.lo ctype-simple.lo ctype-bin.lo ctype-mb.lo \ diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 21cbfaf6dbb..e0cc119bd16 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -4425,7 +4425,6 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field) field->max_length= 10; /* 2003-11-11 */ param->skip_result= skip_result_with_length; break; - break; case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_TIMESTAMP: param->skip_result= skip_result_with_length; diff --git a/mysql-test/lib/My/SafeProcess/safe_process.cc b/mysql-test/lib/My/SafeProcess/safe_process.cc index 50c433b9b39..1c778362975 100644 --- a/mysql-test/lib/My/SafeProcess/safe_process.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process.cc @@ -159,7 +159,7 @@ int main(int argc, char* const argv[] ) signal(SIGCHLD, handle_signal); signal(SIGABRT, handle_abort); - sprintf(safe_process_name, "safe_process[%d]", own_pid); + sprintf(safe_process_name, "safe_process[%ld]", (long) own_pid); message("Started"); diff --git a/mysys/mf_loadpath.c b/mysys/mf_loadpath.c index 1df613a1733..b329d103d94 100644 --- a/mysys/mf_loadpath.c +++ b/mysys/mf_loadpath.c @@ -42,7 +42,7 @@ char * my_load_path(char * to, const char *path, if (is_cur) is_cur=2; /* Remove current dir */ if (! my_getwd(buff,(uint) (FN_REFLEN-strlen(path)+is_cur),MYF(0))) - VOID(strncat(buff, path+is_cur, FN_REFLEN)); + VOID(strncat(buff, path+is_cur, FN_REFLEN-1)); else VOID(strnmov(buff, path, FN_REFLEN)); /* Return org file name */ } diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c index 4f7cd90e8aa..86fd61537e7 100644 --- a/mysys/mf_pack.c +++ b/mysys/mf_pack.c @@ -52,7 +52,7 @@ void pack_dirname(char * to, const char *from) buff_length= strlen(buff); d_length= (size_t) (start-to); if ((start == to || - (buff_length == d_length && !bcmp(buff,start,d_length))) && + (buff_length == d_length && !memcmp(buff,start,d_length))) && *start != FN_LIBCHAR && *start) { /* Put current dir before */ bchange((uchar*) to, d_length, (uchar*) buff, buff_length, strlen(to)+1); @@ -70,7 +70,7 @@ void pack_dirname(char * to, const char *from) } if (length > 1 && length < d_length) { /* test if /xx/yy -> ~/yy */ - if (bcmp(to,home_dir,length) == 0 && to[length] == FN_LIBCHAR) + if (memcmp(to,home_dir,length) == 0 && to[length] == FN_LIBCHAR) { to[0]=FN_HOMELIB; /* Filename begins with ~ */ (void) strmov_overlapp(to+1,to+length); @@ -80,7 +80,7 @@ void pack_dirname(char * to, const char *from) { /* Test if cwd is ~/... */ if (length > 1 && length < buff_length) { - if (bcmp(buff,home_dir,length) == 0 && buff[length] == FN_LIBCHAR) + if (memcmp(buff,home_dir,length) == 0 && buff[length] == FN_LIBCHAR) { buff[0]=FN_HOMELIB; (void) strmov_overlapp(buff+1,buff+length); @@ -166,7 +166,7 @@ size_t cleanup_dirname(register char *to, const char *from) *pos = FN_LIBCHAR; if (*pos == FN_LIBCHAR) { - if ((size_t) (pos-start) > length && bcmp(pos-length,parent,length) == 0) + if ((size_t) (pos-start) > length && memcmp(pos-length,parent,length) == 0) { /* If .../../; skip prev */ pos-=length; if (pos != start) @@ -197,7 +197,7 @@ size_t cleanup_dirname(register char *to, const char *from) end_parentdir=pos; while (pos >= start && *pos != FN_LIBCHAR) /* remove prev dir */ pos--; - if (pos[1] == FN_HOMELIB || bcmp(pos,parent,length) == 0) + if (pos[1] == FN_HOMELIB || memcmp(pos,parent,length) == 0) { /* Don't remove ~user/ */ pos=strmov(end_parentdir+1,parent); *pos=FN_LIBCHAR; @@ -206,7 +206,7 @@ size_t cleanup_dirname(register char *to, const char *from) } } else if ((size_t) (pos-start) == length-1 && - !bcmp(start,parent+1,length-1)) + !memcmp(start,parent+1,length-1)) start=pos; /* Starts with "../" */ else if (pos-start > 0 && pos[-1] == FN_LIBCHAR) { diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c index e127b2584ae..b7258080337 100644 --- a/mysys/my_bitmap.c +++ b/mysys/my_bitmap.c @@ -508,10 +508,8 @@ uint bitmap_get_first_set(const MY_BITMAP *map) if (*byte_ptr & (1 << k)) return (i*32) + (j*8) + k; } - DBUG_ASSERT(0); } } - DBUG_ASSERT(0); } } return MY_BIT_NONE; @@ -534,7 +532,7 @@ uint bitmap_get_first(const MY_BITMAP *map) { byte_ptr= (uchar*)data_ptr; for (j=0; ; j++, byte_ptr++) - { + { if (*byte_ptr != 0xFF) { for (k=0; ; k++) @@ -542,10 +540,8 @@ uint bitmap_get_first(const MY_BITMAP *map) if (!(*byte_ptr & (1 << k))) return (i*32) + (j*8) + k; } - DBUG_ASSERT(0); } } - DBUG_ASSERT(0); } } return MY_BIT_NONE; diff --git a/mysys/my_gethwaddr.c b/mysys/my_gethwaddr.c index c7f138c7337..00e0e90f1e4 100644 --- a/mysys/my_gethwaddr.c +++ b/mysys/my_gethwaddr.c @@ -47,7 +47,7 @@ my_bool my_gethwaddr(uchar *to) uchar *buf, *next, *end, *addr; struct if_msghdr *ifm; struct sockaddr_dl *sdl; - int i, res=1, mib[6]={CTL_NET, AF_ROUTE, 0, AF_LINK, NET_RT_IFLIST, 0}; + int res=1, mib[6]={CTL_NET, AF_ROUTE, 0, AF_LINK, NET_RT_IFLIST, 0}; if (sysctl(mib, 6, NULL, &len, NULL, 0) == -1) goto err; diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 26b1cc75af0..b0e7175d0b9 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -30,7 +30,7 @@ my_error_reporter my_getopt_error_reporter= &default_reporter; static int findopt(char *optpat, uint length, const struct my_option **opt_res, - char **ffname); + const char **ffname); my_bool getopt_compare_strings(const char *s, const char *t, uint length); @@ -115,8 +115,8 @@ int handle_options(int *argc, char ***argv, uint 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, *UNINIT_VAR(prev_found), - *opt_str, key_name[FN_REFLEN]; + char **pos, **pos_end, *optend, *opt_str, key_name[FN_REFLEN]; + const char *UNINIT_VAR(prev_found); const struct my_option *optp; void *value; int error, i; @@ -225,7 +225,6 @@ int handle_options(int *argc, char ***argv, Find first the right option. Return error in case of an ambiguous, or unknown option */ - LINT_INIT(prev_found); optp= longopts; if (!(opt_found= findopt(opt_str, length, &optp, &prev_found))) { @@ -709,10 +708,10 @@ static int setval(const struct my_option *opts, void *value, char *argument, static int findopt(char *optpat, uint length, const struct my_option **opt_res, - char **ffname) + const char **ffname) { uint count; - struct my_option *opt= (struct my_option *) *opt_res; + const struct my_option *opt= *opt_res; for (count= 0; opt->name; opt++) { @@ -723,8 +722,9 @@ static int findopt(char *optpat, uint length, return 1; if (!count) { + /* We only need to know one prev */ count= 1; - *ffname= (char *) opt->name; /* We only need to know one prev */ + *ffname= opt->name; } else if (strcmp(*ffname, opt->name)) { diff --git a/mysys/my_handler.c b/mysys/my_handler.c index 3bc27b622cb..7aa8177040d 100644 --- a/mysys/my_handler.c +++ b/mysys/my_handler.c @@ -269,7 +269,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); a+=a_length; b+=b_length; - break; } break; case HA_KEYTYPE_INT8: diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c index 2c72026ab5a..76faa33e804 100644 --- a/mysys/safemalloc.c +++ b/mysys/safemalloc.c @@ -163,7 +163,7 @@ void *_mymalloc(size_t size, const char *filename, uint lineno, myf MyFlags) my_message(EE_OUTOFMEMORY, buff, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH)); } DBUG_PRINT("error",("Out of memory, in use: %ld at line %d, '%s'", - sf_malloc_max_memory,lineno, filename)); + (ulong) sf_malloc_max_memory, lineno, filename)); DBUG_EXECUTE_IF("simulate_out_of_memory", DBUG_SET("-d,simulate_out_of_memory");); if (MyFlags & MY_FAE) diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index 0e0e93cf220..b925c5588be 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -125,8 +125,7 @@ static int check_lock(struct st_lock_list *list, const char* lock_type, { THR_LOCK_DATA *data,**prev; uint count=0; - THR_LOCK_OWNER *first_owner; - LINT_INIT(first_owner); + THR_LOCK_OWNER *UNINIT_VAR(first_owner); prev= &list->data; if (list->data) diff --git a/regex/regcomp.c b/regex/regcomp.c index b203d4941e1..8280fbfd6c8 100644 --- a/regex/regcomp.c +++ b/regex/regcomp.c @@ -690,7 +690,6 @@ register cset *cs; case '-': SETERROR(REG_ERANGE); return; /* NOTE RETURN */ - break; default: c = '\0'; break; diff --git a/sql/field.cc b/sql/field.cc index 7360a013ffb..2229bc19b3c 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -8691,7 +8691,13 @@ int Field_set::store(longlong nr, bool unsigned_val) { ASSERT_COLUMN_MARKED_FOR_WRITE; int error= 0; - ulonglong max_nr= set_bits(ulonglong, typelib->count); + ulonglong max_nr; + + if (sizeof(ulonglong)*8 <= typelib->count) + max_nr= ULONGLONG_MAX; + else + max_nr= (ULL(1) << typelib->count) - 1; + if ((ulonglong) nr > max_nr) { nr&= max_nr; diff --git a/sql/item.cc b/sql/item.cc index 5f0ca4374df..db2c4c0974b 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4130,8 +4130,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) context->first_name_resolution_table, context->last_name_resolution_table, reference, REPORT_ALL_ERRORS, - !any_privileges && - TRUE, TRUE); + !any_privileges, TRUE); } return -1; } diff --git a/sql/item_create.cc b/sql/item_create.cc index fd8f13d6dc5..5726e987ef6 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -5051,8 +5051,6 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, CHARSET_INFO *cs) { Item *UNINIT_VAR(res); - ulong len; - uint dec; switch (cast_type) { case ITEM_CAST_BINARY: @@ -5075,11 +5073,10 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, break; case ITEM_CAST_DECIMAL: { - if (c_len == NULL) - { - len= 0; - } - else + ulong len= 0; + uint dec= 0; + + if (c_len) { ulong decoded_size; errno= 0; @@ -5093,11 +5090,7 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, len= decoded_size; } - if (c_dec == NULL) - { - dec= 0; - } - else + if (c_dec) { ulong decoded_size; errno= 0; @@ -5133,12 +5126,9 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, } case ITEM_CAST_CHAR: { + int len= -1; CHARSET_INFO *real_cs= (cs ? cs : thd->variables.collation_connection); - if (c_len == NULL) - { - len= LL(-1); - } - else + if (c_len) { ulong decoded_size; errno= 0; @@ -5148,7 +5138,7 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), "cast as char", MAX_FIELD_BLOBLENGTH); return NULL; } - len= decoded_size; + len= (int) decoded_size; } res= new (thd->mem_root) Item_char_typecast(a, len, real_cs); break; diff --git a/sql/log.cc b/sql/log.cc index b3554d2a068..d8d5f6fa418 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1862,7 +1862,7 @@ static int find_uniq_filename(char *name) file_info= dir_info->dir_entry; for (i=dir_info->number_off_files ; i-- ; file_info++) { - if (bcmp((uchar*) file_info->name, (uchar*) start, length) == 0 && + if (memcmp(file_info->name, start, length) == 0 && test_if_number(file_info->name+length, &number,0)) { set_if_bigger(max_found,(ulong) number); diff --git a/sql/log_event.cc b/sql/log_event.cc index 5ff4b50c6df..d53f13e0b6b 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2905,7 +2905,7 @@ void Query_log_event::print_query_header(IO_CACHE* file, if (likely(charset_inited) && (unlikely(!print_event_info->charset_inited || - bcmp((uchar*) print_event_info->charset, (uchar*) charset, 6)))) + memcmp(print_event_info->charset, charset, 6)))) { CHARSET_INFO *cs_info= get_charset(uint2korr(charset), MYF(MY_WME)); if (cs_info) @@ -2928,8 +2928,8 @@ void Query_log_event::print_query_header(IO_CACHE* file, } if (time_zone_len) { - if (bcmp((uchar*) print_event_info->time_zone_str, - (uchar*) time_zone_str, time_zone_len+1)) + if (memcmp(print_event_info->time_zone_str, + time_zone_str, time_zone_len+1)) { my_b_printf(file,"SET @@session.time_zone='%s'%s\n", time_zone_str, print_event_info->delimiter); @@ -7503,8 +7503,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) { int actual_error= convert_handler_error(error, thd, table); bool idempotent_error= (idempotent_error_code(error) && - ((bit_is_set(slave_exec_mode, - SLAVE_EXEC_MODE_IDEMPOTENT)) == 1)); + (slave_exec_mode & SLAVE_EXEC_MODE_IDEMPOTENT)); bool ignored_error= (idempotent_error == 0 ? ignored_error_code(actual_error) : 0); @@ -8332,7 +8331,7 @@ Write_rows_log_event::do_before_row_operations(const Slave_reporting_capability todo: to introduce a property for the event (handler?) which forces applying the event in the replace (idempotent) fashion. */ - if (bit_is_set(slave_exec_mode, SLAVE_EXEC_MODE_IDEMPOTENT) == 1 || + if ((slave_exec_mode & SLAVE_EXEC_MODE_IDEMPOTENT) || m_table->s->db_type()->db_type == DB_TYPE_NDBCLUSTER) { /* @@ -8411,7 +8410,7 @@ Write_rows_log_event::do_after_row_operations(const Slave_reporting_capability * int local_error= 0; m_table->next_number_field=0; m_table->auto_increment_field_not_null= FALSE; - if (bit_is_set(slave_exec_mode, SLAVE_EXEC_MODE_IDEMPOTENT) == 1 || + if ((slave_exec_mode & SLAVE_EXEC_MODE_IDEMPOTENT) || m_table->s->db_type()->db_type == DB_TYPE_NDBCLUSTER) { m_table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); @@ -8514,7 +8513,7 @@ Rows_log_event::write_row(const Relay_log_info *const rli, TABLE *table= m_table; // pointer to event's table int error; - int keynum; + int UNINIT_VAR(keynum); auto_afree_ptr key(NULL); /* fill table->record[0] with default values */ @@ -8712,10 +8711,8 @@ int Write_rows_log_event::do_exec_row(const Relay_log_info *const rli) { DBUG_ASSERT(m_table != NULL); - int error= - write_row(rli, /* if 1 then overwrite */ - bit_is_set(slave_exec_mode, SLAVE_EXEC_MODE_IDEMPOTENT) == 1); - + int error= write_row(rli, (slave_exec_mode & SLAVE_EXEC_MODE_IDEMPOTENT)); + if (error && !thd->is_error()) { DBUG_ASSERT(0); diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index 202b81989a8..e901f44286c 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -441,7 +441,7 @@ copy_extra_record_fields(TABLE *table, DBUG_ASSERT(master_reclength <= table->s->reclength); if (master_reclength < table->s->reclength) - bmove_align(table->record[0] + master_reclength, + memcpy(table->record[0] + master_reclength, table->record[1] + master_reclength, table->s->reclength - master_reclength); @@ -720,7 +720,7 @@ static int find_and_fetch_row(TABLE *table, uchar *key) rnd_pos() returns the record in table->record[0], so we have to move it to table->record[1]. */ - bmove_align(table->record[1], table->record[0], table->s->reclength); + memcpy(table->record[1], table->record[0], table->s->reclength); DBUG_RETURN(error); } @@ -1213,7 +1213,7 @@ int Update_rows_log_event_old::do_exec_row(TABLE *table) overwriting the default values that where put there by the unpack_row() function. */ - bmove_align(table->record[0], m_after_image, table->s->reclength); + memcpy(table->record[0], m_after_image, table->s->reclength); copy_extra_record_fields(table, m_master_reclength, m_width); /* diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 5514c356bd1..99f16b36dfa 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -559,7 +559,7 @@ ulong query_buff_size, slow_launch_time, slave_open_temp_tables; ulong open_files_limit, max_binlog_size, max_relay_log_size; ulong slave_net_timeout, slave_trans_retries; ulong slave_exec_mode_options; -const char *slave_exec_mode_str= "STRICT"; +static const char *slave_exec_mode_str= "STRICT"; ulong thread_cache_size=0, thread_pool_size= 0; ulong binlog_cache_size=0; ulonglong max_binlog_cache_size=0; @@ -2464,7 +2464,6 @@ extern "C" sig_handler handle_segfault(int sig) { time_t curr_time; struct tm tm; - THD *thd=current_thd; /* Strictly speaking, one needs a mutex here @@ -2523,13 +2522,15 @@ the thread stack. Please read http://dev.mysql.com/doc/mysql/en/linux.html\n\n", #endif /* HAVE_LINUXTHREADS */ #ifdef HAVE_STACKTRACE + THD *thd=current_thd; + if (!(test_flags & TEST_NO_STACKTRACE)) { - fprintf(stderr,"thd: 0x%lx\n",(long) thd); - fprintf(stderr,"\ -Attempting backtrace. You can use the following information to find out\n\ -where mysqld died. If you see no messages after this, something went\n\ -terribly wrong...\n"); + fprintf(stderr, "thd: 0x%lx\n",(long) thd); + fprintf(stderr, "Attempting backtrace. You can use the following " + "information to find out\nwhere mysqld died. If " + "you see no messages after this, something went\n" + "terribly wrong...\n"); my_print_stacktrace(thd ? (uchar*) thd->thread_stack : NULL, my_thread_stack_size); } @@ -7879,10 +7880,11 @@ static int mysql_init_variables(void) /* Things with default values that are not zero */ delay_key_write_options= (uint) DELAY_KEY_WRITE_ON; - slave_exec_mode_options= 0; - slave_exec_mode_options= (uint) - find_bit_type_or_exit(slave_exec_mode_str, &slave_exec_mode_typelib, NULL, - &error); + slave_exec_mode_options= find_bit_type_or_exit(slave_exec_mode_str, + &slave_exec_mode_typelib, + NULL, &error); + /* Default mode string must not yield a error. */ + DBUG_ASSERT(!error); if (error) return 1; opt_specialflag= SPECIAL_ENGLISH; @@ -8118,8 +8120,9 @@ mysqld_get_one_option(int optid, init_slave_skip_errors(argument); break; case OPT_SLAVE_EXEC_MODE: - slave_exec_mode_options= (uint) - find_bit_type_or_exit(argument, &slave_exec_mode_typelib, "", &error); + slave_exec_mode_options= find_bit_type_or_exit(argument, + &slave_exec_mode_typelib, + "", &error); if (error) return 1; break; @@ -8773,7 +8776,7 @@ static int get_options(int *argc,char **argv) /* Set global MyISAM variables from delay_key_write_options */ fix_delay_key_write((THD*) 0, OPT_GLOBAL); /* Set global slave_exec_mode from its option */ - fix_slave_exec_mode(OPT_GLOBAL); + fix_slave_exec_mode(); #ifndef EMBEDDED_LIBRARY if (mysqld_chroot) diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 316e26f7e40..99a42bbe818 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -1120,8 +1120,7 @@ bool Relay_log_info::cached_charset_compare(char *charset) const { DBUG_ENTER("Relay_log_info::cached_charset_compare"); - if (bcmp((uchar*) cached_charset, (uchar*) charset, - sizeof(cached_charset))) + if (memcmp(cached_charset, charset, sizeof(cached_charset))) { memcpy(const_cast(cached_charset), charset, sizeof(cached_charset)); DBUG_RETURN(1); diff --git a/sql/set_var.cc b/sql/set_var.cc index 241126e1e6f..c5517da92f8 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -92,14 +92,13 @@ TYPELIB delay_key_write_typelib= delay_key_write_type_names, NULL }; -const char *slave_exec_mode_names[]= -{ "STRICT", "IDEMPOTENT", NullS }; -static const unsigned int slave_exec_mode_names_len[]= -{ sizeof("STRICT") - 1, sizeof("IDEMPOTENT") - 1, 0 }; +static const char *slave_exec_mode_names[]= { "STRICT", "IDEMPOTENT", NullS }; +static unsigned int slave_exec_mode_names_len[]= { sizeof("STRICT") - 1, + sizeof("IDEMPOTENT") - 1, 0 }; TYPELIB slave_exec_mode_typelib= { array_elements(slave_exec_mode_names)-1, "", - slave_exec_mode_names, (unsigned int *) slave_exec_mode_names_len + slave_exec_mode_names, slave_exec_mode_names_len }; static int sys_check_ftb_syntax(THD *thd, set_var *var); @@ -1215,16 +1214,14 @@ uchar *sys_var_set::value_ptr(THD *thd, enum_var_type type, void sys_var_set_slave_mode::set_default(THD *thd, enum_var_type type) { - slave_exec_mode_options= 0; - bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT); + slave_exec_mode_options= SLAVE_EXEC_MODE_STRICT; } bool sys_var_set_slave_mode::check(THD *thd, set_var *var) { bool rc= sys_var_set::check(thd, var); - if (!rc && - bit_is_set(var->save_result.ulong_value, SLAVE_EXEC_MODE_STRICT) == 1 && - bit_is_set(var->save_result.ulong_value, SLAVE_EXEC_MODE_IDEMPOTENT) == 1) + if (!rc && (var->save_result.ulong_value & SLAVE_EXEC_MODE_STRICT) && + (var->save_result.ulong_value & SLAVE_EXEC_MODE_IDEMPOTENT)) { rc= true; my_error(ER_SLAVE_AMBIGOUS_EXEC_MODE, MYF(0), ""); @@ -1241,20 +1238,18 @@ bool sys_var_set_slave_mode::update(THD *thd, set_var *var) return rc; } -void fix_slave_exec_mode(enum_var_type type) +void fix_slave_exec_mode(void) { DBUG_ENTER("fix_slave_exec_mode"); - compile_time_assert(sizeof(slave_exec_mode_options) * CHAR_BIT - > SLAVE_EXEC_MODE_LAST_BIT - 1); - if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 && - bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 1) + + if ((slave_exec_mode_options & SLAVE_EXEC_MODE_STRICT) && + (slave_exec_mode_options & SLAVE_EXEC_MODE_IDEMPOTENT)) { - sql_print_error("Ambiguous slave modes combination." - " STRICT will be used"); - bit_do_clear(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT); + sql_print_error("Ambiguous slave modes combination. STRICT will be used"); + slave_exec_mode_options&= ~SLAVE_EXEC_MODE_IDEMPOTENT; } - if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 0) - bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT); + if (!(slave_exec_mode_options & SLAVE_EXEC_MODE_IDEMPOTENT)) + slave_exec_mode_options|= SLAVE_EXEC_MODE_STRICT; DBUG_VOID_RETURN; } diff --git a/sql/set_var.h b/sql/set_var.h index bc94c6b85c4..68cd94a5670 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -1446,7 +1446,7 @@ sys_var *find_sys_var(THD *thd, const char *str, uint length=0); int sql_set_variables(THD *thd, List *var_list); bool not_all_support_one_shot(List *var_list); void fix_delay_key_write(THD *thd, enum_var_type type); -void fix_slave_exec_mode(enum_var_type type); +void fix_slave_exec_mode(void); ulong fix_sql_mode(ulong sql_mode); extern sys_var_const_str sys_charset_system; extern sys_var_str sys_init_connect; diff --git a/sql/slave.cc b/sql/slave.cc index af53bc65c0e..795bc481071 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2113,7 +2113,7 @@ int apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli) DBUG_PRINT("info", ("thd->options: %s%s; rli->last_event_start_time: %lu", FLAGSTR(thd->options, OPTION_NOT_AUTOCOMMIT), FLAGSTR(thd->options, OPTION_BEGIN), - rli->last_event_start_time)); + (ulong) rli->last_event_start_time)); /* Execute the event to change the database and update the binary @@ -2885,8 +2885,8 @@ pthread_handler_t handle_slave_sql(void *arg) char llbuff[22],llbuff1[22]; char saved_log_name[FN_REFLEN]; char saved_master_log_name[FN_REFLEN]; - my_off_t saved_log_pos; - my_off_t saved_master_log_pos; + my_off_t UNINIT_VAR(saved_log_pos); + my_off_t UNINIT_VAR(saved_master_log_pos); my_off_t saved_skip= 0; Relay_log_info* rli = &((Master_info*)arg)->rli; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 3a51b5c5610..d2392bdd9b1 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8403,15 +8403,15 @@ my_bool mysql_rm_tmp_tables(void) (file->name[1] == '.' && !file->name[2]))) continue; - if (!bcmp((uchar*) file->name, (uchar*) tmp_file_prefix, - tmp_file_prefix_length)) + if (!memcmp(file->name, tmp_file_prefix, + tmp_file_prefix_length)) { char *ext= fn_ext(file->name); uint ext_len= strlen(ext); uint filePath_len= my_snprintf(filePath, sizeof(filePath), "%s%c%s", tmpdir, FN_LIBCHAR, file->name); - if (!bcmp((uchar*) reg_ext, (uchar*) ext, ext_len)) + if (!memcmp(reg_ext, ext, ext_len)) { handler *handler_file= 0; /* We should cut file extention before deleting of table */ diff --git a/sql/sql_class.h b/sql/sql_class.h index 4c1d4a98db0..023367cb747 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -83,9 +83,10 @@ enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY, RNEXT_SAME }; enum enum_duplicates { DUP_ERROR, DUP_REPLACE, DUP_UPDATE }; enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON, DELAY_KEY_WRITE_ALL }; -enum enum_slave_exec_mode { SLAVE_EXEC_MODE_STRICT, - SLAVE_EXEC_MODE_IDEMPOTENT, - SLAVE_EXEC_MODE_LAST_BIT}; + +#define SLAVE_EXEC_MODE_STRICT (1U << 0) +#define SLAVE_EXEC_MODE_IDEMPOTENT (1U << 1) + enum enum_mark_columns { MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE}; @@ -2418,7 +2419,7 @@ class select_result :public Sql_alloc { protected: THD *thd; SELECT_LEX_UNIT *unit; - uint nest_level; + int nest_level; public: select_result(); virtual ~select_result() {}; @@ -2559,7 +2560,7 @@ public: Creates a select_export to represent INTO OUTFILE with a defined level of subquery nesting. */ - select_export(sql_exchange *ex, uint nest_level_arg) :select_to_file(ex) + select_export(sql_exchange *ex, int nest_level_arg) :select_to_file(ex) { nest_level= nest_level_arg; } @@ -2576,7 +2577,7 @@ public: Creates a select_export to represent INTO DUMPFILE with a defined level of subquery nesting. */ - select_dump(sql_exchange *ex, uint nest_level_arg) : + select_dump(sql_exchange *ex, int nest_level_arg) : select_to_file(ex) { nest_level= nest_level_arg; @@ -3046,7 +3047,7 @@ public: Creates a select_dumpvar to represent INTO with a defined level of subquery nesting. */ - select_dumpvar(uint nest_level_arg) + select_dumpvar(int nest_level_arg) { var_list.empty(); row_count= 0; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 75a738a0073..f6045e4704e 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -218,8 +218,7 @@ bool log_in_use(const char* log_name) if ((linfo = tmp->current_linfo)) { pthread_mutex_lock(&linfo->lock); - result = !bcmp((uchar*) log_name, (uchar*) linfo->log_file_name, - log_name_len); + result = !memcmp(log_name, linfo->log_file_name, log_name_len); pthread_mutex_unlock(&linfo->lock); if (result) break; diff --git a/sql/udf_example.c b/sql/udf_example.c index 82af58ec502..637293209e0 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -141,7 +141,9 @@ typedef long long longlong; #ifdef HAVE_DLOPEN +#if !defined(HAVE_GETHOSTBYADDR_R) || !defined(HAVE_SOLARIS_STYLE_GETHOST) static pthread_mutex_t LOCK_hostname; +#endif /* These must be right or mysqld will not find the symbol! */ diff --git a/sql/unireg.h b/sql/unireg.h index 3ff7f058e3c..4f6b647964d 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -129,8 +129,8 @@ #define SPECIAL_LOG_QUERIES_NOT_USING_INDEXES 4096 /* Obsolete */ /* Extern defines */ -#define store_record(A,B) bmove_align((A)->B,(A)->record[0],(size_t) (A)->s->reclength) -#define restore_record(A,B) bmove_align((A)->record[0],(A)->B,(size_t) (A)->s->reclength) +#define store_record(A,B) memcpy((A)->B,(A)->record[0],(size_t) (A)->s->reclength) +#define restore_record(A,B) memcpy((A)->record[0],(A)->B,(size_t) (A)->s->reclength) #define cmp_record(A,B) memcmp((A)->record[0],(A)->B,(size_t) (A)->s->reclength) #define empty_record(A) { \ restore_record((A),s->default_values); \ diff --git a/storage/heap/hp_hash.c b/storage/heap/hp_hash.c index aaaa0fe833f..f56df42aab3 100644 --- a/storage/heap/hp_hash.c +++ b/storage/heap/hp_hash.c @@ -577,7 +577,7 @@ int hp_rec_key_cmp(HP_KEYDEF *keydef, const uchar *rec1, const uchar *rec2, } else { - if (bcmp(rec1+seg->start,rec2+seg->start,seg->length)) + if (memcmp(rec1+seg->start,rec2+seg->start,seg->length)) return 1; } } @@ -660,7 +660,7 @@ int hp_key_cmp(HP_KEYDEF *keydef, const uchar *rec, const uchar *key) } else { - if (bcmp(rec+seg->start,key,seg->length)) + if (memcmp(rec+seg->start,key,seg->length)) return 1; } } diff --git a/storage/heap/hp_test2.c b/storage/heap/hp_test2.c index 5c548b6be74..bf06cf03035 100644 --- a/storage/heap/hp_test2.c +++ b/storage/heap/hp_test2.c @@ -406,7 +406,7 @@ int main(int argc, char *argv[]) bmove(record2,record,reclength); if (heap_rsame(file,record,-1) || heap_rsame(file,record2,2)) goto err; - if (bcmp(record2,record,reclength)) + if (memcmp(record2,record,reclength)) { puts("heap_rsame didn't find right record"); goto end; @@ -415,7 +415,7 @@ int main(int argc, char *argv[]) puts("- Test of read through position"); if (heap_rrnd(file,record,position)) goto err; - if (bcmp(record3,record,reclength)) + if (memcmp(record3,record,reclength)) { puts("heap_frnd didn't find right record"); goto end; diff --git a/storage/innobase/os/os0file.c b/storage/innobase/os/os0file.c index 7373a97cfb0..3396d1adf2f 100644 --- a/storage/innobase/os/os0file.c +++ b/storage/innobase/os/os0file.c @@ -3974,6 +3974,9 @@ os_aio_simulated_handle( ulint n; ulint i; + /* Fix compiler warning */ + *consecutive_ios = NULL; + segment = os_aio_get_array_and_local_segment(&array, global_segment); restart: diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index f2f390862bd..8ecb07d75e8 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -139,7 +139,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) (uchar*) myisam_file_magic, 4)) { DBUG_PRINT("error",("Wrong header in %s",name_buff)); - DBUG_DUMP("error_dump",(char*) share->state.header.file_version, + DBUG_DUMP("error_dump", share->state.header.file_version, head_length); my_errno=HA_ERR_NOT_A_TABLE; goto err; diff --git a/storage/myisam/mi_page.c b/storage/myisam/mi_page.c index 76fac8688a7..90e31e72532 100644 --- a/storage/myisam/mi_page.c +++ b/storage/myisam/mi_page.c @@ -49,7 +49,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, { DBUG_PRINT("error",("page %lu had wrong page length: %u", (ulong) page, page_size)); - DBUG_DUMP("page", (char*) tmp, keyinfo->block_length); + DBUG_DUMP("page", tmp, keyinfo->block_length); info->last_keypage = HA_OFFSET_ERROR; mi_print_error(info->s, HA_ERR_CRASHED); my_errno = HA_ERR_CRASHED; diff --git a/storage/myisam/mi_search.c b/storage/myisam/mi_search.c index 95f817e47aa..9c842fba544 100644 --- a/storage/myisam/mi_search.c +++ b/storage/myisam/mi_search.c @@ -819,7 +819,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, DBUG_PRINT("error", ("Found too long null packed key: %u of %u at 0x%lx", length, keyseg->length, (long) *page_pos)); - DBUG_DUMP("key",(char*) *page_pos,16); + DBUG_DUMP("key", *page_pos, 16); mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; return 0; @@ -876,7 +876,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, { DBUG_PRINT("error",("Found too long packed key: %u of %u at 0x%lx", length, keyseg->length, (long) *page_pos)); - DBUG_DUMP("key",(char*) *page_pos,16); + DBUG_DUMP("key", *page_pos, 16); mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; return 0; /* Error */ @@ -948,7 +948,7 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, DBUG_PRINT("error", ("Found too long binary packed key: %u of %u at 0x%lx", length, keyinfo->maxlength, (long) *page_pos)); - DBUG_DUMP("key",(char*) *page_pos,16); + DBUG_DUMP("key", *page_pos, 16); mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; DBUG_RETURN(0); /* Wrong key */ diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index 23c58638166..d7c168d01b0 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -415,7 +415,7 @@ int main(int argc, char *argv[]) } ant=0; while (mi_rprev(file,read_record3,0) == 0 && - bcmp(read_record3+start,key,length) == 0) ant++; + memcmp(read_record3+start,key,length) == 0) ant++; if (ant != dupp_keys) { printf("prev: Found: %d records of %d\n",ant,dupp_keys); @@ -453,7 +453,7 @@ int main(int argc, char *argv[]) goto end; } if (mi_rlast(file,read_record2,0) || - bcmp(read_record2,read_record3,reclength)) + memcmp(read_record2,read_record3,reclength)) { printf("Can't find last record\n"); DBUG_DUMP("record2",(uchar*) read_record2,reclength); @@ -468,7 +468,7 @@ int main(int argc, char *argv[]) printf("prev: I found: %d records of %d\n",ant,write_count); goto end; } - if (bcmp(read_record,read_record3,reclength)) + if (memcmp(read_record,read_record3,reclength)) { printf("Can't find first record\n"); goto end; @@ -483,7 +483,7 @@ int main(int argc, char *argv[]) mi_rprev(file,read_record3,0) == 0 || mi_rnext(file,read_record3,0)) goto err; - if (bcmp(read_record,read_record3,reclength) != 0) + if (memcmp(read_record,read_record3,reclength) != 0) printf("Can't find first record\n"); if (!silent) @@ -495,7 +495,7 @@ int main(int argc, char *argv[]) mi_rnext(file,read_record3,0) == 0 || mi_rprev(file,read_record3,0)) goto err; - if (bcmp(read_record2,read_record3,reclength)) + if (memcmp(read_record2,read_record3,reclength)) printf("Can't find last record\n"); #ifdef NOT_ANYMORE if (!silent) @@ -509,7 +509,7 @@ int main(int argc, char *argv[]) bzero((char*) file->lastkey,file->s->base.max_key_length*2); if (mi_rkey(file,read_record,0,key2,(uint) i,HA_READ_PREFIX)) goto err; - if (bcmp(read_record+start,key,(uint) i)) + if (memcmp(read_record+start,key,(uint) i)) { puts("Didn't find right record"); goto end; @@ -528,7 +528,7 @@ int main(int argc, char *argv[]) opt_delete++; ant=1; while (mi_rnext(file,read_record3,0) == 0 && - bcmp(read_record3+start,key,length) == 0) ant++; + memcmp(read_record3+start,key,length) == 0) ant++; if (ant != dupp_keys-1) { printf("next: I can only find: %d keys of %d\n",ant,dupp_keys-1); @@ -546,7 +546,7 @@ int main(int argc, char *argv[]) opt_delete++; ant=1; while (mi_rprev(file,read_record3,0) == 0 && - bcmp(read_record3+start,key,length) == 0) ant++; + memcmp(read_record3+start,key,length) == 0) ant++; if (ant != dupp_keys-2) { printf("next: I can only find: %d keys of %d\n",ant,dupp_keys-2); @@ -566,7 +566,7 @@ int main(int argc, char *argv[]) if (mi_rnext(file,read_record,0)) goto err; /* Skall finnas poster */ while (mi_rnext(file,read_record3,0) == 0 && - bcmp(read_record3+start,key,length) == 0) ant++; + memcmp(read_record3+start,key,length) == 0) ant++; if (ant != dupp_keys-3) { printf("next: I can only find: %d keys of %d\n",ant,dupp_keys-3); @@ -581,7 +581,7 @@ int main(int argc, char *argv[]) opt_delete++; ant=0; while (mi_rprev(file,read_record3,0) == 0 && - bcmp(read_record3+start,key,length) == 0) ant++; + memcmp(read_record3+start,key,length) == 0) ant++; if (ant != dupp_keys-4) { printf("next: I can only find: %d keys of %d\n",ant,dupp_keys-4); @@ -604,7 +604,7 @@ int main(int argc, char *argv[]) for (i=min(2,keys) ; i-- > 0 ;) { if (mi_rsame(file,read_record2,(int) i)) goto err; - if (bcmp(read_record,read_record2,reclength) != 0) + if (memcmp(read_record,read_record2,reclength) != 0) { printf("is_rsame didn't find same record\n"); goto end; diff --git a/storage/myisam/mi_unique.c b/storage/myisam/mi_unique.c index 02fcd9289dd..fdba84a2e67 100644 --- a/storage/myisam/mi_unique.c +++ b/storage/myisam/mi_unique.c @@ -56,7 +56,7 @@ my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, uchar *record, if (_mi_search_next(info,info->s->keyinfo+def->key, info->lastkey, MI_UNIQUE_HASH_LENGTH, SEARCH_BIGGER, info->s->state.key_root[def->key]) || - bcmp((char*) info->lastkey, (char*) key_buff, MI_UNIQUE_HASH_LENGTH)) + memcmp(info->lastkey, key_buff, MI_UNIQUE_HASH_LENGTH)) { info->page_changed=1; /* Can't optimize read next */ info->lastpos=lastpos; diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index 7886cc2a5a2..8e18924c5b8 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -293,8 +293,9 @@ static int myisammrg_parent_open_callback(void *callback_param, } } - DBUG_PRINT("myrg", ("open: '%.*s'.'%.*s'", child_l->db_length, child_l->db, - child_l->table_name_length, child_l->table_name)); + DBUG_PRINT("myrg", ("open: '%.*s'.'%.*s'", (int) child_l->db_length, + child_l->db, (int) child_l->table_name_length, + child_l->table_name)); /* Convert to lowercase if required. */ if (lower_case_table_names && child_l->table_name_length) @@ -341,7 +342,7 @@ static MI_INFO *myisammrg_attach_children_callback(void *callback_param) TABLE *parent; TABLE *child; TABLE_LIST *child_l; - MI_INFO *myisam; + MI_INFO *UNINIT_VAR(myisam); DBUG_ENTER("myisammrg_attach_children_callback"); my_errno= 0; diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt index 3d9de566670..67e8ad22783 100755 --- a/strings/CMakeLists.txt +++ b/strings/CMakeLists.txt @@ -18,7 +18,7 @@ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -DSAFEMALLOC -DSAFE_MUT INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -SET(STRINGS_SOURCES bchange.c bcmp.c bfill.c bmove512.c bmove_upp.c ctype-big5.c ctype-bin.c ctype-cp932.c +SET(STRINGS_SOURCES bchange.c bfill.c bmove512.c bmove_upp.c ctype-big5.c ctype-bin.c ctype-cp932.c ctype-czech.c ctype-euc_kr.c ctype-eucjpms.c ctype-extra.c ctype-gb2312.c ctype-gbk.c ctype-latin1.c ctype-mb.c ctype-simple.c ctype-sjis.c ctype-tis620.c ctype-uca.c ctype-ucs2.c ctype-ujis.c ctype-utf8.c ctype-win1250ch.c ctype.c decimal.c int2str.c diff --git a/strings/Makefile.am b/strings/Makefile.am index db9016b7148..1303af91820 100644 --- a/strings/Makefile.am +++ b/strings/Makefile.am @@ -21,19 +21,19 @@ pkglib_LIBRARIES = libmystrings.a # Exact one of ASSEMBLER_X if ASSEMBLER_x86 ASRCS = strings-x86.s longlong2str-x86.s my_strtoll10-x86.s -CSRCS = bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c str_alloc.c longlong2str_asm.c my_strchr.c strmov.c +CSRCS = bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c str_alloc.c longlong2str_asm.c my_strchr.c strmov.c else if ASSEMBLER_sparc32 # These file MUST all be on the same line!! Otherwise automake # generats a very broken makefile ASRCS = bmove_upp-sparc.s strappend-sparc.s strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s strnmov-sparc.s strstr-sparc.s -CSRCS = strcont.c strfill.c strcend.c is_prefix.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c strxmov.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c strmov.c +CSRCS = strcont.c strfill.c strcend.c is_prefix.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c strxmov.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c strmov.c else #no assembler ASRCS = # These file MUST all be on the same line!! Otherwise automake # generats a very broken makefile -CSRCS = strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strinstr.c strmake.c strnmov.c strmov.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c +CSRCS = strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strinstr.c strmake.c strnmov.c strmov.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c endif endif @@ -57,7 +57,7 @@ EXTRA_DIST = ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc CHARSET_INFO.txt libmystrings_a_LIBADD= -conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c bcmp.c +conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c conf_to_src_LDADD= #force static linking of conf_to_src - essential when linking against #custom installation of libc diff --git a/strings/bcmp.c b/strings/bcmp.c deleted file mode 100644 index 1b6ed22fc22..00000000000 --- a/strings/bcmp.c +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* - bcmp(s1, s2, len) returns 0 if the "len" bytes starting at "s1" are - identical to the "len" bytes starting at "s2", non-zero if they are - different. - Now only used with purify because purify gives wrong warnings when - comparing a shorter string with bcmp. -*/ - -#include -#include "m_string.h" - -#ifdef HAVE_purify -#undef bcmp -#undef HAVE_BCMP -#endif - -#if !defined(bcmp) && !defined(HAVE_BCMP) - -#if defined(MC68000) && defined(DS90) - -int bcmp(s1,s2, len) -const char *s1; -const char *s2; -uint len; /* 0 <= len <= 65535 */ -{ - asm(" movl 12(a7),d0 "); - asm(" subqw #1,d0 "); - asm(" blt .L5 "); - asm(" movl 4(a7),a1 "); - asm(" movl 8(a7),a0 "); - asm(".L4: cmpmb (a0)+,(a1)+ "); - asm(" dbne d0,.L4 "); - asm(".L5: addqw #1,d0 "); -} - -#else - -#ifndef HAVE_purify -size_t bcmp(register const uchar *s1,register const uchar *s2, - register size_t len) -#else -size_t my_bcmp(register const uchar *s1,register const uchar *s2, - register size_t len) -#endif -{ - while (len-- != 0 && *s1++ == *s2++) ; - return len+1; -} - -#endif -#endif /* BSD_FUNCS */ diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index cead55f8a0a..865a19b0828 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -203,7 +203,7 @@ static int my_strnncoll_ucs2(CHARSET_INFO *cs, my_bool t_is_prefix) { int s_res,t_res; - my_wc_t UNINIT_VAR(s_wc),t_wc; + my_wc_t UNINIT_VAR(s_wc), UNINIT_VAR(t_wc); const uchar *se=s+slen; const uchar *te=t+tlen; MY_UNICASE_INFO **uni_plane= cs->caseinfo; @@ -317,7 +317,7 @@ static int my_strncasecmp_ucs2(CHARSET_INFO *cs, const char *s, const char *t, size_t len) { int s_res,t_res; - my_wc_t UNINIT_VAR(s_wc),t_wc; + my_wc_t UNINIT_VAR(s_wc), UNINIT_VAR(t_wc); const char *se=s+len; const char *te=t+len; MY_UNICASE_INFO **uni_plane= cs->caseinfo; @@ -1384,7 +1384,7 @@ int my_strnncoll_ucs2_bin(CHARSET_INFO *cs, my_bool t_is_prefix) { int s_res,t_res; - my_wc_t UNINIT_VAR(s_wc),t_wc; + my_wc_t UNINIT_VAR(s_wc), UNINIT_VAR(t_wc); const uchar *se=s+slen; const uchar *te=t+tlen; diff --git a/strings/make-ccc b/strings/make-ccc index 78d5ad1ce42..93be2bbf862 100755 --- a/strings/make-ccc +++ b/strings/make-ccc @@ -1,3 +1,3 @@ -ccc -DHAVE_CONFIG_H -I. -I. -I.. -I./../include -I../include -O -DDBUG_OFF -fast -O3 -fomit-frame-pointer -c atof.c bchange.c bcmp.c bfill.c bmove.c bmove512.c bmove_upp.c ct_init.c ctype-latin1.c int2str.c is_prefix.c llstr.c longlong2str.c r_strinstr.c str2int.c strappend.c strcend.c strcont.c strend.c strfill.c strinstr.c strmake.c strmov.c strnmov.c strstr.c strtol.c strtoll.c strtoul.c strtoull.c strxmov.c strxnmov.c +ccc -DHAVE_CONFIG_H -I. -I. -I.. -I./../include -I../include -O -DDBUG_OFF -fast -O3 -fomit-frame-pointer -c atof.c bchange.c bfill.c bmove.c bmove512.c bmove_upp.c ct_init.c ctype-latin1.c int2str.c is_prefix.c llstr.c longlong2str.c r_strinstr.c str2int.c strappend.c strcend.c strcont.c strend.c strfill.c strinstr.c strmake.c strmov.c strnmov.c strstr.c strtol.c strtoll.c strtoul.c strtoull.c strxmov.c strxnmov.c rm libmystrings.a ar -cr libmystrings.a atof.o diff --git a/strings/str_test.c b/strings/str_test.c index 3ddfca39419..a476809e22d 100644 --- a/strings/str_test.c +++ b/strings/str_test.c @@ -50,10 +50,10 @@ int main(void) errors=tests=0; init_strings(); - test_arg("bcmp(from,to,5)",(long) my_test(bcmp(from,to,5)),1L); - test_arg("bcmp(from,from,5)",(long) bcmp(from,from,5),0L); + test_arg("memcmp(from,to,5)",(long) my_test(memcmp(from,to,5)),1L); + test_arg("memcmp(from,from,5)",(long) memcmp(from,from,5),0L); - test_arg("bcmp(from,to,0)",(long) bcmp(from,to,0),0L); + test_arg("memcmp(from,to,0)",(long) memcmp(from,to,0),0L); test_arg("strend(from)",(long) strend(from),(long) from+F_LEN); test_arg("strchr(v1,'M')",(long) strchr(v1,'M'),(long) v1); test_arg("strchr(v1,'y')",(long) strchr(v1,'y'),(long) v1+4); @@ -93,7 +93,7 @@ int main(void) test_strarg("bmove_upp(to+6,from+6,3)",(bmove_upp(to+6,from+6,3),0L),INT_MAX32, 3,T_CHAR,3,F_CHAR,0,0); test_strarg("bmove_upp(to,from,0)",(bmove_upp(to,from,0),0L),INT_MAX32,0,0); - test_strarg("bmove_align(to,from,8)",(bmove_align(to,from,8),0L),INT_MAX32, + test_strarg("memcpy(to,from,8)",(memcpy(to,from,8),0L),INT_MAX32, 8,F_CHAR,0,0); test_strarg("strappend(to,3,' ')",(strappend(to,3,' '),0L),INT_MAX32, 3,T_CHAR,1,0,T_LEN-4,T_CHAR,1,0,0,0); @@ -233,7 +233,7 @@ int compare_buff(const char *message, char * b1, char * b2, int length, { int i,error=0; - if (bcmp(b1,b2,length)) + if (memcmp(b1,b2,length)) { errors++; printf("func: '%s' Buffers differ\nIs: ",message); diff --git a/strings/xml.c b/strings/xml.c index 1b697ec6b26..f3cfaad54fa 100644 --- a/strings/xml.c +++ b/strings/xml.c @@ -123,16 +123,16 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a) a->beg=p->cur; a->end=p->cur; - if ((p->end - p->cur > 3) && !bcmp(p->cur,"", 3); p->cur++) + for (; (p->cur < p->end) && memcmp(p->cur, "-->", 3); p->cur++) {} - if (!bcmp(p->cur, "-->", 3)) + if (!memcmp(p->cur, "-->", 3)) p->cur+=3; a->end=p->cur; lex=MY_XML_COMMENT; } - else if (!bcmp(p->cur, "cur, "cur+= 9; for (; p->cur < p->end - 2 ; p->cur++) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 97d146ff9ef..c492db723b0 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -18096,7 +18096,7 @@ static void test_bug53371() static void test_bug53907() { int rc; - char buf[] = "\x4test\x14../client_test_db/t1"; + uchar buf[] = "\x4test\x14../client_test_db/t1"; myheader("test_bug53907"); From 0300935ff3f6b422cff4c383d74ce0124dfd7f1f Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 2 Jul 2010 18:42:32 -0300 Subject: [PATCH 025/118] Bug#53445: Build with -Wall and fix warnings that it generates If bzero is not available, resort to memset. Also, remove dead bzero.c --- include/m_string.h | 8 ++--- strings/bzero.c | 82 ---------------------------------------------- 2 files changed, 4 insertions(+), 86 deletions(-) delete mode 100644 strings/bzero.c diff --git a/include/m_string.h b/include/m_string.h index d027047f501..3e5cd063b7b 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -58,6 +58,10 @@ # define bfill(A,B,C) memset((A),(C),(B)) #endif +#if !defined(bzero) && !defined(HAVE_BZERO) +# define bzero(A,B) memset((A),0,(B)) +#endif + #if defined(__cplusplus) extern "C" { #endif @@ -104,10 +108,6 @@ extern const double log_10[309]; extern void bfill(uchar *dst,size_t len,pchar fill); #endif -#if !defined(bzero) && !defined(HAVE_BZERO) -extern void bzero(uchar * dst,size_t len); -#endif - #ifndef bmove512 extern void bmove512(uchar *dst,const uchar *src,size_t len); #endif diff --git a/strings/bzero.c b/strings/bzero.c deleted file mode 100644 index b720de65eed..00000000000 --- a/strings/bzero.c +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* File : bzero.c - Author : Richard A. O'Keefe. - Michael Widenius; ifdef MC68000 - Updated: 23 April 1984 - Defines: bzero() - - bzero(dst, len) moves "len" 0 bytes to "dst". - Thus to clear a disc buffer to 0s do bzero(buffer, BUFSIZ). - - Note: the "b" routines are there to exploit certain VAX order codes, - The asm code is presented for your interest and amusement. -*/ - -#ifndef BSD_FUNCS -#include "strings.h" - -#ifdef bzero -#undef bzero /* remove macro */ -#endif - -#if VaxAsm - -static void _bzero64 _A((char *dst,int len)); - -void bzero(dst, len) -char *dst; -uint len; -{ - while ((int) len >= 64*K) - { - _bzero64(dst, 64*K-1); - dst += 64*K-1; - len -= 64*K-1; - } - _bzero64(dst, len); -} - -_bzero64(dst, len) -char *dst; -int len; -{ - asm("movc5 $0,*4(ap),$0,8(ap),*4(ap)"); -} - -#else - -#if defined(MC68000) && defined(DS90) - -void bzero(dst, len) -char *dst; -uint len; -{ - bfill(dst,len,0); /* This is very optimized ! */ -} /* bzero */ - -#else - -void bzero(dst, len) -register char *dst; -register uint len; -{ - while (len-- != 0) *dst++ = 0; -} /* bzero */ - -#endif -#endif -#endif /* BSD_FUNCS */ From 85d281737f0feccbd43d7f025658d260d340dd84 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Sat, 3 Jul 2010 10:20:05 -0300 Subject: [PATCH 026/118] Fix somewhat bogus GCC warning. Although needless as the base class is mostly empty, initialize the base class explicitly in the copy constructor. --- sql/sql_list.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_list.h b/sql/sql_list.h index 3e0ba2b2ede..c61846c22cd 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -74,7 +74,7 @@ public: SQL_I_List() { empty(); } - SQL_I_List(const SQL_I_List &tmp) + SQL_I_List(const SQL_I_List &tmp) : Sql_alloc() { elements= tmp.elements; first= tmp.first; From 1a17d7e8079b4cbda51c311eceaea38b407556f3 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 4 Jul 2010 12:02:49 +0800 Subject: [PATCH 027/118] The following statements support the CURRENT_USER() where a user is needed. DROP USER RENAME USER CURRENT_USER() ... GRANT ... TO CURRENT_USER() REVOKE ... FROM CURRENT_USER() ALTER DEFINER = CURRENT_USER() EVENTbut, When these statements are binlogged, CURRENT_USER() just is binlogged as 'CURRENT_USER()', it is not expanded to the real user name. When slave executes the log event, 'CURRENT_USER()' is expand to the user of slave SQL thread, but SQL thread's user name always NULL. This breaks the replication. After this patch, session's user will be written into query log events if these statements call CURREN_USER() or 'ALTER EVENT' does not assign a definer. mysql-test/include/diff_tables.inc: Expend its abilities. Now it can diff not only in sessions of 'master' and 'slave', but other sessions as well. sql/log_event.cc: session's user will be written into Query_log_event, if is_current_user_used() is TRUE. On slave SQL thread, Only thd->invoker is written into Query_log_event, if it exists. sql/sql_acl.cc: On slave SQL thread, grantor should copy from thd->invoker, if it exists sql/sql_class.h: On slave SQL thread, thd->invoker is used to store the applying event's invoker. --- mysql-test/include/diff_tables.inc | 18 +- mysql-test/include/rpl_diff_tables.inc | 35 +++ .../suite/rpl/r/rpl_current_user.result | 205 +++++++++++++++ .../suite/rpl/r/rpl_innodb_mixed_dml.result | 2 +- mysql-test/suite/rpl/t/rpl_current_user.cnf | 9 + mysql-test/suite/rpl/t/rpl_current_user.test | 238 ++++++++++++++++++ sql/log_event.cc | 65 ++++- sql/log_event.h | 7 +- sql/sql_acl.cc | 23 +- sql/sql_class.cc | 20 ++ sql/sql_class.h | 31 +++ sql/sql_parse.cc | 2 +- 12 files changed, 634 insertions(+), 21 deletions(-) create mode 100644 mysql-test/include/rpl_diff_tables.inc create mode 100644 mysql-test/suite/rpl/r/rpl_current_user.result create mode 100644 mysql-test/suite/rpl/t/rpl_current_user.cnf create mode 100644 mysql-test/suite/rpl/t/rpl_current_user.test diff --git a/mysql-test/include/diff_tables.inc b/mysql-test/include/diff_tables.inc index d15dd56b35d..e11e69b3023 100644 --- a/mysql-test/include/diff_tables.inc +++ b/mysql-test/include/diff_tables.inc @@ -64,17 +64,13 @@ let $_diff_table=$diff_table_2; let $_diff_i=2; while ($_diff_i) { - # Parse out any leading "master:" or "slave:" from the table - # specification and connect the appropriate server. - let $_diff_conn_master=`SELECT SUBSTR('$_diff_table', 1, 7) = 'master:'`; - if ($_diff_conn_master) { - let $_diff_table=`SELECT SUBSTR('$_diff_table', 8)`; - connection master; - } - let $_diff_conn_slave=`SELECT SUBSTR('$_diff_table', 1, 6) = 'slave:'`; - if ($_diff_conn_slave) { - let $_diff_table=`SELECT SUBSTR('$_diff_table', 7)`; - connection slave; + # Parse out any leading "master:" or "slave:" from the table specification +# and connect the appropriate server. + let $_pos= `SELECT LOCATE(':', '$_diff_table')`; + let $_diff_conn=`SELECT SUBSTR('$_diff_table', 1, $_pos-1)`; + if (`SELECT "XX$_diff_conn" <> "XX"`) { + let $_diff_table=`SELECT SUBSTR('$_diff_table', $_pos+1)`; + connection $_diff_conn; } # Sanity-check the input. diff --git a/mysql-test/include/rpl_diff_tables.inc b/mysql-test/include/rpl_diff_tables.inc new file mode 100644 index 00000000000..c3a45578a79 --- /dev/null +++ b/mysql-test/include/rpl_diff_tables.inc @@ -0,0 +1,35 @@ +# ############################################################################# +# Check whether the given table is consistent between different master and +# slaves +# +# Usage: +# --let $diff_table= test.t1 +# --let $diff_server_list= master, slave, slave2 +# --source include/rpl_diff_tables.inc +# ############################################################################# + +if (`SELECT "XX$diff_table" = "XX"`) +{ + --die diff_table is null. +} + +--let $_servers= master, slave +if (`SELECT "XX$diff_server_list" <> "XX"`) +{ + --let $_servers= $diff_server_list +} + +--let $_master= `SELECT SUBSTRING_INDEX('$_servers', ',', 1)` +--let $_servers= `SELECT LTRIM(SUBSTRING('$_servers', LENGTH('$_master') + 2))` +connection $_master; +while (`SELECT "XX$_servers" <> "XX"`) +{ + --let $_slave= `SELECT SUBSTRING_INDEX('$_servers', ',', 1)` + --let $_servers= `SELECT LTRIM(SUBSTRING('$_servers', LENGTH('$_slave') + 2))` + + --sync_slave_with_master $_slave + --let $diff_table_1= $_master:$diff_table + --let $diff_table_2= $_slave:$diff_table + --source include/diff_tables.inc + connection $_slave; +} diff --git a/mysql-test/suite/rpl/r/rpl_current_user.result b/mysql-test/suite/rpl/r/rpl_current_user.result new file mode 100644 index 00000000000..85490c2571c --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_current_user.result @@ -0,0 +1,205 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; + +# On slave2 +# Connect slave2 to slave +CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=SLAVE_MYPORT;, +MASTER_LOG_FILE='slave-bin.000001', MASTER_USER='root'; +START SLAVE; + +# [On master] +DROP VIEW IF EXISTS v_user; +DROP VIEW IF EXISTS v_tables_priv; +DROP VIEW IF EXISTS v_procs_priv; +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS my_grant; +DROP PROCEDURE IF EXISTS my_revoke; +DROP FUNCTION IF EXISTS my_user; +DROP EVENT IF EXISTS e1; +CREATE TABLE t1(c1 char(100)); +CREATE VIEW test.v_user AS SELECT * FROM mysql.user WHERE User LIKE 'bug48321%'; +CREATE VIEW test.v_tables_priv AS SELECT * FROM mysql.tables_priv WHERE User LIKE 'bug48321%'; +CREATE VIEW test.v_procs_priv AS SELECT * FROM mysql.procs_priv WHERE User LIKE 'bug48321%'; +CREATE VIEW test.v_event AS SELECT definer FROM mysql.event WHERE name = 'e1'; +CREATE PROCEDURE p1() SELECT 1; +# bug48321_1-01234 has the max length(16) of user. +GRANT ALL PRIVILEGES ON *.* TO 'bug48321_1-01234'@'localhost' WITH GRANT OPTION; + +# Make sure the max lengths of user and host +# the user name is too lengh +GRANT CREATE USER ON *.* TO '01234567890123456'@'fakehost'; +ERROR HY000: String '01234567890123456' is too long for user name (should be no longer than 16) +# the host name is too lengh +GRANT CREATE USER ON *.* TO 'fakename'@'0123456789012345678901234567890123456789012345678901234567890'; +ERROR HY000: String '0123456789012345678901234567890123456789012345678901234567890' is too long for host name (should be no longer than 60) + +# User 'bug48321_1-01234' connects to master by conn1 +# [On conn1] +# Verify 'REVOKE ALL' statement +REVOKE ALL PRIVILEGES, GRANT OPTION FROM CURRENT_USER(); +Comparing tables master:test.v_user and slave:test.v_user +Comparing tables master:test.v_user and slave2:test.v_user + +# Verify 'GRANT ... ON TABLE ...' statement +GRANT CREATE, INSERT, SELECT ON TABLE test.t1 TO CURRENT_USER(); +Comparing tables master:test.v_tables_priv and slave:test.v_tables_priv +Comparing tables master:test.v_tables_priv and slave2:test.v_tables_priv + +# Verify 'GRANT ... ON PROCEDURE...' statement +GRANT ALTER ROUTINE, EXECUTE ON PROCEDURE p1 TO CURRENT_USER(); +Comparing tables master:test.v_procs_priv and slave:test.v_procs_priv +Comparing tables master:test.v_procs_priv and slave2:test.v_procs_priv + +# Verify 'GRANT ... ON *.* ...' statement +GRANT ALL PRIVILEGES ON *.* TO CURRENT_USER() WITH GRANT OPTION; +Comparing tables master:test.v_procs_priv and slave:test.v_procs_priv +Comparing tables master:test.v_procs_priv and slave2:test.v_procs_priv + +# Verify 'REVOKE ... ON TABLE ...' statement +REVOKE CREATE, INSERT, SELECT ON TABLE t1 FROM CURRENT_USER(); +Comparing tables master:test.v_tables_priv and slave:test.v_tables_priv +Comparing tables master:test.v_tables_priv and slave2:test.v_tables_priv + +# Verify 'REVOKE ... ON PROCEDURE...' statement +REVOKE ALTER ROUTINE, EXECUTE ON PROCEDURE p1 FROM CURRENT_USER(); +Comparing tables master:test.v_procs_priv and slave:test.v_procs_priv +Comparing tables master:test.v_procs_priv and slave2:test.v_procs_priv + +# Verify 'REVOKE ... ON *.* ...' statement +REVOKE ALL PRIVILEGES ON *.* FROM CURRENT_USER(); +Comparing tables master:test.v_user and slave:test.v_user +Comparing tables master:test.v_user and slave2:test.v_user + +# Verify 'GRANT ...' statement in the procedure +CREATE PROCEDURE my_grant() +GRANT CREATE, INSERT, SELECT ON TABLE test.t1 TO CURRENT_USER(); +call my_grant; +Comparing tables master:test.v_tables_priv and slave:test.v_tables_priv +Comparing tables master:test.v_tables_priv and slave2:test.v_tables_priv + +# Verify 'REVOKE ... ON TABLE ...' statement in the procedure +CREATE PROCEDURE my_revoke() +REVOKE CREATE, INSERT, SELECT ON TABLE t1 FROM CURRENT_USER(); +call my_revoke; +Comparing tables master:test.v_tables_priv and slave:test.v_tables_priv +Comparing tables master:test.v_tables_priv and slave2:test.v_tables_priv + +# Verify 'RENAME USER ...' statement +RENAME USER CURRENT_USER TO 'bug48321_2'@'localhost'; +Comparing tables master:test.v_user and slave:test.v_user +Comparing tables master:test.v_user and slave2:test.v_user + +# Verify 'DROP USER ...' statement +GRANT CREATE USER ON *.* TO 'bug48321_2'@'localhost'; +DROP USER CURRENT_USER(); +Comparing tables master:test.v_user and slave:test.v_user +Comparing tables master:test.v_user and slave2:test.v_user + +# Verify 'ALTER EVENT...' statement +CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT * FROM t1; +# Explicitly assign CURRENT_USER() to definer +ALTER DEFINER=CURRENT_USER() EVENT e1 ENABLE; +Comparing tables master:test.v_event and slave:test.v_event +Comparing tables master:test.v_event and slave2:test.v_event + +# Session user will be set as definer, if the statement does not assign +# a definer +ALTER EVENT e1 ENABLE; +Comparing tables master:test.v_event and slave:test.v_event +Comparing tables master:test.v_event and slave2:test.v_event + +# Verify that this patch does not affect the calling of CURRENT_USER() +# in the other statements +# [On master] +INSERT INTO t1 VALUES(CURRENT_USER()), ('1234'); +Warnings: +Note 1592 Statement may not be safe to log in statement format. +SELECT * FROM t1; +c1 +root@localhost +1234 +# [On slave] +SELECT * FROM t1; +c1 +@ +1234 +# [On slave2] +SELECT * FROM t1; +c1 +@ +1234 +# [On master] +UPDATE t1 SET c1=CURRENT_USER() WHERE c1='1234'; +Warnings: +Note 1592 Statement may not be safe to log in statement format. +SELECT * FROM t1; +c1 +root@localhost +root@localhost +# [On slave] +SELECT * FROM t1; +c1 +@ +@ +# [On slave2] +SELECT * FROM t1; +c1 +@ +@ +# [On master] +DELETE FROM t1 WHERE c1=CURRENT_USER(); +Warnings: +Note 1592 Statement may not be safe to log in statement format. +SELECT * FROM t1; +c1 +# [On slave] +SELECT * FROM t1; +c1 +# [On slave2] +SELECT * FROM t1; +c1 +# [On master] +CREATE TABLE t2(c1 char(100)); +CREATE FUNCTION my_user() RETURNS VARCHAR(64) +SQL SECURITY INVOKER +BEGIN +INSERT INTO t2 VALUES(CURRENT_USER()); +RETURN CURRENT_USER(); +END | +INSERT INTO t1 VALUES(my_user()); +Warnings: +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +SELECT * FROM t1; +c1 +root@localhost +SELECT * FROM t2; +c1 +root@localhost +# [On slave] +SELECT * FROM t1; +c1 +@ +SELECT * FROM t2; +c1 +@ +# [On slave2] +SELECT * FROM t1; +c1 +@ +SELECT * FROM t2; +c1 +@ + +# END +DROP TABLE t1, t2; +DROP VIEW v_user, v_tables_priv, v_procs_priv, v_event; +DROP PROCEDURE p1; +DROP PROCEDURE my_grant; +DROP PROCEDURE my_revoke; +DROP FUNCTION my_user; +DROP EVENT e1; 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 26f2545dd72..35f4cd3ecbb 100644 --- a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result +++ b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result @@ -750,7 +750,7 @@ test_rpl e2 root@localhost SYSTEM RECURRING NULL 1 # # NULL ENABLED 1 latin1 lat USE test_rpl; SHOW EVENTS; Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -test_rpl e2 @ SYSTEM RECURRING NULL 1 # # NULL SLAVESIDE_DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci +test_rpl e2 root@localhost SYSTEM RECURRING NULL 1 # # NULL SLAVESIDE_DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci ==========MASTER========== SELECT COUNT(*) FROM t1; COUNT(*) diff --git a/mysql-test/suite/rpl/t/rpl_current_user.cnf b/mysql-test/suite/rpl/t/rpl_current_user.cnf new file mode 100644 index 00000000000..999ee727a88 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_current_user.cnf @@ -0,0 +1,9 @@ +!include ../my.cnf + +[mysqld.3] +server-id=3 +log-bin=slave-bin + +[ENV] +SLAVE_MYPORT1= @mysqld.3.port +SLAVE_MYSOCK1= @mysqld.3.socket diff --git a/mysql-test/suite/rpl/t/rpl_current_user.test b/mysql-test/suite/rpl/t/rpl_current_user.test new file mode 100644 index 00000000000..72581ed7049 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_current_user.test @@ -0,0 +1,238 @@ +############################################################################## +# BUG#48321 CURRENT_USER() incorrectly replicated for DROP/RENAME USER, +# REVOKE, GRANT, ALTER EVENT +# +# Calling CURRENT_USER() results into inconsistency between slave and master, +# as the slave SQL thread has different user with common users. +# +# After the patch for bug#48321, session's user will be written into query log +# event if CURRENT_USER() is called in 'DROP/RENAME USER', 'REVOKE', 'GRANT', +# 'ALTER EVENT'. +# +############################################################################## +source include/master-slave.inc; +source include/have_binlog_format_statement.inc; + +--echo +--echo # On slave2 +connect (slave2,127.0.0.1,root,,test,$SLAVE_MYPORT1,); +connection slave2; + +--echo # Connect slave2 to slave +--replace_result $SLAVE_MYPORT SLAVE_MYPORT; +eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$SLAVE_MYPORT, + MASTER_LOG_FILE='slave-bin.000001', MASTER_USER='root'; +START SLAVE; +source include/wait_for_slave_to_start.inc; + +--echo +--echo # [On master] +connection master; +--disable_warnings +DROP VIEW IF EXISTS v_user; +DROP VIEW IF EXISTS v_tables_priv; +DROP VIEW IF EXISTS v_procs_priv; +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS my_grant; +DROP PROCEDURE IF EXISTS my_revoke; +DROP FUNCTION IF EXISTS my_user; +DROP EVENT IF EXISTS e1; +--enable_warnings +CREATE TABLE t1(c1 char(100)); +CREATE VIEW test.v_user AS SELECT * FROM mysql.user WHERE User LIKE 'bug48321%'; +CREATE VIEW test.v_tables_priv AS SELECT * FROM mysql.tables_priv WHERE User LIKE 'bug48321%'; +CREATE VIEW test.v_procs_priv AS SELECT * FROM mysql.procs_priv WHERE User LIKE 'bug48321%'; +CREATE VIEW test.v_event AS SELECT definer FROM mysql.event WHERE name = 'e1'; +CREATE PROCEDURE p1() SELECT 1; +--echo # bug48321_1-01234 has the max length(16) of user. +GRANT ALL PRIVILEGES ON *.* TO 'bug48321_1-01234'@'localhost' WITH GRANT OPTION; + +--echo +--echo # Make sure the max lengths of user and host +--echo # the user name is too lengh +--error 1470 +GRANT CREATE USER ON *.* TO '01234567890123456'@'fakehost'; +--echo # the host name is too lengh +--error 1470 +GRANT CREATE USER ON *.* TO 'fakename'@'0123456789012345678901234567890123456789012345678901234567890'; + +--echo +--echo # User 'bug48321_1-01234' connects to master by conn1 +connect (conn1, 127.0.0.1, 'bug48321_1-01234'@'localhost',,); +connection conn1; +--echo # [On conn1] +--echo # Verify 'REVOKE ALL' statement +REVOKE ALL PRIVILEGES, GRANT OPTION FROM CURRENT_USER(); +let $diff_table= test.v_user; +let $diff_server_list= master, slave, slave2; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'GRANT ... ON TABLE ...' statement +connection conn1; +GRANT CREATE, INSERT, SELECT ON TABLE test.t1 TO CURRENT_USER(); +let $diff_table= test.v_tables_priv; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'GRANT ... ON PROCEDURE...' statement +connection conn1; +GRANT ALTER ROUTINE, EXECUTE ON PROCEDURE p1 TO CURRENT_USER(); +let $diff_table= test.v_procs_priv; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'GRANT ... ON *.* ...' statement +connection conn1; +GRANT ALL PRIVILEGES ON *.* TO CURRENT_USER() WITH GRANT OPTION; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'REVOKE ... ON TABLE ...' statement +connection conn1; +REVOKE CREATE, INSERT, SELECT ON TABLE t1 FROM CURRENT_USER(); +let $diff_table= test.v_tables_priv; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'REVOKE ... ON PROCEDURE...' statement +connection conn1; +REVOKE ALTER ROUTINE, EXECUTE ON PROCEDURE p1 FROM CURRENT_USER(); +let $diff_table= test.v_procs_priv; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'REVOKE ... ON *.* ...' statement +connection conn1; +REVOKE ALL PRIVILEGES ON *.* FROM CURRENT_USER(); +let $diff_table= test.v_user; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'GRANT ...' statement in the procedure +connection conn1; +CREATE PROCEDURE my_grant() + GRANT CREATE, INSERT, SELECT ON TABLE test.t1 TO CURRENT_USER(); +call my_grant; +let $diff_table= test.v_tables_priv; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'REVOKE ... ON TABLE ...' statement in the procedure +connection conn1; +CREATE PROCEDURE my_revoke() + REVOKE CREATE, INSERT, SELECT ON TABLE t1 FROM CURRENT_USER(); +call my_revoke; +let $diff_table= test.v_tables_priv; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'RENAME USER ...' statement +connection conn1; +RENAME USER CURRENT_USER TO 'bug48321_2'@'localhost'; +let $diff_table= test.v_user; +source include/rpl_diff_tables.inc; + +disconnect conn1; + +--echo +--echo # Verify 'DROP USER ...' statement +connection master; +GRANT CREATE USER ON *.* TO 'bug48321_2'@'localhost'; +connect (conn1, 127.0.0.1, 'bug48321_2'@'localhost',,); +connection conn1; +DROP USER CURRENT_USER(); +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify 'ALTER EVENT...' statement +connection master; +CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT * FROM t1; + +--echo # Explicitly assign CURRENT_USER() to definer +ALTER DEFINER=CURRENT_USER() EVENT e1 ENABLE; +let $diff_table= test.v_event; +source include/rpl_diff_tables.inc; + +connection master; +--echo +--echo # Session user will be set as definer, if the statement does not assign +--echo # a definer +ALTER EVENT e1 ENABLE; +sync_slave_with_master; +source include/rpl_diff_tables.inc; + +--echo +--echo # Verify that this patch does not affect the calling of CURRENT_USER() +--echo # in the other statements +connection master; +--echo # [On master] +INSERT INTO t1 VALUES(CURRENT_USER()), ('1234'); +SELECT * FROM t1; +sync_slave_with_master; +--echo # [On slave] +SELECT * FROM t1; +--echo # [On slave2] +sync_slave_with_master slave2; +SELECT * FROM t1; + +connection master; +--echo # [On master] +UPDATE t1 SET c1=CURRENT_USER() WHERE c1='1234'; +SELECT * FROM t1; +sync_slave_with_master; +--echo # [On slave] +SELECT * FROM t1; +sync_slave_with_master slave2; +--echo # [On slave2] +SELECT * FROM t1; + +connection master; +--echo # [On master] +DELETE FROM t1 WHERE c1=CURRENT_USER(); +SELECT * FROM t1; +sync_slave_with_master; +--echo # [On slave] +SELECT * FROM t1; +sync_slave_with_master slave2; +--echo # [On slave2] +SELECT * FROM t1; + +connection master; +--echo # [On master] +CREATE TABLE t2(c1 char(100)); + +DELIMITER |; +CREATE FUNCTION my_user() RETURNS VARCHAR(64) + SQL SECURITY INVOKER +BEGIN + INSERT INTO t2 VALUES(CURRENT_USER()); + RETURN CURRENT_USER(); +END | +DELIMITER ;| + +INSERT INTO t1 VALUES(my_user()); +SELECT * FROM t1; +SELECT * FROM t2; +sync_slave_with_master; +--echo # [On slave] +SELECT * FROM t1; +SELECT * FROM t2; +sync_slave_with_master slave2; +--echo # [On slave2] +SELECT * FROM t1; +SELECT * FROM t2; + +--echo +--echo # END +connection master; +DROP TABLE t1, t2; +DROP VIEW v_user, v_tables_priv, v_procs_priv, v_event; +DROP PROCEDURE p1; +DROP PROCEDURE my_grant; +DROP PROCEDURE my_revoke; +DROP FUNCTION my_user; +DROP EVENT e1; +sync_slave_with_master; +sync_slave_with_master slave2; +source include/master-slave-end.inc; diff --git a/sql/log_event.cc b/sql/log_event.cc index d53f13e0b6b..0e4d4bd512b 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2307,6 +2307,53 @@ bool Query_log_event::write(IO_CACHE* file) start+= 4; } + if (thd && thd->is_current_user_used()) + { + LEX_STRING user; + LEX_STRING host; + memset(&user, 0, sizeof(user)); + memset(&host, 0, sizeof(host)); + + if (thd->slave_thread && thd->has_invoker()) + { + /* user will be null, if master is older than this patch */ + user= thd->get_invoker_user(); + host= thd->get_invoker_host(); + } + else if (thd->security_ctx->priv_user) + { + Security_context *ctx= thd->security_ctx; + + user.length= strlen(ctx->priv_user); + user.str= ctx->priv_user; + if (ctx->priv_host[0] != '\0') + { + host.str= ctx->priv_host; + host.length= strlen(ctx->priv_host); + } + } + + if (user.length > 0) + { + *start++= Q_INVOKER; + + /* + Store user length and user. The max length of use is 16, so 1 byte is + enough to store the user's length. + */ + *start++= (uchar)user.length; + memcpy(start, user.str, user.length); + start+= user.length; + + /* + Store host length and host. The max length of host is 60, so 1 byte is + enough to store the host's length. + */ + *start++= (uchar)host.length; + memcpy(start, host.str, host.length); + start+= host.length; + } + } /* NOTE: When adding new status vars, please don't forget to update the MAX_SIZE_LOG_EVENT_STATUS in log_event.h and update the function @@ -2575,6 +2622,8 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, bool catalog_nz= 1; DBUG_ENTER("Query_log_event::Query_log_event(char*,...)"); + memset(&user, 0, sizeof(user)); + memset(&host, 0, sizeof(host)); common_header_len= description_event->common_header_len; post_header_len= description_event->post_header_len[event_type-1]; DBUG_PRINT("info",("event_len: %u common_header_len: %d post_header_len: %d", @@ -2729,6 +2778,20 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, data_written= master_data_written= uint4korr(pos); pos+= 4; break; + case Q_INVOKER: + { + CHECK_SPACE(pos, end, 1); + user.length= *pos++; + CHECK_SPACE(pos, end, user.length); + user.str= my_strndup((const char *)pos, user.length, MYF(0)); + pos+= user.length; + + CHECK_SPACE(pos, end, 1); + host.length= *pos++; + CHECK_SPACE(pos, end, host.length); + host.str= my_strndup((const char *)pos, host.length, MYF(0)); + pos+= host.length; + } default: /* That's why you must write status vars in growing order of code */ DBUG_PRINT("info",("Query_log_event has unknown status vars (first has\ @@ -3178,7 +3241,7 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli, thd->variables.collation_database= thd->db_charset; thd->table_map_for_update= (table_map)table_map_for_update; - + thd->set_invoker(&user, &host); /* Execute the query (note that we bypass dispatch_command()) */ const char* found_semicolon= NULL; mysql_parse(thd, thd->query(), thd->query_length(), &found_semicolon); diff --git a/sql/log_event.h b/sql/log_event.h index e3ca4ca3321..816a241e55d 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -264,7 +264,8 @@ struct sql_ex_info 1 + 2 /* type, lc_time_names_number */ + \ 1 + 2 /* type, charset_database_number */ + \ 1 + 8 /* type, table_map_for_update */ + \ - 1 + 4 /* type, master_data_written */) + 1 + 4 /* type, master_data_written */ + \ + 1 + 16 + 1 + 60/* type, user_len, user, host_len, host */) #define MAX_LOG_EVENT_HEADER ( /* in order of Query_log_event::write */ \ LOG_EVENT_HEADER_LEN + /* write_header */ \ QUERY_HEADER_LEN + /* write_data */ \ @@ -333,6 +334,8 @@ struct sql_ex_info #define Q_MASTER_DATA_WRITTEN_CODE 10 +#define Q_INVOKER 11 + /* Intvar event post-header */ /* Intvar event data */ @@ -1546,6 +1549,8 @@ protected: */ class Query_log_event: public Log_event { + LEX_STRING user; + LEX_STRING host; protected: Log_event::Byte* data_buf; public: diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index dd256c70ecb..9640b8db1b2 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -194,6 +194,7 @@ static bool compare_hostname(const acl_host_and_ip *host,const char *hostname, const char *ip); static my_bool acl_load(THD *thd, TABLE_LIST *tables); static my_bool grant_load(THD *thd, TABLE_LIST *tables); +static inline void get_grantor(THD *thd, char* grantor); /* Convert scrambled password to binary form, according to scramble type, @@ -2704,6 +2705,20 @@ end: DBUG_RETURN(result); } +static inline void get_grantor(THD *thd, char *grantor) +{ + const char *user= thd->security_ctx->user; + const char *host= thd->security_ctx->host_or_ip; + +#if defined(HAVE_REPLICATION) + if (thd->slave_thread && thd->has_invoker()) + { + user= thd->get_invoker_user().str; + host= thd->get_invoker_host().str; + } +#endif + strxmov(grantor, user, "@", host, NullS); +} static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, TABLE *table, const LEX_USER &combo, @@ -2718,9 +2733,7 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, uchar user_key[MAX_KEY_LENGTH]; DBUG_ENTER("replace_table_table"); - strxmov(grantor, thd->security_ctx->user, "@", - thd->security_ctx->host_or_ip, NullS); - + get_grantor(thd, grantor); /* The following should always succeed as new users are created before this function is called! @@ -2850,9 +2863,7 @@ static int replace_routine_table(THD *thd, GRANT_NAME *grant_name, DBUG_RETURN(-1); } - strxmov(grantor, thd->security_ctx->user, "@", - thd->security_ctx->host_or_ip, NullS); - + get_grantor(thd, grantor); /* New users are created before this function is called. diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 93aa6a8268c..2ce03708a9a 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -736,6 +736,9 @@ THD::THD() thr_lock_owner_init(&main_lock_id, &lock_info); m_internal_handler= NULL; + current_user_used= FALSE; + memset(&invoker_user, 0, sizeof(invoker_user)); + memset(&invoker_host, 0, sizeof(invoker_host)); } @@ -1236,6 +1239,7 @@ void THD::cleanup_after_query() where= THD::DEFAULT_WHERE; /* reset table map for multi-table update */ table_map_for_update= 0; + clean_current_user_used(); } @@ -3267,6 +3271,22 @@ void THD::set_query(char *query_arg, uint32 query_length_arg) pthread_mutex_unlock(&LOCK_thd_data); } +void THD::get_definer(LEX_USER *definer) +{ + set_current_user_used(); +#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) + if (slave_thread && has_invoker()) + { + definer->user = invoker_user; + definer->host= invoker_host; + definer->password.str= NULL; + definer->password.length= 0; + } + else +#endif + get_default_definer(this, definer); +} + /** Mark transaction to rollback and mark error as fatal to a sub-statement. diff --git a/sql/sql_class.h b/sql/sql_class.h index 023367cb747..5155ffe0603 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2341,6 +2341,18 @@ public: Protected with LOCK_thd_data mutex. */ void set_query(char *query_arg, uint32 query_length_arg); + void set_current_user_used() { current_user_used= TRUE; } + bool is_current_user_used() { return current_user_used; } + void clean_current_user_used() { current_user_used= FALSE; } + void get_definer(LEX_USER *definer); + void set_invoker(const LEX_STRING *user, const LEX_STRING *host) + { + invoker_user= *user; + invoker_host= *host; + } + LEX_STRING get_invoker_user() { return invoker_user; } + LEX_STRING get_invoker_host() { return invoker_host; } + bool has_invoker() { return invoker_user.length > 0; } private: /** The current internal error handler for this thread, or NULL. */ Internal_error_handler *m_internal_handler; @@ -2360,6 +2372,25 @@ private: tree itself is reused between executions and thus is stored elsewhere. */ MEM_ROOT main_mem_root; + + /** + It will be set TURE if CURRENT_USER() is called in account management + statements or default definer is set in CREATE/ALTER SP, SF, Event, + TRIGGER or VIEW statements. + + Current user will be binlogged into Query_log_event if current_user_used + is TRUE; It will be stored into invoker_host and invoker_user by SQL thread. + */ + bool current_user_used; + + /** + It points to the invoker in the Query_log_event. + SQL thread use it as the default definer in CREATE/ALTER SP, SF, Event, + TRIGGER or VIEW statements or current user in account management + statements if it is not NULL. + */ + LEX_STRING invoker_user; + LEX_STRING invoker_host; }; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ed2c76fdcb8..1f3d29ffec0 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7654,7 +7654,7 @@ LEX_USER *create_default_definer(THD *thd) if (! (definer= (LEX_USER*) thd->alloc(sizeof(LEX_USER)))) return 0; - get_default_definer(thd, definer); + thd->get_definer(definer); return definer; } From fd0eb0c1b02879b527471f4304f4a443fdd96fa9 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 4 Jul 2010 16:17:53 +0800 Subject: [PATCH 028/118] Postfix for bug#48321 Some test cases set ANSI_QUOTES in sql_mode. So we have to use single quotes to quote literal strings. --- mysql-test/include/diff_tables.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/include/diff_tables.inc b/mysql-test/include/diff_tables.inc index e11e69b3023..81362e8643b 100644 --- a/mysql-test/include/diff_tables.inc +++ b/mysql-test/include/diff_tables.inc @@ -68,7 +68,7 @@ while ($_diff_i) { # and connect the appropriate server. let $_pos= `SELECT LOCATE(':', '$_diff_table')`; let $_diff_conn=`SELECT SUBSTR('$_diff_table', 1, $_pos-1)`; - if (`SELECT "XX$_diff_conn" <> "XX"`) { + if (`SELECT 'XX$_diff_conn' <> 'XX'`) { let $_diff_table=`SELECT SUBSTR('$_diff_table', $_pos+1)`; connection $_diff_conn; } From 3e1a47070518a1995cc48e28c36b7c817d5f6008 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 25 Jun 2010 15:59:44 +0300 Subject: [PATCH 029/118] Bug #53095: SELECT column_name FROM INFORMATION_SCHEMA.STATISTICS returns nothing When looking for table or database names inside INFORMATION_SCHEMA we must convert the table and database names to lowercase (just as it's done in the rest of the server) when lowercase_table_names is non-zero. This will allow us to find the same tables that we would find if there is no condition. Fixed by converting to lower case when extracting the database and table name conditions. Test case added. --- mysql-test/r/lowercase_view.result | 17 ++++++++++++++ mysql-test/t/lowercase_view.test | 22 ++++++++++++++++++ sql/sql_show.cc | 37 ++++++++++++++++++++++-------- 3 files changed, 67 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/lowercase_view.result b/mysql-test/r/lowercase_view.result index c37dc41c495..33c87ec101c 100644 --- a/mysql-test/r/lowercase_view.result +++ b/mysql-test/r/lowercase_view.result @@ -148,3 +148,20 @@ a DROP VIEW v1; DROP TABLE t1; End of 5.0 tests. +# +# Bug #53095: SELECT column_name FROM INFORMATION_SCHEMA.STATISTICS +# returns nothing +# +CREATE TABLE `ttt` ( +`f1` char(3) NOT NULL, +PRIMARY KEY (`f1`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +SELECT count(COLUMN_NAME) FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = +'TTT'; +count(COLUMN_NAME) +1 +SELECT count(*) FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 'TTT'; +count(*) +1 +DROP TABLE `ttt`; +End of 5.0 tests. diff --git a/mysql-test/t/lowercase_view.test b/mysql-test/t/lowercase_view.test index d6612b3e6b9..52be911cde0 100644 --- a/mysql-test/t/lowercase_view.test +++ b/mysql-test/t/lowercase_view.test @@ -160,4 +160,26 @@ SELECT * FROM v1; DROP VIEW v1; DROP TABLE t1; + --echo End of 5.0 tests. + + +--echo # +--echo # Bug #53095: SELECT column_name FROM INFORMATION_SCHEMA.STATISTICS +--echo # returns nothing +--echo # + +CREATE TABLE `ttt` ( + `f1` char(3) NOT NULL, + PRIMARY KEY (`f1`) +) ENGINE=myisam DEFAULT CHARSET=latin1; + +SELECT count(COLUMN_NAME) FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = +'TTT'; +SELECT count(*) FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 'TTT'; + +DROP TABLE `ttt`; + + +--echo End of 5.0 tests. + diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 33abf356718..0eeb333f278 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2690,36 +2690,54 @@ bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables, { LEX *lex= thd->lex; const char *wild= lex->wild ? lex->wild->ptr() : NullS; + bool rc= 0; + bzero((char*) lookup_field_values, sizeof(LOOKUP_FIELD_VALUES)); switch (lex->sql_command) { case SQLCOM_SHOW_DATABASES: if (wild) { - lookup_field_values->db_value.str= (char*) wild; - lookup_field_values->db_value.length= strlen(wild); + thd->make_lex_string(&lookup_field_values->db_value, + wild, strlen(wild), 0); lookup_field_values->wild_db_value= 1; } - return 0; + break; case SQLCOM_SHOW_TABLES: case SQLCOM_SHOW_TABLE_STATUS: case SQLCOM_SHOW_TRIGGERS: case SQLCOM_SHOW_EVENTS: - lookup_field_values->db_value.str= lex->select_lex.db; - lookup_field_values->db_value.length=strlen(lex->select_lex.db); + thd->make_lex_string(&lookup_field_values->db_value, + lex->select_lex.db, strlen(lex->select_lex.db), 0); if (wild) { - lookup_field_values->table_value.str= (char*)wild; - lookup_field_values->table_value.length= strlen(wild); + thd->make_lex_string(&lookup_field_values->table_value, + wild, strlen(wild), 0); lookup_field_values->wild_table_value= 1; } - return 0; + break; default: /* The "default" is for queries over I_S. All previous cases handle SHOW commands. */ - return calc_lookup_values_from_cond(thd, cond, tables, lookup_field_values); + rc= calc_lookup_values_from_cond(thd, cond, tables, lookup_field_values); + break; } + + if (lower_case_table_names && !rc) + { + /* + We can safely do in-place upgrades here since all of the above cases + are allocating a new memory buffer for these strings. + */ + if (lookup_field_values->db_value.str && lookup_field_values->db_value.str[0]) + my_casedn_str(system_charset_info, lookup_field_values->db_value.str); + if (lookup_field_values->table_value.str && + lookup_field_values->table_value.str[0]) + my_casedn_str(system_charset_info, lookup_field_values->table_value.str); + } + + return rc; } @@ -3324,6 +3342,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) error= 0; goto err; } + DBUG_PRINT("INDEX VALUES",("db_name='%s', table_name='%s'", STR_OR_NIL(lookup_field_vals.db_value.str), STR_OR_NIL(lookup_field_vals.table_value.str))); From 1b31b3a38aabefc942ac55d2d6932b2c810d744d Mon Sep 17 00:00:00 2001 From: Jimmy Yang Date: Mon, 28 Jun 2010 19:41:37 -0700 Subject: [PATCH 030/118] Check in fix for bug #53756: "ALTER TABLE ADD PRIMARY KEY affects crash recovery" rb://369 approved by Marko --- .../suite/innodb/r/innodb_bug53756.result | 118 +++++++++++ .../suite/innodb/t/innodb_bug53756.test | 184 ++++++++++++++++++ storage/innobase/dict/dict0load.c | 27 ++- 3 files changed, 315 insertions(+), 14 deletions(-) create mode 100644 mysql-test/suite/innodb/r/innodb_bug53756.result create mode 100644 mysql-test/suite/innodb/t/innodb_bug53756.test diff --git a/mysql-test/suite/innodb/r/innodb_bug53756.result b/mysql-test/suite/innodb/r/innodb_bug53756.result new file mode 100644 index 00000000000..67797f9c90f --- /dev/null +++ b/mysql-test/suite/innodb/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. +# Dpdate 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/t/innodb_bug53756.test b/mysql-test/suite/innodb/t/innodb_bug53756.test new file mode 100644 index 00000000000..85a09478486 --- /dev/null +++ b/mysql-test/suite/innodb/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.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 # Dpdate 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/innobase/dict/dict0load.c b/storage/innobase/dict/dict0load.c index 65f1c9536bd..d5e7600f4d0 100644 --- a/storage/innobase/dict/dict0load.c +++ b/storage/innobase/dict/dict0load.c @@ -927,6 +927,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. */ @@ -953,15 +955,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, &mtr) - || rec_get_deleted_flag(rec, 0)) { + if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) { /* 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); } /*---------------------------------------------------*/ @@ -974,19 +978,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 7ccbf9b817b47d0393fe66bda6f6013ec24486ba Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Tue, 29 Jun 2010 16:32:03 +0700 Subject: [PATCH 031/118] Fixed bug #51855. Race condition in XA START. If several threads concurrently execute the statement XA START 'x', then mysqld server could crash. sql/sql_class.cc: xid_cache_insert: added checking for element in cache before insert it, return TRUE if such element already exists. sql/sql_parse.cc: mysql_execute_command modified: * sequence of calls to xid_cache_search(..)/xid_cache_insert(...) replaced by call to xid_cache_insert(...) in alternative 'case SQLCOM_XA_START:' * added comment to alternative 'case SQLCOM_XA_COMMIT:'. --- sql/sql_class.cc | 10 +++++++--- sql/sql_parse.cc | 26 ++++++++++++++++++-------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 93aa6a8268c..99792f2b262 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -3365,9 +3365,13 @@ bool xid_cache_insert(XID *xid, enum xa_states xa_state) bool xid_cache_insert(XID_STATE *xid_state) { pthread_mutex_lock(&LOCK_xid_cache); - DBUG_ASSERT(hash_search(&xid_cache, xid_state->xid.key(), - xid_state->xid.key_length())==0); - my_bool res=my_hash_insert(&xid_cache, (uchar*)xid_state); + if (hash_search(&xid_cache, xid_state->xid.key(), xid_state->xid.key_length())) + { + pthread_mutex_unlock(&LOCK_xid_cache); + my_error(ER_XAER_DUPID, MYF(0)); + return TRUE; + } + my_bool res= my_hash_insert(&xid_cache, (uchar*)xid_state); pthread_mutex_unlock(&LOCK_xid_cache); return res; } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ed2c76fdcb8..a8dede3e7f5 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4730,7 +4730,7 @@ create_sp_error: my_error(ER_XAER_NOTA, MYF(0)); break; } - thd->transaction.xid_state.xa_state=XA_ACTIVE; + thd->transaction.xid_state.xa_state= XA_ACTIVE; my_ok(thd); break; } @@ -4750,16 +4750,16 @@ create_sp_error: my_error(ER_XAER_OUTSIDE, MYF(0)); break; } - if (xid_cache_search(thd->lex->xid)) - { - my_error(ER_XAER_DUPID, MYF(0)); - break; - } DBUG_ASSERT(thd->transaction.xid_state.xid.is_null()); - thd->transaction.xid_state.xa_state=XA_ACTIVE; + thd->transaction.xid_state.xa_state= XA_ACTIVE; thd->transaction.xid_state.rm_error= 0; thd->transaction.xid_state.xid.set(thd->lex->xid); - xid_cache_insert(&thd->transaction.xid_state); + if (xid_cache_insert(&thd->transaction.xid_state)) + { + thd->transaction.xid_state.xa_state= XA_NOTR; + thd->transaction.xid_state.xid.null(); + break; + } thd->transaction.all.modified_non_trans_table= FALSE; thd->options= ((thd->options & ~(OPTION_KEEP_LOG)) | OPTION_BEGIN); thd->server_status|= SERVER_STATUS_IN_TRANS; @@ -4813,6 +4813,16 @@ create_sp_error: case SQLCOM_XA_COMMIT: if (!thd->transaction.xid_state.xid.eq(thd->lex->xid)) { + /* + xid_state.in_thd is always true beside of xa recovery + procedure. Note, that there is no race condition here + between xid_cache_search and xid_cache_delete, since we're always + deleting our own XID (thd->lex->xid == thd->transaction.xid_state.xid). + The only case when thd->lex->xid != thd->transaction.xid_state.xid + and xid_state->in_thd == 0 is in ha_recover() functionality, + which is called before starting client connections, and thus is + always single-threaded. + */ XID_STATE *xs=xid_cache_search(thd->lex->xid); if (!xs || xs->in_thd) my_error(ER_XAER_NOTA, MYF(0)); From 62084feb5578164832ed487286798d5f7fc7a5ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 29 Jun 2010 15:55:18 +0300 Subject: [PATCH 032/118] Bug#54358: READ UNCOMMITTED access failure of off-page DYNAMIC or COMPRESSED columns When the server crashes after a record stub has been inserted and before all its off-page columns have been written, the record will contain incomplete off-page columns after crash recovery. Such records may only be accessed at the READ UNCOMMITTED isolation level or when rolling back a recovered transaction in recv_recovery_rollback_active(). Skip these records at the READ UNCOMMITTED isolation level. TODO: Add assertions for checking the above assumptions hold when an incomplete BLOB is encountered. btr_rec_copy_externally_stored_field(): Return NULL if the field is incomplete. row_prebuilt_t::templ_contains_blob: Clarify what "BLOB" means in this context. Hint: MySQL BLOBs are not the same as InnoDB BLOBs. row_sel_store_mysql_rec(): Return FALSE if not all columns could be retrieved. Previously this function always returned TRUE. Assert that the record is not delete-marked. row_sel_push_cache_row_for_mysql(): Return FALSE if not all columns could be retrieved. row_search_for_mysql(): Skip records containing incomplete off-page columns. Assert that the transaction isolation level is READ UNCOMMITTED. rb://380 approved by Jimmy Yang --- storage/innodb_plugin/btr/btr0cur.c | 24 ++++- storage/innodb_plugin/include/btr0cur.h | 2 +- storage/innodb_plugin/include/row0mysql.h | 6 +- storage/innodb_plugin/row/row0merge.c | 5 + storage/innodb_plugin/row/row0sel.c | 113 +++++++++++++++++++--- 5 files changed, 133 insertions(+), 17 deletions(-) diff --git a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0cur.c index 50531ad3bd7..9b28f26f054 100644 --- a/storage/innodb_plugin/btr/btr0cur.c +++ b/storage/innodb_plugin/btr/btr0cur.c @@ -4814,7 +4814,7 @@ btr_copy_externally_stored_field( /*******************************************************************//** Copies an externally stored field of a record to mem heap. -@return the field copied to heap */ +@return the field copied to heap, or NULL if the field is incomplete */ UNIV_INTERN byte* btr_rec_copy_externally_stored_field( @@ -4844,6 +4844,28 @@ btr_rec_copy_externally_stored_field( data = rec_get_nth_field(rec, offsets, no, &local_len); + ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE); + + if (UNIV_UNLIKELY + (!memcmp(data + local_len - BTR_EXTERN_FIELD_REF_SIZE, + field_ref_zero, BTR_EXTERN_FIELD_REF_SIZE))) { + /* The externally stored field was not written + yet. This is only a valid condition when the server + crashed after the time a record stub was freshly + inserted but before all its columns were written. This + record should only be seen by + recv_recovery_rollback_active() or any + TRX_ISO_READ_UNCOMMITTED transactions. */ + + /* TODO: assert that there is an owner_trx with + owner_trx->id == DB_TRX_ID and owner_trx->is_recovered */ + + /* TODO: assert that for the current transaction trx, + either (trx == owner_trx && trx_is_recv(trx)) or + trx->isolation_level == TRX_ISO_READ_UNCOMMITTED. */ + return(NULL); + } + return(btr_copy_externally_stored_field(len, data, zip_size, local_len, heap)); } diff --git a/storage/innodb_plugin/include/btr0cur.h b/storage/innodb_plugin/include/btr0cur.h index 716f15c4267..7dc2eb63cf5 100644 --- a/storage/innodb_plugin/include/btr0cur.h +++ b/storage/innodb_plugin/include/btr0cur.h @@ -570,7 +570,7 @@ btr_copy_externally_stored_field_prefix( ulint local_len);/*!< in: length of data, in bytes */ /*******************************************************************//** Copies an externally stored field of a record to mem heap. -@return the field copied to heap */ +@return the field copied to heap, or NULL if the field is incomplete */ UNIV_INTERN byte* btr_rec_copy_externally_stored_field( diff --git a/storage/innodb_plugin/include/row0mysql.h b/storage/innodb_plugin/include/row0mysql.h index 39ea240772c..b69e657361b 100644 --- a/storage/innodb_plugin/include/row0mysql.h +++ b/storage/innodb_plugin/include/row0mysql.h @@ -622,7 +622,11 @@ struct row_prebuilt_struct { the secondary index, then this is set to TRUE */ unsigned templ_contains_blob:1;/*!< TRUE if the template contains - BLOB column(s) */ + a column with DATA_BLOB == + get_innobase_type_from_mysql_type(); + not to be confused with InnoDB + externally stored columns + (VARCHAR can be off-page too) */ mysql_row_templ_t* mysql_template;/*!< template used to transform rows fast between MySQL and Innobase formats; memory for this template diff --git a/storage/innodb_plugin/row/row0merge.c b/storage/innodb_plugin/row/row0merge.c index 70cc7912fad..56a68b58225 100644 --- a/storage/innodb_plugin/row/row0merge.c +++ b/storage/innodb_plugin/row/row0merge.c @@ -1780,6 +1780,11 @@ row_merge_copy_blobs( (below). */ data = btr_rec_copy_externally_stored_field( mrec, offsets, zip_size, i, &len, heap); + /* Because we have locked the table, any records + written by incomplete transactions must have been + rolled back already. There must not be any incomplete + BLOB columns. */ + ut_a(data); dfield_set_data(field, data, len); } diff --git a/storage/innodb_plugin/row/row0sel.c b/storage/innodb_plugin/row/row0sel.c index 2861235a995..ab8c78e4f4a 100644 --- a/storage/innodb_plugin/row/row0sel.c +++ b/storage/innodb_plugin/row/row0sel.c @@ -416,7 +416,7 @@ row_sel_fetch_columns( field_no))) { /* Copy an externally stored field to the - temporary heap */ + temporary heap, if possible. */ heap = mem_heap_create(1); @@ -425,6 +425,21 @@ row_sel_fetch_columns( dict_table_zip_size(index->table), field_no, &len, heap); + /* data == NULL means that the + externally stored field was not + written yet. This is only a valid + condition when the server crashed + after the time a record stub was + freshly inserted but before all its + columns were written. This record + should only be seen by + recv_recovery_rollback_active() or any + TRX_ISO_READ_UNCOMMITTED + transactions. The InnoDB SQL parser + (the sole caller of this function) + does not implement READ UNCOMMITTED, + and it is not involved during rollback. */ + ut_a(data); ut_a(len != UNIV_SQL_NULL); needs_copy = TRUE; @@ -926,6 +941,7 @@ row_sel_get_clust_rec( when plan->clust_pcur was positioned. The latch will not be released until mtr_commit(mtr). */ + ut_ad(!rec_get_deleted_flag(clust_rec, rec_offs_comp(offsets))); row_sel_fetch_columns(index, clust_rec, offsets, UT_LIST_GET_FIRST(plan->columns)); *out_rec = clust_rec; @@ -1628,6 +1644,13 @@ skip_lock: } if (old_vers == NULL) { + /* The record does not exist + in our read view. Skip it, but + first attempt to determine + whether the index segment we + are searching through has been + exhausted. */ + offsets = rec_get_offsets( rec, index, offsets, ULINT_UNDEFINED, &heap); @@ -2647,9 +2670,8 @@ Convert a row in the Innobase format to a row in the MySQL format. Note that the template in prebuilt may advise us to copy only a few columns to mysql_rec, other columns are left blank. All columns may not be needed in the query. -@return TRUE if success, FALSE if could not allocate memory for a BLOB -(though we may also assert in that case) */ -static +@return TRUE on success, FALSE if not all columns could be retrieved */ +static __attribute__((warn_unused_result)) ibool row_sel_store_mysql_rec( /*====================*/ @@ -2672,6 +2694,7 @@ 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); @@ -2719,6 +2742,26 @@ row_sel_store_mysql_rec( dict_table_zip_size(prebuilt->table), templ->rec_field_no, &len, heap); + if (UNIV_UNLIKELY(!data)) { + /* The externally stored field + was not written yet. This is + only a valid condition when + the server crashed after the + time a record stub was freshly + inserted but before all its + columns were written. This + record should only be seen by + recv_recovery_rollback_active() + or any TRX_ISO_READ_UNCOMMITTED + transactions. */ + + if (extern_field_heap) { + mem_heap_free(extern_field_heap); + } + + return(FALSE); + } + ut_a(len != UNIV_SQL_NULL); } else { /* Field is stored in the row. */ @@ -3136,9 +3179,10 @@ row_sel_pop_cached_row_for_mysql( } /********************************************************************//** -Pushes a row for MySQL to the fetch cache. */ -UNIV_INLINE -void +Pushes a row for MySQL to the fetch cache. +@return TRUE on success, FALSE if the record contains incomplete BLOBs */ +UNIV_INLINE __attribute__((warn_unused_result)) +ibool row_sel_push_cache_row_for_mysql( /*=============================*/ row_prebuilt_t* prebuilt, /*!< in: prebuilt struct */ @@ -3180,10 +3224,11 @@ row_sel_push_cache_row_for_mysql( prebuilt->fetch_cache[ prebuilt->n_fetch_cached], prebuilt, rec, offsets))) { - ut_error; + return(FALSE); } prebuilt->n_fetch_cached++; + return(TRUE); } /*********************************************************************//** @@ -3578,6 +3623,24 @@ row_search_for_mysql( if (!row_sel_store_mysql_rec(buf, prebuilt, rec, offsets)) { + /* Only fresh inserts at + server crash time may contain + incomplete externally stored + columns. Pretend that such + records do not exist. Such + records may only be accessed + at the READ UNCOMMITTED + isolation level or when + rolling back a recovered + transaction. Rollback happens + at a lower level, not here. */ + ut_a(trx->isolation_level + == TRX_ISO_READ_UNCOMMITTED); + /* TODO: assert that there is + an owner_trx with + owner_trx->id == DB_TRX_ID and + owner_trx->is_recovered */ + err = DB_TOO_BIG_RECORD; /* We let the main loop to do the @@ -4357,9 +4420,20 @@ requires_clust_rec: not cache rows because there the cursor is a scrollable cursor. */ - row_sel_push_cache_row_for_mysql(prebuilt, result_rec, - offsets); - if (prebuilt->n_fetch_cached == MYSQL_FETCH_CACHE_SIZE) { + if (!row_sel_push_cache_row_for_mysql(prebuilt, result_rec, + offsets)) { + /* Only fresh inserts at server crash time may contain + incomplete externally stored columns. Pretend that + such records do not exist. Such records may only be + accessed at the READ UNCOMMITTED isolation level or + when rolling back a recovered transaction. Rollback + happens at a lower level, not here. */ + ut_a(trx->isolation_level == TRX_ISO_READ_UNCOMMITTED); + /* TODO: assert that there is an owner_trx + with owner_trx->id == DB_TRX_ID and + owner_trx->is_recovered */ + } else if (prebuilt->n_fetch_cached + == MYSQL_FETCH_CACHE_SIZE) { goto got_row; } @@ -4375,9 +4449,20 @@ requires_clust_rec: } else { if (!row_sel_store_mysql_rec(buf, prebuilt, result_rec, offsets)) { - err = DB_TOO_BIG_RECORD; - - goto lock_wait_or_error; + /* Only fresh inserts at server crash + time may contain incomplete externally + stored columns. Pretend that such + records do not exist. Such records may + only be accessed at the READ UNCOMMITTED + isolation level or when rolling back a + recovered transaction. Rollback happens + at a lower level, not here. */ + ut_a(trx->isolation_level + == TRX_ISO_READ_UNCOMMITTED); + /* TODO: assert that there is an owner_trx + with owner_trx->id == DB_TRX_ID and + owner_trx->is_recovered */ + goto next_rec; } } From 4ee0dc7cca6f0f5a0acabed38715203d6bc951ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 29 Jun 2010 15:56:53 +0300 Subject: [PATCH 033/118] ChangeLog entry for Bug #54358 --- storage/innodb_plugin/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index 328fcf8e0bb..5e41c5f180a 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,10 @@ +2010-06-29 The InnoDB Team + + * btr/btr0cur.c, include/btr0cur.h, + include/row0mysql.h, row/row0merge.c, row/row0sel.c: + Fix Bug#54358 READ UNCOMMITTED access failure of off-page DYNAMIC + or COMPRESSED columns + 2010-06-24 The InnoDB Team * handler/ha_innodb.cc: From 63c44558dc02e7c03b224afb09ee4d882619ccf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 29 Jun 2010 16:00:58 +0300 Subject: [PATCH 034/118] Bug#54408: txn rollback after recovery: row0umod.c:673 dict_table_get_format(index->table) The REDUNDANT and COMPACT formats store a local 768-byte prefix of each externally stored column. No row_ext cache is needed, but we initialized one nevertheless. When the BLOB pointer was zero, we would ignore the locally stored prefix as well. This triggered an assertion failure in row_undo_mod_upd_exist_sec(). row_build(): Allow ext==NULL when a REDUNDANT or COMPACT table contains externally stored columns. row_undo_search_clust_to_pcur(), row_upd_store_row(): Invoke row_build() with ext==NULL on REDUNDANT and COMPACT tables. rb://382 approved by Jimmy Yang --- storage/innodb_plugin/row/row0row.c | 8 +++++++- storage/innodb_plugin/row/row0undo.c | 18 +++++++++++++++++- storage/innodb_plugin/row/row0upd.c | 17 ++++++++++++++++- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/storage/innodb_plugin/row/row0row.c b/storage/innodb_plugin/row/row0row.c index cb7dfa2b7c9..8e806a14a98 100644 --- a/storage/innodb_plugin/row/row0row.c +++ b/storage/innodb_plugin/row/row0row.c @@ -294,7 +294,13 @@ row_build( ut_ad(dtuple_check_typed(row)); - if (j) { + if (!ext) { + /* REDUNDANT and COMPACT formats store a local + 768-byte prefix of each externally stored + column. No cache is needed. */ + ut_ad(dict_table_get_format(index->table) + < DICT_TF_FORMAT_ZIP); + } else if (j) { *ext = row_ext_create(j, ext_cols, row, dict_table_zip_size(index->table), heap); diff --git a/storage/innodb_plugin/row/row0undo.c b/storage/innodb_plugin/row/row0undo.c index 9ef842b5114..fd28a4f6520 100644 --- a/storage/innodb_plugin/row/row0undo.c +++ b/storage/innodb_plugin/row/row0undo.c @@ -199,8 +199,24 @@ row_undo_search_clust_to_pcur( ret = FALSE; } else { + row_ext_t** ext; + + if (dict_table_get_format(node->table) >= DICT_TF_FORMAT_ZIP) { + /* In DYNAMIC or COMPRESSED format, there is + no prefix of externally stored columns in the + clustered index record. Build a cache of + column prefixes. */ + ext = &node->ext; + } else { + /* REDUNDANT and COMPACT formats store a local + 768-byte prefix of each externally stored + column. No cache is needed. */ + ext = NULL; + node->ext = NULL; + } + node->row = row_build(ROW_COPY_DATA, clust_index, rec, - offsets, NULL, &node->ext, node->heap); + offsets, NULL, ext, node->heap); if (node->update) { node->undo_row = dtuple_copy(node->row, node->heap); row_upd_replace(node->undo_row, &node->undo_ext, diff --git a/storage/innodb_plugin/row/row0upd.c b/storage/innodb_plugin/row/row0upd.c index d0aaecd3dae..397b117c067 100644 --- a/storage/innodb_plugin/row/row0upd.c +++ b/storage/innodb_plugin/row/row0upd.c @@ -1398,6 +1398,7 @@ row_upd_store_row( dict_index_t* clust_index; rec_t* rec; mem_heap_t* heap = NULL; + row_ext_t** ext; ulint offsets_[REC_OFFS_NORMAL_SIZE]; const ulint* offsets; rec_offs_init(offsets_); @@ -1414,8 +1415,22 @@ row_upd_store_row( offsets = rec_get_offsets(rec, clust_index, offsets_, ULINT_UNDEFINED, &heap); + + if (dict_table_get_format(node->table) >= DICT_TF_FORMAT_ZIP) { + /* In DYNAMIC or COMPRESSED format, there is no prefix + of externally stored columns in the clustered index + record. Build a cache of column prefixes. */ + ext = &node->ext; + } else { + /* REDUNDANT and COMPACT formats store a local + 768-byte prefix of each externally stored column. + No cache is needed. */ + ext = NULL; + node->ext = NULL; + } + node->row = row_build(ROW_COPY_DATA, clust_index, rec, offsets, - NULL, &node->ext, node->heap); + NULL, ext, node->heap); if (node->is_delete) { node->upd_row = NULL; node->upd_ext = NULL; From d8421300944dd04597c65f7dfd081e44f41664cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 29 Jun 2010 16:12:19 +0300 Subject: [PATCH 035/118] ChangeLog entry for Bug #54408 --- storage/innodb_plugin/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index 5e41c5f180a..f7e9a3df943 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,8 @@ +2010-06-29 The InnoDB Team + * row/row0row.c, row/row0undo.c, row/row0upd.c: + Fix Bug#54408 txn rollback after recovery: row0umod.c:673 + dict_table_get_format(index->table) + 2010-06-29 The InnoDB Team * btr/btr0cur.c, include/btr0cur.h, From 707a3bef6e95b1125c91d3a5ecc821bba20caa26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 30 Jun 2010 12:31:49 +0300 Subject: [PATCH 036/118] Correct some comments that were added in the fix of Bug #54358 (READ UNCOMMITTED access failure of off-page DYNAMIC or COMPRESSED columns). Records that lack incompletely written externally stored columns may be accessed by READ UNCOMMITTED transaction even without involving a crash during an INSERT or UPDATE operation. I verified this as follows. (1) added a delay after the mini-transaction for writing the clustered index 'stub' record was committed (patch attached) (2) started mysqld in gdb, setting breakpoints to the where the assertions about READ UNCOMMITTED were added in the bug fix (3) invoked ibtest3 --create-options=key_block_size=2 to create BLOBs in a COMPRESSED table (4) invoked the following: yes 'set transaction isolation level read uncommitted; checksum table blobt3;select sleep(1);'|mysql -uroot test (5) noted that one of the breakpoints was triggered (return(NULL) in btr_rec_copy_externally_stored_field()) === modified file 'storage/innodb_plugin/row/row0ins.c' --- storage/innodb_plugin/row/row0ins.c 2010-06-30 08:17:25 +0000 +++ storage/innodb_plugin/row/row0ins.c 2010-06-30 08:17:25 +0000 @@ -2120,6 +2120,7 @@ function_exit: rec_t* rec; ulint* offsets; mtr_start(&mtr); + os_thread_sleep(5000000); btr_cur_search_to_nth_level(index, 0, entry, PAGE_CUR_LE, BTR_MODIFY_TREE, &cursor, 0, === modified file 'storage/innodb_plugin/row/row0upd.c' --- storage/innodb_plugin/row/row0upd.c 2010-06-30 08:11:55 +0000 +++ storage/innodb_plugin/row/row0upd.c 2010-06-30 08:11:55 +0000 @@ -1763,6 +1763,7 @@ row_upd_clust_rec( rec_offs_init(offsets_); mtr_start(mtr); + os_thread_sleep(5000000); ut_a(btr_pcur_restore_position(BTR_MODIFY_TREE, pcur, mtr)); rec = btr_cur_get_rec(btr_cur); --- storage/innodb_plugin/btr/btr0cur.c | 14 ++------ storage/innodb_plugin/row/row0sel.c | 53 +++++++++-------------------- 2 files changed, 19 insertions(+), 48 deletions(-) diff --git a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0cur.c index 9b28f26f054..7fa7d42320a 100644 --- a/storage/innodb_plugin/btr/btr0cur.c +++ b/storage/innodb_plugin/btr/btr0cur.c @@ -4849,20 +4849,10 @@ btr_rec_copy_externally_stored_field( if (UNIV_UNLIKELY (!memcmp(data + local_len - BTR_EXTERN_FIELD_REF_SIZE, field_ref_zero, BTR_EXTERN_FIELD_REF_SIZE))) { - /* The externally stored field was not written - yet. This is only a valid condition when the server - crashed after the time a record stub was freshly - inserted but before all its columns were written. This - record should only be seen by + /* The externally stored field was not written yet. + This record should only be seen by recv_recovery_rollback_active() or any TRX_ISO_READ_UNCOMMITTED transactions. */ - - /* TODO: assert that there is an owner_trx with - owner_trx->id == DB_TRX_ID and owner_trx->is_recovered */ - - /* TODO: assert that for the current transaction trx, - either (trx == owner_trx && trx_is_recv(trx)) or - trx->isolation_level == TRX_ISO_READ_UNCOMMITTED. */ return(NULL); } diff --git a/storage/innodb_plugin/row/row0sel.c b/storage/innodb_plugin/row/row0sel.c index ab8c78e4f4a..d0c59862fce 100644 --- a/storage/innodb_plugin/row/row0sel.c +++ b/storage/innodb_plugin/row/row0sel.c @@ -427,11 +427,7 @@ row_sel_fetch_columns( /* data == NULL means that the externally stored field was not - written yet. This is only a valid - condition when the server crashed - after the time a record stub was - freshly inserted but before all its - columns were written. This record + written yet. This record should only be seen by recv_recovery_rollback_active() or any TRX_ISO_READ_UNCOMMITTED @@ -2744,12 +2740,7 @@ row_sel_store_mysql_rec( if (UNIV_UNLIKELY(!data)) { /* The externally stored field - was not written yet. This is - only a valid condition when - the server crashed after the - time a record stub was freshly - inserted but before all its - columns were written. This + was not written yet. This record should only be seen by recv_recovery_rollback_active() or any TRX_ISO_READ_UNCOMMITTED @@ -3623,8 +3614,7 @@ row_search_for_mysql( if (!row_sel_store_mysql_rec(buf, prebuilt, rec, offsets)) { - /* Only fresh inserts at - server crash time may contain + /* Only fresh inserts may contain incomplete externally stored columns. Pretend that such records do not exist. Such @@ -3636,10 +3626,6 @@ row_search_for_mysql( at a lower level, not here. */ ut_a(trx->isolation_level == TRX_ISO_READ_UNCOMMITTED); - /* TODO: assert that there is - an owner_trx with - owner_trx->id == DB_TRX_ID and - owner_trx->is_recovered */ err = DB_TOO_BIG_RECORD; @@ -4422,16 +4408,14 @@ requires_clust_rec: if (!row_sel_push_cache_row_for_mysql(prebuilt, result_rec, offsets)) { - /* Only fresh inserts at server crash time may contain - incomplete externally stored columns. Pretend that - such records do not exist. Such records may only be - accessed at the READ UNCOMMITTED isolation level or - when rolling back a recovered transaction. Rollback - happens at a lower level, not here. */ + /* Only fresh inserts may contain incomplete + externally stored columns. Pretend that such + records do not exist. Such records may only be + accessed at the READ UNCOMMITTED isolation + level or when rolling back a recovered + transaction. Rollback happens at a lower + level, not here. */ ut_a(trx->isolation_level == TRX_ISO_READ_UNCOMMITTED); - /* TODO: assert that there is an owner_trx - with owner_trx->id == DB_TRX_ID and - owner_trx->is_recovered */ } else if (prebuilt->n_fetch_cached == MYSQL_FETCH_CACHE_SIZE) { @@ -4449,19 +4433,16 @@ requires_clust_rec: } else { if (!row_sel_store_mysql_rec(buf, prebuilt, result_rec, offsets)) { - /* Only fresh inserts at server crash - time may contain incomplete externally - stored columns. Pretend that such - records do not exist. Such records may - only be accessed at the READ UNCOMMITTED + /* Only fresh inserts may contain + incomplete externally stored + columns. Pretend that such records do + not exist. Such records may only be + accessed at the READ UNCOMMITTED isolation level or when rolling back a - recovered transaction. Rollback happens - at a lower level, not here. */ + recovered transaction. Rollback + happens at a lower level, not here. */ ut_a(trx->isolation_level == TRX_ISO_READ_UNCOMMITTED); - /* TODO: assert that there is an owner_trx - with owner_trx->id == DB_TRX_ID and - owner_trx->is_recovered */ goto next_rec; } } From 38d8ca8cec7c8e38c41bd8f17b1caa8f5142827c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 30 Jun 2010 12:38:47 +0300 Subject: [PATCH 037/118] Bug#54358 follow-up: Correct some error handling. --- storage/innodb_plugin/row/row0sel.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/storage/innodb_plugin/row/row0sel.c b/storage/innodb_plugin/row/row0sel.c index d0c59862fce..76c144e5a8c 100644 --- a/storage/innodb_plugin/row/row0sel.c +++ b/storage/innodb_plugin/row/row0sel.c @@ -3627,11 +3627,8 @@ row_search_for_mysql( ut_a(trx->isolation_level == TRX_ISO_READ_UNCOMMITTED); - err = DB_TOO_BIG_RECORD; - - /* We let the main loop to do the - error handling */ - goto shortcut_fails_too_big_rec; + /* Proceed as in case SEL_RETRY. */ + break; } mtr_commit(&mtr); @@ -3671,7 +3668,7 @@ release_search_latch_if_needed: default: ut_ad(0); } -shortcut_fails_too_big_rec: + mtr_commit(&mtr); mtr_start(&mtr); } From 7f19cc824f0ad0367f731783bb45e0d7bff98be4 Mon Sep 17 00:00:00 2001 From: Jimmy Yang Date: Wed, 30 Jun 2010 22:06:01 -0700 Subject: [PATCH 038/118] Port fix for bug #54311 from mysql-trunk-innodb to mysql-5.1-innodb codeline. Bug #54311: Crash on CHECK PARTITION after concurrent LOAD DATA and adaptive_hash_index=OFF --- storage/innodb_plugin/ChangeLog | 6 ++++++ storage/innodb_plugin/btr/btr0sea.c | 11 ++++++++++- storage/innodb_plugin/ha/ha0ha.c | 15 +++++++++++---- storage/innodb_plugin/handler/ha_innodb.cc | 1 + storage/innodb_plugin/include/btr0sea.h | 8 +++++++- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index f7e9a3df943..a49a6b54a39 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,9 @@ +2010-06-30 The InnoDB Team + + * btr/btr0sea.c, ha/ha0ha.c, handler/ha_innodb.cc, include/btr0sea.h: + Fix Bug#54311 Crash on CHECK PARTITION after concurrent LOAD DATA + and adaptive_hash_index=OFF + 2010-06-29 The InnoDB Team * row/row0row.c, row/row0undo.c, row/row0upd.c: Fix Bug#54408 txn rollback after recovery: row0umod.c:673 diff --git a/storage/innodb_plugin/btr/btr0sea.c b/storage/innodb_plugin/btr/btr0sea.c index c91afa31bf0..ac7248fef20 100644 --- a/storage/innodb_plugin/btr/btr0sea.c +++ b/storage/innodb_plugin/btr/btr0sea.c @@ -46,6 +46,7 @@ Created 2/17/1996 Heikki Tuuri /** Flag: has the search system been enabled? Protected by btr_search_latch and btr_search_enabled_mutex. */ UNIV_INTERN char btr_search_enabled = TRUE; +UNIV_INTERN ibool btr_search_fully_disabled = FALSE; /** Mutex protecting btr_search_enabled */ static mutex_t btr_search_enabled_mutex; @@ -201,12 +202,19 @@ btr_search_disable(void) mutex_enter(&btr_search_enabled_mutex); rw_lock_x_lock(&btr_search_latch); + /* Disable access to hash index, also tell ha_insert_for_fold() + stop adding new nodes to hash index, but still allow updating + existing nodes */ btr_search_enabled = FALSE; /* Clear all block->is_hashed flags and remove all entries from btr_search_sys->hash_index. */ buf_pool_drop_hash_index(); + /* hash index has been cleaned up, disallow any operation to + the hash index */ + btr_search_fully_disabled = TRUE; + /* btr_search_enabled_mutex should guarantee this. */ ut_ad(!btr_search_enabled); @@ -225,6 +233,7 @@ btr_search_enable(void) rw_lock_x_lock(&btr_search_latch); btr_search_enabled = TRUE; + btr_search_fully_disabled = FALSE; rw_lock_x_unlock(&btr_search_latch); mutex_exit(&btr_search_enabled_mutex); @@ -1363,7 +1372,7 @@ btr_search_build_page_hash_index( rw_lock_x_lock(&btr_search_latch); - if (UNIV_UNLIKELY(!btr_search_enabled)) { + if (UNIV_UNLIKELY(btr_search_fully_disabled)) { goto exit_func; } diff --git a/storage/innodb_plugin/ha/ha0ha.c b/storage/innodb_plugin/ha/ha0ha.c index 9d9d341ad39..f9e798012f8 100644 --- a/storage/innodb_plugin/ha/ha0ha.c +++ b/storage/innodb_plugin/ha/ha0ha.c @@ -31,9 +31,7 @@ Created 8/22/1994 Heikki Tuuri #ifdef UNIV_DEBUG # include "buf0buf.h" #endif /* UNIV_DEBUG */ -#ifdef UNIV_SYNC_DEBUG -# include "btr0sea.h" -#endif /* UNIV_SYNC_DEBUG */ +#include "btr0sea.h" #include "page0page.h" /*************************************************************//** @@ -127,7 +125,8 @@ ha_clear( /*************************************************************//** Inserts an entry into a hash table. If an entry with the same fold number is found, its node is updated to point to the new data, and no new node -is inserted. +is inserted. If btr_search_enabled is set to FALSE, we will only allow +updating existing nodes, but no new node is allowed to be added. @return TRUE if succeed, FALSE if no more memory could be allocated */ UNIV_INTERN ibool @@ -174,6 +173,7 @@ ha_insert_for_fold_func( prev_block->n_pointers--; block->n_pointers++; } + ut_ad(!btr_search_fully_disabled); # endif /* !UNIV_HOTBACKUP */ prev_node->block = block; @@ -186,6 +186,13 @@ ha_insert_for_fold_func( prev_node = prev_node->next; } + /* We are in the process of disabling hash index, do not add + new chain node */ + if (!btr_search_enabled) { + ut_ad(!btr_search_fully_disabled); + return(TRUE); + } + /* We have to allocate a new chain node */ node = mem_heap_alloc(hash_get_heap(table, fold), sizeof(ha_node_t)); diff --git a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc index aa80814dbe0..c6042815e6c 100644 --- a/storage/innodb_plugin/handler/ha_innodb.cc +++ b/storage/innodb_plugin/handler/ha_innodb.cc @@ -2270,6 +2270,7 @@ innobase_change_buffering_inited_ok: /* Get the current high water mark format. */ innobase_file_format_check = (char*) trx_sys_file_format_max_get(); + btr_search_fully_disabled = (!btr_search_enabled); DBUG_RETURN(FALSE); error: DBUG_RETURN(TRUE); diff --git a/storage/innodb_plugin/include/btr0sea.h b/storage/innodb_plugin/include/btr0sea.h index f98ba386f9c..20a2be7f877 100644 --- a/storage/innodb_plugin/include/btr0sea.h +++ b/storage/innodb_plugin/include/btr0sea.h @@ -190,7 +190,13 @@ btr_search_validate(void); /** Flag: has the search system been enabled? Protected by btr_search_latch and btr_search_enabled_mutex. */ -extern char btr_search_enabled; +extern char btr_search_enabled; + +/** Flag: whether the search system has completed its disabling process, +It is set to TRUE right after buf_pool_drop_hash_index() in +btr_search_disable(), indicating hash index entries are cleaned up. +Protected by btr_search_latch and btr_search_enabled_mutex. */ +extern ibool btr_search_fully_disabled; /** The search info struct in an index */ struct btr_search_struct{ From 279b3adfc78ae93f976eb8797f41c64f3bc6b4bb Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Thu, 1 Jul 2010 12:05:09 +0300 Subject: [PATCH 039/118] Bug #53613: mysql_upgrade incorrectly revokes TRIGGER privilege on given table Fixed an incomplete historical ALTER TABLE MODIFY trimming the trigger privilege bit from mysql.tables_priv.Table_priv column. Removed the duplicate ALTER TABLE MODIFY. Test suite added. --- mysql-test/r/mysql_upgrade.result | 42 +++++++++++++++++++++++++++++ mysql-test/t/mysql_upgrade.test | 16 +++++++++++ scripts/mysql_system_tables_fix.sql | 4 +-- 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/mysql_upgrade.result b/mysql-test/r/mysql_upgrade.result index 821ad31871f..4541763c7c5 100644 --- a/mysql-test/r/mysql_upgrade.result +++ b/mysql-test/r/mysql_upgrade.result @@ -169,3 +169,45 @@ DROP PROCEDURE testproc; WARNING: NULL values of the 'character_set_client' column ('mysql.proc' table) have been updated with a default value (latin1). Please verify if necessary. WARNING: NULL values of the 'collation_connection' column ('mysql.proc' table) have been updated with a default value (latin1_swedish_ci). Please verify if necessary. WARNING: NULL values of the 'db_collation' column ('mysql.proc' table) have been updated with default values. Please verify if necessary. +# +# Bug #53613: mysql_upgrade incorrectly revokes +# TRIGGER privilege on given table +# +GRANT USAGE ON *.* TO 'user3'@'%'; +GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%'; +Run mysql_upgrade with all privileges on a user +mtr.global_suppressions OK +mtr.test_suppressions OK +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.help_category OK +mysql.help_keyword OK +mysql.help_relation OK +mysql.help_topic OK +mysql.host OK +mysql.ndb_binlog_index OK +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.tables_priv OK +mysql.time_zone OK +mysql.time_zone_leap_second OK +mysql.time_zone_name OK +mysql.time_zone_transition OK +mysql.time_zone_transition_type OK +mysql.user OK +SHOW GRANTS FOR 'user3'@'%'; +Grants for user3@% +GRANT USAGE ON *.* TO 'user3'@'%' +GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%' +DROP USER 'user3'@'%'; +End of 5.1 tests diff --git a/mysql-test/t/mysql_upgrade.test b/mysql-test/t/mysql_upgrade.test index 6c01f3b2027..5f3ff9c7bb8 100644 --- a/mysql-test/t/mysql_upgrade.test +++ b/mysql-test/t/mysql_upgrade.test @@ -108,3 +108,19 @@ CALL testproc(); DROP PROCEDURE testproc; --cat_file $MYSQLTEST_VARDIR/tmp/41569.txt --remove_file $MYSQLTEST_VARDIR/tmp/41569.txt + + +--echo # +--echo # Bug #53613: mysql_upgrade incorrectly revokes +--echo # TRIGGER privilege on given table +--echo # + +GRANT USAGE ON *.* TO 'user3'@'%'; +GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%'; +--echo Run mysql_upgrade with all privileges on a user +--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1 +SHOW GRANTS FOR 'user3'@'%'; + +DROP USER 'user3'@'%'; + +--echo End of 5.1 tests diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql index deeb4d4de82..90bdbdae338 100644 --- a/scripts/mysql_system_tables_fix.sql +++ b/scripts/mysql_system_tables_fix.sql @@ -58,7 +58,7 @@ ALTER TABLE tables_priv COLLATE utf8_general_ci DEFAULT '' NOT NULL, MODIFY Table_priv set('Select','Insert','Update','Delete','Create', 'Drop','Grant','References','Index','Alter', - 'Create View','Show view') + 'Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, COMMENT='Table privileges'; @@ -584,8 +584,6 @@ ALTER TABLE host MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAU ALTER TABLE db ADD Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; ALTER TABLE db MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; -ALTER TABLE tables_priv MODIFY Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL; - UPDATE user SET Trigger_priv=Super_priv WHERE @hadTriggerPriv = 0; # Activate the new, possible modified privilege tables From cd41cd953d9d76b4b9c13fd745856d5023f12d71 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Mon, 5 Jul 2010 09:00:39 -0300 Subject: [PATCH 040/118] Bug#22320: my_atomic-t unit test fails The atomic operations implementation on 5.1 has a few problems, which might cause tests to abort randomly. Since no code in 5.1 uses atomic operations, simply remove the code. --- include/Makefile.am | 6 +- include/atomic/gcc_builtins.h | 33 ------ include/atomic/nolock.h | 44 -------- include/atomic/rwlock.h | 48 -------- include/atomic/x86-gcc.h | 58 ---------- include/atomic/x86-msvc.h | 96 ---------------- include/my_atomic.h | 142 ----------------------- include/my_pthread.h | 2 +- mysys/Makefile.am | 3 +- mysys/my_atomic.c | 45 -------- storage/ibmdb2i/db2i_file.h | 1 - unittest/mysys/Makefile.am | 7 -- unittest/mysys/my_atomic-t.c | 205 ---------------------------------- 13 files changed, 4 insertions(+), 686 deletions(-) delete mode 100644 include/atomic/gcc_builtins.h delete mode 100644 include/atomic/nolock.h delete mode 100644 include/atomic/rwlock.h delete mode 100644 include/atomic/x86-gcc.h delete mode 100644 include/atomic/x86-msvc.h delete mode 100644 include/my_atomic.h delete mode 100644 mysys/my_atomic.c delete mode 100644 unittest/mysys/my_atomic-t.c diff --git a/include/Makefile.am b/include/Makefile.am index 64f73af8606..130517a405e 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -36,10 +36,8 @@ noinst_HEADERS = config-win.h config-netware.h my_bit.h \ my_nosys.h my_alarm.h queues.h rijndael.h sha1.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_atomic.h atomic/nolock.h \ - atomic/rwlock.h atomic/x86-gcc.h atomic/x86-msvc.h \ - atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h + my_handler.h my_time.h my_vle.h my_user.h \ + my_libwrap.h my_stacktrace.h EXTRA_DIST = mysql.h.pp mysql/plugin.h.pp diff --git a/include/atomic/gcc_builtins.h b/include/atomic/gcc_builtins.h deleted file mode 100644 index 509701b30a5..00000000000 --- a/include/atomic/gcc_builtins.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2008 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#define make_atomic_add_body(S) \ - v= __sync_fetch_and_add(a, v); -#define make_atomic_swap_body(S) \ - v= __sync_lock_test_and_set(a, v); -#define make_atomic_cas_body(S) \ - int ## S sav; \ - sav= __sync_val_compare_and_swap(a, *cmp, set); \ - if (!(ret= (sav == *cmp))) *cmp= sav; - -#ifdef MY_ATOMIC_MODE_DUMMY -#define make_atomic_load_body(S) ret= *a -#define make_atomic_store_body(S) *a= v -#else -#define make_atomic_load_body(S) \ - ret= __sync_fetch_and_or(a, 0); -#define make_atomic_store_body(S) \ - (void) __sync_lock_test_and_set(a, v); -#endif diff --git a/include/atomic/nolock.h b/include/atomic/nolock.h deleted file mode 100644 index 10ac17884b6..00000000000 --- a/include/atomic/nolock.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2006 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#if defined(__i386__) || defined(_M_IX86) || defined(HAVE_GCC_ATOMIC_BUILTINS) - -#ifdef MY_ATOMIC_MODE_DUMMY -# define LOCK "" -#else -# define LOCK "lock" -#endif - -#ifdef HAVE_GCC_ATOMIC_BUILTINS -#include "gcc_builtins.h" -#elif __GNUC__ -#include "x86-gcc.h" -#elif defined(_MSC_VER) -#include "x86-msvc.h" -#endif -#endif - -#ifdef make_atomic_cas_body - -typedef struct { } my_atomic_rwlock_t; -#define my_atomic_rwlock_destroy(name) -#define my_atomic_rwlock_init(name) -#define my_atomic_rwlock_rdlock(name) -#define my_atomic_rwlock_wrlock(name) -#define my_atomic_rwlock_rdunlock(name) -#define my_atomic_rwlock_wrunlock(name) - -#endif - diff --git a/include/atomic/rwlock.h b/include/atomic/rwlock.h deleted file mode 100644 index 18b77e93d80..00000000000 --- a/include/atomic/rwlock.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -typedef struct {pthread_rwlock_t rw;} my_atomic_rwlock_t; - -#ifdef MY_ATOMIC_MODE_DUMMY -/* - the following can never be enabled by ./configure, one need to put #define in - a source to trigger the following warning. The resulting code will be broken, - it only makes sense to do it to see now test_atomic detects broken - implementations (another way is to run a UP build on an SMP box). -*/ -#warning MY_ATOMIC_MODE_DUMMY and MY_ATOMIC_MODE_RWLOCKS are incompatible -#define my_atomic_rwlock_destroy(name) -#define my_atomic_rwlock_init(name) -#define my_atomic_rwlock_rdlock(name) -#define my_atomic_rwlock_wrlock(name) -#define my_atomic_rwlock_rdunlock(name) -#define my_atomic_rwlock_wrunlock(name) -#define MY_ATOMIC_MODE "dummy (non-atomic)" -#else -#define my_atomic_rwlock_destroy(name) pthread_rwlock_destroy(& (name)->rw) -#define my_atomic_rwlock_init(name) pthread_rwlock_init(& (name)->rw, 0) -#define my_atomic_rwlock_rdlock(name) pthread_rwlock_rdlock(& (name)->rw) -#define my_atomic_rwlock_wrlock(name) pthread_rwlock_wrlock(& (name)->rw) -#define my_atomic_rwlock_rdunlock(name) pthread_rwlock_unlock(& (name)->rw) -#define my_atomic_rwlock_wrunlock(name) pthread_rwlock_unlock(& (name)->rw) -#define MY_ATOMIC_MODE "rwlocks" -#endif - -#define make_atomic_add_body(S) int ## S sav; sav= *a; *a+= v; v=sav; -#define make_atomic_swap_body(S) int ## S sav; sav= *a; *a= v; v=sav; -#define make_atomic_cas_body(S) if ((ret= (*a == *cmp))) *a= set; else *cmp=*a; -#define make_atomic_load_body(S) ret= *a; -#define make_atomic_store_body(S) *a= v; - diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h deleted file mode 100644 index d79dadbf05e..00000000000 --- a/include/atomic/x86-gcc.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2006 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* - XXX 64-bit atomic operations can be implemented using - cmpxchg8b, if necessary. Though I've heard that not all 64-bit - architectures support double-word (128-bit) cas. -*/ - -#ifdef MY_ATOMIC_NO_XADD -#define MY_ATOMIC_MODE "gcc-x86" LOCK "-no-xadd" -#else -#define MY_ATOMIC_MODE "gcc-x86" LOCK -#endif - -/* fix -ansi errors while maintaining readability */ -#ifndef asm -#define asm __asm__ -#endif - -#ifndef MY_ATOMIC_NO_XADD -#define make_atomic_add_body(S) \ - asm volatile (LOCK "; xadd %0, %1;" : "+r" (v) , "+m" (*a)) -#endif -#define make_atomic_swap_body(S) \ - asm volatile ("; xchg %0, %1;" : "+r" (v) , "+m" (*a)) -#define make_atomic_cas_body(S) \ - asm volatile (LOCK "; cmpxchg %3, %0; setz %2;" \ - : "+m" (*a), "+a" (*cmp), "=q" (ret): "r" (set)) - -#ifdef MY_ATOMIC_MODE_DUMMY -#define make_atomic_load_body(S) ret=*a -#define make_atomic_store_body(S) *a=v -#else -/* - Actually 32-bit reads/writes are always atomic on x86 - But we add LOCK here anyway to force memory barriers -*/ -#define make_atomic_load_body(S) \ - ret=0; \ - asm volatile (LOCK "; cmpxchg %2, %0" \ - : "+m" (*a), "+a" (ret): "r" (ret)) -#define make_atomic_store_body(S) \ - asm volatile ("; xchg %0, %1;" : "+m" (*a) : "r" (v)) -#endif - diff --git a/include/atomic/x86-msvc.h b/include/atomic/x86-msvc.h deleted file mode 100644 index c4885bb8451..00000000000 --- a/include/atomic/x86-msvc.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (C) 2006 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* - XXX 64-bit atomic operations can be implemented using - cmpxchg8b, if necessary -*/ - -// Would it be better to use intrinsics ? -// (InterlockedCompareExchange, InterlockedCompareExchange16 -// InterlockedExchangeAdd, InterlockedExchange) - -#ifndef _atomic_h_cleanup_ -#define _atomic_h_cleanup_ "atomic/x86-msvc.h" - -#define MY_ATOMIC_MODE "msvc-x86" LOCK - -#define make_atomic_add_body(S) \ - _asm { \ - _asm mov reg_ ## S, v \ - _asm LOCK xadd *a, reg_ ## S \ - _asm movzx v, reg_ ## S \ - } -#define make_atomic_cas_body(S) \ - _asm { \ - _asm mov areg_ ## S, *cmp \ - _asm mov reg2_ ## S, set \ - _asm LOCK cmpxchg *a, reg2_ ## S \ - _asm mov *cmp, areg_ ## S \ - _asm setz al \ - _asm movzx ret, al \ - } -#define make_atomic_swap_body(S) \ - _asm { \ - _asm mov reg_ ## S, v \ - _asm xchg *a, reg_ ## S \ - _asm mov v, reg_ ## S \ - } - -#ifdef MY_ATOMIC_MODE_DUMMY -#define make_atomic_load_body(S) ret=*a -#define make_atomic_store_body(S) *a=v -#else -/* - Actually 32-bit reads/writes are always atomic on x86 - But we add LOCK here anyway to force memory barriers -*/ -#define make_atomic_load_body(S) \ - _asm { \ - _asm mov areg_ ## S, 0 \ - _asm mov reg2_ ## S, areg_ ## S \ - _asm LOCK cmpxchg *a, reg2_ ## S \ - _asm mov ret, areg_ ## S \ - } -#define make_atomic_store_body(S) \ - _asm { \ - _asm mov reg_ ## S, v \ - _asm xchg *a, reg_ ## S \ - } -#endif - -#define reg_8 al -#define reg_16 ax -#define reg_32 eax -#define areg_8 al -#define areg_16 ax -#define areg_32 eax -#define reg2_8 bl -#define reg2_16 bx -#define reg2_32 ebx - -#else /* cleanup */ - -#undef reg_8 -#undef reg_16 -#undef reg_32 -#undef areg_8 -#undef areg_16 -#undef areg_32 -#undef reg2_8 -#undef reg2_16 -#undef reg2_32 -#endif - diff --git a/include/my_atomic.h b/include/my_atomic.h deleted file mode 100644 index ed439e5fe87..00000000000 --- a/include/my_atomic.h +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright (C) 2006 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifndef my_atomic_rwlock_init - -#define intptr void * - -#ifndef MY_ATOMIC_MODE_RWLOCKS -#include "atomic/nolock.h" -#endif - -#ifndef make_atomic_cas_body -#include "atomic/rwlock.h" -#endif - -#ifndef make_atomic_add_body -#define make_atomic_add_body(S) \ - int ## S tmp=*a; \ - while (!my_atomic_cas ## S(a, &tmp, tmp+v)); \ - v=tmp; -#endif - -#ifdef HAVE_INLINE - -#define make_atomic_add(S) \ -STATIC_INLINE int ## S my_atomic_add ## S( \ - int ## S volatile *a, int ## S v) \ -{ \ - make_atomic_add_body(S); \ - return v; \ -} - -#define make_atomic_swap(S) \ -STATIC_INLINE int ## S my_atomic_swap ## S( \ - int ## S volatile *a, int ## S v) \ -{ \ - make_atomic_swap_body(S); \ - return v; \ -} - -#define make_atomic_cas(S) \ -STATIC_INLINE int my_atomic_cas ## S(int ## S volatile *a, \ - int ## S *cmp, int ## S set) \ -{ \ - int8 ret; \ - make_atomic_cas_body(S); \ - return ret; \ -} - -#define make_atomic_load(S) \ -STATIC_INLINE int ## S my_atomic_load ## S(int ## S volatile *a) \ -{ \ - int ## S ret; \ - make_atomic_load_body(S); \ - return ret; \ -} - -#define make_atomic_store(S) \ -STATIC_INLINE void my_atomic_store ## S( \ - int ## S volatile *a, int ## S v) \ -{ \ - make_atomic_store_body(S); \ -} - -#else /* no inline functions */ - -#define make_atomic_add(S) \ -extern int ## S my_atomic_add ## S(int ## S volatile *a, int ## S v); - -#define make_atomic_swap(S) \ -extern int ## S my_atomic_swap ## S(int ## S volatile *a, int ## S v); - -#define make_atomic_cas(S) \ -extern int my_atomic_cas ## S(int ## S volatile *a, int ## S *cmp, int ## S set); - -#define make_atomic_load(S) \ -extern int ## S my_atomic_load ## S(int ## S volatile *a); - -#define make_atomic_store(S) \ -extern void my_atomic_store ## S(int ## S volatile *a, int ## S v); - -#endif - -make_atomic_cas( 8) -make_atomic_cas(16) -make_atomic_cas(32) -make_atomic_cas(ptr) - -make_atomic_add( 8) -make_atomic_add(16) -make_atomic_add(32) - -make_atomic_load( 8) -make_atomic_load(16) -make_atomic_load(32) -make_atomic_load(ptr) - -make_atomic_store( 8) -make_atomic_store(16) -make_atomic_store(32) -make_atomic_store(ptr) - -make_atomic_swap( 8) -make_atomic_swap(16) -make_atomic_swap(32) -make_atomic_swap(ptr) - -#undef make_atomic_add -#undef make_atomic_cas -#undef make_atomic_load -#undef make_atomic_store -#undef make_atomic_swap -#undef make_atomic_add_body -#undef make_atomic_cas_body -#undef make_atomic_load_body -#undef make_atomic_store_body -#undef make_atomic_swap_body -#undef intptr - -#ifdef _atomic_h_cleanup_ -#include _atomic_h_cleanup_ -#undef _atomic_h_cleanup_ -#endif - -#define MY_ATOMIC_OK 0 -#define MY_ATOMIC_NOT_1CPU 1 -extern int my_atomic_initialize(); - -#endif - diff --git a/include/my_pthread.h b/include/my_pthread.h index e9256610ea7..eff6a677192 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -715,7 +715,7 @@ extern uint thd_lib_detected; The implementation is guaranteed to be thread safe, on all platforms. Note that the calling code should *not* assume the counter is protected by the mutex given, as the implementation of these helpers may change - to use my_atomic operations instead. + to use atomic operations instead. */ /* diff --git a/mysys/Makefile.am b/mysys/Makefile.am index 19017330654..e4c71f66079 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -30,8 +30,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \ mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \ my_malloc.c my_realloc.c my_once.c mulalloc.c \ my_alloc.c safemalloc.c my_new.cc \ - my_vle.c my_atomic.c \ - my_fopen.c my_fstream.c my_getsystime.c \ + my_vle.c my_fopen.c my_fstream.c my_getsystime.c \ my_error.c errors.c my_div.c my_messnc.c \ mf_format.c mf_same.c mf_dirname.c mf_fn_ext.c \ my_symlink.c my_symlink2.c \ diff --git a/mysys/my_atomic.c b/mysys/my_atomic.c deleted file mode 100644 index aa04d55f624..00000000000 --- a/mysys/my_atomic.c +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2006 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include -#include - -#ifndef HAVE_INLINE -/* the following will cause all inline functions to be instantiated */ -#define HAVE_INLINE -#undef STATIC_INLINE -#define STATIC_INLINE extern -#endif - -#include - -/* - checks that the current build of atomic ops - can run on this machine - - RETURN - ATOMIC_xxx values, see my_atomic.h -*/ -int my_atomic_initialize() -{ - compile_time_assert(sizeof(intptr) == sizeof(void *)); - /* currently the only thing worth checking is SMP/UP issue */ -#ifdef MY_ATOMIC_MODE_DUMMY - return my_getncpus() == 1 ? MY_ATOMIC_OK : MY_ATOMIC_NOT_1CPU; -#else - return MY_ATOMIC_OK; -#endif -} - diff --git a/storage/ibmdb2i/db2i_file.h b/storage/ibmdb2i/db2i_file.h index ff35a473b05..7b63b18c315 100644 --- a/storage/ibmdb2i/db2i_file.h +++ b/storage/ibmdb2i/db2i_file.h @@ -40,7 +40,6 @@ OF SUCH DAMAGE. #include "db2i_global.h" #include "db2i_ileBridge.h" #include "db2i_validatedPointer.h" -#include "my_atomic.h" #include "db2i_iconv.h" #include "db2i_charsetSupport.h" diff --git a/unittest/mysys/Makefile.am b/unittest/mysys/Makefile.am index f0ffc7a6720..b195017e914 100644 --- a/unittest/mysys/Makefile.am +++ b/unittest/mysys/Makefile.am @@ -23,12 +23,5 @@ LDADD = $(top_builddir)/unittest/mytap/libmytap.a \ noinst_PROGRAMS = bitmap-t base64-t -if NEED_THREAD -# my_atomic-t is used to check thread functions, so it is safe to -# ignore the file in non-threaded builds. -# In fact, it will not compile without thread support. -noinst_PROGRAMS += my_atomic-t -endif - # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/unittest/mysys/my_atomic-t.c b/unittest/mysys/my_atomic-t.c deleted file mode 100644 index f2bcd360508..00000000000 --- a/unittest/mysys/my_atomic-t.c +++ /dev/null @@ -1,205 +0,0 @@ -/* Copyright (C) 2006 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include -#include -#include -#include - -/* at least gcc 3.4.5 and 3.4.6 (but not 3.2.3) on RHEL */ -#if __GNUC__ == 3 && __GNUC_MINOR__ == 4 -#define GCC_BUG_WORKAROUND volatile -#else -#define GCC_BUG_WORKAROUND -#endif - -int32 a32,b32,c32; -my_atomic_rwlock_t rwl; - -pthread_attr_t thr_attr; -pthread_mutex_t mutex; -pthread_cond_t cond; -int N; - -/* add and sub a random number in a loop. Must get 0 at the end */ -pthread_handler_t test_atomic_add_handler(void *arg) -{ - int m=*(int *)arg; - GCC_BUG_WORKAROUND int32 x; - for (x=((int)((long)(&m))); m ; m--) - { - x=x*m+0x87654321; - my_atomic_rwlock_wrlock(&rwl); - my_atomic_add32(&a32, x); - my_atomic_rwlock_wrunlock(&rwl); - - my_atomic_rwlock_wrlock(&rwl); - my_atomic_add32(&a32, -x); - my_atomic_rwlock_wrunlock(&rwl); - } - pthread_mutex_lock(&mutex); - N--; - if (!N) pthread_cond_signal(&cond); - pthread_mutex_unlock(&mutex); - return 0; -} - -/* - 1. generate thread number 0..N-1 from b32 - 2. add it to a32 - 3. swap thread numbers in c32 - 4. (optionally) one more swap to avoid 0 as a result - 5. subtract result from a32 - must get 0 in a32 at the end -*/ -pthread_handler_t test_atomic_swap_handler(void *arg) -{ - int m=*(int *)arg; - int32 x; - - my_atomic_rwlock_wrlock(&rwl); - x=my_atomic_add32(&b32, 1); - my_atomic_rwlock_wrunlock(&rwl); - - my_atomic_rwlock_wrlock(&rwl); - my_atomic_add32(&a32, x); - my_atomic_rwlock_wrunlock(&rwl); - - for (; m ; m--) - { - my_atomic_rwlock_wrlock(&rwl); - x=my_atomic_swap32(&c32, x); - my_atomic_rwlock_wrunlock(&rwl); - } - - if (!x) - { - my_atomic_rwlock_wrlock(&rwl); - x=my_atomic_swap32(&c32, x); - my_atomic_rwlock_wrunlock(&rwl); - } - - my_atomic_rwlock_wrlock(&rwl); - my_atomic_add32(&a32, -x); - my_atomic_rwlock_wrunlock(&rwl); - - pthread_mutex_lock(&mutex); - N--; - if (!N) pthread_cond_signal(&cond); - pthread_mutex_unlock(&mutex); - return 0; -} - -/* - same as test_atomic_add_handler, but my_atomic_add32 is emulated with - (slower) my_atomic_cas32 -*/ -pthread_handler_t test_atomic_cas_handler(void *arg) -{ - int m=*(int *)arg, ok; - GCC_BUG_WORKAROUND int32 x,y; - for (x=((int)((long)(&m))); m ; m--) - { - my_atomic_rwlock_wrlock(&rwl); - y=my_atomic_load32(&a32); - my_atomic_rwlock_wrunlock(&rwl); - - x=x*m+0x87654321; - do { - my_atomic_rwlock_wrlock(&rwl); - ok=my_atomic_cas32(&a32, &y, y+x); - my_atomic_rwlock_wrunlock(&rwl); - } while (!ok); - do { - my_atomic_rwlock_wrlock(&rwl); - ok=my_atomic_cas32(&a32, &y, y-x); - my_atomic_rwlock_wrunlock(&rwl); - } while (!ok); - } - pthread_mutex_lock(&mutex); - N--; - if (!N) pthread_cond_signal(&cond); - pthread_mutex_unlock(&mutex); - return 0; -} - -void test_atomic(const char *test, pthread_handler handler, int n, int m) -{ - pthread_t t; - ulonglong now=my_getsystime(); - - a32= 0; - b32= 0; - c32= 0; - - diag("Testing %s with %d threads, %d iterations... ", test, n, m); - for (N=n ; n ; n--) - { - if (pthread_create(&t, &thr_attr, handler, &m) != 0) - { - diag("Could not create thread"); - a32= 1; - goto err; - } - } - - pthread_mutex_lock(&mutex); - while (N) - pthread_cond_wait(&cond, &mutex); - pthread_mutex_unlock(&mutex); - now=my_getsystime()-now; -err: - ok(a32 == 0, "tested %s in %g secs", test, ((double)now)/1e7); -} - -int main() -{ - int err; - MY_INIT("my_atomic-t.c"); - - diag("N CPUs: %d", my_getncpus()); - err= my_atomic_initialize(); - - plan(4); - ok(err == 0, "my_atomic_initialize() returned %d", err); - - pthread_attr_init(&thr_attr); - pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); - pthread_mutex_init(&mutex, 0); - pthread_cond_init(&cond, 0); - my_atomic_rwlock_init(&rwl); - -#ifdef HPUX11 -#define CYCLES 1000 -#else -#define CYCLES 10000 -#endif -#define THREADS 100 - test_atomic("my_atomic_add32", test_atomic_add_handler, THREADS, CYCLES); - test_atomic("my_atomic_swap32", test_atomic_swap_handler, THREADS, CYCLES); - test_atomic("my_atomic_cas32", test_atomic_cas_handler, THREADS, CYCLES); - /* - workaround until we know why it crashes randomly on some machine - (BUG#22320). - */ - sleep(2); - - pthread_mutex_destroy(&mutex); - pthread_cond_destroy(&cond); - pthread_attr_destroy(&thr_attr); - my_atomic_rwlock_destroy(&rwl); - return exit_status(); -} - From 19ea597a385c768fe749c48c2453036a3fb7d6d8 Mon Sep 17 00:00:00 2001 From: Jimmy Yang Date: Mon, 5 Jul 2010 19:26:38 -0700 Subject: [PATCH 041/118] Add innodb_bug53756-master.opt for innodb_bug53756 test. --- mysql-test/suite/innodb/r/innodb_bug53756.result | 2 +- mysql-test/suite/innodb/t/innodb_bug53756-master.opt | 1 + mysql-test/suite/innodb/t/innodb_bug53756.test | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 mysql-test/suite/innodb/t/innodb_bug53756-master.opt diff --git a/mysql-test/suite/innodb/r/innodb_bug53756.result b/mysql-test/suite/innodb/r/innodb_bug53756.result index 67797f9c90f..37453be8201 100644 --- a/mysql-test/suite/innodb/r/innodb_bug53756.result +++ b/mysql-test/suite/innodb/r/innodb_bug53756.result @@ -78,7 +78,7 @@ ROLLBACK; # connection default selects resulting data. # Delete of row 1 was committed. -# Dpdate of row 3 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; diff --git a/mysql-test/suite/innodb/t/innodb_bug53756-master.opt b/mysql-test/suite/innodb/t/innodb_bug53756-master.opt new file mode 100644 index 00000000000..425fda95086 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_bug53756-master.opt @@ -0,0 +1 @@ +--skip-stack-trace --skip-core-file diff --git a/mysql-test/suite/innodb/t/innodb_bug53756.test b/mysql-test/suite/innodb/t/innodb_bug53756.test index 85a09478486..8324f2640a2 100644 --- a/mysql-test/suite/innodb/t/innodb_bug53756.test +++ b/mysql-test/suite/innodb/t/innodb_bug53756.test @@ -114,7 +114,7 @@ ROLLBACK; --echo --echo # connection default selects resulting data. --echo # Delete of row 1 was committed. ---echo # Dpdate of row 3 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 From 9dba6ddfac25088c5b187f15370d949eb4a40896 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jul 2010 16:01:02 +0200 Subject: [PATCH 042/118] Raise version number after cloning 5.1.49 --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 74e575fad8c..a475185d880 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.49], [], [mysql]) +AC_INIT([MySQL Server], [5.1.50], [], [mysql]) AC_CONFIG_SRCDIR([sql/mysqld.cc]) AC_CANONICAL_SYSTEM From 04dd8ed0eb5f06f670f6e455b06c1173988a8f11 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Tue, 6 Jul 2010 15:36:31 -0300 Subject: [PATCH 043/118] Bug#52514: mysql 5.1 do_abi_check does not compile w/ gcc4.5 due to GCC preprocessor change Temporary workaround: disable abi_check if GCC >= 4.5 --- configure.in | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 539d597fd07..d47bf975fdd 100644 --- a/configure.in +++ b/configure.in @@ -475,7 +475,16 @@ if test "$GCC" != "yes" || expr "$CC" : ".*icc.*" then ABI_CHECK="" else - ABI_CHECK="abi_check" + # Workaround GCC >= 4.5 - See Bug#52514 + case `$CC -dumpversion` in + [[4-9]].[[5-9]]*) + AC_MSG_WARN([ABI check disabled (GCC >= 4.5)]) + ABI_CHECK="" + ;; + *) + ABI_CHECK="abi_check" + ;; + esac fi AC_SUBST(ABI_CHECK) From 6652fc78b7b5e1093a0670c3271fec7d626bb222 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Tue, 6 Jul 2010 19:31:54 -0300 Subject: [PATCH 044/118] Fix what is probably the result of a bad merge. No functional change. --- libmysql/libmysql.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index e0cc119bd16..362ad5de6c4 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -4421,6 +4421,7 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field) case MYSQL_TYPE_TIME: field->max_length= 15; /* 19:23:48.123456 */ param->skip_result= skip_result_with_length; + break; case MYSQL_TYPE_DATE: field->max_length= 10; /* 2003-11-11 */ param->skip_result= skip_result_with_length; From d9e7c4efb6bfebf625af629b3ca878f1d0dc7e02 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 7 Jul 2010 12:15:58 +0300 Subject: [PATCH 045/118] Addendum to the fix for bug #53095 (failing information_schema.test on windows) Since the original fix for this bug lowercases the search pattern it's not a good idea to copy the search pattern to the output instead of the real table name found (since, depending on the case mode these two names may differ in case). Fixed the infrmation_schema.test failure by making sure the actual table name of an inoformation schema table is passed instead of the lookup pattern even when the pattern doesn't contain wildcards. --- sql/sql_show.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 0eeb333f278..17fbf62b097 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2939,11 +2939,15 @@ make_table_name_list(THD *thd, List *table_names, LEX *lex, { if (with_i_schema) { + LEX_STRING *name; ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, lookup_field_vals->table_value.str); if (schema_table && !schema_table->hidden) { - if (table_names->push_back(&lookup_field_vals->table_value)) + if (!(name= + thd->make_lex_string(NULL, schema_table->table_name, + strlen(schema_table->table_name), TRUE)) || + table_names->push_back(name)) return 1; } } From 223f42b7158fee3b2464e76654142c7cd55a415e Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Wed, 7 Jul 2010 13:55:09 +0200 Subject: [PATCH 046/118] Bug #54117 crash in thr_multi_unlock, temporary table This crash occured after ALTER TABLE was used on a temporary transactional table locked by LOCK TABLES. Any later attempts to execute LOCK/UNLOCK TABLES, caused the server to crash. The reason for the crash was the list of locked tables would end up having a pointer to a free'd table instance. This happened because ALTER TABLE deleted the table without also removing the table reference from the locked tables list. This patch fixes the problem by making sure ALTER TABLE also removes the table from the locked tables list. Test case added to innodb_mysql.test. --- mysql-test/suite/innodb/r/innodb_mysql.result | 8 ++++++++ mysql-test/suite/innodb/t/innodb_mysql.test | 14 ++++++++++++++ sql/sql_table.cc | 5 +++++ 3 files changed, 27 insertions(+) diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result index ba37a46b62a..8765f58b120 100644 --- a/mysql-test/suite/innodb/r/innodb_mysql.result +++ b/mysql-test/suite/innodb/r/innodb_mysql.result @@ -2499,4 +2499,12 @@ ORDER BY f1 DESC LIMIT 5; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range f2,f4 f4 1 NULL 11 Using where DROP TABLE t1; +# +# Bug#54117 crash in thr_multi_unlock, temporary table +# +CREATE TEMPORARY TABLE t1(a INT) ENGINE = InnoDB; +LOCK TABLES t1 READ; +ALTER TABLE t1 COMMENT 'test'; +UNLOCK TABLES; +DROP TABLE t1; 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 d802b04487e..80f14d32eb8 100644 --- a/mysql-test/suite/innodb/t/innodb_mysql.test +++ b/mysql-test/suite/innodb/t/innodb_mysql.test @@ -737,4 +737,18 @@ ORDER BY f1 DESC LIMIT 5; DROP TABLE t1; + +--echo # +--echo # Bug#54117 crash in thr_multi_unlock, temporary table +--echo # + +CREATE TEMPORARY TABLE t1(a INT) ENGINE = InnoDB; + +LOCK TABLES t1 READ; +ALTER TABLE t1 COMMENT 'test'; +UNLOCK TABLES; + +DROP TABLE t1; + + --echo End of 5.1 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 50045ec6d90..6de461574d8 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -7387,6 +7387,11 @@ view_err: mysql_unlock_tables(thd, thd->lock); thd->lock=0; } + /* + If LOCK TABLES list is not empty and contains this table, + unlock the table and remove the table from this list. + */ + mysql_lock_remove(thd, thd->locked_tables, table, FALSE); /* Remove link to old table and rename the new one */ close_temporary_table(thd, table, 1, 1); /* Should pass the 'new_name' as we store table name in the cache */ From b2318bce9e8ed93d4566896c05806c6bf547b54f Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 7 Jul 2010 20:13:53 +0300 Subject: [PATCH 047/118] Merge the fix for Bug#49238 from SVN (without the unrelated whitespace changes): ------------------------------------------------------------------------ r7009 | jyang | 2010-04-29 20:44:56 +0300 (Thu, 29 Apr 2010) | 6 lines branches/5.0: Port fix for bug #49238 (Creating/Dropping a temporary table while at 1023 transactions will cause assert) from 5.1 to branches/5.1. Separate action for return value DB_TOO_MANY_CONCURRENT_TRXS from that of DB_MUST_GET_MORE_FILE_SPACE in row_drop_table_for_mysql(). ------------------------------------------------------------------------ --- innobase/row/row0mysql.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 75c54cec4b3..f636b505b6b 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -3335,20 +3335,13 @@ fputs(" InnoDB: You are trying to drop table ", stderr); err = trx->error_state; - if (err != DB_SUCCESS) { - ut_a(err == DB_OUT_OF_FILE_SPACE); - - err = DB_MUST_GET_MORE_FILE_SPACE; - - row_mysql_handle_errors(&err, trx, thr, NULL); - - ut_error; - } else { + switch (err) { ibool is_path; const char* name_or_path; + case DB_SUCCESS: space_id = table->space; - + if (table->dir_path_of_temp_table != NULL) { dir_path_of_temp_table = mem_strdup(table->dir_path_of_temp_table); @@ -3407,7 +3400,27 @@ fputs(" InnoDB: You are trying to drop table ", stderr); err = DB_ERROR; } } + break; + + case DB_TOO_MANY_CONCURRENT_TRXS: + /* Cannot even find a free slot for the + the undo log. We can directly exit here + and return the DB_TOO_MANY_CONCURRENT_TRXS + error. */ + break; + + case DB_OUT_OF_FILE_SPACE: + err = DB_MUST_GET_MORE_FILE_SPACE; + + row_mysql_handle_errors(&err, trx, thr, NULL); + + /* Fall through to raise error */ + + default: + /* No other possible error returns */ + ut_error; } + funct_exit: trx_commit_for_mysql(trx); From 0469e7df7ff4251c1afb8a832b34f84a74d4988f Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 7 Jul 2010 20:51:30 +0300 Subject: [PATCH 048/118] Add the innodb_plugin tests to "make dist". --- mysql-test/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 06aea68b52d..13e2388858f 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -100,6 +100,8 @@ TEST_DIRS = t r include std_data std_data/parts collections \ suite/rpl_ndb suite/rpl_ndb/t suite/rpl_ndb/r \ suite/parts suite/parts/t suite/parts/r suite/parts/inc \ suite/innodb suite/innodb/t suite/innodb/r suite/innodb/include \ + suite/innodb_plugin suite/innodb_plugin/t suite/innodb_plugin/r \ + suite/innodb_plugin/include \ suite/engines suite/engines/funcs suite/engines/iuds suite/engines/rr_trx \ suite/engines/funcs/r suite/engines/funcs/t suite/engines/iuds/r \ suite/engines/iuds/t suite/engines/rr_trx/include suite/engines/rr_trx/r \ From 625ae7185abcfc7042be225d4f8ef77806fc0803 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 8 Jul 2010 10:44:26 +0800 Subject: [PATCH 049/118] Postfix bug#48321 Fix the memory leak --- sql/log_event.cc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index 0e4d4bd512b..93d170e1510 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2396,6 +2396,8 @@ bool Query_log_event::write(IO_CACHE* file) Query_log_event::Query_log_event() :Log_event(), data_buf(0) { + memset(&user, 0, sizeof(user)); + memset(&host, 0, sizeof(host)); } @@ -2438,6 +2440,9 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, { time_t end_time; + memset(&user, 0, sizeof(user)); + memset(&host, 0, sizeof(host)); + error_code= errcode; time(&end_time); @@ -2783,13 +2788,13 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, CHECK_SPACE(pos, end, 1); user.length= *pos++; CHECK_SPACE(pos, end, user.length); - user.str= my_strndup((const char *)pos, user.length, MYF(0)); + user.str= (char *)pos; pos+= user.length; CHECK_SPACE(pos, end, 1); host.length= *pos++; CHECK_SPACE(pos, end, host.length); - host.str= my_strndup((const char *)pos, host.length, MYF(0)); + host.str= (char *)pos; pos+= host.length; } default: @@ -2805,12 +2810,16 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, time_zone_len + 1 + data_len + 1 + QUERY_CACHE_FLAGS_SIZE + + user.length + 1 + + host.length + 1 + db_len + 1, MYF(MY_WME)))) #else if (!(start= data_buf = (Log_event::Byte*) my_malloc(catalog_len + 1 + time_zone_len + 1 + - data_len + 1, + data_len + 1 + + user.length + 1 + + host.length + 1, MYF(MY_WME)))) #endif DBUG_VOID_RETURN; @@ -2833,6 +2842,11 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, if (time_zone_len) copy_str_and_move(&time_zone_str, &start, time_zone_len); + if (user.length > 0) + copy_str_and_move((const char **)&(user.str), &start, user.length); + if (host.length > 0) + copy_str_and_move((const char **)&(host.str), &start, host.length); + /** if time_zone_len or catalog_len are 0, then time_zone and catalog are uninitialized at this point. shouldn't they point to the From 9edde02ebb908497a7ad12a2c9e28380d1e30531 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Fri, 9 Jul 2010 01:09:31 +0200 Subject: [PATCH 050/118] Bug#52455: Subpar INSERT ON DUPLICATE KEY UPDATE performance with many partitions The handler function for reading one row from a specific index was not optimized in the partitioning handler since it used the default implementation. No test case since it is performance only, verified by hand. sql/ha_partition.cc: Implemented a optimized version of index_read_idx_map for the case when find flag == HA_READ_KEY_EXACT, which is the common case. sql/ha_partition.h: Declared ha_partition::index_read_idx_map --- sql/ha_partition.cc | 52 +++++++++++++++++++++++++++++++++++++++++++++ sql/ha_partition.h | 9 ++++++++ 2 files changed, 61 insertions(+) diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 60722f0100e..a87c7fbf7b8 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -4219,6 +4219,58 @@ int ha_partition::index_read_last_map(uchar *buf, const uchar *key, } +/* + Optimization of the default implementation to take advantage of dynamic + partition pruning. +*/ +int ha_partition::index_read_idx_map(uchar *buf, uint index, + const uchar *key, + key_part_map keypart_map, + enum ha_rkey_function find_flag) +{ + int error= HA_ERR_KEY_NOT_FOUND; + DBUG_ENTER("ha_partition::index_read_idx_map"); + + if (find_flag == HA_READ_KEY_EXACT) + { + uint part; + m_start_key.key= key; + m_start_key.keypart_map= keypart_map; + m_start_key.flag= find_flag; + m_start_key.length= calculate_key_len(table, index, m_start_key.key, + m_start_key.keypart_map); + + get_partition_set(table, buf, index, &m_start_key, &m_part_spec); + + /* How can it be more than one partition with the current use? */ + DBUG_ASSERT(m_part_spec.start_part == m_part_spec.end_part); + + for (part= m_part_spec.start_part; part <= m_part_spec.end_part; part++) + { + if (bitmap_is_set(&(m_part_info->used_partitions), part)) + { + error= m_file[part]->index_read_idx_map(buf, index, key, + keypart_map, find_flag); + if (error != HA_ERR_KEY_NOT_FOUND && + error != HA_ERR_END_OF_FILE) + break; + } + } + } + else + { + /* + If not only used with READ_EXACT, we should investigate if possible + to optimize for other find_flag's as well. + */ + DBUG_ASSERT(0); + /* fall back on the default implementation */ + error= handler::index_read_idx_map(buf, index, key, keypart_map, find_flag); + } + DBUG_RETURN(error); +} + + /* Read next record in a forward index scan diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 9f6d9e0a5ba..d8872d37a09 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -448,6 +448,15 @@ public: virtual int index_init(uint idx, bool sorted); virtual int index_end(); + /** + @breif + Positions an index cursor to the index specified in the hanlde. Fetches the + row if available. If the key value is null, begin at first key of the + index. + */ + virtual int index_read_idx_map(uchar *buf, uint index, const uchar *key, + key_part_map keypart_map, + enum ha_rkey_function find_flag); /* These methods are used to jump to next or previous entry in the index scan. There are also methods to jump to first and last entry. From 74f23d7e8fe99700c62749251c8844deec8c97ae Mon Sep 17 00:00:00 2001 From: Jimmy Yang Date: Fri, 9 Jul 2010 01:39:20 -0700 Subject: [PATCH 051/118] Fix bug #55039 Failing assertion: space_id > 0 in fil0fil.c. rb://396, approved by Sunny Bains. --- storage/innodb_plugin/dict/dict0crea.c | 18 +++++++++++++++--- storage/innodb_plugin/os/os0file.c | 12 ++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/storage/innodb_plugin/dict/dict0crea.c b/storage/innodb_plugin/dict/dict0crea.c index f185371bfca..09353c45c8c 100644 --- a/storage/innodb_plugin/dict/dict0crea.c +++ b/storage/innodb_plugin/dict/dict0crea.c @@ -240,17 +240,29 @@ dict_build_table_def_step( ibool is_path; mtr_t mtr; ulint space = 0; + ibool file_per_table; ut_ad(mutex_own(&(dict_sys->mutex))); table = node->table; - dict_hdr_get_new_id(&table->id, NULL, - srv_file_per_table ? &space : NULL); + /* Cache the global variable "srv_file_per_table" to + a local variable before using it. Please note + "srv_file_per_table" is not under dict_sys mutex + protection, and could be changed while executing + this function. So better to cache the current value + to a local variable, and all future reference to + "srv_file_per_table" should use this local variable. */ + file_per_table = srv_file_per_table; + + dict_hdr_get_new_id(&table->id, NULL, NULL); thr_get_trx(thr)->table_id = table->id; - if (srv_file_per_table) { + if (file_per_table) { + /* Get a new space id if srv_file_per_table is set */ + dict_hdr_get_new_id(NULL, NULL, &space); + if (UNIV_UNLIKELY(space == ULINT_UNDEFINED)) { return(DB_ERROR); } diff --git a/storage/innodb_plugin/os/os0file.c b/storage/innodb_plugin/os/os0file.c index b244e3974b3..9f937b9def2 100644 --- a/storage/innodb_plugin/os/os0file.c +++ b/storage/innodb_plugin/os/os0file.c @@ -1339,7 +1339,11 @@ try_again: /* When srv_file_per_table is on, file creation failure may not be critical to the whole instance. Do not crash the server in - case of unknown errors. */ + case of unknown errors. + Please note "srv_file_per_table" is a global variable with + no explicit synchronization protection. It could be + changed during this execution path. It might not have the + same value as the one when building the table definition */ if (srv_file_per_table) { retry = os_file_handle_error_no_exit(name, create_mode == OS_FILE_CREATE ? @@ -1426,7 +1430,11 @@ try_again: /* When srv_file_per_table is on, file creation failure may not be critical to the whole instance. Do not crash the server in - case of unknown errors. */ + case of unknown errors. + Please note "srv_file_per_table" is a global variable with + no explicit synchronization protection. It could be + changed during this execution path. It might not have the + same value as the one when building the table definition */ if (srv_file_per_table) { retry = os_file_handle_error_no_exit(name, create_mode == OS_FILE_CREATE ? From 013136364c95b7bcc5a987dd301b042f31dab1f9 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Fri, 9 Jul 2010 14:39:47 +0400 Subject: [PATCH 052/118] Bug#54416 MAX from JOIN with HAVING returning NULL with 5.1 and Empty set The problem there is that HAVING condition evaluates const parts of condition despite the condition has references on aggregate functions. Table t1 became const tables after make_join_statistics and table1.pk = 1, HAVING is transformed into MAX(1) < 7 and taken away from HAVING. The fix is to skip evaluation of HAVING conts parts if HAVING condition has references on aggregate functions. mysql-test/r/having.result: test case mysql-test/t/having.test: test case sql/sql_select.cc: skip evaluation of HAVING conts parts if HAVING condition has references on aggregate functions. --- mysql-test/r/having.result | 16 ++++++++++++++++ mysql-test/t/having.test | 21 +++++++++++++++++++++ sql/sql_select.cc | 2 +- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index 54293e9d02e..cd1b4ae0218 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -530,3 +530,19 @@ MAX(t2.f2) NULL DROP TABLE t1,t2; End of 5.0 tests +# +# Bug#54416 MAX from JOIN with HAVING returning NULL with 5.1 and Empty set +# +CREATE TABLE t1 (f1 INT(11), f2 VARCHAR(1), PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (1,'f'); +CREATE TABLE t2 (f1 INT(11), f2 VARCHAR(1)); +INSERT INTO t2 VALUES (2,'m'); +INSERT INTO t2 VALUES (3,'m'); +INSERT INTO t2 VALUES (11,NULL); +INSERT INTO t2 VALUES (12,'k'); +SELECT MAX(t1.f1) field1 +FROM t1 JOIN t2 ON t2.f2 LIKE 'x' +HAVING field1 < 7; +field1 +DROP TABLE t1,t2; +End of 5.1 tests diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test index 65bf9518a5c..c808e747523 100644 --- a/mysql-test/t/having.test +++ b/mysql-test/t/having.test @@ -544,3 +544,24 @@ ORDER BY t1.f2; DROP TABLE t1,t2; --echo End of 5.0 tests + +--echo # +--echo # Bug#54416 MAX from JOIN with HAVING returning NULL with 5.1 and Empty set +--echo # + +CREATE TABLE t1 (f1 INT(11), f2 VARCHAR(1), PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (1,'f'); + +CREATE TABLE t2 (f1 INT(11), f2 VARCHAR(1)); +INSERT INTO t2 VALUES (2,'m'); +INSERT INTO t2 VALUES (3,'m'); +INSERT INTO t2 VALUES (11,NULL); +INSERT INTO t2 VALUES (12,'k'); + +SELECT MAX(t1.f1) field1 +FROM t1 JOIN t2 ON t2.f2 LIKE 'x' +HAVING field1 < 7; + +DROP TABLE t1,t2; + +--echo End of 5.1 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b20726fc151..fe391b50bb9 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1132,7 +1132,7 @@ JOIN::optimize() elements may be lost during further having condition transformation in JOIN::exec. */ - if (having && const_table_map) + if (having && const_table_map && !having->with_sum_func) { having->update_used_tables(); having= remove_eq_conds(thd, having, &having_value); From 70b02d3aedb5c7ddf84720d0dd54e6f74c797788 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Fri, 9 Jul 2010 13:15:26 +0200 Subject: [PATCH 053/118] Bug#52517: Regression in ROW level replication performance with partitions In bug-28430 HA_PRIMARY_KEY_REQUIRED_FOR_POSITION was disabled in the partitioning engine in the first patch, That bug was later fixed a second time, but that flag was not removed. No need to disable this flag, as it leads to bad choise in row replication. sql/ha_partition.h: Not disabling HA_PRIMARY_KEY_REQUIRED_FOR_POSITION flag. Updated comment (has nothing to do with hidden key. sql/handler.h: Updated comments to about HA_PRIMARY_KEY_REQUIRED_FOR_POSITION. --- sql/ha_partition.h | 6 +----- sql/handler.h | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 9f6d9e0a5ba..351d3d6b247 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -53,8 +53,7 @@ typedef struct st_ha_data_partition HA_CAN_FULLTEXT | \ HA_DUPLICATE_POS | \ HA_CAN_SQL_HANDLER | \ - HA_CAN_INSERT_DELAYED | \ - HA_PRIMARY_KEY_REQUIRED_FOR_POSITION) + HA_CAN_INSERT_DELAYED) class ha_partition :public handler { private: @@ -766,9 +765,6 @@ public: HA_PRIMARY_KEY_REQUIRED_FOR_POSITION: Does the storage engine need a PK for position? - Used with hidden primary key in InnoDB. - Hidden primary keys cannot be supported by partitioning, since the - partitioning expressions columns must be a part of the primary key. (InnoDB) HA_FILE_BASED is always set for partition handler since we use a diff --git a/sql/handler.h b/sql/handler.h index d9dfd4f0707..3c7cba747fa 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -93,7 +93,10 @@ #define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15) /* If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position() - uses a primary key. Without primary key, we can't call position(). + uses a primary key given by the record argument. + Without primary key, we can't call position(). + If not set, the position is returned as the current rows position + regardless of what argument is given. */ #define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16) #define HA_CAN_RTREEKEYS (1 << 17) @@ -1446,10 +1449,9 @@ public: virtual int rnd_next(uchar *buf)=0; virtual int rnd_pos(uchar * buf, uchar *pos)=0; /** - One has to use this method when to find - random position by record as the plain - position() call doesn't work for some - handlers for random position. + This function only works for handlers having + HA_PRIMARY_KEY_REQUIRED_FOR_POSITION set. + It will return the row with the PK given in the record argument. */ virtual int rnd_pos_by_record(uchar *record) { @@ -1467,6 +1469,12 @@ public: { return HA_ERR_WRONG_COMMAND; } virtual ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key) { return (ha_rows) 10; } + /* + If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, then it sets ref + (reference to the row, aka position, with the primary key given in + the record). + Otherwise it set ref to the current row. + */ virtual void position(const uchar *record)=0; virtual int info(uint)=0; // see my_base.h for full description virtual void get_dynamic_partition_info(PARTITION_INFO *stat_info, From cd37b73fe5107098c669fcbf569e9f20de013141 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 9 Jul 2010 08:37:51 -0300 Subject: [PATCH 054/118] Bug#53445: Build with -Wall and fix warnings that it generates Introduce a MySQL maintainer/developer mode that enables a set of warning options for the C/C++ compiler. This mode is intended to help improve the overall quality of the code. The warning options are: C_WARNINGS="-Wall -Wextra -Wunused -Wwrite-strings -Werror" CXX_WARNINGS="$C_WARNINGS -Wno-unused-parameter" Since -Wall is essentially a moving target, autoconf checks are not run with warning options enabled, in particualr -Werror. This decision might be revisited in the future. The patch also fixes a mistake in the makefiles, where automake CXXFLAGS would be set to CFLAGS. config/ac-macros/maintainer.m4: Add a set of default compiler flags used when in maintainer mode. configure.in: Hook into the maintainer mode. Disabled by default. --- config/ac-macros/maintainer.m4 | 66 +++++++++++++++++++++++++++++++ configure.in | 9 +++++ plugin/daemon_example/Makefile.am | 4 +- storage/archive/Makefile.am | 4 +- storage/blackhole/Makefile.am | 4 +- storage/csv/Makefile.am | 4 +- storage/example/Makefile.am | 4 +- storage/federated/Makefile.am | 4 +- storage/ibmdb2i/Makefile.am | 4 +- storage/innobase/Makefile.am | 4 +- storage/innodb_plugin/Makefile.am | 4 +- 11 files changed, 93 insertions(+), 18 deletions(-) create mode 100644 config/ac-macros/maintainer.m4 diff --git a/config/ac-macros/maintainer.m4 b/config/ac-macros/maintainer.m4 new file mode 100644 index 00000000000..6aa1d166f2a --- /dev/null +++ b/config/ac-macros/maintainer.m4 @@ -0,0 +1,66 @@ +# +# Control aspects of the development environment which are +# specific to MySQL maintainers and developers. +# +AC_DEFUN([MY_MAINTAINER_MODE], [ + AC_MSG_CHECKING([whether to enable the maintainer-specific development environment]) + AC_ARG_ENABLE([mysql-maintainer-mode], + [AS_HELP_STRING([--enable-mysql-maintainer-mode], + [Enable a MySQL maintainer-specific development environment])], + [USE_MYSQL_MAINTAINER_MODE=$enableval], + [USE_MYSQL_MAINTAINER_MODE=no]) + AC_MSG_RESULT([$USE_MYSQL_MAINTAINER_MODE]) +]) + +# Set warning options required under 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" + CXX_WARNINGS="${C_WARNINGS} -Wno-unused-parameter" + ]) + + # Test whether the warning options work. + # Test C options + AS_IF([test -n "$C_WARNINGS"], [ + save_CFLAGS="$CFLAGS" + AC_MSG_CHECKING([whether to use C warning options ${C_WARNINGS}]) + AC_LANG_PUSH(C) + CFLAGS="$CFLAGS ${C_WARNINGS}" + AC_LANG_WERROR + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [myac_c_warning_flags=yes], + [myac_c_warning_flags=no]) + AC_LANG_POP() + AC_MSG_RESULT([$myac_c_warning_flags]) + CFLAGS="$save_CFLAGS" + ]) + + # Test C++ options + AS_IF([test -n "$CXX_WARNINGS"], [ + save_CXXFLAGS="$CXXFLAGS" + AC_MSG_CHECKING([whether to use C++ warning options ${CXX_WARNINGS}]) + AC_LANG_PUSH(C++) + CXXFLAGS="$CXXFLAGS ${CXX_WARNINGS}" + AC_LANG_WERROR + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [myac_cxx_warning_flags=yes], + [myac_cxx_warning_flags=no]) + AC_LANG_POP() + AC_MSG_RESULT([$myac_cxx_warning_flags]) + CXXFLAGS="$save_CXXFLAGS" + ]) + + # Set compile flag variables. + AS_IF([test "$myac_c_warning_flags" = "yes"], [ + AM_CFLAGS="${AM_CFLAGS} ${C_WARNINGS}" + AC_SUBST([AM_CFLAGS])]) + AS_IF([test "$myac_cxx_warning_flags" = "yes"], [ + AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS}" + AC_SUBST([AM_CXXFLAGS])]) +]) + + +# Set compiler flags required under maintainer mode. +AC_DEFUN([MY_MAINTAINER_MODE_SETUP], [ + AS_IF([test "$USE_MYSQL_MAINTAINER_MODE" = "yes"], + [MY_MAINTAINER_MODE_WARNINGS]) +]) diff --git a/configure.in b/configure.in index d47bf975fdd..bc1d7df6703 100644 --- a/configure.in +++ b/configure.in @@ -65,6 +65,7 @@ MYSQL_TCP_PORT_DEFAULT=3306 MYSQL_UNIX_ADDR_DEFAULT="/tmp/mysql.sock" dnl Include m4 +sinclude(config/ac-macros/maintainer.m4) sinclude(config/ac-macros/alloca.m4) sinclude(config/ac-macros/check_cpu.m4) sinclude(config/ac-macros/character_sets.m4) @@ -102,6 +103,8 @@ AC_SUBST(SHARED_LIB_MAJOR_VERSION) AC_SUBST(SHARED_LIB_VERSION) AC_SUBST(AVAILABLE_LANGUAGES) +# Whether the maintainer mode should be enabled. +MY_MAINTAINER_MODE # Canonicalize the configuration name. @@ -2889,6 +2892,12 @@ do done AC_SUBST(sql_union_dirs) +# +# Setup maintainer mode options by the end to not disturb +# system and other checks. +# +MY_MAINTAINER_MODE_SETUP + # Some usefull subst AC_SUBST(CC) AC_SUBST(GXX) diff --git a/plugin/daemon_example/Makefile.am b/plugin/daemon_example/Makefile.am index c5414cd46c7..02310699396 100644 --- a/plugin/daemon_example/Makefile.am +++ b/plugin/daemon_example/Makefile.am @@ -27,14 +27,14 @@ INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \ EXTRA_LTLIBRARIES = libdaemon_example.la pkgplugin_LTLIBRARIES = @plugin_daemon_example_shared_target@ libdaemon_example_la_LDFLAGS = -module -rpath $(pkgplugindir) -libdaemon_example_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +libdaemon_example_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN libdaemon_example_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN libdaemon_example_la_SOURCES = daemon_example.cc EXTRA_LIBRARIES = libdaemon_example.a noinst_LIBRARIES = @plugin_daemon_example_static_target@ -libdaemon_example_a_CXXFLAGS = $(AM_CFLAGS) +libdaemon_example_a_CXXFLAGS = $(AM_CXXFLAGS) libdaemon_example_a_CFLAGS = $(AM_CFLAGS) libdaemon_example_a_SOURCES= daemon_example.cc diff --git a/storage/archive/Makefile.am b/storage/archive/Makefile.am index d092f091798..94e98c468ad 100644 --- a/storage/archive/Makefile.am +++ b/storage/archive/Makefile.am @@ -36,14 +36,14 @@ noinst_PROGRAMS = archive_test archive_reader EXTRA_LTLIBRARIES = ha_archive.la pkgplugin_LTLIBRARIES = @plugin_archive_shared_target@ ha_archive_la_LDFLAGS = -module -rpath $(pkgplugindir) -ha_archive_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_archive_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_archive_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_archive_la_SOURCES = ha_archive.cc azio.c EXTRA_LIBRARIES = libarchive.a noinst_LIBRARIES = @plugin_archive_static_target@ -libarchive_a_CXXFLAGS = $(AM_CFLAGS) +libarchive_a_CXXFLAGS = $(AM_CXXFLAGS) libarchive_a_CFLAGS = $(AM_CFLAGS) libarchive_a_SOURCES = ha_archive.cc azio.c diff --git a/storage/blackhole/Makefile.am b/storage/blackhole/Makefile.am index db4f67cf847..2d27261b671 100644 --- a/storage/blackhole/Makefile.am +++ b/storage/blackhole/Makefile.am @@ -35,14 +35,14 @@ noinst_HEADERS = ha_blackhole.h EXTRA_LTLIBRARIES = ha_blackhole.la pkgplugin_LTLIBRARIES = @plugin_blackhole_shared_target@ ha_blackhole_la_LDFLAGS=-module -rpath $(pkgplugindir) -ha_blackhole_la_CXXFLAGS=$(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_blackhole_la_CXXFLAGS=$(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_blackhole_la_CFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_blackhole_la_SOURCES=ha_blackhole.cc EXTRA_LIBRARIES = libblackhole.a noinst_LIBRARIES = @plugin_blackhole_static_target@ -libblackhole_a_CXXFLAGS=$(AM_CFLAGS) +libblackhole_a_CXXFLAGS=$(AM_CXXFLAGS) libblackhole_a_CFLAGS = $(AM_CFLAGS) libblackhole_a_SOURCES= ha_blackhole.cc diff --git a/storage/csv/Makefile.am b/storage/csv/Makefile.am index 07ffac88a96..3a00ae85e20 100644 --- a/storage/csv/Makefile.am +++ b/storage/csv/Makefile.am @@ -32,12 +32,12 @@ noinst_HEADERS = ha_tina.h transparent_file.h EXTRA_LTLIBRARIES = ha_csv.la pkglib_LTLIBRARIES = @plugin_csv_shared_target@ ha_csv_la_LDFLAGS = -module -rpath $(MYSQLLIBdir) -ha_csv_la_CXXFLAGS = $(AM_CFLAGS) -DMYSQL_PLUGIN +ha_csv_la_CXXFLAGS = $(AM_CXXFLAGS) -DMYSQL_PLUGIN ha_csv_la_SOURCES = transparent_file.cc ha_tina.cc EXTRA_LIBRARIES = libcsv.a noinst_LIBRARIES = @plugin_csv_static_target@ -libcsv_a_CXXFLAGS = $(AM_CFLAGS) +libcsv_a_CXXFLAGS = $(AM_CXXFLAGS) libcsv_a_SOURCES = transparent_file.cc ha_tina.cc EXTRA_DIST = CMakeLists.txt plug.in diff --git a/storage/example/Makefile.am b/storage/example/Makefile.am index 4b2f165377c..1c87adbbb4c 100644 --- a/storage/example/Makefile.am +++ b/storage/example/Makefile.am @@ -35,14 +35,14 @@ noinst_HEADERS = ha_example.h EXTRA_LTLIBRARIES = ha_example.la pkgplugin_LTLIBRARIES = @plugin_example_shared_target@ ha_example_la_LDFLAGS = -module -rpath $(pkgplugindir) -ha_example_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_example_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_example_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_example_la_SOURCES = ha_example.cc EXTRA_LIBRARIES = libexample.a noinst_LIBRARIES = @plugin_example_static_target@ -libexample_a_CXXFLAGS = $(AM_CFLAGS) +libexample_a_CXXFLAGS = $(AM_CXXFLAGS) libexample_a_CFLAGS = $(AM_CFLAGS) libexample_a_SOURCES= ha_example.cc diff --git a/storage/federated/Makefile.am b/storage/federated/Makefile.am index 64ea0207017..eab8c0c3929 100644 --- a/storage/federated/Makefile.am +++ b/storage/federated/Makefile.am @@ -35,14 +35,14 @@ noinst_HEADERS = ha_federated.h EXTRA_LTLIBRARIES = ha_federated.la pkgplugin_LTLIBRARIES = @plugin_federated_shared_target@ ha_federated_la_LDFLAGS = -module -rpath $(pkgplugindir) -ha_federated_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_federated_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_federated_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_federated_la_SOURCES = ha_federated.cc EXTRA_LIBRARIES = libfederated.a noinst_LIBRARIES = @plugin_federated_static_target@ -libfederated_a_CXXFLAGS = $(AM_CFLAGS) +libfederated_a_CXXFLAGS = $(AM_CXXFLAGS) libfederated_a_CFLAGS = $(AM_CFLAGS) libfederated_a_SOURCES= ha_federated.cc diff --git a/storage/ibmdb2i/Makefile.am b/storage/ibmdb2i/Makefile.am index 768ca15f4cf..b9602e392e0 100644 --- a/storage/ibmdb2i/Makefile.am +++ b/storage/ibmdb2i/Makefile.am @@ -34,7 +34,7 @@ EXTRA_LTLIBRARIES = ha_ibmdb2i.la pkgplugin_LTLIBRARIES = @plugin_ibmdb2i_shared_target@ ha_ibmdb2i_la_LIBADD = -liconv ha_ibmdb2i_la_LDFLAGS = -module -rpath $(MYSQLLIBdir) -ha_ibmdb2i_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_ibmdb2i_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_ibmdb2i_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_ibmdb2i_la_SOURCES = ha_ibmdb2i.cc db2i_ileBridge.cc db2i_conversion.cc \ db2i_blobCollection.cc db2i_file.cc db2i_charsetSupport.cc \ @@ -44,7 +44,7 @@ ha_ibmdb2i_la_SOURCES = ha_ibmdb2i.cc db2i_ileBridge.cc db2i_conversion.cc \ EXTRA_LIBRARIES = libibmdb2i.a noinst_LIBRARIES = @plugin_ibmdb2i_static_target@ -libibmdb2i_a_CXXFLAGS = $(AM_CFLAGS) +libibmdb2i_a_CXXFLAGS = $(AM_CXXFLAGS) libibmdb2i_a_CFLAGS = $(AM_CFLAGS) libibmdb2i_a_SOURCES= $(ha_ibmdb2i_la_SOURCES) diff --git a/storage/innobase/Makefile.am b/storage/innobase/Makefile.am index a597e3c24e4..2c93a3a409a 100644 --- a/storage/innobase/Makefile.am +++ b/storage/innobase/Makefile.am @@ -156,14 +156,14 @@ libinnobase_a_SOURCES= btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c \ ut/ut0ut.c ut/ut0vec.c ut/ut0wqueue.c \ handler/ha_innodb.cc -libinnobase_a_CXXFLAGS= $(AM_CFLAGS) +libinnobase_a_CXXFLAGS= $(AM_CXXFLAGS) libinnobase_a_CFLAGS= $(AM_CFLAGS) EXTRA_LTLIBRARIES= ha_innodb.la pkgplugin_LTLIBRARIES= @plugin_innobase_shared_target@ ha_innodb_la_LDFLAGS= -module -rpath $(pkgplugindir) -ha_innodb_la_CXXFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS) +ha_innodb_la_CXXFLAGS= $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS) ha_innodb_la_CFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS) ha_innodb_la_SOURCES= $(libinnobase_a_SOURCES) diff --git a/storage/innodb_plugin/Makefile.am b/storage/innodb_plugin/Makefile.am index 1d0dd936895..f11e5db01f4 100644 --- a/storage/innodb_plugin/Makefile.am +++ b/storage/innodb_plugin/Makefile.am @@ -325,14 +325,14 @@ libinnobase_a_SOURCES= \ ut/ut0vec.c \ ut/ut0wqueue.c -libinnobase_a_CXXFLAGS= $(AM_CFLAGS) +libinnobase_a_CXXFLAGS= $(AM_CXXFLAGS) libinnobase_a_CFLAGS= $(AM_CFLAGS) EXTRA_LTLIBRARIES= ha_innodb_plugin.la pkgplugin_LTLIBRARIES= @plugin_innodb_plugin_shared_target@ ha_innodb_plugin_la_LDFLAGS= -module -rpath $(pkgplugindir) -ha_innodb_plugin_la_CXXFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS) +ha_innodb_plugin_la_CXXFLAGS= $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS) ha_innodb_plugin_la_CFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS) ha_innodb_plugin_la_SOURCES= $(libinnobase_a_SOURCES) From 11fae04527098cb6c266eae41188504bd22a5b52 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 9 Jul 2010 09:00:17 -0300 Subject: [PATCH 055/118] Bug#45288: pb2 returns a lot of compilation warnings on linux Although the C standard mandates that sprintf return the number of bytes written, some very ancient systems (i.e. SunOS 4) returned a pointer to the buffer instead. Since these systems are not supported anymore and are hopefully long dead by now, simply remove the portability wrapper that dealt with this discrepancy. The autoconf check was causing trouble with GCC. --- client/mysqlbinlog.cc | 2 +- client/mysqlcheck.c | 3 +-- client/sql_string.cc | 5 +++-- configure.in | 34 ------------------------------- include/my_global.h | 11 ---------- sql-common/my_time.c | 23 +++++++-------------- sql/field.cc | 10 ++++----- sql/item_timefunc.cc | 24 ++++++++-------------- sql/log_event.cc | 32 ++++++++++++++--------------- sql/my_decimal.cc | 8 ++++---- sql/partition_info.cc | 6 +++--- sql/protocol.cc | 24 ++++++++-------------- sql/sql_acl.cc | 10 ++++----- sql/sql_analyse.cc | 10 ++++----- sql/sql_show.cc | 2 +- sql/sql_string.cc | 5 +++-- storage/federated/ha_federated.cc | 17 ++++++---------- strings/decimal.c | 2 +- tests/mysql_client_test.c | 26 +++++++++++------------ 19 files changed, 90 insertions(+), 164 deletions(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 30bdb58153f..dec3f142798 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -437,7 +437,7 @@ Exit_status Load_log_processor::process_first_event(const char *bname, ptr= fname + target_dir_name_len; memcpy(ptr,bname,blen); ptr+= blen; - ptr+= my_sprintf(ptr, (ptr, "-%x", file_id)); + ptr+= sprintf(ptr, "-%x", file_id); if ((file= create_unique_file(fname,ptr)) < 0) { diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 4183ab1dd5e..78c4b79085e 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -703,8 +703,7 @@ static int handle_request_for_tables(char *tables, uint length) if (opt_all_in_1) { /* No backticks here as we added them before */ - query_length= my_sprintf(query, - (query, "%s TABLE %s %s", op, tables, options)); + query_length= sprintf(query, "%s TABLE %s %s", op, tables, options); } else { diff --git a/client/sql_string.cc b/client/sql_string.cc index dc6147b563f..50fb4a5b777 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -122,7 +122,8 @@ bool String::set(double num,uint decimals, CHARSET_INFO *cs) str_charset=cs; if (decimals >= NOT_FIXED_DEC) { - uint32 len= my_sprintf(buff,(buff, "%.15g",num));// Enough for a DATETIME + // Enough for a DATETIME + uint32 len= sprintf(buff, "%.15g", num); return copy(buff, len, &my_charset_latin1, cs, &dummy_errors); } #ifdef HAVE_FCONVERT @@ -674,7 +675,7 @@ void String::qs_append(const char *str, uint32 len) void String::qs_append(double d) { char *buff = Ptr + str_length; - str_length+= my_sprintf(buff, (buff, "%.15g", d)); + str_length+= sprintf(buff, buff, "%.15g", d); } void String::qs_append(double *d) diff --git a/configure.in b/configure.in index bc1d7df6703..0264c351b07 100644 --- a/configure.in +++ b/configure.in @@ -278,40 +278,6 @@ AC_CHECK_PROGS(YACC, ['bison -y -p MYSQL']) AC_CHECK_PROG(PDFMANUAL, pdftex, manual.pdf) AC_CHECK_PROG(DVIS, tex, manual.dvi) -#check the return type of sprintf -AC_MSG_CHECKING("return type of sprintf") -AC_TRY_RUN([ - int main() - { - char* s = "hello"; - char buf[6]; - if((int)sprintf(buf, s) == strlen(s)) - return 0; - - return -1; - } - ], - [AC_DEFINE(SPRINTF_RETURNS_INT, [1], [POSIX sprintf]) - AC_MSG_RESULT("int")], - [AC_TRY_RUN([ - int main() - { - char* s = "hello"; - char buf[6]; - if((char*)sprintf(buf,s) == buf + strlen(s)) - return 0; - return -1; - } ], - [AC_DEFINE(SPRINTF_RETURNS_PTR, [1], [Broken sprintf]) - AC_MSG_RESULT("ptr")], - [AC_DEFINE(SPRINTF_RETURNS_GARBAGE, [1], [Broken sprintf]) - AC_MSG_RESULT("garbage")] - )], - # Cross compile, assume POSIX - [AC_DEFINE(SPRINTF_RETURNS_INT, [1], [POSIX sprintf]) - AC_MSG_RESULT("int (we assume)")] -) - AC_PATH_PROG(uname_prog, uname, no) # We should go through this and put all the explictly system dependent diff --git a/include/my_global.h b/include/my_global.h index 572df6a584d..f03ed665d5a 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1467,17 +1467,6 @@ do { doubleget_union _tmp; \ #endif /* WORDS_BIGENDIAN */ -/* sprintf does not always return the number of bytes :- */ -#ifdef SPRINTF_RETURNS_INT -#define my_sprintf(buff,args) sprintf args -#else -#ifdef SPRINTF_RETURNS_PTR -#define my_sprintf(buff,args) ((int)(sprintf args - buff)) -#else -#define my_sprintf(buff,args) ((ulong) sprintf args, (ulong) strlen(buff)) -#endif -#endif - #ifndef THREAD #define thread_safe_increment(V,L) (V)++ #define thread_safe_decrement(V,L) (V)-- diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 95078a50097..c4e917801d5 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -1024,30 +1024,21 @@ void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type) int my_time_to_str(const MYSQL_TIME *l_time, char *to) { uint extra_hours= 0; - return my_sprintf(to, (to, "%s%02u:%02u:%02u", - (l_time->neg ? "-" : ""), - extra_hours+ l_time->hour, - l_time->minute, - l_time->second)); + return sprintf(to, "%s%02u:%02u:%02u", (l_time->neg ? "-" : ""), + extra_hours+ l_time->hour, l_time->minute, l_time->second); } int my_date_to_str(const MYSQL_TIME *l_time, char *to) { - return my_sprintf(to, (to, "%04u-%02u-%02u", - l_time->year, - l_time->month, - l_time->day)); + return sprintf(to, "%04u-%02u-%02u", + l_time->year, l_time->month, l_time->day); } int my_datetime_to_str(const MYSQL_TIME *l_time, char *to) { - return my_sprintf(to, (to, "%04u-%02u-%02u %02u:%02u:%02u", - l_time->year, - l_time->month, - l_time->day, - l_time->hour, - l_time->minute, - l_time->second)); + return sprintf(to, "%04u-%02u-%02u %02u:%02u:%02u", + l_time->year, l_time->month, l_time->day, + l_time->hour, l_time->minute, l_time->second); } diff --git a/sql/field.cc b/sql/field.cc index 2229bc19b3c..c648b53e139 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2277,7 +2277,7 @@ int Field_decimal::store(double nr) snprintf(buff,sizeof(buff)-1, "%.*f",(int) dec,nr); length= strlen(buff); #else - length= my_sprintf(buff,(buff,"%.*f",dec,nr)); + length= sprintf(buff, "%.*f", dec, nr); #endif if (length > field_length) @@ -4259,7 +4259,7 @@ String *Field_float::val_str(String *val_buffer, snprintf(to,to_length-1,"%.*f",dec,nr); to=strend(to); #else - to+= my_sprintf(to,(to,"%.*f",dec,nr)); + to+= sprintf(to, "%.*f", dec, nr); #endif #endif } @@ -4617,7 +4617,7 @@ String *Field_double::val_str(String *val_buffer, snprintf(to,to_length-1,"%.*f",dec,nr); to=strend(to); #else - to+= my_sprintf(to,(to,"%.*f",dec,nr)); + to+= sprintf(to, "%.*f", dec, nr); #endif #endif } @@ -6461,7 +6461,7 @@ int Field_str::store(double nr) /* Limit precision to DBL_DIG to avoid garbage past significant digits */ set_if_smaller(digits, DBL_DIG); - length= (uint) my_sprintf(buff, (buff, "%-.*g", digits, nr)); + length= (uint) sprintf(buff, "%-.*g", digits, nr); #ifdef __WIN__ /* @@ -10419,7 +10419,7 @@ Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code, { /* DBL_DIG is enough to print '-[digits].E+###' */ char str_nr[DBL_DIG + 8]; - uint str_len= my_sprintf(str_nr, (str_nr, "%g", nr)); + uint str_len= sprintf(str_nr, "%g", nr); make_truncated_value_warning(thd, level, str_nr, str_len, ts_type, field_name); } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 4248c2e6b4f..dff4d20f347 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -754,13 +754,11 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, str->append(hours_i < 12 ? "AM" : "PM",2); break; case 'r': - length= my_sprintf(intbuff, - (intbuff, - ((l_time->hour % 24) < 12) ? - "%02d:%02d:%02d AM" : "%02d:%02d:%02d PM", - (l_time->hour+11)%12+1, - l_time->minute, - l_time->second)); + length= sprintf(intbuff, ((l_time->hour % 24) < 12) ? + "%02d:%02d:%02d AM" : "%02d:%02d:%02d PM", + (l_time->hour+11)%12+1, + l_time->minute, + l_time->second); str->append(intbuff, length); break; case 'S': @@ -769,12 +767,8 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, str->append_with_prefill(intbuff, length, 2, '0'); break; case 'T': - length= my_sprintf(intbuff, - (intbuff, - "%02d:%02d:%02d", - l_time->hour, - l_time->minute, - l_time->second)); + length= sprintf(intbuff, "%02d:%02d:%02d", + l_time->hour, l_time->minute, l_time->second); str->append(intbuff, length); break; case 'U': @@ -2985,12 +2979,12 @@ String *Item_func_maketime::val_str(String *str) char buf[28]; char *ptr= longlong10_to_str(hour, buf, args[0]->unsigned_flag ? 10 : -10); int len = (int)(ptr - buf) + - my_sprintf(ptr, (ptr, ":%02u:%02u", (uint)minute, (uint)second)); + sprintf(ptr, ":%02u:%02u", (uint) minute, (uint) second); make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, buf, len, MYSQL_TIMESTAMP_TIME, NullS); } - + if (make_time_with_warn((DATE_TIME_FORMAT *) 0, <ime, str)) { null_value= 1; diff --git a/sql/log_event.cc b/sql/log_event.cc index 93d170e1510..7becdf51747 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1664,17 +1664,17 @@ beg: int i, end; char buff[512], *pos; pos= buff; - pos+= my_sprintf(buff, (buff, "%s", dec.sign() ? "-" : "")); + pos+= sprintf(buff, "%s", dec.sign() ? "-" : ""); end= ROUND_UP(dec.frac) + ROUND_UP(dec.intg)-1; for (i=0; i < end; i++) - pos+= my_sprintf(pos, (pos, "%09d.", dec.buf[i])); - pos+= my_sprintf(pos, (pos, "%09d", dec.buf[i])); + pos+= sprintf(pos, "%09d.", dec.buf[i]); + pos+= sprintf(pos, "%09d", dec.buf[i]); my_b_printf(file, "%s", buff); my_snprintf(typestr, typestr_length, "DECIMAL(%d,%d)", precision, decimals); return bin_size; } - + case MYSQL_TYPE_FLOAT: { float fl; @@ -5481,8 +5481,7 @@ void User_var_log_event::pack_info(Protocol* protocol) if (!(buf= (char*) my_malloc(val_offset + FLOATING_POINT_BUFFER, MYF(MY_WME)))) return; - event_len+= my_sprintf(buf + val_offset, - (buf + val_offset, "%.14g", real_val)); + event_len+= sprintf(buf + val_offset, "%.14g", real_val); break; case INT_RESULT: if (!(buf= (char*) my_malloc(val_offset + 22, MYF(MY_WME)))) @@ -5664,7 +5663,7 @@ void User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) double real_val; char real_buf[FMT_G_BUFSIZE(14)]; float8get(real_val, val); - my_sprintf(real_buf, (real_buf, "%.14g", real_val)); + sprintf(real_buf, "%.14g", real_val); my_b_printf(&cache, ":=%s%s\n", real_buf, print_event_info->delimiter); break; case INT_RESULT: @@ -6414,10 +6413,9 @@ void Append_block_log_event::print(FILE* file, void Append_block_log_event::pack_info(Protocol *protocol) { char buf[256]; - uint length; - length= (uint) my_sprintf(buf, - (buf, ";file_id=%u;block_len=%u", file_id, - block_len)); + size_t length; + length= my_snprintf(buf, sizeof(buf), ";file_id=%u;block_len=%u", + file_id, block_len); protocol->store(buf, length, &my_charset_bin); } @@ -6566,9 +6564,9 @@ void Delete_file_log_event::print(FILE* file, void Delete_file_log_event::pack_info(Protocol *protocol) { char buf[64]; - uint length; - length= (uint) my_sprintf(buf, (buf, ";file_id=%u", (uint) file_id)); - protocol->store(buf, (int32) length, &my_charset_bin); + size_t length; + length= my_snprintf(buf, sizeof(buf), ";file_id=%u", (uint) file_id); + protocol->store(buf, length, &my_charset_bin); } #endif @@ -6664,9 +6662,9 @@ void Execute_load_log_event::print(FILE* file, void Execute_load_log_event::pack_info(Protocol *protocol) { char buf[64]; - uint length; - length= (uint) my_sprintf(buf, (buf, ";file_id=%u", (uint) file_id)); - protocol->store(buf, (int32) length, &my_charset_bin); + size_t length; + length= my_snprintf(buf, sizeof(buf), ";file_id=%u", (uint) file_id); + protocol->store(buf, length, &my_charset_bin); } diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc index 208ddefb890..3aa01880b83 100644 --- a/sql/my_decimal.cc +++ b/sql/my_decimal.cc @@ -249,12 +249,12 @@ print_decimal(const my_decimal *dec) int i, end; char buff[512], *pos; pos= buff; - pos+= my_sprintf(buff, (buff, "Decimal: sign: %d intg: %d frac: %d { ", - dec->sign(), dec->intg, dec->frac)); + pos+= sprintf(buff, "Decimal: sign: %d intg: %d frac: %d { ", + dec->sign(), dec->intg, dec->frac); end= ROUND_UP(dec->frac)+ROUND_UP(dec->intg)-1; for (i=0; i < end; i++) - pos+= my_sprintf(pos, (pos, "%09d, ", dec->buf[i])); - pos+= my_sprintf(pos, (pos, "%09d }\n", dec->buf[i])); + pos+= sprintf(pos, "%09d, ", dec->buf[i]); + pos+= sprintf(pos, "%09d }\n", dec->buf[i]); fputs(buff, DBUG_FILE); } diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 6e2f7dfad26..d85888e295c 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -103,8 +103,8 @@ char *partition_info::create_default_partition_names(uint part_no, { do { - my_sprintf(move_ptr, (move_ptr,"p%u", (start_no + i))); - move_ptr+=MAX_PART_NAME_SIZE; + sprintf(move_ptr, "p%u", (start_no + i)); + move_ptr+= MAX_PART_NAME_SIZE; } while (++i < no_parts_arg); } else @@ -135,7 +135,7 @@ char *partition_info::create_subpartition_name(uint subpart_no, if (likely(ptr != NULL)) { - my_sprintf(ptr, (ptr, "%ssp%u", part_name, subpart_no)); + my_snprintf(ptr, size_alloc, "%ssp%u", part_name, subpart_no); } else { diff --git a/sql/protocol.cc b/sql/protocol.cc index dc53e029647..eaf01ecd550 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -1003,16 +1003,12 @@ bool Protocol_text::store(MYSQL_TIME *tm) #endif char buff[40]; uint length; - length= my_sprintf(buff,(buff, "%04d-%02d-%02d %02d:%02d:%02d", - (int) tm->year, - (int) tm->month, - (int) tm->day, - (int) tm->hour, - (int) tm->minute, - (int) tm->second)); + length= sprintf(buff, "%04d-%02d-%02d %02d:%02d:%02d", + (int) tm->year, (int) tm->month, + (int) tm->day, (int) tm->hour, + (int) tm->minute, (int) tm->second); if (tm->second_part) - length+= my_sprintf(buff+length,(buff+length, ".%06d", - (int)tm->second_part)); + length+= sprintf(buff+length, ".%06d", (int) tm->second_part); return net_store_data((uchar*) buff, length); } @@ -1046,13 +1042,11 @@ bool Protocol_text::store_time(MYSQL_TIME *tm) char buff[40]; uint length; uint day= (tm->year || tm->month) ? 0 : tm->day; - length= my_sprintf(buff,(buff, "%s%02ld:%02d:%02d", - tm->neg ? "-" : "", - (long) day*24L+(long) tm->hour, - (int) tm->minute, - (int) tm->second)); + length= sprintf(buff, "%s%02ld:%02d:%02d", tm->neg ? "-" : "", + (long) day*24L+(long) tm->hour, (int) tm->minute, + (int) tm->second); if (tm->second_part) - length+= my_sprintf(buff+length,(buff+length, ".%06d", (int)tm->second_part)); + length+= sprintf(buff+length, ".%06d", (int) tm->second_part); return net_store_data((uchar*) buff, length); } diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 9640b8db1b2..90eef872115 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1653,12 +1653,10 @@ bool change_password(THD *thd, const char *host, const char *user, result= 0; if (mysql_bin_log.is_open()) { - query_length= - my_sprintf(buff, - (buff,"SET PASSWORD FOR '%-.120s'@'%-.120s'='%-.120s'", - acl_user->user ? acl_user->user : "", - acl_user->host.hostname ? acl_user->host.hostname : "", - new_password)); + query_length= sprintf(buff, "SET PASSWORD FOR '%-.120s'@'%-.120s'='%-.120s'", + acl_user->user ? acl_user->user : "", + acl_user->host.hostname ? acl_user->host.hostname : "", + new_password); thd->clear_error(); result= thd->binlog_query(THD::MYSQL_QUERY_TYPE, buff, query_length, FALSE, FALSE, 0); diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index d273b3319ee..29ba956bf6c 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -408,7 +408,7 @@ void field_real::add() if ((decs = decimals()) == NOT_FIXED_DEC) { - length= my_sprintf(buff, (buff, "%g", num)); + length= sprintf(buff, "%g", num); if (rint(num) != num) max_notzero_dec_len = 1; } @@ -419,7 +419,7 @@ void field_real::add() snprintf(buff, sizeof(buff)-1, "%-.*f", (int) decs, num); length = (uint) strlen(buff); #else - length= my_sprintf(buff, (buff, "%-.*f", (int) decs, num)); + length= sprintf(buff, "%-.*f", (int) decs, num); #endif // We never need to check further than this @@ -1006,9 +1006,9 @@ void field_decimal::get_opt_type(String *answer, my_decimal_set_zero(&zero); my_bool is_unsigned= (my_decimal_cmp(&zero, &min_arg) >= 0); - length= my_sprintf(buff, (buff, "DECIMAL(%d, %d)", - (int) (max_length - (item->decimals ? 1 : 0)), - item->decimals)); + length= my_snprintf(buff, sizeof(buff), "DECIMAL(%d, %d)", + (int) (max_length - (item->decimals ? 1 : 0)), + item->decimals); if (is_unsigned) length= (uint) (strmov(buff+length, " UNSIGNED")- buff); answer->append(buff, length); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 17fbf62b097..ca0d16697cd 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2278,7 +2278,7 @@ static bool show_status_array(THD *thd, const char *wild, value= ((char *) status_var + (ulong) value); /* fall through */ case SHOW_DOUBLE: - end= buff + my_sprintf(buff, (buff, "%f", *(double*) value)); + end= buff + sprintf(buff, "%f", *(double*) value); break; case SHOW_LONG_STATUS: value= ((char *) status_var + (ulong) value); diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 7c9793b273b..a41f4d52101 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -112,7 +112,8 @@ bool String::set_real(double num,uint decimals, CHARSET_INFO *cs) str_charset=cs; if (decimals >= NOT_FIXED_DEC) { - uint32 len= my_sprintf(buff,(buff, "%.15g",num));// Enough for a DATETIME + // Enough for a DATETIME + uint32 len= sprintf(buff, "%.15g", num); return copy(buff, len, &my_charset_latin1, cs, &dummy_errors); } #ifdef HAVE_FCONVERT @@ -676,7 +677,7 @@ void String::qs_append(const char *str, uint32 len) void String::qs_append(double d) { char *buff = Ptr + str_length; - str_length+= my_sprintf(buff, (buff, "%.15g", d)); + str_length+= sprintf(buff, "%.15g", d); } void String::qs_append(double *d) diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 955c35ad71b..e881b253274 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -561,7 +561,6 @@ static int parse_url_error(FEDERATED_SHARE *share, TABLE *table, int error_num) int get_connection(MEM_ROOT *mem_root, FEDERATED_SHARE *share) { int error_num= ER_FOREIGN_SERVER_DOESNT_EXIST; - char error_buffer[FEDERATED_QUERY_BUFFER_SIZE]; FOREIGN_SERVER *server, server_buffer; DBUG_ENTER("ha_federated::get_connection"); @@ -613,10 +612,8 @@ int get_connection(MEM_ROOT *mem_root, FEDERATED_SHARE *share) DBUG_RETURN(0); error: - my_sprintf(error_buffer, - (error_buffer, "server name: '%s' doesn't exist!", - share->connection_string)); - my_error(error_num, MYF(0), error_buffer); + my_printf_error(error_num, "server name: '%s' doesn't exist!", + MYF(0), share->connection_string); DBUG_RETURN(error_num); } @@ -2405,8 +2402,8 @@ int ha_federated::index_read_idx_with_result_set(uchar *buf, uint index, if (real_query(sql_query.ptr(), sql_query.length())) { - my_sprintf(error_buffer, (error_buffer, "error: %d '%s'", - mysql_errno(mysql), mysql_error(mysql))); + sprintf(error_buffer, "error: %d '%s'", + mysql_errno(mysql), mysql_error(mysql)); retval= ER_QUERY_ON_FOREIGN_DATA_SOURCE; goto error; } @@ -2775,7 +2772,6 @@ int ha_federated::rnd_pos(uchar *buf, uchar *pos) int ha_federated::info(uint flag) { - char error_buffer[FEDERATED_QUERY_BUFFER_SIZE]; char status_buf[FEDERATED_QUERY_BUFFER_SIZE]; int error; uint error_code; @@ -2859,9 +2855,8 @@ error: mysql_free_result(result); if (mysql) { - my_sprintf(error_buffer, (error_buffer, ": %d : %s", - mysql_errno(mysql), mysql_error(mysql))); - my_error(error_code, MYF(0), error_buffer); + my_printf_error(error_code, ": %d : %s", MYF(0), + mysql_errno(mysql), mysql_error(mysql)); } else if (remote_error_number != -1 /* error already reported */) diff --git a/strings/decimal.c b/strings/decimal.c index d6c33baf713..4403fc9fd6b 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -994,7 +994,7 @@ int double2decimal(double from, decimal_t *to) char buff[400], *end; int length, res; DBUG_ENTER("double2decimal"); - length= my_sprintf(buff, (buff, "%.16G", from)); + length= sprintf(buff, "%.16G", from); DBUG_PRINT("info",("from: %g from_as_str: %s", from, buff)); end= buff+length; res= string2decimal(buff, to, &end); diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index c492db723b0..00389d431fa 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -1685,7 +1685,7 @@ static void test_prepare() /* now, execute the prepared statement to insert 10 records.. */ for (tiny_data= 0; tiny_data < 100; tiny_data++) { - length[1]= my_sprintf(str_data, (str_data, "MySQL%d", int_data)); + length[1]= sprintf(str_data, "MySQL%d", int_data); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); int_data += 25; @@ -1724,7 +1724,7 @@ static void test_prepare() /* now, execute the prepared statement to insert 10 records.. */ for (o_tiny_data= 0; o_tiny_data < 100; o_tiny_data++) { - len= my_sprintf(data, (data, "MySQL%d", o_int_data)); + len= sprintf(data, "MySQL%d", o_int_data); rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); @@ -3090,7 +3090,7 @@ static void test_simple_update() my_bind[0].buffer= szData; /* string data */ my_bind[0].buffer_length= sizeof(szData); my_bind[0].length= &length[0]; - length[0]= my_sprintf(szData, (szData, "updated-data")); + length[0]= sprintf(szData, "updated-data"); my_bind[1].buffer= (void *) &nData; my_bind[1].buffer_type= MYSQL_TYPE_LONG; @@ -3286,7 +3286,7 @@ static void test_long_data_str() DIE_UNLESS(rc == 1); mysql_free_result(result); - my_sprintf(data, (data, "%d", i*5)); + sprintf(data, "%d", i*5); verify_col_data("test_long_data_str", "LENGTH(longstr)", data); data[0]= '\0'; while (i--) @@ -3344,7 +3344,7 @@ static void test_long_data_str1() rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); - length= my_sprintf(data, (data, "MySQL AB")); + length= sprintf(data, "MySQL AB"); /* supply data in pieces */ for (i= 0; i < 3; i++) @@ -3384,10 +3384,10 @@ static void test_long_data_str1() DIE_UNLESS(rc == 1); mysql_free_result(result); - my_sprintf(data, (data, "%ld", (long)i*length)); + sprintf(data, "%ld", (long)i*length); verify_col_data("test_long_data_str", "length(longstr)", data); - my_sprintf(data, (data, "%d", i*2)); + sprintf(data, "%d", i*2); verify_col_data("test_long_data_str", "length(blb)", data); /* Test length of field->max_length */ @@ -3659,7 +3659,7 @@ static void test_update() my_bind[0].buffer= szData; my_bind[0].buffer_length= sizeof(szData); my_bind[0].length= &length[0]; - length[0]= my_sprintf(szData, (szData, "inserted-data")); + length[0]= sprintf(szData, "inserted-data"); my_bind[1].buffer= (void *)&nData; my_bind[1].buffer_type= MYSQL_TYPE_LONG; @@ -3688,7 +3688,7 @@ static void test_update() my_bind[0].buffer= szData; my_bind[0].buffer_length= sizeof(szData); my_bind[0].length= &length[0]; - length[0]= my_sprintf(szData, (szData, "updated-data")); + length[0]= sprintf(szData, "updated-data"); my_bind[1].buffer= (void *)&nData; my_bind[1].buffer_type= MYSQL_TYPE_LONG; @@ -4257,7 +4257,7 @@ static void bind_fetch(int row_count) /* CHAR */ { char buff[20]; - long len= my_sprintf(buff, (buff, "%d", rc)); + long len= sprintf(buff, "%d", rc); DIE_UNLESS(strcmp(s_data, buff) == 0); DIE_UNLESS(length[6] == (ulong) len); } @@ -4850,7 +4850,7 @@ static void test_insert() /* now, execute the prepared statement to insert 10 records.. */ for (tiny_data= 0; tiny_data < 3; tiny_data++) { - length= my_sprintf(str_data, (str_data, "MySQL%d", tiny_data)); + length= sprintf(str_data, "MySQL%d", tiny_data); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); } @@ -17512,7 +17512,7 @@ static void test_wl4166_1() /* now, execute the prepared statement to insert 10 records.. */ for (tiny_data= 0; tiny_data < 10; tiny_data++) { - length[1]= my_sprintf(str_data, (str_data, "MySQL%d", int_data)); + length[1]= sprintf(str_data, "MySQL%d", int_data); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); int_data += 25; @@ -17535,7 +17535,7 @@ static void test_wl4166_1() for (tiny_data= 50; tiny_data < 60; tiny_data++) { - length[1]= my_sprintf(str_data, (str_data, "MySQL%d", int_data)); + length[1]= sprintf(str_data, "MySQL%d", int_data); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); int_data += 25; From 51ada4dcb05da577fcd26d11b66b8ac2557b3967 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 9 Jul 2010 15:17:47 +0300 Subject: [PATCH 056/118] Addendum #2 to bug #53095 : fixed a bad testcase result. --- mysql-test/suite/funcs_1/r/is_basics_mixed.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/funcs_1/r/is_basics_mixed.result b/mysql-test/suite/funcs_1/r/is_basics_mixed.result index 2ae4f96c400..d20e5750403 100644 --- a/mysql-test/suite/funcs_1/r/is_basics_mixed.result +++ b/mysql-test/suite/funcs_1/r/is_basics_mixed.result @@ -328,7 +328,7 @@ ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_ SELECT table_schema,table_name FROM information_schema.tables WHERE table_schema = 'information_schema' AND table_name = 'tables'; table_schema table_name -information_schema tables +information_schema TABLES SELECT * FROM information_schema.table_privileges WHERE table_schema = 'information_schema'; GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE From 72e404be34096c2b750345f7d23f6be08a95a78d Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 9 Jul 2010 09:51:21 -0300 Subject: [PATCH 057/118] Remove AC_LANG_WERROR, it causes trouble earlier versions of autoconf and is not strictly needed for now. --- config/ac-macros/maintainer.m4 | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/ac-macros/maintainer.m4 b/config/ac-macros/maintainer.m4 index 6aa1d166f2a..1b7df75d6f7 100644 --- a/config/ac-macros/maintainer.m4 +++ b/config/ac-macros/maintainer.m4 @@ -27,7 +27,6 @@ AC_DEFUN([MY_MAINTAINER_MODE_WARNINGS], [ AC_MSG_CHECKING([whether to use C warning options ${C_WARNINGS}]) AC_LANG_PUSH(C) CFLAGS="$CFLAGS ${C_WARNINGS}" - AC_LANG_WERROR AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [myac_c_warning_flags=yes], [myac_c_warning_flags=no]) AC_LANG_POP() @@ -41,7 +40,6 @@ AC_DEFUN([MY_MAINTAINER_MODE_WARNINGS], [ AC_MSG_CHECKING([whether to use C++ warning options ${CXX_WARNINGS}]) AC_LANG_PUSH(C++) CXXFLAGS="$CXXFLAGS ${CXX_WARNINGS}" - AC_LANG_WERROR AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [myac_cxx_warning_flags=yes], [myac_cxx_warning_flags=no]) AC_LANG_POP() From e98169d52c8610efa523040d4409054e352f92df Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 12 Jul 2010 18:58:55 +0400 Subject: [PATCH 058/118] Bug#55061: Build failing on sol 8 x86 - assembler code vs compiler problem GCC-style inline assembly is not supported by the Sun Studio compilers prior to version 12. Added a check for the Sun Studio version to avoid using _FPU_GETCW() / _FPU_SETCW() when inline assembly is unsupported. This can lead to some differences in floating point calculations on Solaris 8/x86 which, however, is not worth bothering with Sun-style assembly .il templates. --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 99f16b36dfa..598db8d993c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -190,7 +190,7 @@ typedef fp_except fp_except_t; # define fpu_control_t unsigned int # define _FPU_EXTENDED 0x300 # define _FPU_DOUBLE 0x200 -# if defined(__GNUC__) || defined(__SUNPRO_CC) +# if defined(__GNUC__) || (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x590) # define _FPU_GETCW(cw) asm volatile ("fnstcw %0" : "=m" (*&cw)) # define _FPU_SETCW(cw) asm volatile ("fldcw %0" : : "m" (*&cw)) # else From 4c28b6776884b3890cc82c251eb4b54fe5dd81d4 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Thu, 15 Jul 2010 10:10:16 +0400 Subject: [PATCH 059/118] Backport of the fix for bug#25421 to 5.0. Calculating the estimated number of records for a range scan may take a significant time, and it was impossible for a user to interrupt that process by killing the connection or the query. Fixed by checking the thread's 'killed' status in check_quick_keys() and interrupting the calculation process if it is set to a non-zero value. --- sql/opt_range.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 84519c091b9..35d1216387c 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -6066,6 +6066,9 @@ check_quick_keys(PARAM *param,uint idx,SEL_ARG *key_tree, tmp_max_flag=max_key_flag | key_tree->max_flag; } + if (unlikely(param->thd->killed != 0)) + return HA_POS_ERROR; + keynr=param->real_keynr[idx]; param->range_count++; if (!tmp_min_flag && ! tmp_max_flag && From 37c97fd472846fcb35575a51ab2937c0b82b9c5a Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Fri, 16 Jul 2010 11:15:22 +0400 Subject: [PATCH 060/118] Fix for bug #50667: The InnoDB plugin prevents initialization of the "embedded" server Problem: mysqltest_embedded failed to load ha_innodb_plugin library on some platforms (due to some unresolved references). Fix: on FreeBSD use -export-dynamic flag building mysqltest_embedded. That allows to use its global symbols to resolve references in the dynamically loaded plugin library. libmysqld/examples/Makefile.am: Fix for bug #50667: The InnoDB plugin prevents initialization of the "embedded" server - use -export-dynamic (on FreeBSD/DragonFly) building mysqltest_embedded to allow using its global symbols to resolve references in the dynamically loaded plugin libraries. --- libmysqld/examples/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libmysqld/examples/Makefile.am b/libmysqld/examples/Makefile.am index 109d33a85ae..fd37f362960 100644 --- a/libmysqld/examples/Makefile.am +++ b/libmysqld/examples/Makefile.am @@ -42,7 +42,8 @@ LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @LIBDL@ $(CXXLDFLAGS) \ mysqltest_embedded_LINK = $(CXXLINK) nodist_mysqltest_embedded_SOURCES = mysqltest.cc -mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a +mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a \ + @MYSQLD_EXTRA_LDFLAGS@ nodist_mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \ my_readline.h sql_string.h completion_hash.h From dcaef2424e56f714068411baa52f3b488210b5b0 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 16 Jul 2010 16:56:33 +0300 Subject: [PATCH 061/118] Addendum to bug #53814 : test results updates --- .../suite/funcs_1/r/is_columns_innodb.result | 12 ++-- .../suite/funcs_1/r/is_columns_is.result | 68 +++++++++---------- .../suite/funcs_1/r/is_columns_memory.result | 12 ++-- .../suite/funcs_1/r/is_columns_myisam.result | 12 ++-- .../suite/funcs_1/r/is_columns_mysql.result | 12 ++-- 5 files changed, 58 insertions(+), 58 deletions(-) diff --git a/mysql-test/suite/funcs_1/r/is_columns_innodb.result b/mysql-test/suite/funcs_1/r/is_columns_innodb.result index 73a74e4d7a2..61079b06666 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_innodb.result +++ b/mysql-test/suite/funcs_1/r/is_columns_innodb.result @@ -450,9 +450,9 @@ NULL test tb1 f27 27 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned zero NULL test tb1 f28 28 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references NULL test tb1 f29 29 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) select,insert,update,references NULL test tb1 f3 3 NULL YES char 0 0 NULL NULL latin1 latin1_swedish_ci char(0) select,insert,update,references -NULL test tb1 f30 30 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned select,insert,update,references -NULL test tb1 f31 31 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references -NULL test tb1 f32 32 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references +NULL test tb1 f30 30 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references +NULL test tb1 f31 31 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references +NULL test tb1 f32 32 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references NULL test tb1 f33 33 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references NULL test tb1 f34 34 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references NULL test tb1 f35 35 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references @@ -565,9 +565,9 @@ NULL test tb3 f143 26 99999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned s NULL test tb3 f144 27 0000099999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references NULL test tb3 f145 28 0000099999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references NULL test tb3 f146 29 999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) select,insert,update,references -NULL test tb3 f147 30 999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned select,insert,update,references -NULL test tb3 f148 31 00000000000000999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references -NULL test tb3 f149 32 00000000000000999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references +NULL test tb3 f147 30 999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references +NULL test tb3 f148 31 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references +NULL test tb3 f149 32 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references NULL test tb3 f150 33 1000 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references NULL test tb3 f151 34 999 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references NULL test tb3 f152 35 0000001000 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result index ccb94c63d46..0bed3753165 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is.result @@ -15,8 +15,8 @@ NULL information_schema COLLATIONS IS_DEFAULT 4 NO varchar 3 9 NULL NULL utf8 u NULL information_schema COLLATIONS SORTLEN 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(3) select NULL information_schema COLLATION_CHARACTER_SET_APPLICABILITY CHARACTER_SET_NAME 2 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select NULL information_schema COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME 1 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select -NULL information_schema COLUMNS CHARACTER_MAXIMUM_LENGTH 9 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema COLUMNS CHARACTER_OCTET_LENGTH 10 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema COLUMNS CHARACTER_MAXIMUM_LENGTH 9 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema COLUMNS CHARACTER_OCTET_LENGTH 10 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema COLUMNS CHARACTER_SET_NAME 13 NULL YES varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select NULL information_schema COLUMNS COLLATION_NAME 14 NULL YES varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select NULL information_schema COLUMNS COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select @@ -27,9 +27,9 @@ NULL information_schema COLUMNS COLUMN_TYPE 15 NULL NO longtext 4294967295 42949 NULL information_schema COLUMNS DATA_TYPE 8 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema COLUMNS EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select NULL information_schema COLUMNS IS_NULLABLE 7 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select -NULL information_schema COLUMNS NUMERIC_PRECISION 11 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema COLUMNS NUMERIC_SCALE 12 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema COLUMNS ORDINAL_POSITION 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema COLUMNS NUMERIC_PRECISION 11 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema COLUMNS NUMERIC_SCALE 12 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema COLUMNS ORDINAL_POSITION 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema COLUMNS PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema COLUMNS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select NULL information_schema COLUMNS TABLE_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select @@ -71,14 +71,14 @@ NULL information_schema EVENTS SQL_MODE 12 NO varchar 8192 24576 NULL NULL utf8 NULL information_schema EVENTS STARTS 13 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select NULL information_schema EVENTS STATUS 15 NO varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18) select NULL information_schema EVENTS TIME_ZONE 5 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema FILES AUTOEXTEND_SIZE 19 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema FILES AVG_ROW_LENGTH 28 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema FILES CHECKSUM 36 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema FILES AUTOEXTEND_SIZE 19 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema FILES AVG_ROW_LENGTH 28 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema FILES CHECKSUM 36 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema FILES CHECK_TIME 35 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select NULL information_schema FILES CREATE_TIME 33 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select NULL information_schema FILES CREATION_TIME 20 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select -NULL information_schema FILES DATA_FREE 32 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema FILES DATA_LENGTH 29 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema FILES DATA_FREE 32 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema FILES DATA_LENGTH 29 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema FILES DELETED_ROWS 12 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4) select NULL information_schema FILES ENGINE 10 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema FILES EXTENT_SIZE 16 0 NO bigint NULL NULL 19 0 NULL NULL bigint(4) select @@ -88,27 +88,27 @@ NULL information_schema FILES FILE_NAME 2 NULL YES varchar 64 192 NULL NULL utf8 NULL information_schema FILES FILE_TYPE 3 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select NULL information_schema FILES FREE_EXTENTS 14 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4) select NULL information_schema FILES FULLTEXT_KEYS 11 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema FILES INDEX_LENGTH 31 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema FILES INITIAL_SIZE 17 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema FILES INDEX_LENGTH 31 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema FILES INITIAL_SIZE 17 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema FILES LAST_ACCESS_TIME 22 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select NULL information_schema FILES LAST_UPDATE_TIME 21 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select NULL information_schema FILES LOGFILE_GROUP_NAME 8 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema FILES LOGFILE_GROUP_NUMBER 9 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4) select -NULL information_schema FILES MAXIMUM_SIZE 18 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema FILES MAX_DATA_LENGTH 30 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema FILES MAXIMUM_SIZE 18 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema FILES MAX_DATA_LENGTH 30 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema FILES RECOVER_TIME 23 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4) select NULL information_schema FILES ROW_FORMAT 26 NULL YES varchar 10 30 NULL NULL utf8 utf8_general_ci varchar(10) select NULL information_schema FILES STATUS 37 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select NULL information_schema FILES TABLESPACE_NAME 4 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema FILES TABLE_CATALOG 5 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema FILES TABLE_NAME 7 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema FILES TABLE_ROWS 27 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema FILES TABLE_ROWS 27 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema FILES TABLE_SCHEMA 6 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema FILES TOTAL_EXTENTS 15 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4) select NULL information_schema FILES TRANSACTION_COUNTER 24 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4) select NULL information_schema FILES UPDATE_COUNT 13 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4) select NULL information_schema FILES UPDATE_TIME 34 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select -NULL information_schema FILES VERSION 25 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema FILES VERSION 25 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema GLOBAL_STATUS VARIABLE_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema GLOBAL_STATUS VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) select NULL information_schema GLOBAL_VARIABLES VARIABLE_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select @@ -125,29 +125,29 @@ NULL information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_SCHEMA 10 NULL YES var NULL information_schema KEY_COLUMN_USAGE TABLE_CATALOG 4 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select NULL information_schema KEY_COLUMN_USAGE TABLE_NAME 6 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema KEY_COLUMN_USAGE TABLE_SCHEMA 5 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema PARTITIONS AVG_ROW_LENGTH 14 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema PARTITIONS CHECKSUM 22 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema PARTITIONS AVG_ROW_LENGTH 14 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema PARTITIONS CHECKSUM 22 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema PARTITIONS CHECK_TIME 21 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select NULL information_schema PARTITIONS CREATE_TIME 19 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select -NULL information_schema PARTITIONS DATA_FREE 18 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema PARTITIONS DATA_LENGTH 15 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema PARTITIONS INDEX_LENGTH 17 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema PARTITIONS MAX_DATA_LENGTH 16 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema PARTITIONS DATA_FREE 18 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema PARTITIONS DATA_LENGTH 15 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema PARTITIONS INDEX_LENGTH 17 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema PARTITIONS MAX_DATA_LENGTH 16 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema PARTITIONS NODEGROUP 24 NO varchar 12 36 NULL NULL utf8 utf8_general_ci varchar(12) select NULL information_schema PARTITIONS PARTITION_COMMENT 23 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema PARTITIONS PARTITION_DESCRIPTION 12 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema PARTITIONS PARTITION_EXPRESSION 10 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema PARTITIONS PARTITION_METHOD 8 NULL YES varchar 12 36 NULL NULL utf8 utf8_general_ci varchar(12) select NULL information_schema PARTITIONS PARTITION_NAME 4 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema PARTITIONS PARTITION_ORDINAL_POSITION 6 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema PARTITIONS PARTITION_ORDINAL_POSITION 6 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema PARTITIONS SUBPARTITION_EXPRESSION 11 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema PARTITIONS SUBPARTITION_METHOD 9 NULL YES varchar 12 36 NULL NULL utf8 utf8_general_ci varchar(12) select NULL information_schema PARTITIONS SUBPARTITION_NAME 5 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema PARTITIONS SUBPARTITION_ORDINAL_POSITION 7 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema PARTITIONS SUBPARTITION_ORDINAL_POSITION 7 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema PARTITIONS TABLESPACE_NAME 25 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema PARTITIONS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select NULL information_schema PARTITIONS TABLE_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema PARTITIONS TABLE_ROWS 13 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema PARTITIONS TABLE_ROWS 13 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema PARTITIONS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema PARTITIONS UPDATE_TIME 20 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select NULL information_schema PLUGINS PLUGIN_AUTHOR 8 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select @@ -231,27 +231,27 @@ NULL information_schema STATISTICS SUB_PART 11 NULL YES bigint NULL NULL 19 0 NU NULL information_schema STATISTICS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select NULL information_schema STATISTICS TABLE_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema STATISTICS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema TABLES AUTO_INCREMENT 14 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema TABLES AVG_ROW_LENGTH 9 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema TABLES CHECKSUM 19 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema TABLES AUTO_INCREMENT 14 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema TABLES AVG_ROW_LENGTH 9 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema TABLES CHECKSUM 19 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema TABLES CHECK_TIME 17 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select NULL information_schema TABLES CREATE_OPTIONS 20 NULL YES varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select NULL information_schema TABLES CREATE_TIME 15 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select -NULL information_schema TABLES DATA_FREE 13 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema TABLES DATA_LENGTH 10 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema TABLES DATA_FREE 13 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema TABLES DATA_LENGTH 10 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema TABLES ENGINE 5 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema TABLES INDEX_LENGTH 12 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema TABLES MAX_DATA_LENGTH 11 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema TABLES INDEX_LENGTH 12 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema TABLES MAX_DATA_LENGTH 11 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema TABLES ROW_FORMAT 7 NULL YES varchar 10 30 NULL NULL utf8 utf8_general_ci varchar(10) select NULL information_schema TABLES TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select NULL information_schema TABLES TABLE_COLLATION 18 NULL YES varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select NULL information_schema TABLES TABLE_COMMENT 21 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select NULL information_schema TABLES TABLE_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema TABLES TABLE_ROWS 8 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema TABLES TABLE_ROWS 8 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema TABLES TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema TABLES TABLE_TYPE 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema TABLES UPDATE_TIME 16 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select -NULL information_schema TABLES VERSION 6 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema TABLES VERSION 6 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select diff --git a/mysql-test/suite/funcs_1/r/is_columns_memory.result b/mysql-test/suite/funcs_1/r/is_columns_memory.result index 513d7bdfac6..60dea25e0e3 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_memory.result +++ b/mysql-test/suite/funcs_1/r/is_columns_memory.result @@ -437,9 +437,9 @@ NULL test tb1 f27 19 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned zero NULL test tb1 f28 20 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references NULL test tb1 f29 21 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) select,insert,update,references NULL test tb1 f3 3 NULL YES char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references -NULL test tb1 f30 22 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned select,insert,update,references -NULL test tb1 f31 23 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references -NULL test tb1 f32 24 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references +NULL test tb1 f30 22 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references +NULL test tb1 f31 23 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references +NULL test tb1 f32 24 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references NULL test tb1 f33 25 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references NULL test tb1 f34 26 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references NULL test tb1 f35 27 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references @@ -540,9 +540,9 @@ NULL test tb3 f143 20 99999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned s NULL test tb3 f144 21 0000099999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references NULL test tb3 f145 22 0000099999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references NULL test tb3 f146 23 999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) select,insert,update,references -NULL test tb3 f147 24 999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned select,insert,update,references -NULL test tb3 f148 25 00000000000000999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references -NULL test tb3 f149 26 00000000000000999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references +NULL test tb3 f147 24 999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references +NULL test tb3 f148 25 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references +NULL test tb3 f149 26 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references NULL test tb3 f150 27 1000 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references NULL test tb3 f151 28 999 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references NULL test tb3 f152 29 0000001000 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references diff --git a/mysql-test/suite/funcs_1/r/is_columns_myisam.result b/mysql-test/suite/funcs_1/r/is_columns_myisam.result index a95ca4f0ebf..6d0a44d2223 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_myisam.result +++ b/mysql-test/suite/funcs_1/r/is_columns_myisam.result @@ -479,9 +479,9 @@ NULL test tb1 f27 27 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned zero NULL test tb1 f28 28 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references NULL test tb1 f29 29 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) select,insert,update,references NULL test tb1 f3 3 NULL YES char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references -NULL test tb1 f30 30 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned select,insert,update,references -NULL test tb1 f31 31 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references -NULL test tb1 f32 32 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references +NULL test tb1 f30 30 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references +NULL test tb1 f31 31 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references +NULL test tb1 f32 32 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references NULL test tb1 f33 33 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references NULL test tb1 f34 34 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references NULL test tb1 f35 35 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references @@ -602,9 +602,9 @@ NULL test tb3 f143 26 99999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned s NULL test tb3 f144 27 0000099999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references NULL test tb3 f145 28 0000099999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references NULL test tb3 f146 29 999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) select,insert,update,references -NULL test tb3 f147 30 999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned select,insert,update,references -NULL test tb3 f148 31 00000000000000999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references -NULL test tb3 f149 32 00000000000000999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references +NULL test tb3 f147 30 999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references +NULL test tb3 f148 31 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references +NULL test tb3 f149 32 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references NULL test tb3 f150 33 1000 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references NULL test tb3 f151 34 999 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references NULL test tb3 f152 35 0000001000 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql.result b/mysql-test/suite/funcs_1/r/is_columns_mysql.result index 98eeacdb74c..2b285d7cc56 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result +++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result @@ -97,13 +97,13 @@ NULL mysql host Select_priv 3 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum( NULL mysql host Show_view_priv 16 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references NULL mysql host Trigger_priv 20 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references NULL mysql host Update_priv 5 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references -NULL mysql ndb_binlog_index deletes 6 NULL NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned select,insert,update,references -NULL mysql ndb_binlog_index epoch 3 NULL NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned PRI select,insert,update,references +NULL mysql ndb_binlog_index deletes 6 NULL NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references +NULL mysql ndb_binlog_index epoch 3 NULL NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned PRI select,insert,update,references NULL mysql ndb_binlog_index File 2 NULL NO varchar 255 255 NULL NULL latin1 latin1_swedish_ci varchar(255) select,insert,update,references -NULL mysql ndb_binlog_index inserts 4 NULL NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned select,insert,update,references -NULL mysql ndb_binlog_index Position 1 NULL NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned select,insert,update,references -NULL mysql ndb_binlog_index schemaops 7 NULL NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned select,insert,update,references -NULL mysql ndb_binlog_index updates 5 NULL NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned select,insert,update,references +NULL mysql ndb_binlog_index inserts 4 NULL NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references +NULL mysql ndb_binlog_index Position 1 NULL NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references +NULL mysql ndb_binlog_index schemaops 7 NULL NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references +NULL mysql ndb_binlog_index updates 5 NULL NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references NULL mysql plugin dl 2 NO char 128 384 NULL NULL utf8 utf8_bin char(128) select,insert,update,references NULL mysql plugin name 1 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references NULL mysql proc body 11 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references From 92f3fc92f3310cb19d48f69ab6f5d23789a90570 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 16 Jul 2010 14:33:35 -0300 Subject: [PATCH 062/118] Bug#48327: Some crashes specific to FreeBSD ("embedded") Bug#47139: Test "merge" crashes in "embedded" run Backport patch for Bug#47139 --- storage/myisam/mi_dynrec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c index 09152f8d013..4153f55aa3c 100644 --- a/storage/myisam/mi_dynrec.c +++ b/storage/myisam/mi_dynrec.c @@ -66,9 +66,12 @@ static int _mi_cmp_buffer(File file, const uchar *buff, my_off_t filepos, my_bool mi_dynmap_file(MI_INFO *info, my_off_t size) { DBUG_ENTER("mi_dynmap_file"); - if (size > (my_off_t) (~((size_t) 0))) + if (size == 0 || size > (my_off_t) (~((size_t) 0))) { - DBUG_PRINT("warning", ("File is too large for mmap")); + if (size) + DBUG_PRINT("warning", ("File is too large for mmap")); + else + DBUG_PRINT("warning", ("Do not mmap zero-length")); DBUG_RETURN(1); } /* From 85e5ce0ba06b6a79e4bd7521ab0e44c1e63a3e77 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Mon, 19 Jul 2010 11:03:52 +0200 Subject: [PATCH 063/118] Bug #54734 assert in Diagnostics_area::set_ok_status This assert checks that the server does not try to send OK to the client if there has been some error during processing. This is done to make sure that the error is in fact sent to the client. The problem was that view errors during processing of WHERE conditions in UPDATE statements where not detected by the update code. It therefore tried to send OK to the client, triggering the assert. The bug was only noticeable in debug builds. This patch fixes the problem by making sure that the update code checks for errors during condition processing and acts accordingly. --- mysql-test/r/update.result | 14 ++++++++++++++ mysql-test/t/update.test | 20 ++++++++++++++++++++ sql/filesort.cc | 4 +++- sql/opt_range.h | 6 +++++- sql/sql_delete.cc | 3 ++- sql/sql_select.cc | 32 ++++++++++++-------------------- sql/sql_update.cc | 12 ++++++++++-- 7 files changed, 66 insertions(+), 25 deletions(-) diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result index 006eaba4e69..63baf639487 100644 --- a/mysql-test/r/update.result +++ b/mysql-test/r/update.result @@ -527,3 +527,17 @@ ERROR HY000: You are using safe update mode and you tried to update a table with SET SESSION sql_safe_updates = DEFAULT; DROP TABLE t1; DROP VIEW v1; +# +# Bug#54734 assert in Diagnostics_area::set_ok_status +# +DROP TABLE IF EXISTS t1, not_exists; +DROP FUNCTION IF EXISTS f1; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 (PRIMARY KEY(pk)) AS SELECT 1 AS pk; +CREATE FUNCTION f1() RETURNS INTEGER RETURN (SELECT 1 FROM not_exists); +CREATE VIEW v1 AS SELECT pk FROM t1 WHERE f1() = 13; +UPDATE v1 SET pk = 7 WHERE pk > 0; +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DROP VIEW v1; +DROP FUNCTION f1; +DROP TABLE t1; diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test index f6708828a6b..c515f8873d8 100644 --- a/mysql-test/t/update.test +++ b/mysql-test/t/update.test @@ -483,3 +483,23 @@ UPDATE IGNORE v1 SET a = 1; SET SESSION sql_safe_updates = DEFAULT; DROP TABLE t1; DROP VIEW v1; + +--echo # +--echo # Bug#54734 assert in Diagnostics_area::set_ok_status +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1, not_exists; +DROP FUNCTION IF EXISTS f1; +DROP VIEW IF EXISTS v1; +--enable_warnings + +CREATE TABLE t1 (PRIMARY KEY(pk)) AS SELECT 1 AS pk; +CREATE FUNCTION f1() RETURNS INTEGER RETURN (SELECT 1 FROM not_exists); +CREATE VIEW v1 AS SELECT pk FROM t1 WHERE f1() = 13; +--error ER_VIEW_INVALID +UPDATE v1 SET pk = 7 WHERE pk > 0; + +DROP VIEW v1; +DROP FUNCTION f1; +DROP TABLE t1; diff --git a/sql/filesort.cc b/sql/filesort.cc index 7b584b39516..021cbdd2aad 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -514,6 +514,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, volatile THD::killed_state *killed= &thd->killed; handler *file; MY_BITMAP *save_read_set, *save_write_set; + bool skip_record; DBUG_ENTER("find_all_keys"); DBUG_PRINT("info",("using: %s", (select ? select->quick ? "ranges" : "where": @@ -606,7 +607,8 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, } if (error == 0) param->examined_rows++; - if (error == 0 && (!select || select->skip_record() == 0)) + if (!error && (!select || + (!select->skip_record(thd, &skip_record) && !skip_record))) { if (idx == param->keys) { diff --git a/sql/opt_range.h b/sql/opt_range.h index edae1e4114a..c6e488cf14c 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -788,7 +788,11 @@ class SQL_SELECT :public Sql_alloc { tmp.set_all(); return test_quick_select(thd, tmp, 0, limit, force_quick_range) < 0; } - inline bool skip_record() { return cond ? cond->val_int() == 0 : 0; } + inline bool skip_record(THD *thd, bool *skip_record) + { + *skip_record= cond ? cond->val_int() == FALSE : FALSE; + return thd->is_error(); + } int test_quick_select(THD *thd, key_map keys, table_map prev_tables, ha_rows limit, bool force_quick_range); }; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index eb0fd4b5332..6a87eb4e572 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -51,6 +51,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, THD::killed_state killed_status= THD::NOT_KILLED; DBUG_ENTER("mysql_delete"); bool save_binlog_row_based; + bool skip_record; THD::enum_binlog_query_type query_type= thd->lex->sql_command == SQLCOM_TRUNCATE ? @@ -307,7 +308,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, { thd->examined_row_count++; // thd->is_error() is tested to disallow delete row on error - if (!(select && select->skip_record())&& ! thd->is_error() ) + if (!select || (!select->skip_record(thd, &skip_record) && !skip_record)) { if (triggers_applicable && diff --git a/sql/sql_select.cc b/sql/sql_select.cc index fe391b50bb9..2fc287bbe66 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -11657,38 +11657,30 @@ flush_cached_records(JOIN *join,JOIN_TAB *join_tab,bool skip_last) SQL_SELECT *select=join_tab->select; if (rc == NESTED_LOOP_OK) { - bool consider_record= !join_tab->cache.select || - !join_tab->cache.select->skip_record(); - - /* - Check for error: skip_record() can execute code by calling - Item_subselect::val_*. We need to check for errors (if any) - after such call. - */ - if (join->thd->is_error()) + bool skip_record= FALSE; + if (join_tab->cache.select && + join_tab->cache.select->skip_record(join->thd, &skip_record)) { reset_cache_write(&join_tab->cache); return NESTED_LOOP_ERROR; } - if (consider_record) + if (!skip_record) { uint i; reset_cache_read(&join_tab->cache); for (i=(join_tab->cache.records- (skip_last ? 1 : 0)) ; i-- > 0 ;) { read_cached_record(join_tab); - if (!select || !select->skip_record()) + skip_record= FALSE; + if (select && select->skip_record(join->thd, &skip_record)) { - /* - Check for error: skip_record() can execute code by calling - Item_subselect::val_*. We need to check for errors (if any) - after such call. - */ - if (join->thd->is_error()) - rc= NESTED_LOOP_ERROR; - else - rc= (join_tab->next_select)(join,join_tab+1,0); + reset_cache_write(&join_tab->cache); + return NESTED_LOOP_ERROR; + } + if (!skip_record) + { + rc= (join_tab->next_select)(join,join_tab+1,0); if (rc != NESTED_LOOP_OK && rc != NESTED_LOOP_NO_MORE_ROWS) { reset_cache_write(&join_tab->cache); diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 3cdbb97b90b..17fac877fbc 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -473,7 +473,14 @@ int mysql_update(THD *thd, while (!(error=info.read_record(&info)) && !thd->killed) { thd->examined_row_count++; - if (!(select && select->skip_record())) + bool skip_record= FALSE; + if (select && select->skip_record(thd, &skip_record)) + { + error= 1; + table->file->unlock_row(); + break; + } + if (!skip_record) { if (table->file->was_semi_consistent_read()) continue; /* repeat the read of the same row if it still exists */ @@ -580,7 +587,8 @@ int mysql_update(THD *thd, while (!(error=info.read_record(&info)) && !thd->killed) { thd->examined_row_count++; - if (!(select && select->skip_record())) + bool skip_record; + if (!select || (!select->skip_record(thd, &skip_record) && !skip_record)) { if (table->file->was_semi_consistent_read()) continue; /* repeat the read of the same row if it still exists */ From d79e6c2e4594dc506d4d30cdc53545321b475ada Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Mon, 19 Jul 2010 17:47:17 +0300 Subject: [PATCH 064/118] fix tree names --- .bzr-mysql/default.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf index 77df77c6021..f044f8e62da 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-5.1-security" +post_commit_to = "commits@lists.mysql.com" +post_push_to = "commits@lists.mysql.com" +tree_name = "mysql-5.1" From 689a96fcce55221101b8c9b613104c0b96edfb6b Mon Sep 17 00:00:00 2001 From: Sven Sandberg Date: Tue, 20 Jul 2010 17:27:13 +0200 Subject: [PATCH 065/118] BUG#55322: SHOW BINLOG EVENTS increases @@SESSION.MAX_ALLOWED_PACKET Problem: when SHOW BINLOG EVENTS was issued, it increased the value of @@session.max_allowed_packet. This allowed a non-root user to increase the amount of memory used by her thread arbitrarily. Thus, it removes the bound on the amount of system resources used by a client, so it presents a security risk (DoS attack). Fix: it is correct to increase the value of @@session.max_allowed_packet while executing SHOW BINLOG EVENTS (see BUG 30435). However, the increase should only be temporary. Thus, the fix is to restore the value when SHOW BINLOG EVENTS ends. The value of @@session.max_allowed_packet is also increased in mysql_binlog_send (i.e., the binlog dump thread). It is not clear if this can cause any trouble, since normally the client that issues COM_BINLOG_DUMP will not issue any other commands that would be affected by the increased value of @@session.max_allowed_packet. However, we restore the value just in case. mysql-test/suite/rpl/r/rpl_packet.result: update result file mysql-test/suite/rpl/t/rpl_packet.test: Add test that verifies that @@session.max_allowed_packet does not change when issuing SHOW BINLOG EVENTS. Make previous sub-test clean up. Add comments listing the bugs in this test case. sql/sql_repl.cc: Restore the old value of thd->variables.max_allowed_packet at the end of mysql_binlog_send and mysql_show_binlog_events. --- mysql-test/suite/rpl/r/rpl_packet.result | 8 +++++ mysql-test/suite/rpl/t/rpl_packet.test | 39 +++++++++++++++++++++++- sql/sql_repl.cc | 5 +++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/rpl/r/rpl_packet.result b/mysql-test/suite/rpl/r/rpl_packet.result index 0a9495751fe..1ec9259a1fb 100644 --- a/mysql-test/suite/rpl/r/rpl_packet.result +++ b/mysql-test/suite/rpl/r/rpl_packet.result @@ -49,6 +49,14 @@ Slave_IO_Running = No (expect No) SELECT "Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master'" AS Last_IO_Error; Last_IO_Error Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master' +STOP SLAVE; +RESET SLAVE; +RESET MASTER; +SET @max_allowed_packet_0= @@session.max_allowed_packet; +SHOW BINLOG EVENTS; +SET @max_allowed_packet_1= @@session.max_allowed_packet; +SHOW BINLOG EVENTS; +SET @max_allowed_packet_2= @@session.max_allowed_packet; ==== clean up ==== DROP TABLE t1; SET @@global.max_allowed_packet= 1024; diff --git a/mysql-test/suite/rpl/t/rpl_packet.test b/mysql-test/suite/rpl/t/rpl_packet.test index bfc144c759b..08a533e22ca 100644 --- a/mysql-test/suite/rpl/t/rpl_packet.test +++ b/mysql-test/suite/rpl/t/rpl_packet.test @@ -1,7 +1,12 @@ +# ==== Purpose ==== # # Check replication protocol packet size handling -# Bug#19402 SQL close to the size of the max_allowed_packet fails on slave # +# ==== Related bugs ==== +# Bug#19402 SQL close to the size of the max_allowed_packet fails on slave +# BUG#23755: Replicated event larger that max_allowed_packet infinitely re-transmits +# BUG#42914: No LAST_IO_ERROR for max_allowed_packet errors +# BUG#55322: SHOW BINLOG EVENTS increases @@SESSION.MAX_ALLOWED_PACKET # max-out size db name source include/master-slave.inc; @@ -119,6 +124,38 @@ let $slave_io_running= query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1); let $last_io_error= query_get_value(SHOW SLAVE STATUS, Last_IO_Error, 1); eval SELECT "$last_io_error" AS Last_IO_Error; +# Remove the bad binlog and clear error status on slave. +STOP SLAVE; +RESET SLAVE; +--connection master +RESET MASTER; + + +# +# BUG#55322: SHOW BINLOG EVENTS increases @@SESSION.MAX_ALLOWED_PACKET +# +# In BUG#55322, @@session.max_allowed_packet increased each time SHOW +# BINLOG EVENTS was issued. To verify that this bug is fixed, we +# execute SHOW BINLOG EVENTS twice and check that max_allowed_packet +# never changes. We turn off the result log because we don't care +# about the contents of the binlog. + +--disable_result_log +SET @max_allowed_packet_0= @@session.max_allowed_packet; +SHOW BINLOG EVENTS; +SET @max_allowed_packet_1= @@session.max_allowed_packet; +SHOW BINLOG EVENTS; +SET @max_allowed_packet_2= @@session.max_allowed_packet; +--enable_result_log +if (`SELECT NOT(@max_allowed_packet_0 = @max_allowed_packet_1 AND @max_allowed_packet_1 = @max_allowed_packet_2)`) +{ + --echo ERROR: max_allowed_packet changed after executing SHOW BINLOG EVENTS + --source include/show_rpl_debug_info.inc + SELECT @max_allowed_packet_0, @max_allowed_packet_1, @max_allowed_packet_2; + --die @max_allowed_packet changed after executing SHOW BINLOG EVENTS +} + + --echo ==== clean up ==== connection master; DROP TABLE t1; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index c220f609c09..dcbc982b4aa 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -357,6 +357,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, #ifndef DBUG_OFF int left_events = max_binlog_dump_events; #endif + int old_max_allowed_packet= thd->variables.max_allowed_packet; DBUG_ENTER("mysql_binlog_send"); DBUG_PRINT("enter",("log_ident: '%s' pos: %ld", log_ident, (long) pos)); @@ -762,6 +763,7 @@ end: pthread_mutex_lock(&LOCK_thread_count); thd->current_linfo = 0; pthread_mutex_unlock(&LOCK_thread_count); + thd->variables.max_allowed_packet= old_max_allowed_packet; DBUG_VOID_RETURN; err: @@ -779,6 +781,7 @@ err: pthread_mutex_unlock(&LOCK_thread_count); if (file >= 0) (void) my_close(file, MYF(MY_WME)); + thd->variables.max_allowed_packet= old_max_allowed_packet; my_message(my_errno, errmsg, MYF(0)); DBUG_VOID_RETURN; @@ -1422,6 +1425,7 @@ bool mysql_show_binlog_events(THD* thd) bool ret = TRUE; IO_CACHE log; File file = -1; + int old_max_allowed_packet= thd->variables.max_allowed_packet; DBUG_ENTER("mysql_show_binlog_events"); Log_event::init_show_field_list(&field_list); @@ -1560,6 +1564,7 @@ err: pthread_mutex_lock(&LOCK_thread_count); thd->current_linfo = 0; pthread_mutex_unlock(&LOCK_thread_count); + thd->variables.max_allowed_packet= old_max_allowed_packet; DBUG_RETURN(ret); } From b0035c76d46caf25d6b52f4e1552c1e83f7f0911 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Tue, 20 Jul 2010 14:36:15 -0300 Subject: [PATCH 066/118] Bug#54453: Failing assertion: trx->active_trans when renaming a table with active trx Essentially, the problem is that InnoDB does a implicit commit when a cursor (table handler) is unlocked/closed, creating a dissonance between the transaction state within the server layer and the storage engine layer. Theoretically, a statement transaction can encompass several table instances in a similar manner to a multiple statement transaction, hence it does not make sense to limit a statement transaction to the lifetime of the table instances (cursors) used within it. Since this particular instance of the problem is only triggerable on 5.1 and is masked on 5.5 due 2PC being skipped (assertion is in the prepare phase of a 2PC), the solution (which is less risky) is to explicitly end the transaction before the cached table is unlock on rename table. The patch is to be null merged into trunk. mysql-test/include/commit.inc: Fix counters, the binlog engine does not get involved anymore. mysql-test/suite/innodb_plugin/r/innodb_bug54453.result: Add test case result for Bug#54453 mysql-test/suite/innodb_plugin/t/innodb_bug54453.test: Add test case for Bug#54453 sql/sql_table.cc: End transaction as otherwise InnoDB will end it behind our backs. --- mysql-test/include/commit.inc | 4 ++-- mysql-test/r/commit_1innodb.result | 4 ++-- .../suite/innodb_plugin/r/innodb_bug54453.result | 9 +++++++++ .../suite/innodb_plugin/t/innodb_bug54453.test | 15 +++++++++++++++ sql/sql_table.cc | 8 ++++++++ 5 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 mysql-test/suite/innodb_plugin/r/innodb_bug54453.result create mode 100644 mysql-test/suite/innodb_plugin/t/innodb_bug54453.test diff --git a/mysql-test/include/commit.inc b/mysql-test/include/commit.inc index d91ba8291fd..d412eae8364 100644 --- a/mysql-test/include/commit.inc +++ b/mysql-test/include/commit.inc @@ -725,9 +725,9 @@ call p_verify_status_increment(4, 4, 4, 4); alter table t3 add column (b int); call p_verify_status_increment(2, 0, 2, 0); alter table t3 rename t4; -call p_verify_status_increment(2, 2, 2, 2); +call p_verify_status_increment(1, 0, 1, 0); rename table t4 to t3; -call p_verify_status_increment(2, 2, 2, 2); +call p_verify_status_increment(1, 0, 1, 0); truncate table t3; call p_verify_status_increment(4, 4, 4, 4); create view v1 as select * from t2; diff --git a/mysql-test/r/commit_1innodb.result b/mysql-test/r/commit_1innodb.result index 51c4ac3002c..1f0b2c8019b 100644 --- a/mysql-test/r/commit_1innodb.result +++ b/mysql-test/r/commit_1innodb.result @@ -841,11 +841,11 @@ call p_verify_status_increment(2, 0, 2, 0); SUCCESS alter table t3 rename t4; -call p_verify_status_increment(2, 2, 2, 2); +call p_verify_status_increment(1, 0, 1, 0); SUCCESS rename table t4 to t3; -call p_verify_status_increment(2, 2, 2, 2); +call p_verify_status_increment(1, 0, 1, 0); SUCCESS truncate table t3; diff --git a/mysql-test/suite/innodb_plugin/r/innodb_bug54453.result b/mysql-test/suite/innodb_plugin/r/innodb_bug54453.result new file mode 100644 index 00000000000..e623989a9d4 --- /dev/null +++ b/mysql-test/suite/innodb_plugin/r/innodb_bug54453.result @@ -0,0 +1,9 @@ +# +# Bug#54453: Failing assertion: trx->active_trans when renaming a table with active trx +# +DROP TABLE IF EXISTS bug54453; +CREATE TABLE bug54453(a INT) ENGINE=InnoDB; +ALTER TABLE bug54453 RENAME TO bug54453_2; +SELECT * FROM bug54453_2; +a +DROP TABLE bug54453_2; diff --git a/mysql-test/suite/innodb_plugin/t/innodb_bug54453.test b/mysql-test/suite/innodb_plugin/t/innodb_bug54453.test new file mode 100644 index 00000000000..486695d326d --- /dev/null +++ b/mysql-test/suite/innodb_plugin/t/innodb_bug54453.test @@ -0,0 +1,15 @@ +--source include/have_innodb_plugin.inc +--source include/have_log_bin.inc + +--echo # +--echo # Bug#54453: Failing assertion: trx->active_trans when renaming a table with active trx +--echo # + +--disable_warnings +DROP TABLE IF EXISTS bug54453; +--enable_warnings + +CREATE TABLE bug54453(a INT) ENGINE=InnoDB; +ALTER TABLE bug54453 RENAME TO bug54453_2; +SELECT * FROM bug54453_2; +DROP TABLE bug54453_2; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 50045ec6d90..47b91fcca0e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -6848,6 +6848,14 @@ view_err: if (!error && (new_name != table_name || new_db != db)) { thd_proc_info(thd, "rename"); + + /* + Workaround InnoDB ending the transaction when the table instance + is unlocked/closed (close_cached_table below), otherwise the trx + state will differ between the server and storage engine layers. + */ + ha_autocommit_or_rollback(thd, 0); + /* Then do a 'simple' rename of the table. First we need to close all instances of 'source' table. From c36fee08f6fa7974324438572a260101335cb4b4 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Tue, 20 Jul 2010 14:44:29 -0300 Subject: [PATCH 067/118] Bug#52514: mysql 5.1 do_abi_check does not compile w/ gcc4.5 due to GCC preprocessor change The problem is that newer GCC versions treats missing headers as fatal errors. The solution is to use a guard macro to prevent the inclusion of system headers when checking the ABI with the C Preprocessor. Reference: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15638 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44836 Makefile.am: Define guard macro. configure.in: Remove workaround. include/mysql.h: Guard the header inclusion. include/mysql.h.pp: Header is not included anymore. --- Makefile.am | 2 +- configure.in | 11 +---------- include/mysql.h | 2 ++ include/mysql.h.pp | 1 - 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Makefile.am b/Makefile.am index 7953b81fb7b..4ce753ad8aa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -314,7 +314,7 @@ abi_check_all: $(TEST_PREPROCESSOR_HEADER) do_abi_check: set -ex; \ for file in $(abi_headers); do \ - @CC@ -E -nostdinc -dI \ + @CC@ -E -nostdinc -dI -DMYSQL_ABI_CHECK \ -I$(top_srcdir)/include \ -I$(top_srcdir)/include/mysql \ -I$(top_srcdir)/sql \ diff --git a/configure.in b/configure.in index 0264c351b07..8dcdecf8ea2 100644 --- a/configure.in +++ b/configure.in @@ -444,16 +444,7 @@ if test "$GCC" != "yes" || expr "$CC" : ".*icc.*" then ABI_CHECK="" else - # Workaround GCC >= 4.5 - See Bug#52514 - case `$CC -dumpversion` in - [[4-9]].[[5-9]]*) - AC_MSG_WARN([ABI check disabled (GCC >= 4.5)]) - ABI_CHECK="" - ;; - *) - ABI_CHECK="abi_check" - ;; - esac + ABI_CHECK="abi_check" fi AC_SUBST(ABI_CHECK) diff --git a/include/mysql.h b/include/mysql.h index d114afb6c93..dcf3e167e6a 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -44,7 +44,9 @@ extern "C" { #endif #ifndef _global_h /* If not standard header */ +#ifndef MYSQL_ABI_CHECK #include +#endif #ifdef __LCC__ #include /* For windows */ #endif diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 633cde41130..0a397863022 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -1,4 +1,3 @@ -#include typedef char my_bool; typedef int my_socket; #include "mysql_version.h" From 9a5fa17fd3c4885262e31bf14cf495d02e5f6b27 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Tue, 20 Jul 2010 15:07:36 -0300 Subject: [PATCH 068/118] Bug#45288: pb2 returns a lot of compilation warnings on linux Fix warnings flagged by the new warning option -Wunused-but-set-variable that was added to GCC 4.6 and that is enabled by -Wunused and -Wall. The option causes a warning whenever a local variable is assigned to but is later unused. It also warns about meaningless pointer dereferences. client/mysql.cc: Meaningless pointer dereferences. client/mysql_upgrade.c: Check whether reading from the file succeeded. extra/comp_err.c: Unused. extra/yassl/src/yassl_imp.cpp: Skip instead of reading data that is discarded. include/my_pthread.h: Variable is only used in debug builds. include/mysys_err.h: Add new error messages. mysys/errors.c: Add new error message for permission related functions. mysys/mf_iocache.c: Variable is only checked under THREAD. mysys/my_copy.c: Raise a error if chmod or chown fails. mysys/my_redel.c: Raise a error if chmod or chown fails. regex/engine.c: Use a equivalent variable for the assert. server-tools/instance-manager/instance_options.cc: Unused. sql/field.cc: Unused. sql/item.cc: Unused. sql/log.cc: Do not ignore the return value of freopen: only set buffer if reopening succeeds. Adjust doxygen comment to the right function. Pass message lenght to log function. sql/mysqld.cc: Do not ignore the return value of freopen: only set buffer if reopening succeeds. sql/partition_info.cc: Unused. sql/slave.cc: No need to set pointer to the address of '\0'. sql/spatial.cc: Unused. Left for historical purposes. sql/sql_acl.cc: Unused. sql/sql_base.cc: Pointers are always set to the same variables. sql/sql_parse.cc: End statement if reading fails. Store the buffer after it has actually been updated. sql/sql_repl.cc: No need to set pointer to the address of '\0'. sql/sql_show.cc: Put variable under the same ifdef block. sql/udf_example.c: Set null pointer flag appropriately. storage/csv/ha_tina.cc: Meaningless dereferences. storage/example/ha_example.cc: Return the error since it's available. storage/myisam/mi_locking.c: Remove unused and dead code. --- client/mysql.cc | 4 +- client/mysql_upgrade.c | 5 +- extra/comp_err.c | 2 - extra/yassl/src/yassl_imp.cpp | 24 ++---- include/my_pthread.h | 5 +- include/mysys_err.h | 4 +- mysys/errors.c | 6 +- mysys/mf_iocache.c | 11 ++- mysys/my_copy.c | 20 ++++- mysys/my_redel.c | 24 ++++-- regex/engine.c | 17 ++--- .../instance-manager/instance_options.cc | 3 - sql/field.cc | 2 - sql/item.cc | 7 +- sql/log.cc | 73 ++++++++++--------- sql/mysqld.cc | 7 +- sql/partition_info.cc | 2 - sql/slave.cc | 7 +- sql/spatial.cc | 3 +- sql/sql_acl.cc | 2 - sql/sql_base.cc | 14 +--- sql/sql_load.cc | 13 ++-- sql/sql_parse.cc | 17 +++-- sql/sql_repl.cc | 7 +- sql/sql_show.cc | 4 +- sql/sql_table.cc | 2 - sql/table.cc | 3 +- sql/udf_example.c | 2 +- storage/csv/ha_tina.cc | 12 +-- storage/example/ha_example.cc | 2 +- storage/myisam/mi_locking.c | 14 +--- storage/myisam/rt_split.c | 3 - storage/myisammrg/myrg_open.c | 5 -- strings/decimal.c | 3 +- 34 files changed, 155 insertions(+), 174 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index edcc72b60bf..5b90f318629 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -3639,7 +3639,7 @@ xmlencode_print(const char *src, uint length) tee_fputs("NULL", PAGER); else { - for (const char *p = src; length; *p++, length--) + for (const char *p = src; length; p++, length--) { const char *t; if ((t = array_value(xmlmeta, *p))) @@ -4726,7 +4726,7 @@ static const char* construct_prompt() struct tm *t = localtime(&lclock); /* parse thru the settings for the prompt */ - for (char *c = current_prompt; *c ; *c++) + for (char *c = current_prompt; *c ; c++) { if (*c != PROMPT_CHAR) processed_prompt.append(*c); diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 0b8b43775ed..3122cc25731 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -595,7 +595,10 @@ static int upgrade_already_done(void) my_fclose(in, MYF(0)); - return (strncmp(buf, MYSQL_SERVER_VERSION, + if (!res) + return 0; /* Could not read from file => not sure */ + + return (strncmp(res, MYSQL_SERVER_VERSION, sizeof(MYSQL_SERVER_VERSION)-1)==0); } diff --git a/extra/comp_err.c b/extra/comp_err.c index c02c7ca3d2a..7e0b47a7dc7 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -831,7 +831,6 @@ static struct message *parse_message_string(struct message *new_message, static struct errors *parse_error_string(char *str, int er_count) { struct errors *new_error; - char *start; DBUG_ENTER("parse_error_string"); DBUG_PRINT("enter", ("str: %s", str)); @@ -842,7 +841,6 @@ static struct errors *parse_error_string(char *str, int er_count) DBUG_RETURN(0); /* OOM: Fatal error */ /* getting the error name */ - start= str; str= skip_delimiters(str); if (!(new_error->er_name= get_word(&str))) diff --git a/extra/yassl/src/yassl_imp.cpp b/extra/yassl/src/yassl_imp.cpp index f079df8c7ce..86799f961ae 100644 --- a/extra/yassl/src/yassl_imp.cpp +++ b/extra/yassl/src/yassl_imp.cpp @@ -884,21 +884,19 @@ void Alert::Process(input_buffer& input, SSL& ssl) else hmac(ssl, verify, data, aSz, alert, true); - // read mac and fill + // read mac and skip fill int digestSz = ssl.getCrypto().get_digest().get_digestSize(); opaque mac[SHA_LEN]; input.read(mac, digestSz); if (ssl.getSecurity().get_parms().cipher_type_ == block) { int ivExtra = 0; - opaque fill; if (ssl.isTLSv1_1()) ivExtra = ssl.getCrypto().get_cipher().get_blockSize(); int padSz = ssl.getSecurity().get_parms().encrypt_size_ - ivExtra - aSz - digestSz; - for (int i = 0; i < padSz; i++) - fill = input[AUTO]; + input.set_current(input.get_current() + padSz); } // verify @@ -981,17 +979,17 @@ output_buffer& operator<<(output_buffer& output, const Data& data) void Data::Process(input_buffer& input, SSL& ssl) { int msgSz = ssl.getSecurity().get_parms().encrypt_size_; - int pad = 0, padByte = 0; + int pad = 0, padSz = 0; int ivExtra = 0; if (ssl.getSecurity().get_parms().cipher_type_ == block) { if (ssl.isTLSv1_1()) // IV ivExtra = ssl.getCrypto().get_cipher().get_blockSize(); pad = *(input.get_buffer() + input.get_current() + msgSz -ivExtra - 1); - padByte = 1; + padSz = 1; } int digestSz = ssl.getCrypto().get_digest().get_digestSize(); - int dataSz = msgSz - ivExtra - digestSz - pad - padByte; + int dataSz = msgSz - ivExtra - digestSz - pad - padSz; opaque verify[SHA_LEN]; const byte* rawData = input.get_buffer() + input.get_current(); @@ -1020,14 +1018,10 @@ void Data::Process(input_buffer& input, SSL& ssl) hmac(ssl, verify, rawData, dataSz, application_data, true); } - // read mac and fill + // read mac and skip fill opaque mac[SHA_LEN]; - opaque fill; input.read(mac, digestSz); - for (int i = 0; i < pad; i++) - fill = input[AUTO]; - if (padByte) - fill = input[AUTO]; + input.set_current(input.get_current() + pad + padSz); // verify if (dataSz) { @@ -2073,11 +2067,9 @@ void Finished::Process(input_buffer& input, SSL& ssl) if (ssl.isTLSv1_1()) ivExtra = ssl.getCrypto().get_cipher().get_blockSize(); - opaque fill; int padSz = ssl.getSecurity().get_parms().encrypt_size_ - ivExtra - HANDSHAKE_HEADER - finishedSz - digestSz; - for (int i = 0; i < padSz; i++) - fill = input[AUTO]; + input.set_current(input.get_current() + padSz); // verify mac if (memcmp(mac, verifyMAC, digestSz)) { diff --git a/include/my_pthread.h b/include/my_pthread.h index eff6a677192..fec7c972a7b 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -269,13 +269,14 @@ int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */ we want to make sure that no such flags are set. */ #if defined(HAVE_SIGACTION) && !defined(my_sigset) -#define my_sigset(A,B) do { struct sigaction l_s; sigset_t l_set; int l_rc; \ +#define my_sigset(A,B) do { struct sigaction l_s; sigset_t l_set; \ + IF_DBUG(int l_rc); \ DBUG_ASSERT((A) != 0); \ sigemptyset(&l_set); \ l_s.sa_handler = (B); \ l_s.sa_mask = l_set; \ l_s.sa_flags = 0; \ - l_rc= sigaction((A), &l_s, (struct sigaction *) NULL);\ + IF_DBUG(l_rc=) sigaction((A), &l_s, NULL); \ DBUG_ASSERT(l_rc == 0); \ } while (0) #elif defined(HAVE_SIGSET) && !defined(my_sigset) diff --git a/include/mysys_err.h b/include/mysys_err.h index 09e77248c17..6294b37f773 100644 --- a/include/mysys_err.h +++ b/include/mysys_err.h @@ -62,7 +62,9 @@ extern const char * NEAR globerrs[]; /* my_error_messages is here */ #define EE_UNKNOWN_COLLATION 28 #define EE_FILENOTFOUND 29 #define EE_FILE_NOT_CLOSED 30 -#define EE_ERROR_LAST 30 /* Copy last error nr */ +#define EE_CHANGE_OWNERSHIP 31 +#define EE_CHANGE_PERMISSIONS 32 +#define EE_ERROR_LAST 32 /* Copy last error nr */ /* Add error numbers before EE_ERROR_LAST and change it accordingly. */ /* exit codes for all MySQL programs */ diff --git a/mysys/errors.c b/mysys/errors.c index 8d3303cac9f..a5ad4a956ab 100644 --- a/mysys/errors.c +++ b/mysys/errors.c @@ -49,7 +49,9 @@ const char * NEAR globerrs[GLOBERRS]= "Can't sync file '%s' to disk (Errcode: %d)", "Collation '%s' is not a compiled collation and is not specified in the '%s' file", "File '%s' not found (Errcode: %d)", - "File '%s' (fileno: %d) was not closed" + "File '%s' (fileno: %d) was not closed", + "Can't change ownership of the file '%s' (Errcode: %d)", + "Can't change permissions of the file '%s' (Errcode: %d)", }; void init_glob_errs(void) @@ -90,6 +92,8 @@ void init_glob_errs() EE(EE_UNKNOWN_COLLATION)= "Collation '%s' is not a compiled collation and is not specified in the %s file"; EE(EE_FILENOTFOUND) = "File '%s' not found (Errcode: %d)"; EE(EE_FILE_NOT_CLOSED) = "File '%s' (fileno: %d) was not closed"; + EE(EE_CHANGE_OWNERSHIP) = "Can't change ownership of the file '%s' (Errcode: %d)"; + EE(EE_CHANGE_PERMISSIONS) = "Can't change permissions of the file '%s' (Errcode: %d)"; } #endif diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index 1a47982b221..e9b947b04a6 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -1701,16 +1701,19 @@ int my_block_write(register IO_CACHE *info, const uchar *Buffer, size_t Count, #endif -int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock) +int my_b_flush_io_cache(IO_CACHE *info, + int need_append_buffer_lock __attribute__((unused))) { size_t length; - my_bool append_cache; my_off_t pos_in_file; + my_bool append_cache= (info->type == SEQ_READ_APPEND); DBUG_ENTER("my_b_flush_io_cache"); DBUG_PRINT("enter", ("cache: 0x%lx", (long) info)); - if (!(append_cache = (info->type == SEQ_READ_APPEND))) - need_append_buffer_lock=0; +#ifdef THREAD + if (!append_cache) + need_append_buffer_lock= 0; +#endif if (info->type == WRITE_CACHE || append_cache) { diff --git a/mysys/my_copy.c b/mysys/my_copy.c index 418e2b6f8a2..d0c1fc29229 100644 --- a/mysys/my_copy.c +++ b/mysys/my_copy.c @@ -16,6 +16,7 @@ #include "mysys_priv.h" #include /* for stat */ #include +#include "mysys_err.h" #if defined(HAVE_UTIME_H) #include #elif defined(HAVE_SYS_UTIME_H) @@ -56,7 +57,6 @@ int my_copy(const char *from, const char *to, myf MyFlags) File from_file,to_file; uchar buff[IO_SIZE]; MY_STAT stat_buff,new_stat_buff; - int res; DBUG_ENTER("my_copy"); DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags)); @@ -102,9 +102,23 @@ int my_copy(const char *from, const char *to, myf MyFlags) if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat) DBUG_RETURN(0); /* File copyed but not stat */ - res= chmod(to, stat_buff.st_mode & 07777); /* Copy modes */ + /* Copy modes */ + if (chmod(to, stat_buff.st_mode & 07777)) + { + my_errno= errno; + if (MyFlags & (MY_FAE+MY_WME)) + my_error(EE_CHANGE_PERMISSIONS, MYF(ME_BELL+ME_WAITTANG), from, errno); + goto err; + } #if !defined(__WIN__) && !defined(__NETWARE__) - res= chown(to, stat_buff.st_uid,stat_buff.st_gid); /* Copy ownership */ + /* Copy ownership */ + if (chown(to, stat_buff.st_uid,stat_buff.st_gid)) + { + my_errno= errno; + if (MyFlags & (MY_FAE+MY_WME)) + my_error(EE_CHANGE_OWNERSHIP, MYF(ME_BELL+ME_WAITTANG), from, errno); + goto err; + } #endif #if !defined(VMS) && !defined(__ZTC__) if (MyFlags & MY_COPYTIME) diff --git a/mysys/my_redel.c b/mysys/my_redel.c index 6521253f949..4013c5c8323 100644 --- a/mysys/my_redel.c +++ b/mysys/my_redel.c @@ -76,11 +76,8 @@ end: int my_copystat(const char *from, const char *to, int MyFlags) { struct stat statbuf; -#if !defined(__WIN__) && !defined(__NETWARE__) - int res; -#endif - if (stat((char*) from, &statbuf)) + if (stat(from, &statbuf)) { my_errno=errno; if (MyFlags & (MY_FAE+MY_WME)) @@ -89,7 +86,15 @@ int my_copystat(const char *from, const char *to, int MyFlags) } if ((statbuf.st_mode & S_IFMT) != S_IFREG) return 1; - VOID(chmod(to, statbuf.st_mode & 07777)); /* Copy modes */ + + /* Copy modes */ + if (chmod(to, statbuf.st_mode & 07777)) + { + my_errno= errno; + if (MyFlags & (MY_FAE+MY_WME)) + my_error(EE_CHANGE_PERMISSIONS, MYF(ME_BELL+ME_WAITTANG), from, errno); + return -1; + } #if !defined(__WIN__) && !defined(__NETWARE__) if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING) @@ -97,7 +102,14 @@ int my_copystat(const char *from, const char *to, int MyFlags) if (MyFlags & MY_LINK_WARNING) my_error(EE_LINK_WARNING,MYF(ME_BELL+ME_WAITTANG),from,statbuf.st_nlink); } - res= chown(to, statbuf.st_uid, statbuf.st_gid); /* Copy ownership */ + /* Copy ownership */ + if (chown(to, statbuf.st_uid, statbuf.st_gid)) + { + my_errno= errno; + if (MyFlags & (MY_FAE+MY_WME)) + my_error(EE_CHANGE_OWNERSHIP, MYF(ME_BELL+ME_WAITTANG), from, errno); + return -1; + } #endif /* !__WIN__ && !__NETWARE__ */ #ifndef VMS diff --git a/regex/engine.c b/regex/engine.c index 1968ca61a96..be08adf8601 100644 --- a/regex/engine.c +++ b/regex/engine.c @@ -256,7 +256,6 @@ sopno stopst; register char *ssp; /* start of string matched by subsubRE */ register char *sep; /* end of string matched by subsubRE */ register char *oldssp; /* previous ssp */ - register char *dp; /* used in debug mode to check asserts */ AT("diss", start, stop, startst, stopst); sp = start; @@ -314,11 +313,9 @@ sopno stopst; ssub = ss + 1; esub = es - 1; /* did innards match? */ - if (slow(charset, m, sp, rest, ssub, esub) != NULL) { - dp = dissect(charset, m, sp, rest, ssub, esub); - assert(dp == rest); - } else /* no */ - assert(sp == rest); + if (slow(charset, m, sp, rest, ssub, esub) != NULL) + sp = dissect(charset, m, sp, rest, ssub, esub); + assert(sp == rest); sp = rest; break; case OPLUS_: @@ -353,8 +350,8 @@ sopno stopst; } assert(sep == rest); /* must exhaust substring */ assert(slow(charset, m, ssp, sep, ssub, esub) == rest); - dp = dissect(charset, m, ssp, sep, ssub, esub); - assert(dp == sep); + sp = dissect(charset, m, ssp, sep, ssub, esub); + assert(sp == sep); sp = rest; break; case OCH_: @@ -388,8 +385,8 @@ sopno stopst; else assert(OP(m->g->strip[esub]) == O_CH); } - dp = dissect(charset, m, sp, rest, ssub, esub); - assert(dp == rest); + sp = dissect(charset, m, sp, rest, ssub, esub); + assert(sp == rest); sp = rest; break; case O_PLUS: diff --git a/server-tools/instance-manager/instance_options.cc b/server-tools/instance-manager/instance_options.cc index 8b96d6f0f96..725089e2f42 100644 --- a/server-tools/instance-manager/instance_options.cc +++ b/server-tools/instance-manager/instance_options.cc @@ -303,7 +303,6 @@ bool Instance_options::fill_log_options() enum { MAX_LOG_OPTION_LENGTH= 256 }; char datadir[MAX_LOG_OPTION_LENGTH]; char hostname[MAX_LOG_OPTION_LENGTH]; - uint hostname_length; struct log_files_st { const char *name; @@ -335,8 +334,6 @@ bool Instance_options::fill_log_options() strmov(hostname, "mysql"); hostname[MAX_LOG_OPTION_LENGTH - 1]= 0; /* Safety */ - hostname_length= strlen(hostname); - for (log_files= logs_st; log_files->name; log_files++) { diff --git a/sql/field.cc b/sql/field.cc index c648b53e139..c887a5f1c9b 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5541,7 +5541,6 @@ int Field_date::store(const char *from, uint len,CHARSET_INFO *cs) int Field_date::store(double nr) { longlong tmp; - int error= 0; if (nr >= 19000000000000.0 && nr <= 99991231235959.0) nr=floor(nr/1000000.0); // Timestamp to date if (nr < 0.0 || nr > 99991231.0) @@ -5550,7 +5549,6 @@ int Field_date::store(double nr) set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, nr, MYSQL_TIMESTAMP_DATE); - error= 1; } else tmp= (longlong) rint(nr); diff --git a/sql/item.cc b/sql/item.cc index db2c4c0974b..66c5314c16e 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -255,11 +255,10 @@ my_decimal *Item::val_decimal_from_int(my_decimal *decimal_value) my_decimal *Item::val_decimal_from_string(my_decimal *decimal_value) { String *res; - char *end_ptr; - if (!(res= val_str(&str_value))) - return 0; // NULL or EOM - end_ptr= (char*) res->ptr()+ res->length(); + if (!(res= val_str(&str_value))) + return NULL; + if (str2my_decimal(E_DEC_FATAL_ERROR & ~E_DEC_BAD_NUM, res->ptr(), res->length(), res->charset(), decimal_value) & E_DEC_BAD_NUM) diff --git a/sql/log.cc b/sql/log.cc index d8d5f6fa418..614a07e6b63 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -5050,6 +5050,22 @@ void sql_perror(const char *message) } +/* + Unfortunately, there seems to be no good way + to restore the original streams upon failure. +*/ +static bool redirect_std_streams(const char *file) +{ + if (freopen(file, "a+", stdout) && freopen(file, "a+", stderr)) + { + setbuf(stderr, NULL); + return FALSE; + } + + return TRUE; +} + + bool flush_error_log() { bool result=0; @@ -5077,11 +5093,7 @@ bool flush_error_log() setbuf(stderr, NULL); (void) my_delete(err_renamed, MYF(0)); my_rename(log_error_file,err_renamed,MYF(0)); - if (freopen(log_error_file,"a+",stdout)) - { - freopen(log_error_file,"a+",stderr); - setbuf(stderr, NULL); - } + redirect_std_streams(log_error_file); if ((fd = my_open(err_temp, O_RDONLY, MYF(0))) >= 0) { @@ -5096,13 +5108,7 @@ bool flush_error_log() result= 1; #else my_rename(log_error_file,err_renamed,MYF(0)); - if (freopen(log_error_file,"a+",stdout)) - { - FILE *reopen; - reopen= freopen(log_error_file,"a+",stderr); - setbuf(stderr, NULL); - } - else + if (redirect_std_streams(log_error_file)) result= 1; #endif VOID(pthread_mutex_unlock(&LOCK_error_log)); @@ -5153,25 +5159,9 @@ static void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, #endif /* __NT__ */ -/** - Prints a printf style message to the error log and, under NT, to the - Windows event log. - - This function prints the message into a buffer and then sends that buffer - to other functions to write that message to other logging sources. - - @param event_type Type of event to write (Error, Warning, or Info) - @param format Printf style format of message - @param args va_list list of arguments for the message - - @returns - The function always returns 0. The return value is present in the - signature to be compatible with other logging routines, which could - return an error (e.g. logging to the log tables) -*/ - #ifndef EMBEDDED_LIBRARY -static void print_buffer_to_file(enum loglevel level, const char *buffer) +static void print_buffer_to_file(enum loglevel level, const char *buffer, + size_t length) { time_t skr; struct tm tm_tmp; @@ -5185,7 +5175,7 @@ static void print_buffer_to_file(enum loglevel level, const char *buffer) localtime_r(&skr, &tm_tmp); start=&tm_tmp; - fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d [%s] %s\n", + fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d [%s] %.*s\n", start->tm_year % 100, start->tm_mon+1, start->tm_mday, @@ -5194,7 +5184,7 @@ static void print_buffer_to_file(enum loglevel level, const char *buffer) start->tm_sec, (level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ? "Warning" : "Note"), - buffer); + (int) length, buffer); fflush(stderr); @@ -5202,7 +5192,22 @@ static void print_buffer_to_file(enum loglevel level, const char *buffer) DBUG_VOID_RETURN; } +/** + Prints a printf style message to the error log and, under NT, to the + Windows event log. + This function prints the message into a buffer and then sends that buffer + to other functions to write that message to other logging sources. + + @param level The level of the msg significance + @param format Printf style format of message + @param args va_list list of arguments for the message + + @returns + The function always returns 0. The return value is present in the + signature to be compatible with other logging routines, which could + return an error (e.g. logging to the log tables) +*/ int vprint_msg_to_log(enum loglevel level, const char *format, va_list args) { char buff[1024]; @@ -5210,7 +5215,7 @@ int vprint_msg_to_log(enum loglevel level, const char *format, va_list args) DBUG_ENTER("vprint_msg_to_log"); length= my_vsnprintf(buff, sizeof(buff), format, args); - print_buffer_to_file(level, buff); + print_buffer_to_file(level, buff, length); #ifdef __NT__ print_buffer_to_nt_eventlog(level, buff, length, sizeof(buff)); @@ -5218,7 +5223,7 @@ int vprint_msg_to_log(enum loglevel level, const char *format, va_list args) DBUG_RETURN(0); } -#endif /*EMBEDDED_LIBRARY*/ +#endif /* EMBEDDED_LIBRARY */ void sql_print_error(const char *format, ...) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 99f16b36dfa..fda64e5a1ea 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3783,7 +3783,6 @@ static void end_ssl() static int init_server_components() { - FILE* reopen; DBUG_ENTER("init_server_components"); /* We need to call each of these following functions to ensure that @@ -3826,8 +3825,8 @@ static int init_server_components() if (freopen(log_error_file, "a+", stdout)) #endif { - reopen= freopen(log_error_file, "a+", stderr); - setbuf(stderr, NULL); + if (freopen(log_error_file, "a+", stderr)) + setbuf(stderr, NULL); } } } @@ -8222,7 +8221,7 @@ mysqld_get_one_option(int optid, *val= 0; val+= 2; while (*val && my_isspace(mysqld_charset, *val)) - *val++; + val++; if (!*val) { sql_print_error("Bad syntax in replicate-rewrite-db - empty TO db!\n"); diff --git a/sql/partition_info.cc b/sql/partition_info.cc index d85888e295c..f37151ea51d 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -1206,13 +1206,11 @@ bool partition_info::set_up_charset_field_preps() i= 0; while ((field= *(ptr++))) { - CHARSET_INFO *cs; uchar *field_buf; LINT_INIT(field_buf); if (!field_is_partition_charset(field)) continue; - cs= ((Field_str*)field)->charset(); size= field->pack_length(); if (!(field_buf= (uchar*) sql_calloc(size))) goto error; diff --git a/sql/slave.cc b/sql/slave.cc index 795bc481071..f1e0962e7e8 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3035,11 +3035,8 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME, pthread_mutex_lock(&rli->data_lock); if (rli->slave_skip_counter) { - char *pos; - pos= strmake(saved_log_name, rli->group_relay_log_name, FN_REFLEN - 1); - pos= '\0'; - pos= strmake(saved_master_log_name, rli->group_master_log_name, FN_REFLEN - 1); - pos= '\0'; + strmake(saved_log_name, rli->group_relay_log_name, FN_REFLEN - 1); + strmake(saved_master_log_name, rli->group_master_log_name, FN_REFLEN - 1); saved_log_pos= rli->group_relay_log_pos; saved_master_log_pos= rli->group_master_log_pos; saved_skip= rli->slave_skip_counter; diff --git a/sql/spatial.cc b/sql/spatial.cc index 11df6c00dc5..2305a8eb97d 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -159,11 +159,10 @@ Geometry *Geometry::construct(Geometry_buffer *buffer, { uint32 geom_type; Geometry *result; - char byte_order; if (data_len < SRID_SIZE + WKB_HEADER_SIZE) // < 4 + (1 + 4) return NULL; - byte_order= data[SRID_SIZE]; + /* + 1 to skip the byte order (stored in position SRID_SIZE). */ geom_type= uint4korr(data + SRID_SIZE + 1); if (!(result= create_by_typeid(buffer, (int) geom_type))) return NULL; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 90eef872115..b507b70d1fb 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -5701,7 +5701,6 @@ bool mysql_create_user(THD *thd, List &list) { int result; String wrong_users; - ulong sql_mode; LEX_USER *user_name, *tmp_user_name; List_iterator user_list(list); TABLE_LIST tables[GRANT_TABLES]; @@ -5748,7 +5747,6 @@ bool mysql_create_user(THD *thd, List &list) } some_users_created= TRUE; - sql_mode= thd->variables.sql_mode; if (replace_user_table(thd, tables[0].table, *user_name, 0, 0, 1, 0)) { append_user(&wrong_users, user_name); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index d2392bdd9b1..c38526a6d0b 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5674,7 +5674,7 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table) DBUG_ENTER("update_field_dependencies"); if (thd->mark_used_columns != MARK_COLUMNS_NONE) { - MY_BITMAP *current_bitmap, *other_bitmap; + MY_BITMAP *bitmap; /* We always want to register the used keys, as the column bitmap may have @@ -5685,15 +5685,9 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table) table->merge_keys.merge(field->part_of_key); if (thd->mark_used_columns == MARK_COLUMNS_READ) - { - current_bitmap= table->read_set; - other_bitmap= table->write_set; - } + bitmap= table->read_set; else - { - current_bitmap= table->write_set; - other_bitmap= table->read_set; - } + bitmap= table->write_set; /* The test-and-set mechanism in the bitmap is not reliable during @@ -5702,7 +5696,7 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table) only those columns that are used in the SET clause. I.e they are being set here. See multi_update::prepare() */ - if (bitmap_fast_test_and_set(current_bitmap, field->field_index)) + if (bitmap_fast_test_and_set(bitmap, field->field_index)) { if (thd->mark_used_columns == MARK_COLUMNS_WRITE) { diff --git a/sql/sql_load.cc b/sql/sql_load.cc index ee7481234a4..a4cf46b35e8 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -128,6 +128,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, bool is_fifo=0; #ifndef EMBEDDED_LIBRARY LOAD_FILE_INFO lf_info; + THD::killed_state killed_status; #endif char *db = table_list->db; // This is never null /* @@ -138,7 +139,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, char *tdb= thd->db ? thd->db : db; // Result is never null ulong skip_lines= ex->skip_lines; bool transactional_table; - THD::killed_state killed_status= THD::NOT_KILLED; DBUG_ENTER("mysql_load"); #ifdef EMBEDDED_LIBRARY @@ -455,7 +455,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, error=1; thd->killed= THD::KILL_QUERY; };); - killed_status= (error == 0)? THD::NOT_KILLED : thd->killed; + +#ifndef EMBEDDED_LIBRARY + killed_status= (error == 0) ? THD::NOT_KILLED : thd->killed; +#endif + /* We must invalidate the table in query cache before binlog writing and ha_autocommit_... @@ -708,12 +712,9 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, List_iterator_fast it(fields_vars); Item_field *sql_field; TABLE *table= table_list->table; - ulonglong id; bool err; DBUG_ENTER("read_fixed_length"); - id= 0; - while (!read_info.read_fixed_length()) { if (thd->killed) @@ -839,12 +840,10 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, Item *item; TABLE *table= table_list->table; uint enclosed_length; - ulonglong id; bool err; DBUG_ENTER("read_sep_field"); enclosed_length=enclosed.length(); - id= 0; for (;;it.rewind()) { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 1f3d29ffec0..134517e5bf7 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -465,6 +465,12 @@ static void handle_bootstrap_impl(THD *thd) } buff= (char*) thd->net.buff; res= fgets(buff + length, thd->net.max_packet - length, file); + if (!res && !feof(file)) + { + net_end_statement(thd); + bootstrap_error= 1; + break; + } length+= (ulong) strlen(buff + length); /* purecov: end */ } @@ -1535,7 +1541,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { STATUS_VAR current_global_status_var; ulong uptime; - uint length; + uint length __attribute__((unused)); ulonglong queries_per_second1000; char buff[250]; uint buff_len= sizeof(buff); @@ -1548,7 +1554,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, else queries_per_second1000= thd->query_id * LL(1000) / uptime; - length= my_snprintf((char*) buff, buff_len - 1, + length= my_snprintf(buff, buff_len - 1, "Uptime: %lu Threads: %d Questions: %lu " "Slow queries: %lu Opens: %lu Flush tables: %lu " "Open tables: %u Queries per second avg: %u.%u", @@ -1560,10 +1566,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, cached_open_tables(), (uint) (queries_per_second1000 / 1000), (uint) (queries_per_second1000 % 1000)); -#ifdef EMBEDDED_LIBRARY - /* Store the buffer in permanent memory */ - my_ok(thd, 0, 0, buff); -#endif #ifdef SAFEMALLOC if (sf_malloc_cur_memory) // Using SAFEMALLOC { @@ -1578,6 +1580,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd, VOID(my_net_write(net, (uchar*) buff, length)); VOID(net_flush(net)); thd->main_da.disable_status(); +#else + /* Store the buffer in permanent memory */ + my_ok(thd, 0, 0, buff); #endif break; } diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index f6045e4704e..d7dd3eb63f2 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1168,12 +1168,9 @@ bool change_master(THD* thd, Master_info* mi) /* Before processing the command, save the previous state. */ - char *pos; - pos= strmake(saved_host, mi->host, HOSTNAME_LENGTH); - pos= '\0'; + strmake(saved_host, mi->host, HOSTNAME_LENGTH); saved_port= mi->port; - pos= strmake(saved_log_name, mi->master_log_name, FN_REFLEN - 1); - pos= '\0'; + strmake(saved_log_name, mi->master_log_name, FN_REFLEN - 1); saved_log_pos= mi->master_log_pos; /* diff --git a/sql/sql_show.cc b/sql/sql_show.cc index d0e76e501e2..eb5d3a1965d 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3868,7 +3868,6 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, uint flags=field->flags; char tmp[MAX_FIELD_WIDTH]; String type(tmp,sizeof(tmp), system_charset_info); - char *end; int decimals, field_length; if (wild && wild[0] && @@ -3889,7 +3888,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, field->field_name) & COL_ACLS; if (!tables->schema_table && !col_access) continue; - end= tmp; + char *end= tmp; for (uint bitnr=0; col_access ; col_access>>=1,bitnr++) { if (col_access & 1) @@ -4015,7 +4014,6 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, table->field[15]->store((const char*) pos, strlen((const char*) pos), cs); - end= tmp; if (field->unireg_check == Field::NEXT_NUMBER) table->field[16]->store(STRING_WITH_LEN("auto_increment"), cs); if (show_table->timestamp_field == field && diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 47b91fcca0e..f765e5c5cae 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -6507,7 +6507,6 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, uint index_add_count= 0; uint *index_add_buffer= NULL; uint candidate_key_count= 0; - bool committed= 0; bool no_pk; DBUG_ENTER("mysql_alter_table"); @@ -7380,7 +7379,6 @@ view_err: DBUG_PRINT("info", ("Committing before unlocking table")); if (ha_autocommit_or_rollback(thd, 0) || end_active_trans(thd)) goto err1; - committed= 1; } /*end of if (! new_table) for add/drop index*/ diff --git a/sql/table.cc b/sql/table.cc index dde3654dab1..e989ab039a0 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -534,7 +534,7 @@ int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags) int error, table_type; bool error_given; File file; - uchar head[288], *disk_buff; + uchar head[288]; char path[FN_REFLEN]; MEM_ROOT **root_ptr, *old_root; DBUG_ENTER("open_table_def"); @@ -543,7 +543,6 @@ int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags) error= 1; error_given= 0; - disk_buff= NULL; strxmov(path, share->normalized_path.str, reg_ext, NullS); if ((file= my_open(path, O_RDONLY | O_SHARE, MYF(0))) < 0) diff --git a/sql/udf_example.c b/sql/udf_example.c index 637293209e0..468118b44ef 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -1067,7 +1067,7 @@ char *myfunc_argument_name(UDF_INIT *initid __attribute__((unused)), { if (!args->attributes[0]) { - null_value= 0; + *null_value= 1; return 0; } (*length)--; /* space for ending \0 (for debugging purposes) */ diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index e3bc7f55dd2..5a3399b2401 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -468,7 +468,7 @@ int ha_tina::encode_quote(uchar *buf) const char *ptr; const char *end_ptr; const bool was_null= (*field)->is_null(); - + /* assistance for backwards compatibility in production builds. note: this will not work for ENUM columns. @@ -480,7 +480,7 @@ int ha_tina::encode_quote(uchar *buf) } (*field)->val_str(&attribute,&attribute); - + if (was_null) (*field)->set_null(); @@ -491,34 +491,30 @@ int ha_tina::encode_quote(uchar *buf) buffer.append('"'); - while (ptr < end_ptr) + for (; ptr < end_ptr; ptr++) { if (*ptr == '"') { buffer.append('\\'); buffer.append('"'); - *ptr++; } else if (*ptr == '\r') { buffer.append('\\'); buffer.append('r'); - *ptr++; } else if (*ptr == '\\') { buffer.append('\\'); buffer.append('\\'); - *ptr++; } else if (*ptr == '\n') { buffer.append('\\'); buffer.append('n'); - *ptr++; } else - buffer.append(*ptr++); + buffer.append(*ptr); } buffer.append('"'); } diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index 604722c3c8c..2a4fe538c85 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -153,7 +153,7 @@ static int example_done_func(void *p) hash_free(&example_open_tables); pthread_mutex_destroy(&example_mutex); - DBUG_RETURN(0); + DBUG_RETURN(error); } diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c index 342efff4842..589b9cf89b7 100644 --- a/storage/myisam/mi_locking.c +++ b/storage/myisam/mi_locking.c @@ -29,7 +29,6 @@ int mi_lock_database(MI_INFO *info, int lock_type) int error; uint count; MYISAM_SHARE *share=info->s; - uint flag; DBUG_ENTER("mi_lock_database"); DBUG_PRINT("enter",("lock_type: %d old lock %d r_locks: %u w_locks: %u " "global_changed: %d open_count: %u name: '%s'", @@ -48,7 +47,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) DBUG_RETURN(0); } - flag=error=0; + error= 0; pthread_mutex_lock(&share->intern_lock); if (share->kfile >= 0) /* May only be false on windows */ { @@ -120,14 +119,12 @@ int mi_lock_database(MI_INFO *info, int lock_type) { if (share->r_locks) { /* Only read locks left */ - flag=1; if (my_lock(share->kfile,F_RDLCK,0L,F_TO_EOF, MYF(MY_WME | MY_SEEK_NOT_DONE)) && !error) error=my_errno; } else if (!share->w_locks) { /* No more locks */ - flag=1; if (my_lock(share->kfile,F_UNLCK,0L,F_TO_EOF, MYF(MY_WME | MY_SEEK_NOT_DONE)) && !error) error=my_errno; @@ -148,7 +145,6 @@ int mi_lock_database(MI_INFO *info, int lock_type) */ if (share->w_locks == 1) { - flag=1; if (my_lock(share->kfile,lock_type,0L,F_TO_EOF, MYF(MY_SEEK_NOT_DONE))) { @@ -163,7 +159,6 @@ int mi_lock_database(MI_INFO *info, int lock_type) } if (!share->r_locks && !share->w_locks) { - flag=1; if (my_lock(share->kfile,lock_type,0L,F_TO_EOF, info->lock_wait | MY_SEEK_NOT_DONE)) { @@ -188,7 +183,6 @@ int mi_lock_database(MI_INFO *info, int lock_type) { /* Change READONLY to RW */ if (share->r_locks == 1) { - flag=1; if (my_lock(share->kfile,lock_type,0L,F_TO_EOF, MYF(info->lock_wait | MY_SEEK_NOT_DONE))) { @@ -205,7 +199,6 @@ int mi_lock_database(MI_INFO *info, int lock_type) { if (!share->w_locks) { - flag=1; if (my_lock(share->kfile,lock_type,0L,F_TO_EOF, info->lock_wait | MY_SEEK_NOT_DONE)) { @@ -252,11 +245,6 @@ int mi_lock_database(MI_INFO *info, int lock_type) } #endif pthread_mutex_unlock(&share->intern_lock); -#if defined(FULL_LOG) || defined(_lint) - lock_type|=(int) (flag << 8); /* Set bit to set if real lock */ - myisam_log_command(MI_LOG_LOCK,info,(uchar*) &lock_type,sizeof(lock_type), - error); -#endif DBUG_RETURN(error); } /* mi_lock_database */ diff --git a/storage/myisam/rt_split.c b/storage/myisam/rt_split.c index 88cf643faf9..03d22de68fa 100644 --- a/storage/myisam/rt_split.c +++ b/storage/myisam/rt_split.c @@ -255,7 +255,6 @@ int rtree_split_page(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uchar *key, SplitStruct *stop; double *coord_buf; double *next_coord; - double *old_coord; int n_dim; uchar *source_cur, *cur1, *cur2; uchar *new_page= info->buff; @@ -293,8 +292,6 @@ int rtree_split_page(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uchar *key, rtree_d_mbr(keyinfo->seg, key, key_length, cur->coords); cur->key = key; - old_coord = next_coord; - if (split_rtree_node(task, max_keys + 1, mi_getint(page) + full_length + 2, full_length, rt_PAGE_MIN_SIZE(keyinfo->block_length), diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c index 5fcbe0c3297..18f8aa8d2c0 100644 --- a/storage/myisammrg/myrg_open.c +++ b/storage/myisammrg/myrg_open.c @@ -227,9 +227,7 @@ MYRG_INFO *myrg_parent_open(const char *parent_name, int save_errno; int insert_method; uint length; - uint dir_length; uint child_count; - size_t name_buff_length; File fd; IO_CACHE file_cache; char parent_name_buff[FN_REFLEN * 2]; @@ -299,7 +297,6 @@ MYRG_INFO *myrg_parent_open(const char *parent_name, } /* Call callback for each child. */ - dir_length= dirname_part(parent_name_buff, parent_name, &name_buff_length); my_b_seek(&file_cache, 0); while ((length= my_b_gets(&file_cache, child_name_buff, FN_REFLEN - 1))) { @@ -379,7 +376,6 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, { ulonglong file_offset; MI_INFO *myisam; - int rc; int errpos; int save_errno; uint idx; @@ -398,7 +394,6 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, here and in ha_myisammrg::store_lock() forces consistent data. */ pthread_mutex_lock(&m_info->mutex); - rc= 1; errpos= 0; file_offset= 0; min_keys= 0; diff --git a/strings/decimal.c b/strings/decimal.c index 4403fc9fd6b..bda296ce832 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -1934,8 +1934,7 @@ static int do_sub(decimal_t *from1, decimal_t *from2, decimal_t *to) int decimal_intg(decimal_t *from) { int res; - dec1 *tmp_res; - tmp_res= remove_leading_zeroes(from, &res); + remove_leading_zeroes(from, &res); return res; } From bd41af86ebc53510760504b980f073be4438f6e9 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Wed, 21 Jul 2010 14:56:43 +0700 Subject: [PATCH 069/118] Fixed bug #42496 - the server could crash on a debug assert after a failure to write into a closed socket sql/protocol.cc: Protocol::flush modified: set thd->main_da.can_overwrite_status= TRUE before call to net_flush() in order to prevent crash on assert in case of socket write failure, reset it to FALSE when net_flush() returned; Protocol::send_fields modified: return from method with error if call to my_net_write(), proto.write() or write_eof_packet() failed. sql/sql_cache.cc: Query_cache::send_result_to_client modified: call to thd->main_da.disable_status() only if write to socket was successful. sql/sql_cursor.cc: Materialized_cursor::fetch modified: leave method if call to result->send_data() failed. sql/sql_prepare.cc: send_prep_stmt() modified: call to thd->main_da.disable_status() only if thd->protocol_text.send_fields() completed successfully. --- sql/protocol.cc | 15 +++++++++++---- sql/sql_cache.cc | 3 ++- sql/sql_cursor.cc | 7 ++++++- sql/sql_prepare.cc | 7 +++++-- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/sql/protocol.cc b/sql/protocol.cc index dc53e029647..dfb78462f13 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -534,7 +534,11 @@ void Protocol::end_partial_result_set(THD *thd_arg) bool Protocol::flush() { #ifndef EMBEDDED_LIBRARY - return net_flush(&thd->net); + bool error; + thd->main_da.can_overwrite_status= TRUE; + error= net_flush(&thd->net); + thd->main_da.can_overwrite_status= FALSE; + return error; #else return 0; #endif @@ -574,7 +578,8 @@ bool Protocol::send_fields(List *list, uint flags) if (flags & SEND_NUM_ROWS) { // Packet with number of elements uchar *pos= net_store_length(buff, list->elements); - (void) my_net_write(&thd->net, buff, (size_t) (pos-buff)); + if (my_net_write(&thd->net, buff, (size_t) (pos-buff))) + DBUG_RETURN(1); } #ifndef DBUG_OFF @@ -698,7 +703,7 @@ bool Protocol::send_fields(List *list, uint flags) if (flags & SEND_DEFAULTS) item->send(&prot, &tmp); // Send default value if (prot.write()) - break; /* purecov: inspected */ + DBUG_RETURN(1); #ifndef DBUG_OFF field_types[count++]= field.type; #endif @@ -711,7 +716,9 @@ bool Protocol::send_fields(List *list, uint flags) to show that there is no cursor. Send no warning information, as it will be sent at statement end. */ - write_eof_packet(thd, &thd->net, thd->server_status, thd->total_warn_count); + if (write_eof_packet(thd, &thd->net, thd->server_status, + thd->total_warn_count)) + DBUG_RETURN(1); } DBUG_RETURN(prepare_for_send(list)); diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index f862cbed4f1..fcf4edbdc22 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1653,7 +1653,8 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", thd->limit_found_rows = query->found_rows(); thd->status_var.last_query_cost= 0.0; - thd->main_da.disable_status(); + if (!thd->main_da.is_set()) + thd->main_da.disable_status(); BLOCK_UNLOCK_RD(query_block); DBUG_RETURN(1); // Result sent to client diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc index 6f61dc40f66..d7d029d28d4 100644 --- a/sql/sql_cursor.cc +++ b/sql/sql_cursor.cc @@ -658,7 +658,12 @@ void Materialized_cursor::fetch(ulong num_rows) if ((res= table->file->rnd_next(table->record[0]))) break; /* Send data only if the read was successful. */ - result->send_data(item_list); + /* + If network write failed (i.e. due to a closed socked), + the error has already been set. Just return. + */ + if (result->send_data(item_list)) + return; } switch (res) { diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 041d9f7c30b..bd152866deb 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -263,8 +263,11 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns) &stmt->lex->param_list, Protocol::SEND_EOF); } - /* Flag that a response has already been sent */ - thd->main_da.disable_status(); + + if (!error) + /* Flag that a response has already been sent */ + thd->main_da.disable_status(); + DBUG_RETURN(error); } #else From e24abd9091ce28a27f27073ab70aed94851362bc Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 21 Jul 2010 18:05:57 +0300 Subject: [PATCH 070/118] Addendum #4 to bug #53095 SHOW DATABASES LIKE ... was not converting to lowercase on comparison as the documentation is suggesting. Fixed it to behave similarly to SHOW TABLES LIKE ... and updated the failing on MacOSX lowercase_table2 test case. --- mysql-test/r/lowercase_table2.result | 3 ++- sql/sql_show.cc | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/lowercase_table2.result b/mysql-test/r/lowercase_table2.result index 51c2ac0faf5..c9a46b70fab 100644 --- a/mysql-test/r/lowercase_table2.result +++ b/mysql-test/r/lowercase_table2.result @@ -56,6 +56,7 @@ CREATE DATABASE `TEST_$1`; SHOW DATABASES LIKE "TEST%"; Database (TEST%) TEST_$1 +test DROP DATABASE `test_$1`; CREATE TABLE T1 (a int) engine=innodb; INSERT INTO T1 VALUES (1); @@ -171,6 +172,6 @@ create table myUC (i int); select TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES where TABLE_SCHEMA ='mysqltest_LC2'; TABLE_SCHEMA TABLE_NAME -mysqltest_LC2 myUC +mysqltest_lc2 myUC use test; drop database mysqltest_LC2; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index eb5d3a1965d..616bced8f4a 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -521,8 +521,19 @@ find_files(THD *thd, List *files, const char *db, continue; file_name_len= filename_to_tablename(file->name, uname, sizeof(uname)); - if (wild && wild_compare(uname, wild, 0)) - continue; + if (wild) + { + if (lower_case_table_names) + { + if (my_wildcmp(files_charset_info, + uname, uname + file_name_len, + wild, wild + wild_length, + wild_prefix, wild_one,wild_many)) + continue; + } + else if (wild_compare(uname, wild, 0)) + continue; + } if (!(file_name= thd->make_lex_string(file_name, uname, file_name_len, TRUE))) { From e9a52f962f2d89fe1938145105bcb35f970a2414 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 22 Jul 2010 11:15:15 -0500 Subject: [PATCH 071/118] Bug#49542 - Do as the comment suggests and downgrade directory errors from find_file() to a warning unless they happen during a SHOW command. --- sql/sql_show.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index eb5d3a1965d..c979d44dc1c 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1,4 +1,4 @@ -/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* Copyright 2000, 2010 Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -9,9 +9,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* Function with list databases, tables or fields */ @@ -2986,7 +2986,7 @@ make_table_name_list(THD *thd, List *table_names, LEX *lex, */ if (res == FIND_FILES_DIR) { - if (lex->sql_command != SQLCOM_SELECT) + if (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) return 1; thd->clear_error(); return 2; From 1837dcfee747b697bce2023d94a8daff6e393039 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Fri, 23 Jul 2010 15:52:54 +0400 Subject: [PATCH 072/118] Bug #54476: crash when group_concat and 'with rollup' in prepared statements Using GROUP_CONCAT() together with the WITH ROLLUP modifier could crash the server. The reason was a combination of several facts: 1. The Item_func_group_concat class stores pointers to ORDER objects representing the columns in the ORDER BY clause of GROUP_CONCAT(). 2. find_order_in_list() called from Item_func_group_concat::setup() modifies the ORDER objects so that their 'item' member points to the arguments list allocated in the Item_func_group_concat constructor. 3. In some cases (e.g. in JOIN::rollup_make_fields) a copy of the original Item_func_group_concat object could be created by using the Item_func_group_concat::Item_func_group_concat(THD *thd, Item_func_group_concat *item) copy constructor. The latter essentially creates a shallow copy of the source object. Memory for the arguments array is allocated on thd->mem_root, but the pointers for arguments and ORDER are copied verbatim. What happens in the test case is that when executing the query for the first time, after a copy of the original Item_func_group_concat object has been created by JOIN::rollup_make_fields(), find_order_in_list() is called for this new object. It then resolves ORDER BY by modifying the ORDER objects so that they point to elements of the arguments array which is local to the cloned object. When thd->mem_root is freed upon completing the execution, pointers in the ORDER objects become invalid. Those ORDER objects, however, are also shared with the original Item_func_group_concat object which is preserved between executions of a prepared statement. So the first call to find_order_in_list() for the original object on the second execution tries to dereference an invalid pointer. The solution is to create copies of the ORDER objects when copying Item_func_group_concat to not leave any stale pointers in other instances with different lifecycles. mysql-test/r/func_gconcat.result: Test case for bug #54476. mysql-test/t/func_gconcat.test: Test case for bug #54476. sql/item_sum.cc: Copy the ORDER objects pointed to by the elements of the 'order' array in the copy constructor of Item_func_group_concat. sql/table.h: Removed the unused 'item_copy' member of the ORDER class. --- mysql-test/r/func_gconcat.result | 21 ++++++++++++++++++++- mysql-test/t/func_gconcat.test | 16 +++++++++++++++- sql/item_sum.cc | 19 ++++++++++++++++++- sql/table.h | 1 - 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 766f3b6bfaa..ae48eb1e0ff 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -995,6 +995,7 @@ SELECT 1 FROM 1 1 DROP TABLE t1; +End of 5.0 tests # # Bug #52397: another crash with explain extended and group_concat # @@ -1010,4 +1011,22 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select 1 AS `1` from (select group_concat(`test`.`t1`.`a` order by `test`.`t1`.`a` ASC separator ',') AS `GROUP_CONCAT(t1.a ORDER BY t1.a ASC)` from `test`.`t1` `t2` join `test`.`t1` group by `test`.`t1`.`a`) `d` DROP TABLE t1; -End of 5.0 tests +# +# Bug #54476: crash when group_concat and 'with rollup' in prepared statements +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +PREPARE stmt FROM "SELECT GROUP_CONCAT(t1.a ORDER BY t1.a) FROM t1 JOIN t1 t2 GROUP BY t1.a WITH ROLLUP"; +EXECUTE stmt; +GROUP_CONCAT(t1.a ORDER BY t1.a) +1,1 +2,2 +1,1,2,2 +EXECUTE stmt; +GROUP_CONCAT(t1.a ORDER BY t1.a) +1,1 +2,2 +1,1,2,2 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +End of 5.1 tests diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index e832ea316eb..926c1f92855 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -708,6 +708,7 @@ SELECT 1 FROM DROP TABLE t1; +--echo End of 5.0 tests --echo # --echo # Bug #52397: another crash with explain extended and group_concat @@ -719,5 +720,18 @@ EXPLAIN EXTENDED SELECT 1 FROM t1 t2, t1 GROUP BY t1.a) AS d; DROP TABLE t1; +--echo # +--echo # Bug #54476: crash when group_concat and 'with rollup' in prepared statements +--echo # ---echo End of 5.0 tests +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); + +PREPARE stmt FROM "SELECT GROUP_CONCAT(t1.a ORDER BY t1.a) FROM t1 JOIN t1 t2 GROUP BY t1.a WITH ROLLUP"; +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; +DROP TABLE t1; + +--echo End of 5.1 tests diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 228e36fc9f9..1048bd3d6ff 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3034,7 +3034,6 @@ Item_func_group_concat::Item_func_group_concat(THD *thd, tree(item->tree), unique_filter(item->unique_filter), table(item->table), - order(item->order), context(item->context), arg_count_order(item->arg_count_order), arg_count_field(item->arg_count_field), @@ -3047,6 +3046,24 @@ Item_func_group_concat::Item_func_group_concat(THD *thd, { quick_group= item->quick_group; result.set_charset(collation.collation); + + /* + Since the ORDER structures pointed to by the elements of the 'order' array + may be modified in find_order_in_list() called from + Item_func_group_concat::setup(), create a copy of those structures so that + such modifications done in this object would not have any effect on the + object being copied. + */ + ORDER *tmp; + if (!(order= (ORDER **) thd->alloc(sizeof(ORDER *) * arg_count_order + + sizeof(ORDER) * arg_count_order))) + return; + tmp= (ORDER *)(order + arg_count_order); + for (uint i= 0; i < arg_count_order; i++, tmp++) + { + memcpy(tmp, item->order[i], sizeof(ORDER)); + order[i]= tmp; + } } diff --git a/sql/table.h b/sql/table.h index 3ef3c5e0cb2..9088b3b6965 100644 --- a/sql/table.h +++ b/sql/table.h @@ -55,7 +55,6 @@ typedef struct st_order { struct st_order *next; Item **item; /* Point at item in select fields */ Item *item_ptr; /* Storage for initial item */ - Item **item_copy; /* For SPs; the original item ptr */ int counter; /* position in SELECT list, correct only if counter_used is true*/ bool asc; /* true if ascending */ From 6c4335b4cdb5207e7fbc5bff60d0488af4897be7 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Fri, 23 Jul 2010 19:32:38 +0300 Subject: [PATCH 073/118] Increment InnoDB Plugin version to 1.0.11. InnoDB Plugin 1.0.10 has been released with MySQL 5.1.49. --- 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 b8e595161b9..aa56c18e44e 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 10 +#define INNODB_VERSION_BUGFIX 11 /* The following is the InnoDB version as shown in SELECT plugin_version FROM information_schema.plugins; From e57a9d6fe035df7d200b90c518256b68b6a9fc49 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 26 Jul 2010 09:06:18 +0400 Subject: [PATCH 074/118] Bug#45012 my_like_range_cp932 generates invalid string Problem: The functions my_like_range_xxx() returned badly formed maximum strings for Asian character sets, which made problems for storage engines. Fix: - Removed a number my_like_range_xxx() implementations, which were in fact dumplicate code pieces. - Using generic my_like_range_mb() instead. - Setting max_sort_char member properly for Asian character sets - Adding unittest/strings/strings-t.c, to test that my_like_range_xxx() return well-formed min and max strings. Notes: - No additional tests in mysql/t/ available. Old tests cover the affected code well enough. --- configure.in | 3 +- strings/ctype-big5.c | 86 +------------------------- strings/ctype-cp932.c | 76 +---------------------- strings/ctype-euc_kr.c | 4 +- strings/ctype-eucjpms.c | 4 +- strings/ctype-gb2312.c | 4 +- strings/ctype-gbk.c | 86 +------------------------- strings/ctype-mb.c | 22 +++++-- strings/ctype-sjis.c | 85 +------------------------- strings/ctype-ujis.c | 4 +- unittest/Makefile.am | 4 +- unittest/strings/Makefile.am | 27 +++++++++ unittest/strings/strings-t.c | 114 +++++++++++++++++++++++++++++++++++ 13 files changed, 181 insertions(+), 338 deletions(-) create mode 100644 unittest/strings/Makefile.am create mode 100644 unittest/strings/strings-t.c diff --git a/configure.in b/configure.in index 0af6a92fcc9..efd291f953c 100644 --- a/configure.in +++ b/configure.in @@ -2880,7 +2880,8 @@ fi AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl unittest/Makefile unittest/mytap/Makefile unittest/mytap/t/Makefile dnl - unittest/mysys/Makefile unittest/examples/Makefile dnl + unittest/mysys/Makefile unittest/strings/Makefile dnl + unittest/examples/Makefile dnl strings/Makefile regex/Makefile storage/Makefile dnl man/Makefile BUILD/Makefile vio/Makefile dnl libmysql/Makefile libmysql_r/Makefile client/Makefile dnl diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 3da307b82fc..2cb40c266d2 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -377,86 +377,6 @@ static int my_strxfrm_big5(uchar *dest, const uchar *src, int len) #endif -/* -** Calculate min_str and max_str that ranges a LIKE string. -** Arguments: -** ptr Pointer to LIKE string. -** ptr_length Length of LIKE string. -** escape Escape character in LIKE. (Normally '\'). -** All escape characters should be removed from min_str and max_str -** res_length Length of min_str and max_str. -** min_str Smallest case sensitive string that ranges LIKE. -** Should be space padded to res_length. -** max_str Largest case sensitive string that ranges LIKE. -** Normally padded with the biggest character sort value. -** -** The function should return 0 if ok and 1 if the LIKE string can't be -** optimized ! -*/ - -#define max_sort_char ((char) 255) - -static my_bool my_like_range_big5(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,size_t ptr_length, - pbool escape, pbool w_one, pbool w_many, - size_t res_length, - char *min_str, char *max_str, - size_t *min_length, size_t *max_length) -{ - const char *end= ptr + ptr_length; - char *min_org=min_str; - char *min_end=min_str+res_length; - size_t charlen= res_length / cs->mbmaxlen; - - for (; ptr != end && min_str != min_end && charlen > 0; ptr++, charlen--) - { - if (ptr+1 != end && isbig5code(ptr[0],ptr[1])) - { - *min_str++= *max_str++ = *ptr++; - *min_str++= *max_str++ = *ptr; - continue; - } - if (*ptr == escape && ptr+1 != end) - { - ptr++; /* Skip escape */ - if (isbig5code(ptr[0], ptr[1])) - *min_str++= *max_str++ = *ptr++; - if (min_str < min_end) - *min_str++= *max_str++= *ptr; - continue; - } - if (*ptr == w_one) /* '_' in SQL */ - { - *min_str++='\0'; /* This should be min char */ - *max_str++=max_sort_char; - continue; - } - if (*ptr == w_many) /* '%' in SQL */ - { - /* - Calculate length of keys: - 'a\0\0... is the smallest possible string when we have space expand - a\ff\ff... is the biggest possible string - */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : - res_length); - *max_length= res_length; - do { - *min_str++ = 0; - *max_str++ = max_sort_char; - } while (min_str != min_end); - return 0; - } - *min_str++= *max_str++ = *ptr; - } - - *min_length= *max_length= (size_t) (min_str-min_org); - while (min_str != min_end) - *min_str++= *max_str++= ' '; - return 0; -} - - static uint ismbchar_big5(CHARSET_INFO *cs __attribute__((unused)), const char* p, const char *e) { @@ -6338,7 +6258,7 @@ static MY_COLLATION_HANDLER my_collation_big5_chinese_ci_handler = my_strnncollsp_big5, my_strnxfrm_big5, my_strnxfrmlen_simple, - my_like_range_big5, + my_like_range_mb, my_wildcmp_mb, my_strcasecmp_mb, my_instr_mb, @@ -6402,7 +6322,7 @@ CHARSET_INFO my_charset_big5_chinese_ci= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xF9D5, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ &my_charset_big5_handler, @@ -6435,7 +6355,7 @@ CHARSET_INFO my_charset_big5_bin= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xF9FE, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ &my_charset_big5_handler, diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index 07191c436b7..238c6f61baa 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -306,76 +306,6 @@ static size_t my_strnxfrm_cp932(CHARSET_INFO *cs __attribute__((unused)), } -/* -** Calculate min_str and max_str that ranges a LIKE string. -** Arguments: -** ptr Pointer to LIKE string. -** ptr_length Length of LIKE string. -** escape Escape character in LIKE. (Normally '\'). -** All escape characters should be removed from min_str and max_str -** res_length Length of min_str and max_str. -** min_str Smallest case sensitive string that ranges LIKE. -** Should be space padded to res_length. -** max_str Largest case sensitive string that ranges LIKE. -** Normally padded with the biggest character sort value. -** -** The function should return 0 if ok and 1 if the LIKE string can't be -** optimized ! -*/ - -#define max_sort_char ((char) 255) - -static my_bool my_like_range_cp932(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,size_t ptr_length, - pbool escape, pbool w_one, pbool w_many, - size_t res_length, - char *min_str,char *max_str, - size_t *min_length, size_t *max_length) -{ - const char *end=ptr+ptr_length; - char *min_org=min_str; - char *min_end=min_str+res_length; - - while (ptr < end && min_str < min_end) { - if (ismbchar_cp932(cs, ptr, end)) { - *min_str++ = *max_str++ = *ptr++; - if (min_str < min_end) - *min_str++ = *max_str++ = *ptr++; - continue; - } - if (*ptr == escape && ptr+1 < end) { - ptr++; /* Skip escape */ - if (ismbchar_cp932(cs, ptr, end)) - *min_str++ = *max_str++ = *ptr++; - if (min_str < min_end) - *min_str++ = *max_str++ = *ptr++; - continue; - } - if (*ptr == w_one) { /* '_' in SQL */ - *min_str++ = '\0'; /* This should be min char */ - *max_str++ = max_sort_char; - ptr++; - continue; - } - if (*ptr == w_many) - { /* '%' in SQL */ - *min_length = (size_t)(min_str - min_org); - *max_length = res_length; - do - { - *min_str++= 0; - *max_str++= max_sort_char; - } while (min_str < min_end); - return 0; - } - *min_str++ = *max_str++ = *ptr++; - } - *min_length = *max_length = (size_t) (min_str - min_org); - while (min_str < min_end) - *min_str++ = *max_str++ = ' '; /* Because if key compression */ - return 0; -} - /* page 0 0x00A1-0x00DF */ static uint16 tab_cp932_uni0[]={ 0xFF61,0xFF62,0xFF63,0xFF64,0xFF65,0xFF66,0xFF67,0xFF68, @@ -5467,7 +5397,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncollsp_cp932, my_strnxfrm_cp932, my_strnxfrmlen_simple, - my_like_range_cp932, + my_like_range_mb, my_wildcmp_mb, /* wildcmp */ my_strcasecmp_8bit, my_instr_mb, @@ -5533,7 +5463,7 @@ CHARSET_INFO my_charset_cp932_japanese_ci= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFCFC, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ &my_charset_handler, @@ -5565,7 +5495,7 @@ CHARSET_INFO my_charset_cp932_bin= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFCFC, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ &my_charset_handler, diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index fc0af7e35d5..ee957304716 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -8762,7 +8762,7 @@ CHARSET_INFO my_charset_euckr_korean_ci= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFEFE, /* max_sort_char */ ' ', /* pad char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, @@ -8795,7 +8795,7 @@ CHARSET_INFO my_charset_euckr_bin= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFEFE, /* max_sort_char */ ' ', /* pad char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c index b8b04dfca6b..615981b4d27 100644 --- a/strings/ctype-eucjpms.c +++ b/strings/ctype-eucjpms.c @@ -8710,7 +8710,7 @@ CHARSET_INFO my_charset_eucjpms_japanese_ci= 1, /* mbminlen */ 3, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFEFE, /* max_sort_char */ ' ', /* pad_char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, @@ -8743,7 +8743,7 @@ CHARSET_INFO my_charset_eucjpms_bin= 1, /* mbminlen */ 3, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFEFE, /* max_sort_char */ ' ', /* pad_char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index 0267f35ff5c..84f67dbbc2e 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -5790,7 +5790,7 @@ CHARSET_INFO my_charset_gb2312_chinese_ci= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xF7FE, /* max_sort_char */ ' ', /* pad char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, @@ -5822,7 +5822,7 @@ CHARSET_INFO my_charset_gb2312_bin= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xF7FE, /* max_sort_char */ ' ', /* pad char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index 7b8bb85652b..89607823d34 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -2690,86 +2690,6 @@ static size_t my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)), } -/* -** Calculate min_str and max_str that ranges a LIKE string. -** Arguments: -** ptr Pointer to LIKE string. -** ptr_length Length of LIKE string. -** escape Escape character in LIKE. (Normally '\'). -** All escape characters should be removed from min_str and max_str -** res_length Length of min_str and max_str. -** min_str Smallest case sensitive string that ranges LIKE. -** Should be space padded to res_length. -** max_str Largest case sensitive string that ranges LIKE. -** Normally padded with the biggest character sort value. -** -** The function should return 0 if ok and 1 if the LIKE string can't be -** optimized ! -*/ - -#define max_sort_char ((uchar) 255) - -static my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,size_t ptr_length, - pbool escape, pbool w_one, pbool w_many, - size_t res_length, - char *min_str,char *max_str, - size_t *min_length,size_t *max_length) -{ - const char *end= ptr + ptr_length; - char *min_org=min_str; - char *min_end=min_str+res_length; - size_t charlen= res_length / cs->mbmaxlen; - - for (; ptr != end && min_str != min_end && charlen > 0; ptr++, charlen--) - { - if (ptr+1 != end && isgbkcode(ptr[0],ptr[1])) - { - *min_str++= *max_str++ = *ptr++; - *min_str++= *max_str++ = *ptr; - continue; - } - if (*ptr == escape && ptr+1 != end) - { - ptr++; /* Skip escape */ - if (isgbkcode(ptr[0], ptr[1])) - *min_str++= *max_str++ = *ptr; - if (min_str < min_end) - *min_str++= *max_str++= *ptr; - continue; - } - if (*ptr == w_one) /* '_' in SQL */ - { - *min_str++='\0'; /* This should be min char */ - *max_str++=max_sort_char; - continue; - } - if (*ptr == w_many) /* '%' in SQL */ - { - /* - Calculate length of keys: - 'a\0\0... is the smallest possible string when we have space expand - a\ff\ff... is the biggest possible string - */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : - res_length); - *max_length= res_length; - do { - *min_str++= 0; - *max_str++= max_sort_char; - } while (min_str != min_end); - return 0; - } - *min_str++= *max_str++ = *ptr; - } - - *min_length= *max_length = (size_t) (min_str - min_org); - while (min_str != min_end) - *min_str++= *max_str++= ' '; /* Because if key compression */ - return 0; -} - - static uint ismbchar_gbk(CHARSET_INFO *cs __attribute__((unused)), const char* p, const char *e) { @@ -9983,7 +9903,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncollsp_gbk, my_strnxfrm_gbk, my_strnxfrmlen_simple, - my_like_range_gbk, + my_like_range_mb, my_wildcmp_mb, my_strcasecmp_mb, my_instr_mb, @@ -10048,7 +9968,7 @@ CHARSET_INFO my_charset_gbk_chinese_ci= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xA967, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ &my_charset_handler, @@ -10080,7 +10000,7 @@ CHARSET_INFO my_charset_gbk_bin= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFEFE, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ &my_charset_handler, diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 903811e2ab9..e3788fc4dff 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -498,7 +498,9 @@ static void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)), DESCRIPTION Write max key: - for non-Unicode character sets: - just set to 255. + just bfill using max_sort_char if max_sort_char is one byte. + In case when max_sort_char is two bytes, fill with double-byte pairs + and optionally pad with a single space character. - for Unicode character set (utf-8): create a buffer with multibyte representation of the max_sort_char character, and copy it into max_str in a loop. @@ -510,12 +512,20 @@ static void pad_max_char(CHARSET_INFO *cs, char *str, char *end) if (!(cs->state & MY_CS_UNICODE)) { - bfill(str, end - str, 255); - return; + if (cs->max_sort_char <= 255) + { + bfill(str, end - str, cs->max_sort_char); + return; + } + buf[0]= cs->max_sort_char >> 8; + buf[1]= cs->max_sort_char & 0xFF; + buflen= 2; + } + else + { + buflen= cs->cset->wc_mb(cs, cs->max_sort_char, (uchar*) buf, + (uchar*) buf + sizeof(buf)); } - - buflen= cs->cset->wc_mb(cs, cs->max_sort_char, (uchar*) buf, - (uchar*) buf + sizeof(buf)); DBUG_ASSERT(buflen > 0); do diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index ac426e0d7b5..3f479ffc102 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -304,85 +304,6 @@ static size_t my_strnxfrm_sjis(CHARSET_INFO *cs __attribute__((unused)), } -/* -** Calculate min_str and max_str that ranges a LIKE string. -** Arguments: -** ptr Pointer to LIKE string. -** ptr_length Length of LIKE string. -** escape Escape character in LIKE. (Normally '\'). -** All escape characters should be removed from min_str and max_str -** res_length Length of min_str and max_str. -** min_str Smallest case sensitive string that ranges LIKE. -** Should be space padded to res_length. -** max_str Largest case sensitive string that ranges LIKE. -** Normally padded with the biggest character sort value. -** -** The function should return 0 if ok and 1 if the LIKE string can't be -** optimized ! -*/ - -#define max_sort_char ((char) 255) - -static my_bool my_like_range_sjis(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,size_t ptr_length, - pbool escape, pbool w_one, pbool w_many, - size_t res_length, - char *min_str,char *max_str, - size_t *min_length,size_t *max_length) -{ - const char *end= ptr + ptr_length; - char *min_org=min_str; - char *min_end=min_str+res_length; - size_t charlen= res_length / cs->mbmaxlen; - - for ( ; ptr < end && min_str < min_end && charlen > 0 ; charlen--) - { - if (ismbchar_sjis(cs, ptr, end)) { - *min_str++ = *max_str++ = *ptr++; - if (min_str < min_end) - *min_str++ = *max_str++ = *ptr++; - continue; - } - if (*ptr == escape && ptr+1 < end) { - ptr++; /* Skip escape */ - if (ismbchar_sjis(cs, ptr, end)) - *min_str++ = *max_str++ = *ptr++; - if (min_str < min_end) - *min_str++ = *max_str++ = *ptr++; - continue; - } - if (*ptr == w_one) { /* '_' in SQL */ - *min_str++ = '\0'; /* This should be min char */ - *max_str++ = max_sort_char; - ptr++; - continue; - } - if (*ptr == w_many) - { /* '%' in SQL */ - /* - Calculate length of keys: - 'a\0\0... is the smallest possible string when we have space expand - a\ff\ff... is the biggest possible string - */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : - res_length); - *max_length= res_length; - do - { - *min_str++= 0; - *max_str++= max_sort_char; - } while (min_str < min_end); - return 0; - } - *min_str++ = *max_str++ = *ptr++; - } - - *min_length= *max_length= (size_t) (min_str - min_org); - while (min_str != min_end) - *min_str++= *max_str++= ' '; /* Because if key compression */ - return 0; -} - /* page 0 0x00A1-0x00DF */ static uint16 tab_sjis_uni0[]={ 0xFF61,0xFF62,0xFF63,0xFF64,0xFF65,0xFF66,0xFF67,0xFF68, @@ -4628,7 +4549,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncollsp_sjis, my_strnxfrm_sjis, my_strnxfrmlen_simple, - my_like_range_sjis, + my_like_range_mb, my_wildcmp_mb, /* wildcmp */ my_strcasecmp_8bit, my_instr_mb, @@ -4694,7 +4615,7 @@ CHARSET_INFO my_charset_sjis_japanese_ci= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFCFC, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ &my_charset_handler, @@ -4726,7 +4647,7 @@ CHARSET_INFO my_charset_sjis_bin= 1, /* mbminlen */ 2, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFCFC, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ &my_charset_handler, diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index 1a872a92595..4474bd0cf96 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -8567,7 +8567,7 @@ CHARSET_INFO my_charset_ujis_japanese_ci= 1, /* mbminlen */ 3, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFEFE, /* max_sort_char */ ' ', /* pad char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, @@ -8600,7 +8600,7 @@ CHARSET_INFO my_charset_ujis_bin= 1, /* mbminlen */ 3, /* mbmaxlen */ 0, /* min_sort_char */ - 255, /* max_sort_char */ + 0xFEFE, /* max_sort_char */ ' ', /* pad char */ 0, /* escape_with_backslash_is_dangerous */ &my_charset_handler, diff --git a/unittest/Makefile.am b/unittest/Makefile.am index 65fa615fb98..889e029f6ef 100644 --- a/unittest/Makefile.am +++ b/unittest/Makefile.am @@ -13,12 +13,12 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -SUBDIRS = mytap . mysys examples +SUBDIRS = mytap . mysys examples strings EXTRA_DIST = unit.pl CLEANFILES = unit -unittests = mytap mysys @mysql_se_unittest_dirs@ @mysql_pg_unittest_dirs@ +unittests = mytap mysys strings @mysql_se_unittest_dirs@ @mysql_pg_unittest_dirs@ test: perl unit.pl run $(unittests) diff --git a/unittest/strings/Makefile.am b/unittest/strings/Makefile.am new file mode 100644 index 00000000000..5b18d89f58e --- /dev/null +++ b/unittest/strings/Makefile.am @@ -0,0 +1,27 @@ +# Copyright 2000, 2010, Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +AM_CPPFLAGS = @ZLIB_INCLUDES@ -I$(top_builddir)/include +AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap + +LDADD = $(top_builddir)/unittest/mytap/libmytap.a \ + $(top_builddir)/mysys/libmysys.a \ + $(top_builddir)/dbug/libdbug.a \ + $(top_builddir)/strings/libmystrings.a + +noinst_PROGRAMS = strings-t + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/unittest/strings/strings-t.c b/unittest/strings/strings-t.c new file mode 100644 index 00000000000..2d246cfa17f --- /dev/null +++ b/unittest/strings/strings-t.c @@ -0,0 +1,114 @@ +/* Copyright 2000, 2010, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include +#include +#include + + +/* + Test that like_range() returns well-formed results. +*/ +static int +test_like_range_for_charset(CHARSET_INFO *cs, const char *src, size_t src_len) +{ + char min_str[32], max_str[32]; + size_t min_len, max_len, min_well_formed_len, max_well_formed_len; + int error= 0; + + cs->coll->like_range(cs, src, src_len, '\\', '_', '%', + sizeof(min_str), min_str, max_str, &min_len, &max_len); + diag("min_len=%d\tmax_len=%d\t%s", min_len, max_len, cs->name); + min_well_formed_len= cs->cset->well_formed_len(cs, + min_str, min_str + min_len, + 10000, &error); + max_well_formed_len= cs->cset->well_formed_len(cs, + max_str, max_str + max_len, + 10000, &error); + if (min_len != min_well_formed_len) + diag("Bad min_str: min_well_formed_len=%d min_str[%d]=0x%02X", + min_well_formed_len, min_well_formed_len, + (uchar) min_str[min_well_formed_len]); + if (max_len != max_well_formed_len) + diag("Bad max_str: max_well_formed_len=%d max_str[%d]=0x%02X", + max_well_formed_len, max_well_formed_len, + (uchar) max_str[max_well_formed_len]); + return + min_len == min_well_formed_len && + max_len == max_well_formed_len ? 0 : 1; +} + + +static CHARSET_INFO *charset_list[]= +{ +#ifdef HAVE_CHARSET_big5 + &my_charset_big5_chinese_ci, + &my_charset_big5_bin, +#endif +#ifdef HAVE_CHARSET_euckr + &my_charset_euckr_korean_ci, + &my_charset_euckr_bin, +#endif +#ifdef HAVE_CHARSET_gb2312 + &my_charset_gb2312_chinese_ci, + &my_charset_gb2312_bin, +#endif +#ifdef HAVE_CHARSET_gbk + &my_charset_gbk_chinese_ci, + &my_charset_gbk_bin, +#endif +#ifdef HAVE_CHARSET_latin1 + &my_charset_latin1, + &my_charset_latin1_bin, +#endif +#ifdef HAVE_CHARSET_sjis + &my_charset_sjis_japanese_ci, + &my_charset_sjis_bin, +#endif +#ifdef HAVE_CHARSET_tis620 + &my_charset_tis620_thai_ci, + &my_charset_tis620_bin, +#endif +#ifdef HAVE_CHARSET_ujis + &my_charset_ujis_japanese_ci, + &my_charset_ujis_bin, +#endif +#ifdef HAVE_CHARSET_utf8 + &my_charset_utf8_general_ci, + &my_charset_utf8_unicode_ci, + &my_charset_utf8_bin, +#endif +}; + + +int main() +{ + size_t i, failed= 0; + + plan(1); + diag("Testing my_like_range_xxx() functions"); + + for (i= 0; i < array_elements(charset_list); i++) + { + CHARSET_INFO *cs= charset_list[i]; + if (test_like_range_for_charset(cs, "abc%", 4)) + { + ++failed; + diag("Failed for %s", cs->name); + } + } + ok(failed == 0, "Testing my_like_range_xxx() functions"); + return exit_status(); +} From 2529ee72ec1af6d27a4f1dc5db2c4f2f001b6120 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 23 Jul 2010 21:55:03 -0300 Subject: [PATCH 075/118] Bug#55501: Disable innodb plugin usage in the embedded server on certain OSes Do not attempt to test the innodb plugin with the embedded server, it's not supported for now. --- mysql-test/include/have_innodb_plugin.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/include/have_innodb_plugin.inc b/mysql-test/include/have_innodb_plugin.inc index 99a79465f52..df876deb2d7 100644 --- a/mysql-test/include/have_innodb_plugin.inc +++ b/mysql-test/include/have_innodb_plugin.inc @@ -1,3 +1,4 @@ +--source include/not_embedded.inc disable_query_log; --require r/true.require SELECT (plugin_library LIKE 'ha_innodb_plugin%') AS `TRUE` FROM information_schema.plugins WHERE LOWER(plugin_name) = 'innodb' AND LOWER(plugin_status) = 'active'; From 277b055f141173316ef38588721f0522ccabc4a5 Mon Sep 17 00:00:00 2001 From: Jimmy Yang Date: Wed, 28 Jul 2010 03:20:44 -0700 Subject: [PATCH 076/118] Fix bug #55581 by backporting fix of #52546 from mysql-trunk-innodb to mysql-5.1-innodb plugin. --- storage/innodb_plugin/ChangeLog | 6 ++++ storage/innodb_plugin/include/mem0pool.h | 12 ------- storage/innodb_plugin/mem/mem0mem.c | 12 +++---- storage/innodb_plugin/mem/mem0pool.c | 41 +++++++++++++++--------- storage/innodb_plugin/srv/srv0start.c | 6 +++- 5 files changed, 43 insertions(+), 34 deletions(-) diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index 5bc4ea7c303..3e802360d23 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,9 @@ +2010-07-27 The InnoDB Team + + * include/mem0pool.h, mem/mem0mem.c, mem/mem0pool.c, srv/srv0start.c: + Fix Bug#55581 shutdown with innodb-use-sys-malloc=0: assert + mutex->magic_n == MUTEX_MAGIC_N. + 2010-06-30 The InnoDB Team * btr/btr0sea.c, ha/ha0ha.c, handler/ha_innodb.cc, include/btr0sea.h: diff --git a/storage/innodb_plugin/include/mem0pool.h b/storage/innodb_plugin/include/mem0pool.h index 5e93bf88a47..fa8be296ec9 100644 --- a/storage/innodb_plugin/include/mem0pool.h +++ b/storage/innodb_plugin/include/mem0pool.h @@ -100,18 +100,6 @@ mem_pool_get_reserved( /*==================*/ mem_pool_t* pool); /*!< in: memory pool */ /********************************************************************//** -Reserves the mem pool mutex. */ -UNIV_INTERN -void -mem_pool_mutex_enter(void); -/*======================*/ -/********************************************************************//** -Releases the mem pool mutex. */ -UNIV_INTERN -void -mem_pool_mutex_exit(void); -/*=====================*/ -/********************************************************************//** Validates a memory pool. @return TRUE if ok */ UNIV_INTERN diff --git a/storage/innodb_plugin/mem/mem0mem.c b/storage/innodb_plugin/mem/mem0mem.c index c0ce8a3e1ac..1dd4db30841 100644 --- a/storage/innodb_plugin/mem/mem0mem.c +++ b/storage/innodb_plugin/mem/mem0mem.c @@ -367,7 +367,7 @@ mem_heap_create_block( block->line = line; #ifdef MEM_PERIODIC_CHECK - mem_pool_mutex_enter(); + mutex_enter(&(mem_comm_pool->mutex)); if (!mem_block_list_inited) { mem_block_list_inited = TRUE; @@ -376,7 +376,7 @@ mem_heap_create_block( UT_LIST_ADD_LAST(mem_block_list, mem_block_list, block); - mem_pool_mutex_exit(); + mutex_exit(&(mem_comm_pool->mutex)); #endif mem_block_set_len(block, len); mem_block_set_type(block, type); @@ -479,11 +479,11 @@ mem_heap_block_free( UT_LIST_REMOVE(list, heap->base, block); #ifdef MEM_PERIODIC_CHECK - mem_pool_mutex_enter(); + mutex_enter(&(mem_comm_pool->mutex)); UT_LIST_REMOVE(mem_block_list, mem_block_list, block); - mem_pool_mutex_exit(); + mutex_exit(&(mem_comm_pool->mutex)); #endif ut_ad(heap->total_size >= block->len); @@ -556,7 +556,7 @@ mem_validate_all_blocks(void) { mem_block_t* block; - mem_pool_mutex_enter(); + mutex_enter(&(mem_comm_pool->mutex)); block = UT_LIST_GET_FIRST(mem_block_list); @@ -568,6 +568,6 @@ mem_validate_all_blocks(void) block = UT_LIST_GET_NEXT(mem_block_list, block); } - mem_pool_mutex_exit(); + mutex_exit(&(mem_comm_pool->mutex)); } #endif diff --git a/storage/innodb_plugin/mem/mem0pool.c b/storage/innodb_plugin/mem/mem0pool.c index c4f8af607e0..3291453eeb5 100644 --- a/storage/innodb_plugin/mem/mem0pool.c +++ b/storage/innodb_plugin/mem/mem0pool.c @@ -34,6 +34,7 @@ Created 5/12/1997 Heikki Tuuri #include "ut0lst.h" #include "ut0byte.h" #include "mem0mem.h" +#include "srv0start.h" /* We would like to use also the buffer frames to allocate memory. This would be desirable, because then the memory consumption of the database @@ -121,23 +122,33 @@ mysql@lists.mysql.com */ UNIV_INTERN ulint mem_n_threads_inside = 0; /********************************************************************//** -Reserves the mem pool mutex. */ -UNIV_INTERN +Reserves the mem pool mutex if we are not in server shutdown. Use +this function only in memory free functions, since only memory +free functions are used during server shutdown. */ +UNIV_INLINE void -mem_pool_mutex_enter(void) -/*======================*/ +mem_pool_mutex_enter( +/*=================*/ + mem_pool_t* pool) /*!< in: memory pool */ { - mutex_enter(&(mem_comm_pool->mutex)); + if (srv_shutdown_state < SRV_SHUTDOWN_EXIT_THREADS) { + mutex_enter(&(pool->mutex)); + } } /********************************************************************//** -Releases the mem pool mutex. */ -UNIV_INTERN +Releases the mem pool mutex if we are not in server shutdown. As +its corresponding mem_pool_mutex_enter() function, use it only +in memory free functions */ +UNIV_INLINE void -mem_pool_mutex_exit(void) -/*=====================*/ +mem_pool_mutex_exit( +/*================*/ + mem_pool_t* pool) /*!< in: memory pool */ { - mutex_exit(&(mem_comm_pool->mutex)); + if (srv_shutdown_state < SRV_SHUTDOWN_EXIT_THREADS) { + mutex_exit(&(pool->mutex)); + } } /********************************************************************//** @@ -567,7 +578,7 @@ mem_area_free( n = ut_2_log(size); - mutex_enter(&(pool->mutex)); + mem_pool_mutex_enter(pool); mem_n_threads_inside++; ut_a(mem_n_threads_inside == 1); @@ -595,7 +606,7 @@ mem_area_free( pool->reserved += ut_2_exp(n); mem_n_threads_inside--; - mutex_exit(&(pool->mutex)); + mem_pool_mutex_exit(pool); mem_area_free(new_ptr, pool); @@ -611,7 +622,7 @@ mem_area_free( } mem_n_threads_inside--; - mutex_exit(&(pool->mutex)); + mem_pool_mutex_exit(pool); ut_ad(mem_pool_validate(pool)); } @@ -630,7 +641,7 @@ mem_pool_validate( ulint free; ulint i; - mutex_enter(&(pool->mutex)); + mem_pool_mutex_enter(pool); free = 0; @@ -658,7 +669,7 @@ mem_pool_validate( ut_a(free + pool->reserved == pool->size); - mutex_exit(&(pool->mutex)); + mem_pool_mutex_exit(pool); return(TRUE); } diff --git a/storage/innodb_plugin/srv/srv0start.c b/storage/innodb_plugin/srv/srv0start.c index e517b9a86b0..ba9fc831b39 100644 --- a/storage/innodb_plugin/srv/srv0start.c +++ b/storage/innodb_plugin/srv/srv0start.c @@ -2018,9 +2018,13 @@ innobase_shutdown_for_mysql(void) pars_lexer_close(); log_mem_free(); buf_pool_free(); - ut_free_all_mem(); mem_close(); + /* ut_free_all_mem() frees all allocated memory not freed yet + in shutdown, and it will also free the ut_list_mutex, so it + should be the last one for all operation */ + ut_free_all_mem(); + if (os_thread_count != 0 || os_event_count != 0 || os_mutex_count != 0 From f67481558db6c0f746fdbed4d7d5e2c82b45980e Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Wed, 28 Jul 2010 12:59:19 -0300 Subject: [PATCH 077/118] Bug#53463: YaSSL patch appears to be reverted The problem is that the fix Bug#29784 was mistakenly reverted when updating YaSSL to a newer version. The solution is to re-apply the fix and this time actually add a meaningful test case so that possible regressions are caught. extra/yassl/taocrypt/src/coding.cpp: Fixed buffer allocation to compute the proper maximum decoded size: (EncodedLength * 3/4) + 3 mysql-test/std_data/server8k-cert.pem: Update certificate. mysql-test/std_data/server8k-key.pem: Update key. mysql-test/t/ssl_8k_key-master.opt: Start the server using the certificate and key that triggers the problem. --- extra/yassl/taocrypt/src/coding.cpp | 2 +- mysql-test/std_data/server8k-cert.pem | 172 +++++++---------------- mysql-test/std_data/server8k-key.pem | 194 +++++++++++++------------- mysql-test/t/ssl_8k_key-master.opt | 1 + 4 files changed, 148 insertions(+), 221 deletions(-) create mode 100644 mysql-test/t/ssl_8k_key-master.opt diff --git a/extra/yassl/taocrypt/src/coding.cpp b/extra/yassl/taocrypt/src/coding.cpp index 7a9d50aaac9..7fc681e1a05 100644 --- a/extra/yassl/taocrypt/src/coding.cpp +++ b/extra/yassl/taocrypt/src/coding.cpp @@ -185,7 +185,7 @@ void Base64Decoder::Decode() { word32 bytes = coded_.size(); word32 plainSz = bytes - ((bytes + (pemLineSz - 1)) / pemLineSz); - plainSz = (plainSz * 3 + 3) / 4; + plainSz = ((plainSz * 3) / 4) + 3; decoded_.New(plainSz); word32 i = 0; diff --git a/mysql-test/std_data/server8k-cert.pem b/mysql-test/std_data/server8k-cert.pem index 06e118cf034..e71ba5722b9 100644 --- a/mysql-test/std_data/server8k-cert.pem +++ b/mysql-test/std_data/server8k-cert.pem @@ -1,125 +1,51 @@ -Certificate: - Data: - Version: 1 (0x0) - Serial Number: 1048579 (0x100003) - Signature Algorithm: md5WithRSAEncryption - Issuer: C=SE, ST=Uppsala, L=Uppsala, O=MySQL AB - Validity - Not Before: Jan 29 12:01:53 2010 GMT - Not After : Jan 28 12:01:53 2015 GMT - Subject: C=SE, ST=Uppsala, O=MySQL AB, CN=server - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (8192 bit) - Modulus: - 00:ca:aa:1d:c4:11:ec:91:f0:c7:ff:5f:90:92:fc: - 40:0c:5e:b7:3d:00:c5:20:d5:0f:89:31:07:d7:41: - 4c:8b:60:80:aa:38:14:de:93:6b:9c:74:88:41:68: - b5:02:41:01:2d:86:a2:7a:95:53:5e:7b:67:2f:6c: - 1e:29:51:f9:44:fd:4a:80:be:b2:23:a1:3e:1b:38: - cf:88:c4:71:ee:f8:6b:41:c5:2d:c0:c3:52:ac:59: - 7d:81:34:19:95:32:b8:9a:51:b6:41:36:d4:c4:a1: - ae:84:e6:38:b9:e8:bf:96:be:19:7a:6b:77:4d:e0: - de:e6:b3:b6:6b:bc:3d:dd:68:bc:4b:c4:eb:f5:36: - 93:ed:56:a2:15:50:8a:10:e8:d6:22:ed:6c:b1:cd: - c3:18:c9:f6:0a:e1:de:61:65:62:d6:14:41:8c:b5: - fb:14:68:c1:cf:12:5d:41:21:9d:57:11:43:7d:bb: - 43:2c:21:bb:c3:44:7d:a8:cf:1f:c3:71:75:b5:47: - c2:7d:ce:38:3c:73:64:9e:15:d8:a7:27:cf:bd:40: - c8:45:08:e3:c8:39:a8:0b:8e:c2:5b:7b:f1:47:91: - 12:91:cc:e1:00:e0:94:5b:bd:32:e4:0c:8d:c3:be: - cc:76:32:52:12:69:b0:18:e0:b0:c2:76:34:5a:5f: - 79:d9:f6:81:9d:02:0a:61:69:1c:33:ce:49:fa:76: - 03:1e:07:5b:27:0b:bf:34:9e:34:96:b8:03:9b:50: - 3a:6a:2f:17:7a:14:cf:65:63:00:37:52:a8:73:ce: - 4b:14:40:f4:d2:9a:56:54:33:b8:77:2e:42:5b:8f: - ec:1f:18:f4:ad:ab:8a:4a:8d:6d:70:25:f3:58:e7: - cb:66:51:14:7d:16:f4:eb:6d:56:76:76:51:6e:d6: - 1d:da:d3:8d:c0:64:5a:67:4e:af:e2:bf:33:d1:b8: - f6:2a:fc:57:87:a7:35:5e:80:c9:ac:fc:87:c9:71: - 17:91:bf:b7:4d:a3:ed:3c:1b:27:f4:66:a0:f9:46: - 03:27:cc:ea:80:f6:4b:40:f6:41:94:cd:bd:0a:b3: - ef:26:be:de:6f:69:ae:0f:3f:1c:55:63:33:90:9b: - ed:ca:5a:12:4d:de:4b:06:c2:a2:92:b0:42:3d:31: - af:a4:15:12:15:f8:8a:e9:88:8d:cf:fd:85:66:50: - 6f:11:f1:9f:48:f3:b5:ba:9d:86:68:24:a2:5d:a8: - 7c:54:42:fa:d8:b5:c5:f2:dd:0e:0f:d0:68:e4:54: - 7e:c5:b9:a0:9b:65:2d:77:f4:8f:b9:30:0a:d5:86: - 5c:ed:c9:7c:d1:da:9d:0d:63:50:ee:e5:1e:92:63: - cc:a2:0c:e8:4a:96:02:4d:dc:8f:df:7c:8f:08:18: - a8:30:88:d7:af:89:ad:fc:57:4b:10:f9:f1:cb:48: - e8:b6:3b:c8:3f:fc:c2:d3:d1:4a:10:3c:1b:6b:64: - dc:e5:65:1e:5b:b2:da:b1:e2:24:97:8f:ee:c0:4b: - 8e:18:83:7c:17:a6:3c:45:b3:60:06:23:f2:2f:18: - 13:9e:17:8a:c6:72:79:8c:4d:04:f3:9d:ea:e0:25: - d3:33:8c:1e:11:47:63:1f:a5:45:3f:bd:85:b3:fe: - a5:68:ee:48:b7:0c:a4:c9:7f:72:d0:75:66:9b:6a: - f9:a0:50:f3:a8:59:6d:a3:dd:38:4f:70:2b:bb:ff: - 92:2e:71:ab:ef:e9:00:ed:0d:d1:b4:6f:f0:8e:b2: - 09:fb:4d:61:0d:d9:10:d5:54:11:cd:03:94:84:fd: - a8:68:e4:45:6e:1e:6a:1e:2f:85:a1:6d:f5:b6:c0: - f1:ee:f7:36:e9:fe:c2:f7:ad:cc:13:46:5b:88:42: - f0:2d:1f:b5:0e:7e:b5:2b:e4:8d:ab:b9:87:30:6a: - 3d:12:f4:ad:f3:1c:ac:cc:1a:48:29:2a:96:7b:80: - 00:0b:6e:59:87:bf:a3:ca:70:99:1b:1c:fd:72:3d: - b2:d3:94:4a:cf:55:75:be:1f:40:ec:55:35:48:2d: - 55:f0:00:da:3c:b0:60:ba:11:32:66:54:0b:be:06: - a4:5e:b7:c9:59:bb:4d:f4:92:06:26:48:6e:c2:12: - d4:7c:f0:20:b8:a2:e1:bc:6a:b6:19:0e:37:47:55: - c9:f2:49:0d:96:75:a2:84:64:bf:34:fc:be:b2:41: - e4:f5:88:eb:e1:b7:26:a5:e5:41:c2:20:0c:f6:e2: - a8:a5:e7:76:54:a5:fb:4b:80:05:7d:18:85:7a:ba: - bc:b7:ad:c0:2f:60:85:cc:15:12:1c:2f:0a:9e:f3: - 7c:40:cf:f4:3e:23:d2:95:ca:d0:06:58:52:f0:84: - d8:0f:3d:eb:ff:12:68:94:79:8f:be:40:29:5f:98: - c8:90:6c:05:2f:99:8c:2a:63:78:1f:23:b1:29:c5: - e7:49:c9:b2:92:0f:53:0b:d5:71:28:17:c2:19:bf: - 60:bf:7c:87:a8:ab:c1:f4:0a:c1:b8:d2:68:ee:c1: - ce:a7:13:13:17:6d:24:5d:a2:37:a6:d7:7d:48:8b: - 2b:74:2d:40:2e:ca:19:d5:b6:3e:6c:42:71:fa:cf: - 85:87:f9:de:80:73:8b:89:f4:70:f0:d8:d7:ff:40: - 41:9c:c7:15:6d:9b:6e:4c:b5:52:02:99:79:32:73: - ca:26:a0:ac:31:6f:c4:b0:f5:da:bb:c2:1f:e0:9f: - 44:ba:25:f7:9f - Exponent: 65537 (0x10001) - Signature Algorithm: md5WithRSAEncryption - 08:75:dc:b9:3f:aa:b6:7e:81:7a:39:d1:ee:ed:44:b6:ce:1b: - 37:c4:4c:19:d0:66:e6:eb:b5:4f:2a:ef:95:58:64:21:55:01: - 12:30:ac:8a:95:d1:06:de:29:46:a4:f1:7d:7f:b0:1e:d2:4e: - fb:f6:fa:9a:74:be:85:62:db:0b:82:90:58:62:c5:5f:f1:80: - 02:9f:c5:fb:f3:6b:b0:b4:3b:04:b1:e5:53:c2:d0:00:a1:1a: - 9d:65:60:6f:73:98:67:e0:9c:c8:12:94:79:59:bf:43:7b:f5: - 77:c8:8f:df:b1:cd:11:1c:01:19:99:c2:22:42:f7:41:ae:b4: - b8:1a -----BEGIN CERTIFICATE----- -MIIFfDCCBOUCAxAAAzANBgkqhkiG9w0BAQQFADBEMQswCQYDVQQGEwJTRTEQMA4G -A1UECBMHVXBwc2FsYTEQMA4GA1UEBxMHVXBwc2FsYTERMA8GA1UEChMITXlTUUwg -QUIwHhcNMTAwMTI5MTIwMTUzWhcNMTUwMTI4MTIwMTUzWjBDMQswCQYDVQQGEwJT -RTEQMA4GA1UECBMHVXBwc2FsYTERMA8GA1UEChMITXlTUUwgQUIxDzANBgNVBAMT -BnNlcnZlcjCCBCIwDQYJKoZIhvcNAQEBBQADggQPADCCBAoCggQBAMqqHcQR7JHw -x/9fkJL8QAxetz0AxSDVD4kxB9dBTItggKo4FN6Ta5x0iEFotQJBAS2GonqVU157 -Zy9sHilR+UT9SoC+siOhPhs4z4jEce74a0HFLcDDUqxZfYE0GZUyuJpRtkE21MSh -roTmOLnov5a+GXprd03g3uaztmu8Pd1ovEvE6/U2k+1WohVQihDo1iLtbLHNwxjJ -9grh3mFlYtYUQYy1+xRowc8SXUEhnVcRQ327Qywhu8NEfajPH8NxdbVHwn3OODxz -ZJ4V2Kcnz71AyEUI48g5qAuOwlt78UeREpHM4QDglFu9MuQMjcO+zHYyUhJpsBjg -sMJ2NFpfedn2gZ0CCmFpHDPOSfp2Ax4HWycLvzSeNJa4A5tQOmovF3oUz2VjADdS -qHPOSxRA9NKaVlQzuHcuQluP7B8Y9K2rikqNbXAl81jny2ZRFH0W9OttVnZ2UW7W -HdrTjcBkWmdOr+K/M9G49ir8V4enNV6Ayaz8h8lxF5G/t02j7TwbJ/RmoPlGAyfM -6oD2S0D2QZTNvQqz7ya+3m9prg8/HFVjM5Cb7cpaEk3eSwbCopKwQj0xr6QVEhX4 -iumIjc/9hWZQbxHxn0jztbqdhmgkol2ofFRC+ti1xfLdDg/QaORUfsW5oJtlLXf0 -j7kwCtWGXO3JfNHanQ1jUO7lHpJjzKIM6EqWAk3cj998jwgYqDCI16+JrfxXSxD5 -8ctI6LY7yD/8wtPRShA8G2tk3OVlHluy2rHiJJeP7sBLjhiDfBemPEWzYAYj8i8Y -E54XisZyeYxNBPOd6uAl0zOMHhFHYx+lRT+9hbP+pWjuSLcMpMl/ctB1Zptq+aBQ -86hZbaPdOE9wK7v/ki5xq+/pAO0N0bRv8I6yCftNYQ3ZENVUEc0DlIT9qGjkRW4e -ah4vhaFt9bbA8e73Nun+wvetzBNGW4hC8C0ftQ5+tSvkjau5hzBqPRL0rfMcrMwa -SCkqlnuAAAtuWYe/o8pwmRsc/XI9stOUSs9Vdb4fQOxVNUgtVfAA2jywYLoRMmZU -C74GpF63yVm7TfSSBiZIbsIS1HzwILii4bxqthkON0dVyfJJDZZ1ooRkvzT8vrJB -5PWI6+G3JqXlQcIgDPbiqKXndlSl+0uABX0YhXq6vLetwC9ghcwVEhwvCp7zfEDP -9D4j0pXK0AZYUvCE2A896/8SaJR5j75AKV+YyJBsBS+ZjCpjeB8jsSnF50nJspIP -UwvVcSgXwhm/YL98h6irwfQKwbjSaO7BzqcTExdtJF2iN6bXfUiLK3QtQC7KGdW2 -PmxCcfrPhYf53oBzi4n0cPDY1/9AQZzHFW2bbky1UgKZeTJzyiagrDFvxLD12rvC -H+CfRLol958CAwEAATANBgkqhkiG9w0BAQQFAAOBgQAIddy5P6q2foF6OdHu7US2 -zhs3xEwZ0Gbm67VPKu+VWGQhVQESMKyKldEG3ilGpPF9f7Ae0k779vqadL6FYtsL -gpBYYsVf8YACn8X782uwtDsEseVTwtAAoRqdZWBvc5hn4JzIEpR5Wb9De/V3yI/f -sc0RHAEZmcIiQvdBrrS4Gg== +MIIJFDCCBPwCAQEwDQYJKoZIhvcNAQEEBQAwTjELMAkGA1UEBhMCU0UxEDAOBgNV +BAgTB1VwcHNhbGExETAPBgNVBAoTCE15U1FMIEFCMQ0wCwYDVQQLEwRUZXN0MQsw +CQYDVQQDEwJDQTAeFw0xMDA3MjgxNDA3MjhaFw0xODEwMTQxNDA3MjhaMFIxCzAJ +BgNVBAYTAlNFMRAwDgYDVQQIEwdVcHBzYWxhMREwDwYDVQQKEwhNeVNRTCBBQjEN +MAsGA1UECxMEVGVzdDEPMA0GA1UEAxMGc2VydmVyMIIEIjANBgkqhkiG9w0BAQEF +AAOCBA8AMIIECgKCBAEA6h3v1OWb9I9U/Z8diBu/xYGS8NCTD3ZESboHxVI2qSEC +PgxNNcG8Lh0ktQdgYcOe64MnDTZX0Bibm47hoDldrAlTSffFxQhylqBBoXxDF+Lr +hXIqCz7K0PsK+bYusL9ezJ7PETDnCT7oy95q4GXbKsutbNsm9if4ZE41gs2KnoU2 +DA7kvMmkKojrMIL4+BqTXA20LLo0iSbgvUTvpSJw4u96BeyzMNnxK2wP5vvTtUo5 +hACbfU87YjaSKs+q2VXCzfyYGZk1L1xk5GUI0bP+jutf1dDzNttW2/q2Nf5rxx09 +Gh/GwmOnEk1O7cOZ8VQCsOHirIM39NuSARsY6Y3G5XM4k2W4nxyR/RtdG9bvs/33 +aGsZ5V5yp7WSs8s9HHwaCPSsUiLKckQ7uA0TTRgbeweMrrLKovG57jsbBBB8pQD4 +PRd31qgxCdstWXHiWwRyI8vOLWENPXPFqA/rJwwqNdWTogy38aqVXxGYR8PIwjA2 +OaIwFjwGZcsPNLqw6bgAN8O2UBqZHWiMF8mi7brvioDvAIufZuqa2SqT/At45H83 +psQ6R4FsxZt6SAK7EsdPo8OYTrY1i4iPZd/eKhnEu2srEZgsKRwY5H1mvDH5fWCc +HSFu07sWmlmK6Or65Fsa0IaKLJiQDVVETd6xrI0wkM4AOcbKDrS7aywJ426dopbs ++LFdt4N0cdII4gBgJAfLuuA2yrDXRq4P6cgpVMy0R+0dEYE8zzm8zf1a+Ud273LS +9+LB+LJKwqbW8nOPBoiekimIKfJYoOA4+C/mAjsYl1sVjjEhXJAs9S9L2UvnUk1P +sZi4UKHI6eAIEl7VM1sQ4GbdZ0px2dF2Ax7pGkhD+DLpYyYkCprharKZdmuUNLUd +NhXxi/HSEiE+Uy+o8RIzmH7LuROl/ZgnfHjJEiBLt2qPvwrwYd4c3XuXWs4YsWfV +JTt8Mx2ihgVcdGy9//shCSmgJwR1oWrhgC10AEL2fKeRnYUal1i+IxFPp7nb8uwx +UADgR0cY4A3qR/JP489QFIcxBTVs65De+Bq3ecnujk6yeGpD9iptonq4Y8uNZMc1 +kOE7GiFGwR4EufT5SEMh+tUkjth2r+842vmZZuxrVQaohDiATmIJA07W51zKH+nQ +uw4qVKnAhPaDLCLc7YMIH9JcmkeQX0nf8/S2O2WYDH8glVDi5hfW08tCmV647vRY +nTIywUTO0lFpz7M+VyMNaJ6yXU6biBV5hLAI8C5ldr/SWI789W2+ebBaJ9gfK+PT +trohFSK37GcoSH4V6qSLJHCBASEsiddqHIHMLJZRYD+B6J3tLhjVUM43u+MEGbFT +d33ZDke/WzLTExWkaOv36e67gDBmgDuj9yroq3wGfwIDAQABMA0GCSqGSIb3DQEB +BAUAA4IEAQCc9RBhRbuWlmRZPZkqIdi5/+enyjoMmOa6ryJPxFSP8D2jrlHgQsk1 ++GsJmPFT3rwWfoGAQu/aeSX4sp8OhKVJtqNA6MJrGYnZIMolgYa1wZPbkjJsdEfi +UsZdIB0n2+KA0xwEdGPdkGCfNPBtOg557DkcyEvsIZ9ELp4Pp2XzWRhyFGasJZc4 +YwgD/3K2rpOPZoMkBKeKqV19j41OfLKGBVyuaqzitbu9+KT4RU1ibr2a+UuFCwdT +oqyN7bfWXjcjXOMkxCsOmLfKmqQxs7TEOVrYPTdYjamDxLy/e5g5FgoCxGY8iil0 ++YFLZyH6eEx/Os9DlG/M3O1MeRD9U97CdsphbDVZIDyWw5xeX8qQHJe0KSprAgiG +TLhTZHeyrKujQCQS1oFFmNy4gSqXt0j1/6/9T80j6HeyjiiYEaEQK9YLTAjRoA7W +VN8wtHI5F3RlNOVQEJks/bjdlpLL3VhaWtfewGh/mXRGcow84cgcsejMexmhreHm +JfTUl9+X1IFFxGq2/606A9ROQ7kN/s4rXu7/TiMODXI/kZijoWd2SCc7Z0YWoNo7 +IRKkmZtrsflJbObEuK2Jk59uqzSxyQOBId8qtbPo8qJJyHGV5GCp34g4x67BxJBo +h1iyVMamBAS5Ip1ejghuROrB8Hit8NhAZApXju62btJeXLX+mQayXb/wC/IXNJJD +83tXiLfZgs6GzLAq7+KW/64sZSvj87CPiNtxkvjchAvyr+fhbBXCrf4rlOjJE6SH +Je2/Jon7uqijncARGLBeYUT0Aa6k1slpXuSKxDNt7EIkP21kDZ5/OJ0Y1u587KVB +dEhuDgNf2/8ij7gAQBwBoZMe1DrwddrxgLLBlyHpAZetNYFZNT+Cs/OlpqI0Jm59 +kK9pX0BY4AGOd23XM3K/uLawdmf67kkftim7aVaqXFHPiWsJVtlzmidKvNSmbmZe +dOmMXp6PBoqcdusFVUS7vjd3KAes5wUX/CaTyOOPRu0LMSnpwEnaL76IC9x4Jd6d +7QqY/OFTjpPH8nP57LwouiT6MgSUCWGaOkPuBJ9w9sENSbbINpgJJ42iAe2kE+R7 +qEIvf/2ETCTseeQUqm2nWiSPLkNagEh6kojmEoKrGyrv3YjrSXSOY1a70tDVy43+ +ueQDQzNZm3Q7inpke2ZKvWyY0LQmLzP2te+tnNBcdLyKJx7emPRTuMUlEdK7cLbt +V3Sy9IKtyAXqqd66fPFj4NhJygyncj8M6CSqhG5L0GhDbkA8UJ8yK/gfKm3h5xe2 +utULK5VMtAhQt6cVahO59A9t/OI17y45bmlIgdlEQISzVFe9ZbIUJW44zBfPx74k +/w8pMRr8gEuRqpL2WdJiKGG6lhMHLVFo -----END CERTIFICATE----- diff --git a/mysql-test/std_data/server8k-key.pem b/mysql-test/std_data/server8k-key.pem index faf4b43fa56..99e7417733e 100644 --- a/mysql-test/std_data/server8k-key.pem +++ b/mysql-test/std_data/server8k-key.pem @@ -1,99 +1,99 @@ -----BEGIN RSA PRIVATE KEY----- -MIISKgIBAAKCBAEAyqodxBHskfDH/1+QkvxADF63PQDFINUPiTEH10FMi2CAqjgU -3pNrnHSIQWi1AkEBLYaiepVTXntnL2weKVH5RP1KgL6yI6E+GzjPiMRx7vhrQcUt -wMNSrFl9gTQZlTK4mlG2QTbUxKGuhOY4uei/lr4Zemt3TeDe5rO2a7w93Wi8S8Tr -9TaT7VaiFVCKEOjWIu1ssc3DGMn2CuHeYWVi1hRBjLX7FGjBzxJdQSGdVxFDfbtD -LCG7w0R9qM8fw3F1tUfCfc44PHNknhXYpyfPvUDIRQjjyDmoC47CW3vxR5ESkczh -AOCUW70y5AyNw77MdjJSEmmwGOCwwnY0Wl952faBnQIKYWkcM85J+nYDHgdbJwu/ -NJ40lrgDm1A6ai8XehTPZWMAN1Koc85LFED00ppWVDO4dy5CW4/sHxj0rauKSo1t -cCXzWOfLZlEUfRb0621WdnZRbtYd2tONwGRaZ06v4r8z0bj2KvxXh6c1XoDJrPyH -yXEXkb+3TaPtPBsn9Gag+UYDJ8zqgPZLQPZBlM29CrPvJr7eb2muDz8cVWMzkJvt -yloSTd5LBsKikrBCPTGvpBUSFfiK6YiNz/2FZlBvEfGfSPO1up2GaCSiXah8VEL6 -2LXF8t0OD9Bo5FR+xbmgm2Utd/SPuTAK1YZc7cl80dqdDWNQ7uUekmPMogzoSpYC -TdyP33yPCBioMIjXr4mt/FdLEPnxy0jotjvIP/zC09FKEDwba2Tc5WUeW7LaseIk -l4/uwEuOGIN8F6Y8RbNgBiPyLxgTnheKxnJ5jE0E853q4CXTM4weEUdjH6VFP72F -s/6laO5ItwykyX9y0HVmm2r5oFDzqFlto904T3Aru/+SLnGr7+kA7Q3RtG/wjrIJ -+01hDdkQ1VQRzQOUhP2oaORFbh5qHi+FoW31tsDx7vc26f7C963ME0ZbiELwLR+1 -Dn61K+SNq7mHMGo9EvSt8xyszBpIKSqWe4AAC25Zh7+jynCZGxz9cj2y05RKz1V1 -vh9A7FU1SC1V8ADaPLBguhEyZlQLvgakXrfJWbtN9JIGJkhuwhLUfPAguKLhvGq2 -GQ43R1XJ8kkNlnWihGS/NPy+skHk9Yjr4bcmpeVBwiAM9uKoped2VKX7S4AFfRiF -erq8t63AL2CFzBUSHC8KnvN8QM/0PiPSlcrQBlhS8ITYDz3r/xJolHmPvkApX5jI -kGwFL5mMKmN4HyOxKcXnScmykg9TC9VxKBfCGb9gv3yHqKvB9ArBuNJo7sHOpxMT -F20kXaI3ptd9SIsrdC1ALsoZ1bY+bEJx+s+Fh/negHOLifRw8NjX/0BBnMcVbZtu -TLVSApl5MnPKJqCsMW/EsPXau8If4J9EuiX3nwIDAQABAoIEAElnTjqq502AsV+c -hGfId4ZDdAjjU4LtyJ+/I4DihM/ilxeQEnb/XDWhu4w9WXpEgyGzJvxRQ43wElKJ -zW7X4voK58Yzy5++EhmX/QsjY8TTMz3yJf0wgawtCZkXfsCcS2KRf/qk2nGRwf0e -yaMEWwhFOEMv01lgvjs/Ei55Usrz2Wd0HqaFKxUGkNQ5hJhVTOH/rqPDzAsZc0VD -w+Dw8NhrI8bMTvF4c+IFW8NwYmWbuh87CTxdx30VPJI82ttWJ/UN1bLtU08J2IKt -lPgOIl8ArMjcTGxD/cqZ3Wl3Pc/XCqvGUiSYMwP7Rgh1R4+DdtjEpxdGMmMAVuVI -HPQyqpa4gv+UMqBPish0yjSuM7jXnztINOvg9Vk1sxC5AT9eaRltmiS1s+lVxe+T -43ulf0ccYXJD/WclWSGCwloNFuokPIV+Lgo1pKsp4XDgoxQfkXwH8Q4dEqebY9rT -Tv9FGb1bMbdl22X1oSu2lBltBZaB/QnruV7L2GaQ0tqLKizgBRuvZFSE+DWdMb6d -9mnEB8LWtca/nzogXb5qv4GEMUX4FUAmSf1FnGWZwwDi1DFfJ860RVKf0xokGGQ3 -cm3H/F4veds88Z1hsAu0bG8h/bEAim+Whvag995cFHDD4on41KXW8wX1on9VFA1W -CkaGUPhLRytXDBVCSJkOYYFSJlb2wqONiWe4Tn5hsantCfliTj/GVkgDq2h7dAGR -WyoqTntJAv/xJsUOV9WmGXnWNeZX8BSO3P5dnXnMzhCWQGoprXmWFyJ3TYCJ2+CO -rzkZbtuKvTvGc3sDJgrSVmmg0BrOkH+GyYVlJdTDBmfzoORludDCFHECa8oK7NwY -t3o0eNlG6IqTxl2HIoPneW9nXFQtCXv6tpJjljwjlz5WpJG+kBW6bDedcxZu7olZ -fqtnyZTB2SjzzbGdQ4JvFup8MxNyPvYiqumQXJgkyXFVDl/UFhjWuGe04i8NBJgJ -xORcjfgLrKH1XKVBWPJdh/2YeUKIIvQ9RB4WVqXgGmD/21tgv1bVEMYabh23e/HE -Fe1U2XQPJKxGCEtG6b4zhFP+PeZACS+Vk5IVJYK9n4SepPBPgX/wbJLOcKGpsKjp -yx5WjopMO6T+VUV8HIduuZ+E8+uAILHDmo2Bq+LHblaxd4SkM0+hL2H36imK5CUO -5fLuvHW88LvFtQw6xhP20s+BnmgzE5ZvNG4Iedkjvwe9HmdNDew0UYT5vNJN0ehh -OlraBC++JYwEclrBD9SRvprT63XKDG735pPvzLQi7WKDCBn1/JEgxDIO8nkMewOZ -FU48Mdmkn9wqPeIigQciwl62fuAQCGRG+RXMQqra4A1apqMZQEauTK50VhHDGdbc -ye9LHaECggIBAO9lAzoYS/Lu0ticMt24P8BSbGdxSNIpEyIlTTs+7A0UjpfXsoK9 -4EJWZ7lhgbQh+SCTS662SeC+s8M6bT+3mELxUC5S/N3aCPyfjcM3JaoACkI9+VMn -9otJZjAEwH7cNpMN0Xa8fHCEma3l3XKiVxEJbuJC86S5mpkjeXVnDajAidBtevBd -LWJ9n2yXk+ZKUyI0mjpqItwUxOgQ/MOIvqAu66xyjg08/I1QQTuIrReAA+oaVKhp -c42Ufn26hUhNrQCBAtMAO3VC/chciet6vEMNEM13GqLp4+PcPhRX90gO4+bNrScD -WgiW/jc24CGan8gAenBWC/3l/C6JUsMp+ZYmPozsa0zo6edgiO/f2KXe5nP87wZT -MxaYJgnyXJxMefI79kUHPrhpXZxuiSCEWLhCBN34Lhpr2L491i2g/FJj9i6N3EzE -N3ic5Q63o4QFusjqIm3taQQFoGP2Cgg9owz5WJ0uRz/gtOE3XQiQA7+ozoAXOlTw -pJK5MMtVrEoOLIbVJIpxfDcKDp3yorR8QCQLHgDBmFeNCDmk+7YP33dRIc/AVNLF -q7cecqEc7D8AkXX8Q53GfCEg+uqbdeMQXK4BUE9iwRK9RiFhas/RJe73+Iio3S0L -ekLpnnOfvk744ws+JWsLpsfC/ZE7OxBLPtq2xvGl/RT2G7tCjmpX3CbPAoICAQDY -uOEJks2T105EcMPJjzNHCCqjK6S7qZaWkF3KT1Z0Mu5oUZwwHamsMg4BQJ2mjMrL -fRBKfXQLA6vgE7zysw3F300RDxE1RVow5+JLDQ4bqupp27/M0a8fuwksyOdKHqCV -YHzuTCxbVIFZawTjfOxJVXDHKCFCilfY1LsA+V+oFe3Ej8YYxWXkXA9ZLigpmt3s -Wu6eFcZgF3utzIGjI6eP6lL5bWp6Bh9Avp2xrOvpFwE2m02Y7/Zom6MT4DXvByY2 -KHHQLsasEMpeLuxQXjLeTocwcxBwBFKhX95yFuv31k00VydT+NExtaZeUYi9l19J -WmM4GjFjAqa3uUwMNVv5JfWtKMyk4FOox2XftLvMiIhV95B8hAGxtYr3hPkGg80O -AWPq6OKUD332COXRaHkmL5aQdN3gP5zh9+rH6icLrrZbrQidVRyDw03doRoGrH7i -ixXLyYoW80PHgqUDPohd5bFkZpi2vwXMl1YQ2TfN9TvYFSGme9YCm9ZuypnqauW/ -aAf0FI1MNwS+XDREtzPdFi0me6WxpKL4a2Z3GGNxIFuBjQ/uydWpjxkny9qI3KAp -SgjI3kBUDGq3gf0R+Xo/d4d/4asK9Nv2Fi0X+RfGqioFaTbQl/1zhNdvhP9IcwEJ -DLVQ3UhMdfg285RarC2Sihui0M8Smi9od9Dj6rdWMQKCAgEAiQVRFoRnnDGz/wVQ -W/Wkj6jdoUuG+btG10lwbhOyuj3k6+Yqp4iUfoPENKgpu/eiB1InhGWT3Y5ph7m+ -ZDTqco56bTlUwIqWkDmmw3CiHy6MsKOWPFFoXQry8VMW9sWGex7yoDp8I07SQ2WJ -HZ7rpLW4gMr/d25AnZxfXaJRgCBMAT9YmZFLc88hW99aaPproO1oxTyQnVVJ6uYm -NqjjKv4QKJEc21jn2N5xp+iv4f6Evw65G/fXitbOm5oRxXOoLNyqyCie35wrc+37 -hwumC97DmkasuUiUBoy9/5jl0ZmsOiPJEsZpVvdNpD7FhJZjE++qJPgrPvTPJbe1 -5jz1PUrAjJqZQ9kgYC2x01JVR4NQdlz0VrNyT2FgjFrrRQ7E0bAeYh4meRjd2rat -yC3YNgabkI0HnlnSIfl0yIMXSPUsKDNMP6gjc+aheI4FioBZC7xvXmn/rKynw+9E -iLj2xWtGnBir8VTlUu8EUe1UJ/Qv1cL1wT5HhC95TTjJN03rkHUYyCDyjvIzsZX6 -KMHhWIAAeUBVuO7hIVVcOTXWmw2WA7o7ErTPdy13QN40Hk9t8pEkBn9f9vpQg83d -aMypr3LTC80jY11wcZS3tSEpzCCkYVv91FV4cioTZmytWbg9A+dbNWzi1f22ctTr -FoVrAXaSYie2trOy5bjPmPCW8qMCggIBALQUKymBSkDmTqqf6I+65ajIKGWdBizJ -Jc/F9aj9c6DqER+tcFKq0ym6DdkMj/KsWnXrXXYH+DyOuGpg/EfOcEtS2P6rvmi9 -T8wDYg1qs6ZZxp5fcmgGc7Wx/FWyOj1kZZq5qhV4RgM9nJ1oR4+fZdcpn6RcvAZG -XehWG20byVgpoIAL11cN7zRpKne32rd3b5/NjyjcfxGpcaNgovej0L/MvVV0jV0H -aUCrIu1X+k6cRu3Q7hF+kwkpCcCiNS6AikfGI4wQ0hR3fy/zXXkKTMpcBglEEwyB -Cwf8WSID2d79uvka0hr8TRc5ERyeMzkWZp7U9EzRtufGdDGFTqN2Uw4bdKCFnkYC -AIHl7ciMrN+vM1n7c5uDNMUtTGOPojy/l8tjbFrtWBgfJ1Mg4ZW3cbNBJ6Kw+Qw0 -z28USYoEDp2uduiGRvo0lpUF29Wk37Nb8bLcTygeNxgK2u8Up3iipT0gdt4uQgbX -g0IVHfayB6SjeS57oJJto85XHz7AKlSWroD1OGagDSifLtneU7AlanryymGHrI6H -dsNkuqeLJFYDxQVI6UxJebiCpyxiPxwp9wtX8SS3SEyOZL5GzLn6ypGiCH1CTpW0 -EHHSy3V4DUGOc4w7eMirAnbSkxCfOmBA70NNw/uFY2XlQHKow0T0fImfKIeJagbT -B0GPDYvUpLKBAoICAQCzYnq8xupXK7lvTLaj936qGSe54OC2sj9+UpsFiPxglNY2 -sO5zKWKyY7+rjK6zG2ciGfPEDsZNIqKw1W/KBfR2kRLqkt4bC3fSCvUztx0vtGUe -veXlqiwETdE7RJXoaGJrgJArYJvpOd8PtWGeM+sSJNNrUlGlJnSiZ0CcypqUZgZL -WzGFfLOQYAXCykdB1iZkBqU2C5wktvCb9sVz6G3TmAwSKTENOWWZWmh+W0J4pZFV -ZEyvsxViJRQbwxa0kC0F5J/UtWZknO79/ZFj1H4jiAR45EjWHE+UZAkFwG8BSl54 -EKOx7GDanuRILr0dtbyi4d31nCYXdjs3x2+1N3exw4oKQIvNuF54WoowbNPu0kEb -G+7/kLwcJqRnSV4AiLuMz5aOte7JJSw5tzgZZlAQwJO7IDfrLqodivcXF5yirwiF -dyBpzSDmupy/aTHnCpT+l0H96jRU2awxaeRHZUqZog8gMHsslNVZEFvUFDJ7AUN/ -yyfUzJYjH18pZt0hS7jNb1O7KxZCkWGMiEcxHkgF/UINab5qruNBVKOkJ5vqGhYi -uNkgeGsQtXJcpqMRRiVXJE0kE+26gk+iaYnBJN9jnwy8OEAlYFUHsbCPObe/vPMQ -3RLl+ZoKdFkN/gTiy70wUTRVw+tWk+iAZc7GPX1CqDFOqGZ2t+xdF8hpsMtEww== +MIISKQIBAAKCBAEA6h3v1OWb9I9U/Z8diBu/xYGS8NCTD3ZESboHxVI2qSECPgxN +NcG8Lh0ktQdgYcOe64MnDTZX0Bibm47hoDldrAlTSffFxQhylqBBoXxDF+LrhXIq +Cz7K0PsK+bYusL9ezJ7PETDnCT7oy95q4GXbKsutbNsm9if4ZE41gs2KnoU2DA7k +vMmkKojrMIL4+BqTXA20LLo0iSbgvUTvpSJw4u96BeyzMNnxK2wP5vvTtUo5hACb +fU87YjaSKs+q2VXCzfyYGZk1L1xk5GUI0bP+jutf1dDzNttW2/q2Nf5rxx09Gh/G +wmOnEk1O7cOZ8VQCsOHirIM39NuSARsY6Y3G5XM4k2W4nxyR/RtdG9bvs/33aGsZ +5V5yp7WSs8s9HHwaCPSsUiLKckQ7uA0TTRgbeweMrrLKovG57jsbBBB8pQD4PRd3 +1qgxCdstWXHiWwRyI8vOLWENPXPFqA/rJwwqNdWTogy38aqVXxGYR8PIwjA2OaIw +FjwGZcsPNLqw6bgAN8O2UBqZHWiMF8mi7brvioDvAIufZuqa2SqT/At45H83psQ6 +R4FsxZt6SAK7EsdPo8OYTrY1i4iPZd/eKhnEu2srEZgsKRwY5H1mvDH5fWCcHSFu +07sWmlmK6Or65Fsa0IaKLJiQDVVETd6xrI0wkM4AOcbKDrS7aywJ426dopbs+LFd +t4N0cdII4gBgJAfLuuA2yrDXRq4P6cgpVMy0R+0dEYE8zzm8zf1a+Ud273LS9+LB ++LJKwqbW8nOPBoiekimIKfJYoOA4+C/mAjsYl1sVjjEhXJAs9S9L2UvnUk1PsZi4 +UKHI6eAIEl7VM1sQ4GbdZ0px2dF2Ax7pGkhD+DLpYyYkCprharKZdmuUNLUdNhXx +i/HSEiE+Uy+o8RIzmH7LuROl/ZgnfHjJEiBLt2qPvwrwYd4c3XuXWs4YsWfVJTt8 +Mx2ihgVcdGy9//shCSmgJwR1oWrhgC10AEL2fKeRnYUal1i+IxFPp7nb8uwxUADg +R0cY4A3qR/JP489QFIcxBTVs65De+Bq3ecnujk6yeGpD9iptonq4Y8uNZMc1kOE7 +GiFGwR4EufT5SEMh+tUkjth2r+842vmZZuxrVQaohDiATmIJA07W51zKH+nQuw4q +VKnAhPaDLCLc7YMIH9JcmkeQX0nf8/S2O2WYDH8glVDi5hfW08tCmV647vRYnTIy +wUTO0lFpz7M+VyMNaJ6yXU6biBV5hLAI8C5ldr/SWI789W2+ebBaJ9gfK+PTtroh +FSK37GcoSH4V6qSLJHCBASEsiddqHIHMLJZRYD+B6J3tLhjVUM43u+MEGbFTd33Z +Dke/WzLTExWkaOv36e67gDBmgDuj9yroq3wGfwIDAQABAoIEAQCSt6YoZqigz/50 +XvYT6Uf6T6S1lBDFXNmY1qOuDkLBJTWRiwYMDViQEaWCaZgGTKDYeT3M8uR/Phyu +lRFi5vCEMufmcAeZ3hxptw7KU+R8ILJ207/zgit6YglTys9h5txTIack39+6FJmx +wbZ64HpETJZnpMO6+fuZaMXyLjuT8mmXjvHcOgXOvjWeFkZOveDhjJkAesUXuqyX +EI+ajoXuQiPXeKonkD2qd7NTjzfy4gw/ZF4NXs0ZVJeviqtIPo2xp33udOw2vRFh +bMvlF4cNLAbIKYVyOG0ruOfd2I7Unsc/CvD1u5vlRVuUd8OO0JZLIZR7hlRX+A58 +8O1g2H/wJZAsF1BnLnFzDGYCX2WjCCK3Zn85FkKGRa0lTdYDduad/C/N3Y2/pHFE +e7U/2D7IkEei59tD2HcsDBB3MJnckkn/hyiL9qWcxqWZ61vurE+XjU6tc6fnfhk9 +pJQ6yU3epPU7Vfsk0UGA7bbgKpsyzyH8Zl76YC2mN2ZVJjZekfhY+ibT9odEPdOl +yLB5iXA6/WhKkDWaOqZGOH+7MblWgT9wHINlcn+nKzOr00JHl26ac6aMlXXi9vbe +4jgJbFK1HYlFIndyX/BdqRTsFemDoDrVqrEYsaONoVYDd9c5qrqYOeh34DhOksQW +hNwWBfmMlfzgOGtCYhMeK+AajqTtUbMYQA6qp47KJd/Oa5Dvi3ZCpvZh3Ll5iIau +rqCtmojsWCqmpWSu7P+Wu4+O3XkUMPdQUuQ5rJFESEBB3yEJcxqk/RItTcKNElNC +PASrPrMD9cli7S/pJ+frbhu1Gna1ArXzXQE9pMozPaBpjCig7+15R0lL3pmOKO6e +WK3dgSwrnW6TQdLPlSD4lbRoiIdTHVBczztDeUqVvFiV3/cuaEi1nvaVdAYLqjuL +ogK4HwE/FQ54S0ijAsP52n25usoH6OTU3bSd/7NTp0vZCy3yf10x7HUdsh2DvhRO +3+TSK5t0yz0Nt7hNwcI6pLmWUIYcZgpFc/WsiiGscTfhy8rh3kRHI8ylGq53KNF+ +yCVmjqnBRWs91ArxmeF1ctX2t3w5p7gf65hJWqoX/2DiSi5FBsr6HLxa5sUi4wRZ +136aCNt5Wu7w+AzPDbQW6qKUGSyfHJAw4JZasZcaZLise5IWb1ks0DtFbWWdT3ux +8r2AM7IO1WopnekrYCnx/aBvBAv4NjWozVA517ztVttPERt3AGb4nm387nYt5R2U +NO2GBWcDyT8JQLKmffE1AkWolCR1GsvcNLQfLCbnNppgsnsLE/viTG4mq1wjnd8O +2Q8nH1SVTuyGFREMp/zsiAEaGfdd0hI2r1J7OdNPBBCtmhITsy9ZYHqm5vrGvy3s +vi2GuB2RAoICAQD/oWUsg4eTJxHifTJLz/tVSTXnw7DhfbFVa1K1rUV63/MRQAFW +pabN4T6Yfp3CpdRkljCA8KPJZj7euwhm4OEg1ulpOouA+cfWlE9RFE8wyOK5SYwM +k+nk31P9MUC866pZg/ghzBGDub91OW1+ZGEtqnLI/n/LhiAIWt0hJvgZclTc1cAL +xffHVlFwoSyNl/nc3ueZCC95nOLst2XcuxZLLbOFtZCmDYsp49q/Jn6EFjn4Ge2o +qp38z6eZgDMP1F4lb9nDqXPHfUSt2jxKlmpfXS+IPKdba67+EjhbtmUYzaR4EoPI +zh+o6SrVWT6Yve7KGiYv06fuRz1m/lLQO/Arbd9ntSjgn+ZEXGOkbhnHUX3DJ4ny +/6XEGB9NLQjern4uNTn0AaV+uvhncapFMaIBnVfq0Cw8eog0136PBYRaVX7T44j5 +HwIyGXWtYGA/SzDEQoksD0Y/T61BEGnLZaKeavNd82WwFvcYHZtE0J4aQGjCEE7N ++nijzCy+j5ETmme9KJvQHpEyXP3N4RBko1eWvyTwFZDdIXtoa6TTEI51lm+FXJ/b +Y+BzMr6KRo29FB+7//1ptUoMvn5hzL0PwOv2ZSTQuoG5hLDEbxWXLNhd1VHcfznF +3EZHwfD2F8aGQ3kz+fkMTNfK955KorDrmLgvmV9eZZ5yQxGZrs5H5YfKpwKCAgEA +6nSUbzfSdVFUH89NM5FmEJgkD06vqCgHl2mpyF+VmDGcay4K06eA4QbRO5kns13+ +n6PcBl/YVW/rNE8iFi+WxfqUpAjdR1HlShvTuTRVqtFTfuN8XhbYU6VMjKyuE0kd +LKe3KRdwubjVNhXRZLBknU+3Y/4hnIR7mcE3/M5Zv5hjb7XnwWg/SzxV9WojCKiu +vQ7cXhH5/o7EuKcl1d6vueGhWsRylCG9RimwgViR2H7zD9kpkOc0nNym9cSpb0Gv +Lui4cf/fVwIt2HfNEGBjbM/83e2MH6b8Xp1fFAy0aXCdRtOo4LVOzJVAxn5dERMX +4JJ4d5cSFbssDN1bITOKzuytfBqRIQGNkOfizgQNWUiaFI0MhEN/icymjm1ybOIh +Gc9tzqKI4wP2X9g+u3+Oof1QaBcZ4UbZEU9ITN87Pa6XVJmpNx7A81BafWoEPFeE +ahoO4XDwlHZazDuSlOseEShxXcVwaIiqySy7OBEPBVuYdEd2Qw/z3JTx9Kw8MKnf +hu+ar5tz5dPnJIsvLeYCcJDe/K6loiZuHTtPbWEy9p6It7qubQNPBvTSBN5eVDKc +Q2bTQNCx8SAAA9C5gJiwWoQKsXJzbRFRY77P9JjuGpua3YJ2nYBHEJmF+fp1R33c +uHIyMphPMkKC4GC3/43kkMr6tck8kZbXGSYsLsBr2GkCggIBAJvvrjILQianzKcm +zAmnI6AQ+ssYesvyyrxaraeZvSqJdlLtgmOCxVANuQt5IW9djUSWwZvGL4Np1aw0 +15k6UNqhftzsE7FnrVneOsww4WXXBUcV8FKz4Bf3i9qFswILmGzmrfSf8YczRfGS +SJKzVPxwX3jwlrBmbx/pnb7dcLbFIbNcyLvl1ZJJu4BDMVRmgssTRp/5eExtQZg4 +//A4SA8wH7TO3yAMXvn8vrGgH8kfbdlEp88d1SYk3g4rP/rGB3A63NIYikIEzmJn +ICQ3wUfPJnGq3kRMWgEuyCZaCy2oNE3yrWVPJ8z3/2MJ/79ZDVNHxEeki2o1FuW+ ++nGAPq+fZIp03iy4HdVRro7dgugtc9QaSHJtNId8V4vSjviX5Oz3FxUb9AJst58S +nVV8Q2FMxBa/SlzSOkhRtCg2q1gXkzhaMnIVUleRZFGQ2uWBToxKMjcoUifIyN1J +z999bkfI4hBLq5pRSAXz+YVu5SMKa10GaawIwJLat+i+1zboF6QyI2o/Wz8nrsNq +KX/ajFGu5C94WFgsVoWKNI90KBLe48Ssje9c68waBlV/WHMg1YLvU3yqVDOV+K5c +IHB9tPMnG+AgBYZPxSzuvnLrrkj/GeKx0WI7TrvzOLRGKJo6irMEJ8IzFegASRUq +TVZKYQDYRG7m+lKlSxU+pyMAh2c9AoICAE4kavCip1eIssQjYLTGSkFPo/0iGbOv +G9CgXAE3snFWX67tWphupKrbjdMSWcQTmPD2OTg6q6zWL4twsIi6dcMooHAHsFC7 +//LyUV/SDJdxSyXohiQJ8zH1zwy35RDydnHSuF5OvLh53T44iWDI1dAEqLgAFI3J +LjTxzEpLMGiGTuYFt+ejai0WQAQayvBw4ESM9m+4CB2K0hBFTXv5y5HlnNTW0uWC +VUZUUMrbjUieDz8B/zOXi9aYSGFzmZFGUDAPSqJcSMEELemPDF7f8WNr8vi42tIV +4tlaFD1nep4F9bWMiCXU6B2RxVQi+7vcJEIqL1KUnGd3ydfD00K+ng4Xnj7Vz/cz +QE7CqrpFaXmPlCMzW6+dm51/AyhHXDLkL2od05hiXcNkJ7KMLWRqwExHVIxM3shR +x7lYNl3ArUsCrNd6m4aOjnrKFk7kjeLavHxskPccoGKrC9o0JMfTkWLgmuBJFQ0S +N/HzIbcvIFWF0Ms4ojb50yp6ziXhXfJOO/0KUQEki71XIhvw89mVZszDzD5lqzjf +HCZMBU4MbmL6NdEevFIDH0zPPkx3HPNtJt3kIJbit9wI8VhUMe+ldGnGxpWb8tKw +SfM3vrHkYr+lizk26XfXMFhdAuVtT7dzQKSNEyP/1a2Hs307Xzgiv8JulJ8QIkrX +/nsYWPOAGLG5AoICABmdW9Ppkvuhb1AEcjTWb+XCyopoBc6vit/uQWD9uO+CeX7a +cfzq+iH01CAjyVMc4E1JDc5Lpi106U+GRGcAAaPJB2Sp5NznoxaOVrb71blu4Q4x +bNjtKM/P/DXpO+yJYoOPdKtaSDhtnfNDM7H/jztJ3XIrOltKA7CcRDohbBWIx8Q0 +0uEpvfFpZZBco3yVmjP0RLgIVYn/ZDj9wGhSvFWIJ5vv6GXmtDrcHGMLxcfv7t76 +UVcMW/Yy4mYJRCzGOrWagyVijJ6MTVNciqadWcH1KcbB3EGoMFYMn61or2qJABPM +xz89IlhnROU1Re3X/QRx5t86cw6oa+FqrWMOhSs31I0dNWSuS/xDympG27YIYSDd +mv5seT78GjFmMJC5pPOLoXsbTPB0HpsX2/UL/w/eRAfilTOef/Cf9VE5MP/C2YR7 +NBxUU7/+21D6WvdtBTcZbrXWGroAo8zPP+PwX0+c6WoAvqDJvCPndp8xZhSgEJN/ +0kScptezi8n3ZHI95EA9U5mAHxHz0IhDDVzWw/z1f1SBPxKVX3+By3zaa3lrD2ch +cHq7nBkX72veEevnHUY8Z2rHE2G2jdmRfOtwm4sjL0VBV9fRRoxzJWRduKyeOtDL +EhhBhUoTrT48UnfW9hxnbNLB9P/hh+UJu9HrS2uAwHoGE1+8gcyundupGDBn -----END RSA PRIVATE KEY----- diff --git a/mysql-test/t/ssl_8k_key-master.opt b/mysql-test/t/ssl_8k_key-master.opt new file mode 100644 index 00000000000..b58ca7f39f0 --- /dev/null +++ b/mysql-test/t/ssl_8k_key-master.opt @@ -0,0 +1 @@ +--loose-ssl-key=$MYSQL_TEST_DIR/std_data/server8k-key.pem --loose-ssl-cert=$MYSQL_TEST_DIR/std_data/server8k-cert.pem From 2124538d9cea1cea39b01f0b8b99052b36004fb9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Jul 2010 11:00:57 +0800 Subject: [PATCH 078/118] BUG#49124 Security issue with /*!-versioned */ SQL statements on Slave /*![:version:] Query Code */, where [:version:] is a sequence of 5 digits representing the mysql server version(e.g /*!50200 ... */), is a special comment that the query in it can be executed on those servers whose versions are larger than the version appearing in the comment. It leads to a security issue when slave's version is larger than master's. A malicious user can improve his privileges on slaves. Because slave SQL thread is running with SUPER privileges, so it can execute queries that he/she does not have privileges on master. This bug is fixed with the logic below: - To replace '!' with ' ' in the magic comments which are not applied on master. So they become common comments and will not be applied on slave. - Example: 'INSERT INTO t1 VALUES (1) /*!10000, (2)*/ /*!99999 ,(3)*/ will be binlogged as 'INSERT INTO t1 VALUES (1) /*!10000, (2)*/ /* 99999 ,(3)*/ mysql-test/suite/rpl/t/rpl_conditional_comments.test: Test the patch for this bug. sql/mysql_priv.h: Rename inBuf as rawBuf and remove the const limitation. sql/sql_lex.cc: To replace '!' with ' ' in the magic comments which are not applied on master. sql/sql_lex.h: Remove the const limitation on parameter buff, as it can be modified in the function since this patch. Add member function yyUnput for Lex_input_stream. It set a character back the query buff. sql/sql_parse.cc: Rename inBuf as rawBuf and remove the const limitation. sql/sql_partition.cc: Remove the const limitation on parameter part_buff, as it can be modified in the function since this patch. sql/sql_partition.h: Remove the const limitation on parameter part_buff, as it can be modified in the function since this patch. sql/table.h: Remove the const limitation on variable partition_info, as it can be modified since this patch. --- .../rpl/r/rpl_conditional_comments.result | 57 ++++++++++++++ .../suite/rpl/t/rpl_conditional_comments.test | 74 +++++++++++++++++++ sql/mysql_priv.h | 2 +- sql/sql_lex.cc | 19 ++++- sql/sql_lex.h | 20 ++++- sql/sql_parse.cc | 12 +-- sql/sql_partition.cc | 2 +- sql/sql_partition.h | 2 +- sql/table.h | 2 +- 9 files changed, 173 insertions(+), 17 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_conditional_comments.result create mode 100644 mysql-test/suite/rpl/t/rpl_conditional_comments.test diff --git a/mysql-test/suite/rpl/r/rpl_conditional_comments.result b/mysql-test/suite/rpl/r/rpl_conditional_comments.result new file mode 100644 index 00000000000..105d3bc59f3 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_conditional_comments.result @@ -0,0 +1,57 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +CREATE TABLE t1(c1 INT); +show binlog events from ; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # use `test`; CREATE TABLE t1(c1 INT) + +# Case 1: +# ------------------------------------------------------------------ +# In a statement, some CCs are applied while others are not. The CCs +# which are not applied on master will be binlogged as common comments. +/*!99999 --- */INSERT /*!INTO*/ /*!10000 t1 */ VALUES(10) /*!99999 ,(11)*/; +show binlog events from ; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # use `test`; /* 99999 --- */INSERT /*!INTO*/ /*!10000 t1 */ VALUES(10) /* 99999 ,(11)*/ +Comparing tables master:test.t1 and slave:test.t1 + +# Case 2: +# ----------------------------------------------------------------- +# Verify whether it can be binlogged correctly when executing prepared +# statement. +PREPARE stmt FROM 'INSERT INTO /*!99999 blabla*/ t1 VALUES(60) /*!99999 ,(61)*/'; +EXECUTE stmt; +DROP TABLE t1; +CREATE TABLE t1(c1 INT); +EXECUTE stmt; +Comparing tables master:test.t1 and slave:test.t1 + +SET @value=62; +PREPARE stmt FROM 'INSERT INTO /*!99999 blabla */ t1 VALUES(?) /*!99999 ,(63)*/'; +EXECUTE stmt USING @value; +DROP TABLE t1; +CREATE TABLE t1(c1 INT); +EXECUTE stmt USING @value; +show binlog events from ; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # use `test`; INSERT INTO /* 99999 blabla*/ t1 VALUES(60) /* 99999 ,(61)*/ +master-bin.000001 # Query # # use `test`; DROP TABLE t1 +master-bin.000001 # Query # # use `test`; CREATE TABLE t1(c1 INT) +master-bin.000001 # Query # # use `test`; INSERT INTO /* 99999 blabla*/ t1 VALUES(60) /* 99999 ,(61)*/ +master-bin.000001 # Query # # use `test`; INSERT INTO /* 99999 blabla */ t1 VALUES(62) /* 99999 ,(63)*/ +master-bin.000001 # Query # # use `test`; DROP TABLE t1 +master-bin.000001 # Query # # use `test`; CREATE TABLE t1(c1 INT) +master-bin.000001 # Query # # use `test`; INSERT INTO /* 99999 blabla */ t1 VALUES(62) /* 99999 ,(63)*/ +Comparing tables master:test.t1 and slave:test.t1 + +# Case 3: +# ----------------------------------------------------------------- +# Verify it can restore the '!', if the it is an uncomplete conditional +# comments +SELECT c1 FROM /*!99999 t1 WHEREN; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/*!99999 t1 WHEREN' at line 1 +DROP TABLE t1; diff --git a/mysql-test/suite/rpl/t/rpl_conditional_comments.test b/mysql-test/suite/rpl/t/rpl_conditional_comments.test new file mode 100644 index 00000000000..14251d5eb37 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_conditional_comments.test @@ -0,0 +1,74 @@ +############################################################################### +# After the patch for BUG#49124: +# - Use ' ' instead of '!' in the conditional comments which are not applied on +# master. So they become common comments and will not be applied on slave. +# +# - Example: +# 'INSERT INTO t1 VALUES (1) /*!10000, (2)*/ /*!99999 ,(3)*/ +# will be binlogged as +# 'INSERT INTO t1 VALUES (1) /*!10000, (2)*/ /* 99999 ,(3)*/'. +############################################################################### +source include/master-slave.inc; +source include/have_binlog_format_statement.inc; + +CREATE TABLE t1(c1 INT); +source include/show_binlog_events.inc; +let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); + +--echo +--echo # Case 1: +--echo # ------------------------------------------------------------------ +--echo # In a statement, some CCs are applied while others are not. The CCs +--echo # which are not applied on master will be binlogged as common comments. + +/*!99999 --- */INSERT /*!INTO*/ /*!10000 t1 */ VALUES(10) /*!99999 ,(11)*/; + +source include/show_binlog_events.inc; +let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); +sync_slave_with_master; +let $diff_table_1=master:test.t1; +let $diff_table_2=slave:test.t1; +source include/diff_tables.inc; + +--echo +--echo # Case 2: +--echo # ----------------------------------------------------------------- +--echo # Verify whether it can be binlogged correctly when executing prepared +--echo # statement. +PREPARE stmt FROM 'INSERT INTO /*!99999 blabla*/ t1 VALUES(60) /*!99999 ,(61)*/'; +EXECUTE stmt; +DROP TABLE t1; +CREATE TABLE t1(c1 INT); +EXECUTE stmt; + +sync_slave_with_master; +let $diff_table_1=master:test.t1; +let $diff_table_2=slave:test.t1; +source include/diff_tables.inc; + +--echo +SET @value=62; +PREPARE stmt FROM 'INSERT INTO /*!99999 blabla */ t1 VALUES(?) /*!99999 ,(63)*/'; +EXECUTE stmt USING @value; +DROP TABLE t1; +CREATE TABLE t1(c1 INT); +EXECUTE stmt USING @value; + +source include/show_binlog_events.inc; +let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); + +sync_slave_with_master; +let $diff_table_1=master:test.t1; +let $diff_table_2=slave:test.t1; +source include/diff_tables.inc; + +--echo +--echo # Case 3: +--echo # ----------------------------------------------------------------- +--echo # Verify it can restore the '!', if the it is an uncomplete conditional +--echo # comments +--error 1064 +SELECT c1 FROM /*!99999 t1 WHEREN; + +DROP TABLE t1; +source include/master-slave-end.inc; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 88f3763ef50..9f2c0b04f2c 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1024,7 +1024,7 @@ bool mysql_opt_change_db(THD *thd, bool force_switch, bool *cur_db_changed); -void mysql_parse(THD *thd, const char *inBuf, uint length, +void mysql_parse(THD *thd, char *rawbuf, uint length, const char ** semicolon); bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 6bfd6f3906c..2bff036b1f1 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -111,7 +111,7 @@ st_parsing_options::reset() } -bool Lex_input_stream::init(THD *thd, const char *buff, unsigned int length) +bool Lex_input_stream::init(THD *thd, char *buff, unsigned int length) { DBUG_EXECUTE_IF("bug42064_simulate_oom", DBUG_SET("+d,simulate_out_of_memory");); @@ -1292,11 +1292,10 @@ int MYSQLlex(void *arg, void *yythd) ulong version; version=strtol(version_str, NULL, 10); - /* Accept 'M' 'm' 'm' 'd' 'd' */ - lip->yySkipn(5); - if (version <= MYSQL_VERSION_ID) { + /* Accept 'M' 'm' 'm' 'd' 'd' */ + lip->yySkipn(5); /* Expand the content of the special comment as real code */ lip->set_echo(TRUE); state=MY_LEX_START; @@ -1304,7 +1303,19 @@ int MYSQLlex(void *arg, void *yythd) } else { + const char* version_mark= lip->get_ptr() - 1; + DBUG_ASSERT(*version_mark == '!'); + /* + Patch and skip the conditional comment to avoid it + being propagated infinitely (eg. to a slave). + */ + char *pcom= lip->yyUnput(' '); comment_closed= ! consume_comment(lip, 1); + if (! comment_closed) + { + DBUG_ASSERT(pcom == version_mark); + *pcom= '!'; + } /* version allowed to have one level of comment inside. */ } } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index cefb0cb49fb..7403bb5a1a4 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1180,7 +1180,7 @@ public: @retval FALSE OK @retval TRUE Error */ - bool init(THD *thd, const char *buff, unsigned int length); + bool init(THD *thd, char *buff, unsigned int length); /** Set the echo mode. @@ -1294,6 +1294,20 @@ public: m_ptr += n; } + /** + Puts a character back into the stream, canceling + the effect of the last yyGet() or yySkip(). + Note that the echo mode should not change between calls + to unput, get, or skip from the stream. + */ + char *yyUnput(char ch) + { + *--m_ptr= ch; + if (m_echo) + m_cpp_ptr--; + return m_ptr; + } + /** End of file indicator for the query text to parse. @return true if there are no more characters to parse @@ -1440,7 +1454,7 @@ public: private: /** Pointer to the current position in the raw input stream. */ - const char *m_ptr; + char *m_ptr; /** Starting position of the last token parsed, in the raw buffer. */ const char *m_tok_start; @@ -1972,7 +1986,7 @@ public: @retval FALSE OK @retval TRUE Error */ - bool init(THD *thd, const char *buff, unsigned int length) + bool init(THD *thd, char *buff, unsigned int length) { return m_lip.init(thd, buff, length); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0a509f62849..9ec03ea1d5f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5946,13 +5946,13 @@ void mysql_init_multi_delete(LEX *lex) Parse a query. @param thd Current thread - @param inBuf Begining of the query text + @param rawbuf Begining of the query text @param length Length of the query text @param[out] found_semicolon For multi queries, position of the character of the next query in the query text. */ -void mysql_parse(THD *thd, const char *inBuf, uint length, +void mysql_parse(THD *thd, char *rawbuf, uint length, const char ** found_semicolon) { DBUG_ENTER("mysql_parse"); @@ -5978,7 +5978,7 @@ void mysql_parse(THD *thd, const char *inBuf, uint length, lex_start(thd); mysql_reset_thd_for_next_command(thd); - if (query_cache_send_result_to_client(thd, (char*) inBuf, length) <= 0) + if (query_cache_send_result_to_client(thd, rawbuf, length) <= 0) { LEX *lex= thd->lex; @@ -5987,7 +5987,7 @@ void mysql_parse(THD *thd, const char *inBuf, uint length, Parser_state parser_state; bool err; - if (!(err= parser_state.init(thd, inBuf, length))) + if (!(err= parser_state.init(thd, rawbuf, length))) { err= parse_sql(thd, & parser_state, NULL); *found_semicolon= parser_state.m_lip.found_semicolon; @@ -6073,14 +6073,14 @@ void mysql_parse(THD *thd, const char *inBuf, uint length, 1 can be ignored */ -bool mysql_test_parse_for_slave(THD *thd, char *inBuf, uint length) +bool mysql_test_parse_for_slave(THD *thd, char *rawbuf, uint length) { LEX *lex= thd->lex; bool error= 0; DBUG_ENTER("mysql_test_parse_for_slave"); Parser_state parser_state; - if (!(error= parser_state.init(thd, inBuf, length))) + if (!(error= parser_state.init(thd, rawbuf, length))) { lex_start(thd); mysql_reset_thd_for_next_command(thd); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 122ae661046..76caa2b0c8d 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -3876,7 +3876,7 @@ void get_partition_set(const TABLE *table, uchar *buf, const uint index, */ bool mysql_unpack_partition(THD *thd, - const char *part_buf, uint part_info_len, + char *part_buf, uint part_info_len, const char *part_state, uint part_state_len, TABLE* table, bool is_create_table_ind, handlerton *default_db_type, diff --git a/sql/sql_partition.h b/sql/sql_partition.h index b9efbf25a00..02a5ead1117 100644 --- a/sql/sql_partition.h +++ b/sql/sql_partition.h @@ -78,7 +78,7 @@ void get_full_part_id_from_key(const TABLE *table, uchar *buf, KEY *key_info, const key_range *key_spec, part_id_range *part_spec); -bool mysql_unpack_partition(THD *thd, const char *part_buf, +bool mysql_unpack_partition(THD *thd, char *part_buf, uint part_info_len, const char *part_state, uint part_state_len, TABLE *table, bool is_create_table_ind, diff --git a/sql/table.h b/sql/table.h index 3ef3c5e0cb2..8ea7175eec4 100644 --- a/sql/table.h +++ b/sql/table.h @@ -442,7 +442,7 @@ typedef struct st_table_share #ifdef WITH_PARTITION_STORAGE_ENGINE /** @todo: Move into *ha_data for partitioning */ bool auto_partitioned; - const char *partition_info; + char *partition_info; uint partition_info_len; uint partition_info_buffer_size; const char *part_state; From 6f6a3e529310fa3f719ff0381ee94e83e7e93683 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 29 Jul 2010 10:12:44 +0400 Subject: [PATCH 079/118] Postfix for BUG#45012. Problem: The original patch didn't compile on debug_werror due to wrong format in printf("%d") for size_t variables. Fix: Adding cast to (int). --- unittest/strings/strings-t.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unittest/strings/strings-t.c b/unittest/strings/strings-t.c index 2d246cfa17f..278f42e56a5 100644 --- a/unittest/strings/strings-t.c +++ b/unittest/strings/strings-t.c @@ -30,7 +30,7 @@ test_like_range_for_charset(CHARSET_INFO *cs, const char *src, size_t src_len) cs->coll->like_range(cs, src, src_len, '\\', '_', '%', sizeof(min_str), min_str, max_str, &min_len, &max_len); - diag("min_len=%d\tmax_len=%d\t%s", min_len, max_len, cs->name); + diag("min_len=%d\tmax_len=%d\t%s", (int) min_len, (int) max_len, cs->name); min_well_formed_len= cs->cset->well_formed_len(cs, min_str, min_str + min_len, 10000, &error); @@ -39,11 +39,11 @@ test_like_range_for_charset(CHARSET_INFO *cs, const char *src, size_t src_len) 10000, &error); if (min_len != min_well_formed_len) diag("Bad min_str: min_well_formed_len=%d min_str[%d]=0x%02X", - min_well_formed_len, min_well_formed_len, + (int) min_well_formed_len, (int) min_well_formed_len, (uchar) min_str[min_well_formed_len]); if (max_len != max_well_formed_len) diag("Bad max_str: max_well_formed_len=%d max_str[%d]=0x%02X", - max_well_formed_len, max_well_formed_len, + (int) max_well_formed_len, (int) max_well_formed_len, (uchar) max_str[max_well_formed_len]); return min_len == min_well_formed_len && From 5e13086bf88eabfbf91dce63332a450ef52f101f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Jul 2010 11:59:34 +0800 Subject: [PATCH 080/118] Bug #34283 mysqlbinlog leaves tmpfile after termination if binlog contains load data infile With statement- or mixed-mode logging, "LOAD DATA INFILE" queries are written to the binlog using special types of log events. When mysqlbinlog reads such events, it re-creates the file in a temporary directory with a generated filename and outputs a "LOAD DATA INFILE" query where the filename is replaced by the generated file. The temporary file is not deleted by mysqlbinlog after termination. To fix the problem, in mixed mode we go to row-based. In SBR, we document it to remind user the tmpfile is left in a temporary directory. mysql-test/suite/binlog/r/binlog_mixed_load_data.result: Test result for BUG#34283. mysql-test/suite/binlog/t/binlog_mixed_load_data.test: Added the test file to verify that 'load data infile...' statement will go to row-based in mixed mode. sql/sql_load.cc: Added code to go to row-based in mixed mode for 'load data infile ...' statement --- .../suite/binlog/r/binlog_mixed_load_data.result | 10 ++++++++++ .../suite/binlog/t/binlog_mixed_load_data.test | 15 +++++++++++++++ sql/sql_load.cc | 8 ++++++++ 3 files changed, 33 insertions(+) create mode 100644 mysql-test/suite/binlog/r/binlog_mixed_load_data.result create mode 100644 mysql-test/suite/binlog/t/binlog_mixed_load_data.test diff --git a/mysql-test/suite/binlog/r/binlog_mixed_load_data.result b/mysql-test/suite/binlog/r/binlog_mixed_load_data.result new file mode 100644 index 00000000000..840257f11ff --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_mixed_load_data.result @@ -0,0 +1,10 @@ +RESET MASTER; +CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=MYISAM; +LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1; +show binlog events from ; +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 # # COMMIT +DROP TABLE t1; diff --git a/mysql-test/suite/binlog/t/binlog_mixed_load_data.test b/mysql-test/suite/binlog/t/binlog_mixed_load_data.test new file mode 100644 index 00000000000..7e7cb973c1b --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_mixed_load_data.test @@ -0,0 +1,15 @@ +# +# Bug #34283 mysqlbinlog leaves tmpfile after termination +# if binlog contains load data infile, so in mixed mode we +# go to row-based for avoiding the problem. +# + +--source include/have_binlog_format_mixed.inc +--source include/have_log_bin.inc + +RESET MASTER; +CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=MYISAM; +let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); +LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1; +--source include/show_binlog_events.inc +DROP TABLE t1; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index a4cf46b35e8..f9386206dce 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -141,6 +141,14 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, bool transactional_table; DBUG_ENTER("mysql_load"); + /* + Bug #34283 + mysqlbinlog leaves tmpfile after termination if binlog contains + load data infile, so in mixed mode we go to row-based for + avoiding the problem. + */ + thd->set_current_stmt_binlog_row_based_if_mixed(); + #ifdef EMBEDDED_LIBRARY read_file_from_client = 0; //server is always in the same process #endif From a9538cacda199fcfd733a191c17cc68569871cd7 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 30 Jul 2010 09:17:10 -0300 Subject: [PATCH 081/118] Bug#54041: MySQL 5.0.92 fails when tests from Connector/C suite run Fix a regression (due to a typo) which caused spurious incorrect argument errors for long data stream parameters if all forms of logging were disabled (binary, general and slow logs). mysql-test/t/mysql_client_test.test: Save the status of the slow_log. sql/sql_prepare.cc: Add a missing logical NOT operator. tests/mysql_client_test.c: Disable all query logs when running C tests. Fixes a omission when, slow log should have been disabled too. Run test case for Bug#54041 with query logs enabled and disabled. --- mysql-test/r/mysql_client_test.result | 2 ++ mysql-test/t/mysql_client_test.test | 2 ++ sql/sql_prepare.cc | 4 +-- tests/mysql_client_test.c | 49 +++++++++++++++++++++------ 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/mysql_client_test.result b/mysql-test/r/mysql_client_test.result index 08d982c85e3..edda7980e97 100644 --- a/mysql-test/r/mysql_client_test.result +++ b/mysql-test/r/mysql_client_test.result @@ -1,3 +1,5 @@ SET @old_general_log= @@global.general_log; +SET @old_slow_query_log= @@global.slow_query_log; ok SET @@global.general_log= @old_general_log; +SET @@global.slow_query_log= @old_slow_query_log; diff --git a/mysql-test/t/mysql_client_test.test b/mysql-test/t/mysql_client_test.test index 15c0cd4ac84..41670117c7c 100644 --- a/mysql-test/t/mysql_client_test.test +++ b/mysql-test/t/mysql_client_test.test @@ -2,6 +2,7 @@ -- source include/not_embedded.inc SET @old_general_log= @@global.general_log; +SET @old_slow_query_log= @@global.slow_query_log; # We run with different binaries for normal and --embedded-server # @@ -17,3 +18,4 @@ SET @old_general_log= @@global.general_log; echo ok; SET @@global.general_log= @old_general_log; +SET @@global.slow_query_log= @old_slow_query_log; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index bd152866deb..d6eb90a57be 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -793,7 +793,7 @@ static bool insert_params_with_log(Prepared_statement *stmt, uchar *null_array, type (the types are supplied at execute). Check that the supplied type of placeholder can accept a data stream. */ - else if (!is_param_long_data_type(param)) + else if (! is_param_long_data_type(param)) DBUG_RETURN(1); res= param->query_val_str(&str); if (param->convert_str_value(thd)) @@ -839,7 +839,7 @@ static bool insert_params(Prepared_statement *stmt, uchar *null_array, type (the types are supplied at execute). Check that the supplied type of placeholder can accept a data stream. */ - else if (is_param_long_data_type(param)) + else if (! is_param_long_data_type(param)) DBUG_RETURN(1); if (param->convert_str_value(stmt->thd)) DBUG_RETURN(1); /* out of memory */ diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 00389d431fa..87c35666ac6 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -13246,37 +13246,52 @@ static void test_bug15518() } -static void disable_general_log() +static void disable_query_logs() { int rc; rc= mysql_query(mysql, "set @@global.general_log=off"); myquery(rc); + rc= mysql_query(mysql, "set @@global.slow_query_log=off"); + myquery(rc); } -static void enable_general_log(int truncate) +static void enable_query_logs(int truncate) { int rc; rc= mysql_query(mysql, "set @save_global_general_log=@@global.general_log"); myquery(rc); + rc= mysql_query(mysql, "set @save_global_slow_query_log=@@global.slow_query_log"); + myquery(rc); + rc= mysql_query(mysql, "set @@global.general_log=on"); myquery(rc); + rc= mysql_query(mysql, "set @@global.slow_query_log=on"); + myquery(rc); + + if (truncate) { rc= mysql_query(mysql, "truncate mysql.general_log"); myquery(rc); + + rc= mysql_query(mysql, "truncate mysql.slow_log"); + myquery(rc); } } -static void restore_general_log() +static void restore_query_logs() { int rc; rc= mysql_query(mysql, "set @@global.general_log=@save_global_general_log"); myquery(rc); + + rc= mysql_query(mysql, "set @@global.slow_query_log=@save_global_slow_query_log"); + myquery(rc); } @@ -15447,7 +15462,7 @@ static void test_bug17667() return; } - enable_general_log(1); + enable_query_logs(1); for (statement_cursor= statements; statement_cursor->buffer != NULL; statement_cursor++) @@ -15527,7 +15542,7 @@ static void test_bug17667() statement_cursor->buffer); } - restore_general_log(); + restore_query_logs(); if (!opt_silent) printf("success. All queries found intact in the log.\n"); @@ -17390,7 +17405,7 @@ static void test_bug28386() } mysql_free_result(result); - enable_general_log(1); + enable_query_logs(1); stmt= mysql_simple_prepare(mysql, "SELECT ?"); check_stmt(stmt); @@ -17429,7 +17444,7 @@ static void test_bug28386() mysql_free_result(result); - restore_general_log(); + restore_query_logs(); DBUG_VOID_RETURN; } @@ -18215,7 +18230,7 @@ static void test_bug42373() Bug#54041: MySQL 5.0.92 fails when tests from Connector/C suite run */ -static void test_bug54041() +static void test_bug54041_impl() { int rc; MYSQL_STMT *stmt; @@ -18230,7 +18245,7 @@ static void test_bug54041() rc= mysql_query(mysql, "CREATE TABLE t1 (a INT)"); myquery(rc); - stmt= mysql_simple_prepare(mysql, "INSERT INTO t1 (a) VALUES (?)"); + stmt= mysql_simple_prepare(mysql, "SELECT a FROM t1 WHERE a > ?"); check_stmt(stmt); verify_param_count(stmt, 1); @@ -18268,6 +18283,20 @@ static void test_bug54041() } +/** + Bug#54041: MySQL 5.0.92 fails when tests from Connector/C suite run +*/ + +static void test_bug54041() +{ + enable_query_logs(0); + test_bug54041_impl(); + disable_query_logs(); + test_bug54041_impl(); + restore_query_logs(); +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -18348,7 +18377,7 @@ and you are welcome to modify and redistribute it under the GPL license\n"); static struct my_tests_st my_tests[]= { - { "disable_general_log", disable_general_log }, + { "disable_query_logs", disable_query_logs }, { "test_view_sp_list_fields", test_view_sp_list_fields }, { "client_query", client_query }, { "test_prepare_insert_update", test_prepare_insert_update}, From a6f726c5855011f6ba660ced6bce4721507d0fa3 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 30 Jul 2010 09:34:40 -0300 Subject: [PATCH 082/118] Bug#54041: MySQL 5.0.92 fails when tests from Connector/C suite run Fix a regression (due to a typo) which caused spurious incorrect argument errors for long data stream parameters if all forms of logging were disabled (binary, general and slow logs). sql/sql_prepare.cc: Add a missing logical NOT operator. --- sql/sql_prepare.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index c2fecd63777..9815acfe815 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -755,7 +755,7 @@ static bool insert_params_withlog(Prepared_statement *stmt, uchar *null_array, type (the types are supplied at execute). Check that the supplied type of placeholder can accept a data stream. */ - else if (!is_param_long_data_type(param)) + else if (! is_param_long_data_type(param)) DBUG_RETURN(1); res= param->query_val_str(&str); if (param->convert_str_value(thd)) @@ -801,7 +801,7 @@ static bool insert_params(Prepared_statement *stmt, uchar *null_array, type (the types are supplied at execute). Check that the supplied type of placeholder can accept a data stream. */ - else if (is_param_long_data_type(param)) + else if (! is_param_long_data_type(param)) DBUG_RETURN(1); if (param->convert_str_value(stmt->thd)) DBUG_RETURN(1); /* out of memory */ From de5029a4586176b9fed06ab96fb3a6e0bbcd8c54 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 30 Jul 2010 16:35:06 +0300 Subject: [PATCH 083/118] Bug #55188: GROUP BY, GROUP_CONCAT and TEXT - inconsistent results In order to be able to check if the set of the grouping fields in a GROUP BY has changed (and thus to start a new group) the optimizer caches the current values of these fields in a set of Cached_item derived objects. The Cached_item_str, used for caching varchar and TEXT columns, is limited in length by the max_sort_length variable. A String buffer to store the value with an alloced length of either the max length of the string or the value of max_sort_length (whichever is smaller) in Cached_item_str's constructor. Then, at compare time the value of the string to compare to was truncated to the alloced length of the string buffer inside Cached_item_str. This is all fine and valid, but only if you're not assigning values near or equal to the alloced length of this buffer. Because when assigning values like this the alloced length is rounded up and as a result the next set of data will not match the group buffer, thus leading to wrong results because of the changed alloced_length. Fixed by preserving the original maximum length in the Cached_item_str's constructor and using this instead of the alloced_length to limit the string to compare to. Test case added. --- mysql-test/r/group_by.result | 35 +++++++++++++++++++++++++++++++++++ mysql-test/t/group_by.test | 14 ++++++++++++++ sql/item.h | 1 + sql/item_buff.cc | 6 ++++-- 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 645dd460735..f74584f6bcf 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -1810,4 +1810,39 @@ MAX(t2.a) 2 DROP TABLE t1, t2; # +# Bug#55188: GROUP BY, GROUP_CONCAT and TEXT - inconsistent results +# +CREATE TABLE t1 (a text, b varchar(10)); +INSERT INTO t1 VALUES (repeat('1', 1300),'one'), (repeat('1', 1300),'two'); +EXPLAIN +SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a; +id 1 +select_type SIMPLE +table t1 +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 2 +Extra Using filesort +SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a; +SUBSTRING(a,1,10) LENGTH(a) GROUP_CONCAT(b) +1111111111 1300 one,two +EXPLAIN +SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; +id 1 +select_type SIMPLE +table t1 +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 2 +Extra Using temporary; Using filesort +SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; +SUBSTRING(a,1,10) LENGTH(a) +1111111111 1300 +DROP TABLE t1; # End of 5.1 tests diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index c5b27ee1a62..75ec1d82b02 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1221,5 +1221,19 @@ DROP TABLE t1, t2; --echo # +--echo # Bug#55188: GROUP BY, GROUP_CONCAT and TEXT - inconsistent results +--echo # + +CREATE TABLE t1 (a text, b varchar(10)); +INSERT INTO t1 VALUES (repeat('1', 1300),'one'), (repeat('1', 1300),'two'); + +query_vertical EXPLAIN +SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a; +SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a; +query_vertical EXPLAIN +SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; +SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; +DROP TABLE t1; + --echo # End of 5.1 tests diff --git a/sql/item.h b/sql/item.h index 174995b43e6..57abb43010e 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2740,6 +2740,7 @@ public: class Cached_item_str :public Cached_item { Item *item; + uint32 value_max_length; String value,tmp_value; public: Cached_item_str(THD *thd, Item *arg); diff --git a/sql/item_buff.cc b/sql/item_buff.cc index 2f45d0a17c2..0ac4edb3656 100644 --- a/sql/item_buff.cc +++ b/sql/item_buff.cc @@ -58,7 +58,9 @@ Cached_item::~Cached_item() {} */ Cached_item_str::Cached_item_str(THD *thd, Item *arg) - :item(arg), value(min(arg->max_length, thd->variables.max_sort_length)) + :item(arg), + value_max_length(min(arg->max_length, thd->variables.max_sort_length)), + value(value_max_length) {} bool Cached_item_str::cmp(void) @@ -67,7 +69,7 @@ bool Cached_item_str::cmp(void) bool tmp; if ((res=item->val_str(&tmp_value))) - res->length(min(res->length(), value.alloced_length())); + res->length(min(res->length(), value_max_length)); if (null_value != item->null_value) { if ((null_value= item->null_value)) From 55e60e14fa4eb240194412ee162c0394751da9e1 Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Fri, 30 Jul 2010 14:44:39 +0100 Subject: [PATCH 084/118] Revert patch for BUG#34283. Causing lots of test failures in PB2, mostly because existing test result files were not updated. --- .../suite/binlog/r/binlog_mixed_load_data.result | 10 ---------- .../suite/binlog/t/binlog_mixed_load_data.test | 15 --------------- sql/sql_load.cc | 8 -------- 3 files changed, 33 deletions(-) delete mode 100644 mysql-test/suite/binlog/r/binlog_mixed_load_data.result delete mode 100644 mysql-test/suite/binlog/t/binlog_mixed_load_data.test diff --git a/mysql-test/suite/binlog/r/binlog_mixed_load_data.result b/mysql-test/suite/binlog/r/binlog_mixed_load_data.result deleted file mode 100644 index 840257f11ff..00000000000 --- a/mysql-test/suite/binlog/r/binlog_mixed_load_data.result +++ /dev/null @@ -1,10 +0,0 @@ -RESET MASTER; -CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=MYISAM; -LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1; -show binlog events from ; -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 # # COMMIT -DROP TABLE t1; diff --git a/mysql-test/suite/binlog/t/binlog_mixed_load_data.test b/mysql-test/suite/binlog/t/binlog_mixed_load_data.test deleted file mode 100644 index 7e7cb973c1b..00000000000 --- a/mysql-test/suite/binlog/t/binlog_mixed_load_data.test +++ /dev/null @@ -1,15 +0,0 @@ -# -# Bug #34283 mysqlbinlog leaves tmpfile after termination -# if binlog contains load data infile, so in mixed mode we -# go to row-based for avoiding the problem. -# - ---source include/have_binlog_format_mixed.inc ---source include/have_log_bin.inc - -RESET MASTER; -CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=MYISAM; -let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); -LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1; ---source include/show_binlog_events.inc -DROP TABLE t1; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index f9386206dce..a4cf46b35e8 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -141,14 +141,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, bool transactional_table; DBUG_ENTER("mysql_load"); - /* - Bug #34283 - mysqlbinlog leaves tmpfile after termination if binlog contains - load data infile, so in mixed mode we go to row-based for - avoiding the problem. - */ - thd->set_current_stmt_binlog_row_based_if_mixed(); - #ifdef EMBEDDED_LIBRARY read_file_from_client = 0; //server is always in the same process #endif From ae02cad707494b5c4b3a9bb033fb8515efa50134 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 30 Jul 2010 17:09:24 +0300 Subject: [PATCH 085/118] Disable the tests failing under valgrind because of bug #55503 --- mysql-test/suite/innodb_plugin/t/innodb-autoinc-44030.test | 2 ++ mysql-test/suite/innodb_plugin/t/innodb-autoinc.test | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mysql-test/suite/innodb_plugin/t/innodb-autoinc-44030.test b/mysql-test/suite/innodb_plugin/t/innodb-autoinc-44030.test index 99cdac72e2e..5e4cf9dcb4c 100644 --- a/mysql-test/suite/innodb_plugin/t/innodb-autoinc-44030.test +++ b/mysql-test/suite/innodb_plugin/t/innodb-autoinc-44030.test @@ -1,6 +1,8 @@ -- source include/have_innodb_plugin.inc # embedded server ignores 'delayed', so skip this -- source include/not_embedded.inc +# remove the next line after bug #55503 is fixed +-- source include/not_valgrind.inc let $innodb_file_format_check_orig=`select @@innodb_file_format_check`; diff --git a/mysql-test/suite/innodb_plugin/t/innodb-autoinc.test b/mysql-test/suite/innodb_plugin/t/innodb-autoinc.test index 5a83ffe3617..49394a019d0 100644 --- a/mysql-test/suite/innodb_plugin/t/innodb-autoinc.test +++ b/mysql-test/suite/innodb_plugin/t/innodb-autoinc.test @@ -1,6 +1,8 @@ -- source include/have_innodb_plugin.inc # embedded server ignores 'delayed', so skip this -- source include/not_embedded.inc +# remove the next line after bug #55503 is fixed +-- source include/not_valgrind.inc let $innodb_file_format_check_orig=`select @@innodb_file_format_check`; From 9899e690f06e275e8c7b2e39dba96b46701fd949 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 30 Jul 2010 17:33:10 -0300 Subject: [PATCH 086/118] Bug#45288: pb2 returns a lot of compilation warnings on linux Fix compiler warnings. mysys/stacktrace.c: Tag unused parameters. sql/sql_lex.cc: Variable becomes unused in non-debug builds. Also, no need to assert the obvious. --- mysys/stacktrace.c | 4 +++- sql/sql_lex.cc | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c index 75fda93b56e..7bac8017324 100644 --- a/mysys/stacktrace.c +++ b/mysys/stacktrace.c @@ -86,7 +86,9 @@ void my_print_stacktrace(uchar* stack_bottom __attribute__((unused)), #if BACKTRACE_DEMANGLE -char __attribute__ ((weak)) *my_demangle(const char *mangled_name, int *status) +char __attribute__ ((weak)) * +my_demangle(const char *mangled_name __attribute__((unused)), + int *status __attribute__((unused))) { return NULL; } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 2bff036b1f1..24c51be2512 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1303,8 +1303,6 @@ int MYSQLlex(void *arg, void *yythd) } else { - const char* version_mark= lip->get_ptr() - 1; - DBUG_ASSERT(*version_mark == '!'); /* Patch and skip the conditional comment to avoid it being propagated infinitely (eg. to a slave). @@ -1313,7 +1311,6 @@ int MYSQLlex(void *arg, void *yythd) comment_closed= ! consume_comment(lip, 1); if (! comment_closed) { - DBUG_ASSERT(pcom == version_mark); *pcom= '!'; } /* version allowed to have one level of comment inside. */ From 80aa8824971de3e5524537e30175b2390d0570db Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Sun, 1 Aug 2010 22:12:36 +0400 Subject: [PATCH 087/118] Bug #54461: crash with longblob and union or update with subquery Queries may crash, if 1) the GREATEST or the LEAST function has a mixed list of numeric and LONGBLOB arguments and 2) the result of such a function goes through an intermediate temporary table. An Item that references a LONGBLOB field has max_length of UINT_MAX32 == (2^32 - 1). The current implementation of GREATEST/LEAST returns REAL result for a mixed list of numeric and string arguments (that contradicts with the current documentation, this contradiction was discussed and it was decided to update the documentation). The max_length of such a function call was calculated as a maximum of argument max_length values (i.e. UINT_MAX32). That max_length value of UINT_MAX32 was used as a length for the intermediate temporary table Field_double to hold GREATEST/LEAST function result. The Field_double::val_str() method call on that field allocates a String value. Since an allocation of String reserves an additional byte for a zero-termination, the size of String buffer was set to (UINT_MAX32 + 1), that caused an integer overflow: actually, an empty buffer of size 0 was allocated. An initialization of the "first" byte of that zero-size buffer with '\0' caused a crash. The Item_func_min_max::fix_length_and_dec() has been modified to calculate max_length for the REAL result like we do it for arithmetical operators. ****** Bug #54461: crash with longblob and union or update with subquery Queries may crash, if 1) the GREATEST or the LEAST function has a mixed list of numeric and LONGBLOB arguments and 2) the result of such a function goes through an intermediate temporary table. An Item that references a LONGBLOB field has max_length of UINT_MAX32 == (2^32 - 1). The current implementation of GREATEST/LEAST returns REAL result for a mixed list of numeric and string arguments (that contradicts with the current documentation, this contradiction was discussed and it was decided to update the documentation). The max_length of such a function call was calculated as a maximum of argument max_length values (i.e. UINT_MAX32). That max_length value of UINT_MAX32 was used as a length for the intermediate temporary table Field_double to hold GREATEST/LEAST function result. The Field_double::val_str() method call on that field allocates a String value. Since an allocation of String reserves an additional byte for a zero-termination, the size of String buffer was set to (UINT_MAX32 + 1), that caused an integer overflow: actually, an empty buffer of size 0 was allocated. An initialization of the "first" byte of that zero-size buffer with '\0' caused a crash. The Item_func_min_max::fix_length_and_dec() has been modified to calculate max_length for the REAL result like we do it for arithmetical operators. mysql-test/r/func_misc.result: Test case for bug #54461. ****** Test case for bug #54461. mysql-test/t/func_misc.test: Test case for bug #54461. ****** Test case for bug #54461. sql/item_func.cc: Bug #54461: crash with longblob and union or update with subquery The Item_func_min_max::fix_length_and_dec() has been modified to calculate max_length for the REAL result like we do it for arithmetical operators. ****** Bug #54461: crash with longblob and union or update with subquery The Item_func_min_max::fix_length_and_dec() has been modified to calculate max_length for the REAL result like we do it for arithmetical operators. --- mysql-test/r/func_misc.result | 15 +++++++++++++++ mysql-test/t/func_misc.test | 12 ++++++++++++ sql/item_func.cc | 2 ++ 3 files changed, 29 insertions(+) diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 81dddd0f648..eee56ae7461 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -336,4 +336,19 @@ End of 5.0 tests select connection_id() > 0; connection_id() > 0 1 +# +# Bug #54461: crash with longblob and union or update with subquery +# +CREATE TABLE t1 (a INT, b LONGBLOB); +INSERT INTO t1 VALUES (1, '2'), (2, '3'), (3, '2'); +SELECT DISTINCT LEAST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; +LEAST(a, (SELECT b FROM t1 LIMIT 1)) +1 +2 +SELECT DISTINCT GREATEST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; +GREATEST(a, (SELECT b FROM t1 LIMIT 1)) +2 +3 +1 +DROP TABLE t1; End of tests diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 6590b43f2dc..c6b5ffd5a3f 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -467,4 +467,16 @@ select NAME_CONST('_id',1234) as id; select connection_id() > 0; +--echo # +--echo # Bug #54461: crash with longblob and union or update with subquery +--echo # + +CREATE TABLE t1 (a INT, b LONGBLOB); +INSERT INTO t1 VALUES (1, '2'), (2, '3'), (3, '2'); + +SELECT DISTINCT LEAST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; +SELECT DISTINCT GREATEST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; + +DROP TABLE t1; + --echo End of tests diff --git a/sql/item_func.cc b/sql/item_func.cc index 1bec4700bff..1b13297c951 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2243,6 +2243,8 @@ void Item_func_min_max::fix_length_and_dec() max_length= my_decimal_precision_to_length_no_truncation(max_int_part + decimals, decimals, unsigned_flag); + else if (cmp_type == REAL_RESULT) + max_length= float_length(decimals); cached_field_type= agg_field_type(args, arg_count); } From f62e89fade7cda645de80e2996de69e7d980cbdd Mon Sep 17 00:00:00 2001 From: Alfranio Correia Date: Mon, 2 Aug 2010 20:48:56 +0100 Subject: [PATCH 088/118] BUG#55625 RBR breaks on failing 'CREATE TABLE' A CREATE...SELECT that fails is written to the binary log if a non-transactional statement is updated. If the logging format is ROW, the CREATE statement and the changes are written to the binary log as distinct events and by consequence the created table is not rolled back in the slave. In this patch, we opted to let the slave goes out of sync by not writting to the binary log the CREATE statement. We do this by simply reseting the binary log's cache. mysql-test/suite/rpl/r/rpl_drop.result: Added a test case. mysql-test/suite/rpl/t/rpl_drop.test: Added a test case. sql/log.cc: Introduced a function to clean up the cache. sql/log.h: Introduced a function to clean up the cache. sql/sql_insert.cc: Cleaned up the binary log cache if a CREATE...SELECT fails. --- mysql-test/suite/rpl/r/rpl_drop.result | 24 ++++++++++++ mysql-test/suite/rpl/t/rpl_drop.test | 53 +++++++++++++++++++++++++- sql/log.cc | 13 +++++++ sql/log.h | 3 +- sql/sql_insert.cc | 11 ++++++ 5 files changed, 102 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_drop.result b/mysql-test/suite/rpl/r/rpl_drop.result index b83594c9bb1..5ebbc4f9ce7 100644 --- a/mysql-test/suite/rpl/r/rpl_drop.result +++ b/mysql-test/suite/rpl/r/rpl_drop.result @@ -8,3 +8,27 @@ drop table if exists t1, t2; create table t1 (a int); drop table t1, t2; ERROR 42S02: Unknown table 't2' +include/stop_slave.inc +SET @old_binlog_format= @@global.binlog_format; +SET GLOBAL binlog_format = ROW; +include/start_slave.inc +SET @old_binlog_format= @@global.binlog_format; +SET binlog_format = ROW; +CREATE TABLE t2(a INT) ENGINE=MYISAM; +CREATE TABLE t3(a INT) ENGINE=INNODB; +CREATE FUNCTION f1() RETURNS INT +BEGIN +insert into t2 values(1); +insert into t3 values(1); +return 1; +END| +CREATE TABLE t1(UNIQUE(a)) ENGINE=MYISAM SELECT 1 AS a UNION ALL SELECT f1(); +ERROR 23000: Duplicate entry '1' for key 'a' +CREATE TABLE t1(UNIQUE(a)) ENGINE=INNODB SELECT 1 AS a UNION ALL SELECT f1(); +ERROR 23000: Duplicate entry '1' for key 'a' +show binlog events in 'master-bin.000001' from ; +Log_name Pos Event_type Server_id End_log_pos Info +DROP FUNCTION f1; +DROP TABLE t2, t3; +SET @@global.binlog_format= @old_binlog_format; +SET @@global.binlog_format= @old_binlog_format; diff --git a/mysql-test/suite/rpl/t/rpl_drop.test b/mysql-test/suite/rpl/t/rpl_drop.test index b38007a755f..336edad6fc5 100644 --- a/mysql-test/suite/rpl/t/rpl_drop.test +++ b/mysql-test/suite/rpl/t/rpl_drop.test @@ -1,6 +1,7 @@ # Testcase for BUG#4552 (DROP on two tables, one of which does not # exist, must be binlogged with a non-zero error code) source include/master-slave.inc; +source include/have_innodb.inc; --disable_warnings drop table if exists t1, t2; --enable_warnings @@ -10,7 +11,57 @@ drop table t1, t2; save_master_pos; connection slave; sync_with_master; - # End of 4.1 tests +# BUG#55625 RBR breaks on failing 'CREATE TABLE' +# A CREATE...SELECT that fails is written to the binary log if a non-transactional +# statement is updated. If the logging format is ROW, the CREATE statement and the +# changes are written to the binary log as distinct events and by consequence the +# created table is not rolled back in the slave. +# To fix the problem, we do not write a CREATE...SELECT that fails to the binary +# log. Howerver, the changes to non-transactional tables are not replicated and +# thus the slave goes out of sync. This should be fixed after BUG#47899. +# +# In the test case, we verify if the binary log contains no information for a +# CREATE...SELECT that fails. +connection slave; +--source include/stop_slave.inc +SET @old_binlog_format= @@global.binlog_format; +SET GLOBAL binlog_format = ROW; +--source include/start_slave.inc + +connection master; +SET @old_binlog_format= @@global.binlog_format; +SET binlog_format = ROW; + +CREATE TABLE t2(a INT) ENGINE=MYISAM; +CREATE TABLE t3(a INT) ENGINE=INNODB; + +delimiter |; +CREATE FUNCTION f1() RETURNS INT +BEGIN + insert into t2 values(1); + insert into t3 values(1); + return 1; +END| +delimiter ;| + +let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1); +let $binlog_file= query_get_value("SHOW MASTER STATUS", File, 1); + +--error 1062 +CREATE TABLE t1(UNIQUE(a)) ENGINE=MYISAM SELECT 1 AS a UNION ALL SELECT f1(); +--error 1062 +CREATE TABLE t1(UNIQUE(a)) ENGINE=INNODB SELECT 1 AS a UNION ALL SELECT f1(); + +--source include/show_binlog_events.inc + +DROP FUNCTION f1; +DROP TABLE t2, t3; +SET @@global.binlog_format= @old_binlog_format; + +--sync_slave_with_master +SET @@global.binlog_format= @old_binlog_format; + +# End of 5.1 tests diff --git a/sql/log.cc b/sql/log.cc index 614a07e6b63..3f41bf1c929 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1628,6 +1628,19 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all) DBUG_RETURN(error); } +/** + Cleanup the cache. + + @param thd The client thread that wants to clean up the cache. +*/ +void MYSQL_BIN_LOG::reset_gathered_updates(THD *thd) +{ + binlog_trx_data *const trx_data= + (binlog_trx_data*) thd_get_ha_data(thd, binlog_hton); + + trx_data->reset(); +} + void MYSQL_BIN_LOG::set_write_error(THD *thd) { DBUG_ENTER("MYSQL_BIN_LOG::set_write_error"); diff --git a/sql/log.h b/sql/log.h index 8d3880d9171..8f1ed7ee90c 100644 --- a/sql/log.h +++ b/sql/log.h @@ -356,10 +356,11 @@ public: /* Use this to start writing a new log file */ void new_file(); + void reset_gathered_updates(THD *thd); bool write(Log_event* event_info); // binary log write bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event, bool incident); - bool write_incident(THD *thd, bool lock); + bool write_incident(THD *thd, bool lock); int write_cache(IO_CACHE *cache, bool lock_log, bool flush_and_sync); void set_write_error(THD *thd); bool check_write_error(THD *thd); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 35c24e7571e..83b1834da0b 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3873,6 +3873,17 @@ void select_create::abort() if (table) { + if (thd->lex->sql_command == SQLCOM_CREATE_TABLE && + thd->current_stmt_binlog_row_based && + !(thd->lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) && + mysql_bin_log.is_open()) + { + /* + This should be removed after BUG#47899. + */ + mysql_bin_log.reset_gathered_updates(thd); + } + table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); if (!create_info->table_existed) From 9bc9855c16f815e71223398ef17cd6052becc44e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 25 Aug 2010 22:22:33 +0200 Subject: [PATCH 089/118] mtr changes: * expanding unknown env variable does not abort mtr * have_archive, blackhole, innodb - preload the corresponding engine * all options from .opt files get equal treatment, all are searched for special options, not only -{master,slave}.opt as before (which ignored suite.opt and --mysqld=...) * --plugin-load gets special treatment too - all instances are merged into one * federated test fixed to preload federated --- mysql-test/README.suites | 15 +- mysql-test/include/have_archive.inc | 9 +- mysql-test/include/have_archive.opt | 2 + mysql-test/include/have_blackhole.opt | 2 + mysql-test/include/have_innodb.opt | 1 + mysql-test/include/have_pbxt.inc | 9 +- mysql-test/lib/mtr_cases.pm | 145 ++++++++++-------- mysql-test/mysql-test-run.pl | 22 +-- .../federated/federated_innodb-slave.opt | 1 - .../federated_transactions-slave.opt | 1 - mysql-test/suite/federated/my.cnf | 2 - mysql-test/suite/federated/suite.opt | 2 + mysql-test/t/mysqltest_ps.test | 2 +- 13 files changed, 113 insertions(+), 100 deletions(-) create mode 100644 mysql-test/include/have_archive.opt create mode 100644 mysql-test/include/have_blackhole.opt delete mode 100644 mysql-test/suite/federated/federated_innodb-slave.opt delete mode 100644 mysql-test/suite/federated/federated_transactions-slave.opt create mode 100644 mysql-test/suite/federated/suite.opt diff --git a/mysql-test/README.suites b/mysql-test/README.suites index 99155f37485..076fc216a0e 100644 --- a/mysql-test/README.suites +++ b/mysql-test/README.suites @@ -20,11 +20,18 @@ subdirectories under the suitedir or directly in the suitedir (that is suitedir/t/*.test or suitedir/*.test, same for *.result)) ========================== -A suite can contain a suite.opt file - at the same location where .test -files are. As usual, the .opt file can use $-substitutions for the -environment variables. +A suite can contain a suite.opt file - at the same location where .test files +are or in the suite directory. As usual, the .opt file can use $-substitutions +for the environment variables. Usually, using my.cnf template (see below) is preferrable. + +But command line options (.opt files and combinations file) get special +treatment - they can have special options that affect mtr behavior. cnf +files cannot. Special options are + --timezone, --plugin-load, --result-file, --config-file-template, + --default-time-zone, --force-restart + ========================== A suite can have suite.pm file in the suitedir. It must declare a package that inherits from My::Suite. @@ -108,8 +115,8 @@ Most probably a suite my.cnf will need to start from !include include/default_my.cnf and then modify the configuration as necessary. -========================== +========================== A suite can have combinations file in the suitedir. It uses my.cnf syntax but it cannot use @-substitutions. Instead, it can use $-substitutions for the environment variables. Because the combination options will not be diff --git a/mysql-test/include/have_archive.inc b/mysql-test/include/have_archive.inc index 82399ca4c6c..0fd85fa576f 100644 --- a/mysql-test/include/have_archive.inc +++ b/mysql-test/include/have_archive.inc @@ -1,4 +1,5 @@ ---disable_query_log ---require r/true.require -select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'archive'; ---enable_query_log +if (!`SELECT count(*) FROM information_schema.engines WHERE + (support = 'YES' OR support = 'DEFAULT') AND + engine = 'archive'`){ + skip Need archive engine; +} diff --git a/mysql-test/include/have_archive.opt b/mysql-test/include/have_archive.opt new file mode 100644 index 00000000000..cf9309d9fb0 --- /dev/null +++ b/mysql-test/include/have_archive.opt @@ -0,0 +1,2 @@ +--loose-archive +--plugin-load=$HA_ARCHIVE_SO diff --git a/mysql-test/include/have_blackhole.opt b/mysql-test/include/have_blackhole.opt new file mode 100644 index 00000000000..b600b468390 --- /dev/null +++ b/mysql-test/include/have_blackhole.opt @@ -0,0 +1,2 @@ +--loose-blackhole +--plugin-load=$HA_BLACKHOLE_SO diff --git a/mysql-test/include/have_innodb.opt b/mysql-test/include/have_innodb.opt index 48457b17309..4fb96229a7b 100644 --- a/mysql-test/include/have_innodb.opt +++ b/mysql-test/include/have_innodb.opt @@ -1 +1,2 @@ --loose-innodb +--plugin-load=$HA_XTRADB_SO diff --git a/mysql-test/include/have_pbxt.inc b/mysql-test/include/have_pbxt.inc index a8afc2c8324..b11aee2617f 100644 --- a/mysql-test/include/have_pbxt.inc +++ b/mysql-test/include/have_pbxt.inc @@ -1,4 +1,5 @@ -disable_query_log; ---require r/true.require -select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'pbxt'; -enable_query_log; +if (!`SELECT count(*) FROM information_schema.engines WHERE + (support = 'YES' OR support = 'DEFAULT') AND + engine = 'pbxt'`){ + skip Need PBXT engine; +} diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index f9c0c762753..f7794d1964d 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -325,12 +325,8 @@ sub collect_one_suite } # Read suite.opt file - my $suite_opt_file= "$testdir/suite.opt"; - my $suite_opts= []; - if ( -f $suite_opt_file ) - { - $suite_opts= opts_from_file($suite_opt_file); - } + my $suite_opts= [ opts_from_file("$testdir/suite.opt") ]; + $suite_opts = [ opts_from_file("$suitedir/suite.opt") ] unless @$suite_opts; if ( @$opt_cases ) { @@ -618,67 +614,78 @@ sub optimize_cases { # Read options from the given opt file and append them as an array # to $tinfo->{$opt_name} # -sub process_opts_file { - my ($tinfo, $opt_file, $opt_name)= @_; +sub process_opts { + my ($tinfo, $opt_name)= @_; - if ( -f $opt_file ) + my @opts= @{$tinfo->{$opt_name}}; + $tinfo->{$opt_name} = []; + + my @plugins; + + foreach my $opt (@opts) { - my $opts= opts_from_file($opt_file); + my $value; - foreach my $opt ( @$opts ) + # The opt file is used both to send special options to the mysqld + # as well as pass special test case specific options to this + # script + + $value= mtr_match_prefix($opt, "--timezone="); + if ( defined $value ) { - my $value; - - # The opt file is used both to send special options to the mysqld - # as well as pass special test case specific options to this - # script - - $value= mtr_match_prefix($opt, "--timezone="); - if ( defined $value ) - { - $tinfo->{'timezone'}= $value; - next; - } - - $value= mtr_match_prefix($opt, "--result-file="); - if ( defined $value ) - { - # Specifies the file mysqltest should compare - # output against - $tinfo->{'result_file'}= "r/$value.result"; - next; - } - - $value= mtr_match_prefix($opt, "--config-file-template="); - if ( defined $value) - { - # Specifies the configuration file to use for this test - $tinfo->{'template_path'}= dirname($tinfo->{path})."/$value"; - next; - } - - # If we set default time zone, remove the one we have - $value= mtr_match_prefix($opt, "--default-time-zone="); - if ( defined $value ) - { - # Set timezone for this test case to something different - $tinfo->{'timezone'}= "GMT-8"; - # Fallthrough, add the --default-time-zone option - } - - # The --restart option forces a restart even if no special - # option is set. If the options are the same as next testcase - # there is no need to restart after the testcase - # has completed - if ( $opt eq "--force-restart" ) - { - $tinfo->{'force_restart'}= 1; - next; - } - - # Ok, this was a real option, add it - push(@{$tinfo->{$opt_name}}, $opt); + $tinfo->{'timezone'}= $value; + next; } + + $value= mtr_match_prefix($opt, "--plugin-load="); + if (defined $value) + { + push @plugins, $value; + next; + } + + $value= mtr_match_prefix($opt, "--result-file="); + if ( defined $value ) + { + # Specifies the file mysqltest should compare + # output against + $tinfo->{'result_file'}= "r/$value.result"; + next; + } + + $value= mtr_match_prefix($opt, "--config-file-template="); + if ( defined $value) + { + # Specifies the configuration file to use for this test + $tinfo->{'template_path'}= dirname($tinfo->{path})."/$value"; + next; + } + + # If we set default time zone, remove the one we have + $value= mtr_match_prefix($opt, "--default-time-zone="); + if ( defined $value ) + { + # Set timezone for this test case to something different + $tinfo->{'timezone'}= "GMT-8"; + # Fallthrough, add the --default-time-zone option + } + + # The --restart option forces a restart even if no special + # option is set. If the options are the same as next testcase + # there is no need to restart after the testcase + # has completed + if ( $opt eq "--force-restart" ) + { + $tinfo->{'force_restart'}= 1; + next; + } + + # Ok, this was a real option, add it + push(@{$tinfo->{$opt_name}}, $opt); + } + + if (@plugins) { + push @{$tinfo->{$opt_name}}, "--plugin-load=" . join(':', @plugins); } } @@ -1009,15 +1016,17 @@ sub collect_one_test_case { # ---------------------------------------------------------------------- for (@source_files) { s/\.\w+$//; - process_opts_file($tinfo, "$_.opt", 'master_opt'); - process_opts_file($tinfo, "$_.opt", 'slave_opt'); - process_opts_file($tinfo, "$_-master.opt", 'master_opt'); - process_opts_file($tinfo, "$_-slave.opt", 'slave_opt'); + push @{$tinfo->{master_opt}}, opts_from_file("$_.opt"); + push @{$tinfo->{slave_opt}}, opts_from_file("$_.opt"); + push @{$tinfo->{master_opt}}, opts_from_file("$_-master.opt"); + push @{$tinfo->{slave_opt}}, opts_from_file("$_-slave.opt"); } push(@{$tinfo->{'master_opt'}}, @::opt_extra_mysqld_opt); push(@{$tinfo->{'slave_opt'}}, @::opt_extra_mysqld_opt); + process_opts($tinfo, 'master_opt'); + process_opts($tinfo, 'slave_opt'); return $tinfo; } @@ -1103,6 +1112,8 @@ sub opts_from_file ($) { my $file= shift; local $_; + return () unless -f $file; + open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!"); my @args; while ( ) @@ -1143,7 +1154,7 @@ sub opts_from_file ($) { } } close FILE; - return \@args; + return @args; } sub print_testcases { diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 25b881488db..98e116b4217 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3564,8 +3564,9 @@ sub timezone { my ($tinfo)= @_; local $_ = $tinfo->{timezone}; return 'DEFAULT' unless defined $_; - s/\$\{(\w+)\}/envsubst($1)/ge; - s/\$(\w+)/envsubst($1)/ge; + no warnings 'uninitialized'; + s/\$\{(\w+)\}/$ENV{$1}/ge; + s/\$(\w+)/$ENV{$1}/ge; $_; } @@ -5071,18 +5072,6 @@ sub started { return grep(defined $_, map($_->{proc}, @_)); } sub stopped { return grep(!defined $_, map($_->{proc}, @_)); } -sub envsubst { - my $string= shift; - - if ( ! defined $ENV{$string} ) - { - mtr_error(".opt file references '$string' which is not set"); - } - - return $ENV{$string}; -} - - sub get_extra_opts { my ($mysqld, $tinfo)= @_; @@ -5093,8 +5082,9 @@ sub get_extra_opts { # Expand environment variables foreach my $opt ( @$opts ) { - $opt =~ s/\$\{(\w+)\}/envsubst($1)/ge; - $opt =~ s/\$(\w+)/envsubst($1)/ge; + no warnings 'uninitialized'; + $opt =~ s/\$\{(\w+)\}/$ENV{$1}/ge; + $opt =~ s/\$(\w+)/$ENV{$1}/ge; } return $opts; } diff --git a/mysql-test/suite/federated/federated_innodb-slave.opt b/mysql-test/suite/federated/federated_innodb-slave.opt deleted file mode 100644 index 48457b17309..00000000000 --- a/mysql-test/suite/federated/federated_innodb-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-innodb diff --git a/mysql-test/suite/federated/federated_transactions-slave.opt b/mysql-test/suite/federated/federated_transactions-slave.opt deleted file mode 100644 index 48457b17309..00000000000 --- a/mysql-test/suite/federated/federated_transactions-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-innodb diff --git a/mysql-test/suite/federated/my.cnf b/mysql-test/suite/federated/my.cnf index 7556abad300..3962c2aca77 100644 --- a/mysql-test/suite/federated/my.cnf +++ b/mysql-test/suite/federated/my.cnf @@ -3,10 +3,8 @@ [mysqld.1] log-bin= master-bin -loose-federated [mysqld.2] -loose-federated [ENV] MASTER_MYPORT= @mysqld.1.port diff --git a/mysql-test/suite/federated/suite.opt b/mysql-test/suite/federated/suite.opt new file mode 100644 index 00000000000..2cce1887441 --- /dev/null +++ b/mysql-test/suite/federated/suite.opt @@ -0,0 +1,2 @@ +--federated +--plugin-load=$HA_FEDERATEDX_SO diff --git a/mysql-test/t/mysqltest_ps.test b/mysql-test/t/mysqltest_ps.test index c91f6dcb409..c5a332f691f 100644 --- a/mysql-test/t/mysqltest_ps.test +++ b/mysql-test/t/mysqltest_ps.test @@ -4,7 +4,7 @@ if (`SELECT $PS_PROTOCOL = 0`) { - --skip Need prepared statement protocol + --skip Need ps-protocol } # From e86aeaeec035ff68689c67b32c56d0305554a470 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 27 Aug 2010 16:53:16 +0200 Subject: [PATCH 090/118] use the correct path separator on windows. remove duplicates from the --plugin-load list. $ENV{TERM} can be undefined (on Windows) --- mysql-test/lib/mtr_cases.pm | 7 +++++-- mysql-test/mysql-test-run.pl | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index f7794d1964d..2aa12f60f32 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -621,6 +621,7 @@ sub process_opts { $tinfo->{$opt_name} = []; my @plugins; + my %seen; foreach my $opt (@opts) { @@ -640,7 +641,8 @@ sub process_opts { $value= mtr_match_prefix($opt, "--plugin-load="); if (defined $value) { - push @plugins, $value; + push @plugins, $value unless $seen{$value}; + $seen{$value}=1; next; } @@ -685,7 +687,8 @@ sub process_opts { } if (@plugins) { - push @{$tinfo->{$opt_name}}, "--plugin-load=" . join(':', @plugins); + my $sep = (IS_WIN32PERL) ? ';' : ':'; + push @{$tinfo->{$opt_name}}, "--plugin-load=" . join($sep, @plugins); } } diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 98e116b4217..62253b550f3 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -5840,7 +5840,7 @@ sub time_format($) { my $num_tests; sub xterm_stat { - if (-t STDOUT and $ENV{TERM} =~ /xterm/) { + if (-t STDOUT and defined $ENV{TERM} and $ENV{TERM} =~ /xterm/) { my ($left) = @_; # 2.5 -> best by test From 89d9105d448e1acbb72fad6dfc540a18e5f14d85 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 28 Aug 2010 11:29:44 +0300 Subject: [PATCH 091/118] Fixed failing tests mysql-test/suite/binlog/t/binlog_row_binlog.test: Don't run test if utf8_unicode_ci is not available mysql-test/suite/binlog/t/binlog_stm_binlog.test: Don't run test if utf8_unicode_ci is not available mysql-test/suite/funcs_1/r/is_columns_is.result: Update result mysql-test/suite/innodb/t/innodb_misc1.test: Don't run test if utf8_unicode_ci is not available mysql-test/suite/innodb/t/innodb_mysql.test: Don't run test if utf8_unicode_ci is not available --- .../suite/binlog/t/binlog_row_binlog.test | 4 +- .../suite/binlog/t/binlog_stm_binlog.test | 2 + .../suite/funcs_1/r/is_columns_is.result | 110 +++++++++--------- mysql-test/suite/innodb/t/innodb_misc1.test | 2 + mysql-test/suite/innodb/t/innodb_mysql.test | 2 + 5 files changed, 64 insertions(+), 56 deletions(-) diff --git a/mysql-test/suite/binlog/t/binlog_row_binlog.test b/mysql-test/suite/binlog/t/binlog_row_binlog.test index 8adc8eee5c1..2bf4f93f332 100644 --- a/mysql-test/suite/binlog/t/binlog_row_binlog.test +++ b/mysql-test/suite/binlog/t/binlog_row_binlog.test @@ -2,4 +2,6 @@ # For both statement and row based bin logs 9/19/2005 [jbm] -- source include/have_binlog_format_row.inc --- source extra/binlog_tests/binlog.test +let collation=utf8_unicode_ci; +--source include/have_collation.inc +--source extra/binlog_tests/binlog.test diff --git a/mysql-test/suite/binlog/t/binlog_stm_binlog.test b/mysql-test/suite/binlog/t/binlog_stm_binlog.test index f5257f21434..682b0a3bfa7 100644 --- a/mysql-test/suite/binlog/t/binlog_stm_binlog.test +++ b/mysql-test/suite/binlog/t/binlog_stm_binlog.test @@ -1,5 +1,7 @@ -- source include/not_embedded.inc -- source include/have_binlog_format_mixed.inc +let collation=utf8_unicode_ci; +--source include/have_collation.inc --disable_warnings drop table if exists t1; diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result index f3f7fae9e6c..e28ea5078b7 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is.result @@ -113,34 +113,34 @@ NULL information_schema GLOBAL_STATUS VARIABLE_NAME 1 NO varchar 64 192 NULL NU NULL information_schema GLOBAL_STATUS VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) select NULL information_schema GLOBAL_VARIABLES VARIABLE_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema GLOBAL_VARIABLES VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) select -NULL information_schema INNODB_BUFFER_POOL_PAGES fix_count 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES flush_type 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES lru_position 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES page_no 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES fix_count 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES flush_type 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES lru_position 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES page_no 3 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_BUFFER_POOL_PAGES page_type 1 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema INNODB_BUFFER_POOL_PAGES space_id 2 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB compressed 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB fix_count 7 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB flush_type 8 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB lru_position 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB next_page_no 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB page_no 2 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB part_len 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB space_id 1 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX access_time 9 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX data_size 7 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX dirty 11 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX fix_count 14 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX flush_type 15 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX hashed 8 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES space_id 2 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB compressed 3 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB fix_count 7 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB flush_type 8 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB lru_position 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB next_page_no 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB page_no 2 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB part_len 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB space_id 1 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX access_time 9 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX data_size 7 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX dirty 11 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX fix_count 14 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX flush_type 15 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX hashed 8 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX index_name 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX lru_position 13 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX modified 10 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX n_recs 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX old 12 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX page_no 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX lru_position 13 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX modified 10 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX n_recs 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX old 12 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX page_no 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX schema_name 1 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX space_id 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX space_id 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX table_name 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema INNODB_CMP compress_ops 2 0 NO int NULL NULL 10 0 NULL NULL int(11) select NULL information_schema INNODB_CMP compress_ops_ok 3 0 NO int NULL NULL 10 0 NULL NULL int(11) select @@ -164,10 +164,10 @@ NULL information_schema INNODB_CMP_RESET compress_time 4 0 NO int NULL NULL 10 0 NULL information_schema INNODB_CMP_RESET page_size 1 0 NO int NULL NULL 10 0 NULL NULL int(5) select NULL information_schema INNODB_CMP_RESET uncompress_ops 5 0 NO int NULL NULL 10 0 NULL NULL int(11) select NULL information_schema INNODB_CMP_RESET uncompress_time 6 0 NO int NULL NULL 10 0 NULL NULL int(11) select -NULL information_schema INNODB_INDEX_STATS fields 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_INDEX_STATS fields 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_INDEX_STATS index_name 3 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select -NULL information_schema INNODB_INDEX_STATS index_size 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_INDEX_STATS leaf_pages 7 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_INDEX_STATS index_size 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_INDEX_STATS leaf_pages 7 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_INDEX_STATS row_per_keys 5 NO varchar 256 768 NULL NULL utf8 utf8_general_ci varchar(256) select NULL information_schema INNODB_INDEX_STATS table_name 2 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select NULL information_schema INNODB_INDEX_STATS table_schema 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select @@ -175,9 +175,9 @@ NULL information_schema INNODB_LOCKS lock_data 10 NULL YES varchar 8192 24576 NU NULL information_schema INNODB_LOCKS lock_id 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select NULL information_schema INNODB_LOCKS lock_index 6 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) select NULL information_schema INNODB_LOCKS lock_mode 3 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select -NULL information_schema INNODB_LOCKS lock_page 8 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_LOCKS lock_rec 9 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_LOCKS lock_space 7 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_LOCKS lock_page 8 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_LOCKS lock_rec 9 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_LOCKS lock_space 7 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_LOCKS lock_table 5 NO varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) select NULL information_schema INNODB_LOCKS lock_trx_id 2 NO varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18) select NULL information_schema INNODB_LOCKS lock_type 4 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select @@ -185,42 +185,42 @@ NULL information_schema INNODB_LOCK_WAITS blocking_lock_id 4 NO varchar 81 243 NULL information_schema INNODB_LOCK_WAITS blocking_trx_id 3 NO varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18) select NULL information_schema INNODB_LOCK_WAITS requested_lock_id 2 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select NULL information_schema INNODB_LOCK_WAITS requesting_trx_id 1 NO varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18) select -NULL information_schema INNODB_RSEG curr_size 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_RSEG max_size 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_RSEG page_no 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_RSEG rseg_id 1 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_RSEG space_id 2 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_RSEG zip_size 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_SYS_INDEXES ID 2 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_RSEG curr_size 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_RSEG max_size 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_RSEG page_no 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_RSEG rseg_id 1 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_RSEG space_id 2 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_RSEG zip_size 3 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_SYS_INDEXES ID 2 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_SYS_INDEXES NAME 3 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select -NULL information_schema INNODB_SYS_INDEXES N_FIELDS 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_SYS_INDEXES PAGE_NO 7 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_SYS_INDEXES SPACE 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_SYS_INDEXES TABLE_ID 1 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_SYS_INDEXES TYPE 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_SYS_INDEXES N_FIELDS 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_SYS_INDEXES PAGE_NO 7 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_SYS_INDEXES SPACE 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_SYS_INDEXES TABLE_ID 1 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_SYS_INDEXES TYPE 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_SYS_TABLES CLUSTER_NAME 8 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select -NULL information_schema INNODB_SYS_TABLES ID 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_SYS_TABLES MIX_ID 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_SYS_TABLES MIX_LEN 7 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_SYS_TABLES ID 3 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_SYS_TABLES MIX_ID 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_SYS_TABLES MIX_LEN 7 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_SYS_TABLES NAME 2 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select -NULL information_schema INNODB_SYS_TABLES N_COLS 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_SYS_TABLES N_COLS 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_SYS_TABLES SCHEMA 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select -NULL information_schema INNODB_SYS_TABLES SPACE 9 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_SYS_TABLES TYPE 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_TABLE_STATS clust_size 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_TABLE_STATS modified 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_TABLE_STATS other_size 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_TABLE_STATS rows 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_SYS_TABLES SPACE 9 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_SYS_TABLES TYPE 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_TABLE_STATS clust_size 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_TABLE_STATS modified 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_TABLE_STATS other_size 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_TABLE_STATS rows 3 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_TABLE_STATS table_name 2 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select NULL information_schema INNODB_TABLE_STATS table_schema 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select NULL information_schema INNODB_TRX trx_id 1 NO varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18) select -NULL information_schema INNODB_TRX trx_mysql_thread_id 7 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_TRX trx_mysql_thread_id 7 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_TRX trx_query 8 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) select NULL information_schema INNODB_TRX trx_requested_lock_id 4 NULL YES varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select NULL information_schema INNODB_TRX trx_started 3 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select NULL information_schema INNODB_TRX trx_state 2 NO varchar 13 39 NULL NULL utf8 utf8_general_ci varchar(13) select NULL information_schema INNODB_TRX trx_wait_started 5 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select -NULL information_schema INNODB_TRX trx_weight 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_TRX trx_weight 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema KEY_COLUMN_USAGE COLUMN_NAME 7 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select NULL information_schema KEY_COLUMN_USAGE CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select NULL information_schema KEY_COLUMN_USAGE CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select diff --git a/mysql-test/suite/innodb/t/innodb_misc1.test b/mysql-test/suite/innodb/t/innodb_misc1.test index 1bebd5411bc..295b9ec464c 100644 --- a/mysql-test/suite/innodb/t/innodb_misc1.test +++ b/mysql-test/suite/innodb/t/innodb_misc1.test @@ -14,6 +14,8 @@ ####################################################################### -- source include/have_innodb.inc +let collation=utf8_unicode_ci; +--source include/have_collation.inc let $MYSQLD_DATADIR= `select @@datadir`; diff --git a/mysql-test/suite/innodb/t/innodb_mysql.test b/mysql-test/suite/innodb/t/innodb_mysql.test index 4d767ed5fc8..1171eaa899c 100644 --- a/mysql-test/suite/innodb/t/innodb_mysql.test +++ b/mysql-test/suite/innodb/t/innodb_mysql.test @@ -8,6 +8,8 @@ # Slow test, don't run during staging part -- source include/not_staging.inc -- source include/have_innodb.inc +-- source include/have_query_cache.inc + let $engine_type= InnoDB; let $other_engine_type= MEMORY; # InnoDB does support FOREIGN KEYFOREIGN KEYs From 7b91240bbab3094c8c148c46949c0202ae1e991d Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 28 Aug 2010 16:51:09 +0300 Subject: [PATCH 092/118] Fixed build & test failures in buildbot mysql-test/t/bug46080-master.opt: Lower limits to be able to run tests regex/main.c: Fixed compiler warnings storage/maria/ma_key_recover.c: Fixed compiler warnings storage/maria/ma_recovery.c: Fixed compiler warnings storage/maria/ma_unique.c: Fixed compiler warnings strings/ctype-uca.c: Added comment strings/xml.c: Fixed compiler warnings support-files/compiler_warnings.supp: Added suppressions for windows unittest/strings/strings-t.c: Added ifdef to fix compilation failure when compiling without UCA --- mysql-test/t/bug46080-master.opt | 2 +- regex/main.c | 4 ++-- storage/maria/ma_key_recover.c | 2 +- storage/maria/ma_recovery.c | 2 +- storage/maria/ma_unique.c | 3 +-- strings/ctype-uca.c | 4 ++-- strings/xml.c | 8 ++++---- support-files/compiler_warnings.supp | 7 ++++++- unittest/strings/strings-t.c | 2 ++ 9 files changed, 20 insertions(+), 14 deletions(-) diff --git a/mysql-test/t/bug46080-master.opt b/mysql-test/t/bug46080-master.opt index dacdab53a4b..ff809c0cc69 100644 --- a/mysql-test/t/bug46080-master.opt +++ b/mysql-test/t/bug46080-master.opt @@ -1 +1 @@ ---skip-grant-tables --skip-name-resolve --safemalloc-mem-limit=20000000 +--skip-grant-tables --skip-name-resolve --safemalloc-mem-limit=20000000 --loose-maria-pagecache-buffer-size=1M diff --git a/regex/main.c b/regex/main.c index fa97ca89047..e8277053382 100644 --- a/regex/main.c +++ b/regex/main.c @@ -17,8 +17,8 @@ regoff_t startoff = 0; regoff_t endoff = 0; -extern int split(); -extern void regprint(); +extern int split(char *string, char **fields, int nfields, const char *sep); +extern void regprint(my_regex_t *r, FILE *d); /* - main - do the simple case, hand off to regress() for regression diff --git a/storage/maria/ma_key_recover.c b/storage/maria/ma_key_recover.c index 82f8099fe6a..3b65b52cf75 100644 --- a/storage/maria/ma_key_recover.c +++ b/storage/maria/ma_key_recover.c @@ -1005,7 +1005,7 @@ uint _ma_apply_redo_index(MARIA_HA *info, { DBUG_PRINT("error", ("page_length %u",page_length)); DBUG_DUMP("KEY_OP_CHECK bad page", buff, max_page_length); - DBUG_ASSERT("crc" == "failure in REDO_INDEX"); + DBUG_ASSERT("crc failure in REDO_INDEX" == 0); } #endif DBUG_PRINT("redo", ("key_op_check")); diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index a10fac9a15d..c7457f9ac39 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -545,7 +545,7 @@ static int display_and_apply_record(const LOG_DESC *log_desc, if (log_desc->record_execute_in_redo_phase == NULL) { /* die on all not-yet-handled records :) */ - DBUG_ASSERT("one more hook" == "to write"); + DBUG_ASSERT("one more hook to write" == 0); return 1; } if ((error= (*log_desc->record_execute_in_redo_phase)(rec))) diff --git a/storage/maria/ma_unique.c b/storage/maria/ma_unique.c index bae58fd70cd..a90578c2162 100644 --- a/storage/maria/ma_unique.c +++ b/storage/maria/ma_unique.c @@ -68,8 +68,7 @@ my_bool _ma_check_unique(MARIA_HA *info, MARIA_UNIQUEDEF *def, uchar *record, DBUG_ASSERT(info->last_key.data_length == MARIA_UNIQUE_HASH_LENGTH); if (_ma_search_next(info, &info->last_key, SEARCH_BIGGER, info->s->state.key_root[def->key]) || - bcmp((char*) info->last_key.data, (char*) key_buff, - MARIA_UNIQUE_HASH_LENGTH)) + bcmp(info->last_key.data, key_buff, MARIA_UNIQUE_HASH_LENGTH)) { info->page_changed= 1; /* Can't optimize read next */ info->cur_row.lastpos= lastpos; diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index b2a60265a0a..3d08e466ca3 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -7002,7 +7002,7 @@ static my_uca_scanner_handler my_ucs2_uca_scanner_handler= my_uca_scanner_next_ucs2 }; -#endif +#endif /* HAVE_CHARSET_ucs2 */ /* @@ -8832,7 +8832,7 @@ CHARSET_INFO my_charset_ucs2_croatian_uca_ci= }; -#endif +#endif /* HAVE_CHARSET_ucs2 */ #ifdef HAVE_CHARSET_utf8 diff --git a/strings/xml.c b/strings/xml.c index 1b697ec6b26..14da69e088a 100644 --- a/strings/xml.c +++ b/strings/xml.c @@ -123,16 +123,16 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a) a->beg=p->cur; a->end=p->cur; - if ((p->end - p->cur > 3) && !bcmp(p->cur,"", 3); p->cur++) + for (; (p->cur < p->end) && bcmp((uchar*) p->cur, (uchar*) "-->", 3); p->cur++) {} - if (!bcmp(p->cur, "-->", 3)) + if (!bcmp((uchar*) p->cur, (uchar*) "-->", 3)) p->cur+=3; a->end=p->cur; lex=MY_XML_COMMENT; } - else if (!bcmp(p->cur, "cur, (uchar*) "cur+= 9; for (; p->cur < p->end - 2 ; p->cur++) diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp index 41ebf1bcf8a..fc861a1c830 100644 --- a/support-files/compiler_warnings.supp +++ b/support-files/compiler_warnings.supp @@ -24,7 +24,9 @@ sql_yacc.cc : .*switch statement contains 'default' but no 'case' labels.* # Things that can be ignored in InnoDB # pars0grm.tab.c: .*'yyerrorlab' : unreferenced label.* +pars0grm.c: 'yyerrorlab' : unreferenced label _flex_tmp.c: .*not enough actual parameters for macro 'yywrap'.* +lexyy.c : not enough actual parameters for macro 'yywrap' pars0lex.l: .*conversion from 'ulint' to 'int', possible loss of data.* btr/btr0cur\.c: .*value computed is not used.*: 3175-3375 include/buf0buf\.ic: unused parameter .*mtr.* @@ -44,7 +46,7 @@ buf/buf0buf\.c: .*block_mutex.* might be used uninitialized btr/btr0cur\.c: null argument where non-null required: 1800-3000 btr/btr0btr\.c: null argument where non-null required: 2500-3000 ibuf/ibuf0ibuf.c: null argument where non-null required: 700-1000 -fsp/fsp0fsp\.c: result of 32-bit shift implicitly converted to 64 bits +fsp0fsp\.c: result of 32-bit shift implicitly converted to 64 bits # # bdb is not critical to keep up to date @@ -111,6 +113,9 @@ signal\.c : .*unused parameter.* .* : conversion from '.*size_t' to 'uint16'.* .* : The following environment variables were not found.* +# Ignore uninitialized local variables on windows +.* : uninitialized local variable .* used + # # The following should be fixed by the ndb team # diff --git a/unittest/strings/strings-t.c b/unittest/strings/strings-t.c index 278f42e56a5..cb33af3ac03 100644 --- a/unittest/strings/strings-t.c +++ b/unittest/strings/strings-t.c @@ -87,7 +87,9 @@ static CHARSET_INFO *charset_list[]= #endif #ifdef HAVE_CHARSET_utf8 &my_charset_utf8_general_ci, +#ifdef HAVE_HAVE_UCA_COLLATIONS &my_charset_utf8_unicode_ci, +#endif &my_charset_utf8_bin, #endif }; From 01dd4f9a6eed921ac9fc9f3f5cf1eb3a67248a96 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 29 Aug 2010 19:02:26 +0200 Subject: [PATCH 093/118] typo fixed --- mysql-test/lib/My/ConfigFactory.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/lib/My/ConfigFactory.pm b/mysql-test/lib/My/ConfigFactory.pm index d5414713262..7725b025dd8 100644 --- a/mysql-test/lib/My/ConfigFactory.pm +++ b/mysql-test/lib/My/ConfigFactory.pm @@ -606,7 +606,7 @@ sub new_config { # add auto-options $config->insert('OPT', 'port' => sub { fix_port($self, $config) }); - $config->insert('OPT', 'vardir' => sub { shift->{ARGS}->{vardir} }); + $config->insert('OPT', 'vardir' => sub { $self->{ARGS}->{vardir} }); { # Run pre rules From 72a26cb020fdbee7bba7612f55ab4e254092a7af Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 30 Aug 2010 08:30:56 +0200 Subject: [PATCH 094/118] make the check for windows to work in cygnin perl too --- mysql-test/lib/mtr_cases.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index 2aa12f60f32..5536a1003ce 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -687,7 +687,7 @@ sub process_opts { } if (@plugins) { - my $sep = (IS_WIN32PERL) ? ';' : ':'; + my $sep = (IS_WINDOWS) ? ';' : ':'; push @{$tinfo->{$opt_name}}, "--plugin-load=" . join($sep, @plugins); } } From 401c69e49babc293da30f833c18673f5f071eca3 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 30 Aug 2010 16:25:23 +0300 Subject: [PATCH 095/118] Fixed test failure mysql-test/t/loaddata.test: Don't run test if ucs2 is not compiled --- mysql-test/t/loaddata.test | 2 ++ support-files/compiler_warnings.supp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index 821453777f5..53eae4fdfaa 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -2,6 +2,8 @@ # Some simple test of load data # +-- source include/have_ucs2.inc + --disable_warnings drop table if exists t1, t2; --enable_warnings diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp index fc861a1c830..a56c39b51a0 100644 --- a/support-files/compiler_warnings.supp +++ b/support-files/compiler_warnings.supp @@ -112,6 +112,8 @@ signal\.c : .*unused parameter.* .* : conversion from '.*size_t' to 'uInt'.* .* : conversion from '.*size_t' to 'uint16'.* .* : The following environment variables were not found.* +.* : no public symbols found; archive member will be inaccessible +.* : DESCRIPTION statement not supported # Ignore uninitialized local variables on windows .* : uninitialized local variable .* used From ee5551e644cfae6bc1c95df0ff98d70a666dfdd2 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 3 Sep 2010 13:01:47 +0300 Subject: [PATCH 096/118] Fixed bugs (mostly on sparc) that caused crashes in mysql-test-run sql/item_sum.cc: Fixed alignment problem that caused crases on sparc. (ORDER needs an aligment of 8 as it includes longlongs) storage/federatedx/ha_federatedx.cc: Fixed crash on sparc as 'pos' is not aligned on 4/8. storage/maria/ma_page.c: Removed wrong assert --- sql/item_sum.cc | 5 ++--- storage/federatedx/ha_federatedx.cc | 5 ++++- storage/maria/ma_page.c | 3 +-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 934003ead19..45c3ee3cd20 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3064,10 +3064,10 @@ Item_func_group_concat::Item_func_group_concat(THD *thd, object being copied. */ ORDER *tmp; - if (!(order= (ORDER **) thd->alloc(sizeof(ORDER *) * arg_count_order + + if (!(tmp= (ORDER *) thd->alloc(sizeof(ORDER *) * arg_count_order + sizeof(ORDER) * arg_count_order))) return; - tmp= (ORDER *)(order + arg_count_order); + order= (ORDER **)(tmp + arg_count_order); for (uint i= 0; i < arg_count_order; i++, tmp++) { memcpy(tmp, item->order[i], sizeof(ORDER)); @@ -3076,7 +3076,6 @@ Item_func_group_concat::Item_func_group_concat(THD *thd, } - void Item_func_group_concat::cleanup() { DBUG_ENTER("Item_func_group_concat::cleanup"); diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index b5215b17f62..c3105de7a94 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -2967,10 +2967,13 @@ int ha_federatedx::rnd_pos(uchar *buf, uchar *pos) DBUG_ENTER("ha_federatedx::rnd_pos"); ha_statistic_increment(&SSV::ha_read_rnd_count); + /* We have to move this to 'ref' to get things aligned */ + bmove(ref, pos, ref_length); + if ((retval= txn->acquire(share, TRUE, &io))) goto error; - if ((retval= io->seek_position(&result, pos))) + if ((retval= io->seek_position(&result, ref))) goto error; retval= read_next(buf, result); diff --git a/storage/maria/ma_page.c b/storage/maria/ma_page.c index acbee2a6f07..80a9c4f486f 100644 --- a/storage/maria/ma_page.c +++ b/storage/maria/ma_page.c @@ -423,8 +423,7 @@ my_off_t _ma_new(register MARIA_HA *info, int level, share->key_del_current= mi_sizekorr(buff+share->keypage_header); #ifndef DBUG_OFF key_del_current= share->key_del_current; - DBUG_ASSERT(key_del_current != share->state.key_del && - (key_del_current != 0) && + DBUG_ASSERT((key_del_current != 0) && ((key_del_current == HA_OFFSET_ERROR) || (key_del_current <= (share->state.state.key_file_length - block_size)))); From 9ec2d5b6e510b9a3ad2fd54c37eb302c0121f9e3 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Sep 2010 17:41:57 +0200 Subject: [PATCH 097/118] Updated with changes from lp:percona-server/release-5.1.49-12 as of September 3, 2010 --- ChangeLog | 143 ++++- Makefile.in | 1 + btr/btr0btr.c | 21 +- btr/btr0cur.c | 16 +- btr/btr0sea.c | 1 + buf/buf0buddy.c | 19 +- buf/buf0buf.c | 456 +++++++++++++- buf/buf0flu.c | 27 + buf/buf0lru.c | 19 +- dict/dict0boot.c | 107 +++- dict/dict0crea.c | 224 ++++++- dict/dict0dict.c | 384 ++++++++++-- dict/dict0load.c | 10 +- dict/dict0mem.c | 4 +- fil/fil0fil.c | 154 ++--- fsp/fsp0fsp.c | 6 +- ha/hash0hash.c | 64 ++ handler/ha_innodb.cc | 458 ++++++++++---- handler/ha_innodb.h | 4 + handler/handler0alter.cc | 2 + handler/i_s.cc | 202 ++++--- handler/i_s.h | 1 + handler/innodb_patch_info.h | 1 + include/buf0buf.h | 15 +- include/buf0buf.ic | 5 + include/buf0lru.h | 2 +- include/buf0rea.h | 3 +- include/db0err.h | 2 + include/dict0boot.h | 20 +- include/dict0crea.h | 18 + include/dict0dict.h | 8 +- include/dict0mem.h | 2 +- include/fil0fil.h | 24 +- include/ha_prototypes.h | 20 +- include/hash0hash.h | 49 ++ include/lock0lock.h | 12 +- include/log0log.ic | 5 +- include/mach0data.ic | 23 +- include/mtr0log.ic | 2 +- include/os0proc.h | 28 + include/page0page.h | 2 +- include/page0page.ic | 3 + include/page0zip.h | 2 +- include/que0que.h | 2 + include/rem0cmp.h | 4 +- include/row0mysql.h | 72 ++- include/srv0srv.h | 6 +- include/sync0rw.h | 5 +- include/sync0sync.h | 2 +- include/trx0sys.h | 1 + include/trx0trx.h | 4 +- include/univ.i | 18 +- include/ut0lst.h | 43 ++ lock/lock0lock.c | 178 +++--- log/log0log.c | 5 +- log/log0recv.c | 6 +- os/os0file.c | 19 +- os/os0proc.c | 170 ++++++ page/page0zip.c | 12 +- .../percona_innodb_buffer_pool_shm-master.opt | 1 + .../percona_innodb_buffer_pool_shm.result | 6 + .../percona_innodb_buffer_pool_shm.test | 18 + ...cona_innodb_use_sys_stats_table-master.opt | 1 + .../percona_innodb_use_sys_stats_table.result | 3 + .../percona_innodb_use_sys_stats_table.test | 2 + .../percona_log_connection_error-master.opt | 1 + .../percona_log_connection_error.result | 15 + .../percona_log_connection_error.test | 52 ++ ...ona_query_response_time-replication.result | 60 ++ ...rcona_query_response_time-replication.test | 52 ++ .../percona_query_response_time-stored.result | 310 ++++++++++ .../percona_query_response_time-stored.test | 87 +++ .../percona_query_response_time.result | 564 ++++++++++++++++++ .../percona_query_response_time.test | 65 ++ .../percona_query_response_time_flush.inc | 1 + .../percona_query_response_time_show.inc | 7 + .../percona_query_response_time_sleep.inc | 19 + percona-suite/percona_server_variables.result | 340 +++++++++++ percona-suite/percona_server_variables.test | 7 + .../percona_slave_innodb_stats-master.opt | 1 + .../percona_slave_innodb_stats-slave.opt | 1 + .../percona_slave_innodb_stats.result | 21 + percona-suite/percona_slave_innodb_stats.test | 43 ++ ...uery_log-use_global_long_query_time.result | 35 ++ ..._query_log-use_global_long_query_time.test | 21 + percona-suite/percona_sql_no_fcache.result | 12 + percona-suite/percona_sql_no_fcache.test | 11 + ...rcona_status_wait_query_cache_mutex.result | 27 + ...percona_status_wait_query_cache_mutex.test | 37 ++ percona-suite/percona_xtradb_bug317074.test | 5 +- que/que0que.c | 14 + rem/rem0cmp.c | 7 +- row/row0ins.c | 139 +++-- row/row0merge.c | 133 +++-- row/row0mysql.c | 133 +++-- row/row0purge.c | 11 + row/row0sel.c | 179 ++++-- row/row0uins.c | 13 +- row/row0umod.c | 78 ++- row/row0undo.c | 4 +- row/row0upd.c | 16 +- srv/srv0srv.c | 15 +- srv/srv0start.c | 5 + sync/sync0arr.c | 4 +- sync/sync0rw.c | 22 +- sync/sync0sync.c | 8 +- trx/trx0i_s.c | 40 +- trx/trx0purge.c | 3 +- trx/trx0sys.c | 8 +- trx/trx0trx.c | 57 +- ut/ut0auxconf_atomic_pthread_t_gcc.c | 43 -- ut/ut0auxconf_atomic_pthread_t_solaris.c | 54 -- ut/ut0auxconf_have_gcc_atomics.c | 61 -- ut/ut0auxconf_have_solaris_atomics.c | 39 -- ut/ut0auxconf_pause.c | 32 - ut/ut0auxconf_sizeof_pthread_t.c | 35 -- 116 files changed, 4951 insertions(+), 1143 deletions(-) create mode 100644 percona-suite/percona_innodb_buffer_pool_shm-master.opt create mode 100644 percona-suite/percona_innodb_buffer_pool_shm.result create mode 100644 percona-suite/percona_innodb_buffer_pool_shm.test create mode 100644 percona-suite/percona_innodb_use_sys_stats_table-master.opt create mode 100644 percona-suite/percona_innodb_use_sys_stats_table.result create mode 100644 percona-suite/percona_innodb_use_sys_stats_table.test create mode 100644 percona-suite/percona_log_connection_error-master.opt create mode 100644 percona-suite/percona_log_connection_error.result create mode 100644 percona-suite/percona_log_connection_error.test create mode 100644 percona-suite/percona_query_response_time-replication.result create mode 100644 percona-suite/percona_query_response_time-replication.test create mode 100644 percona-suite/percona_query_response_time-stored.result create mode 100644 percona-suite/percona_query_response_time-stored.test create mode 100644 percona-suite/percona_query_response_time.result create mode 100644 percona-suite/percona_query_response_time.test create mode 100644 percona-suite/percona_query_response_time_flush.inc create mode 100644 percona-suite/percona_query_response_time_show.inc create mode 100644 percona-suite/percona_query_response_time_sleep.inc create mode 100644 percona-suite/percona_server_variables.result create mode 100644 percona-suite/percona_server_variables.test create mode 100644 percona-suite/percona_slave_innodb_stats-master.opt create mode 100644 percona-suite/percona_slave_innodb_stats-slave.opt create mode 100644 percona-suite/percona_slave_innodb_stats.result create mode 100644 percona-suite/percona_slave_innodb_stats.test create mode 100644 percona-suite/percona_sql_no_fcache.result create mode 100644 percona-suite/percona_sql_no_fcache.test create mode 100644 percona-suite/percona_status_wait_query_cache_mutex.result create mode 100644 percona-suite/percona_status_wait_query_cache_mutex.test delete mode 100644 ut/ut0auxconf_atomic_pthread_t_gcc.c delete mode 100644 ut/ut0auxconf_atomic_pthread_t_solaris.c delete mode 100644 ut/ut0auxconf_have_gcc_atomics.c delete mode 100644 ut/ut0auxconf_have_solaris_atomics.c delete mode 100644 ut/ut0auxconf_pause.c delete mode 100644 ut/ut0auxconf_sizeof_pthread_t.c diff --git a/ChangeLog b/ChangeLog index bc69aaca96a..5ebcf1e87a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,128 @@ +2010-06-24 The InnoDB Team + + * handler/ha_innodb.cc: + Fix Bug#54679 alter table causes compressed row_format to revert + to compact + +2010-06-22 The InnoDB Team + + * dict/dict0dict.c, dict/dict0mem.c, include/dict0mem.h, + include/univ.i, page/page0zip.c, row/row0merge.c: + Fix Bug#47991 InnoDB Dictionary Cache memory usage increases + indefinitely when renaming tables + +2010-06-22 The InnoDB Team + + * handler/ha_innodb.cc: + Fix Bug#54686: "field->col->mtype == type" assertion error at + row/row0sel.c + +2010-06-22 The InnoDB Team + + * handler/ha_innodb.cc, innodb_bug54044.result, innodb_bug54044.test: + Fix Bug#54044 Create temporary tables and using innodb crashes. + +2010-06-21 The InnoDB Team + + * dict/dict0load.c, fil/fil0fil.c: + Fix Bug#54658: InnoDB: Warning: allocated tablespace %lu, + old maximum was 0 (introduced in Bug #53578 fix) + +2010-06-16 The InnoDB Team + + * row/row0merge.c: + Fix Bug#54330 Broken fast index creation + +2010-06-10 The InnoDB Team + + * include/log0log.ic, row/row0ins.c, row/row0purge.c, + row/row0uins.c, row/row0umod.c, row/row0upd.c: + Fix Bug#39168 ERROR: the age of the last checkpoint ... exceeds + the log group capacity + +2010-06-08 The InnoDB Team + + * dict/dict0load.c: + Fix Bug#54009 Server crashes when data is selected from non backed + up table for InnoDB plugin + +2010-06-02 The InnoDB Team + + * include/db0err.h, include/lock0lock.h, include/row0mysql.h, + lock/lock0lock.c, row/row0ins.c, row/row0mysql.c, row/row0sel.c: + Fix Bug#53674 InnoDB: Error: unlock row could not find a + 4 mode lock on the record + +2010-06-01 The InnoDB Team + + * include/sync0rw.h, sync/sync0rw.c: + Fix Bug#48197 Concurrent rw_lock_free may cause assertion failure + +2010-06-01 The InnoDB Team + + * row/row0umod.c: + Fix Bug#53812 assert row/row0umod.c line 660 in txn rollback + after crash recovery + +2010-05-25 The InnoDB Team + + * handler/ha_innodb.cc, include/row0mysql.h, row/row0mysql.c: + Fix Bug#53592: crash replacing duplicates into table after fast + alter table added unique key + +2010-05-24 The InnoDB Team + + * dict/dict0boot.c, dict/dict0crea.c, fil/fil0fil.c, + include/dict0boot.h, include/fil0fil.h, row/row0mysql.c: + Fix Bug#53578: assert on invalid page access, in fil_io() + +2010-05-14 The InnoDB Team + * mysql-test/innodb_bug48024.test, mysql-test/innodb_bug48024.result, + dict/dict0dict.c, handler/ha_innodb.cc, handler/ha_innodb.h, + include/dict0dict.h, include/ha_prototypes.h, include/row0mysql.h, + include/trx0trx.h, row/row0mysql.c, trx/trx0i_s.c, trx/trx0trx.c: + Fix Bug#48024 Innodb doesn't work with multi-statements + Fix Bug#53644 InnoDB thinks that /*/ starts and ends a comment + +2010-05-12 The InnoDB Team + + * handler/handler0alter.cc: + Fix Bug#53591 crash with fast alter table and text/blob prefix + primary key + +2010-05-12 The InnoDB Team + + * row/row0merge.c: + Fix Bug#53471 row_merge_drop_temp_indexes() refers freed memory, SEGVs + +2010-05-11 The InnoDB Team + + * mysql-test/innodb_bug53290.test, mysql-test/innodb_bug53290.result, + include/rem0cmp.h, rem/rem0cmp.c, row/row0merge.c: + Fix Bug#53290 wrong duplicate key error when adding a unique index + via fast alter table + +2010-05-11 The InnoDB Team + * buf/buf0lru.c, include/buf0buf.ic: + Fix Bug#53307 valgrind: warnings in main.partition_innodb_plugin + +2010-05-05 The InnoDB Team + + * row/row0merge.c: + Fix Bug#53256 in a stress test, assert dict/dict0dict.c:815 + table2 == NULL + +2010-05-05 The InnoDB Team + + * handler/ha_innodb.cc: + Fix Bug#53165 Setting innodb_change_buffering=DEFAULT produces + incorrect result + +2010-05-04 The InnoDB Team + + * fsp/fsp0fsp.c: + Fix Bug#53306 valgrind: warnings in innodb.innodb + 2010-05-03 The InnoDB Team * buf0buf.c: @@ -48,12 +173,6 @@ Only check the record size at index creation time when innodb_strict_mode is set or when ROW_FORMAT is DYNAMIC or COMPRESSED. -2010-04-20 The InnoDB Team - - * btr/btr0btr.c, include/univ.i: - Implement UNIV_BTR_AVOID_COPY, for avoiding writes when a B-tree - node is split at the first or last record. - 2010-04-15 The InnoDB Team * trx/trx0rec.c: @@ -72,6 +191,10 @@ * mysql-test/innodb_bug38231.test: Remove non-determinism in the test case. +2010-03-29 The InnoDB Team + + InnoDB Plugin 1.0.7 released + 2010-03-18 The InnoDB Team * CMakeLists.txt: @@ -194,6 +317,14 @@ Fix Bug#49497 Error 1467 (ER_AUTOINC_READ_FAILED) on inserting a negative value +2010-01-28 The InnoDB Team + * handler/ha_innodb.h, handler/ha_innodb.cc, + handler/handler0alter.cc, + mysql-test/innodb_bug47622.test, + mysql-test/innodb_bug47622.result: + Fix Bug#47622 the new index is added before the existing ones + in MySQL, but after one in SE + 2010-01-27 The InnoDB Team * include/row0mysql.h, log/log0recv.c, row/row0mysql.c: diff --git a/Makefile.in b/Makefile.in index c4bb0f9a9a2..ab393ac1d62 100644 --- a/Makefile.in +++ b/Makefile.in @@ -573,6 +573,7 @@ yassl_dir = @yassl_dir@ yassl_h_ln_cmd = @yassl_h_ln_cmd@ yassl_libs = @yassl_libs@ yassl_taocrypt_extra_cxxflags = @yassl_taocrypt_extra_cxxflags@ +yassl_thread_cxxflags = @yassl_thread_cxxflags@ zlib_dir = @zlib_dir@ MYSQLDATAdir = $(localstatedir) MYSQLSHAREdir = $(pkgdatadir) diff --git a/btr/btr0btr.c b/btr/btr0btr.c index 12e57dcc490..ff047095aa4 100644 --- a/btr/btr0btr.c +++ b/btr/btr0btr.c @@ -2030,6 +2030,7 @@ func_start: goto insert_empty; } } else if (UNIV_UNLIKELY(insert_left)) { + ut_a(n_iterations > 0); first_rec = page_rec_get_next(page_get_infimum_rec(page)); move_limit = page_rec_get_next(btr_cur_get_rec(cursor)); } else { @@ -2076,17 +2077,7 @@ insert_empty: } /* 5. Move then the records to the new page */ - if (direction == FSP_DOWN -#ifdef UNIV_BTR_AVOID_COPY - && page_rec_is_supremum(move_limit)) { - /* Instead of moving all records, make the new page - the empty page. */ - - left_block = block; - right_block = new_block; - } else if (direction == FSP_DOWN -#endif /* UNIV_BTR_AVOID_COPY */ - ) { + if (direction == FSP_DOWN) { /* fputs("Split left\n", stderr); */ if (0 @@ -2129,14 +2120,6 @@ insert_empty: right_block = block; lock_update_split_left(right_block, left_block); -#ifdef UNIV_BTR_AVOID_COPY - } else if (!split_rec) { - /* Instead of moving all records, make the new page - the empty page. */ - - left_block = new_block; - right_block = block; -#endif /* UNIV_BTR_AVOID_COPY */ } else { /* fputs("Split right\n", stderr); */ diff --git a/btr/btr0cur.c b/btr/btr0cur.c index 91ff5957d48..9b87d969a64 100644 --- a/btr/btr0cur.c +++ b/btr/btr0cur.c @@ -2136,9 +2136,8 @@ any_extern: err = btr_cur_upd_lock_and_undo(flags, cursor, update, cmpl_info, thr, mtr, &roll_ptr); if (err != DB_SUCCESS) { -err_exit: - mem_heap_free(heap); - return(err); + + goto err_exit; } /* Ok, we may do the replacement. Store on the page infimum the @@ -2184,9 +2183,10 @@ err_exit: page_cur_move_to_next(page_cursor); + err = DB_SUCCESS; +err_exit: mem_heap_free(heap); - - return(DB_SUCCESS); + return(err); } /*************************************************************//** @@ -3412,7 +3412,7 @@ btr_estimate_n_pages_not_null( ibool diverged_lot; ulint divergence_level; ulint n_pages; - ulint i,j; + ulint i; mtr_t mtr; mem_heap_t* heap; @@ -4259,6 +4259,8 @@ btr_store_big_rec_extern_fields( field_ref += local_len; } extern_len = big_rec_vec->fields[i].len; + UNIV_MEM_ASSERT_RW(big_rec_vec->fields[i].data, + extern_len); ut_a(extern_len > 0); @@ -4895,6 +4897,7 @@ btr_copy_blob_prefix( mtr_commit(&mtr); if (page_no == FIL_NULL || copy_len != part_len) { + UNIV_MEM_ASSERT_RW(buf, copied_len); return(copied_len); } @@ -5078,6 +5081,7 @@ btr_copy_externally_stored_field_prefix_low( space_id, page_no, offset); inflateEnd(&d_stream); mem_heap_free(heap); + UNIV_MEM_ASSERT_RW(buf, d_stream.total_out); return(d_stream.total_out); } else { return(btr_copy_blob_prefix(buf, len, space_id, diff --git a/btr/btr0sea.c b/btr/btr0sea.c index 61909903a67..36dadd47e69 100644 --- a/btr/btr0sea.c +++ b/btr/btr0sea.c @@ -182,6 +182,7 @@ void btr_search_sys_free(void) /*=====================*/ { + rw_lock_free(&btr_search_latch); mem_free(btr_search_latch_temp); btr_search_latch_temp = NULL; mem_heap_free(btr_search_sys->hash_index->heap); diff --git a/buf/buf0buddy.c b/buf/buf0buddy.c index 8fc6c286d4d..8ce2d1888ef 100644 --- a/buf/buf0buddy.c +++ b/buf/buf0buddy.c @@ -490,11 +490,15 @@ buf_buddy_relocate( pool), so there is nothing wrong about this. The mach_read_from_4() calls here will only trigger bogus Valgrind memcheck warnings in UNIV_DEBUG_VALGRIND builds. */ - bpage = buf_page_hash_get( - mach_read_from_4((const byte*) src - + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID), - mach_read_from_4((const byte*) src - + FIL_PAGE_OFFSET)); + ulint space = mach_read_from_4( + (const byte*) src + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); + ulint page_no = mach_read_from_4( + (const byte*) src + FIL_PAGE_OFFSET); + /* Suppress Valgrind warnings about conditional jump + on uninitialized value. */ + UNIV_MEM_VALID(&space, sizeof space); + UNIV_MEM_VALID(&page_no, sizeof page_no); + bpage = buf_page_hash_get(space, page_no); if (!bpage || bpage->zip.data != src) { /* The block has probably been freshly @@ -569,7 +573,12 @@ success: } } else if (i == buf_buddy_get_slot(sizeof(buf_page_t))) { /* This must be a buf_page_t object. */ +#if UNIV_WORD_SIZE == 4 + /* On 32-bit systems, there is no padding in + buf_page_t. On other systems, Valgrind could complain + about uninitialized pad bytes. */ UNIV_MEM_ASSERT_RW(src, size); +#endif mutex_exit(&zip_free_mutex); diff --git a/buf/buf0buf.c b/buf/buf0buf.c index 8592704665a..8b12e9c67b0 100644 --- a/buf/buf0buf.c +++ b/buf/buf0buf.c @@ -53,6 +53,10 @@ Created 11/5/1995 Heikki Tuuri #include "page0zip.h" #include "trx0trx.h" #include "srv0start.h" +#include "que0que.h" +#include "read0read.h" +#include "row0row.h" +#include "ha_prototypes.h" /* prototypes for new functions added to ha_innodb.cc */ trx_t* innobase_get_trx(); @@ -78,9 +82,9 @@ inline void _increment_page_get_statistics(buf_block_t* block, trx_t* trx) block_hash_byte = block_hash >> 3; block_hash_offset = (byte) block_hash & 0x07; if (block_hash_byte < 0 || block_hash_byte >= DPAH_SIZE) - fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset); + fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %d !!!\n", block_hash_byte, block_hash_offset); if (block_hash_offset < 0 || block_hash_offset > 7) - fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset); + fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %d !!!\n", block_hash_byte, block_hash_offset); if ((trx->distinct_page_access_hash[block_hash_byte] & ((byte) 0x01 << block_hash_offset)) == 0) trx->distinct_page_access++; trx->distinct_page_access_hash[block_hash_byte] |= (byte) 0x01 << block_hash_offset; @@ -310,14 +314,30 @@ read-ahead or flush occurs */ UNIV_INTERN ibool buf_debug_prints = FALSE; #endif /* UNIV_DEBUG */ -/** A chunk of buffers. The buffer pool is allocated in chunks. */ -struct buf_chunk_struct{ - ulint mem_size; /*!< allocated size of the chunk */ - ulint size; /*!< size of frames[] and blocks[] */ - void* mem; /*!< pointer to the memory area which - was allocated for the frames */ - buf_block_t* blocks; /*!< array of buffer control blocks */ +/* Buffer pool shared memory segment information */ +typedef struct buf_shm_info_struct buf_shm_info_t; + +struct buf_shm_info_struct { + char head_str[8]; + ulint binary_id; + ibool is_new; /* during initializing */ + ibool clean; /* clean shutdowned and free */ + ibool reusable; /* reusable */ + ulint buf_pool_size; /* backup value */ + ulint page_size; /* backup value */ + ulint frame_offset; /* offset of the first frame based on chunk->mem */ + ulint zip_hash_offset; + ulint zip_hash_n; + + ulint checksum; + + buf_pool_t buf_pool_backup; + buf_chunk_t chunk_backup; + + ib_uint64_t dummy; }; + +#define BUF_SHM_INFO_HEAD "XTRA_SHM" #endif /* !UNIV_HOTBACKUP */ /********************************************************************//** @@ -764,6 +784,45 @@ buf_block_init( #endif /* UNIV_SYNC_DEBUG */ } +static +void +buf_block_reuse( +/*============*/ + buf_block_t* block, + ptrdiff_t frame_offset) +{ + /* block_init */ + block->frame = ((void*)(block->frame) + frame_offset); + + UNIV_MEM_DESC(block->frame, UNIV_PAGE_SIZE, block); + + block->index = NULL; + +#ifdef UNIV_DEBUG + /* recreate later */ + block->page.in_page_hash = FALSE; + block->page.in_zip_hash = FALSE; +#endif /* UNIV_DEBUG */ + +#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG + block->n_pointers = 0; +#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ + + if (block->page.zip.data) + block->page.zip.data = ((void*)(block->page.zip.data) + frame_offset); + + block->is_hashed = FALSE; + + mutex_create(&block->mutex, SYNC_BUF_BLOCK); + + rw_lock_create(&block->lock, SYNC_LEVEL_VARYING); + ut_ad(rw_lock_validate(&(block->lock))); + +#ifdef UNIV_SYNC_DEBUG + rw_lock_create(&block->debug_latch, SYNC_NO_ORDER_CHECK); +#endif /* UNIV_SYNC_DEBUG */ +} + /********************************************************************//** Allocates a chunk of buffer frames. @return chunk, or NULL on failure */ @@ -776,26 +835,167 @@ buf_chunk_init( { buf_block_t* block; byte* frame; + ulint zip_hash_n = 0; + ulint zip_hash_mem_size = 0; + hash_table_t* zip_hash_tmp = NULL; ulint i; + buf_shm_info_t* shm_info = NULL; /* Round down to a multiple of page size, although it already should be. */ mem_size = ut_2pow_round(mem_size, UNIV_PAGE_SIZE); + + if (srv_buffer_pool_shm_key) { + /* zip_hash size */ + zip_hash_n = (mem_size / UNIV_PAGE_SIZE) * 2; + zip_hash_mem_size = ut_2pow_round(hash_create_needed(zip_hash_n) + + (UNIV_PAGE_SIZE - 1), UNIV_PAGE_SIZE); + } + /* Reserve space for the block descriptors. */ mem_size += ut_2pow_round((mem_size / UNIV_PAGE_SIZE) * (sizeof *block) + (UNIV_PAGE_SIZE - 1), UNIV_PAGE_SIZE); + if (srv_buffer_pool_shm_key) { + mem_size += ut_2pow_round(sizeof(buf_shm_info_t) + + (UNIV_PAGE_SIZE - 1), UNIV_PAGE_SIZE); + mem_size += zip_hash_mem_size; + } chunk->mem_size = mem_size; + + if (srv_buffer_pool_shm_key) { + ulint binary_id; + ibool is_new; + + ut_a(buf_pool->n_chunks == 1); + + fprintf(stderr, + "InnoDB: Notice: innodb_buffer_pool_shm_key option is specified.\n" + "InnoDB: This option may not be safe to keep consistency of datafiles.\n" + "InnoDB: Because InnoDB cannot lock datafiles when shutdown until reusing shared memory segment.\n" + "InnoDB: You should ensure no change of InnoDB files while using innodb_buffer_pool_shm_key.\n"); + + /* FIXME: This is vague id still */ + binary_id = (ulint) ((void*)mtr_commit - (void*)btr_root_get) + + (ulint) ((void*)os_get_os_version - (void*)buf_calc_page_new_checksum) + + (ulint) ((void*)page_dir_find_owner_slot - (void*)dfield_data_is_binary_equal) + + (ulint) ((void*)que_graph_publish - (void*)dict_casedn_str) + + (ulint) ((void*)read_view_oldest_copy_or_open_new - (void*)fil_space_get_version) + + (ulint) ((void*)rec_get_n_extern_new - (void*)fsp_get_size_low) + + (ulint) ((void*)row_get_trx_id_offset - (void*)ha_create_func) + + (ulint) ((void*)srv_set_io_thread_op_info - (void*)thd_is_replication_slave_thread) + + (ulint) ((void*)mutex_create_func - (void*)ibuf_inside) + + (ulint) ((void*)trx_set_detailed_error - (void*)lock_check_trx_id_sanity) + + (ulint) ((void*)ut_time - (void*)mem_heap_strdup); + + chunk->mem = os_shm_alloc(&chunk->mem_size, srv_buffer_pool_shm_key, &is_new); + + if (UNIV_UNLIKELY(chunk->mem == NULL)) { + return(NULL); + } + +#ifdef UNIV_SET_MEM_TO_ZERO + if (is_new) { + memset(chunk->mem, '\0', chunk->mem_size); + } +#endif + + shm_info = chunk->mem; + + zip_hash_tmp = (hash_table_t*)((void*)chunk->mem + chunk->mem_size - zip_hash_mem_size); + + if (is_new) { + strncpy(shm_info->head_str, BUF_SHM_INFO_HEAD, 8); + shm_info->binary_id = binary_id; + shm_info->is_new = TRUE; /* changed to FALSE when the initialization is finished */ + shm_info->clean = FALSE; /* changed to TRUE when free the segment. */ + shm_info->reusable = FALSE; /* changed to TRUE when validation is finished. */ + shm_info->buf_pool_size = srv_buf_pool_size; + shm_info->page_size = srv_page_size; + shm_info->zip_hash_offset = chunk->mem_size - zip_hash_mem_size; + shm_info->zip_hash_n = zip_hash_n; + } else { + ulint checksum; + + if (strncmp(shm_info->head_str, BUF_SHM_INFO_HEAD, 8)) { + fprintf(stderr, + "InnoDB: Error: The shared memory segment seems not to be for buffer pool.\n"); + return(NULL); + } + if (shm_info->binary_id != binary_id) { + fprintf(stderr, + "InnoDB: Error: The shared memory segment seems not to be for this binary.\n"); + return(NULL); + } + if (shm_info->is_new) { + fprintf(stderr, + "InnoDB: Error: The shared memory was not initialized yet.\n"); + return(NULL); + } + if (!shm_info->clean) { + fprintf(stderr, + "InnoDB: Error: The shared memory was not shut down cleanly.\n"); + return(NULL); + } + if (!shm_info->reusable) { + fprintf(stderr, + "InnoDB: Error: The shared memory has unrecoverable contents.\n"); + return(NULL); + } + if (shm_info->buf_pool_size != srv_buf_pool_size) { + fprintf(stderr, + "InnoDB: Error: srv_buf_pool_size is different (shm=%lu current=%lu).\n", + shm_info->buf_pool_size, srv_buf_pool_size); + return(NULL); + } + if (shm_info->page_size != srv_page_size) { + fprintf(stderr, + "InnoDB: Error: srv_page_size is different (shm=%lu current=%lu).\n", + shm_info->page_size, srv_page_size); + return(NULL); + } + + ut_a(shm_info->zip_hash_offset == chunk->mem_size - zip_hash_mem_size); + ut_a(shm_info->zip_hash_n == zip_hash_n); + + /* check checksum */ + checksum = ut_fold_binary(chunk->mem + sizeof(buf_shm_info_t), + chunk->mem_size - sizeof(buf_shm_info_t)); + if (shm_info->checksum != checksum) { + fprintf(stderr, + "InnoDB: Error: checksum of the shared memory is not match. " + "(stored=%lu calculated=%lu)\n", + shm_info->checksum, checksum); + return(NULL); + } + + /* flag to use the segment. */ + shm_info->clean = FALSE; /* changed to TRUE when free the segment. */ + } + + /* init zip_hash contents */ + if (is_new) { + hash_create_init(zip_hash_tmp, zip_hash_n); + } else { + /* adjust offset is done later */ + hash_create_reuse(zip_hash_tmp); + } + } else { chunk->mem = os_mem_alloc_large(&chunk->mem_size); if (UNIV_UNLIKELY(chunk->mem == NULL)) { return(NULL); } + } /* Allocate the block descriptors from the start of the memory block. */ + if (srv_buffer_pool_shm_key) { + chunk->blocks = chunk->mem + sizeof(buf_shm_info_t); + } else { chunk->blocks = chunk->mem; + } /* Align a pointer to the first frame. Note that when os_large_page_size is smaller than UNIV_PAGE_SIZE, @@ -803,8 +1003,13 @@ buf_chunk_init( it is bigger, we may allocate more blocks than requested. */ frame = ut_align(chunk->mem, UNIV_PAGE_SIZE); + if (srv_buffer_pool_shm_key) { + /* reserve zip_hash space and always -1 for reproductibity */ + chunk->size = (chunk->mem_size - zip_hash_mem_size) / UNIV_PAGE_SIZE - 1; + } else { chunk->size = chunk->mem_size / UNIV_PAGE_SIZE - (frame != chunk->mem); + } /* Subtract the space needed for block descriptors. */ { @@ -818,6 +1023,98 @@ buf_chunk_init( chunk->size = size; } + if (shm_info && !(shm_info->is_new)) { + /* convert the shared memory segment for reuse */ + ptrdiff_t phys_offset; + ptrdiff_t logi_offset; + ptrdiff_t blocks_offset; + void* previous_frame_address; + + if (chunk->size < shm_info->chunk_backup.size) { + fprintf(stderr, + "InnoDB: Error: The buffer pool became smaller because of allocated address.\n" + "InnoDB: Retrying may avoid this situation.\n"); + shm_info->clean = TRUE; /* release the flag for retrying */ + return(NULL); + } + + chunk->size = shm_info->chunk_backup.size; + phys_offset = (void*)frame - (void*)((void*)chunk->mem + shm_info->frame_offset); + logi_offset = (void*)frame - (void*)chunk->blocks[0].frame; + previous_frame_address = chunk->blocks[0].frame; + blocks_offset = (void*)chunk->blocks - (void*)shm_info->chunk_backup.blocks; + + if (phys_offset || logi_offset || blocks_offset) { + fprintf(stderr, + "InnoDB: Buffer pool in the shared memory segment should be converted.\n" + "InnoDB: Previous frames in address : %p\n" + "InnoDB: Previous frames were located : %p\n" + "InnoDB: Current frames should be located: %p\n" + "InnoDB: Pysical offset : %ld (%#lx)\n" + "InnoDB: Logical offset (frames) : %ld (%#lx)\n" + "InnoDB: Logical offset (blocks) : %ld (%#lx)\n", + (void*)((void*)chunk->mem + shm_info->frame_offset), + (void*)chunk->blocks[0].frame, (void*)frame, + phys_offset, phys_offset, logi_offset, logi_offset, + blocks_offset, blocks_offset); + } else { + fprintf(stderr, + "InnoDB: Buffer pool in the shared memory segment can be used as it is.\n"); + } + + if (phys_offset) { + fprintf(stderr, + "InnoDB: Aligning physical offset..."); + + memmove((void*)frame, (void*)((void*)chunk->mem + shm_info->frame_offset), + chunk->size * UNIV_PAGE_SIZE); + + fprintf(stderr, + " Done.\n"); + } + + if (logi_offset || blocks_offset) { + fprintf(stderr, + "InnoDB: Aligning logical offset..."); + + /* buf_block_t */ + block = chunk->blocks; + + for (i = chunk->size; i--; ) { + buf_block_reuse(block, logi_offset); + block++; + } + + /* buf_pool_t buf_pool_backup */ + UT_LIST_OFFSET(flush_list, buf_page_t, shm_info->buf_pool_backup.flush_list, + previous_frame_address, logi_offset, blocks_offset); + UT_LIST_OFFSET(free, buf_page_t, shm_info->buf_pool_backup.free, + previous_frame_address, logi_offset, blocks_offset); + UT_LIST_OFFSET(LRU, buf_page_t, shm_info->buf_pool_backup.LRU, + previous_frame_address, logi_offset, blocks_offset); + if (shm_info->buf_pool_backup.LRU_old) + shm_info->buf_pool_backup.LRU_old = + ((void*)(shm_info->buf_pool_backup.LRU_old) + + (((void*)shm_info->buf_pool_backup.LRU_old > previous_frame_address) + ? logi_offset : blocks_offset)); + + UT_LIST_OFFSET(unzip_LRU, buf_block_t, shm_info->buf_pool_backup.unzip_LRU, + previous_frame_address, logi_offset, blocks_offset); + + UT_LIST_OFFSET(zip_list, buf_page_t, shm_info->buf_pool_backup.zip_clean, + previous_frame_address, logi_offset, blocks_offset); + for (i = 0; i < BUF_BUDDY_SIZES_MAX; i++) { + UT_LIST_OFFSET(zip_list, buf_page_t, shm_info->buf_pool_backup.zip_free[i], + previous_frame_address, logi_offset, blocks_offset); + } + + HASH_OFFSET(zip_hash_tmp, buf_page_t, hash, + previous_frame_address, logi_offset, blocks_offset); + + fprintf(stderr, + " Done.\n"); + } + } else { /* Init block structs and assign frames for them. Then we assign the frames to the first blocks (we already mapped the memory above). */ @@ -841,6 +1138,11 @@ buf_chunk_init( block++; frame += UNIV_PAGE_SIZE; } + } + + if (shm_info) { + shm_info->frame_offset = (void*)chunk->blocks[0].frame - (void*)chunk->mem; + } return(chunk); } @@ -940,6 +1242,11 @@ buf_chunk_not_freed( ready = buf_flush_ready_for_replace(&block->page); mutex_exit(&block->mutex); + if (block->page.is_corrupt) { + /* corrupt page may remain, it can be skipped */ + break; + } + if (!ready) { return(block); @@ -1017,6 +1324,8 @@ buf_chunk_free( UNIV_MEM_UNDESC(block); } + ut_a(!srv_buffer_pool_shm_key); + os_mem_free_large(chunk->mem, chunk->mem_size); } @@ -1066,7 +1375,10 @@ buf_pool_init(void) srv_buf_pool_curr_size = buf_pool->curr_size * UNIV_PAGE_SIZE; buf_pool->page_hash = hash_create(2 * buf_pool->curr_size); + /* zip_hash is allocated to shm when srv_buffer_pool_shm_key is enabled */ + if (!srv_buffer_pool_shm_key) { buf_pool->zip_hash = hash_create(2 * buf_pool->curr_size); + } buf_pool->last_printout_time = time(NULL); @@ -1081,6 +1393,86 @@ buf_pool_init(void) --------------------------- */ /* All fields are initialized by mem_zalloc(). */ + if (srv_buffer_pool_shm_key) { + buf_shm_info_t* shm_info; + + ut_a(chunk->blocks == chunk->mem + sizeof(buf_shm_info_t)); + shm_info = chunk->mem; + + buf_pool->zip_hash = (hash_table_t*)((void*)chunk->mem + shm_info->zip_hash_offset); + + if(shm_info->is_new) { + shm_info->is_new = FALSE; /* initialization was finished */ + } else { + buf_block_t* block = chunk->blocks; + buf_page_t* b; + + /* shm_info->buf_pool_backup should be converted */ + /* at buf_chunk_init(). So copy simply. */ + buf_pool->flush_list = shm_info->buf_pool_backup.flush_list; + buf_pool->freed_page_clock = shm_info->buf_pool_backup.freed_page_clock; + buf_pool->free = shm_info->buf_pool_backup.free; + buf_pool->LRU = shm_info->buf_pool_backup.LRU; + buf_pool->LRU_old = shm_info->buf_pool_backup.LRU_old; + buf_pool->LRU_old_len = shm_info->buf_pool_backup.LRU_old_len; + buf_pool->unzip_LRU = shm_info->buf_pool_backup.unzip_LRU; + buf_pool->zip_clean = shm_info->buf_pool_backup.zip_clean; + for (i = 0; i < BUF_BUDDY_SIZES_MAX; i++) { + buf_pool->zip_free[i] = shm_info->buf_pool_backup.zip_free[i]; + } + + for (i = 0; i < chunk->size; i++, block++) { + if (buf_block_get_state(block) + == BUF_BLOCK_FILE_PAGE) { + ut_d(block->page.in_page_hash = TRUE); + HASH_INSERT(buf_page_t, hash, buf_pool->page_hash, + buf_page_address_fold( + block->page.space, + block->page.offset), + &block->page); + } + } + + for (b = UT_LIST_GET_FIRST(buf_pool->zip_clean); b; + b = UT_LIST_GET_NEXT(zip_list, b)) { + ut_ad(!b->in_flush_list); + ut_ad(b->in_LRU_list); + + ut_d(b->in_page_hash = TRUE); + HASH_INSERT(buf_page_t, hash, buf_pool->page_hash, + buf_page_address_fold(b->space, b->offset), b); + } + + for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b; + b = UT_LIST_GET_NEXT(flush_list, b)) { + ut_ad(b->in_flush_list); + ut_ad(b->in_LRU_list); + + switch (buf_page_get_state(b)) { + case BUF_BLOCK_ZIP_DIRTY: + ut_d(b->in_page_hash = TRUE); + HASH_INSERT(buf_page_t, hash, buf_pool->page_hash, + buf_page_address_fold(b->space, + b->offset), b); + break; + case BUF_BLOCK_FILE_PAGE: + /* uncompressed page */ + break; + case BUF_BLOCK_ZIP_FREE: + case BUF_BLOCK_ZIP_PAGE: + case BUF_BLOCK_NOT_USED: + case BUF_BLOCK_READY_FOR_USE: + case BUF_BLOCK_MEMORY: + case BUF_BLOCK_REMOVE_HASH: + ut_error; + break; + } + } + + + } + } + mutex_exit(&LRU_list_mutex); rw_lock_x_unlock(&page_hash_latch); buf_pool_mutex_exit(); @@ -1105,6 +1497,30 @@ buf_pool_free(void) buf_chunk_t* chunk; buf_chunk_t* chunks; + if (srv_buffer_pool_shm_key) { + buf_shm_info_t* shm_info; + + ut_a(buf_pool->n_chunks == 1); + + chunk = buf_pool->chunks; + shm_info = chunk->mem; + ut_a(chunk->blocks == chunk->mem + sizeof(buf_shm_info_t)); + + /* validation the shared memory segment doesn't have unrecoverable contents. */ + /* Currently, validation became not needed */ + shm_info->reusable = TRUE; + + memcpy(&(shm_info->buf_pool_backup), buf_pool, sizeof(buf_pool_t)); + memcpy(&(shm_info->chunk_backup), chunk, sizeof(buf_chunk_t)); + + if (srv_fast_shutdown < 2) { + shm_info->checksum = ut_fold_binary(chunk->mem + sizeof(buf_shm_info_t), + chunk->mem_size - sizeof(buf_shm_info_t)); + shm_info->clean = TRUE; + } + + os_shm_free(chunk->mem, chunk->mem_size); + } else { chunks = buf_pool->chunks; chunk = chunks + buf_pool->n_chunks; @@ -1113,10 +1529,13 @@ buf_pool_free(void) would fail at shutdown. */ os_mem_free_large(chunk->mem, chunk->mem_size); } + } mem_free(buf_pool->chunks); hash_table_free(buf_pool->page_hash); + if (!srv_buffer_pool_shm_key) { hash_table_free(buf_pool->zip_hash); + } mem_free(buf_pool); buf_pool = NULL; } @@ -1311,6 +1730,11 @@ try_again: //buf_pool_mutex_enter(); mutex_enter(&LRU_list_mutex); + if (srv_buffer_pool_shm_key) { + /* Cannot support shrink */ + goto func_done; + } + shrink_again: if (buf_pool->n_chunks <= 1) { @@ -1554,6 +1978,11 @@ void buf_pool_resize(void) /*=================*/ { + if (srv_buffer_pool_shm_key) { + /* Cannot support resize */ + return; + } + //buf_pool_mutex_enter(); mutex_enter(&LRU_list_mutex); @@ -2458,7 +2887,7 @@ wait_until_unfixed: block->page.buf_fix_count = 1; buf_block_set_io_fix(block, BUF_IO_READ); - rw_lock_x_lock(&block->lock); + rw_lock_x_lock_func(&block->lock, 0, file, line); UNIV_MEM_INVALID(bpage, sizeof *bpage); @@ -2508,7 +2937,12 @@ wait_until_unfixed: ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); //mutex_enter(&block->mutex); +#if UNIV_WORD_SIZE == 4 + /* On 32-bit systems, there is no padding in buf_page_t. On + other systems, Valgrind could complain about uninitialized pad + bytes. */ UNIV_MEM_ASSERT_RW(&block->page, sizeof block->page); +#endif buf_block_buf_fix_inc(block, file, line); @@ -3522,7 +3956,7 @@ corrupt: if (srv_pass_corrupt_table && !trx_sys_sys_space(bpage->space) && bpage->space < SRV_LOG_SPACE_FIRST_ID) { fprintf(stderr, - "InnoDB: space %lu will be treated as corrupt.\n", + "InnoDB: space %u will be treated as corrupt.\n", bpage->space); fil_space_set_corrupt(bpage->space); if (trx && trx->dict_operation_lock_mode == 0) { diff --git a/buf/buf0flu.c b/buf/buf0flu.c index 17588475bbf..0a03d583549 100644 --- a/buf/buf0flu.c +++ b/buf/buf0flu.c @@ -257,6 +257,17 @@ buf_flush_insert_into_flush_list( ut_d(block->page.in_flush_list = TRUE); UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, &block->page); +#ifdef UNIV_DEBUG_VALGRIND + { + ulint zip_size = buf_block_get_zip_size(block); + + if (UNIV_UNLIKELY(zip_size)) { + UNIV_MEM_ASSERT_RW(block->page.zip.data, zip_size); + } else { + UNIV_MEM_ASSERT_RW(block->frame, UNIV_PAGE_SIZE); + } + } +#endif /* UNIV_DEBUG_VALGRIND */ #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG ut_a(buf_flush_validate_low()); #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ @@ -286,6 +297,18 @@ buf_flush_insert_sorted_into_flush_list( ut_ad(!block->page.in_flush_list); ut_d(block->page.in_flush_list = TRUE); +#ifdef UNIV_DEBUG_VALGRIND + { + ulint zip_size = buf_block_get_zip_size(block); + + if (UNIV_UNLIKELY(zip_size)) { + UNIV_MEM_ASSERT_RW(block->page.zip.data, zip_size); + } else { + UNIV_MEM_ASSERT_RW(block->frame, UNIV_PAGE_SIZE); + } + } +#endif /* UNIV_DEBUG_VALGRIND */ + prev_b = NULL; /* For the most part when this function is called the flush_rbt @@ -830,6 +853,7 @@ try_again: zip_size = buf_page_get_zip_size(bpage); if (UNIV_UNLIKELY(zip_size)) { + UNIV_MEM_ASSERT_RW(bpage->zip.data, zip_size); /* Copy the compressed page and clear the rest. */ memcpy(trx_doublewrite->write_buf + UNIV_PAGE_SIZE * trx_doublewrite->first_free, @@ -839,6 +863,8 @@ try_again: + zip_size, 0, UNIV_PAGE_SIZE - zip_size); } else { ut_a(buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE); + UNIV_MEM_ASSERT_RW(((buf_block_t*) bpage)->frame, + UNIV_PAGE_SIZE); memcpy(trx_doublewrite->write_buf + UNIV_PAGE_SIZE * trx_doublewrite->first_free, @@ -1533,6 +1559,7 @@ retry: } else if (!have_LRU_mutex) { /* confirm it again with LRU_mutex for exactness */ have_LRU_mutex = TRUE; + distance = 0; goto retry; } diff --git a/buf/buf0lru.c b/buf/buf0lru.c index a3d7f3f84bd..cc730cad40d 100644 --- a/buf/buf0lru.c +++ b/buf/buf0lru.c @@ -1455,7 +1455,7 @@ buf_LRU_make_block_old( Try to free a block. If bpage is a descriptor of a compressed-only page, the descriptor object will be freed as well. -NOTE: If this function returns BUF_LRU_FREED, it will not temporarily +NOTE: If this function returns BUF_LRU_FREED, it will temporarily release buf_pool_mutex. Furthermore, the page frame will no longer be accessible via bpage. @@ -1485,7 +1485,12 @@ buf_LRU_free_block( ut_ad(buf_page_in_file(bpage)); //ut_ad(bpage->in_LRU_list); ut_ad(!bpage->in_flush_list == !bpage->oldest_modification); +#if UNIV_WORD_SIZE == 4 + /* On 32-bit systems, there is no padding in buf_page_t. On + other systems, Valgrind could complain about uninitialized pad + bytes. */ UNIV_MEM_ASSERT_RW(bpage, sizeof *bpage); +#endif if (!bpage->in_LRU_list || !block_mutex || !buf_page_can_relocate(bpage)) { @@ -1618,8 +1623,13 @@ not_freed: ut_ad(prev_b->in_LRU_list); ut_ad(buf_page_in_file(prev_b)); +#if UNIV_WORD_SIZE == 4 + /* On 32-bit systems, there is no + padding in buf_page_t. On other + systems, Valgrind could complain about + uninitialized pad bytes. */ UNIV_MEM_ASSERT_RW(prev_b, sizeof *prev_b); - +#endif UT_LIST_INSERT_AFTER(LRU, buf_pool->LRU, prev_b, b); @@ -1834,7 +1844,12 @@ buf_LRU_block_remove_hashed_page( ut_a(buf_page_get_io_fix(bpage) == BUF_IO_NONE); ut_a(bpage->buf_fix_count == 0); +#if UNIV_WORD_SIZE == 4 + /* On 32-bit systems, there is no padding in + buf_page_t. On other systems, Valgrind could complain + about uninitialized pad bytes. */ UNIV_MEM_ASSERT_RW(bpage, sizeof *bpage); +#endif buf_LRU_remove_block(bpage); diff --git a/dict/dict0boot.c b/dict/dict0boot.c index 0a713f0deaa..43cfced65a0 100644 --- a/dict/dict0boot.c +++ b/dict/dict0boot.c @@ -62,32 +62,47 @@ dict_hdr_get( } /**********************************************************************//** -Returns a new table, index, or tree id. -@return the new id */ +Returns a new table, index, or space id. */ UNIV_INTERN -dulint +void dict_hdr_get_new_id( /*================*/ - ulint type) /*!< in: DICT_HDR_ROW_ID, ... */ + dulint* table_id, /*!< out: table id (not assigned if NULL) */ + dulint* index_id, /*!< out: index id (not assigned if NULL) */ + ulint* space_id) /*!< out: space id (not assigned if NULL) */ { dict_hdr_t* dict_hdr; dulint id; mtr_t mtr; - ut_ad((type == DICT_HDR_TABLE_ID) || (type == DICT_HDR_INDEX_ID)); - mtr_start(&mtr); dict_hdr = dict_hdr_get(&mtr); - id = mtr_read_dulint(dict_hdr + type, &mtr); - id = ut_dulint_add(id, 1); + if (table_id) { + id = mtr_read_dulint(dict_hdr + DICT_HDR_TABLE_ID, &mtr); + id = ut_dulint_add(id, 1); + mlog_write_dulint(dict_hdr + DICT_HDR_TABLE_ID, id, &mtr); + *table_id = id; + } - mlog_write_dulint(dict_hdr + type, id, &mtr); + if (index_id) { + id = mtr_read_dulint(dict_hdr + DICT_HDR_INDEX_ID, &mtr); + id = ut_dulint_add(id, 1); + mlog_write_dulint(dict_hdr + DICT_HDR_INDEX_ID, id, &mtr); + *index_id = id; + } + + if (space_id) { + *space_id = mtr_read_ulint(dict_hdr + DICT_HDR_MAX_SPACE_ID, + MLOG_4BYTES, &mtr); + if (fil_assign_new_space_id(space_id)) { + mlog_write_ulint(dict_hdr + DICT_HDR_MAX_SPACE_ID, + *space_id, MLOG_4BYTES, &mtr); + } + } mtr_commit(&mtr); - - return(id); } /**********************************************************************//** @@ -151,9 +166,12 @@ dict_hdr_create( mlog_write_dulint(dict_header + DICT_HDR_INDEX_ID, ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); - /* Obsolete, but we must initialize it to 0 anyway. */ - mlog_write_dulint(dict_header + DICT_HDR_MIX_ID, - ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); + mlog_write_ulint(dict_header + DICT_HDR_MAX_SPACE_ID, + 0, MLOG_4BYTES, mtr); + + /* Obsolete, but we must initialize it anyway. */ + mlog_write_ulint(dict_header + DICT_HDR_MIX_ID_LOW, + DICT_HDR_FIRST_ID, MLOG_4BYTES, mtr); /* Create the B-tree roots for the clustered indexes of the basic system tables */ @@ -245,6 +263,29 @@ dict_boot(void) /* Get the dictionary header */ dict_hdr = dict_hdr_get(&mtr); + if (ut_dulint_cmp(mtr_read_dulint(dict_hdr + DICT_HDR_XTRADB_MARK, &mtr), + DICT_HDR_XTRADB_FLAG) != 0) { + /* not extended yet by XtraDB, need to be extended */ + ulint root_page_no; + + root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE, + DICT_HDR_SPACE, 0, DICT_STATS_ID, + dict_ind_redundant, &mtr); + if (root_page_no == FIL_NULL) { + fprintf(stderr, "InnoDB: Warning: failed to create SYS_STATS btr.\n"); + srv_use_sys_stats_table = FALSE; + } else { + mlog_write_ulint(dict_hdr + DICT_HDR_STATS, root_page_no, + MLOG_4BYTES, &mtr); + mlog_write_dulint(dict_hdr + DICT_HDR_XTRADB_MARK, + DICT_HDR_XTRADB_FLAG, &mtr); + } + mtr_commit(&mtr); + /* restart mtr */ + mtr_start(&mtr); + dict_hdr = dict_hdr_get(&mtr); + } + /* Because we only write new row ids to disk-based data structure (dictionary header) when it is divisible by DICT_HDR_ROW_ID_WRITE_MARGIN, in recovery we will not recover @@ -406,7 +447,7 @@ dict_boot(void) table->id = DICT_FIELDS_ID; dict_table_add_to_cache(table, heap); dict_sys->sys_fields = table; - mem_heap_free(heap); + mem_heap_empty(heap); index = dict_mem_index_create("SYS_FIELDS", "CLUST_IND", DICT_HDR_SPACE, @@ -423,6 +464,41 @@ dict_boot(void) FALSE); ut_a(error == DB_SUCCESS); + /*-------------------------*/ + table = dict_mem_table_create("SYS_STATS", DICT_HDR_SPACE, 3, 0); + table->n_mysql_handles_opened = 1; /* for pin */ + + dict_mem_table_add_col(table, heap, "INDEX_ID", DATA_BINARY, 0, 0); + dict_mem_table_add_col(table, heap, "KEY_COLS", DATA_INT, 0, 4); + dict_mem_table_add_col(table, heap, "DIFF_VALS", DATA_BINARY, 0, 0); + + /* The '+ 2' below comes from the fields DB_TRX_ID, DB_ROLL_PTR */ +#if DICT_SYS_STATS_DIFF_VALS_FIELD != 2 + 2 +#error "DICT_SYS_STATS_DIFF_VALS_FIELD != 2 + 2" +#endif + + table->id = DICT_STATS_ID; + dict_table_add_to_cache(table, heap); + dict_sys->sys_stats = table; + mem_heap_empty(heap); + + index = dict_mem_index_create("SYS_STATS", "CLUST_IND", + DICT_HDR_SPACE, + DICT_UNIQUE | DICT_CLUSTERED, 2); + + dict_mem_index_add_field(index, "INDEX_ID", 0); + dict_mem_index_add_field(index, "KEY_COLS", 0); + + index->id = DICT_STATS_ID; + error = dict_index_add_to_cache(table, index, + mtr_read_ulint(dict_hdr + + DICT_HDR_STATS, + MLOG_4BYTES, &mtr), + FALSE); + ut_a(error == DB_SUCCESS); + + mem_heap_free(heap); + mtr_commit(&mtr); /*-------------------------*/ @@ -436,6 +512,7 @@ dict_boot(void) dict_load_sys_table(dict_sys->sys_columns); dict_load_sys_table(dict_sys->sys_indexes); dict_load_sys_table(dict_sys->sys_fields); + dict_load_sys_table(dict_sys->sys_stats); mutex_exit(&(dict_sys->mutex)); } diff --git a/dict/dict0crea.c b/dict/dict0crea.c index fc9f69fe591..45e86d94f0d 100644 --- a/dict/dict0crea.c +++ b/dict/dict0crea.c @@ -239,16 +239,34 @@ dict_build_table_def_step( const char* path_or_name; ibool is_path; mtr_t mtr; + ulint space = 0; + ibool file_per_table; ut_ad(mutex_own(&(dict_sys->mutex))); table = node->table; - table->id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID); + /* Cache the global variable "srv_file_per_table" to + a local variable before using it. Please note + "srv_file_per_table" is not under dict_sys mutex + protection, and could be changed while executing + this function. So better to cache the current value + to a local variable, and all future reference to + "srv_file_per_table" should use this local variable. */ + file_per_table = srv_file_per_table; + + dict_hdr_get_new_id(&table->id, NULL, NULL); thr_get_trx(thr)->table_id = table->id; - if (srv_file_per_table) { + if (file_per_table) { + /* Get a new space id if srv_file_per_table is set */ + dict_hdr_get_new_id(NULL, NULL, &space); + + if (UNIV_UNLIKELY(space == ULINT_UNDEFINED)) { + return(DB_ERROR); + } + /* We create a new single-table tablespace for the table. We initially let it be 4 pages: - page 0 is the fsp header and an extent descriptor page, @@ -257,8 +275,6 @@ dict_build_table_def_step( - page 3 will contain the root of the clustered index of the table we create here. */ - ulint space = 0; /* reset to zero for the call below */ - if (table->dir_path_of_temp_table) { /* We place tables created with CREATE TEMPORARY TABLE in the tmp dir of mysqld server */ @@ -276,7 +292,7 @@ dict_build_table_def_step( flags = table->flags & ~(~0 << DICT_TF_BITS); error = fil_create_new_single_table_tablespace( - &space, path_or_name, is_path, + space, path_or_name, is_path, flags == DICT_TF_COMPACT ? 0 : flags, FIL_IBD_FILE_INITIAL_SIZE); table->space = (unsigned int) space; @@ -491,6 +507,51 @@ dict_create_sys_fields_tuple( return(entry); } +/*****************************************************************//** +Based on an index object, this function builds the entry to be inserted +in the SYS_STATS system table. +@return the tuple which should be inserted */ +static +dtuple_t* +dict_create_sys_stats_tuple( +/*========================*/ + const dict_index_t* index, + ulint i, + mem_heap_t* heap) +{ + dict_table_t* sys_stats; + dtuple_t* entry; + dfield_t* dfield; + byte* ptr; + + ut_ad(index); + ut_ad(heap); + + sys_stats = dict_sys->sys_stats; + + entry = dtuple_create(heap, 3 + DATA_N_SYS_COLS); + + dict_table_copy_types(entry, sys_stats); + + /* 0: INDEX_ID -----------------------*/ + dfield = dtuple_get_nth_field(entry, 0/*INDEX_ID*/); + ptr = mem_heap_alloc(heap, 8); + mach_write_to_8(ptr, index->id); + dfield_set_data(dfield, ptr, 8); + /* 1: KEY_COLS -----------------------*/ + dfield = dtuple_get_nth_field(entry, 1/*KEY_COLS*/); + ptr = mem_heap_alloc(heap, 4); + mach_write_to_4(ptr, i); + dfield_set_data(dfield, ptr, 4); + /* 4: DIFF_VALS ----------------------*/ + dfield = dtuple_get_nth_field(entry, 2/*DIFF_VALS*/); + ptr = mem_heap_alloc(heap, 8); + mach_write_to_8(ptr, ut_dulint_zero); /* initial value is 0 */ + dfield_set_data(dfield, ptr, 8); + + return(entry); +} + /*****************************************************************//** Creates the tuple with which the index entry is searched for writing the index tree root page number, if such a tree is created. @@ -561,7 +622,7 @@ dict_build_index_def_step( ut_ad((UT_LIST_GET_LEN(table->indexes) > 0) || dict_index_is_clust(index)); - index->id = dict_hdr_get_new_id(DICT_HDR_INDEX_ID); + dict_hdr_get_new_id(NULL, &index->id, NULL); /* Inherit the space id from the table; we store all indexes of a table in the same tablespace */ @@ -600,6 +661,27 @@ dict_build_field_def_step( return(DB_SUCCESS); } +/***************************************************************//** +Builds a row for storing stats to insert. +@return DB_SUCCESS */ +static +ulint +dict_build_stats_def_step( +/*======================*/ + ind_node_t* node) +{ + dict_index_t* index; + dtuple_t* row; + + index = node->index; + + row = dict_create_sys_stats_tuple(index, node->stats_no, node->heap); + + ins_node_set_new_row(node->stats_def, row); + + return(DB_SUCCESS); +} + /***************************************************************//** Creates an index tree for the index if it is not a member of a cluster. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ @@ -924,6 +1006,49 @@ ind_create_graph_create( dict_sys->sys_fields, heap); node->field_def->common.parent = node; + if (srv_use_sys_stats_table) { + node->stats_def = ins_node_create(INS_DIRECT, + dict_sys->sys_stats, heap); + node->stats_def->common.parent = node; + } else { + node->stats_def = NULL; + } + + node->commit_node = commit_node_create(heap); + node->commit_node->common.parent = node; + + return(node); +} + +/*********************************************************************//** +*/ +UNIV_INTERN +ind_node_t* +ind_insert_stats_graph_create( +/*==========================*/ + dict_index_t* index, + mem_heap_t* heap) +{ + ind_node_t* node; + + node = mem_heap_alloc(heap, sizeof(ind_node_t)); + + node->common.type = QUE_NODE_INSERT_STATS; + + node->index = index; + + node->state = INDEX_BUILD_STATS_COLS; + node->page_no = FIL_NULL; + node->heap = mem_heap_create(256); + + node->ind_def = NULL; + node->field_def = NULL; + + node->stats_def = ins_node_create(INS_DIRECT, + dict_sys->sys_stats, heap); + node->stats_def->common.parent = node; + node->stats_no = 0; + node->commit_node = commit_node_create(heap); node->commit_node->common.parent = node; @@ -1074,6 +1199,7 @@ dict_create_index_step( node->state = INDEX_BUILD_FIELD_DEF; node->field_no = 0; + node->stats_no = 0; thr->run_node = node->ind_def; @@ -1119,7 +1245,31 @@ dict_create_index_step( goto function_exit; } - node->state = INDEX_CREATE_INDEX_TREE; + if (srv_use_sys_stats_table) { + node->state = INDEX_BUILD_STATS_COLS; + } else { + node->state = INDEX_CREATE_INDEX_TREE; + } + } + + if (node->state == INDEX_BUILD_STATS_COLS) { + if (node->stats_no <= dict_index_get_n_unique(node->index)) { + + err = dict_build_stats_def_step(node); + + if (err != DB_SUCCESS) { + + goto function_exit; + } + + node->stats_no++; + + thr->run_node = node->stats_def; + + return(thr); + } else { + node->state = INDEX_CREATE_INDEX_TREE; + } } if (node->state == INDEX_CREATE_INDEX_TREE) { @@ -1170,6 +1320,66 @@ function_exit: return(thr); } +/****************************************************************//** +*/ +UNIV_INTERN +que_thr_t* +dict_insert_stats_step( +/*===================*/ + que_thr_t* thr) /*!< in: query thread */ +{ + ind_node_t* node; + ulint err = DB_ERROR; + trx_t* trx; + + ut_ad(thr); + + trx = thr_get_trx(thr); + + node = thr->run_node; + + if (thr->prev_node == que_node_get_parent(node)) { + node->state = INDEX_BUILD_STATS_COLS; + } + + if (node->state == INDEX_BUILD_STATS_COLS) { + if (node->stats_no <= dict_index_get_n_unique(node->index)) { + + err = dict_build_stats_def_step(node); + + if (err != DB_SUCCESS) { + + goto function_exit; + } + + node->stats_no++; + + thr->run_node = node->stats_def; + + return(thr); + } else { + node->state = INDEX_COMMIT_WORK; + } + } + + if (node->state == INDEX_COMMIT_WORK) { + + /* do not commit transaction here for now */ + } + +function_exit: + trx->error_state = err; + + if (err == DB_SUCCESS) { + } else { + return(NULL); + } + + thr->run_node = que_node_get_parent(node); + + return(thr); +} + /****************************************************************//** Creates the foreign key constraints system tables inside InnoDB at database creation or database start if they are not found or are diff --git a/dict/dict0dict.c b/dict/dict0dict.c index 1d088b2e02b..51ee7f9246f 100644 --- a/dict/dict0dict.c +++ b/dict/dict0dict.c @@ -83,7 +83,7 @@ static char dict_ibfk[] = "_ibfk_"; /** array of mutexes protecting dict_index_t::stat_n_diff_key_vals[] */ #define DICT_INDEX_STAT_MUTEX_SIZE 32 -mutex_t dict_index_stat_mutex[DICT_INDEX_STAT_MUTEX_SIZE]; +static mutex_t dict_index_stat_mutex[DICT_INDEX_STAT_MUTEX_SIZE]; /*******************************************************************//** Tries to find column names for the index and sets the col field of the @@ -571,13 +571,11 @@ dict_table_get_on_id( if (ut_dulint_cmp(table_id, DICT_FIELDS_ID) <= 0 || trx->dict_operation_lock_mode == RW_X_LATCH) { - /* It is a system table which will always exist in the table - cache: we avoid acquiring the dictionary mutex, because - if we are doing a rollback to handle an error in TABLE - CREATE, for example, we already have the mutex! */ - ut_ad(mutex_own(&(dict_sys->mutex)) - || trx->dict_operation_lock_mode == RW_X_LATCH); + /* Note: An X latch implies that the transaction + already owns the dictionary mutex. */ + + ut_ad(mutex_own(&dict_sys->mutex)); return(dict_table_get_on_id_low(table_id)); } @@ -712,7 +710,7 @@ dict_table_get( /* If table->ibd_file_missing == TRUE, this will print an error message and return without doing anything. */ - dict_update_statistics(table); + dict_update_statistics(table, FALSE); } } @@ -855,7 +853,8 @@ dict_table_add_to_cache( /* Add table to LRU list of tables */ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table); - dict_sys->size += mem_heap_get_size(table->heap); + dict_sys->size += mem_heap_get_size(table->heap) + + strlen(table->name) + 1; } /**********************************************************************//** @@ -909,14 +908,21 @@ dict_table_rename_in_cache( dict_foreign_t* foreign; dict_index_t* index; ulint fold; - ulint old_size; - const char* old_name; + char old_name[MAX_TABLE_NAME_LEN + 1]; ut_ad(table); ut_ad(mutex_own(&(dict_sys->mutex))); - old_size = mem_heap_get_size(table->heap); - old_name = table->name; + /* store the old/current name to an automatic variable */ + if (strlen(table->name) + 1 <= sizeof(old_name)) { + memcpy(old_name, table->name, strlen(table->name) + 1); + } else { + ut_print_timestamp(stderr); + fprintf(stderr, "InnoDB: too long table name: '%s', " + "max length is %d\n", table->name, + MAX_TABLE_NAME_LEN); + ut_error; + } fold = ut_fold_string(new_name); @@ -962,12 +968,22 @@ dict_table_rename_in_cache( /* Remove table from the hash tables of tables */ HASH_DELETE(dict_table_t, name_hash, dict_sys->table_hash, ut_fold_string(old_name), table); - table->name = mem_heap_strdup(table->heap, new_name); + + if (strlen(new_name) > strlen(table->name)) { + /* We allocate MAX_TABLE_NAME_LEN+1 bytes here to avoid + memory fragmentation, we assume a repeated calls of + ut_realloc() with the same size do not cause fragmentation */ + ut_a(strlen(new_name) <= MAX_TABLE_NAME_LEN); + table->name = ut_realloc(table->name, MAX_TABLE_NAME_LEN + 1); + } + memcpy(table->name, new_name, strlen(new_name) + 1); /* Add table to hash table of tables */ HASH_INSERT(dict_table_t, name_hash, dict_sys->table_hash, fold, table); - dict_sys->size += (mem_heap_get_size(table->heap) - old_size); + + dict_sys->size += strlen(new_name) - strlen(old_name); + ut_a(dict_sys->size > 0); /* Update the table_name field in indexes */ index = dict_table_get_first_index(table); @@ -1192,7 +1208,7 @@ dict_table_remove_from_cache( /* Remove table from LRU list of tables */ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table); - size = mem_heap_get_size(table->heap); + size = mem_heap_get_size(table->heap) + strlen(table->name) + 1; ut_ad(dict_sys->size >= size); @@ -3076,25 +3092,28 @@ static char* dict_strip_comments( /*================*/ - const char* sql_string) /*!< in: SQL string */ + const char* sql_string, /*!< in: SQL string */ + size_t sql_length) /*!< in: length of sql_string */ { char* str; const char* sptr; + const char* eptr = sql_string + sql_length; char* ptr; /* unclosed quote character (0 if none) */ char quote = 0; - str = mem_alloc(strlen(sql_string) + 1); + str = mem_alloc(sql_length + 1); sptr = sql_string; ptr = str; for (;;) { scan_more: - if (*sptr == '\0') { + if (sptr >= eptr || *sptr == '\0') { +end_of_string: *ptr = '\0'; - ut_a(ptr <= str + strlen(sql_string)); + ut_a(ptr <= str + sql_length); return(str); } @@ -3113,30 +3132,35 @@ scan_more: || (sptr[0] == '-' && sptr[1] == '-' && sptr[2] == ' ')) { for (;;) { + if (++sptr >= eptr) { + goto end_of_string; + } + /* In Unix a newline is 0x0A while in Windows it is 0x0D followed by 0x0A */ - if (*sptr == (char)0x0A - || *sptr == (char)0x0D - || *sptr == '\0') { - + switch (*sptr) { + case (char) 0X0A: + case (char) 0x0D: + case '\0': goto scan_more; } - - sptr++; } } else if (!quote && *sptr == '/' && *(sptr + 1) == '*') { + sptr += 2; for (;;) { - if (*sptr == '*' && *(sptr + 1) == '/') { - - sptr += 2; - - goto scan_more; + if (sptr >= eptr) { + goto end_of_string; } - if (*sptr == '\0') { - + switch (*sptr) { + case '\0': goto scan_more; + case '*': + if (sptr[1] == '/') { + sptr += 2; + goto scan_more; + } } sptr++; @@ -3817,6 +3841,7 @@ dict_create_foreign_constraints( name before it: test.table2; the default database id the database of parameter name */ + size_t sql_length, /*!< in: length of sql_string */ const char* name, /*!< in: table full name in the normalized form database_name/table_name */ @@ -3831,7 +3856,7 @@ dict_create_foreign_constraints( ut_a(trx); ut_a(trx->mysql_thd); - str = dict_strip_comments(sql_string); + str = dict_strip_comments(sql_string, sql_length); heap = mem_heap_create(10000); err = dict_create_foreign_constraints_low( @@ -3864,6 +3889,7 @@ dict_foreign_parse_drop_constraints( dict_foreign_t* foreign; ibool success; char* str; + size_t len; const char* ptr; const char* id; FILE* ef = dict_foreign_err_file; @@ -3878,7 +3904,10 @@ dict_foreign_parse_drop_constraints( *constraints_to_drop = mem_heap_alloc(heap, 1000 * sizeof(char*)); - str = dict_strip_comments(*(trx->mysql_query_str)); + ptr = innobase_get_stmt(trx->mysql_thd, &len); + + str = dict_strip_comments(ptr, len); + ptr = str; ut_ad(mutex_own(&(dict_sys->mutex))); @@ -4218,6 +4247,259 @@ dict_index_calc_min_rec_len( return(sum); } +/*********************************************************************//** +functions to use SYS_STATS system table. */ +static +ibool +dict_reload_statistics( +/*===================*/ + dict_table_t* table, + ulint* sum_of_index_sizes) +{ + dict_index_t* index; + ulint size; + mem_heap_t* heap; + + index = dict_table_get_first_index(table); + + if (index == NULL) { + /* Table definition is corrupt */ + + return(FALSE); + } + + heap = mem_heap_create(1000); + + while (index) { + if (table->is_corrupt) { + ut_a(srv_pass_corrupt_table); + mem_heap_free(heap); + return(FALSE); + } + + size = btr_get_size(index, BTR_TOTAL_SIZE); + + index->stat_index_size = size; + + *sum_of_index_sizes += size; + + 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; + +/*===========================================*/ +{ + dict_table_t* sys_stats; + dict_index_t* sys_index; + btr_pcur_t pcur; + dtuple_t* tuple; + dfield_t* dfield; + ulint key_cols; + ulint n_cols; + const rec_t* rec; + const byte* field; + ulint len; + ib_int64_t* stat_n_diff_key_vals_tmp; + byte* buf; + ulint i; + mtr_t mtr; + + n_cols = dict_index_get_n_unique(index); + stat_n_diff_key_vals_tmp = mem_heap_zalloc(heap, (n_cols + 1) * sizeof(ib_int64_t)); + + sys_stats = dict_sys->sys_stats; + sys_index = UT_LIST_GET_FIRST(sys_stats->indexes); + ut_a(!dict_table_is_comp(sys_stats)); + + tuple = dtuple_create(heap, 1); + dfield = dtuple_get_nth_field(tuple, 0); + + buf = mem_heap_alloc(heap, 8); + mach_write_to_8(buf, index->id); + + dfield_set_data(dfield, buf, 8); + dict_index_copy_types(tuple, sys_index, 1); + + mtr_start(&mtr); + + btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE, + BTR_SEARCH_LEAF, &pcur, &mtr); + for (i = 0; i <= n_cols; i++) { + rec = btr_pcur_get_rec(&pcur); + + if (!btr_pcur_is_on_user_rec(&pcur) + || ut_dulint_cmp(mach_read_from_8(rec_get_nth_field_old(rec, 0, &len)), + index->id)) { + /* not found: even 1 if not found should not be alowed */ + fprintf(stderr, "InnoDB: Warning: stats for %s/%s (%lu/%lu)" + " not fonund in SYS_STATS\n", + index->table_name, index->name, i, n_cols); + btr_pcur_close(&pcur); + mtr_commit(&mtr); + mem_heap_free(heap); + return(FALSE); + } + + if (rec_get_deleted_flag(rec, 0)) { + goto next_rec; + } + + field = rec_get_nth_field_old(rec, 1, &len); + ut_a(len == 4); + + key_cols = mach_read_from_4(field); + + ut_a(i == key_cols); + + field = rec_get_nth_field_old(rec, DICT_SYS_STATS_DIFF_VALS_FIELD, &len); + ut_a(len == 8); + + stat_n_diff_key_vals_tmp[i] = ut_conv_dulint_to_longlong(mach_read_from_8(field)); +next_rec: + btr_pcur_move_to_next_user_rec(&pcur, &mtr); + } + + btr_pcur_close(&pcur); + mtr_commit(&mtr); + + dict_index_stat_mutex_enter(index); + for (i = 0; i <= n_cols; i++) { + index->stat_n_diff_key_vals[i] = stat_n_diff_key_vals_tmp[i]; + } + dict_index_stat_mutex_exit(index); +} +/*===========================================*/ + + index = dict_table_get_next_index(index); + } + + mem_heap_free(heap); + return(TRUE); +} + +static +void +dict_store_statistics( +/*==================*/ + dict_table_t* table) +{ + dict_index_t* index; + mem_heap_t* heap; + + index = dict_table_get_first_index(table); + + ut_a(index); + + heap = mem_heap_create(1000); + + while (index) { + if (table->is_corrupt) { + ut_a(srv_pass_corrupt_table); + mem_heap_free(heap); + return; + } + +/*===========================================*/ +{ + dict_table_t* sys_stats; + dict_index_t* sys_index; + btr_pcur_t pcur; + dtuple_t* tuple; + dfield_t* dfield; + ulint key_cols; + ulint n_cols; + ulint rests; + const rec_t* rec; + const byte* field; + ulint len; + ib_int64_t* stat_n_diff_key_vals_tmp; + byte* buf; + ulint i; + mtr_t mtr; + + n_cols = dict_index_get_n_unique(index); + stat_n_diff_key_vals_tmp = mem_heap_zalloc(heap, (n_cols + 1) * sizeof(ib_int64_t)); + + dict_index_stat_mutex_enter(index); + for (i = 0; i <= n_cols; i++) { + stat_n_diff_key_vals_tmp[i] = index->stat_n_diff_key_vals[i]; + } + dict_index_stat_mutex_exit(index); + + sys_stats = dict_sys->sys_stats; + sys_index = UT_LIST_GET_FIRST(sys_stats->indexes); + ut_a(!dict_table_is_comp(sys_stats)); + + tuple = dtuple_create(heap, 1); + dfield = dtuple_get_nth_field(tuple, 0); + + buf = mem_heap_alloc(heap, 8); + mach_write_to_8(buf, index->id); + + dfield_set_data(dfield, buf, 8); + dict_index_copy_types(tuple, sys_index, 1); + + mtr_start(&mtr); + + btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE, + BTR_MODIFY_LEAF, &pcur, &mtr); + rests = n_cols + 1; + for (i = 0; i <= n_cols; i++) { + rec = btr_pcur_get_rec(&pcur); + + if (!btr_pcur_is_on_user_rec(&pcur) + || ut_dulint_cmp(mach_read_from_8(rec_get_nth_field_old(rec, 0, &len)), + index->id)) { + /* not found */ + btr_pcur_close(&pcur); + mtr_commit(&mtr); + break; + } + + if (rec_get_deleted_flag(rec, 0)) { + goto next_rec; + } + + field = rec_get_nth_field_old(rec, 1, &len); + ut_a(len == 4); + + key_cols = mach_read_from_4(field); + + field = rec_get_nth_field_old(rec, DICT_SYS_STATS_DIFF_VALS_FIELD, &len); + ut_a(len == 8); + + mlog_write_dulint((byte*)field, + ut_dulint_create((ulint) (stat_n_diff_key_vals_tmp[key_cols] >> 32), + (ulint) stat_n_diff_key_vals_tmp[key_cols] & 0xFFFFFFFF), + &mtr); + + rests--; + +next_rec: + btr_pcur_move_to_next_user_rec(&pcur, &mtr); + } + btr_pcur_close(&pcur); + mtr_commit(&mtr); + + if (rests) { + fprintf(stderr, "InnoDB: Warning: failed to store %lu stats entries" + " of %s/%s to SYS_STATS system table.\n", + rests, index->table_name, index->name); + } +} +/*===========================================*/ + + index = dict_table_get_next_index(index); + } + + mem_heap_free(heap); +} + /*********************************************************************//** Calculates new estimates for table and index statistics. The statistics are used in query optimization. */ @@ -4226,9 +4508,10 @@ void dict_update_statistics_low( /*=======================*/ dict_table_t* table, /*!< in/out: table */ - ibool has_dict_mutex __attribute__((unused))) + ibool has_dict_mutex __attribute__((unused)), /*!< in: TRUE if the caller has the dictionary mutex */ + ibool sync) /*!< in: TRUE if must update SYS_STATS */ { dict_index_t* index; ulint size; @@ -4254,6 +4537,23 @@ dict_update_statistics_low( return; } + if (srv_use_sys_stats_table && !sync) { + /* reload statistics from SYS_STATS table */ + if (dict_reload_statistics(table, &sum_of_index_sizes)) { + /* success */ +#ifdef UNIV_DEBUG + fprintf(stderr, "InnoDB: DEBUG: reload_statistics is scceeded for %s.\n", + table->name); +#endif + goto end; + } + } +#ifdef UNIV_DEBUG + fprintf(stderr, "InnoDB: DEBUG: update_statistics for %s.\n", + table->name); +#endif + sum_of_index_sizes = 0; + /* Find out the sizes of the indexes and how many different values for the key they approximately have */ @@ -4291,6 +4591,11 @@ dict_update_statistics_low( index = dict_table_get_next_index(index); } + if (srv_use_sys_stats_table) { + /* store statistics to SYS_STATS table */ + dict_store_statistics(table); + } +end: index = dict_table_get_first_index(table); dict_index_stat_mutex_enter(index); @@ -4317,9 +4622,10 @@ UNIV_INTERN void dict_update_statistics( /*===================*/ - dict_table_t* table) /*!< in/out: table */ + dict_table_t* table, /*!< in/out: table */ + ibool sync) { - dict_update_statistics_low(table, FALSE); + dict_update_statistics_low(table, FALSE, sync); } /**********************************************************************//** @@ -4400,7 +4706,7 @@ dict_table_print_low( ut_ad(mutex_own(&(dict_sys->mutex))); if (srv_stats_auto_update) - dict_update_statistics_low(table, TRUE); + dict_update_statistics_low(table, TRUE, FALSE); fprintf(stderr, "--------------------------------------\n" diff --git a/dict/dict0load.c b/dict/dict0load.c index ba0374595ce..90c52bfba87 100644 --- a/dict/dict0load.c +++ b/dict/dict0load.c @@ -222,7 +222,7 @@ loop: is no index */ if (srv_stats_auto_update && dict_table_get_first_index(table)) { - dict_update_statistics_low(table, TRUE); + dict_update_statistics_low(table, TRUE, FALSE); } dict_table_print_low(table); @@ -316,7 +316,7 @@ dict_check_tablespaces_and_store_max_id( dict_index_t* sys_index; btr_pcur_t pcur; const rec_t* rec; - ulint max_space_id = 0; + ulint max_space_id; mtr_t mtr; mutex_enter(&(dict_sys->mutex)); @@ -327,6 +327,11 @@ dict_check_tablespaces_and_store_max_id( sys_index = UT_LIST_GET_FIRST(sys_tables->indexes); ut_a(!dict_table_is_comp(sys_tables)); + max_space_id = mtr_read_ulint(dict_hdr_get(&mtr) + + DICT_HDR_MAX_SPACE_ID, + MLOG_4BYTES, &mtr); + fil_set_max_space_id_if_bigger(max_space_id); + btr_pcur_open_at_index_side(TRUE, sys_index, BTR_SEARCH_LEAF, &pcur, TRUE, &mtr); loop: @@ -973,6 +978,7 @@ err_exit: /* Try to open the tablespace */ if (!fil_open_single_table_tablespace( TRUE, space, + flags == DICT_TF_COMPACT ? 0 : flags & ~(~0 << DICT_TF_BITS), name)) { /* We failed to find a sensible tablespace file */ diff --git a/dict/dict0mem.c b/dict/dict0mem.c index 388d46568ac..f2d219bfd4f 100644 --- a/dict/dict0mem.c +++ b/dict/dict0mem.c @@ -68,7 +68,8 @@ dict_mem_table_create( table->heap = heap; table->flags = (unsigned int) flags; - table->name = mem_heap_strdup(heap, name); + table->name = ut_malloc(strlen(name) + 1); + memcpy(table->name, name, strlen(name) + 1); table->space = (unsigned int) space; table->n_cols = (unsigned int) (n_cols + DATA_N_SYS_COLS); @@ -108,6 +109,7 @@ dict_mem_table_free( #ifndef UNIV_HOTBACKUP mutex_free(&(table->autoinc_mutex)); #endif /* UNIV_HOTBACKUP */ + ut_free(table->name); mem_heap_free(table->heap); } diff --git a/fil/fil0fil.c b/fil/fil0fil.c index bca6db473ed..17b821bb7ee 100644 --- a/fil/fil0fil.c +++ b/fil/fil0fil.c @@ -44,6 +44,8 @@ Created 10/25/1995 Heikki Tuuri #include "trx0sys.h" #include "pars0pars.h" #include "row0mysql.h" +#include "row0row.h" +#include "que0que.h" #ifndef UNIV_HOTBACKUP # include "buf0lru.h" # include "ibuf0ibuf.h" @@ -284,6 +286,10 @@ struct fil_system_struct { request */ UT_LIST_BASE_NODE_T(fil_space_t) space_list; /*!< list of all file spaces */ + ibool space_id_reuse_warned; + /* !< TRUE if fil_space_create() + has issued a warning about + potential space_id reuse */ }; /** The tablespace memory cache. This variable is NULL before the module is @@ -1198,7 +1204,19 @@ try_again: space->tablespace_version = fil_system->tablespace_version; space->mark = FALSE; - if (purpose == FIL_TABLESPACE && id > fil_system->max_assigned_id) { + if (UNIV_LIKELY(purpose == FIL_TABLESPACE && !recv_recovery_on) + && UNIV_UNLIKELY(id > fil_system->max_assigned_id)) { + if (!fil_system->space_id_reuse_warned) { + fil_system->space_id_reuse_warned = TRUE; + + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Warning: allocated tablespace %lu," + " old maximum was %lu\n", + (ulong) id, + (ulong) fil_system->max_assigned_id); + } + fil_system->max_assigned_id = id; } @@ -1238,19 +1256,25 @@ try_again: Assigns a new space id for a new single-table tablespace. This works simply by incrementing the global counter. If 4 billion id's is not enough, we may need to recycle id's. -@return new tablespace id; ULINT_UNDEFINED if could not assign an id */ -static -ulint -fil_assign_new_space_id(void) -/*=========================*/ +@return TRUE if assigned, FALSE if not */ +UNIV_INTERN +ibool +fil_assign_new_space_id( +/*====================*/ + ulint* space_id) /*!< in/out: space id */ { - ulint id; + ulint id; + ibool success; mutex_enter(&fil_system->mutex); - fil_system->max_assigned_id++; + id = *space_id; - id = fil_system->max_assigned_id; + if (id < fil_system->max_assigned_id) { + id = fil_system->max_assigned_id; + } + + id++; if (id > (SRV_LOG_SPACE_FIRST_ID / 2) && (id % 1000000UL == 0)) { ut_print_timestamp(stderr); @@ -1266,7 +1290,11 @@ fil_assign_new_space_id(void) (ulong) SRV_LOG_SPACE_FIRST_ID); } - if (id >= SRV_LOG_SPACE_FIRST_ID) { + success = (id < SRV_LOG_SPACE_FIRST_ID); + + if (success) { + *space_id = fil_system->max_assigned_id = id; + } else { ut_print_timestamp(stderr); fprintf(stderr, "InnoDB: You have run out of single-table" @@ -1276,14 +1304,12 @@ fil_assign_new_space_id(void) " have to dump all your tables and\n" "InnoDB: recreate the whole InnoDB installation.\n", (ulong) id); - fil_system->max_assigned_id--; - - id = ULINT_UNDEFINED; + *space_id = ULINT_UNDEFINED; } mutex_exit(&fil_system->mutex); - return(id); + return(success); } /*******************************************************************//** @@ -1519,7 +1545,7 @@ fil_init( ut_a(hash_size > 0); ut_a(max_n_open > 0); - fil_system = mem_alloc(sizeof(fil_system_t)); + fil_system = mem_zalloc(sizeof(fil_system_t)); mutex_create(&fil_system->mutex, SYNC_ANY_LATCH); @@ -1528,16 +1554,9 @@ fil_init( UT_LIST_INIT(fil_system->LRU); - fil_system->n_open = 0; fil_system->max_n_open = max_n_open; - fil_system->modification_counter = 0; fil_system->max_assigned_id = TRX_SYS_SPACE_MAX; - - fil_system->tablespace_version = 0; - - UT_LIST_INIT(fil_system->unflushed_spaces); - UT_LIST_INIT(fil_system->space_list); } /*******************************************************************//** @@ -2122,7 +2141,7 @@ fil_op_log_parse_or_replay( fil_create_directory_for_tablename(name); if (fil_create_new_single_table_tablespace( - &space_id, name, FALSE, flags, + space_id, name, FALSE, flags, FIL_IBD_FILE_INITIAL_SIZE) != DB_SUCCESS) { ut_error; } @@ -2569,9 +2588,7 @@ UNIV_INTERN ulint fil_create_new_single_table_tablespace( /*===================================*/ - ulint* space_id, /*!< in/out: space id; if this is != 0, - then this is an input parameter, - otherwise output */ + ulint space_id, /*!< in: space id */ const char* tablename, /*!< in: the table name in the usual databasename/tablename format of InnoDB, or a dir path to a temp @@ -2591,6 +2608,8 @@ fil_create_new_single_table_tablespace( ibool success; char* path; + ut_a(space_id > 0); + ut_a(space_id < SRV_LOG_SPACE_FIRST_ID); ut_a(size >= FIL_IBD_FILE_INITIAL_SIZE); /* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for ROW_FORMAT=COMPACT @@ -2647,38 +2666,21 @@ fil_create_new_single_table_tablespace( return(DB_ERROR); } - buf2 = ut_malloc(3 * UNIV_PAGE_SIZE); - /* Align the memory for file i/o if we might have O_DIRECT set */ - page = ut_align(buf2, UNIV_PAGE_SIZE); - ret = os_file_set_size(path, file, size * UNIV_PAGE_SIZE, 0); if (!ret) { - ut_free(buf2); - os_file_close(file); - os_file_delete(path); - - mem_free(path); - return(DB_OUT_OF_FILE_SPACE); - } - - if (*space_id == 0) { - *space_id = fil_assign_new_space_id(); - } - - /* printf("Creating tablespace %s id %lu\n", path, *space_id); */ - - if (*space_id == ULINT_UNDEFINED) { - ut_free(buf2); + err = DB_OUT_OF_FILE_SPACE; error_exit: os_file_close(file); error_exit2: os_file_delete(path); mem_free(path); - return(DB_ERROR); + return(err); } + /* printf("Creating tablespace %s id %lu\n", path, space_id); */ + /* We have to write the space id to the file immediately and flush the file to disk. This is because in crash recovery we must be aware what tablespaces exist and what are their space id's, so that we can apply @@ -2688,10 +2690,14 @@ error_exit2: with zeros from the call of os_file_set_size(), until a buffer pool flush would write to it. */ + buf2 = ut_malloc(3 * UNIV_PAGE_SIZE); + /* Align the memory for file i/o if we might have O_DIRECT set */ + page = ut_align(buf2, UNIV_PAGE_SIZE); + memset(page, '\0', UNIV_PAGE_SIZE); - fsp_header_init_fields(page, *space_id, flags); - mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, *space_id); + fsp_header_init_fields(page, space_id, flags); + mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, space_id); if (!(flags & DICT_TF_ZSSIZE_MASK)) { buf_flush_init_for_writing(page, NULL, 0); @@ -2722,6 +2728,7 @@ error_exit2: " to tablespace ", stderr); ut_print_filename(stderr, path); putc('\n', stderr); + err = DB_ERROR; goto error_exit; } @@ -2731,22 +2738,20 @@ error_exit2: fputs("InnoDB: Error: file flush of tablespace ", stderr); ut_print_filename(stderr, path); fputs(" failed\n", stderr); + err = DB_ERROR; goto error_exit; } os_file_close(file); - if (*space_id == ULINT_UNDEFINED) { - goto error_exit2; - } - - success = fil_space_create(path, *space_id, flags, FIL_TABLESPACE); + success = fil_space_create(path, space_id, flags, FIL_TABLESPACE); if (!success) { + err = DB_ERROR; goto error_exit2; } - fil_node_create(path, size, *space_id, FALSE); + fil_node_create(path, size, space_id, FALSE); #ifndef UNIV_HOTBACKUP { @@ -2757,7 +2762,7 @@ error_exit2: fil_op_write_log(flags ? MLOG_FILE_CREATE2 : MLOG_FILE_CREATE, - *space_id, + space_id, is_temp ? MLOG_FILE_FLAG_TEMP : 0, flags, tablename, NULL, &mtr); @@ -3122,7 +3127,7 @@ fil_open_single_table_tablespace( for (i = 0; i < n_index; i++) { new_id[i] = dict_table_get_index_on_name(table, - (page + (i + 1) * 512 + 12))->id; + (char*)(page + (i + 1) * 512 + 12))->id; old_id[i] = mach_read_from_8(page + (i + 1) * 512); root_page[i] = mach_read_from_4(page + (i + 1) * 512 + 8); } @@ -3146,7 +3151,7 @@ skip_info: /* over write space id of all pages */ rec_offs_init(offsets_); - fprintf(stderr, "InnoDB: Progress in %:"); + fprintf(stderr, "InnoDB: Progress in %%:"); for (offset = 0; offset < size_bytes; offset += UNIV_PAGE_SIZE) { ulint checksum_field; @@ -3888,39 +3893,6 @@ next_datadir_item: return(err); } -/********************************************************************//** -If we need crash recovery, and we have called -fil_load_single_table_tablespaces() and dict_load_single_table_tablespaces(), -we can call this function to print an error message of orphaned .ibd files -for which there is not a data dictionary entry with a matching table name -and space id. */ -UNIV_INTERN -void -fil_print_orphaned_tablespaces(void) -/*================================*/ -{ - fil_space_t* space; - - mutex_enter(&fil_system->mutex); - - space = UT_LIST_GET_FIRST(fil_system->space_list); - - while (space) { - if (space->purpose == FIL_TABLESPACE && !trx_sys_sys_space(space->id) - && !space->mark) { - fputs("InnoDB: Warning: tablespace ", stderr); - ut_print_filename(stderr, space->name); - fprintf(stderr, " of id %lu has no matching table in\n" - "InnoDB: the InnoDB data dictionary.\n", - (ulong) space->id); - } - - space = UT_LIST_GET_NEXT(space_list, space); - } - - mutex_exit(&fil_system->mutex); -} - /*******************************************************************//** Returns TRUE if a single-table tablespace does not exist in the memory cache, or is being deleted there. diff --git a/fsp/fsp0fsp.c b/fsp/fsp0fsp.c index a05a96a28b7..f6ff47aa7d5 100644 --- a/fsp/fsp0fsp.c +++ b/fsp/fsp0fsp.c @@ -658,7 +658,7 @@ xdes_calc_descriptor_page( ulint offset) /*!< in: page offset */ { #ifndef DOXYGEN /* Doxygen gets confused of these */ -//# if UNIV_PAGE_SIZE <= XDES_ARR_OFFSET \ +//# if UNIV_PAGE_SIZE <= XDES_ARR_OFFSET // + (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE //# error //# endif @@ -882,12 +882,10 @@ fsp_init_file_page_low( return; } - UNIV_MEM_INVALID(page, UNIV_PAGE_SIZE); + memset(page, 0, UNIV_PAGE_SIZE); mach_write_to_4(page + FIL_PAGE_OFFSET, buf_block_get_page_no(block)); - memset(page + FIL_PAGE_LSN, 0, 8); mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, buf_block_get_space(block)); - memset(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, 0, 8); } #ifndef UNIV_HOTBACKUP diff --git a/ha/hash0hash.c b/ha/hash0hash.c index 30c304dafcd..bc058cd4729 100644 --- a/ha/hash0hash.c +++ b/ha/hash0hash.c @@ -127,6 +127,70 @@ hash_create( return(table); } +/*************************************************************//** +*/ +UNIV_INTERN +ulint +hash_create_needed( +/*===============*/ + ulint n) +{ + ulint prime; + ulint offset; + + prime = ut_find_prime(n); + + offset = (sizeof(hash_table_t) + 7) / 8; + offset *= 8; + + return(offset + sizeof(hash_cell_t) * prime); +} + +UNIV_INTERN +void +hash_create_init( +/*=============*/ + hash_table_t* table, + ulint n) +{ + ulint prime; + ulint offset; + + prime = ut_find_prime(n); + + offset = (sizeof(hash_table_t) + 7) / 8; + offset *= 8; + + table->array = (hash_cell_t*)(((void*)table) + offset); + table->n_cells = prime; +# if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG + table->adaptive = FALSE; +# endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ + table->n_mutexes = 0; + table->mutexes = NULL; + table->heaps = NULL; + table->heap = NULL; + ut_d(table->magic_n = HASH_TABLE_MAGIC_N); + + /* Initialize the cell array */ + hash_table_clear(table); +} + +UNIV_INTERN +void +hash_create_reuse( +/*==============*/ + hash_table_t* table) +{ + ulint offset; + + offset = (sizeof(hash_table_t) + 7) / 8; + offset *= 8; + + table->array = (hash_cell_t*)(((void*)table) + offset); + ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); +} + /*************************************************************//** Frees a hash table. */ UNIV_INTERN diff --git a/handler/ha_innodb.cc b/handler/ha_innodb.cc index 5c01abd2e0c..80d1e0b0435 100644 --- a/handler/ha_innodb.cc +++ b/handler/ha_innodb.cc @@ -196,6 +196,7 @@ static my_bool innobase_overwrite_relay_log_info = FALSE; static my_bool innobase_rollback_on_timeout = FALSE; static my_bool innobase_create_status_file = FALSE; static my_bool innobase_stats_on_metadata = TRUE; +static my_bool innobase_use_sys_stats_table = FALSE; static char* internal_innobase_data_file_path = NULL; @@ -340,6 +341,12 @@ static MYSQL_THDVAR_ULONG(lock_wait_timeout, PLUGIN_VAR_RQCMDARG, "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.", NULL, NULL, 50, 1, 1024 * 1024 * 1024, 0); +static MYSQL_THDVAR_ULONG(flush_log_at_trx_commit_session, PLUGIN_VAR_RQCMDARG, + "Control innodb_flush_log_at_trx_commit for each sessions. " + "The value 0~2 are same meanings to innodb_flush_log_at_trx_commit. " + "The value 3 regards innodb_flush_log_at_trx_commit (default).", + NULL, NULL, 3, 0, 3, 0); + static handler *innobase_create_handler(handlerton *hton, TABLE_SHARE *table, @@ -720,6 +727,17 @@ thd_lock_wait_timeout( return(THDVAR((THD*) thd, lock_wait_timeout)); } +/******************************************************************//** +*/ +extern "C" UNIV_INTERN +ulong +thd_flush_log_at_trx_commit_session( +/*================================*/ + void* thd) +{ + return(THDVAR((THD*) thd, flush_log_at_trx_commit_session)); +} + /********************************************************************//** Obtain the InnoDB transaction of a MySQL thread. @return reference to transaction pointer */ @@ -1035,6 +1053,29 @@ innobase_get_charset( return(thd_charset((THD*) mysql_thd)); } +/**********************************************************************//** +Determines the current SQL statement. +@return SQL statement string */ +extern "C" UNIV_INTERN +const char* +innobase_get_stmt( +/*==============*/ + void* mysql_thd, /*!< in: MySQL thread handle */ + size_t* length) /*!< out: length of the SQL statement */ +{ +#if MYSQL_VERSION_ID >= 50142 + LEX_STRING* stmt; + + stmt = thd_query_string((THD*) mysql_thd); + *length = stmt->length; + return(stmt->str); +#else + const char* stmt_str = thd_query((THD*) mysql_thd); + *length = strlen(stmt_str); + return(stmt_str); +#endif +} + #if defined (__WIN__) && defined (MYSQL_DYNAMIC_PLUGIN) extern MYSQL_PLUGIN_IMPORT MY_TMPDIR mysql_tmpdir_list; /*******************************************************************//** @@ -1355,7 +1396,6 @@ innobase_trx_allocate( trx = trx_allocate_for_mysql(); trx->mysql_thd = thd; - trx->mysql_query_str = thd_query(thd); innobase_trx_init(thd, trx); @@ -2039,12 +2079,12 @@ innobase_init( srv_page_size_shift = 0; if (innobase_page_size != (1 << 14)) { - int n_shift; + uint n_shift; fprintf(stderr, "InnoDB: Warning: innodb_page_size has been changed from default value 16384. (###EXPERIMENTAL### operation)\n"); for (n_shift = 12; n_shift <= UNIV_PAGE_SIZE_SHIFT_MAX; n_shift++) { - if (innobase_page_size == (1 << n_shift)) { + if (innobase_page_size == ((ulong)1 << n_shift)) { srv_page_size_shift = n_shift; srv_page_size = (1 << srv_page_size_shift); fprintf(stderr, @@ -2235,6 +2275,8 @@ mem_free_and_error: srv_extra_undoslots = (ibool) innobase_extra_undoslots; + srv_use_sys_stats_table = (ibool) innobase_use_sys_stats_table; + /* -------------- Log files ---------------------------*/ /* The default dir for log files is the datadir of MySQL */ @@ -4230,6 +4272,11 @@ get_innobase_type_from_mysql_type( case MYSQL_TYPE_BLOB: case MYSQL_TYPE_LONG_BLOB: return(DATA_BLOB); + case MYSQL_TYPE_NULL: + /* MySQL currently accepts "NULL" datatype, but will + reject such datatype in the next release. We will cope + with it and not trigger assertion failure in 5.1 */ + break; default: ut_error; } @@ -5699,6 +5746,9 @@ ha_innobase::index_read( prebuilt->index_usable = FALSE; DBUG_RETURN(HA_ERR_CRASHED); } + if (UNIV_UNLIKELY(!prebuilt->index_usable)) { + DBUG_RETURN(HA_ERR_TABLE_DEF_CHANGED); + } /* Note that if the index for which the search template is built is not necessarily prebuilt->index, but can also be the clustered index */ @@ -6338,7 +6388,22 @@ create_table_def( field = form->field[i]; col_type = get_innobase_type_from_mysql_type(&unsigned_type, - field); + field); + + if (!col_type) { + push_warning_printf( + (THD*) trx->mysql_thd, + MYSQL_ERROR::WARN_LEVEL_WARN, + ER_CANT_CREATE_TABLE, + "Error creating table '%s' with " + "column '%s'. Please check its " + "column type and try to re-create " + "the table with an appropriate " + "column type.", + table->name, (char*) field->field_name); + goto err_col; + } + if (field->null_ptr) { nulls_allowed = 0; } else { @@ -6396,7 +6461,7 @@ create_table_def( if (dict_col_name_is_reserved(field->field_name)){ my_error(ER_WRONG_COLUMN_NAME, MYF(0), field->field_name); - +err_col: dict_mem_table_free(table); trx_commit_for_mysql(trx); @@ -6796,6 +6861,9 @@ ha_innobase::create( /* Cache the value of innodb_file_format, in case it is modified by another thread while the table is being created. */ const ulint file_format = srv_file_format; + const char* stmt; + size_t stmt_len; + enum row_type row_type; DBUG_ENTER("ha_innobase::create"); @@ -6916,94 +6984,94 @@ ha_innobase::create( } } - if (create_info->used_fields & HA_CREATE_USED_ROW_FORMAT) { - if (flags) { - /* KEY_BLOCK_SIZE was specified. */ - if (form->s->row_type != ROW_TYPE_COMPRESSED) { - /* ROW_FORMAT other than COMPRESSED - ignores KEY_BLOCK_SIZE. It does not - make sense to reject conflicting - KEY_BLOCK_SIZE and ROW_FORMAT, because - such combinations can be obtained - with ALTER TABLE anyway. */ - push_warning_printf( - thd, - MYSQL_ERROR::WARN_LEVEL_WARN, - ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ignoring KEY_BLOCK_SIZE=%lu" - " unless ROW_FORMAT=COMPRESSED.", - create_info->key_block_size); - flags = 0; - } - } else { - /* No KEY_BLOCK_SIZE */ - if (form->s->row_type == ROW_TYPE_COMPRESSED) { - /* ROW_FORMAT=COMPRESSED without - KEY_BLOCK_SIZE implies half the - maximum KEY_BLOCK_SIZE. */ - flags = (DICT_TF_ZSSIZE_MAX - 1) - << DICT_TF_ZSSIZE_SHIFT - | DICT_TF_COMPACT - | DICT_TF_FORMAT_ZIP - << DICT_TF_FORMAT_SHIFT; + row_type = form->s->row_type; + + if (flags) { + /* KEY_BLOCK_SIZE was specified. */ + if (!(create_info->used_fields & HA_CREATE_USED_ROW_FORMAT)) { + /* ROW_FORMAT was not specified; + default to ROW_FORMAT=COMPRESSED */ + row_type = ROW_TYPE_COMPRESSED; + } else if (row_type != ROW_TYPE_COMPRESSED) { + /* ROW_FORMAT other than COMPRESSED + ignores KEY_BLOCK_SIZE. It does not + make sense to reject conflicting + KEY_BLOCK_SIZE and ROW_FORMAT, because + such combinations can be obtained + with ALTER TABLE anyway. */ + push_warning_printf( + thd, + MYSQL_ERROR::WARN_LEVEL_WARN, + ER_ILLEGAL_HA_CREATE_OPTION, + "InnoDB: ignoring KEY_BLOCK_SIZE=%lu" + " unless ROW_FORMAT=COMPRESSED.", + create_info->key_block_size); + flags = 0; + } + } else { + /* No KEY_BLOCK_SIZE */ + if (row_type == ROW_TYPE_COMPRESSED) { + /* ROW_FORMAT=COMPRESSED without + KEY_BLOCK_SIZE implies half the + maximum KEY_BLOCK_SIZE. */ + flags = (DICT_TF_ZSSIZE_MAX - 1) + << DICT_TF_ZSSIZE_SHIFT + | DICT_TF_COMPACT + | DICT_TF_FORMAT_ZIP + << DICT_TF_FORMAT_SHIFT; //#if DICT_TF_ZSSIZE_MAX < 1 //# error "DICT_TF_ZSSIZE_MAX < 1" //#endif - } } + } - switch (form->s->row_type) { - const char* row_format_name; - case ROW_TYPE_REDUNDANT: - break; - case ROW_TYPE_COMPRESSED: - case ROW_TYPE_DYNAMIC: - row_format_name - = form->s->row_type == ROW_TYPE_COMPRESSED - ? "COMPRESSED" - : "DYNAMIC"; + switch (row_type) { + const char* row_format_name; + case ROW_TYPE_REDUNDANT: + break; + case ROW_TYPE_COMPRESSED: + case ROW_TYPE_DYNAMIC: + row_format_name + = row_type == ROW_TYPE_COMPRESSED + ? "COMPRESSED" + : "DYNAMIC"; - if (!srv_file_per_table) { - push_warning_printf( - thd, - MYSQL_ERROR::WARN_LEVEL_WARN, - ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ROW_FORMAT=%s" - " requires innodb_file_per_table.", - row_format_name); - } else if (file_format < DICT_TF_FORMAT_ZIP) { - push_warning_printf( - thd, - MYSQL_ERROR::WARN_LEVEL_WARN, - ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ROW_FORMAT=%s" - " requires innodb_file_format >" - " Antelope.", - row_format_name); - } else { - flags |= DICT_TF_COMPACT - | (DICT_TF_FORMAT_ZIP - << DICT_TF_FORMAT_SHIFT); - break; - } - - /* fall through */ - case ROW_TYPE_NOT_USED: - case ROW_TYPE_FIXED: - default: - push_warning(thd, - MYSQL_ERROR::WARN_LEVEL_WARN, - ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: assuming ROW_FORMAT=COMPACT."); - case ROW_TYPE_DEFAULT: - case ROW_TYPE_COMPACT: - flags = DICT_TF_COMPACT; + if (!srv_file_per_table) { + push_warning_printf( + thd, + MYSQL_ERROR::WARN_LEVEL_WARN, + ER_ILLEGAL_HA_CREATE_OPTION, + "InnoDB: ROW_FORMAT=%s" + " requires innodb_file_per_table.", + row_format_name); + } else if (file_format < DICT_TF_FORMAT_ZIP) { + push_warning_printf( + thd, + MYSQL_ERROR::WARN_LEVEL_WARN, + ER_ILLEGAL_HA_CREATE_OPTION, + "InnoDB: ROW_FORMAT=%s" + " requires innodb_file_format >" + " Antelope.", + row_format_name); + } else { + flags |= DICT_TF_COMPACT + | (DICT_TF_FORMAT_ZIP + << DICT_TF_FORMAT_SHIFT); break; } - } else if (!flags) { - /* No KEY_BLOCK_SIZE or ROW_FORMAT specified: - use ROW_FORMAT=COMPACT by default. */ + + /* fall through */ + case ROW_TYPE_NOT_USED: + case ROW_TYPE_FIXED: + default: + push_warning(thd, + MYSQL_ERROR::WARN_LEVEL_WARN, + ER_ILLEGAL_HA_CREATE_OPTION, + "InnoDB: assuming ROW_FORMAT=COMPACT."); + case ROW_TYPE_DEFAULT: + case ROW_TYPE_COMPACT: flags = DICT_TF_COMPACT; + break; } /* Look for a primary key */ @@ -7012,7 +7080,7 @@ ha_innobase::create( (int) form->s->primary_key : -1); - /* Our function row_get_mysql_key_number_for_index assumes + /* Our function innobase_get_mysql_key_number_for_index assumes the primary key is always number 0, if it exists */ ut_a(primary_key_no == -1 || primary_key_no == 0); @@ -7072,9 +7140,11 @@ ha_innobase::create( } } - if (*trx->mysql_query_str) { - error = row_table_add_foreign_constraints(trx, - *trx->mysql_query_str, norm_name, + stmt = innobase_get_stmt(thd, &stmt_len); + + if (stmt) { + error = row_table_add_foreign_constraints( + trx, stmt, stmt_len, norm_name, create_info->options & HA_LEX_CREATE_TMP_TABLE); error = convert_error_code_to_mysql(error, flags, NULL); @@ -7367,7 +7437,6 @@ innobase_drop_database( /* In the Windows plugin, thd = current_thd is always NULL */ trx = trx_allocate_for_mysql(); trx->mysql_thd = NULL; - trx->mysql_query_str = NULL; #else trx = innobase_trx_allocate(thd); #endif @@ -7567,6 +7636,10 @@ ha_innobase::records_in_range( n_rows = HA_POS_ERROR; goto func_exit; } + if (UNIV_UNLIKELY(!row_merge_is_index_usable(prebuilt->trx, index))) { + n_rows = HA_ERR_TABLE_DEF_CHANGED; + goto func_exit; + } heap = mem_heap_create(2 * (key->key_parts * sizeof(dfield_t) + sizeof(dtuple_t))); @@ -7745,6 +7818,86 @@ ha_innobase::is_corrupt() const return (FALSE); } +/*********************************************************************//** +Calculates the key number used inside MySQL for an Innobase index. We will +first check the "index translation table" for a match of the index to get +the index number. If there does not exist an "index translation table", +or not able to find the index in the translation table, then we will fall back +to the traditional way of looping through dict_index_t list to find a +match. In this case, we have to take into account if we generated a +default clustered index for the table +@return the key number used inside MySQL */ +static +unsigned int +innobase_get_mysql_key_number_for_index( +/*====================================*/ + INNOBASE_SHARE* share, /*!< in: share structure for index + translation table. */ + const TABLE* table, /*!< in: table in MySQL data + dictionary */ + dict_table_t* ib_table,/*!< in: table in Innodb data + dictionary */ + const dict_index_t* index) /*!< in: index */ +{ + const dict_index_t* ind; + unsigned int i; + + ut_ad(index); + ut_ad(ib_table); + ut_ad(table); + ut_ad(share); + + /* If index does not belong to the table of share structure. Search + index->table instead */ + if (index->table != ib_table) { + i = 0; + ind = dict_table_get_first_index(index->table); + + while (index != ind) { + ind = dict_table_get_next_index(ind); + i++; + } + + if (row_table_got_default_clust_index(index->table)) { + ut_a(i > 0); + i--; + } + + return(i); + } + + /* If index translation table exists, we will first check + the index through index translation table for a match. */ + if (share->idx_trans_tbl.index_mapping) { + for (i = 0; i < share->idx_trans_tbl.index_count; i++) { + if (share->idx_trans_tbl.index_mapping[i] == index) { + return(i); + } + } + + /* Print an error message if we cannot find the index + ** in the "index translation table". */ + sql_print_error("Cannot find index %s in InnoDB index " + "translation table.", index->name); + } + + /* If we do not have an "index translation table", or not able + to find the index in the translation table, we'll directly find + matching index in the dict_index_t list */ + for (i = 0; i < table->s->keys; i++) { + ind = dict_table_get_index_on_name( + ib_table, table->key_info[i].name); + + if (index == ind) { + return(i); + } + } + + sql_print_error("Cannot find matching index number for index %s " + "in InnoDB index list.", index->name); + + return(0); +} /*********************************************************************//** Returns statistics information of the table to the MySQL interpreter, in various fields of the handle object. */ @@ -7802,9 +7955,30 @@ ha_innobase::info( /* In sql_show we call with this flag: update then statistics so that they are up-to-date */ + if (srv_use_sys_stats_table + && thd_sql_command(user_thd) == SQLCOM_ANALYZE) { + /* If the indexes on the table don't have enough rows in SYS_STATS system table, */ + /* they need to be created. */ + dict_index_t* index; + + prebuilt->trx->op_info = "confirming rows of SYS_STATS to store statistics"; + + ut_a(prebuilt->trx->conc_state == TRX_NOT_STARTED); + + for (index = dict_table_get_first_index(ib_table); + index != NULL; + index = dict_table_get_next_index(index)) { + row_insert_stats_for_mysql(index, prebuilt->trx); + innobase_commit_low(prebuilt->trx); + } + + ut_a(prebuilt->trx->conc_state == TRX_NOT_STARTED); + } + prebuilt->trx->op_info = "updating table statistics"; - dict_update_statistics(ib_table); + dict_update_statistics(ib_table, + (thd_sql_command(user_thd) == SQLCOM_ANALYZE)?TRUE:FALSE); prebuilt->trx->op_info = "returning various info to MySQL"; } @@ -8016,8 +8190,8 @@ ha_innobase::info( err_index = trx_get_error_info(prebuilt->trx); if (err_index) { - errkey = (unsigned int) - row_get_mysql_key_number_for_index(err_index); + errkey = innobase_get_mysql_key_number_for_index( + share, table, ib_table, err_index); } else { errkey = (unsigned int) prebuilt->trx->error_key_num; } @@ -10766,7 +10940,35 @@ innodb_old_blocks_pct_update( } /*************************************************************//** -Check if it is a valid value of innodb_change_buffering. This function is +Find the corresponding ibuf_use_t value that indexes into +innobase_change_buffering_values[] array for the input +change buffering option name. +@return corresponding IBUF_USE_* value for the input variable +name, or IBUF_USE_COUNT if not able to find a match */ +static +ibuf_use_t +innodb_find_change_buffering_value( +/*===============================*/ + const char* input_name) /*!< in: input change buffering + option name */ +{ + ulint use; + + for (use = 0; use < UT_ARR_SIZE(innobase_change_buffering_values); + use++) { + /* found a match */ + if (!innobase_strcasecmp( + input_name, innobase_change_buffering_values[use])) { + return((ibuf_use_t)use); + } + } + + /* Did not find any match */ + return(IBUF_USE_COUNT); +} + +/*************************************************************//** +Check if it is a valid value of innodb_change_buffering. This function is registered as a callback with MySQL. @return 0 for valid innodb_change_buffering */ static @@ -10790,19 +10992,22 @@ innodb_change_buffering_validate( change_buffering_input = value->val_str(value, buff, &len); if (change_buffering_input != NULL) { - ulint use; + ibuf_use_t use; - for (use = 0; use < UT_ARR_SIZE(innobase_change_buffering_values); - use++) { - if (!innobase_strcasecmp( - change_buffering_input, - innobase_change_buffering_values[use])) { - *(ibuf_use_t*) save = (ibuf_use_t) use; - return(0); - } + use = innodb_find_change_buffering_value( + change_buffering_input); + + if (use != IBUF_USE_COUNT) { + /* Find a matching change_buffering option value. */ + *static_cast(save) = + innobase_change_buffering_values[use]; + + return(0); } } + /* No corresponding change buffering option for user supplied + "change_buffering_input" */ return(1); } @@ -10813,21 +11018,27 @@ static void innodb_change_buffering_update( /*===========================*/ - THD* thd, /*!< in: thread handle */ - struct st_mysql_sys_var* var, /*!< in: pointer to - system variable */ - void* var_ptr, /*!< out: where the - formal string goes */ - const void* save) /*!< in: immediate result - from check function */ + THD* thd, /*!< in: thread handle */ + struct st_mysql_sys_var* var, /*!< in: pointer to + system variable */ + void* var_ptr,/*!< out: where the + formal string goes */ + const void* save) /*!< in: immediate result + from check function */ { + ibuf_use_t use; + ut_a(var_ptr != NULL); ut_a(save != NULL); - ut_a((*(ibuf_use_t*) save) < IBUF_USE_COUNT); - ibuf_use = *(const ibuf_use_t*) save; + use = innodb_find_change_buffering_value( + *static_cast(save)); - *(const char**) var_ptr = innobase_change_buffering_values[ibuf_use]; + ut_a(use < IBUF_USE_COUNT); + + ibuf_use = use; + *static_cast(var_ptr) = + *static_cast(save); } static int show_innodb_vars(THD *thd, SHOW_VAR *var, char *buff) @@ -11093,6 +11304,14 @@ static MYSQL_SYSVAR_ULONG(stats_update_need_lock, srv_stats_update_need_lock, "e.g. Data_free.", NULL, NULL, 1, 0, 1, 0); +static MYSQL_SYSVAR_BOOL(use_sys_stats_table, innobase_use_sys_stats_table, + PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, + "Enable to use SYS_STATS system table to store statistics statically, " + "And avoids to calculate statistics at every first open of the tables. " + "This option may make the opportunities of update statistics less. " + "So you should use ANALYZE TABLE command intentionally.", + NULL, NULL, FALSE); + static MYSQL_SYSVAR_BOOL(adaptive_hash_index, btr_search_enabled, PLUGIN_VAR_OPCMDARG, "Enable InnoDB adaptive hash index (enabled by default). " @@ -11118,7 +11337,12 @@ static MYSQL_SYSVAR_ULONG(autoextend_increment, srv_auto_extend_increment, static MYSQL_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.", - NULL, NULL, 128*1024*1024L, 5*1024*1024L, LONGLONG_MAX, 1024*1024L); + NULL, NULL, 128*1024*1024L, 32*1024*1024L, LONGLONG_MAX, 1024*1024L); + +static MYSQL_SYSVAR_UINT(buffer_pool_shm_key, srv_buffer_pool_shm_key, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "[experimental] The key value of shared memory segment for the buffer pool. 0 means disable the feature (default).", + NULL, NULL, 0, 0, INT_MAX32, 0); static MYSQL_SYSVAR_ULONG(commit_concurrency, innobase_commit_concurrency, PLUGIN_VAR_RQCMDARG, @@ -11249,7 +11473,7 @@ static MYSQL_SYSVAR_STR(change_buffering, innobase_change_buffering, "Buffer changes to reduce random access: " "OFF, ON, none, inserts.", innodb_change_buffering_validate, - innodb_change_buffering_update, NULL); + innodb_change_buffering_update, "inserts"); static MYSQL_SYSVAR_ULONG(read_ahead_threshold, srv_read_ahead_threshold, PLUGIN_VAR_RQCMDARG, @@ -11379,6 +11603,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(additional_mem_pool_size), MYSQL_SYSVAR(autoextend_increment), MYSQL_SYSVAR(buffer_pool_size), + MYSQL_SYSVAR(buffer_pool_shm_key), MYSQL_SYSVAR(checksums), MYSQL_SYSVAR(fast_checksum), MYSQL_SYSVAR(commit_concurrency), @@ -11423,6 +11648,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(stats_method), MYSQL_SYSVAR(stats_auto_update), MYSQL_SYSVAR(stats_update_need_lock), + MYSQL_SYSVAR(use_sys_stats_table), MYSQL_SYSVAR(stats_sample_pages), MYSQL_SYSVAR(adaptive_hash_index), MYSQL_SYSVAR(replication_delay), @@ -11446,6 +11672,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(flush_neighbor_pages), MYSQL_SYSVAR(read_ahead), MYSQL_SYSVAR(adaptive_checkpoint), + MYSQL_SYSVAR(flush_log_at_trx_commit_session), MYSQL_SYSVAR(enable_unsafe_group_commit), MYSQL_SYSVAR(expand_import), MYSQL_SYSVAR(extra_rsegments), @@ -11465,7 +11692,7 @@ mysql_declare_plugin(innodb_plugin) &innobase_storage_engine, innobase_hton_name, "Innobase Oy", - "Supports transactions, row-level locking, and foreign keys", + "Percona-XtraDB, Supports transactions, row-level locking, and foreign keys", PLUGIN_LICENSE_GPL, innobase_init, /* Plugin Init */ NULL, /* Plugin Deinit */ @@ -11490,6 +11717,7 @@ i_s_innodb_index_stats, i_s_innodb_admin_command, i_s_innodb_sys_tables, i_s_innodb_sys_indexes, +i_s_innodb_sys_stats, i_s_innodb_patches mysql_declare_plugin_end; diff --git a/handler/ha_innodb.h b/handler/ha_innodb.h index 729abcbcd0a..04224277deb 100644 --- a/handler/ha_innodb.h +++ b/handler/ha_innodb.h @@ -233,7 +233,11 @@ the definitions are bracketed with #ifdef INNODB_COMPATIBILITY_HOOKS */ extern "C" { struct charset_info_st *thd_charset(MYSQL_THD thd); +#if MYSQL_VERSION_ID >= 50142 +LEX_STRING *thd_query_string(MYSQL_THD thd); +#else char **thd_query(MYSQL_THD thd); +#endif /** Get the file name of the MySQL binlog. * @return the name of the binlog file diff --git a/handler/handler0alter.cc b/handler/handler0alter.cc index e474c318c58..e936bfafa0e 100644 --- a/handler/handler0alter.cc +++ b/handler/handler0alter.cc @@ -894,6 +894,8 @@ error: prebuilt->trx->error_info = NULL; /* fall through */ default: + trx->error_state = DB_SUCCESS; + if (new_primary) { if (indexed_table != innodb_table) { row_merge_drop_table(trx, indexed_table); diff --git a/handler/i_s.cc b/handler/i_s.cc index 3165ce663ca..06e1a4fd0ab 100644 --- a/handler/i_s.cc +++ b/handler/i_s.cc @@ -43,20 +43,11 @@ extern "C" { #include "ha_prototypes.h" /* for innobase_convert_name() */ #include "srv0start.h" /* for srv_was_started */ #include "btr0btr.h" /* for btr_page_get_index_id */ -#include "dict0dict.h" /* for dict_index_get_if_in_cache */ #include "trx0rseg.h" /* for trx_rseg_struct */ #include "trx0sys.h" /* for trx_sys */ #include "dict0dict.h" /* for dict_sys */ #include "btr0pcur.h" #include "buf0lru.h" /* for XTRA_LRU_[DUMP/RESTORE] */ -/* from buf0buf.c */ -struct buf_chunk_struct{ - ulint mem_size; /* allocated size of the chunk */ - ulint size; /* size of frames[] and blocks[] */ - void* mem; /* pointer to the memory area which - was allocated for the frames */ - buf_block_t* blocks; /* array of buffer control blocks */ -}; } static const char plugin_author[] = "Innobase Oy"; @@ -450,27 +441,11 @@ static ST_FIELD_INFO i_s_innodb_buffer_pool_pages_fields_info[] = static ST_FIELD_INFO i_s_innodb_buffer_pool_pages_index_fields_info[] = { - {STRUCT_FLD(field_name, "schema_name"), - STRUCT_FLD(field_length, 64), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), + {STRUCT_FLD(field_name, "index_id"), + STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), + STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - {STRUCT_FLD(field_name, "table_name"), - STRUCT_FLD(field_length, 64), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - {STRUCT_FLD(field_name, "index_name"), - STRUCT_FLD(field_length, 64), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), + STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), STRUCT_FLD(old_name, ""), STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, @@ -671,7 +646,6 @@ i_s_innodb_buffer_pool_pages_fill( RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name); buf_pool_mutex_enter(); - mutex_enter(&(dict_sys->mutex)); chunk = buf_pool->chunks; @@ -743,7 +717,6 @@ i_s_innodb_buffer_pool_pages_fill( } } - mutex_exit(&(dict_sys->mutex)); buf_pool_mutex_exit(); DBUG_RETURN(status); @@ -764,13 +737,8 @@ i_s_innodb_buffer_pool_pages_index_fill( int status = 0; ulint n_chunks, n_blocks; - dict_index_t* index; dulint index_id; - const char *p; - char db_name_raw[NAME_LEN*5+1], db_name[NAME_LEN+1]; - char table_name_raw[NAME_LEN*5+1], table_name[NAME_LEN+1]; - buf_chunk_t* chunk; DBUG_ENTER("i_s_innodb_buffer_pool_pages_index_fill"); @@ -784,7 +752,6 @@ i_s_innodb_buffer_pool_pages_index_fill( RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name); buf_pool_mutex_enter(); - mutex_enter(&(dict_sys->mutex)); chunk = buf_pool->chunks; @@ -796,48 +763,28 @@ i_s_innodb_buffer_pool_pages_index_fill( if (fil_page_get_type(frame) == FIL_PAGE_INDEX) { index_id = btr_page_get_index_id(frame); - index = dict_index_get_if_in_cache_low(index_id); - if(index) - { - if((p = strchr(index->table_name, '/'))) - { - strncpy(db_name_raw, index->table_name, p-index->table_name); - db_name_raw[p-index->table_name] = 0; - filename_to_tablename(db_name_raw, db_name, sizeof(db_name)); - field_store_string(table->field[0], db_name); - p++; - } else { - field_store_string(table->field[0], NULL); - p = index->table_name; - } - strcpy(table_name_raw, (const char*)p); - filename_to_tablename(table_name_raw, table_name, sizeof(table_name)); - field_store_string(table->field[1], table_name); - field_store_string(table->field[2], index->name); + table->field[0]->store(ut_conv_dulint_to_longlong(index_id)); + table->field[1]->store(block->page.space); + table->field[2]->store(block->page.offset); + table->field[3]->store(page_get_n_recs(frame)); + table->field[4]->store(page_get_data_size(frame)); + table->field[5]->store(block->is_hashed); + table->field[6]->store(block->page.access_time); + table->field[7]->store(block->page.newest_modification != 0); + table->field[8]->store(block->page.oldest_modification != 0); + table->field[9]->store(block->page.old); + table->field[10]->store(0); + table->field[11]->store(block->page.buf_fix_count); + table->field[12]->store(block->page.flush_type); - table->field[3]->store(block->page.space); - table->field[4]->store(block->page.offset); - table->field[5]->store(page_get_n_recs(frame)); - table->field[6]->store(page_get_data_size(frame)); - table->field[7]->store(block->is_hashed); - table->field[8]->store(block->page.access_time); - table->field[9]->store(block->page.newest_modification != 0); - table->field[10]->store(block->page.oldest_modification != 0); - table->field[11]->store(block->page.old); - table->field[12]->store(0); - table->field[13]->store(block->page.buf_fix_count); - table->field[14]->store(block->page.flush_type); - - if (schema_table_store_record(thd, table)) { - status = 1; - break; - } + if (schema_table_store_record(thd, table)) { + status = 1; + break; } } } } - mutex_exit(&(dict_sys->mutex)); buf_pool_mutex_exit(); DBUG_RETURN(status); @@ -875,7 +822,6 @@ i_s_innodb_buffer_pool_pages_blob_fill( RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name); buf_pool_mutex_enter(); - mutex_enter(&(dict_sys->mutex)); chunk = buf_pool->chunks; @@ -931,7 +877,6 @@ i_s_innodb_buffer_pool_pages_blob_fill( } } - mutex_exit(&(dict_sys->mutex)); buf_pool_mutex_exit(); DBUG_RETURN(status); @@ -3037,11 +2982,10 @@ i_s_innodb_admin_command_fill( COND* cond) { TABLE* i_s_table = (TABLE *) tables->table; - CHARSET_INFO *cs= system_charset_info; char** query_str; char* ptr; char quote = '\0'; - char* command_head = "XTRA_"; + const char* command_head = "XTRA_"; DBUG_ENTER("i_s_innodb_admin_command_fill"); @@ -3310,6 +3254,35 @@ static ST_FIELD_INFO i_s_innodb_sys_indexes_info[] = END_OF_ST_FIELD_INFO }; +static ST_FIELD_INFO i_s_innodb_sys_stats_info[] = +{ + {STRUCT_FLD(field_name, "INDEX_ID"), + STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), + STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), + STRUCT_FLD(value, 0), + STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), + STRUCT_FLD(old_name, ""), + STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + + {STRUCT_FLD(field_name, "KEY_COLS"), + STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), + STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), + STRUCT_FLD(value, 0), + STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), + STRUCT_FLD(old_name, ""), + STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + + {STRUCT_FLD(field_name, "DIFF_VALS"), + STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), + STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), + STRUCT_FLD(value, 0), + STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), + STRUCT_FLD(old_name, ""), + STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + + END_OF_ST_FIELD_INFO +}; + static int copy_string_field( @@ -3564,6 +3537,40 @@ copy_sys_indexes_rec( return 0; } +static +int +copy_sys_stats_rec( +/*===============*/ + TABLE* table, + const dict_index_t* index, + const rec_t* rec +) +{ + int status; + int field; + + /* INDEX_ID */ + field = dict_index_get_nth_col_pos(index, 0); + status = copy_id_field(table, 0, rec, field); + if (status) { + return status; + } + /* KEY_COLS */ + field = dict_index_get_nth_col_pos(index, 1); + status = copy_int_field(table, 1, rec, field); + if (status) { + return status; + } + /* DIFF_VALS */ + field = dict_index_get_nth_col_pos(index, 2); + status = copy_id_field(table, 2, rec, field); + if (status) { + return status; + } + + return 0; +} + static int i_s_innodb_schema_table_fill( @@ -3593,6 +3600,8 @@ i_s_innodb_schema_table_fill( id = 0; } else if (innobase_strcasecmp(table_name, "innodb_sys_indexes") == 0) { id = 1; + } else if (innobase_strcasecmp(table_name, "innodb_sys_stats") == 0) { + id = 2; } else { DBUG_RETURN(1); } @@ -3606,8 +3615,10 @@ i_s_innodb_schema_table_fill( if (id == 0) { innodb_table = dict_table_get_low("SYS_TABLES"); - } else { + } else if (id == 1) { innodb_table = dict_table_get_low("SYS_INDEXES"); + } else { + innodb_table = dict_table_get_low("SYS_STATS"); } index = UT_LIST_GET_FIRST(innodb_table->indexes); @@ -3632,8 +3643,10 @@ i_s_innodb_schema_table_fill( if (id == 0) { status = copy_sys_tables_rec(table, index, rec); - } else { + } else if (id == 1) { status = copy_sys_indexes_rec(table, index, rec); + } else { + status = copy_sys_stats_rec(table, index, rec); } if (status) { btr_pcur_close(&pcur); @@ -3698,6 +3711,21 @@ i_s_innodb_sys_indexes_init( DBUG_RETURN(0); } +static +int +i_s_innodb_sys_stats_init( +/*======================*/ + void* p) +{ + DBUG_ENTER("i_s_innodb_sys_stats_init"); + ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p; + + schema->fields_info = i_s_innodb_sys_stats_info; + schema->fill_table = i_s_innodb_schema_table_fill; + + DBUG_RETURN(0); +} + UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_tables = { STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), @@ -3729,3 +3757,19 @@ UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_indexes = STRUCT_FLD(system_vars, NULL), STRUCT_FLD(__reserved1, NULL) }; + +UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_stats = +{ + STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), + STRUCT_FLD(info, &i_s_info), + STRUCT_FLD(name, "INNODB_SYS_STATS"), + STRUCT_FLD(author, plugin_author), + STRUCT_FLD(descr, "InnoDB SYS_STATS table"), + STRUCT_FLD(license, PLUGIN_LICENSE_GPL), + STRUCT_FLD(init, i_s_innodb_sys_stats_init), + STRUCT_FLD(deinit, i_s_common_deinit), + STRUCT_FLD(version, 0x0100 /* 1.0 */), + STRUCT_FLD(status_vars, NULL), + STRUCT_FLD(system_vars, NULL), + STRUCT_FLD(__reserved1, NULL) +}; diff --git a/handler/i_s.h b/handler/i_s.h index 41c63a98d76..3905fdc7b06 100644 --- a/handler/i_s.h +++ b/handler/i_s.h @@ -43,5 +43,6 @@ extern struct st_mysql_plugin i_s_innodb_index_stats; extern struct st_mysql_plugin i_s_innodb_admin_command; extern struct st_mysql_plugin i_s_innodb_sys_tables; extern struct st_mysql_plugin i_s_innodb_sys_indexes; +extern struct st_mysql_plugin i_s_innodb_sys_stats; #endif /* i_s_h */ diff --git a/handler/innodb_patch_info.h b/handler/innodb_patch_info.h index 38b97411340..e68f12d0fec 100644 --- a/handler/innodb_patch_info.h +++ b/handler/innodb_patch_info.h @@ -47,5 +47,6 @@ struct innodb_enhancement { {"innodb_fast_checksum","Using the checksum on 32bit-unit calculation","incompatible for unpatched ver.","http://www.percona.com/docs/wiki/percona-xtradb"}, {"innodb_files_extend","allow >4GB transaction log files, and can vary universal page size of datafiles","incompatible for unpatched ver.","http://www.percona.com/docs/wiki/percona-xtradb"}, {"innodb_sys_tables_sys_indexes","Expose InnoDB SYS_TABLES and SYS_INDEXES schema tables","","http://www.percona.com/docs/wiki/percona-xtradb"}, +{"innodb_buffer_pool_shm","Put buffer pool contents to shared memory segment and reuse it at clean restart [experimental]","","http://www.percona.com/docs/wiki/percona-xtradb"}, {NULL, NULL, NULL, NULL} }; diff --git a/include/buf0buf.h b/include/buf0buf.h index f93510be6d6..9484146d8a3 100644 --- a/include/buf0buf.h +++ b/include/buf0buf.h @@ -36,6 +36,7 @@ Created 11/5/1995 Heikki Tuuri #include "ut0rbt.h" #ifndef UNIV_HOTBACKUP #include "os0proc.h" +#include "srv0srv.h" /** @name Modes for buf_page_get_gen */ /* @{ */ @@ -1301,11 +1302,23 @@ struct buf_block_struct{ /**********************************************************************//** Compute the hash fold value for blocks in buf_pool->zip_hash. */ /* @{ */ -#define BUF_POOL_ZIP_FOLD_PTR(ptr) ((ulint) (ptr) / UNIV_PAGE_SIZE) +/* the fold should be relative when srv_buffer_pool_shm_key is enabled */ +#define BUF_POOL_ZIP_FOLD_PTR(ptr) (!srv_buffer_pool_shm_key\ + ?((ulint) (ptr) / UNIV_PAGE_SIZE)\ + :((ulint) ((void*)ptr - (void*)(buf_pool->chunks->blocks->frame)) / UNIV_PAGE_SIZE)) #define BUF_POOL_ZIP_FOLD(b) BUF_POOL_ZIP_FOLD_PTR((b)->frame) #define BUF_POOL_ZIP_FOLD_BPAGE(b) BUF_POOL_ZIP_FOLD((buf_block_t*) (b)) /* @} */ +/** A chunk of buffers. The buffer pool is allocated in chunks. */ +struct buf_chunk_struct{ + ulint mem_size; /*!< allocated size of the chunk */ + ulint size; /*!< size of frames[] and blocks[] */ + void* mem; /*!< pointer to the memory area which + was allocated for the frames */ + buf_block_t* blocks; /*!< array of buffer control blocks */ +}; + /** @brief The buffer pool statistics structure. */ struct buf_pool_stat_struct{ ulint n_page_gets; /*!< number of page gets performed; diff --git a/include/buf0buf.ic b/include/buf0buf.ic index 2c7386a22a4..a725446629f 100644 --- a/include/buf0buf.ic +++ b/include/buf0buf.ic @@ -973,7 +973,12 @@ buf_page_hash_get( ut_a(buf_page_in_file(bpage)); ut_ad(bpage->in_page_hash); ut_ad(!bpage->in_zip_hash); +#if UNIV_WORD_SIZE == 4 + /* On 32-bit systems, there is no padding in + buf_page_t. On other systems, Valgrind could complain + about uninitialized pad bytes. */ UNIV_MEM_ASSERT_RW(bpage, sizeof *bpage); +#endif } return(bpage); diff --git a/include/buf0lru.h b/include/buf0lru.h index 0a7d01c95cf..d3b59e8b579 100644 --- a/include/buf0lru.h +++ b/include/buf0lru.h @@ -96,7 +96,7 @@ buf_LRU_insert_zip_clean( Try to free a block. If bpage is a descriptor of a compressed-only page, the descriptor object will be freed as well. -NOTE: If this function returns BUF_LRU_FREED, it will not temporarily +NOTE: If this function returns BUF_LRU_FREED, it will temporarily release buf_pool_mutex. Furthermore, the page frame will no longer be accessible via bpage. diff --git a/include/buf0rea.h b/include/buf0rea.h index 71f62ff7b49..56d3d24a3b7 100644 --- a/include/buf0rea.h +++ b/include/buf0rea.h @@ -158,8 +158,7 @@ buf_read_recv_pages( /** The size in pages of the area which the read-ahead algorithms read if invoked */ -#define BUF_READ_AHEAD_AREA \ - ut_min(64, ut_2_power_up(buf_pool->curr_size / 32)) +#define BUF_READ_AHEAD_AREA 64 /** @name Modes used in read-ahead @{ */ /** read only pages belonging to the insert buffer tree */ diff --git a/include/db0err.h b/include/db0err.h index 747e9b5364e..c841c2b4afe 100644 --- a/include/db0err.h +++ b/include/db0err.h @@ -28,6 +28,8 @@ Created 5/24/1996 Heikki Tuuri enum db_err { + DB_SUCCESS_LOCKED_REC = 9, /*!< like DB_SUCCESS, but a new + explicit record lock was created */ DB_SUCCESS = 10, /* The following are error codes */ diff --git a/include/dict0boot.h b/include/dict0boot.h index 1a13bd1503a..9239e031a7f 100644 --- a/include/dict0boot.h +++ b/include/dict0boot.h @@ -46,13 +46,14 @@ dict_hdr_get( /*=========*/ mtr_t* mtr); /*!< in: mtr */ /**********************************************************************//** -Returns a new row, table, index, or tree id. -@return the new id */ +Returns a new table, index, or space id. */ UNIV_INTERN -dulint +void dict_hdr_get_new_id( /*================*/ - ulint type); /*!< in: DICT_HDR_ROW_ID, ... */ + dulint* table_id, /*!< out: table id (not assigned if NULL) */ + dulint* index_id, /*!< out: index id (not assigned if NULL) */ + ulint* space_id); /*!< out: space id (not assigned if NULL) */ /**********************************************************************//** Returns a new row id. @return the new id */ @@ -100,6 +101,7 @@ dict_create(void); #define DICT_COLUMNS_ID ut_dulint_create(0, 2) #define DICT_INDEXES_ID ut_dulint_create(0, 3) #define DICT_FIELDS_ID ut_dulint_create(0, 4) +#define DICT_STATS_ID ut_dulint_create(0, 6) /* The following is a secondary index on SYS_TABLES */ #define DICT_TABLE_IDS_ID ut_dulint_create(0, 5) @@ -119,17 +121,21 @@ dict_create(void); #define DICT_HDR_ROW_ID 0 /* The latest assigned row id */ #define DICT_HDR_TABLE_ID 8 /* The latest assigned table id */ #define DICT_HDR_INDEX_ID 16 /* The latest assigned index id */ -#define DICT_HDR_MIX_ID 24 /* Obsolete, always 0. */ +#define DICT_HDR_MAX_SPACE_ID 24 /* The latest assigned space id, or 0*/ +#define DICT_HDR_MIX_ID_LOW 28 /* Obsolete,always DICT_HDR_FIRST_ID */ #define DICT_HDR_TABLES 32 /* Root of the table index tree */ #define DICT_HDR_TABLE_IDS 36 /* Root of the table index tree */ #define DICT_HDR_COLUMNS 40 /* Root of the column index tree */ #define DICT_HDR_INDEXES 44 /* Root of the index index tree */ #define DICT_HDR_FIELDS 48 /* Root of the index field index tree */ +#define DICT_HDR_STATS 52 /* Root of the stats tree */ #define DICT_HDR_FSEG_HEADER 56 /* Segment header for the tablespace segment into which the dictionary header is created */ + +#define DICT_HDR_XTRADB_MARK 256 /* Flag to distinguish expansion of XtraDB */ /*-------------------------------------------------------------*/ /* The field number of the page number field in the sys_indexes table @@ -139,11 +145,15 @@ clustered index */ #define DICT_SYS_INDEXES_TYPE_FIELD 6 #define DICT_SYS_INDEXES_NAME_FIELD 4 +#define DICT_SYS_STATS_DIFF_VALS_FIELD 4 + /* When a row id which is zero modulo this number (which must be a power of two) is assigned, the field DICT_HDR_ROW_ID on the dictionary header page is updated */ #define DICT_HDR_ROW_ID_WRITE_MARGIN 256 +#define DICT_HDR_XTRADB_FLAG ut_dulint_create(0x58545241UL,0x44425F31UL) /* "XTRADB_1" */ + #ifndef UNIV_NONINL #include "dict0boot.ic" #endif diff --git a/include/dict0crea.h b/include/dict0crea.h index cce1246b789..0249091a195 100644 --- a/include/dict0crea.h +++ b/include/dict0crea.h @@ -53,6 +53,14 @@ ind_create_graph_create( dict_index_t* index, /*!< in: index to create, built as a memory data structure */ mem_heap_t* heap); /*!< in: heap where created */ +/*********************************************************************//** +*/ +UNIV_INTERN +ind_node_t* +ind_insert_stats_graph_create( +/*==========================*/ + dict_index_t* index, + mem_heap_t* heap); /***********************************************************//** Creates a table. This is a high-level function used in SQL execution graphs. @return query thread to run next or NULL */ @@ -62,6 +70,13 @@ dict_create_table_step( /*===================*/ que_thr_t* thr); /*!< in: query thread */ /***********************************************************//** +*/ +UNIV_INTERN +que_thr_t* +dict_insert_stats_step( +/*===================*/ + que_thr_t* thr); +/***********************************************************//** Creates an index. This is a high-level function used in SQL execution graphs. @return query thread to run next or NULL */ @@ -170,6 +185,7 @@ struct ind_node_struct{ ins_node_t* field_def; /* child node which does the inserts of the field definitions; the row to be inserted is built by the parent node */ + ins_node_t* stats_def; commit_node_t* commit_node; /* child node which performs a commit after a successful index creation */ @@ -180,6 +196,7 @@ struct ind_node_struct{ dict_table_t* table; /*!< table which owns the index */ dtuple_t* ind_row;/* index definition row built */ ulint field_no;/* next field definition to insert */ + ulint stats_no; mem_heap_t* heap; /*!< memory heap used as auxiliary storage */ }; @@ -189,6 +206,7 @@ struct ind_node_struct{ #define INDEX_CREATE_INDEX_TREE 3 #define INDEX_COMMIT_WORK 4 #define INDEX_ADD_TO_CACHE 5 +#define INDEX_BUILD_STATS_COLS 6 #ifndef UNIV_NONINL #include "dict0crea.ic" diff --git a/include/dict0dict.h b/include/dict0dict.h index 0879e91ab33..3c5e620d3c1 100644 --- a/include/dict0dict.h +++ b/include/dict0dict.h @@ -352,6 +352,7 @@ dict_create_foreign_constraints( name before it: test.table2; the default database id the database of parameter name */ + size_t sql_length, /*!< in: length of sql_string */ const char* name, /*!< in: table full name in the normalized form database_name/table_name */ @@ -1039,8 +1040,9 @@ void dict_update_statistics_low( /*=======================*/ dict_table_t* table, /*!< in/out: table */ - ibool has_dict_mutex);/*!< in: TRUE if the caller has the + ibool has_dict_mutex, /*!< in: TRUE if the caller has the dictionary mutex */ + ibool sync); /*********************************************************************//** Calculates new estimates for table and index statistics. The statistics are used in query optimization. */ @@ -1048,7 +1050,8 @@ UNIV_INTERN void dict_update_statistics( /*===================*/ - dict_table_t* table); /*!< in/out: table */ + dict_table_t* table, /*!< in/out: table */ + ibool sync); /********************************************************************//** Reserves the dictionary system mutex for MySQL. */ UNIV_INTERN @@ -1159,6 +1162,7 @@ struct dict_sys_struct{ dict_table_t* sys_columns; /*!< SYS_COLUMNS table */ dict_table_t* sys_indexes; /*!< SYS_INDEXES table */ dict_table_t* sys_fields; /*!< SYS_FIELDS table */ + dict_table_t* sys_stats; /*!< SYS_STATS table */ }; #endif /* !UNIV_HOTBACKUP */ diff --git a/include/dict0mem.h b/include/dict0mem.h index ee3107a3be1..37c5a4a24fc 100644 --- a/include/dict0mem.h +++ b/include/dict0mem.h @@ -382,7 +382,7 @@ initialized to 0, NULL or FALSE in dict_mem_table_create(). */ struct dict_table_struct{ dulint id; /*!< id of the table */ mem_heap_t* heap; /*!< memory heap */ - const char* name; /*!< table name */ + char* name; /*!< table name */ const char* dir_path_of_temp_table;/*!< NULL or the directory path where a TEMPORARY table that was explicitly created by a user should be placed if diff --git a/include/fil0fil.h b/include/fil0fil.h index 163cacf2892..07c80ef8609 100644 --- a/include/fil0fil.h +++ b/include/fil0fil.h @@ -226,6 +226,16 @@ fil_space_create( 0 for uncompressed tablespaces */ ulint purpose);/*!< in: FIL_TABLESPACE, or FIL_LOG if log */ /*******************************************************************//** +Assigns a new space id for a new single-table tablespace. This works simply by +incrementing the global counter. If 4 billion id's is not enough, we may need +to recycle id's. +@return TRUE if assigned, FALSE if not */ +UNIV_INTERN +ibool +fil_assign_new_space_id( +/*====================*/ + ulint* space_id); /*!< in/out: space id */ +/*******************************************************************//** Returns the size of the space in pages. The tablespace must be cached in the memory cache. @return space size, 0 if space not found */ @@ -428,9 +438,7 @@ UNIV_INTERN ulint fil_create_new_single_table_tablespace( /*===================================*/ - ulint* space_id, /*!< in/out: space id; if this is != 0, - then this is an input parameter, - otherwise output */ + ulint space_id, /*!< in: space id */ const char* tablename, /*!< in: the table name in the usual databasename/tablename format of InnoDB, or a dir path to a temp @@ -499,16 +507,6 @@ UNIV_INTERN ulint fil_load_single_table_tablespaces(void); /*===================================*/ -/********************************************************************//** -If we need crash recovery, and we have called -fil_load_single_table_tablespaces() and dict_load_single_table_tablespaces(), -we can call this function to print an error message of orphaned .ibd files -for which there is not a data dictionary entry with a matching table name -and space id. */ -UNIV_INTERN -void -fil_print_orphaned_tablespaces(void); -/*================================*/ /*******************************************************************//** Returns TRUE if a single-table tablespace does not exist in the memory cache, or is being deleted there. diff --git a/include/ha_prototypes.h b/include/ha_prototypes.h index b737a00b3dc..445d94eeabb 100644 --- a/include/ha_prototypes.h +++ b/include/ha_prototypes.h @@ -215,11 +215,21 @@ innobase_casedn_str( /**********************************************************************//** Determines the connection character set. @return connection character set */ +UNIV_INTERN struct charset_info_st* innobase_get_charset( /*=================*/ void* mysql_thd); /*!< in: MySQL thread handle */ - +/**********************************************************************//** +Determines the current SQL statement. +@return SQL statement string */ +UNIV_INTERN +const char* +innobase_get_stmt( +/*==============*/ + void* mysql_thd, /*!< in: MySQL thread handle */ + size_t* length) /*!< out: length of the SQL statement */ + __attribute__((nonnull)); /******************************************************************//** This function is used to find the storage length in bytes of the first n characters for prefix indexes using a multibyte character set. The function @@ -258,4 +268,12 @@ thd_lock_wait_timeout( void* thd); /*!< in: thread handle (THD*), or NULL to query the global innodb_lock_wait_timeout */ +/******************************************************************//** +*/ + +ulong +thd_flush_log_at_trx_commit_session( +/*================================*/ + void* thd); + #endif diff --git a/include/hash0hash.h b/include/hash0hash.h index b17c21a45ef..9cb410e2ad7 100644 --- a/include/hash0hash.h +++ b/include/hash0hash.h @@ -49,6 +49,28 @@ hash_table_t* hash_create( /*========*/ ulint n); /*!< in: number of array cells */ + +/*************************************************************//** +*/ +UNIV_INTERN +ulint +hash_create_needed( +/*===============*/ + ulint n); + +UNIV_INTERN +void +hash_create_init( +/*=============*/ + hash_table_t* table, + ulint n); + +UNIV_INTERN +void +hash_create_reuse( +/*==============*/ + hash_table_t* table); + #ifndef UNIV_HOTBACKUP /*************************************************************//** Creates a mutex array to protect a hash table. */ @@ -328,6 +350,33 @@ do {\ }\ } while (0) +/********************************************************************//** +Align nodes with moving location.*/ +#define HASH_OFFSET(TABLE, NODE_TYPE, PTR_NAME, FADDR, FOFFSET, BOFFSET) \ +do {\ + ulint i2222;\ + ulint cell_count2222;\ +\ + cell_count2222 = hash_get_n_cells(TABLE);\ +\ + for (i2222 = 0; i2222 < cell_count2222; i2222++) {\ + NODE_TYPE* node2222;\ +\ + if ((TABLE)->array[i2222].node) \ + (TABLE)->array[i2222].node \ + += (((TABLE)->array[i2222].node > (void*)FADDR)?FOFFSET:BOFFSET);\ + node2222 = HASH_GET_FIRST((TABLE), i2222);\ +\ + while (node2222) {\ + if (node2222->PTR_NAME) \ + node2222->PTR_NAME = ((void*)node2222->PTR_NAME) \ + + ((((void*)node2222->PTR_NAME) > (void*)FADDR)?FOFFSET:BOFFSET);\ +\ + node2222 = node2222->PTR_NAME;\ + }\ + }\ +} while (0) + /************************************************************//** Gets the mutex index for a fold value in a hash table. @return mutex number */ diff --git a/include/lock0lock.h b/include/lock0lock.h index 89a6977b589..73f885ecf04 100644 --- a/include/lock0lock.h +++ b/include/lock0lock.h @@ -341,11 +341,12 @@ lock_sec_rec_modify_check_and_lock( que_thr_t* thr, /*!< in: query thread */ mtr_t* mtr); /*!< in/out: mini-transaction */ /*********************************************************************//** -Like the counterpart for a clustered index below, but now we read a +Like lock_clust_rec_read_check_and_lock(), but reads a secondary index record. -@return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ +@return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, DB_LOCK_WAIT, DB_DEADLOCK, +or DB_QUE_THR_SUSPENDED */ UNIV_INTERN -ulint +enum db_err lock_sec_rec_read_check_and_lock( /*=============================*/ ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG @@ -372,9 +373,10 @@ if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the lock wait state and inserts a waiting request for a record lock to the lock queue. Sets the requested mode lock on the record. -@return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ +@return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, DB_LOCK_WAIT, DB_DEADLOCK, +or DB_QUE_THR_SUSPENDED */ UNIV_INTERN -ulint +enum db_err lock_clust_rec_read_check_and_lock( /*===============================*/ ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG diff --git a/include/log0log.ic b/include/log0log.ic index 139f4041a36..1ce00fd7313 100644 --- a/include/log0log.ic +++ b/include/log0log.ic @@ -433,7 +433,10 @@ void log_free_check(void) /*================*/ { - /* ut_ad(sync_thread_levels_empty()); */ + +#ifdef UNIV_SYNC_DEBUG + ut_ad(sync_thread_levels_empty_gen(TRUE)); +#endif /* UNIV_SYNC_DEBUG */ if (log_sys->check_flush_or_checkpoint) { diff --git a/include/mach0data.ic b/include/mach0data.ic index ef20356bd31..96d2417ac81 100644 --- a/include/mach0data.ic +++ b/include/mach0data.ic @@ -36,7 +36,7 @@ mach_write_to_1( ulint n) /*!< in: ulint integer to be stored, >= 0, < 256 */ { ut_ad(b); - ut_ad(n <= 0xFFUL); + ut_ad((n | 0xFFUL) <= 0xFFUL); b[0] = (byte)n; } @@ -65,7 +65,7 @@ mach_write_to_2( ulint n) /*!< in: ulint integer to be stored */ { ut_ad(b); - ut_ad(n <= 0xFFFFUL); + ut_ad((n | 0xFFFFUL) <= 0xFFFFUL); b[0] = (byte)(n >> 8); b[1] = (byte)(n); @@ -81,10 +81,7 @@ mach_read_from_2( /*=============*/ const byte* b) /*!< in: pointer to 2 bytes */ { - ut_ad(b); - return( ((ulint)(b[0]) << 8) - + (ulint)(b[1]) - ); + return(((ulint)(b[0]) << 8) | (ulint)(b[1])); } /********************************************************//** @@ -129,7 +126,7 @@ mach_write_to_3( ulint n) /*!< in: ulint integer to be stored */ { ut_ad(b); - ut_ad(n <= 0xFFFFFFUL); + ut_ad((n | 0xFFFFFFUL) <= 0xFFFFFFUL); b[0] = (byte)(n >> 16); b[1] = (byte)(n >> 8); @@ -148,8 +145,8 @@ mach_read_from_3( { ut_ad(b); return( ((ulint)(b[0]) << 16) - + ((ulint)(b[1]) << 8) - + (ulint)(b[2]) + | ((ulint)(b[1]) << 8) + | (ulint)(b[2]) ); } @@ -183,9 +180,9 @@ mach_read_from_4( { ut_ad(b); return( ((ulint)(b[0]) << 24) - + ((ulint)(b[1]) << 16) - + ((ulint)(b[2]) << 8) - + (ulint)(b[3]) + | ((ulint)(b[1]) << 16) + | ((ulint)(b[2]) << 8) + | (ulint)(b[3]) ); } @@ -721,7 +718,7 @@ mach_read_from_2_little_endian( /*===========================*/ const byte* buf) /*!< in: from where to read */ { - return((ulint)(*buf) + ((ulint)(*(buf + 1))) * 256); + return((ulint)(buf[0]) | ((ulint)(buf[1]) << 8)); } /*********************************************************//** diff --git a/include/mtr0log.ic b/include/mtr0log.ic index db017c7d16e..63af02ba409 100644 --- a/include/mtr0log.ic +++ b/include/mtr0log.ic @@ -203,7 +203,7 @@ mlog_write_initial_log_record_fast( system tablespace */ if ((space == TRX_SYS_SPACE || (srv_doublewrite_file && space == TRX_DOUBLEWRITE_SPACE)) - && offset >= FSP_EXTENT_SIZE && offset < 3 * FSP_EXTENT_SIZE) { + && offset >= (ulint)FSP_EXTENT_SIZE && offset < 3 * (ulint)FSP_EXTENT_SIZE) { if (trx_doublewrite_buf_is_being_created) { /* Do nothing: we only come to this branch in an InnoDB database creation. We do not redo log diff --git a/include/os0proc.h b/include/os0proc.h index fd46bd7db87..582cef6f803 100644 --- a/include/os0proc.h +++ b/include/os0proc.h @@ -32,6 +32,11 @@ Created 9/30/1995 Heikki Tuuri #ifdef UNIV_LINUX #include #include +#else +# if defined HAVE_SYS_IPC_H && HAVE_SYS_SHM_H +#include +#include +# endif #endif typedef void* os_process_t; @@ -70,6 +75,29 @@ os_mem_free_large( ulint size); /*!< in: size returned by os_mem_alloc_large() */ + +/****************************************************************//** +Allocates or attaches and reuses shared memory segment. +The content is not cleared automatically. +@return allocated memory */ +UNIV_INTERN +void* +os_shm_alloc( +/*=========*/ + ulint* n, /*!< in/out: number of bytes */ + uint key, + ibool* is_new); + +/****************************************************************//** +Detach shared memory segment. */ +UNIV_INTERN +void +os_shm_free( +/*========*/ + void *ptr, /*!< in: pointer returned by + os_shm_alloc() */ + ulint size); /*!< in: size returned by + os_shm_alloc() */ #ifndef UNIV_NONINL #include "os0proc.ic" #endif diff --git a/include/page0page.h b/include/page0page.h index 3899499fb6a..863b388b340 100644 --- a/include/page0page.h +++ b/include/page0page.h @@ -500,7 +500,7 @@ ibool page_is_leaf( /*=========*/ const page_t* page) /*!< in: page */ - __attribute__((nonnull, pure)); + __attribute__((pure)); /************************************************************//** Gets the pointer to the next record on the page. @return pointer to next record */ diff --git a/include/page0page.ic b/include/page0page.ic index 8f794410f20..9e571c6be1e 100644 --- a/include/page0page.ic +++ b/include/page0page.ic @@ -275,6 +275,9 @@ page_is_leaf( /*=========*/ const page_t* page) /*!< in: page */ { + if (!page) { + return(FALSE); + } return(!*(const uint16*) (page + (PAGE_HEADER + PAGE_LEVEL))); } diff --git a/include/page0zip.h b/include/page0zip.h index 574809e5227..4d37302ed20 100644 --- a/include/page0zip.h +++ b/include/page0zip.h @@ -114,7 +114,7 @@ page_zip_compress( const page_t* page, /*!< in: uncompressed page */ dict_index_t* index, /*!< in: index of the B-tree node */ mtr_t* mtr) /*!< in: mini-transaction, or NULL */ - __attribute__((nonnull(1,2,3))); + __attribute__((nonnull(1,3))); /**********************************************************************//** Decompress a page. This function should tolerate errors on the compressed diff --git a/include/que0que.h b/include/que0que.h index 39f8d07af89..09a671f49b1 100644 --- a/include/que0que.h +++ b/include/que0que.h @@ -492,6 +492,8 @@ struct que_fork_struct{ #define QUE_NODE_CALL 31 #define QUE_NODE_EXIT 32 +#define QUE_NODE_INSERT_STATS 34 + /* Query thread states */ #define QUE_THR_RUNNING 1 #define QUE_THR_PROCEDURE_WAIT 2 diff --git a/include/rem0cmp.h b/include/rem0cmp.h index 421308af49b..fcea62ad486 100644 --- a/include/rem0cmp.h +++ b/include/rem0cmp.h @@ -148,7 +148,9 @@ cmp_rec_rec_simple( const rec_t* rec2, /*!< in: physical record */ const ulint* offsets1,/*!< in: rec_get_offsets(rec1, ...) */ const ulint* offsets2,/*!< in: rec_get_offsets(rec2, ...) */ - const dict_index_t* index); /*!< in: data dictionary index */ + const dict_index_t* index, /*!< in: data dictionary index */ + ibool* null_eq);/*!< out: set to TRUE if + found matching null values */ /*************************************************************//** This function is used to compare two physical records. Only the common first fields are compared, and if an externally stored field is diff --git a/include/row0mysql.h b/include/row0mysql.h index d2a8734c61f..a604f6e3724 100644 --- a/include/row0mysql.h +++ b/include/row0mysql.h @@ -253,15 +253,6 @@ row_table_got_default_clust_index( /*==============================*/ const dict_table_t* table); /*!< in: table */ /*********************************************************************//** -Calculates the key number used inside MySQL for an Innobase index. We have -to take into account if we generated a default clustered index for the table -@return the key number used inside MySQL */ -UNIV_INTERN -ulint -row_get_mysql_key_number_for_index( -/*===============================*/ - const dict_index_t* index); /*!< in: index */ -/*********************************************************************//** Does an update or delete of a row for MySQL. @return error code or DB_SUCCESS */ UNIV_INTERN @@ -273,27 +264,26 @@ row_update_for_mysql( row_prebuilt_t* prebuilt); /*!< in: prebuilt struct in MySQL handle */ /*********************************************************************//** -This can only be used when srv_locks_unsafe_for_binlog is TRUE or -session is using a READ COMMITTED isolation level. Before -calling this function we must use trx_reset_new_rec_lock_info() and -trx_register_new_rec_lock() to store the information which new record locks -really were set. This function removes a newly set lock under prebuilt->pcur, -and also under prebuilt->clust_pcur. Currently, this is only used and tested -in the case of an UPDATE or a DELETE statement, where the row lock is of the -LOCK_X type. -Thus, this implements a 'mini-rollback' that releases the latest record -locks we set. -@return error code or DB_SUCCESS */ +This can only be used when srv_locks_unsafe_for_binlog is TRUE or this +session is using a READ COMMITTED or READ UNCOMMITTED isolation level. +Before calling this function row_search_for_mysql() must have +initialized prebuilt->new_rec_locks to store the information which new +record locks really were set. This function removes a newly set +clustered index record lock under prebuilt->pcur or +prebuilt->clust_pcur. Thus, this implements a 'mini-rollback' that +releases the latest clustered index record lock we set. +@return error code or DB_SUCCESS */ UNIV_INTERN int row_unlock_for_mysql( /*=================*/ - row_prebuilt_t* prebuilt, /*!< in: prebuilt struct in MySQL + row_prebuilt_t* prebuilt, /*!< in/out: prebuilt struct in MySQL handle */ - ibool has_latches_on_recs);/*!< TRUE if called so that we have - the latches on the records under pcur - and clust_pcur, and we do not need to - reposition the cursors. */ + ibool has_latches_on_recs);/*!< in: TRUE if called + so that we have the latches on + the records under pcur and + clust_pcur, and we do not need + to reposition the cursors. */ /*********************************************************************//** Creates an query graph node of 'update' type to be used in the MySQL interface. @@ -386,6 +376,14 @@ row_create_index_for_mysql( then checked for not being too large. */ /*********************************************************************//** +*/ +UNIV_INTERN +int +row_insert_stats_for_mysql( +/*=======================*/ + dict_index_t* index, + trx_t* trx); +/*********************************************************************//** Scans a table create SQL string and adds to the data dictionary the foreign key constraints declared in the string. This function should be called after the indexes for a table have been created. @@ -403,6 +401,7 @@ row_table_add_foreign_constraints( FOREIGN KEY (a, b) REFERENCES table2(c, d), table2 can be written also with the database name before it: test.table2 */ + size_t sql_length, /*!< in: length of sql_string */ const char* name, /*!< in: table full name in the normalized form database_name/table_name */ @@ -710,18 +709,17 @@ struct row_prebuilt_struct { ulint new_rec_locks; /*!< normally 0; if srv_locks_unsafe_for_binlog is TRUE or session is using READ - COMMITTED isolation level, in a - cursor search, if we set a new - record lock on an index, this is - incremented; this is used in - releasing the locks under the - cursors if we are performing an - UPDATE and we determine after - retrieving the row that it does - not need to be locked; thus, - these can be used to implement a - 'mini-rollback' that releases - the latest record locks */ + COMMITTED or READ UNCOMMITTED + isolation level, set in + row_search_for_mysql() if we set a new + record lock on the secondary + or clustered index; this is + used in row_unlock_for_mysql() + when releasing the lock under + the cursor if we determine + after retrieving the row that + it does not need to be locked + ('mini-rollback') */ ulint mysql_prefix_len;/*!< byte offset of the end of the last requested column */ ulint mysql_row_len; /*!< length in bytes of a row in the diff --git a/include/srv0srv.h b/include/srv0srv.h index b3823e31e44..43f35e8b8a5 100644 --- a/include/srv0srv.h +++ b/include/srv0srv.h @@ -156,6 +156,8 @@ extern ulint srv_buf_pool_curr_size; /*!< current size in bytes */ extern ulint srv_mem_pool_size; extern ulint srv_lock_table_size; +extern uint srv_buffer_pool_shm_key; + extern ibool srv_thread_concurrency_timer_based; extern ulint srv_n_file_io_threads; @@ -207,6 +209,7 @@ extern ulint srv_stats_method; #define SRV_STATS_METHOD_IGNORE_NULLS 2 extern ulint srv_stats_auto_update; extern ulint srv_stats_update_need_lock; +extern ibool srv_use_sys_stats_table; extern ibool srv_use_doublewrite_buf; extern ibool srv_use_checksums; @@ -367,8 +370,9 @@ enum { when writing data files, but do flush after writing to log files */ SRV_UNIX_NOSYNC, /*!< do not flush after writing */ - SRV_UNIX_O_DIRECT /*!< invoke os_file_set_nocache() on + SRV_UNIX_O_DIRECT, /*!< invoke os_file_set_nocache() on data files */ + SRV_UNIX_ALL_O_DIRECT /* new method for examination: logfile also open O_DIRECT */ }; /** Alternatives for file i/o in Windows */ diff --git a/include/sync0rw.h b/include/sync0rw.h index 1fe517ab30a..4edf93f4042 100644 --- a/include/sync0rw.h +++ b/include/sync0rw.h @@ -556,11 +556,12 @@ struct rw_lock_struct { //unsigned cline:14; /*!< Line where created */ unsigned last_s_line:14; /*!< Line number where last time s-locked */ unsigned last_x_line:14; /*!< Line number where last time x-locked */ +#ifdef UNIV_DEBUG ulint magic_n; /*!< RW_LOCK_MAGIC_N */ -}; - /** Value of rw_lock_struct::magic_n */ #define RW_LOCK_MAGIC_N 22643 +#endif /* UNIV_DEBUG */ +}; #ifdef UNIV_SYNC_DEBUG /** The structure for storing debug info of an rw-lock */ diff --git a/include/sync0sync.h b/include/sync0sync.h index 7e210ea82f1..a500cf1da45 100644 --- a/include/sync0sync.h +++ b/include/sync0sync.h @@ -438,7 +438,7 @@ or row lock! */ #define SYNC_FILE_FORMAT_TAG 1200 /* Used to serialize access to the file format tag */ #define SYNC_DICT_OPERATION 1001 /* table create, drop, etc. reserve - this in X-mode, implicit or backround + this in X-mode; implicit or backround operations purge, rollback, foreign key checks reserve this in S-mode */ #define SYNC_DICT 1000 diff --git a/include/trx0sys.h b/include/trx0sys.h index 8b941cdd4e6..9ef9485b611 100644 --- a/include/trx0sys.h +++ b/include/trx0sys.h @@ -326,6 +326,7 @@ UNIV_INTERN void trx_sys_update_mysql_binlog_offset( /*===============================*/ + trx_sysf_t* sys_header, const char* file_name_in,/*!< in: MySQL log file name */ ib_int64_t offset, /*!< in: position in that log file */ ulint field, /*!< in: offset of the MySQL log info field in diff --git a/include/trx0trx.h b/include/trx0trx.h index 4a4b54b93a0..4c0ce392bcd 100644 --- a/include/trx0trx.h +++ b/include/trx0trx.h @@ -497,6 +497,7 @@ struct trx_struct{ FALSE, one can save CPU time and about 150 bytes in the undo log size as then we skip XA steps */ + ulint flush_log_at_trx_commit_session; ulint flush_log_later;/* In 2PC, we hold the prepare_commit mutex across both phases. In that case, we @@ -560,9 +561,6 @@ struct trx_struct{ /*------------------------------*/ void* mysql_thd; /*!< MySQL thread handle corresponding to this trx, or NULL */ - char** mysql_query_str;/* pointer to the field in mysqld_thd - which contains the pointer to the - current SQL query string */ const char* mysql_log_file_name; /* if MySQL binlog is used, this field contains a pointer to the latest file diff --git a/include/univ.i b/include/univ.i index 0e04eceef6f..6166e9c4248 100644 --- a/include/univ.i +++ b/include/univ.i @@ -46,10 +46,10 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 1 #define INNODB_VERSION_MINOR 0 -#define INNODB_VERSION_BUGFIX 8 +#define INNODB_VERSION_BUGFIX 10 #ifndef PERCONA_INNODB_VERSION -#define PERCONA_INNODB_VERSION 11.2 +#define PERCONA_INNODB_VERSION 12.0 #endif @@ -172,9 +172,9 @@ command. Not tested on Windows. */ #define UNIV_COMPILE_TEST_FUNCS */ -#ifdef HAVE_purify +#if defined HAVE_VALGRIND # define UNIV_DEBUG_VALGRIND -#endif /* HAVE_purify */ +#endif /* HAVE_VALGRIND */ #if 0 #define UNIV_DEBUG_VALGRIND /* Enable extra Valgrind instrumentation */ @@ -212,10 +212,6 @@ operations (very slow); also UNIV_DEBUG must be defined */ adaptive hash index */ #define UNIV_SRV_PRINT_LATCH_WAITS /* enable diagnostic output in sync0sync.c */ -#define UNIV_BTR_AVOID_COPY /* when splitting B-tree nodes, - do not move any records when - all the records would - be moved */ #define UNIV_BTR_PRINT /* enable functions for printing B-trees */ #define UNIV_ZIP_DEBUG /* extensive consistency checks @@ -305,6 +301,12 @@ management to ensure correct alignment for doubles etc. */ /* Maximum number of parallel threads in a parallelized operation */ #define UNIV_MAX_PARALLELISM 32 +/* The maximum length of a table name. This is the MySQL limit and is +defined in mysql_com.h like NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN, the +number does not include a terminating '\0'. InnoDB probably can handle +longer names internally */ +#define MAX_TABLE_NAME_LEN 192 + /* UNIVERSAL TYPE DEFINITIONS ========================== diff --git a/include/ut0lst.h b/include/ut0lst.h index 261d33963dc..39553e270f7 100644 --- a/include/ut0lst.h +++ b/include/ut0lst.h @@ -257,5 +257,48 @@ do { \ ut_a(ut_list_node_313 == NULL); \ } while (0) +/********************************************************************//** +Align nodes with moving location. +@param NAME the name of the list +@param TYPE node type +@param BASE base node (not a pointer to it) +@param OFFSET offset moved */ +#define UT_LIST_OFFSET(NAME, TYPE, BASE, FADDR, FOFFSET, BOFFSET) \ +do { \ + ulint ut_list_i_313; \ + TYPE* ut_list_node_313; \ + \ + if ((BASE).start) \ + (BASE).start = ((void*)((BASE).start) \ + + (((void*)((BASE).start) > (void*)FADDR)?FOFFSET:BOFFSET));\ + if ((BASE).end) \ + (BASE).end = ((void*)((BASE).end) \ + + (((void*)((BASE).end) > (void*)FADDR)?FOFFSET:BOFFSET));\ + \ + ut_list_node_313 = (BASE).start; \ + \ + for (ut_list_i_313 = (BASE).count; ut_list_i_313--; ) { \ + ut_a(ut_list_node_313); \ + if ((ut_list_node_313->NAME).prev) \ + (ut_list_node_313->NAME).prev = ((void*)((ut_list_node_313->NAME).prev)\ + + (((void*)((ut_list_node_313->NAME).prev) > (void*)FADDR)?FOFFSET:BOFFSET));\ + if ((ut_list_node_313->NAME).next) \ + (ut_list_node_313->NAME).next = ((void*)((ut_list_node_313->NAME).next)\ + + (((void*)((ut_list_node_313->NAME).next)> (void*)FADDR)?FOFFSET:BOFFSET));\ + ut_list_node_313 = (ut_list_node_313->NAME).next; \ + } \ + \ + ut_a(ut_list_node_313 == NULL); \ + \ + ut_list_node_313 = (BASE).end; \ + \ + for (ut_list_i_313 = (BASE).count; ut_list_i_313--; ) { \ + ut_a(ut_list_node_313); \ + ut_list_node_313 = (ut_list_node_313->NAME).prev; \ + } \ + \ + ut_a(ut_list_node_313 == NULL); \ +} while (0) + #endif diff --git a/lock/lock0lock.c b/lock/lock0lock.c index b103ee79578..7ec4a53e0ea 100644 --- a/lock/lock0lock.c +++ b/lock/lock0lock.c @@ -1733,11 +1733,11 @@ lock_rec_create( Enqueues a waiting request for a lock which cannot be granted immediately. Checks for deadlocks. @return DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED, or -DB_SUCCESS; DB_SUCCESS means that there was a deadlock, but another -transaction was chosen as a victim, and we got the lock immediately: -no need to wait then */ +DB_SUCCESS_LOCKED_REC; DB_SUCCESS_LOCKED_REC means that +there was a deadlock, but another transaction was chosen as a victim, +and we got the lock immediately: no need to wait then */ static -ulint +enum db_err lock_rec_enqueue_waiting( /*=====================*/ ulint type_mode,/*!< in: lock mode this @@ -1811,7 +1811,7 @@ lock_rec_enqueue_waiting( if (trx->wait_lock == NULL) { - return(DB_SUCCESS); + return(DB_SUCCESS_LOCKED_REC); } trx->que_state = TRX_QUE_LOCK_WAIT; @@ -1931,6 +1931,16 @@ somebody_waits: return(lock_rec_create(type_mode, block, heap_no, index, trx)); } +/** Record locking request status */ +enum lock_rec_req_status { + /** Failed to acquire a lock */ + LOCK_REC_FAIL, + /** Succeeded in acquiring a lock (implicit or already acquired) */ + LOCK_REC_SUCCESS, + /** Explicitly created a new lock */ + LOCK_REC_SUCCESS_CREATED +}; + /*********************************************************************//** This is a fast routine for locking a record in the most common cases: there are no explicit locks on the page, or there is just one lock, owned @@ -1938,9 +1948,9 @@ by this transaction, and of the right type_mode. This is a low-level function which does NOT look at implicit locks! Checks lock compatibility within explicit locks. This function sets a normal next-key lock, or in the case of a page supremum record, a gap type lock. -@return TRUE if locking succeeded */ +@return whether the locking succeeded */ UNIV_INLINE -ibool +enum lock_rec_req_status lock_rec_lock_fast( /*===============*/ ibool impl, /*!< in: if TRUE, no lock is set @@ -1979,19 +1989,19 @@ lock_rec_lock_fast( lock_rec_create(mode, block, heap_no, index, trx); } - return(TRUE); + return(LOCK_REC_SUCCESS_CREATED); } if (lock_rec_get_next_on_page(lock)) { - return(FALSE); + return(LOCK_REC_FAIL); } if (lock->trx != trx || lock->type_mode != (mode | LOCK_REC) || lock_rec_get_n_bits(lock) <= heap_no) { - return(FALSE); + return(LOCK_REC_FAIL); } if (!impl) { @@ -2000,10 +2010,11 @@ lock_rec_lock_fast( if (!lock_rec_get_nth_bit(lock, heap_no)) { lock_rec_set_nth_bit(lock, heap_no); + return(LOCK_REC_SUCCESS_CREATED); } } - return(TRUE); + return(LOCK_REC_SUCCESS); } /*********************************************************************//** @@ -2011,9 +2022,10 @@ This is the general, and slower, routine for locking a record. This is a low-level function which does NOT look at implicit locks! Checks lock compatibility within explicit locks. This function sets a normal next-key lock, or in the case of a page supremum record, a gap type lock. -@return DB_SUCCESS, DB_LOCK_WAIT, or error code */ +@return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, DB_LOCK_WAIT, DB_DEADLOCK, +or DB_QUE_THR_SUSPENDED */ static -ulint +enum db_err lock_rec_lock_slow( /*===============*/ ibool impl, /*!< in: if TRUE, no lock is set @@ -2030,7 +2042,6 @@ lock_rec_lock_slow( que_thr_t* thr) /*!< in: query thread */ { trx_t* trx; - ulint err; ut_ad(mutex_own(&kernel_mutex)); ut_ad((LOCK_MODE_MASK & mode) != LOCK_S @@ -2049,27 +2060,23 @@ lock_rec_lock_slow( /* The trx already has a strong enough lock on rec: do nothing */ - err = DB_SUCCESS; } else if (lock_rec_other_has_conflicting(mode, block, heap_no, trx)) { /* If another transaction has a non-gap conflicting request in the queue, as this transaction does not have a lock strong enough already granted on the record, we have to wait. */ - err = lock_rec_enqueue_waiting(mode, block, heap_no, - index, thr); - } else { - if (!impl) { - /* Set the requested lock on the record */ + return(lock_rec_enqueue_waiting(mode, block, heap_no, + index, thr)); + } else if (!impl) { + /* Set the requested lock on the record */ - lock_rec_add_to_queue(LOCK_REC | mode, block, - heap_no, index, trx); - } - - err = DB_SUCCESS; + lock_rec_add_to_queue(LOCK_REC | mode, block, + heap_no, index, trx); + return(DB_SUCCESS_LOCKED_REC); } - return(err); + return(DB_SUCCESS); } /*********************************************************************//** @@ -2078,9 +2085,10 @@ possible, enqueues a waiting lock request. This is a low-level function which does NOT look at implicit locks! Checks lock compatibility within explicit locks. This function sets a normal next-key lock, or in the case of a page supremum record, a gap type lock. -@return DB_SUCCESS, DB_LOCK_WAIT, or error code */ +@return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, DB_LOCK_WAIT, DB_DEADLOCK, +or DB_QUE_THR_SUSPENDED */ static -ulint +enum db_err lock_rec_lock( /*==========*/ ibool impl, /*!< in: if TRUE, no lock is set @@ -2096,8 +2104,6 @@ lock_rec_lock( dict_index_t* index, /*!< in: index of record */ que_thr_t* thr) /*!< in: query thread */ { - ulint err; - ut_ad(mutex_own(&kernel_mutex)); ut_ad((LOCK_MODE_MASK & mode) != LOCK_S || lock_table_has(thr_get_trx(thr), index->table, LOCK_IS)); @@ -2109,18 +2115,20 @@ lock_rec_lock( || mode - (LOCK_MODE_MASK & mode) == LOCK_REC_NOT_GAP || mode - (LOCK_MODE_MASK & mode) == 0); - if (lock_rec_lock_fast(impl, mode, block, heap_no, index, thr)) { - - /* We try a simplified and faster subroutine for the most - common cases */ - - err = DB_SUCCESS; - } else { - err = lock_rec_lock_slow(impl, mode, block, - heap_no, index, thr); + /* We try a simplified and faster subroutine for the most + common cases */ + switch (lock_rec_lock_fast(impl, mode, block, heap_no, index, thr)) { + case LOCK_REC_SUCCESS: + return(DB_SUCCESS); + case LOCK_REC_SUCCESS_CREATED: + return(DB_SUCCESS_LOCKED_REC); + case LOCK_REC_FAIL: + return(lock_rec_lock_slow(impl, mode, block, + heap_no, index, thr)); } - return(err); + ut_error; + return(DB_ERROR); } /*********************************************************************//** @@ -3948,8 +3956,8 @@ lock_rec_unlock( const rec_t* rec, /*!< in: record */ enum lock_mode lock_mode)/*!< in: LOCK_S or LOCK_X */ { + lock_t* first_lock; lock_t* lock; - lock_t* release_lock = NULL; ulint heap_no; ut_ad(trx && rec); @@ -3959,48 +3967,40 @@ lock_rec_unlock( mutex_enter(&kernel_mutex); - lock = lock_rec_get_first(block, heap_no); + first_lock = lock_rec_get_first(block, heap_no); /* Find the last lock with the same lock_mode and transaction from the record. */ - while (lock != NULL) { + for (lock = first_lock; lock != NULL; + lock = lock_rec_get_next(heap_no, lock)) { if (lock->trx == trx && lock_get_mode(lock) == lock_mode) { - release_lock = lock; ut_a(!lock_get_wait(lock)); + lock_rec_reset_nth_bit(lock, heap_no); + goto released; } - - lock = lock_rec_get_next(heap_no, lock); } - /* If a record lock is found, release the record lock */ + mutex_exit(&kernel_mutex); + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Error: unlock row could not" + " find a %lu mode lock on the record\n", + (ulong) lock_mode); - if (UNIV_LIKELY(release_lock != NULL)) { - lock_rec_reset_nth_bit(release_lock, heap_no); - } else { - mutex_exit(&kernel_mutex); - ut_print_timestamp(stderr); - fprintf(stderr, - " InnoDB: Error: unlock row could not" - " find a %lu mode lock on the record\n", - (ulong) lock_mode); - - return; - } + return; +released: /* Check if we can now grant waiting lock requests */ - lock = lock_rec_get_first(block, heap_no); - - while (lock != NULL) { + for (lock = first_lock; lock != NULL; + lock = lock_rec_get_next(heap_no, lock)) { if (lock_get_wait(lock) && !lock_rec_has_to_wait_in_queue(lock)) { /* Grant the lock */ lock_grant(lock); } - - lock = lock_rec_get_next(heap_no, lock); } mutex_exit(&kernel_mutex); @@ -5095,7 +5095,14 @@ lock_rec_insert_check_and_lock( lock_mutex_exit_kernel(); - if ((err == DB_SUCCESS) && !dict_index_is_clust(index)) { + switch (err) { + case DB_SUCCESS_LOCKED_REC: + err = DB_SUCCESS; + /* fall through */ + case DB_SUCCESS: + if (dict_index_is_clust(index)) { + break; + } /* Update the page max trx id field */ page_update_max_trx_id(block, buf_block_get_page_zip(block), @@ -5218,6 +5225,10 @@ lock_clust_rec_modify_check_and_lock( ut_ad(lock_rec_queue_validate(block, rec, index, offsets)); + if (UNIV_UNLIKELY(err == DB_SUCCESS_LOCKED_REC)) { + err = DB_SUCCESS; + } + return(err); } @@ -5284,22 +5295,27 @@ lock_sec_rec_modify_check_and_lock( } #endif /* UNIV_DEBUG */ - if (err == DB_SUCCESS) { + if (err == DB_SUCCESS || err == DB_SUCCESS_LOCKED_REC) { /* Update the page max trx id field */ + /* It might not be necessary to do this if + err == DB_SUCCESS (no new lock created), + but it should not cost too much performance. */ page_update_max_trx_id(block, buf_block_get_page_zip(block), thr_get_trx(thr)->id, mtr); + err = DB_SUCCESS; } return(err); } /*********************************************************************//** -Like the counterpart for a clustered index below, but now we read a +Like lock_clust_rec_read_check_and_lock(), but reads a secondary index record. -@return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ +@return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, DB_LOCK_WAIT, DB_DEADLOCK, +or DB_QUE_THR_SUSPENDED */ UNIV_INTERN -ulint +enum db_err lock_sec_rec_read_check_and_lock( /*=============================*/ ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG @@ -5320,8 +5336,8 @@ lock_sec_rec_read_check_and_lock( LOCK_REC_NOT_GAP */ que_thr_t* thr) /*!< in: query thread */ { - ulint err; - ulint heap_no; + enum db_err err; + ulint heap_no; ut_ad(!dict_index_is_clust(index)); ut_ad(block->frame == page_align(rec)); @@ -5372,9 +5388,10 @@ if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the lock wait state and inserts a waiting request for a record lock to the lock queue. Sets the requested mode lock on the record. -@return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ +@return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, DB_LOCK_WAIT, DB_DEADLOCK, +or DB_QUE_THR_SUSPENDED */ UNIV_INTERN -ulint +enum db_err lock_clust_rec_read_check_and_lock( /*===============================*/ ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG @@ -5395,8 +5412,8 @@ lock_clust_rec_read_check_and_lock( LOCK_REC_NOT_GAP */ que_thr_t* thr) /*!< in: query thread */ { - ulint err; - ulint heap_no; + enum db_err err; + ulint heap_no; ut_ad(dict_index_is_clust(index)); ut_ad(block->frame == page_align(rec)); @@ -5467,17 +5484,22 @@ lock_clust_rec_read_check_and_lock_alt( mem_heap_t* tmp_heap = NULL; ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint* offsets = offsets_; - ulint ret; + ulint err; rec_offs_init(offsets_); offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &tmp_heap); - ret = lock_clust_rec_read_check_and_lock(flags, block, rec, index, + err = lock_clust_rec_read_check_and_lock(flags, block, rec, index, offsets, mode, gap_mode, thr); if (tmp_heap) { mem_heap_free(tmp_heap); } - return(ret); + + if (UNIV_UNLIKELY(err == DB_SUCCESS_LOCKED_REC)) { + err = DB_SUCCESS; + } + + return(err); } /*******************************************************************//** diff --git a/log/log0log.c b/log/log0log.c index 03d097d1c12..fade31037b5 100644 --- a/log/log0log.c +++ b/log/log0log.c @@ -1111,6 +1111,7 @@ log_io_complete( group = (log_group_t*)((ulint)group - 1); if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC + && srv_unix_file_flush_method != SRV_UNIX_ALL_O_DIRECT && srv_unix_file_flush_method != SRV_UNIX_NOSYNC) { fil_flush(group->space_id); @@ -1132,6 +1133,7 @@ log_io_complete( logs and cannot end up here! */ if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC + && srv_unix_file_flush_method != SRV_UNIX_ALL_O_DIRECT && srv_unix_file_flush_method != SRV_UNIX_NOSYNC && srv_flush_log_at_trx_commit != 2) { @@ -1512,7 +1514,8 @@ loop: mutex_exit(&(log_sys->mutex)); - if (srv_unix_file_flush_method == SRV_UNIX_O_DSYNC) { + if (srv_unix_file_flush_method == SRV_UNIX_O_DSYNC + || srv_unix_file_flush_method == SRV_UNIX_ALL_O_DIRECT) { /* O_DSYNC means the OS did not buffer the log file at all: so we have also flushed to disk what we have written */ diff --git a/log/log0recv.c b/log/log0recv.c index cf81a15b001..bbb634addb0 100644 --- a/log/log0recv.c +++ b/log/log0recv.c @@ -2965,9 +2965,12 @@ recv_recovery_from_checkpoint_start_func( ib_uint64_t contiguous_lsn; ib_uint64_t archived_lsn; byte* buf; - byte log_hdr_buf[LOG_FILE_HDR_SIZE]; + byte* log_hdr_buf; + byte log_hdr_buf_base[LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE]; ulint err; + log_hdr_buf = ut_align(log_hdr_buf_base, OS_FILE_LOG_BLOCK_SIZE); + #ifdef UNIV_LOG_ARCHIVE ut_ad(type != LOG_CHECKPOINT || limit_lsn == IB_ULONGLONG_MAX); /** TRUE when recovering from a checkpoint */ @@ -3325,7 +3328,6 @@ recv_recovery_from_checkpoint_finish(void) #endif /* UNIV_DEBUG */ if (recv_needed_recovery && srv_recovery_stats) { - FILE* file = stderr; ulint i; fprintf(stderr, diff --git a/os/os0file.c b/os/os0file.c index c79a41626c9..48d796c38e1 100644 --- a/os/os0file.c +++ b/os/os0file.c @@ -214,7 +214,7 @@ static os_aio_array_t* os_aio_sync_array = NULL; /*!< Synchronous I/O */ /* Per thread buffer used for merged IO requests. Used by os_aio_simulated_handle so that a buffer doesn't have to be allocated for each request. */ -static char* os_aio_thread_buffer[SRV_MAX_N_IO_THREADS]; +static byte* os_aio_thread_buffer[SRV_MAX_N_IO_THREADS]; static ulint os_aio_thread_buffer_size[SRV_MAX_N_IO_THREADS]; /** Number of asynchronous I/O segments. Set by os_aio_init(). */ @@ -1379,7 +1379,11 @@ try_again: /* When srv_file_per_table is on, file creation failure may not be critical to the whole instance. Do not crash the server in - case of unknown errors. */ + case of unknown errors. + Please note "srv_file_per_table" is a global variable with + no explicit synchronization protection. It could be + changed during this execution path. It might not have the + same value as the one when building the table definition */ if (srv_file_per_table) { retry = os_file_handle_error_no_exit(name, create_mode == OS_FILE_CREATE ? @@ -1466,7 +1470,11 @@ try_again: /* When srv_file_per_table is on, file creation failure may not be critical to the whole instance. Do not crash the server in - case of unknown errors. */ + case of unknown errors. + Please note "srv_file_per_table" is a global variable with + no explicit synchronization protection. It could be + changed during this execution path. It might not have the + same value as the one when building the table definition */ if (srv_file_per_table) { retry = os_file_handle_error_no_exit(name, create_mode == OS_FILE_CREATE ? @@ -1494,6 +1502,11 @@ try_again: os_file_set_nocache(file, name, mode_str); } + /* ALL_O_DIRECT: O_DIRECT also for transaction log file */ + if (srv_unix_file_flush_method == SRV_UNIX_ALL_O_DIRECT) { + os_file_set_nocache(file, name, mode_str); + } + #ifdef USE_FILE_LOCK if (create_mode != OS_FILE_OPEN_RAW && os_file_lock(file, name)) { diff --git a/os/os0proc.c b/os/os0proc.c index 48922886f23..8f6c7f430f7 100644 --- a/os/os0proc.c +++ b/os/os0proc.c @@ -229,3 +229,173 @@ os_mem_free_large( } #endif } + +/****************************************************************//** +Allocates or attaches and reuses shared memory segment. +The content is not cleared automatically. +@return allocated memory */ +UNIV_INTERN +void* +os_shm_alloc( +/*=========*/ + ulint* n, /*!< in/out: number of bytes */ + uint key, + ibool* is_new) +{ + void* ptr; + ulint size; + int shmid; + + *is_new = FALSE; +#if defined HAVE_SYS_IPC_H && HAVE_SYS_SHM_H + fprintf(stderr, + "InnoDB: The shared memory key %#x (%d) is specified.\n", + key, key); +# if defined HAVE_LARGE_PAGES && defined UNIV_LINUX + if (!os_use_large_pages || !os_large_page_size) { + goto skip; + } + + /* Align block size to os_large_page_size */ + ut_ad(ut_is_2pow(os_large_page_size)); + size = ut_2pow_round(*n + (os_large_page_size - 1), + os_large_page_size); + + shmid = shmget((key_t)key, (size_t)size, + IPC_CREAT | IPC_EXCL | SHM_HUGETLB | SHM_R | SHM_W); + if (shmid < 0) { + if (errno == EEXIST) { + fprintf(stderr, + "InnoDB: HugeTLB: The shared memory segment seems to exist already.\n"); + shmid = shmget((key_t)key, (size_t)size, + SHM_HUGETLB | SHM_R | SHM_W); + if (shmid < 0) { + fprintf(stderr, + "InnoDB: HugeTLB: Warning: Failed to allocate %lu bytes.(reuse) errno %d\n", + size, errno); + goto skip; + } else { + fprintf(stderr, + "InnoDB: HugeTLB: The existent shared memory segment is used.\n"); + } + } else { + fprintf(stderr, + "InnoDB: HugeTLB: Warning: Failed to allocate %lu bytes.(new) errno %d\n", + size, errno); + goto skip; + } + } else { + *is_new = TRUE; + fprintf(stderr, + "InnoDB: HugeTLB: The new shared memory segment is created.\n"); + } + + ptr = shmat(shmid, NULL, 0); + if (ptr == (void *)-1) { + fprintf(stderr, + "InnoDB: HugeTLB: Warning: Failed to attach shared memory segment, errno %d\n", + errno); + ptr = NULL; + } + + if (ptr) { + *n = size; + os_fast_mutex_lock(&ut_list_mutex); + ut_total_allocated_memory += size; + os_fast_mutex_unlock(&ut_list_mutex); + UNIV_MEM_ALLOC(ptr, size); + return(ptr); + } +skip: + *is_new = FALSE; +# endif /* HAVE_LARGE_PAGES && defined UNIV_LINUX */ +# ifdef HAVE_GETPAGESIZE + size = getpagesize(); +# else + size = UNIV_PAGE_SIZE; +# endif + /* Align block size to system page size */ + ut_ad(ut_is_2pow(size)); + size = *n = ut_2pow_round(*n + (size - 1), size); + + shmid = shmget((key_t)key, (size_t)size, + IPC_CREAT | IPC_EXCL | SHM_R | SHM_W); + if (shmid < 0) { + if (errno == EEXIST) { + fprintf(stderr, + "InnoDB: The shared memory segment seems to exist already.\n"); + shmid = shmget((key_t)key, (size_t)size, + SHM_R | SHM_W); + if (shmid < 0) { + fprintf(stderr, + "InnoDB: Warning: Failed to allocate %lu bytes.(reuse) errno %d\n", + size, errno); + ptr = NULL; + goto end; + } else { + fprintf(stderr, + "InnoDB: The existent shared memory segment is used.\n"); + } + } else { + fprintf(stderr, + "InnoDB: Warning: Failed to allocate %lu bytes.(new) errno %d\n", + size, errno); + ptr = NULL; + goto end; + } + } else { + *is_new = TRUE; + fprintf(stderr, + "InnoDB: The new shared memory segment is created.\n"); + } + + ptr = shmat(shmid, NULL, 0); + if (ptr == (void *)-1) { + fprintf(stderr, + "InnoDB: Warning: Failed to attach shared memory segment, errno %d\n", + errno); + ptr = NULL; + } + + if (ptr) { + *n = size; + os_fast_mutex_lock(&ut_list_mutex); + ut_total_allocated_memory += size; + os_fast_mutex_unlock(&ut_list_mutex); + UNIV_MEM_ALLOC(ptr, size); + } +end: +#else /* HAVE_SYS_IPC_H && HAVE_SYS_SHM_H */ + fprintf(stderr, "InnoDB: shared memory segment is not supported.\n"); + ptr = NULL; +#endif /* HAVE_SYS_IPC_H && HAVE_SYS_SHM_H */ + return(ptr); +} + +/****************************************************************//** +Detach shared memory segment. */ +UNIV_INTERN +void +os_shm_free( +/*========*/ + void *ptr, /*!< in: pointer returned by + os_shm_alloc() */ + ulint size) /*!< in: size returned by + os_shm_alloc() */ +{ + os_fast_mutex_lock(&ut_list_mutex); + ut_a(ut_total_allocated_memory >= size); + os_fast_mutex_unlock(&ut_list_mutex); + +#if defined HAVE_SYS_IPC_H && HAVE_SYS_SHM_H + if (!shmdt(ptr)) { + os_fast_mutex_lock(&ut_list_mutex); + ut_a(ut_total_allocated_memory >= size); + ut_total_allocated_memory -= size; + os_fast_mutex_unlock(&ut_list_mutex); + UNIV_MEM_FREE(ptr, size); + } +#else /* HAVE_SYS_IPC_H && HAVE_SYS_SHM_H */ + fprintf(stderr, "InnoDB: shared memory segment is not supported.\n"); +#endif /* HAVE_SYS_IPC_H && HAVE_SYS_SHM_H */ +} diff --git a/page/page0zip.c b/page/page0zip.c index c5c373781a2..a94d2d54417 100644 --- a/page/page0zip.c +++ b/page/page0zip.c @@ -571,7 +571,7 @@ page_zip_dir_encode( /* Traverse the list of stored records in the collation order, starting from the first user record. */ - rec = page + PAGE_NEW_INFIMUM, TRUE; + rec = page + PAGE_NEW_INFIMUM; i = 0; @@ -1153,6 +1153,10 @@ page_zip_compress( FILE* logfile = NULL; #endif + if (!page) { + return(FALSE); + } + ut_a(page_is_comp(page)); ut_a(fil_page_get_type(page) == FIL_PAGE_INDEX); ut_ad(page_simple_validate_new((page_t*) page)); @@ -1464,6 +1468,7 @@ page_zip_fields_free( dict_table_t* table = index->table; mem_heap_free(index->heap); mutex_free(&(table->autoinc_mutex)); + ut_free(table->name); mem_heap_free(table->heap); } } @@ -3117,8 +3122,13 @@ page_zip_validate_low( temp_page_zip in a debugger when running valgrind --db-attach. */ VALGRIND_GET_VBITS(page, temp_page, UNIV_PAGE_SIZE); UNIV_MEM_ASSERT_RW(page, UNIV_PAGE_SIZE); +# if UNIV_WORD_SIZE == 4 VALGRIND_GET_VBITS(page_zip, &temp_page_zip, sizeof temp_page_zip); + /* On 32-bit systems, there is no padding in page_zip_des_t. + On other systems, Valgrind could complain about uninitialized + pad bytes. */ UNIV_MEM_ASSERT_RW(page_zip, sizeof *page_zip); +# endif VALGRIND_GET_VBITS(page_zip->data, temp_page, page_zip_get_size(page_zip)); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); diff --git a/percona-suite/percona_innodb_buffer_pool_shm-master.opt b/percona-suite/percona_innodb_buffer_pool_shm-master.opt new file mode 100644 index 00000000000..5974ef6e2be --- /dev/null +++ b/percona-suite/percona_innodb_buffer_pool_shm-master.opt @@ -0,0 +1 @@ +--innodb_buffer_pool_shm_key=123456 diff --git a/percona-suite/percona_innodb_buffer_pool_shm.result b/percona-suite/percona_innodb_buffer_pool_shm.result new file mode 100644 index 00000000000..08ece8fb9a9 --- /dev/null +++ b/percona-suite/percona_innodb_buffer_pool_shm.result @@ -0,0 +1,6 @@ +show variables like 'innodb_buffer_pool_shm%'; +Variable_name Value +innodb_buffer_pool_shm_key 123456 +show variables like 'innodb_buffer_pool_shm%'; +Variable_name Value +innodb_buffer_pool_shm_key 123456 diff --git a/percona-suite/percona_innodb_buffer_pool_shm.test b/percona-suite/percona_innodb_buffer_pool_shm.test new file mode 100644 index 00000000000..7b81bb8d54b --- /dev/null +++ b/percona-suite/percona_innodb_buffer_pool_shm.test @@ -0,0 +1,18 @@ +--source include/have_innodb.inc +show variables like 'innodb_buffer_pool_shm%'; + +#clean shutdown (restart_mysqld.inc is not clean if over 10 sec...) +--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +wait +EOF +shutdown_server 120; +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +restart +EOF +--enable_reconnect +--source include/wait_until_connected_again.inc +--disable_reconnect + +show variables like 'innodb_buffer_pool_shm%'; +--sleep 1 +--system ipcrm -M 123456 diff --git a/percona-suite/percona_innodb_use_sys_stats_table-master.opt b/percona-suite/percona_innodb_use_sys_stats_table-master.opt new file mode 100644 index 00000000000..c6865f5704c --- /dev/null +++ b/percona-suite/percona_innodb_use_sys_stats_table-master.opt @@ -0,0 +1 @@ +--innodb_use_sys_stats_table diff --git a/percona-suite/percona_innodb_use_sys_stats_table.result b/percona-suite/percona_innodb_use_sys_stats_table.result new file mode 100644 index 00000000000..cb64de41901 --- /dev/null +++ b/percona-suite/percona_innodb_use_sys_stats_table.result @@ -0,0 +1,3 @@ +show variables like 'innodb_use_sys_stats%'; +Variable_name Value +innodb_use_sys_stats_table ON diff --git a/percona-suite/percona_innodb_use_sys_stats_table.test b/percona-suite/percona_innodb_use_sys_stats_table.test new file mode 100644 index 00000000000..02791137f08 --- /dev/null +++ b/percona-suite/percona_innodb_use_sys_stats_table.test @@ -0,0 +1,2 @@ +--source include/have_innodb.inc +show variables like 'innodb_use_sys_stats%'; diff --git a/percona-suite/percona_log_connection_error-master.opt b/percona-suite/percona_log_connection_error-master.opt new file mode 100644 index 00000000000..32a891789f3 --- /dev/null +++ b/percona-suite/percona_log_connection_error-master.opt @@ -0,0 +1 @@ +--log-error \ No newline at end of file diff --git a/percona-suite/percona_log_connection_error.result b/percona-suite/percona_log_connection_error.result new file mode 100644 index 00000000000..3c6c67f770c --- /dev/null +++ b/percona-suite/percona_log_connection_error.result @@ -0,0 +1,15 @@ +SET @old_max_connections = @@max_connections; +SET @old_log_warnings = @@log_warnings; +SET GLOBAL max_connections=2; +SET GLOBAL LOG_WARNINGS = 0; +connect(localhost,root,,test,port,socket); +ERROR HY000: Too many connections +SET GLOBAL LOG_WARNINGS = 1; +connect(localhost,root,,test,port,socket); +ERROR HY000: Too many connections +SET GLOBAL LOG_WARNINGS = 0; +connect(localhost,root,,test,port,socket); +ERROR HY000: Too many connections +SET GLOBAL max_connections = @old_max_connections; +SET GLOBAL log_warnings = @old_log_warnings; +1 diff --git a/percona-suite/percona_log_connection_error.test b/percona-suite/percona_log_connection_error.test new file mode 100644 index 00000000000..57cd652bd24 --- /dev/null +++ b/percona-suite/percona_log_connection_error.test @@ -0,0 +1,52 @@ +--source include/not_embedded.inc + +connect (main,localhost,root,,); +connection main; +SET @old_max_connections = @@max_connections; +SET @old_log_warnings = @@log_warnings; +SET GLOBAL max_connections=2; +let $port=`SELECT Variable_value FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE Variable_name LIKE 'port'`; +let $socket=`SELECT Variable_value FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE Variable_name LIKE 'socket'`; + +SET GLOBAL LOG_WARNINGS = 0; +--connect (conn0,localhost,root,,) +connection conn0; +replace_result $port port $socket socket; +--error 1040 +--connect(conn1,localhost,root,,) +disconnect conn0; +SLEEP 0.1; # tsarev: hack, but i don't know (and didn't find) how right + +connection main; +SET GLOBAL LOG_WARNINGS = 1; +--connect (conn1,localhost,root,,) +replace_result $port port $socket socket; +--error 1040 +--connect (conn0,localhost,root,,) +disconnect conn1; +SLEEP 0.1; # tsarev: hack, but i don't know (and didn't find) how right + +connection main; +SET GLOBAL LOG_WARNINGS = 0; +--connect (conn0,localhost,root,,) +replace_result $port port $socket socket; +--error 1040 +--connect(conn1,localhost,root,,) +disconnect conn0; +SLEEP 0.1; # tsarev: hack, but i don't know (and didn't find) how right + +connection main; +SET GLOBAL max_connections = @old_max_connections; +SET GLOBAL log_warnings = @old_log_warnings; +let $log_error_= `SELECT @@GLOBAL.log_error`; +if(!`select LENGTH('$log_error_')`) +{ + # MySQL Server on windows is started with --console and thus + # does not know the location of its .err log, use default location + let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.1.err; +} +# Assign env variable LOG_ERROR +let LOG_ERROR=$log_error_; + +let cmd=cat $log_error | grep "Too many connections" | wc -l; +exec $cmd; diff --git a/percona-suite/percona_query_response_time-replication.result b/percona-suite/percona_query_response_time-replication.result new file mode 100644 index 00000000000..df5c73812df --- /dev/null +++ b/percona-suite/percona_query_response_time-replication.result @@ -0,0 +1,60 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +DROP TABLE IF EXISTS t; +CREATE TABLE t(id INT); +SELECT * from t; +id +SELECT * from t; +id +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1; +Warnings: +Warning 1292 Truncated incorrect query_response_time_range_base value: '1' +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 2 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 10; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 10 +FLUSH QUERY_RESPONSE_TIME; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=ON; +INSERT INTO t VALUES(0); +SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) +0 +INSERT INTO t VALUES(1); +SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) +0 +SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) +2 +SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) +3 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 2; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 2 +FLUSH QUERY_RESPONSE_TIME; +INSERT INTO t VALUES(0); +SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) +0 +INSERT INTO t VALUES(1); +SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) +0 +SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) +2 +SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) +3 +DROP TABLE IF EXISTS t; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 10; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=OFF; diff --git a/percona-suite/percona_query_response_time-replication.test b/percona-suite/percona_query_response_time-replication.test new file mode 100644 index 00000000000..4f674c2fd19 --- /dev/null +++ b/percona-suite/percona_query_response_time-replication.test @@ -0,0 +1,52 @@ +--source include/master-slave.inc + +connection master; +-- disable_warnings +DROP TABLE IF EXISTS t; +-- enable_warnings +CREATE TABLE t(id INT); +SELECT * from t; + +sync_slave_with_master; + +connection slave; +SELECT * from t; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 10; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +source include/percona_query_response_time_flush.inc; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=ON; + +connection master; +INSERT INTO t VALUES(0); +SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +INSERT INTO t VALUES(1); +SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +sync_slave_with_master; + +connection slave; +SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; + +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 2; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +source include/percona_query_response_time_flush.inc; + +connection master; +INSERT INTO t VALUES(0); +SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +INSERT INTO t VALUES(1); +SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +sync_slave_with_master; + +connection slave; +SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; + +connection master; +DROP TABLE IF EXISTS t; +sync_slave_with_master; +connection slave; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 10; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=OFF; diff --git a/percona-suite/percona_query_response_time-stored.result b/percona-suite/percona_query_response_time-stored.result new file mode 100644 index 00000000000..386180c791a --- /dev/null +++ b/percona-suite/percona_query_response_time-stored.result @@ -0,0 +1,310 @@ +CREATE FUNCTION test_f() +RETURNS CHAR(30) DETERMINISTIC +BEGIN +DECLARE first VARCHAR(5); +DECLARE second VARCHAR(5); +DECLARE result VARCHAR(20); +SELECT SLEEP(1.11) INTO first; +SET first= 'Hello'; +SET second=', '; +SET result= CONCAT(first,second); +SET result= CONCAT(result,'world!'); +RETURN result; +END/ +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1; +Warnings: +Warning 1292 Truncated incorrect query_response_time_range_base value: '1' +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 2 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 2; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 2 +FLUSH QUERY_RESPONSE_TIME; +SELECT c.count, +(SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as not_zero_region_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count +FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as c WHERE c.count > 0; +count query_count not_zero_region_count region_count +SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +region_count +44 +SELECT time FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +time + 0.000001 + 0.000003 + 0.000007 + 0.000015 + 0.000030 + 0.000061 + 0.000122 + 0.000244 + 0.000488 + 0.000976 + 0.001953 + 0.003906 + 0.007812 + 0.015625 + 0.031250 + 0.062500 + 0.125000 + 0.250000 + 0.500000 + 1.000000 + 2.000000 + 4.000000 + 8.000000 + 16.000000 + 32.000000 + 64.000000 + 128.000000 + 256.000000 + 512.000000 + 1024.000000 + 2048.000000 + 4096.000000 + 8192.000000 + 16384.000000 + 32768.000000 + 65536.000000 + 131072.000000 + 262144.000000 + 524288.000000 + 1048576.00000 + 2097152.00000 + 4194304.00000 + 8388608.00000 +TOO LONG QUERY +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SELECT test_f(); +test_f() +Hello, world! +SELECT test_f(); +test_f() +Hello, world! +SELECT test_f(); +test_f() +Hello, world! +SELECT test_f(); +test_f() +Hello, world! +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SELECT c.count, +(SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as not_zero_region_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count +FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as c WHERE c.count > 0; +count query_count not_zero_region_count region_count +1 5 2 44 +4 5 2 44 +SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +region_count +44 +SELECT time FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +time + 0.000001 + 0.000003 + 0.000007 + 0.000015 + 0.000030 + 0.000061 + 0.000122 + 0.000244 + 0.000488 + 0.000976 + 0.001953 + 0.003906 + 0.007812 + 0.015625 + 0.031250 + 0.062500 + 0.125000 + 0.250000 + 0.500000 + 1.000000 + 2.000000 + 4.000000 + 8.000000 + 16.000000 + 32.000000 + 64.000000 + 128.000000 + 256.000000 + 512.000000 + 1024.000000 + 2048.000000 + 4096.000000 + 8192.000000 + 16384.000000 + 32768.000000 + 65536.000000 + 131072.000000 + 262144.000000 + 524288.000000 + 1048576.00000 + 2097152.00000 + 4194304.00000 + 8388608.00000 +TOO LONG QUERY +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 2 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 10; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 10 +FLUSH QUERY_RESPONSE_TIME; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SELECT test_f(); +test_f() +Hello, world! +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SELECT c.count, +(SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as not_zero_region_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count +FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as c WHERE c.count > 0; +count query_count not_zero_region_count region_count +1 2 2 14 +1 2 2 14 +SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +region_count +14 +SELECT time FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +time + 0.000001 + 0.000010 + 0.000100 + 0.001000 + 0.010000 + 0.100000 + 1.000000 + 10.000000 + 100.000000 + 1000.000000 + 10000.000000 + 100000.000000 + 1000000.00000 +TOO LONG QUERY +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 10 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 7; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 7 +FLUSH QUERY_RESPONSE_TIME; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SELECT test_f(); +test_f() +Hello, world! +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SELECT c.count, +(SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as not_zero_region_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count +FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as c WHERE c.count > 0; +count query_count not_zero_region_count region_count +1 2 2 17 +1 2 2 17 +SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +region_count +17 +SELECT time FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +time + 0.000001 + 0.000008 + 0.000059 + 0.000416 + 0.002915 + 0.020408 + 0.142857 + 1.000000 + 7.000000 + 49.000000 + 343.000000 + 2401.000000 + 16807.000000 + 117649.000000 + 823543.000000 + 5764801.00000 +TOO LONG QUERY +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 7 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 156; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 156 +FLUSH QUERY_RESPONSE_TIME; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SELECT test_f(); +test_f() +Hello, world! +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SELECT c.count, +(SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as not_zero_region_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count +FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as c WHERE c.count > 0; +count query_count not_zero_region_count region_count +1 2 2 7 +1 2 2 7 +SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +region_count +7 +SELECT time FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +time + 0.000041 + 0.006410 + 1.000000 + 156.000000 + 24336.000000 + 3796416.00000 +TOO LONG QUERY +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 156 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1000; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 1000 +FLUSH QUERY_RESPONSE_TIME; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SELECT test_f(); +test_f() +Hello, world! +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SELECT c.count, +(SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as not_zero_region_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count +FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as c WHERE c.count > 0; +count query_count not_zero_region_count region_count +1 2 2 6 +1 2 2 6 +SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +region_count +6 +SELECT time FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +time + 0.000001 + 0.001000 + 1.000000 + 1000.000000 + 1000000.00000 +TOO LONG QUERY +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 1000 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1001; +Warnings: +Warning 1292 Truncated incorrect query_response_time_range_base value: '1001' +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 1000 +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE =10; +DROP FUNCTION test_f; diff --git a/percona-suite/percona_query_response_time-stored.test b/percona-suite/percona_query_response_time-stored.test new file mode 100644 index 00000000000..f761dd7d01c --- /dev/null +++ b/percona-suite/percona_query_response_time-stored.test @@ -0,0 +1,87 @@ +source include/have_innodb.inc; + +delimiter /; +CREATE FUNCTION test_f() +RETURNS CHAR(30) DETERMINISTIC +BEGIN + DECLARE first VARCHAR(5); + DECLARE second VARCHAR(5); + DECLARE result VARCHAR(20); + SELECT SLEEP(1.11) INTO first; + SET first= 'Hello'; + SET second=', '; + SET result= CONCAT(first,second); + SET result= CONCAT(result,'world!'); + RETURN result; +END/ +delimiter ;/ + +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 2; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; + +source include/percona_query_response_time_flush.inc; +source include/percona_query_response_time_show.inc; + +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SELECT test_f(); +SELECT test_f(); +SELECT test_f(); +SELECT test_f(); +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; + +source include/percona_query_response_time_show.inc; + +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 10; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; + +source include/percona_query_response_time_flush.inc; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SELECT test_f(); +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; + +source include/percona_query_response_time_show.inc; + +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 7; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; + +source include/percona_query_response_time_flush.inc; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SELECT test_f(); +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; + +source include/percona_query_response_time_show.inc; + +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 156; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; + +source include/percona_query_response_time_flush.inc; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SELECT test_f(); +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; + +source include/percona_query_response_time_show.inc; + +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1000; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; + +source include/percona_query_response_time_flush.inc; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SELECT test_f(); +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; + +source include/percona_query_response_time_show.inc; + +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1001; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; + +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE =10; + +DROP FUNCTION test_f; \ No newline at end of file diff --git a/percona-suite/percona_query_response_time.result b/percona-suite/percona_query_response_time.result new file mode 100644 index 00000000000..3c12284a525 --- /dev/null +++ b/percona-suite/percona_query_response_time.result @@ -0,0 +1,564 @@ +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1; +Warnings: +Warning 1292 Truncated incorrect query_response_time_range_base value: '1' +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 2 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 2; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 2 +FLUSH QUERY_RESPONSE_TIME; +SELECT c.count, +(SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as not_zero_region_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count +FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as c WHERE c.count > 0; +count query_count not_zero_region_count region_count +SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +region_count +44 +SELECT time FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +time + 0.000001 + 0.000003 + 0.000007 + 0.000015 + 0.000030 + 0.000061 + 0.000122 + 0.000244 + 0.000488 + 0.000976 + 0.001953 + 0.003906 + 0.007812 + 0.015625 + 0.031250 + 0.062500 + 0.125000 + 0.250000 + 0.500000 + 1.000000 + 2.000000 + 4.000000 + 8.000000 + 16.000000 + 32.000000 + 64.000000 + 128.000000 + 256.000000 + 512.000000 + 1024.000000 + 2048.000000 + 4096.000000 + 8192.000000 + 16384.000000 + 32768.000000 + 65536.000000 + 131072.000000 + 262144.000000 + 524288.000000 + 1048576.00000 + 2097152.00000 + 4194304.00000 + 8388608.00000 +TOO LONG QUERY +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SELECT SLEEP(0.31); +SLEEP(0.31) +0 +SELECT SLEEP(0.32); +SLEEP(0.32) +0 +SELECT SLEEP(0.33); +SLEEP(0.33) +0 +SELECT SLEEP(0.34); +SLEEP(0.34) +0 +SELECT SLEEP(0.35); +SLEEP(0.35) +0 +SELECT SLEEP(0.36); +SLEEP(0.36) +0 +SELECT SLEEP(0.37); +SLEEP(0.37) +0 +SELECT SLEEP(0.38); +SLEEP(0.38) +0 +SELECT SLEEP(0.39); +SLEEP(0.39) +0 +SELECT SLEEP(0.40); +SLEEP(0.40) +0 +SELECT SLEEP(1.1); +SLEEP(1.1) +0 +SELECT SLEEP(1.2); +SLEEP(1.2) +0 +SELECT SLEEP(1.3); +SLEEP(1.3) +0 +SELECT SLEEP(1.5); +SLEEP(1.5) +0 +SELECT SLEEP(1.4); +SLEEP(1.4) +0 +SELECT SLEEP(0.5); +SLEEP(0.5) +0 +SELECT SLEEP(2.1); +SLEEP(2.1) +0 +SELECT SLEEP(2.3); +SLEEP(2.3) +0 +SELECT SLEEP(2.5); +SLEEP(2.5) +0 +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SELECT c.count, +(SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as not_zero_region_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count +FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as c WHERE c.count > 0; +count query_count not_zero_region_count region_count +1 20 5 44 +10 20 5 44 +1 20 5 44 +5 20 5 44 +3 20 5 44 +SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +region_count +44 +SELECT time FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +time + 0.000001 + 0.000003 + 0.000007 + 0.000015 + 0.000030 + 0.000061 + 0.000122 + 0.000244 + 0.000488 + 0.000976 + 0.001953 + 0.003906 + 0.007812 + 0.015625 + 0.031250 + 0.062500 + 0.125000 + 0.250000 + 0.500000 + 1.000000 + 2.000000 + 4.000000 + 8.000000 + 16.000000 + 32.000000 + 64.000000 + 128.000000 + 256.000000 + 512.000000 + 1024.000000 + 2048.000000 + 4096.000000 + 8192.000000 + 16384.000000 + 32768.000000 + 65536.000000 + 131072.000000 + 262144.000000 + 524288.000000 + 1048576.00000 + 2097152.00000 + 4194304.00000 + 8388608.00000 +TOO LONG QUERY +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 2 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 10; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 10 +FLUSH QUERY_RESPONSE_TIME; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SELECT SLEEP(0.31); +SLEEP(0.31) +0 +SELECT SLEEP(0.32); +SLEEP(0.32) +0 +SELECT SLEEP(0.33); +SLEEP(0.33) +0 +SELECT SLEEP(0.34); +SLEEP(0.34) +0 +SELECT SLEEP(0.35); +SLEEP(0.35) +0 +SELECT SLEEP(0.36); +SLEEP(0.36) +0 +SELECT SLEEP(0.37); +SLEEP(0.37) +0 +SELECT SLEEP(0.38); +SLEEP(0.38) +0 +SELECT SLEEP(0.39); +SLEEP(0.39) +0 +SELECT SLEEP(0.40); +SLEEP(0.40) +0 +SELECT SLEEP(1.1); +SLEEP(1.1) +0 +SELECT SLEEP(1.2); +SLEEP(1.2) +0 +SELECT SLEEP(1.3); +SLEEP(1.3) +0 +SELECT SLEEP(1.5); +SLEEP(1.5) +0 +SELECT SLEEP(1.4); +SLEEP(1.4) +0 +SELECT SLEEP(0.5); +SLEEP(0.5) +0 +SELECT SLEEP(2.1); +SLEEP(2.1) +0 +SELECT SLEEP(2.3); +SLEEP(2.3) +0 +SELECT SLEEP(2.5); +SLEEP(2.5) +0 +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SELECT c.count, +(SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as not_zero_region_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count +FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as c WHERE c.count > 0; +count query_count not_zero_region_count region_count +1 20 3 14 +11 20 3 14 +8 20 3 14 +SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +region_count +14 +SELECT time FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +time + 0.000001 + 0.000010 + 0.000100 + 0.001000 + 0.010000 + 0.100000 + 1.000000 + 10.000000 + 100.000000 + 1000.000000 + 10000.000000 + 100000.000000 + 1000000.00000 +TOO LONG QUERY +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 10 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 7; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 7 +FLUSH QUERY_RESPONSE_TIME; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SELECT SLEEP(0.31); +SLEEP(0.31) +0 +SELECT SLEEP(0.32); +SLEEP(0.32) +0 +SELECT SLEEP(0.33); +SLEEP(0.33) +0 +SELECT SLEEP(0.34); +SLEEP(0.34) +0 +SELECT SLEEP(0.35); +SLEEP(0.35) +0 +SELECT SLEEP(0.36); +SLEEP(0.36) +0 +SELECT SLEEP(0.37); +SLEEP(0.37) +0 +SELECT SLEEP(0.38); +SLEEP(0.38) +0 +SELECT SLEEP(0.39); +SLEEP(0.39) +0 +SELECT SLEEP(0.40); +SLEEP(0.40) +0 +SELECT SLEEP(1.1); +SLEEP(1.1) +0 +SELECT SLEEP(1.2); +SLEEP(1.2) +0 +SELECT SLEEP(1.3); +SLEEP(1.3) +0 +SELECT SLEEP(1.5); +SLEEP(1.5) +0 +SELECT SLEEP(1.4); +SLEEP(1.4) +0 +SELECT SLEEP(0.5); +SLEEP(0.5) +0 +SELECT SLEEP(2.1); +SLEEP(2.1) +0 +SELECT SLEEP(2.3); +SLEEP(2.3) +0 +SELECT SLEEP(2.5); +SLEEP(2.5) +0 +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SELECT c.count, +(SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as not_zero_region_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count +FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as c WHERE c.count > 0; +count query_count not_zero_region_count region_count +1 20 3 17 +11 20 3 17 +8 20 3 17 +SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +region_count +17 +SELECT time FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +time + 0.000001 + 0.000008 + 0.000059 + 0.000416 + 0.002915 + 0.020408 + 0.142857 + 1.000000 + 7.000000 + 49.000000 + 343.000000 + 2401.000000 + 16807.000000 + 117649.000000 + 823543.000000 + 5764801.00000 +TOO LONG QUERY +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 7 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 156; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 156 +FLUSH QUERY_RESPONSE_TIME; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SELECT SLEEP(0.31); +SLEEP(0.31) +0 +SELECT SLEEP(0.32); +SLEEP(0.32) +0 +SELECT SLEEP(0.33); +SLEEP(0.33) +0 +SELECT SLEEP(0.34); +SLEEP(0.34) +0 +SELECT SLEEP(0.35); +SLEEP(0.35) +0 +SELECT SLEEP(0.36); +SLEEP(0.36) +0 +SELECT SLEEP(0.37); +SLEEP(0.37) +0 +SELECT SLEEP(0.38); +SLEEP(0.38) +0 +SELECT SLEEP(0.39); +SLEEP(0.39) +0 +SELECT SLEEP(0.40); +SLEEP(0.40) +0 +SELECT SLEEP(1.1); +SLEEP(1.1) +0 +SELECT SLEEP(1.2); +SLEEP(1.2) +0 +SELECT SLEEP(1.3); +SLEEP(1.3) +0 +SELECT SLEEP(1.5); +SLEEP(1.5) +0 +SELECT SLEEP(1.4); +SLEEP(1.4) +0 +SELECT SLEEP(0.5); +SLEEP(0.5) +0 +SELECT SLEEP(2.1); +SLEEP(2.1) +0 +SELECT SLEEP(2.3); +SLEEP(2.3) +0 +SELECT SLEEP(2.5); +SLEEP(2.5) +0 +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SELECT c.count, +(SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as not_zero_region_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count +FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as c WHERE c.count > 0; +count query_count not_zero_region_count region_count +1 20 3 7 +11 20 3 7 +8 20 3 7 +SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +region_count +7 +SELECT time FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +time + 0.000041 + 0.006410 + 1.000000 + 156.000000 + 24336.000000 + 3796416.00000 +TOO LONG QUERY +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 156 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1000; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 1000 +FLUSH QUERY_RESPONSE_TIME; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SELECT SLEEP(0.31); +SLEEP(0.31) +0 +SELECT SLEEP(0.32); +SLEEP(0.32) +0 +SELECT SLEEP(0.33); +SLEEP(0.33) +0 +SELECT SLEEP(0.34); +SLEEP(0.34) +0 +SELECT SLEEP(0.35); +SLEEP(0.35) +0 +SELECT SLEEP(0.36); +SLEEP(0.36) +0 +SELECT SLEEP(0.37); +SLEEP(0.37) +0 +SELECT SLEEP(0.38); +SLEEP(0.38) +0 +SELECT SLEEP(0.39); +SLEEP(0.39) +0 +SELECT SLEEP(0.40); +SLEEP(0.40) +0 +SELECT SLEEP(1.1); +SLEEP(1.1) +0 +SELECT SLEEP(1.2); +SLEEP(1.2) +0 +SELECT SLEEP(1.3); +SLEEP(1.3) +0 +SELECT SLEEP(1.5); +SLEEP(1.5) +0 +SELECT SLEEP(1.4); +SLEEP(1.4) +0 +SELECT SLEEP(0.5); +SLEEP(0.5) +0 +SELECT SLEEP(2.1); +SLEEP(2.1) +0 +SELECT SLEEP(2.3); +SLEEP(2.3) +0 +SELECT SLEEP(2.5); +SLEEP(2.5) +0 +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SELECT c.count, +(SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as not_zero_region_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count +FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as c WHERE c.count > 0; +count query_count not_zero_region_count region_count +1 20 3 6 +11 20 3 6 +8 20 3 6 +SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +region_count +6 +SELECT time FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +time + 0.000001 + 0.001000 + 1.000000 + 1000.000000 + 1000000.00000 +TOO LONG QUERY +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 1000 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1001; +Warnings: +Warning 1292 Truncated incorrect query_response_time_range_base value: '1001' +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +Variable_name Value +query_response_time_range_base 1000 +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE =10; diff --git a/percona-suite/percona_query_response_time.test b/percona-suite/percona_query_response_time.test new file mode 100644 index 00000000000..a58cafc8d01 --- /dev/null +++ b/percona-suite/percona_query_response_time.test @@ -0,0 +1,65 @@ +source include/have_innodb.inc; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 2; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; + +source include/percona_query_response_time_flush.inc; +source include/percona_query_response_time_show.inc; + +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +source include/percona_query_response_time_sleep.inc; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; + +source include/percona_query_response_time_show.inc; + +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 10; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; + +source include/percona_query_response_time_flush.inc; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +source include/percona_query_response_time_sleep.inc; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; + +source include/percona_query_response_time_show.inc; + +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 7; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; + +source include/percona_query_response_time_flush.inc; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +source include/percona_query_response_time_sleep.inc; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; + +source include/percona_query_response_time_show.inc; + +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 156; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; + +source include/percona_query_response_time_flush.inc; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +source include/percona_query_response_time_sleep.inc; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; + +source include/percona_query_response_time_show.inc; + +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1000; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; + +source include/percona_query_response_time_flush.inc; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +source include/percona_query_response_time_sleep.inc; +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; + +source include/percona_query_response_time_show.inc; + +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1001; +SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; + +SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE =10; diff --git a/percona-suite/percona_query_response_time_flush.inc b/percona-suite/percona_query_response_time_flush.inc new file mode 100644 index 00000000000..44bb320fe13 --- /dev/null +++ b/percona-suite/percona_query_response_time_flush.inc @@ -0,0 +1 @@ +FLUSH QUERY_RESPONSE_TIME; diff --git a/percona-suite/percona_query_response_time_show.inc b/percona-suite/percona_query_response_time_show.inc new file mode 100644 index 00000000000..761b2c6f0df --- /dev/null +++ b/percona-suite/percona_query_response_time_show.inc @@ -0,0 +1,7 @@ +SELECT c.count, +(SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as not_zero_region_count, +(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count +FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as c WHERE c.count > 0; +SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; +SELECT time FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; diff --git a/percona-suite/percona_query_response_time_sleep.inc b/percona-suite/percona_query_response_time_sleep.inc new file mode 100644 index 00000000000..40688b173b0 --- /dev/null +++ b/percona-suite/percona_query_response_time_sleep.inc @@ -0,0 +1,19 @@ +SELECT SLEEP(0.31); +SELECT SLEEP(0.32); +SELECT SLEEP(0.33); +SELECT SLEEP(0.34); +SELECT SLEEP(0.35); +SELECT SLEEP(0.36); +SELECT SLEEP(0.37); +SELECT SLEEP(0.38); +SELECT SLEEP(0.39); +SELECT SLEEP(0.40); +SELECT SLEEP(1.1); +SELECT SLEEP(1.2); +SELECT SLEEP(1.3); +SELECT SLEEP(1.5); +SELECT SLEEP(1.4); +SELECT SLEEP(0.5); +SELECT SLEEP(2.1); +SELECT SLEEP(2.3); +SELECT SLEEP(2.5); diff --git a/percona-suite/percona_server_variables.result b/percona-suite/percona_server_variables.result new file mode 100644 index 00000000000..25f961b201f --- /dev/null +++ b/percona-suite/percona_server_variables.result @@ -0,0 +1,340 @@ +show variables; +Variable_name Value +auto_increment_increment Value +auto_increment_offset Value +autocommit Value +automatic_sp_privileges Value +back_log Value +basedir Value +big_tables Value +binlog_cache_size Value +binlog_direct_non_transactional_updates Value +binlog_format Value +bulk_insert_buffer_size Value +character_set_client Value +character_set_connection Value +character_set_database Value +character_set_filesystem Value +character_set_results Value +character_set_server Value +character_set_system Value +character_sets_dir Value +collation_connection Value +collation_database Value +collation_server Value +completion_type Value +concurrent_insert Value +connect_timeout Value +datadir Value +date_format Value +datetime_format Value +debug Value +debug_sync Value +default_week_format Value +delay_key_write Value +delayed_insert_limit Value +delayed_insert_timeout Value +delayed_queue_size Value +div_precision_increment Value +enable_query_response_time_stats Value +engine_condition_pushdown Value +error_count Value +event_scheduler Value +expire_logs_days Value +fast_index_creation Value +flush Value +flush_time Value +foreign_key_checks Value +ft_boolean_syntax Value +ft_max_word_len Value +ft_min_word_len Value +ft_query_expansion_limit Value +ft_stopword_file Value +general_log Value +general_log_file Value +group_concat_max_len Value +have_community_features Value +have_compress Value +have_crypt Value +have_csv Value +have_dynamic_loading Value +have_geometry Value +have_innodb Value +have_ndbcluster Value +have_openssl Value +have_partitioning Value +have_query_cache Value +have_rtree_keys Value +have_ssl Value +have_symlink Value +hostname Value +identity Value +ignore_builtin_innodb Value +init_connect Value +init_file Value +init_slave Value +innodb_adaptive_checkpoint Value +innodb_adaptive_flushing Value +innodb_adaptive_hash_index Value +innodb_additional_mem_pool_size Value +innodb_autoextend_increment Value +innodb_autoinc_lock_mode Value +innodb_buffer_pool_shm_key Value +innodb_buffer_pool_size Value +innodb_change_buffering Value +innodb_checkpoint_age_target Value +innodb_checksums Value +innodb_commit_concurrency Value +innodb_concurrency_tickets Value +innodb_data_file_path Value +innodb_data_home_dir Value +innodb_dict_size_limit Value +innodb_doublewrite Value +innodb_doublewrite_file Value +innodb_enable_unsafe_group_commit Value +innodb_expand_import Value +innodb_extra_rsegments Value +innodb_extra_undoslots Value +innodb_fast_checksum Value +innodb_fast_recovery Value +innodb_fast_shutdown Value +innodb_file_format Value +innodb_file_format_check Value +innodb_file_per_table Value +innodb_flush_log_at_trx_commit Value +innodb_flush_log_at_trx_commit_session Value +innodb_flush_method Value +innodb_flush_neighbor_pages Value +innodb_force_recovery Value +innodb_ibuf_accel_rate Value +innodb_ibuf_active_contract Value +innodb_ibuf_max_size Value +innodb_io_capacity Value +innodb_lock_wait_timeout Value +innodb_locks_unsafe_for_binlog Value +innodb_log_buffer_size Value +innodb_log_file_size Value +innodb_log_files_in_group Value +innodb_log_group_home_dir Value +innodb_max_dirty_pages_pct Value +innodb_max_purge_lag Value +innodb_mirrored_log_groups Value +innodb_old_blocks_pct Value +innodb_old_blocks_time Value +innodb_open_files Value +innodb_overwrite_relay_log_info Value +innodb_page_size Value +innodb_pass_corrupt_table Value +innodb_read_ahead Value +innodb_read_ahead_threshold Value +innodb_read_io_threads Value +innodb_recovery_stats Value +innodb_replication_delay Value +innodb_rollback_on_timeout Value +innodb_show_locks_held Value +innodb_show_verbose_locks Value +innodb_spin_wait_delay Value +innodb_stats_auto_update Value +innodb_stats_method Value +innodb_stats_on_metadata Value +innodb_stats_sample_pages Value +innodb_stats_update_need_lock Value +innodb_strict_mode Value +innodb_support_xa Value +innodb_sync_spin_loops Value +innodb_table_locks Value +innodb_thread_concurrency Value +innodb_thread_concurrency_timer_based Value +innodb_thread_sleep_delay Value +innodb_use_purge_thread Value +innodb_use_sys_malloc Value +innodb_use_sys_stats_table Value +innodb_version Value +innodb_write_io_threads Value +insert_id Value +interactive_timeout Value +join_buffer_size Value +keep_files_on_create Value +key_buffer_size Value +key_cache_age_threshold Value +key_cache_block_size Value +key_cache_division_limit Value +language Value +large_files_support Value +large_page_size Value +large_pages Value +last_insert_id Value +lc_time_names Value +license Value +local_infile Value +locked_in_memory Value +log Value +log_bin Value +log_bin_trust_function_creators Value +log_bin_trust_routine_creators Value +log_error Value +log_output Value +log_queries_not_using_indexes Value +log_slave_updates Value +log_slow_filter Value +log_slow_queries Value +log_slow_rate_limit Value +log_slow_slave_statements Value +log_slow_sp_statements Value +log_slow_timestamp_every Value +log_slow_verbosity Value +log_warnings Value +long_query_time Value +low_priority_updates Value +lower_case_file_system Value +lower_case_table_names Value +max_allowed_packet Value +max_binlog_cache_size Value +max_binlog_size Value +max_connect_errors Value +max_connections Value +max_delayed_threads Value +max_error_count Value +max_heap_table_size Value +max_insert_delayed_threads Value +max_join_size Value +max_length_for_sort_data Value +max_prepared_stmt_count Value +max_relay_log_size Value +max_seeks_for_key Value +max_sort_length Value +max_sp_recursion_depth Value +max_tmp_tables Value +max_user_connections Value +max_write_lock_count Value +min_examined_row_limit Value +multi_range_count Value +myisam_data_pointer_size Value +myisam_max_sort_file_size Value +myisam_mmap_size Value +myisam_recover_options Value +myisam_repair_threads Value +myisam_sort_buffer_size Value +myisam_stats_method Value +myisam_use_mmap Value +net_buffer_length Value +net_read_timeout Value +net_retry_count Value +net_write_timeout Value +new Value +old Value +old_alter_table Value +old_passwords Value +open_files_limit Value +optimizer_fix Value +optimizer_prune_level Value +optimizer_search_depth Value +optimizer_switch Value +pid_file Value +plugin_dir Value +port Value +preload_buffer_size Value +profiling Value +profiling_history_size Value +profiling_server Value +profiling_use_getrusage Value +protocol_version Value +pseudo_thread_id Value +query_alloc_block_size Value +query_cache_limit Value +query_cache_min_res_unit Value +query_cache_size Value +query_cache_strip_comments Value +query_cache_type Value +query_cache_wlock_invalidate Value +query_prealloc_size Value +query_response_time_range_base Value +rand_seed1 Value +rand_seed2 Value +range_alloc_block_size Value +read_buffer_size Value +read_only Value +read_rnd_buffer_size Value +relay_log Value +relay_log_index Value +relay_log_info_file Value +relay_log_purge Value +relay_log_space_limit Value +report_host Value +report_password Value +report_port Value +report_user Value +rpl_recovery_rank Value +secure_auth Value +secure_file_priv Value +server_id Value +skip_external_locking Value +skip_name_resolve Value +skip_networking Value +skip_show_database Value +slave_compressed_protocol Value +slave_exec_mode Value +slave_load_tmpdir Value +slave_net_timeout Value +slave_skip_errors Value +slave_transaction_retries Value +slow_launch_time Value +slow_query_log Value +slow_query_log_file Value +slow_query_log_microseconds_timestamp Value +socket Value +sort_buffer_size Value +sql_auto_is_null Value +sql_big_selects Value +sql_big_tables Value +sql_buffer_result Value +sql_log_bin Value +sql_log_off Value +sql_log_update Value +sql_low_priority_updates Value +sql_max_join_size Value +sql_mode Value +sql_notes Value +sql_quote_show_create Value +sql_safe_updates Value +sql_select_limit Value +sql_slave_skip_counter Value +sql_warnings Value +ssl_ca Value +ssl_capath Value +ssl_cert Value +ssl_cipher Value +ssl_key Value +storage_engine Value +suppress_log_warning_1592 Value +sync_binlog Value +sync_frm Value +system_time_zone Value +table_definition_cache Value +table_lock_wait_timeout Value +table_open_cache Value +table_type Value +thread_cache_size Value +thread_handling Value +thread_stack Value +thread_statistics Value +time_format Value +time_zone Value +timed_mutexes Value +timestamp Value +tmp_table_size Value +tmpdir Value +transaction_alloc_block_size Value +transaction_prealloc_size Value +tx_isolation Value +unique_checks Value +updatable_views_with_limit Value +use_global_log_slow_control Value +use_global_long_query_time Value +userstat_running Value +version Value +version_comment Value +version_compile_machine Value +version_compile_os Value +wait_timeout Value +warning_count Value diff --git a/percona-suite/percona_server_variables.test b/percona-suite/percona_server_variables.test new file mode 100644 index 00000000000..232cbb15e25 --- /dev/null +++ b/percona-suite/percona_server_variables.test @@ -0,0 +1,7 @@ +--source include/have_innodb.inc +--source include/have_debug.inc + +#check the list of variable names +--replace_column 2 Value +show variables; + diff --git a/percona-suite/percona_slave_innodb_stats-master.opt b/percona-suite/percona_slave_innodb_stats-master.opt new file mode 100644 index 00000000000..286a9c4484d --- /dev/null +++ b/percona-suite/percona_slave_innodb_stats-master.opt @@ -0,0 +1 @@ +--long_query_time=0 --log_slow_verbosity=innodb --log_slow_slave_statements diff --git a/percona-suite/percona_slave_innodb_stats-slave.opt b/percona-suite/percona_slave_innodb_stats-slave.opt new file mode 100644 index 00000000000..286a9c4484d --- /dev/null +++ b/percona-suite/percona_slave_innodb_stats-slave.opt @@ -0,0 +1 @@ +--long_query_time=0 --log_slow_verbosity=innodb --log_slow_slave_statements diff --git a/percona-suite/percona_slave_innodb_stats.result b/percona-suite/percona_slave_innodb_stats.result new file mode 100644 index 00000000000..c2406bdfd85 --- /dev/null +++ b/percona-suite/percona_slave_innodb_stats.result @@ -0,0 +1,21 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +DROP TABLE IF EXISTS t; +CREATE TABLE t(id INT,data CHAR(30)) ENGINE=InnoDB; +INSERT INTO t VALUES +(1,"aaaaabbbbbcccccdddddeeeeefffff"), +(2,"aaaaabbbbbcccccdddddeeeeefffff"), +(3,"aaaaabbbbbcccccdddddeeeeefffff"), +(4,"aaaaabbbbbcccccdddddeeeeefffff"), +(5,"aaaaabbbbbcccccdddddeeeeefffff"); +INSERT INTO t SELECT t2.id,t2.data from t as t1, t as t2; +INSERT INTO t SELECT t2.id,t2.data from t as t1, t as t2; +STOP SLAVE; +START SLAVE; +INSERT INTO t SELECT t.id,t.data from t; +DROP TABLE IF EXISTS t; +4 diff --git a/percona-suite/percona_slave_innodb_stats.test b/percona-suite/percona_slave_innodb_stats.test new file mode 100644 index 00000000000..defcd1fc406 --- /dev/null +++ b/percona-suite/percona_slave_innodb_stats.test @@ -0,0 +1,43 @@ +source include/have_innodb.inc; +source include/master-slave.inc; + +connection master; +-- disable_warnings +DROP TABLE IF EXISTS t; +-- enable_warnings +CREATE TABLE t(id INT,data CHAR(30)) ENGINE=InnoDB; +INSERT INTO t VALUES +(1,"aaaaabbbbbcccccdddddeeeeefffff"), +(2,"aaaaabbbbbcccccdddddeeeeefffff"), +(3,"aaaaabbbbbcccccdddddeeeeefffff"), +(4,"aaaaabbbbbcccccdddddeeeeefffff"), +(5,"aaaaabbbbbcccccdddddeeeeefffff"); +INSERT INTO t SELECT t2.id,t2.data from t as t1, t as t2; +INSERT INTO t SELECT t2.id,t2.data from t as t1, t as t2; +sync_slave_with_master; + +connection slave; +STOP SLAVE; +-- source include/wait_for_slave_to_stop.inc +--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +wait +EOF +--shutdown_server 10 +--source include/wait_until_disconnected.inc +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +restart +EOF +--enable_reconnect +--source include/wait_until_connected_again.inc +START SLAVE; +-- source include/wait_for_slave_to_start.inc + +connection master; +INSERT INTO t SELECT t.id,t.data from t; +sync_slave_with_master; + +connection master; +DROP TABLE IF EXISTS t; +sync_slave_with_master; + +exec cat var/mysqld.2/mysqld-slow.log | grep InnoDB_IO_r_ops | wc -l; diff --git a/percona-suite/percona_slow_query_log-use_global_long_query_time.result b/percona-suite/percona_slow_query_log-use_global_long_query_time.result index 7c1e840e137..5562c1543bd 100644 --- a/percona-suite/percona_slow_query_log-use_global_long_query_time.result +++ b/percona-suite/percona_slow_query_log-use_global_long_query_time.result @@ -22,3 +22,38 @@ set global long_query_time=2; set global use_global_long_query_time=0; cat var/mysqld.1/data/percona_slow_query_log-use_global_long_query_time.log | grep Query_time | wc -l 3 +show global variables like 'use_global_log_slow_control'; +Variable_name Value +use_global_log_slow_control none +show global variables like 'use_global_long_query_time'; +Variable_name Value +use_global_long_query_time OFF +set global use_global_log_slow_control = long_query_time; +show global variables like 'use_global_log_slow_control'; +Variable_name Value +use_global_log_slow_control long_query_time +show global variables like 'use_global_long_query_time'; +Variable_name Value +use_global_long_query_time ON +set global use_global_log_slow_control = log_slow_filter; +show global variables like 'use_global_log_slow_control'; +Variable_name Value +use_global_log_slow_control log_slow_filter +show global variables like 'use_global_long_query_time'; +Variable_name Value +use_global_long_query_time OFF +set global use_global_long_query_time = ON; +show global variables like 'use_global_log_slow_control'; +Variable_name Value +use_global_log_slow_control log_slow_filter,long_query_time +show global variables like 'use_global_long_query_time'; +Variable_name Value +use_global_long_query_time ON +set global use_global_long_query_time = OFF; +show global variables like 'use_global_log_slow_control'; +Variable_name Value +use_global_log_slow_control log_slow_filter +show global variables like 'use_global_long_query_time'; +Variable_name Value +use_global_long_query_time OFF +set global use_global_log_slow_control = none; diff --git a/percona-suite/percona_slow_query_log-use_global_long_query_time.test b/percona-suite/percona_slow_query_log-use_global_long_query_time.test index 81fd8f7082c..95700c4289e 100644 --- a/percona-suite/percona_slow_query_log-use_global_long_query_time.test +++ b/percona-suite/percona_slow_query_log-use_global_long_query_time.test @@ -17,3 +17,24 @@ set global use_global_long_query_time=0; let $cmd = cat var/mysqld.1/data/percona_slow_query_log-use_global_long_query_time.log | grep Query_time | wc -l; echo $cmd; exec $cmd; + +show global variables like 'use_global_log_slow_control'; +show global variables like 'use_global_long_query_time'; + +set global use_global_log_slow_control = long_query_time; +show global variables like 'use_global_log_slow_control'; +show global variables like 'use_global_long_query_time'; + +set global use_global_log_slow_control = log_slow_filter; +show global variables like 'use_global_log_slow_control'; +show global variables like 'use_global_long_query_time'; + +set global use_global_long_query_time = ON; +show global variables like 'use_global_log_slow_control'; +show global variables like 'use_global_long_query_time'; + +set global use_global_long_query_time = OFF; +show global variables like 'use_global_log_slow_control'; +show global variables like 'use_global_long_query_time'; + +set global use_global_log_slow_control = none; diff --git a/percona-suite/percona_sql_no_fcache.result b/percona-suite/percona_sql_no_fcache.result new file mode 100644 index 00000000000..bc1413fb96d --- /dev/null +++ b/percona-suite/percona_sql_no_fcache.result @@ -0,0 +1,12 @@ +drop table if exists t1; +create table t (a int not null); +insert into t values (1),(2),(3); +SELECT SQL_NO_FCACHE SLEEP(0); +SLEEP(0) +0 +SELECT /*!40001 SQL_NO_CACHE */ /*!50084 SQL_NO_FCACHE */ * FROM t; +a +1 +2 +3 +DROP TABLE t; diff --git a/percona-suite/percona_sql_no_fcache.test b/percona-suite/percona_sql_no_fcache.test new file mode 100644 index 00000000000..da0c2ecef7d --- /dev/null +++ b/percona-suite/percona_sql_no_fcache.test @@ -0,0 +1,11 @@ +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t (a int not null); +insert into t values (1),(2),(3); + +SELECT SQL_NO_FCACHE SLEEP(0); +SELECT /*!40001 SQL_NO_CACHE */ /*!50084 SQL_NO_FCACHE */ * FROM t; + +DROP TABLE t; \ No newline at end of file diff --git a/percona-suite/percona_status_wait_query_cache_mutex.result b/percona-suite/percona_status_wait_query_cache_mutex.result new file mode 100644 index 00000000000..348dcef4d30 --- /dev/null +++ b/percona-suite/percona_status_wait_query_cache_mutex.result @@ -0,0 +1,27 @@ +set GLOBAL query_cache_size=1355776; +flush query cache; +flush query cache; +reset query cache; +flush status; +DROP TABLE IF EXISTS t; +CREATE TABLE t(id INT, number INT); +INSERT INTO t VALUES (0,1); +INSERT INTO t VALUES (1,2); +INSERT INTO t VALUES (2,3); +SELECT number from t where id > 0; +number +2 +3 +SET SESSION debug="+d,status_wait_query_cache_mutex_sleep"; +SELECT number from t where id > 0; +SET SESSION debug="+d,status_wait_query_cache_mutex_sleep"; +SELECT number from t where id > 0; +SET SESSION debug="+d,status_wait_query_cache_mutex_sleep"; +SHOW PROCESSLIST; +Id User Host db Command Time State Info +Id root localhost test Sleep Time NULL +Id root localhost test Query Time Waiting on query cache mutex SELECT number from t where id > 0 +Id root localhost test Query Time Waiting on query cache mutex SELECT number from t where id > 0 +Id root localhost test Query Time NULL SHOW PROCESSLIST +DROP TABLE t; +set GLOBAL query_cache_size=0; diff --git a/percona-suite/percona_status_wait_query_cache_mutex.test b/percona-suite/percona_status_wait_query_cache_mutex.test new file mode 100644 index 00000000000..64a9fe7db71 --- /dev/null +++ b/percona-suite/percona_status_wait_query_cache_mutex.test @@ -0,0 +1,37 @@ +--source include/have_query_cache.inc +--source include/have_debug.inc +set GLOBAL query_cache_size=1355776; +--source include/percona_query_cache_with_comments_clear.inc + +-- disable_warnings +DROP TABLE IF EXISTS t; +-- enable_warnings +CREATE TABLE t(id INT, number INT); +INSERT INTO t VALUES (0,1); +INSERT INTO t VALUES (1,2); +INSERT INTO t VALUES (2,3); +SELECT number from t where id > 0; +--connect (conn0,localhost,root,,) +--connect (conn1,localhost,root,,) +--connect (conn2,localhost,root,,) + +--connection conn0 +--error 0, ER_UNKNOWN_SYSTEM_VARIABLE +SET SESSION debug="+d,status_wait_query_cache_mutex_sleep"; +SEND SELECT number from t where id > 0; +SLEEP 1.0; + +--connection conn1 +--error 0, ER_UNKNOWN_SYSTEM_VARIABLE +SET SESSION debug="+d,status_wait_query_cache_mutex_sleep"; +SEND SELECT number from t where id > 0; +SLEEP 1.0; + +--connection conn2 +--error 0, ER_UNKNOWN_SYSTEM_VARIABLE +SET SESSION debug="+d,status_wait_query_cache_mutex_sleep"; +--replace_column 1 Id 6 Time +SHOW PROCESSLIST; + +DROP TABLE t; +set GLOBAL query_cache_size=0; \ No newline at end of file diff --git a/percona-suite/percona_xtradb_bug317074.test b/percona-suite/percona_xtradb_bug317074.test index 757ac87bf18..af990cf749b 100644 --- a/percona-suite/percona_xtradb_bug317074.test +++ b/percona-suite/percona_xtradb_bug317074.test @@ -21,15 +21,18 @@ CREATE PROCEDURE insert_many(p1 int) BEGIN SET @x = 0; SET @y = 0; +start transaction; REPEAT insert into test1 set b=1; SET @x = @x + 1; SET @y = @y + 1; - IF @y >= 100 THEN + IF @y >= 1000 THEN commit; + start transaction; SET @y = 0; END IF; UNTIL @x >= p1 END REPEAT; +commit; END| delimiter ;| call insert_many(100000); diff --git a/que/que0que.c b/que/que0que.c index 2fe046fa9b8..5c85a04d139 100644 --- a/que/que0que.c +++ b/que/que0que.c @@ -622,10 +622,20 @@ que_graph_free_recursive( que_graph_free_recursive(cre_ind->ind_def); que_graph_free_recursive(cre_ind->field_def); + if (srv_use_sys_stats_table) + que_graph_free_recursive(cre_ind->stats_def); que_graph_free_recursive(cre_ind->commit_node); mem_heap_free(cre_ind->heap); + break; + case QUE_NODE_INSERT_STATS: + cre_ind = node; + + que_graph_free_recursive(cre_ind->stats_def); + que_graph_free_recursive(cre_ind->commit_node); + + mem_heap_free(cre_ind->heap); break; case QUE_NODE_PROC: que_graph_free_stat_list(((proc_node_t*)node)->stat_list); @@ -1139,6 +1149,8 @@ que_node_print_info( str = "CREATE TABLE"; } else if (type == QUE_NODE_CREATE_INDEX) { str = "CREATE INDEX"; + } else if (type == QUE_NODE_INSERT_STATS) { + str = "INSERT TO SYS_STATS"; } else if (type == QUE_NODE_FOR) { str = "FOR LOOP"; } else if (type == QUE_NODE_RETURN) { @@ -1256,6 +1268,8 @@ que_thr_step( thr = dict_create_table_step(thr); } else if (type == QUE_NODE_CREATE_INDEX) { thr = dict_create_index_step(thr); + } else if (type == QUE_NODE_INSERT_STATS) { + thr = dict_insert_stats_step(thr); } else if (type == QUE_NODE_ROW_PRINTF) { thr = row_printf_step(thr); } else { diff --git a/rem/rem0cmp.c b/rem/rem0cmp.c index 45230f1d7b1..8ee434f85da 100644 --- a/rem/rem0cmp.c +++ b/rem/rem0cmp.c @@ -706,7 +706,9 @@ cmp_rec_rec_simple( const rec_t* rec2, /*!< in: physical record */ const ulint* offsets1,/*!< in: rec_get_offsets(rec1, ...) */ const ulint* offsets2,/*!< in: rec_get_offsets(rec2, ...) */ - const dict_index_t* index) /*!< in: data dictionary index */ + const dict_index_t* index, /*!< in: data dictionary index */ + ibool* null_eq)/*!< out: set to TRUE if + found matching null values */ { ulint rec1_f_len; /*!< length of current field in rec1 */ const byte* rec1_b_ptr; /*!< pointer to the current byte @@ -753,6 +755,9 @@ cmp_rec_rec_simple( || rec2_f_len == UNIV_SQL_NULL) { if (rec1_f_len == rec2_f_len) { + if (null_eq) { + *null_eq = TRUE; + } goto next_field; diff --git a/row/row0ins.c b/row/row0ins.c index d7475d613ad..d4925e46f97 100644 --- a/row/row0ins.c +++ b/row/row0ins.c @@ -51,6 +51,15 @@ Created 4/20/1996 Heikki Tuuri #define ROW_INS_PREV 1 #define ROW_INS_NEXT 2 +/************************************************************************* +IMPORTANT NOTE: Any operation that generates redo MUST check that there +is enough space in the redo log before for that operation. This is +done by calling log_free_check(). The reason for checking the +availability of the redo log space before the start of the operation is +that we MUST not hold any synchonization objects when performing the +check. +If you make a change in this module make sure that no codepath is +introduced where a call to log_free_check() is bypassed. */ /*********************************************************************//** Creates an insert node struct. @@ -1121,9 +1130,9 @@ nonstandard_exit_func: /*********************************************************************//** Sets a shared lock on a record. Used in locking possible duplicate key records and also in checking foreign key constraints. -@return DB_SUCCESS or error code */ +@return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, or error code */ static -ulint +enum db_err row_ins_set_shared_rec_lock( /*========================*/ ulint type, /*!< in: LOCK_ORDINARY, LOCK_GAP, or @@ -1134,7 +1143,7 @@ row_ins_set_shared_rec_lock( const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ que_thr_t* thr) /*!< in: query thread */ { - ulint err; + enum db_err err; ut_ad(rec_offs_validate(rec, index, offsets)); @@ -1152,9 +1161,9 @@ row_ins_set_shared_rec_lock( /*********************************************************************//** Sets a exclusive lock on a record. Used in locking possible duplicate key records -@return DB_SUCCESS or error code */ +@return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, or error code */ static -ulint +enum db_err row_ins_set_exclusive_rec_lock( /*===========================*/ ulint type, /*!< in: LOCK_ORDINARY, LOCK_GAP, or @@ -1165,7 +1174,7 @@ row_ins_set_exclusive_rec_lock( const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ que_thr_t* thr) /*!< in: query thread */ { - ulint err; + enum db_err err; ut_ad(rec_offs_validate(rec, index, offsets)); @@ -1205,7 +1214,6 @@ row_ins_check_foreign_constraint( dict_index_t* check_index; ulint n_fields_cmp; btr_pcur_t pcur; - ibool moved; int cmp; ulint err; ulint i; @@ -1336,7 +1344,7 @@ run_again: /* Scan index records and check if there is a matching record */ - for (;;) { + do { const rec_t* rec = btr_pcur_get_rec(&pcur); const buf_block_t* block = btr_pcur_get_block(&pcur); @@ -1348,7 +1356,7 @@ run_again: if (page_rec_is_infimum(rec)) { - goto next_rec; + continue; } offsets = rec_get_offsets(rec, check_index, @@ -1359,12 +1367,13 @@ run_again: err = row_ins_set_shared_rec_lock(LOCK_ORDINARY, block, rec, check_index, offsets, thr); - if (err != DB_SUCCESS) { - - break; + switch (err) { + case DB_SUCCESS_LOCKED_REC: + case DB_SUCCESS: + continue; + default: + goto end_scan; } - - goto next_rec; } cmp = cmp_dtuple_rec(entry, rec, offsets); @@ -1375,9 +1384,12 @@ run_again: err = row_ins_set_shared_rec_lock( LOCK_ORDINARY, block, rec, check_index, offsets, thr); - if (err != DB_SUCCESS) { - + switch (err) { + case DB_SUCCESS_LOCKED_REC: + case DB_SUCCESS: break; + default: + goto end_scan; } } else { /* Found a matching record. Lock only @@ -1388,15 +1400,18 @@ run_again: LOCK_REC_NOT_GAP, block, rec, check_index, offsets, thr); - if (err != DB_SUCCESS) { - + switch (err) { + case DB_SUCCESS_LOCKED_REC: + case DB_SUCCESS: break; + default: + goto end_scan; } if (check_ref) { err = DB_SUCCESS; - break; + goto end_scan; } else if (foreign->type != 0) { /* There is an ON UPDATE or ON DELETE condition: check them in a separate @@ -1422,7 +1437,7 @@ run_again: err = DB_FOREIGN_DUPLICATE_KEY; } - break; + goto end_scan; } /* row_ins_foreign_check_on_constraint @@ -1435,49 +1450,41 @@ run_again: thr, foreign, rec, entry); err = DB_ROW_IS_REFERENCED; - break; + goto end_scan; } } - } + } else { + ut_a(cmp < 0); - if (cmp < 0) { err = row_ins_set_shared_rec_lock( LOCK_GAP, block, rec, check_index, offsets, thr); - if (err != DB_SUCCESS) { - break; + switch (err) { + case DB_SUCCESS_LOCKED_REC: + case DB_SUCCESS: + if (check_ref) { + err = DB_NO_REFERENCED_ROW; + row_ins_foreign_report_add_err( + trx, foreign, rec, entry); + } else { + err = DB_SUCCESS; + } } - if (check_ref) { - err = DB_NO_REFERENCED_ROW; - row_ins_foreign_report_add_err( - trx, foreign, rec, entry); - } else { - err = DB_SUCCESS; - } - - break; + goto end_scan; } + } while (btr_pcur_move_to_next(&pcur, &mtr)); - ut_a(cmp == 0); -next_rec: - moved = btr_pcur_move_to_next(&pcur, &mtr); - - if (!moved) { - if (check_ref) { - rec = btr_pcur_get_rec(&pcur); - row_ins_foreign_report_add_err( - trx, foreign, rec, entry); - err = DB_NO_REFERENCED_ROW; - } else { - err = DB_SUCCESS; - } - - break; - } + if (check_ref) { + row_ins_foreign_report_add_err( + trx, foreign, btr_pcur_get_rec(&pcur), entry); + err = DB_NO_REFERENCED_ROW; + } else { + err = DB_SUCCESS; } +end_scan: btr_pcur_close(&pcur); mtr_commit(&mtr); @@ -1725,9 +1732,13 @@ row_ins_scan_sec_index_for_duplicate( rec, index, offsets, thr); } - if (err != DB_SUCCESS) { - + switch (err) { + case DB_SUCCESS_LOCKED_REC: + err = DB_SUCCESS; + case DB_SUCCESS: break; + default: + goto end_scan; } if (page_rec_is_supremum(rec)) { @@ -1744,17 +1755,15 @@ row_ins_scan_sec_index_for_duplicate( thr_get_trx(thr)->error_info = index; - break; + goto end_scan; } + } else { + ut_a(cmp < 0); + goto end_scan; } - - if (cmp < 0) { - break; - } - - ut_a(cmp == 0); } while (btr_pcur_move_to_next(&pcur, &mtr)); +end_scan: if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } @@ -1843,7 +1852,11 @@ row_ins_duplicate_error_in_clust( cursor->index, offsets, thr); } - if (err != DB_SUCCESS) { + switch (err) { + case DB_SUCCESS_LOCKED_REC: + case DB_SUCCESS: + break; + default: goto func_exit; } @@ -1883,7 +1896,11 @@ row_ins_duplicate_error_in_clust( rec, cursor->index, offsets, thr); } - if (err != DB_SUCCESS) { + switch (err) { + case DB_SUCCESS_LOCKED_REC: + case DB_SUCCESS: + break; + default: goto func_exit; } diff --git a/row/row0merge.c b/row/row0merge.c index 6ee93d24ed3..47c03c77850 100644 --- a/row/row0merge.c +++ b/row/row0merge.c @@ -717,14 +717,16 @@ row_merge_read( } /********************************************************************//** -Read a merge block from the file system. +Write a merge block to the file system. @return TRUE if request was successful, FALSE if fail */ static ibool row_merge_write( /*============*/ int fd, /*!< in: file descriptor */ - ulint offset, /*!< in: offset where to write */ + ulint offset, /*!< in: offset where to read + in number of row_merge_block_t + elements */ const void* buf) /*!< in: data */ { ib_uint64_t ofs = ((ib_uint64_t) offset) @@ -1075,11 +1077,14 @@ row_merge_cmp( record to be compared */ const ulint* offsets1, /*!< in: first record offsets */ const ulint* offsets2, /*!< in: second record offsets */ - const dict_index_t* index) /*!< in: index */ + const dict_index_t* index, /*!< in: index */ + ibool* null_eq) /*!< out: set to TRUE if + found matching null values */ { int cmp; - cmp = cmp_rec_rec_simple(mrec1, mrec2, offsets1, offsets2, index); + cmp = cmp_rec_rec_simple(mrec1, mrec2, offsets1, offsets2, index, + null_eq); #ifdef UNIV_DEBUG if (row_merge_print_cmp) { @@ -1452,11 +1457,13 @@ corrupt: } while (mrec0 && mrec1) { + ibool null_eq = FALSE; switch (row_merge_cmp(mrec0, mrec1, - offsets0, offsets1, index)) { + offsets0, offsets1, index, + &null_eq)) { case 0: if (UNIV_UNLIKELY - (dict_index_is_unique(index))) { + (dict_index_is_unique(index) && !null_eq)) { innobase_rec_to_mysql(table, mrec0, index, offsets0); mem_heap_free(heap); @@ -1578,22 +1585,28 @@ row_merge( const dict_index_t* index, /*!< in: index being created */ merge_file_t* file, /*!< in/out: file containing index entries */ - ulint* half, /*!< in/out: half the file */ row_merge_block_t* block, /*!< in/out: 3 buffers */ int* tmpfd, /*!< in/out: temporary file handle */ - TABLE* table) /*!< in/out: MySQL table, for + TABLE* table, /*!< in/out: MySQL table, for reporting erroneous key value if applicable */ + ulint* num_run,/*!< in/out: Number of runs remain + to be merged */ + ulint* run_offset) /*!< in/out: Array contains the + first offset number for each merge + run */ { ulint foffs0; /*!< first input offset */ ulint foffs1; /*!< second input offset */ ulint error; /*!< error code */ merge_file_t of; /*!< output file */ - const ulint ihalf = *half; + const ulint ihalf = run_offset[*num_run / 2]; /*!< half the input file */ - ulint ohalf; /*!< half the output file */ + ulint n_run = 0; + /*!< num of runs generated from this merge */ UNIV_MEM_ASSERT_W(block[0], 3 * sizeof block[0]); + ut_ad(ihalf < file->offset); of.fd = *tmpfd; @@ -1601,17 +1614,20 @@ row_merge( of.n_rec = 0; /* Merge blocks to the output file. */ - ohalf = 0; foffs0 = 0; foffs1 = ihalf; + UNIV_MEM_INVALID(run_offset, *num_run * sizeof *run_offset); + for (; foffs0 < ihalf && foffs1 < file->offset; foffs0++, foffs1++) { - ulint ahalf; /*!< arithmetic half the input file */ if (UNIV_UNLIKELY(trx_is_interrupted(trx))) { return(DB_INTERRUPTED); } + /* Remember the offset number for this run */ + run_offset[n_run++] = of.offset; + error = row_merge_blocks(index, file, block, &foffs0, &foffs1, &of, table); @@ -1619,21 +1635,6 @@ row_merge( return(error); } - /* Record the offset of the output file when - approximately half the output has been generated. In - this way, the next invocation of row_merge() will - spend most of the time in this loop. The initial - estimate is ohalf==0. */ - ahalf = file->offset / 2; - ut_ad(ohalf <= of.offset); - - /* Improve the estimate until reaching half the input - file size, or we can not get any closer to it. All - comparands should be non-negative when !(ohalf < ahalf) - because ohalf <= of.offset. */ - if (ohalf < ahalf || of.offset - ahalf < ohalf - ahalf) { - ohalf = of.offset; - } } /* Copy the last blocks, if there are any. */ @@ -1643,6 +1644,9 @@ row_merge( return(DB_INTERRUPTED); } + /* Remember the offset number for this run */ + run_offset[n_run++] = of.offset; + if (!row_merge_blocks_copy(index, file, block, &foffs0, &of)) { return(DB_CORRUPTION); } @@ -1655,6 +1659,9 @@ row_merge( return(DB_INTERRUPTED); } + /* Remember the offset number for this run */ + run_offset[n_run++] = of.offset; + if (!row_merge_blocks_copy(index, file, block, &foffs1, &of)) { return(DB_CORRUPTION); } @@ -1666,10 +1673,23 @@ row_merge( return(DB_CORRUPTION); } + ut_ad(n_run <= *num_run); + + *num_run = n_run; + + /* Each run can contain one or more offsets. As merge goes on, + the number of runs (to merge) will reduce until we have one + single run. So the number of runs will always be smaller than + the number of offsets in file */ + ut_ad((*num_run) <= file->offset); + + /* The number of offsets in output file is always equal or + smaller than input file */ + ut_ad(of.offset <= file->offset); + /* Swap file descriptors for the next pass. */ *tmpfd = file->fd; *file = of; - *half = ohalf; UNIV_MEM_INVALID(block[0], 3 * sizeof block[0]); @@ -1694,27 +1714,44 @@ row_merge_sort( if applicable */ { ulint half = file->offset / 2; + ulint num_runs; + ulint* run_offset; + ulint error = DB_SUCCESS; + + /* Record the number of merge runs we need to perform */ + num_runs = file->offset; + + /* If num_runs are less than 1, nothing to merge */ + if (num_runs <= 1) { + return(error); + } + + /* "run_offset" records each run's first offset number */ + run_offset = (ulint*) mem_alloc(file->offset * sizeof(ulint)); + + /* This tells row_merge() where to start for the first round + of merge. */ + run_offset[half] = half; /* The file should always contain at least one byte (the end of file marker). Thus, it must be at least one block. */ ut_ad(file->offset > 0); + /* Merge the runs until we have one big run */ do { - ulint error; + error = row_merge(trx, index, file, block, tmpfd, + table, &num_runs, run_offset); - error = row_merge(trx, index, file, &half, - block, tmpfd, table); + UNIV_MEM_ASSERT_RW(run_offset, num_runs * sizeof *run_offset); if (error != DB_SUCCESS) { - return(error); + break; } + } while (num_runs > 1); - /* half > 0 should hold except when the file consists - of one block. No need to merge further then. */ - ut_ad(half > 0 || file->offset == 1); - } while (half < file->offset && half > 0); + mem_free(run_offset); - return(DB_SUCCESS); + return(error); } /*************************************************************//** @@ -1986,6 +2023,8 @@ row_merge_drop_index( "UPDATE SYS_INDEXES SET NAME=CONCAT('" TEMP_INDEX_PREFIX_STR "', NAME) WHERE ID = :indexid;\n" "COMMIT WORK;\n" + /* Drop the statistics of the index. */ + "DELETE FROM SYS_STATS WHERE INDEX_ID = :indexid;\n" /* Drop the field definitions of the index. */ "DELETE FROM SYS_FIELDS WHERE INDEX_ID = :indexid;\n" /* Drop the index definition and the B-tree. */ @@ -2094,13 +2133,16 @@ row_merge_drop_temp_indexes(void) btr_pcur_store_position(&pcur, &mtr); btr_pcur_commit_specify_mtr(&pcur, &mtr); - table = dict_load_table_on_id(table_id); + table = dict_table_get_on_id_low(table_id); if (table) { dict_index_t* index; + dict_index_t* next_index; for (index = dict_table_get_first_index(table); - index; index = dict_table_get_next_index(index)) { + index; index = next_index) { + + next_index = dict_table_get_next_index(index); if (*index->name == TEMP_INDEX_PREFIX) { row_merge_drop_index(index, table, trx); @@ -2303,7 +2345,7 @@ row_merge_rename_tables( { ulint err = DB_ERROR; pars_info_t* info; - const char* old_name= old_table->name; + char old_name[MAX_TABLE_NAME_LEN + 1]; ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); ut_ad(old_table != new_table); @@ -2311,6 +2353,17 @@ row_merge_rename_tables( ut_a(trx->dict_operation_lock_mode == RW_X_LATCH); + /* store the old/current name to an automatic variable */ + if (strlen(old_table->name) + 1 <= sizeof(old_name)) { + memcpy(old_name, old_table->name, strlen(old_table->name) + 1); + } else { + ut_print_timestamp(stderr); + fprintf(stderr, "InnoDB: too long table name: '%s', " + "max length is %d\n", old_table->name, + MAX_TABLE_NAME_LEN); + ut_error; + } + trx->op_info = "renaming tables"; /* We use the private SQL parser of Innobase to generate the query diff --git a/row/row0mysql.c b/row/row0mysql.c index e520065ea04..98e2d22c56b 100644 --- a/row/row0mysql.c +++ b/row/row0mysql.c @@ -522,6 +522,7 @@ handle_new_error: case DB_CANNOT_ADD_CONSTRAINT: case DB_TOO_MANY_CONCURRENT_TRXS: case DB_OUT_OF_FILE_SPACE: + case DB_INTERRUPTED: if (savept) { /* Roll back the latest, possibly incomplete insertion or update */ @@ -624,6 +625,8 @@ row_create_prebuilt( prebuilt->select_lock_type = LOCK_NONE; prebuilt->stored_select_lock_type = 99999999; + UNIV_MEM_INVALID(&prebuilt->stored_select_lock_type, + sizeof prebuilt->stored_select_lock_type); prebuilt->search_tuple = dtuple_create( heap, 2 * dict_table_get_n_cols(table)); @@ -864,7 +867,7 @@ row_update_statistics_if_needed( if (counter > 2000000000 || ((ib_int64_t)counter > 16 + table->stat_n_rows / 16)) { - dict_update_statistics(table); + dict_update_statistics(table, TRUE); } } @@ -1124,6 +1127,13 @@ row_insert_for_mysql( thr = que_fork_get_first_thr(prebuilt->ins_graph); + if (!prebuilt->mysql_has_locked) { + fprintf(stderr, "InnoDB: Error: row_insert_for_mysql is called without ha_innobase::external_lock()\n"); + if (trx->mysql_thd != NULL) { + innobase_mysql_print_thd(stderr, trx->mysql_thd, 600); + } + } + if (prebuilt->sql_stat_start) { node->state = INS_NODE_SET_IX_LOCK; prebuilt->sql_stat_start = FALSE; @@ -1430,27 +1440,26 @@ run_again: } /*********************************************************************//** -This can only be used when srv_locks_unsafe_for_binlog is TRUE or -this session is using a READ COMMITTED isolation level. Before -calling this function we must use trx_reset_new_rec_lock_info() and -trx_register_new_rec_lock() to store the information which new record locks -really were set. This function removes a newly set lock under prebuilt->pcur, -and also under prebuilt->clust_pcur. Currently, this is only used and tested -in the case of an UPDATE or a DELETE statement, where the row lock is of the -LOCK_X type. -Thus, this implements a 'mini-rollback' that releases the latest record -locks we set. -@return error code or DB_SUCCESS */ +This can only be used when srv_locks_unsafe_for_binlog is TRUE or this +session is using a READ COMMITTED or READ UNCOMMITTED isolation level. +Before calling this function row_search_for_mysql() must have +initialized prebuilt->new_rec_locks to store the information which new +record locks really were set. This function removes a newly set +clustered index record lock under prebuilt->pcur or +prebuilt->clust_pcur. Thus, this implements a 'mini-rollback' that +releases the latest clustered index record lock we set. +@return error code or DB_SUCCESS */ UNIV_INTERN int row_unlock_for_mysql( /*=================*/ - row_prebuilt_t* prebuilt, /*!< in: prebuilt struct in MySQL + row_prebuilt_t* prebuilt, /*!< in/out: prebuilt struct in MySQL handle */ - ibool has_latches_on_recs)/*!< TRUE if called so that we have - the latches on the records under pcur - and clust_pcur, and we do not need to - reposition the cursors. */ + ibool has_latches_on_recs)/*!< in: TRUE if called so + that we have the latches on + the records under pcur and + clust_pcur, and we do not need + to reposition the cursors. */ { btr_pcur_t* pcur = prebuilt->pcur; btr_pcur_t* clust_pcur = prebuilt->clust_pcur; @@ -1647,37 +1656,6 @@ row_table_got_default_clust_index( return(dict_index_get_nth_col(clust_index, 0)->mtype == DATA_SYS); } -/*********************************************************************//** -Calculates the key number used inside MySQL for an Innobase index. We have -to take into account if we generated a default clustered index for the table -@return the key number used inside MySQL */ -UNIV_INTERN -ulint -row_get_mysql_key_number_for_index( -/*===============================*/ - const dict_index_t* index) /*!< in: index */ -{ - const dict_index_t* ind; - ulint i; - - ut_a(index); - - i = 0; - ind = dict_table_get_first_index(index->table); - - while (index != ind) { - ind = dict_table_get_next_index(ind); - i++; - } - - if (row_table_got_default_clust_index(index->table)) { - ut_a(i > 0); - i--; - } - - return(i); -} - /*********************************************************************//** Locks the data dictionary in shared mode from modifications, for performing foreign key check, rollback, or other operation invisible to MySQL. */ @@ -2043,6 +2021,45 @@ error_handling: return((int) err); } +/*********************************************************************//** +*/ +UNIV_INTERN +int +row_insert_stats_for_mysql( +/*=======================*/ + dict_index_t* index, + trx_t* trx) +{ + ind_node_t* node; + mem_heap_t* heap; + que_thr_t* thr; + ulint err; + + ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); + + trx->op_info = "try to insert rows to SYS_STATS"; + + trx_start_if_not_started(trx); + trx->error_state = DB_SUCCESS; + + heap = mem_heap_create(512); + + node = ind_insert_stats_graph_create(index, heap); + + thr = pars_complete_graph_for_exec(node, trx, heap); + + ut_a(thr == que_fork_start_command(que_node_get_parent(thr))); + que_run_threads(thr); + + err = trx->error_state; + + que_graph_free((que_t*) que_node_get_parent(thr)); + + trx->op_info = ""; + + return((int) err); +} + /*********************************************************************//** Scans a table create SQL string and adds to the data dictionary the foreign key constraints declared in the string. This function @@ -2062,6 +2079,7 @@ row_table_add_foreign_constraints( FOREIGN KEY (a, b) REFERENCES table2(c, d), table2 can be written also with the database name before it: test.table2 */ + size_t sql_length, /*!< in: length of sql_string */ const char* name, /*!< in: table full name in the normalized form database_name/table_name */ @@ -2083,8 +2101,8 @@ row_table_add_foreign_constraints( trx_set_dict_operation(trx, TRX_DICT_OP_TABLE); - err = dict_create_foreign_constraints(trx, sql_string, name, - reject_fks); + err = dict_create_foreign_constraints(trx, sql_string, sql_length, + name, reject_fks); if (err == DB_SUCCESS) { /* Check that also referencing constraints are ok */ err = dict_load_foreigns(name, TRUE); @@ -2428,7 +2446,7 @@ row_discard_tablespace_for_mysql( goto funct_exit; } - new_id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID); + dict_hdr_get_new_id(&new_id, NULL, NULL); /* Remove all locks except the table-level S and X locks. */ lock_remove_all_on_table(table, FALSE); @@ -2790,10 +2808,11 @@ row_truncate_table_for_mysql( dict_index_t* index; - space = 0; + dict_hdr_get_new_id(NULL, NULL, &space); - if (fil_create_new_single_table_tablespace( - &space, table->name, FALSE, flags, + if (space == ULINT_UNDEFINED + || fil_create_new_single_table_tablespace( + space, table->name, FALSE, flags, FIL_IBD_FILE_INITIAL_SIZE) != DB_SUCCESS) { ut_print_timestamp(stderr); fprintf(stderr, @@ -2898,7 +2917,7 @@ next_rec: mem_heap_free(heap); - new_id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID); + dict_hdr_get_new_id(&new_id, NULL, NULL); info = pars_info_create(); @@ -2942,7 +2961,7 @@ next_rec: dict_table_autoinc_lock(table); dict_table_autoinc_initialize(table, 1); dict_table_autoinc_unlock(table); - dict_update_statistics(table); + dict_update_statistics(table, TRUE); trx_commit_for_mysql(trx); @@ -3244,6 +3263,8 @@ check_next_foreign: " IF (SQL % NOTFOUND) THEN\n" " found := 0;\n" " ELSE\n" + " DELETE FROM SYS_STATS\n" + " WHERE INDEX_ID = index_id;\n" " DELETE FROM SYS_FIELDS\n" " WHERE INDEX_ID = index_id;\n" " DELETE FROM SYS_INDEXES\n" diff --git a/row/row0purge.c b/row/row0purge.c index 500ebe571ab..835af990672 100644 --- a/row/row0purge.c +++ b/row/row0purge.c @@ -44,6 +44,16 @@ Created 3/14/1997 Heikki Tuuri #include "row0mysql.h" #include "log0log.h" +/************************************************************************* +IMPORTANT NOTE: Any operation that generates redo MUST check that there +is enough space in the redo log before for that operation. This is +done by calling log_free_check(). The reason for checking the +availability of the redo log space before the start of the operation is +that we MUST not hold any synchonization objects when performing the +check. +If you make a change in this module make sure that no codepath is +introduced where a call to log_free_check() is bypassed. */ + /********************************************************************//** Creates a purge node to a query graph. @return own: purge node */ @@ -126,6 +136,7 @@ row_purge_remove_clust_if_poss_low( pcur = &(node->pcur); btr_cur = btr_pcur_get_btr_cur(pcur); + log_free_check(); mtr_start(&mtr); success = row_purge_reposition_pcur(mode, node, &mtr); diff --git a/row/row0sel.c b/row/row0sel.c index 000cc3586fd..0db4fb6f3db 100644 --- a/row/row0sel.c +++ b/row/row0sel.c @@ -863,8 +863,14 @@ row_sel_get_clust_rec( clust_rec, index, offsets, node->row_lock_mode, lock_type, thr); - if (err != DB_SUCCESS) { - + switch (err) { + case DB_SUCCESS: + case DB_SUCCESS_LOCKED_REC: + /* Declare the variable uninitialized in Valgrind. + It should be set to DB_SUCCESS at func_exit. */ + UNIV_MEM_INVALID(&err, sizeof err); + break; + default: goto err_exit; } } else { @@ -934,9 +940,9 @@ err_exit: /*********************************************************************//** Sets a lock on a record. -@return DB_SUCCESS or error code */ +@return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, or error code */ UNIV_INLINE -ulint +enum db_err sel_set_rec_lock( /*=============*/ const buf_block_t* block, /*!< in: buffer block of rec */ @@ -948,8 +954,8 @@ sel_set_rec_lock( LOC_REC_NOT_GAP */ que_thr_t* thr) /*!< in: query thread */ { - trx_t* trx; - ulint err; + trx_t* trx; + enum db_err err; trx = thr_get_trx(thr); @@ -1482,11 +1488,15 @@ rec_loop: node->row_lock_mode, lock_type, thr); - if (err != DB_SUCCESS) { + switch (err) { + case DB_SUCCESS_LOCKED_REC: + err = DB_SUCCESS; + case DB_SUCCESS: + break; + default: /* Note that in this case we will store in pcur the PREDECESSOR of the record we are waiting the lock for */ - goto lock_wait_or_error; } } @@ -1538,8 +1548,12 @@ skip_lock: rec, index, offsets, node->row_lock_mode, lock_type, thr); - if (err != DB_SUCCESS) { - + switch (err) { + case DB_SUCCESS_LOCKED_REC: + err = DB_SUCCESS; + case DB_SUCCESS: + break; + default: goto lock_wait_or_error; } } @@ -2498,6 +2512,7 @@ row_sel_field_store_in_mysql_format( byte* pad_ptr; ut_ad(len != UNIV_SQL_NULL); + UNIV_MEM_ASSERT_RW(data, len); switch (templ->type) { case DATA_INT: @@ -2663,6 +2678,12 @@ row_sel_store_mysql_rec( prebuilt->blob_heap = NULL; } + /* init null bytes with default values as they might be + left uninitialized in some cases and these uninited bytes + might be copied into mysql record buffer that leads to + valgrind warnings */ + memcpy(mysql_rec, prebuilt->default_rec, prebuilt->null_bitmap_len); + for (i = 0; i < prebuilt->n_template; i++) { templ = prebuilt->mysql_template + i; @@ -2746,6 +2767,9 @@ row_sel_store_mysql_rec( /* MySQL assumes that the field for an SQL NULL value is set to the default value. */ + UNIV_MEM_ASSERT_RW(prebuilt->default_rec + + templ->mysql_col_offset, + templ->mysql_col_len); mysql_rec[templ->mysql_null_byte_offset] |= (byte) templ->mysql_null_bit_mask; memcpy(mysql_rec + templ->mysql_col_offset, @@ -2797,9 +2821,9 @@ row_sel_build_prev_vers_for_mysql( Retrieves the clustered index record corresponding to a record in a non-clustered index. Does the necessary locking. Used in the MySQL interface. -@return DB_SUCCESS or error code */ +@return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, or error code */ static -ulint +enum db_err row_sel_get_clust_rec_for_mysql( /*============================*/ row_prebuilt_t* prebuilt,/*!< in: prebuilt struct in the handle */ @@ -2826,7 +2850,7 @@ row_sel_get_clust_rec_for_mysql( dict_index_t* clust_index; const rec_t* clust_rec; rec_t* old_vers; - ulint err; + enum db_err err; trx_t* trx; *out_rec = NULL; @@ -2885,6 +2909,7 @@ row_sel_get_clust_rec_for_mysql( clust_rec = NULL; + err = DB_SUCCESS; goto func_exit; } @@ -2900,8 +2925,11 @@ row_sel_get_clust_rec_for_mysql( 0, btr_pcur_get_block(prebuilt->clust_pcur), clust_rec, clust_index, *offsets, prebuilt->select_lock_type, LOCK_REC_NOT_GAP, thr); - if (err != DB_SUCCESS) { - + switch (err) { + case DB_SUCCESS: + case DB_SUCCESS_LOCKED_REC: + break; + default: goto err_exit; } } else { @@ -2961,6 +2989,8 @@ row_sel_get_clust_rec_for_mysql( rec, sec_index, clust_rec, clust_index)); #endif } + + err = DB_SUCCESS; } func_exit: @@ -2973,7 +3003,6 @@ func_exit: btr_pcur_store_position(prebuilt->clust_pcur, mtr); } - err = DB_SUCCESS; err_exit: return(err); } @@ -3070,6 +3099,11 @@ row_sel_pop_cached_row_for_mysql( for (i = 0; i < prebuilt->n_template; i++) { templ = prebuilt->mysql_template + i; +#if 0 /* Some of the cached_rec may legitimately be uninitialized. */ + UNIV_MEM_ASSERT_RW(cached_rec + + templ->mysql_col_offset, + templ->mysql_col_len); +#endif ut_memcpy(buf + templ->mysql_col_offset, cached_rec + templ->mysql_col_offset, templ->mysql_col_len); @@ -3084,6 +3118,11 @@ row_sel_pop_cached_row_for_mysql( } } else { +#if 0 /* Some of the cached_rec may legitimately be uninitialized. */ + UNIV_MEM_ASSERT_RW(prebuilt->fetch_cache + [prebuilt->fetch_cache_first], + prebuilt->mysql_prefix_len); +#endif ut_memcpy(buf, prebuilt->fetch_cache[prebuilt->fetch_cache_first], prebuilt->mysql_prefix_len); @@ -3134,6 +3173,8 @@ row_sel_push_cache_row_for_mysql( } ut_ad(prebuilt->fetch_cache_first == 0); + UNIV_MEM_INVALID(prebuilt->fetch_cache[prebuilt->n_fetch_cached], + prebuilt->mysql_row_len); if (UNIV_UNLIKELY(!row_sel_store_mysql_rec( prebuilt->fetch_cache[ @@ -3280,6 +3321,7 @@ row_search_for_mysql( mem_heap_t* heap = NULL; ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint* offsets = offsets_; + ibool problematic_use = FALSE; rec_offs_init(offsets_); @@ -3595,6 +3637,13 @@ shortcut_fails_too_big_rec: trx->has_search_latch = FALSE; } + ut_ad(prebuilt->sql_stat_start || trx->conc_state == TRX_ACTIVE); + ut_ad(trx->conc_state == TRX_NOT_STARTED + || trx->conc_state == TRX_ACTIVE); + ut_ad(prebuilt->sql_stat_start + || prebuilt->select_lock_type != LOCK_NONE + || trx->read_view); + trx_start_if_not_started(trx); if (trx->isolation_level <= TRX_ISO_READ_COMMITTED @@ -3679,8 +3728,12 @@ shortcut_fails_too_big_rec: prebuilt->select_lock_type, LOCK_GAP, thr); - if (err != DB_SUCCESS) { - + switch (err) { + case DB_SUCCESS_LOCKED_REC: + err = DB_SUCCESS; + case DB_SUCCESS: + break; + default: goto lock_wait_or_error; } } @@ -3696,6 +3749,15 @@ shortcut_fails_too_big_rec: } } + if (!prebuilt->mysql_has_locked) { + fprintf(stderr, "InnoDB: Error: row_search_for_mysql() is called without ha_innobase::external_lock()\n"); + if (trx->mysql_thd != NULL) { + innobase_mysql_print_thd(stderr, trx->mysql_thd, 600); + } + problematic_use = TRUE; + } +retry_check: + if (!prebuilt->sql_stat_start) { /* No need to set an intention lock or assign a read view */ @@ -3706,6 +3768,14 @@ shortcut_fails_too_big_rec: " perform a consistent read\n" "InnoDB: but the read view is not assigned!\n", stderr); + if (problematic_use) { + fprintf(stderr, "InnoDB: It may be caused by calling " + "without ha_innobase::external_lock()\n" + "InnoDB: For the first-aid, avoiding the crash. " + "But it should be fixed ASAP.\n"); + prebuilt->sql_stat_start = TRUE; + goto retry_check; + } trx_print(stderr, trx, 600); fputc('\n', stderr); ut_a(0); @@ -3785,8 +3855,12 @@ rec_loop: prebuilt->select_lock_type, LOCK_ORDINARY, thr); - if (err != DB_SUCCESS) { - + switch (err) { + case DB_SUCCESS_LOCKED_REC: + err = DB_SUCCESS; + case DB_SUCCESS: + break; + default: goto lock_wait_or_error; } } @@ -3916,8 +3990,11 @@ wrong_offs: prebuilt->select_lock_type, LOCK_GAP, thr); - if (err != DB_SUCCESS) { - + switch (err) { + case DB_SUCCESS_LOCKED_REC: + case DB_SUCCESS: + break; + default: goto lock_wait_or_error; } } @@ -3952,8 +4029,11 @@ wrong_offs: prebuilt->select_lock_type, LOCK_GAP, thr); - if (err != DB_SUCCESS) { - + switch (err) { + case DB_SUCCESS_LOCKED_REC: + case DB_SUCCESS: + break; + default: goto lock_wait_or_error; } } @@ -4023,15 +4103,21 @@ no_gap_lock: switch (err) { const rec_t* old_vers; - case DB_SUCCESS: + case DB_SUCCESS_LOCKED_REC: if (srv_locks_unsafe_for_binlog - || trx->isolation_level <= TRX_ISO_READ_COMMITTED) { + || trx->isolation_level + <= TRX_ISO_READ_COMMITTED) { /* Note that a record of prebuilt->index was locked. */ prebuilt->new_rec_locks = 1; } + err = DB_SUCCESS; + case DB_SUCCESS: break; case DB_LOCK_WAIT: + /* Never unlock rows that were part of a conflict. */ + prebuilt->new_rec_locks = 0; + if (UNIV_LIKELY(prebuilt->row_read_type != ROW_READ_TRY_SEMI_CONSISTENT) || unique_search @@ -4061,7 +4147,6 @@ no_gap_lock: if (UNIV_LIKELY(trx->wait_lock != NULL)) { lock_cancel_waiting_and_release( trx->wait_lock); - prebuilt->new_rec_locks = 0; } else { mutex_exit(&kernel_mutex); @@ -4073,9 +4158,6 @@ no_gap_lock: ULINT_UNDEFINED, &heap); err = DB_SUCCESS; - /* Note that a record of - prebuilt->index was locked. */ - prebuilt->new_rec_locks = 1; break; } mutex_exit(&kernel_mutex); @@ -4212,27 +4294,30 @@ requires_clust_rec: err = row_sel_get_clust_rec_for_mysql(prebuilt, index, rec, thr, &clust_rec, &offsets, &heap, &mtr); - if (err != DB_SUCCESS) { + switch (err) { + case DB_SUCCESS: + if (clust_rec == NULL) { + /* The record did not exist in the read view */ + ut_ad(prebuilt->select_lock_type == LOCK_NONE); + goto next_rec; + } + break; + case DB_SUCCESS_LOCKED_REC: + ut_a(clust_rec != NULL); + if (srv_locks_unsafe_for_binlog + || trx->isolation_level + <= TRX_ISO_READ_COMMITTED) { + /* Note that the clustered index record + was locked. */ + prebuilt->new_rec_locks = 2; + } + err = DB_SUCCESS; + break; + default: goto lock_wait_or_error; } - if (clust_rec == NULL) { - /* The record did not exist in the read view */ - ut_ad(prebuilt->select_lock_type == LOCK_NONE); - - goto next_rec; - } - - if ((srv_locks_unsafe_for_binlog - || trx->isolation_level <= TRX_ISO_READ_COMMITTED) - && prebuilt->select_lock_type != LOCK_NONE) { - /* Note that both the secondary index record - and the clustered index record were locked. */ - ut_ad(prebuilt->new_rec_locks == 1); - prebuilt->new_rec_locks = 2; - } - if (UNIV_UNLIKELY(rec_get_deleted_flag(clust_rec, comp))) { /* The record is delete marked: we can skip it */ diff --git a/row/row0uins.c b/row/row0uins.c index 9f9c814f1a5..930a5cf13b6 100644 --- a/row/row0uins.c +++ b/row/row0uins.c @@ -46,6 +46,16 @@ Created 2/25/1997 Heikki Tuuri #include "ibuf0ibuf.h" #include "log0log.h" +/************************************************************************* +IMPORTANT NOTE: Any operation that generates redo MUST check that there +is enough space in the redo log before for that operation. This is +done by calling log_free_check(). The reason for checking the +availability of the redo log space before the start of the operation is +that we MUST not hold any synchonization objects when performing the +check. +If you make a change in this module make sure that no codepath is +introduced where a call to log_free_check() is bypassed. */ + /***************************************************************//** Removes a clustered index record. The pcur in node was positioned on the record, now it is detached. @@ -152,7 +162,6 @@ row_undo_ins_remove_sec_low( ulint err; mtr_t mtr; - log_free_check(); mtr_start(&mtr); found = row_search_index_entry(index, entry, mode, &pcur, &mtr); @@ -335,6 +344,7 @@ row_undo_ins( transactions. */ ut_a(trx_is_recv(node->trx)); } else { + log_free_check(); err = row_undo_ins_remove_sec(node->index, entry); if (err != DB_SUCCESS) { @@ -346,5 +356,6 @@ row_undo_ins( node->index = dict_table_get_next_index(node->index); } + log_free_check(); return(row_undo_ins_remove_clust_rec(node)); } diff --git a/row/row0umod.c b/row/row0umod.c index e7245dbee41..8464b0f95cc 100644 --- a/row/row0umod.c +++ b/row/row0umod.c @@ -58,12 +58,22 @@ delete marked clustered index record was delete unmarked and possibly also some of its fields were changed. Now, it is possible that the delete marked version has become obsolete at the time the undo is started. */ +/************************************************************************* +IMPORTANT NOTE: Any operation that generates redo MUST check that there +is enough space in the redo log before for that operation. This is +done by calling log_free_check(). The reason for checking the +availability of the redo log space before the start of the operation is +that we MUST not hold any synchonization objects when performing the +check. +If you make a change in this module make sure that no codepath is +introduced where a call to log_free_check() is bypassed. */ + /***********************************************************//** Checks if also the previous version of the clustered index record was modified or inserted by the same transaction, and its undo number is such that it should be undone in the same rollback. @return TRUE if also previous modify or insert of this row should be undone */ -UNIV_INLINE +static ibool row_undo_mod_undo_also_prev_vers( /*=============================*/ @@ -231,6 +241,8 @@ row_undo_mod_clust( ut_ad(node && thr); + log_free_check(); + /* Check if also the previous version of the clustered index record should be undone in this same rollback operation */ @@ -657,24 +669,55 @@ row_undo_mod_upd_exist_sec( /* Build the newest version of the index entry */ entry = row_build_index_entry(node->row, node->ext, index, heap); - ut_a(entry); - /* NOTE that if we updated the fields of a - delete-marked secondary index record so that - alphabetically they stayed the same, e.g., - 'abc' -> 'aBc', we cannot return to the original - values because we do not know them. But this should - not cause problems because in row0sel.c, in queries - we always retrieve the clustered index record or an - earlier version of it, if the secondary index record - through which we do the search is delete-marked. */ + if (UNIV_UNLIKELY(!entry)) { + /* The server must have crashed in + row_upd_clust_rec_by_insert(), in + row_ins_index_entry_low() before + btr_store_big_rec_extern_fields() + has written the externally stored columns + (BLOBs) of the new clustered index entry. */ - err = row_undo_mod_del_mark_or_remove_sec(node, thr, - index, - entry); - if (err != DB_SUCCESS) { - mem_heap_free(heap); + /* The table must be in DYNAMIC or COMPRESSED + format. REDUNDANT and COMPACT formats + store a local 768-byte prefix of each + externally stored column. */ + ut_a(dict_table_get_format(index->table) + >= DICT_TF_FORMAT_ZIP); - return(err); + /* This is only legitimate when + rolling back an incomplete transaction + after crash recovery. */ + ut_a(thr_get_trx(thr)->is_recovered); + + /* The server must have crashed before + completing the insert of the new + clustered index entry and before + inserting to the secondary indexes. + Because node->row was not yet written + to this index, we can ignore it. But + we must restore node->undo_row. */ + } else { + /* NOTE that if we updated the fields of a + delete-marked secondary index record so that + alphabetically they stayed the same, e.g., + 'abc' -> 'aBc', we cannot return to the + original values because we do not know them. + But this should not cause problems because + in row0sel.c, in queries we always retrieve + the clustered index record or an earlier + version of it, if the secondary index record + through which we do the search is + delete-marked. */ + + err = row_undo_mod_del_mark_or_remove_sec( + node, thr, index, entry); + if (err != DB_SUCCESS) { + mem_heap_free(heap); + + return(err); + } + + mem_heap_empty(heap); } /* We may have to update the delete mark in the @@ -683,7 +726,6 @@ row_undo_mod_upd_exist_sec( the secondary index record if we updated its fields but alphabetically they stayed the same, e.g., 'abc' -> 'aBc'. */ - mem_heap_empty(heap); entry = row_build_index_entry(node->undo_row, node->undo_ext, index, heap); diff --git a/row/row0undo.c b/row/row0undo.c index 3d739c9689a..9ef842b5114 100644 --- a/row/row0undo.c +++ b/row/row0undo.c @@ -297,7 +297,7 @@ row_undo( if (locked_data_dict) { - row_mysql_lock_data_dictionary(trx); + row_mysql_freeze_data_dictionary(trx); } if (node->state == UNDO_NODE_INSERT) { @@ -312,7 +312,7 @@ row_undo( if (locked_data_dict) { - row_mysql_unlock_data_dictionary(trx); + row_mysql_unfreeze_data_dictionary(trx); } /* Do some cleanup */ diff --git a/row/row0upd.c b/row/row0upd.c index 95d1d00aeef..d0aaecd3dae 100644 --- a/row/row0upd.c +++ b/row/row0upd.c @@ -92,6 +92,16 @@ the x-latch freed? The most efficient way for performing a searched delete is obviously to keep the x-latch for several steps of query graph execution. */ +/************************************************************************* +IMPORTANT NOTE: Any operation that generates redo MUST check that there +is enough space in the redo log before for that operation. This is +done by calling log_free_check(). The reason for checking the +availability of the redo log space before the start of the operation is +that we MUST not hold any synchonization objects when performing the +check. +If you make a change in this module make sure that no codepath is +introduced where a call to log_free_check() is bypassed. */ + /***********************************************************//** Checks if an update vector changes some of the first ordering fields of an index record. This is only used in foreign key checks and we can assume @@ -1453,7 +1463,6 @@ row_upd_sec_index_entry( entry = row_build_index_entry(node->row, node->ext, index, heap); ut_a(entry); - log_free_check(); mtr_start(&mtr); found = row_search_index_entry(index, entry, BTR_MODIFY_LEAF, &pcur, @@ -1529,7 +1538,7 @@ Updates the secondary index record if it is changed in the row update or deletes it if this is a delete. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -UNIV_INLINE +static ulint row_upd_sec_step( /*=============*/ @@ -2015,6 +2024,7 @@ row_upd( if (node->state == UPD_NODE_UPDATE_CLUSTERED || node->state == UPD_NODE_INSERT_CLUSTERED) { + log_free_check(); err = row_upd_clust_step(node, thr); if (err != DB_SUCCESS) { @@ -2029,6 +2039,8 @@ row_upd( } while (node->index != NULL) { + + log_free_check(); err = row_upd_sec_step(node, thr); if (err != DB_SUCCESS) { diff --git a/srv/srv0srv.c b/srv/srv0srv.c index 56107db60d8..4f66144b37c 100644 --- a/srv/srv0srv.c +++ b/srv/srv0srv.c @@ -211,6 +211,9 @@ UNIV_INTERN ulint srv_buf_pool_curr_size = 0; UNIV_INTERN ulint srv_mem_pool_size = ULINT_MAX; UNIV_INTERN ulint srv_lock_table_size = ULINT_MAX; +/* key value for shm */ +UNIV_INTERN uint srv_buffer_pool_shm_key = 0; + /* This parameter is deprecated. Use srv_n_io_[read|write]_threads instead. */ UNIV_INTERN ulint srv_n_file_io_threads = ULINT_MAX; @@ -380,6 +383,7 @@ UNIV_INTERN unsigned long long srv_stats_sample_pages = 8; UNIV_INTERN ulint srv_stats_method = 0; UNIV_INTERN ulint srv_stats_auto_update = 1; UNIV_INTERN ulint srv_stats_update_need_lock = 1; +UNIV_INTERN ibool srv_use_sys_stats_table = FALSE; UNIV_INTERN ibool srv_use_doublewrite_buf = TRUE; UNIV_INTERN ibool srv_use_checksums = TRUE; @@ -1758,12 +1762,16 @@ srv_suspend_mysql_thread( innodb_lock_wait_timeout, because trx->mysql_thd == NULL. */ lock_wait_timeout = thd_lock_wait_timeout(trx->mysql_thd); - if (trx_is_interrupted(trx) - || (lock_wait_timeout < 100000000 - && wait_time > (double) lock_wait_timeout)) { + if (lock_wait_timeout < 100000000 + && wait_time > (double) lock_wait_timeout) { trx->error_state = DB_LOCK_WAIT_TIMEOUT; } + + if (trx_is_interrupted(trx)) { + + trx->error_state = DB_INTERRUPTED; + } } /********************************************************************//** @@ -1848,7 +1856,6 @@ srv_printf_innodb_monitor( ulint btr_search_sys_subtotal; ulint lock_sys_subtotal; ulint recv_sys_subtotal; - ulint io_counter_subtotal; ulint i; trx_t* trx; diff --git a/srv/srv0start.c b/srv/srv0start.c index ef638058326..93fccabeff6 100644 --- a/srv/srv0start.c +++ b/srv/srv0start.c @@ -1302,6 +1302,9 @@ innobase_start_or_create_for_mysql(void) } else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DIRECT")) { srv_unix_file_flush_method = SRV_UNIX_O_DIRECT; + } else if (0 == ut_strcmp(srv_file_flush_method_str, "ALL_O_DIRECT")) { + srv_unix_file_flush_method = SRV_UNIX_ALL_O_DIRECT; + } else if (0 == ut_strcmp(srv_file_flush_method_str, "littlesync")) { srv_unix_file_flush_method = SRV_UNIX_LITTLESYNC; @@ -1716,6 +1719,8 @@ innobase_start_or_create_for_mysql(void) Note that this is not as heavy weight as it seems. At this point there will be only ONE page in the buf_LRU and there must be no page in the buf_flush list. */ + /* TODO: treat more correctly */ + if (!srv_buffer_pool_shm_key) buf_pool_invalidate(); /* We always try to do a recovery, even if the database had diff --git a/sync/sync0arr.c b/sync/sync0arr.c index cfa52cdcc88..223e1715944 100644 --- a/sync/sync0arr.c +++ b/sync/sync0arr.c @@ -498,7 +498,9 @@ sync_array_cell_print( || type == RW_LOCK_WAIT_EX || type == RW_LOCK_SHARED) { - fputs(type == RW_LOCK_EX ? "X-lock on" : "S-lock on", file); + fputs(type == RW_LOCK_EX ? "X-lock on" + : type == RW_LOCK_WAIT_EX ? "X-lock (wait_ex) on" + : "S-lock on", file); rwlock = cell->old_wait_rw_lock; diff --git a/sync/sync0rw.c b/sync/sync0rw.c index 07eac403dfe..9e10f6e943b 100644 --- a/sync/sync0rw.c +++ b/sync/sync0rw.c @@ -268,7 +268,7 @@ rw_lock_create_func( lock->level = level; #endif /* UNIV_SYNC_DEBUG */ - lock->magic_n = RW_LOCK_MAGIC_N; + ut_d(lock->magic_n = RW_LOCK_MAGIC_N); lock->lock_name = cmutex_name; @@ -282,10 +282,8 @@ rw_lock_create_func( mutex_enter(&rw_lock_list_mutex); - if (UT_LIST_GET_LEN(rw_lock_list) > 0) { - ut_a(UT_LIST_GET_FIRST(rw_lock_list)->magic_n - == RW_LOCK_MAGIC_N); - } + ut_ad(UT_LIST_GET_FIRST(rw_lock_list) == NULL + || UT_LIST_GET_FIRST(rw_lock_list)->magic_n == RW_LOCK_MAGIC_N); UT_LIST_ADD_FIRST(list, rw_lock_list, lock); @@ -314,18 +312,16 @@ rw_lock_free( os_event_free(lock->wait_ex_event); - if (UT_LIST_GET_PREV(list, lock)) { - ut_a(UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N); - } - if (UT_LIST_GET_NEXT(list, lock)) { - ut_a(UT_LIST_GET_NEXT(list, lock)->magic_n == RW_LOCK_MAGIC_N); - } + ut_ad(UT_LIST_GET_PREV(list, lock) == NULL + || UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N); + ut_ad(UT_LIST_GET_NEXT(list, lock) == NULL + || UT_LIST_GET_NEXT(list, lock)->magic_n == RW_LOCK_MAGIC_N); UT_LIST_REMOVE(list, rw_lock_list, lock); mutex_exit(&rw_lock_list_mutex); - lock->magic_n = 0; + ut_d(lock->magic_n = 0); } #ifdef UNIV_DEBUG @@ -344,7 +340,7 @@ rw_lock_validate( ulint waiters = rw_lock_get_waiters(lock); lint lock_word = lock->lock_word; - ut_a(lock->magic_n == RW_LOCK_MAGIC_N); + ut_ad(lock->magic_n == RW_LOCK_MAGIC_N); ut_a(waiters == 0 || waiters == 1); ut_a(lock_word > -X_LOCK_DECR ||(-lock_word) % X_LOCK_DECR == 0); diff --git a/sync/sync0sync.c b/sync/sync0sync.c index f23ece9805a..225f28df78e 100644 --- a/sync/sync0sync.c +++ b/sync/sync0sync.c @@ -434,17 +434,19 @@ mutex_set_waiters( mutex_t* mutex, /*!< in: mutex */ ulint n) /*!< in: value to set */ { - volatile ulint* ptr; /* declared volatile to ensure that - the value is stored to memory */ +#ifdef INNODB_RW_LOCKS_USE_ATOMICS ut_ad(mutex); -#ifdef INNODB_RW_LOCKS_USE_ATOMICS if (n) { os_compare_and_swap_ulint(&mutex->waiters, 0, 1); } else { os_compare_and_swap_ulint(&mutex->waiters, 1, 0); } #else + volatile ulint* ptr; /* declared volatile to ensure that + the value is stored to memory */ + ut_ad(mutex); + ptr = &(mutex->waiters); *ptr = n; /* Here we assume that the write of a single diff --git a/trx/trx0i_s.c b/trx/trx0i_s.c index c160eb2942a..5bc8302d0c0 100644 --- a/trx/trx0i_s.c +++ b/trx/trx0i_s.c @@ -429,6 +429,9 @@ fill_trx_row( which to copy volatile strings */ { + const char* stmt; + size_t stmt_len; + row->trx_id = trx_get_id(trx); row->trx_started = (ib_time_t) trx->start_time; row->trx_state = trx_get_que_state_str(trx); @@ -449,38 +452,33 @@ fill_trx_row( row->trx_weight = (ullint) ut_conv_dulint_to_longlong(TRX_WEIGHT(trx)); - if (trx->mysql_thd != NULL) { - row->trx_mysql_thread_id - = thd_get_thread_id(trx->mysql_thd); - } else { + if (trx->mysql_thd == NULL) { /* For internal transactions e.g., purge and transactions being recovered at startup there is no associated MySQL thread data structure. */ row->trx_mysql_thread_id = 0; + row->trx_query = NULL; + return(TRUE); } - if (trx->mysql_query_str != NULL && *trx->mysql_query_str != NULL) { + row->trx_mysql_thread_id = thd_get_thread_id(trx->mysql_thd); + stmt = innobase_get_stmt(trx->mysql_thd, &stmt_len); - if (strlen(*trx->mysql_query_str) - > TRX_I_S_TRX_QUERY_MAX_LEN) { + if (stmt != NULL) { - char query[TRX_I_S_TRX_QUERY_MAX_LEN + 1]; + char query[TRX_I_S_TRX_QUERY_MAX_LEN + 1]; - memcpy(query, *trx->mysql_query_str, - TRX_I_S_TRX_QUERY_MAX_LEN); - query[TRX_I_S_TRX_QUERY_MAX_LEN] = '\0'; - - row->trx_query = ha_storage_put_memlim( - cache->storage, query, - TRX_I_S_TRX_QUERY_MAX_LEN + 1, - MAX_ALLOWED_FOR_STORAGE(cache)); - } else { - - row->trx_query = ha_storage_put_str_memlim( - cache->storage, *trx->mysql_query_str, - MAX_ALLOWED_FOR_STORAGE(cache)); + if (stmt_len > TRX_I_S_TRX_QUERY_MAX_LEN) { + stmt_len = TRX_I_S_TRX_QUERY_MAX_LEN; } + memcpy(query, stmt, stmt_len); + query[stmt_len] = '\0'; + + row->trx_query = ha_storage_put_memlim( + cache->storage, stmt, stmt_len + 1, + MAX_ALLOWED_FOR_STORAGE(cache)); + if (row->trx_query == NULL) { return(FALSE); diff --git a/trx/trx0purge.c b/trx/trx0purge.c index 41e16b35e85..1c317665878 100644 --- a/trx/trx0purge.c +++ b/trx/trx0purge.c @@ -1148,8 +1148,7 @@ trx_purge(void) /* If we cannot advance the 'purge view' because of an old 'consistent read view', then the DML statements cannot be delayed. Also, srv_max_purge_lag <= 0 means 'infinity'. */ - if (srv_max_purge_lag > 0 - && !UT_LIST_GET_LAST(trx_sys->view_list)) { + if (srv_max_purge_lag > 0) { float ratio = (float) trx_sys->rseg_history_len / srv_max_purge_lag; if (ratio > ULINT_MAX / 10000) { diff --git a/trx/trx0sys.c b/trx/trx0sys.c index 7f50973d65e..ad4471ada0b 100644 --- a/trx/trx0sys.c +++ b/trx/trx0sys.c @@ -840,13 +840,13 @@ UNIV_INTERN void trx_sys_update_mysql_binlog_offset( /*===============================*/ + trx_sysf_t* sys_header, const char* file_name_in,/*!< in: MySQL log file name */ ib_int64_t offset, /*!< in: position in that log file */ ulint field, /*!< in: offset of the MySQL log info field in the trx sys header */ mtr_t* mtr) /*!< in: mtr */ { - trx_sysf_t* sys_header; const char* file_name; if (ut_strlen(file_name_in) >= TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN) { @@ -860,8 +860,6 @@ trx_sys_update_mysql_binlog_offset( file_name = file_name_in; } - sys_header = trx_sysf_get(mtr); - if (mach_read_from_4(sys_header + field + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD) != TRX_SYS_MYSQL_LOG_MAGIC_N) { @@ -1143,12 +1141,8 @@ trx_sysf_dummy_create( ulint space, mtr_t* mtr) { - trx_sysf_t* sys_header; - ulint slot_no; buf_block_t* block; page_t* page; - ulint page_no; - ulint i; ut_ad(mtr); diff --git a/trx/trx0trx.c b/trx/trx0trx.c index f150d64f8dc..9584f0c4c46 100644 --- a/trx/trx0trx.c +++ b/trx/trx0trx.c @@ -109,6 +109,8 @@ trx_create( trx->support_xa = TRUE; + trx->flush_log_at_trx_commit_session = 3; /* means to use innodb_flush_log_at_trx_commit value */ + trx->check_foreigns = TRUE; trx->check_unique_secondary = TRUE; @@ -119,7 +121,6 @@ trx_create( trx->table_id = ut_dulint_zero; trx->mysql_thd = NULL; - trx->mysql_query_str = NULL; trx->active_trans = 0; trx->duplicates = 0; @@ -736,6 +737,9 @@ trx_start( generated by the same transaction, doesn't. */ trx->support_xa = thd_supports_xa(trx->mysql_thd); + trx->flush_log_at_trx_commit_session = + thd_flush_log_at_trx_commit_session(trx->mysql_thd); + mutex_enter(&kernel_mutex); ret = trx_start_low(trx, rseg_id); @@ -758,6 +762,7 @@ trx_commit_off_kernel( trx_rseg_t* rseg; trx_undo_t* undo; mtr_t mtr; + trx_sysf_t* sys_header = NULL; ut_ad(mutex_own(&kernel_mutex)); @@ -815,7 +820,11 @@ trx_commit_off_kernel( if (trx->mysql_log_file_name && trx->mysql_log_file_name[0] != '\0') { + if (!sys_header) { + sys_header = trx_sysf_get(&mtr); + } trx_sys_update_mysql_binlog_offset( + sys_header, trx->mysql_log_file_name, trx->mysql_log_offset, TRX_SYS_MYSQL_LOG_INFO, &mtr); @@ -824,11 +833,16 @@ trx_commit_off_kernel( if (trx->mysql_master_log_file_name[0] != '\0') { /* This database server is a MySQL replication slave */ + if (!sys_header) { + sys_header = trx_sysf_get(&mtr); + } trx_sys_update_mysql_binlog_offset( + sys_header, trx->mysql_relay_log_file_name, trx->mysql_relay_log_pos, TRX_SYS_MYSQL_RELAY_LOG_INFO, &mtr); trx_sys_update_mysql_binlog_offset( + sys_header, trx->mysql_master_log_file_name, trx->mysql_master_log_pos, TRX_SYS_MYSQL_MASTER_LOG_INFO, &mtr); @@ -907,6 +921,7 @@ trx_commit_off_kernel( trx->read_view = NULL; if (lsn) { + ulint flush_log_at_trx_commit; mutex_exit(&kernel_mutex); @@ -915,6 +930,12 @@ trx_commit_off_kernel( trx_undo_insert_cleanup(trx); } + if (trx->flush_log_at_trx_commit_session == 3) { + flush_log_at_trx_commit = srv_flush_log_at_trx_commit; + } else { + flush_log_at_trx_commit = trx->flush_log_at_trx_commit_session; + } + /* NOTE that we could possibly make a group commit more efficient here: call os_thread_yield here to allow also other trxs to come to commit! */ @@ -946,9 +967,9 @@ trx_commit_off_kernel( if (trx->flush_log_later) { /* Do nothing yet */ trx->must_flush_log_later = TRUE; - } else if (srv_flush_log_at_trx_commit == 0) { + } else if (flush_log_at_trx_commit == 0) { /* Do nothing */ - } else if (srv_flush_log_at_trx_commit == 1) { + } else if (flush_log_at_trx_commit == 1) { if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) { /* Write the log but do not flush it to disk */ @@ -960,7 +981,7 @@ trx_commit_off_kernel( log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE); } - } else if (srv_flush_log_at_trx_commit == 2) { + } else if (flush_log_at_trx_commit == 2) { /* Write the log but do not flush it to disk */ @@ -983,7 +1004,6 @@ trx_commit_off_kernel( trx->rseg = NULL; trx->undo_no = ut_dulint_zero; trx->last_sql_stat_start.least_undo_no = ut_dulint_zero; - trx->mysql_query_str = NULL; ut_ad(UT_LIST_GET_LEN(trx->wait_thrs) == 0); ut_ad(UT_LIST_GET_LEN(trx->trx_locks) == 0); @@ -1641,16 +1661,23 @@ trx_commit_complete_for_mysql( trx_t* trx) /*!< in: trx handle */ { ib_uint64_t lsn = trx->commit_lsn; + ulint flush_log_at_trx_commit; ut_a(trx); trx->op_info = "flushing log"; + if (trx->flush_log_at_trx_commit_session == 3) { + flush_log_at_trx_commit = srv_flush_log_at_trx_commit; + } else { + flush_log_at_trx_commit = trx->flush_log_at_trx_commit_session; + } + if (!trx->must_flush_log_later) { /* Do nothing */ - } else if (srv_flush_log_at_trx_commit == 0) { + } else if (flush_log_at_trx_commit == 0) { /* Do nothing */ - } else if (srv_flush_log_at_trx_commit == 1) { + } else if (flush_log_at_trx_commit == 1) { if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) { /* Write the log but do not flush it to disk */ @@ -1661,7 +1688,7 @@ trx_commit_complete_for_mysql( log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE); } - } else if (srv_flush_log_at_trx_commit == 2) { + } else if (flush_log_at_trx_commit == 2) { /* Write the log but do not flush it to disk */ @@ -1922,6 +1949,8 @@ trx_prepare_off_kernel( /*--------------------------------------*/ if (lsn) { + ulint flush_log_at_trx_commit; + /* Depending on the my.cnf options, we may now write the log buffer to the log files, making the prepared state of the transaction durable if the OS does not crash. We may also @@ -1941,9 +1970,15 @@ trx_prepare_off_kernel( mutex_exit(&kernel_mutex); - if (srv_flush_log_at_trx_commit == 0) { + if (trx->flush_log_at_trx_commit_session == 3) { + flush_log_at_trx_commit = srv_flush_log_at_trx_commit; + } else { + flush_log_at_trx_commit = trx->flush_log_at_trx_commit_session; + } + + if (flush_log_at_trx_commit == 0) { /* Do nothing */ - } else if (srv_flush_log_at_trx_commit == 1) { + } else if (flush_log_at_trx_commit == 1) { if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) { /* Write the log but do not flush it to disk */ @@ -1955,7 +1990,7 @@ trx_prepare_off_kernel( log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE); } - } else if (srv_flush_log_at_trx_commit == 2) { + } else if (flush_log_at_trx_commit == 2) { /* Write the log but do not flush it to disk */ diff --git a/ut/ut0auxconf_atomic_pthread_t_gcc.c b/ut/ut0auxconf_atomic_pthread_t_gcc.c deleted file mode 100644 index 30de5aa6f17..00000000000 --- a/ut/ut0auxconf_atomic_pthread_t_gcc.c +++ /dev/null @@ -1,43 +0,0 @@ -/***************************************************************************** - -Copyright (c) 2009, Innobase Oy. All Rights Reserved. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA - -*****************************************************************************/ - -/***************************************************************************** -If this program compiles, then pthread_t objects can be used as arguments -to GCC atomic builtin functions. - -Created March 5, 2009 Vasil Dimov -*****************************************************************************/ - -#include -#include - -int -main(int argc, char** argv) -{ - pthread_t x1; - pthread_t x2; - pthread_t x3; - - memset(&x1, 0x0, sizeof(x1)); - memset(&x2, 0x0, sizeof(x2)); - memset(&x3, 0x0, sizeof(x3)); - - __sync_bool_compare_and_swap(&x1, x2, x3); - - return(0); -} diff --git a/ut/ut0auxconf_atomic_pthread_t_solaris.c b/ut/ut0auxconf_atomic_pthread_t_solaris.c deleted file mode 100644 index 310603c7503..00000000000 --- a/ut/ut0auxconf_atomic_pthread_t_solaris.c +++ /dev/null @@ -1,54 +0,0 @@ -/***************************************************************************** - -Copyright (c) 2009, Innobase Oy. All Rights Reserved. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA - -*****************************************************************************/ - -/***************************************************************************** -If this program compiles and returns 0, then pthread_t objects can be used as -arguments to Solaris libc atomic functions. - -Created April 18, 2009 Vasil Dimov -*****************************************************************************/ - -#include -#include - -int -main(int argc, char** argv) -{ - pthread_t x1; - pthread_t x2; - pthread_t x3; - - memset(&x1, 0x0, sizeof(x1)); - memset(&x2, 0x0, sizeof(x2)); - memset(&x3, 0x0, sizeof(x3)); - - if (sizeof(pthread_t) == 4) { - - atomic_cas_32(&x1, x2, x3); - - } else if (sizeof(pthread_t) == 8) { - - atomic_cas_64(&x1, x2, x3); - - } else { - - return(1); - } - - return(0); -} diff --git a/ut/ut0auxconf_have_gcc_atomics.c b/ut/ut0auxconf_have_gcc_atomics.c deleted file mode 100644 index da5c13d7d79..00000000000 --- a/ut/ut0auxconf_have_gcc_atomics.c +++ /dev/null @@ -1,61 +0,0 @@ -/***************************************************************************** - -Copyright (c) 2009, Innobase Oy. All Rights Reserved. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA - -*****************************************************************************/ - -/***************************************************************************** -If this program compiles and returns 0, then GCC atomic funcions are available. - -Created September 12, 2009 Vasil Dimov -*****************************************************************************/ - -int -main(int argc, char** argv) -{ - long x; - long y; - long res; - char c; - - x = 10; - y = 123; - res = __sync_bool_compare_and_swap(&x, x, y); - if (!res || x != y) { - return(1); - } - - x = 10; - y = 123; - res = __sync_bool_compare_and_swap(&x, x + 1, y); - if (res || x != 10) { - return(1); - } - - x = 10; - y = 123; - res = __sync_add_and_fetch(&x, y); - if (res != 123 + 10 || x != 123 + 10) { - return(1); - } - - c = 10; - res = __sync_lock_test_and_set(&c, 123); - if (res != 10 || c != 123) { - return(1); - } - - return(0); -} diff --git a/ut/ut0auxconf_have_solaris_atomics.c b/ut/ut0auxconf_have_solaris_atomics.c deleted file mode 100644 index 7eb704edd4b..00000000000 --- a/ut/ut0auxconf_have_solaris_atomics.c +++ /dev/null @@ -1,39 +0,0 @@ -/***************************************************************************** - -Copyright (c) 2009, Innobase Oy. All Rights Reserved. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA - -*****************************************************************************/ - -/***************************************************************************** -If this program compiles, then Solaris libc atomic funcions are available. - -Created April 18, 2009 Vasil Dimov -*****************************************************************************/ -#include - -int -main(int argc, char** argv) -{ - ulong_t ulong = 0; - uint32_t uint32 = 0; - uint64_t uint64 = 0; - - atomic_cas_ulong(&ulong, 0, 1); - atomic_cas_32(&uint32, 0, 1); - atomic_cas_64(&uint64, 0, 1); - atomic_add_long(&ulong, 0); - - return(0); -} diff --git a/ut/ut0auxconf_pause.c b/ut/ut0auxconf_pause.c deleted file mode 100644 index 54d63bdd9bc..00000000000 --- a/ut/ut0auxconf_pause.c +++ /dev/null @@ -1,32 +0,0 @@ -/***************************************************************************** - -Copyright (c) 2009, Innobase Oy. All Rights Reserved. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA - -*****************************************************************************/ - -/***************************************************************************** -If this program compiles and can be run and returns 0, then the pause -instruction is available. - -Created Jul 21, 2009 Vasil Dimov -*****************************************************************************/ - -int -main(int argc, char** argv) -{ - __asm__ __volatile__ ("pause"); - - return(0); -} diff --git a/ut/ut0auxconf_sizeof_pthread_t.c b/ut/ut0auxconf_sizeof_pthread_t.c deleted file mode 100644 index 96add4526ef..00000000000 --- a/ut/ut0auxconf_sizeof_pthread_t.c +++ /dev/null @@ -1,35 +0,0 @@ -/***************************************************************************** - -Copyright (c) 2009, Innobase Oy. All Rights Reserved. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA - -*****************************************************************************/ - -/***************************************************************************** -This program should compile and when run, print a single line like: -#define SIZEOF_PTHREAD_T %d - -Created April 18, 2009 Vasil Dimov -*****************************************************************************/ - -#include -#include - -int -main(int argc, char** argv) -{ - printf("#define SIZEOF_PTHREAD_T %d\n", (int) sizeof(pthread_t)); - - return(0); -} From a4fff491eb7f8be7c635287377c57eeff1dd6e89 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 3 Sep 2010 19:20:30 +0300 Subject: [PATCH 098/118] Fix that one can run mysql_upgrade with long table names Fall back to use ALTER TABLE for engines that doesn't support REPAIR when doing repair for upgrade. Nicer output from mysql_upgrade and mysql_check Updated all arrays that used NAME_LEN to use SAFE_NAME_LEN to ensure that we don't break things accidently as names can now have a #mysql50# prefix. client/mysql_upgrade.c: If we are using verbose, also run mysqlcheck in verbose mode. client/mysqlcheck.c: Add more information if running in verbose mode Print 'Needs upgrade' instead of complex error if table needs to be upgraded Don't write connect information if verbose is not 2 or above mysql-test/r/drop.result: Updated test and results as we now support full table names mysql-test/r/grant.result: Now you get a correct error message if using #mysql with paths mysql-test/r/show_check.result: Update results as table names can temporarly be bigger than NAME_LEN (during upgrade) mysql-test/r/upgrade.result: Test upgrade for long table names. mysql-test/suite/funcs_1/r/is_tables_is.result: Updated old test result (had note been updated in a while) mysql-test/t/drop.test: Updated test and results as we now support full table names mysql-test/t/grant.test: Now you get a correct error message if using #mysql with paths mysql-test/t/upgrade.test: Test upgrade for long table names. sql/ha_partition.cc: NAME_LEN -> SAFE_NAME_LEN sql/item.cc: NAME_LEN -> SAFE_NAME_LEN sql/log_event.cc: NAME_LEN -> SAFE_NAME_LEN sql/mysql_priv.h: Added SAFE_NAME_LEN sql/rpl_filter.cc: NAME_LEN -> SAFE_NAME_LEN sql/sp.cc: NAME_LEN -> SAFE_NAME_LEN sql/sp_head.cc: NAME_LEN -> SAFE_NAME_LEN sql/sql_acl.cc: NAME_LEN -> SAFE_NAME_LEN sql/sql_base.cc: NAME_LEN -> SAFE_NAME_LEN sql/sql_connect.cc: NAME_LEN -> SAFE_NAME_LEN sql/sql_parse.cc: NAME_LEN -> SAFE_NAME_LEN sql/sql_prepare.cc: NAME_LEN -> SAFE_NAME_LEN sql/sql_select.cc: NAME_LEN -> SAFE_NAME_LEN sql/sql_show.cc: NAME_LEN -> SAFE_NAME_LEN Enlarge table names for SHOW TABLES to also include optional #mysql50# sql/sql_table.cc: Fall back to use ALTER TABLE for engines that doesn't support REPAIR when doing repair for upgrade. sql/sql_trigger.cc: NAME_LEN -> SAFE_NAME_LEN sql/sql_udf.cc: NAME_LEN -> SAFE_NAME_LEN sql/sql_view.cc: NAME_LEN -> SAFE_NAME_LEN sql/table.cc: Fixed check_table_name() to not count #mysql50# as part of name If #mysql50# is part of the name, don't allow path characters in name. --- client/mysql_upgrade.c | 2 + client/mysqlcheck.c | 25 +- mysql-test/r/drop.result | 11 +- mysql-test/r/grant.result | 2 +- mysql-test/r/show_check.result | 2 +- mysql-test/r/upgrade.result | 8 + ...olloempres?9120761097220077376?cio_com.MYD | Bin 0 -> 56 bytes ...olloempres?9120761097220077376?cio_com.MYI | Bin 0 -> 6144 bytes ...olloempres?9120761097220077376?cio_com.frm | Bin 0 -> 8650 bytes .../suite/funcs_1/r/is_tables_is.result | 828 ------------------ mysql-test/t/drop.test | 5 +- mysql-test/t/grant.test | 2 +- mysql-test/t/upgrade.test | 11 + sql/ha_partition.cc | 2 +- sql/item.cc | 2 +- sql/log_event.cc | 2 +- sql/mysql_priv.h | 1 + sql/rpl_filter.cc | 4 +- sql/sp.cc | 4 +- sql/sp_head.cc | 4 +- sql/sql_acl.cc | 8 +- sql/sql_base.cc | 8 +- sql/sql_connect.cc | 4 +- sql/sql_parse.cc | 6 +- sql/sql_prepare.cc | 4 +- sql/sql_select.cc | 4 +- sql/sql_show.cc | 8 +- sql/sql_table.cc | 85 +- sql/sql_trigger.cc | 4 +- sql/sql_udf.cc | 4 +- sql/sql_view.cc | 2 +- sql/table.cc | 15 +- 32 files changed, 155 insertions(+), 912 deletions(-) create mode 100644 mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD create mode 100644 mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYI create mode 100644 mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.frm diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index a61b67d67c8..4fc1bf0c537 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -672,6 +672,7 @@ static int run_mysqlcheck_upgrade(void) "--check-upgrade", "--all-databases", "--auto-repair", + opt_verbose ? "--verbose": "", opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", NULL); } @@ -687,6 +688,7 @@ static int run_mysqlcheck_fixnames(void) "--all-databases", "--fix-db-names", "--fix-table-names", + opt_verbose ? "--verbose": "", opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", NULL); } diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 62eab5bf6e4..57f40e6b9b1 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -1,4 +1,5 @@ /* Copyright (C) 2000 MySQL AB + Copyright (C) 2010 Monty Program Ab This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,7 +16,7 @@ /* By Jani Tolonen, 2001-04-20, MySQL Development Team */ -#define CHECK_VERSION "2.5.0" +#define CHECK_VERSION "2.6.0" #include "client_priv.h" #include @@ -416,6 +417,8 @@ static int process_all_databases() MYF(0), mysql_error(sock)); return 1; } + if (verbose) + printf("Processing databases\n"); while ((row = mysql_fetch_row(tableres))) { if (process_one_db(row[0])) @@ -429,6 +432,8 @@ static int process_all_databases() static int process_databases(char **db_names) { int result = 0; + if (verbose) + printf("Processing databases\n"); for ( ; *db_names ; db_names++) { if (process_one_db(*db_names)) @@ -624,6 +629,8 @@ static int fix_database_storage_name(const char *name) static int process_one_db(char *database) { + if (verbose) + puts(database); if (what_to_do == DO_UPGRADE) { int rc= 0; @@ -731,7 +738,7 @@ static void print_result() { MYSQL_RES *res; MYSQL_ROW row; - char prev[NAME_LEN*2+2]; + char prev[(NAME_LEN+9)*2+2]; uint i; my_bool found_error=0; @@ -761,7 +768,15 @@ static void print_result() printf("%-50s %s", row[0], row[3]); else if (!status && changed) { - printf("%s\n%-9s: %s", row[0], row[2], row[3]); + /* + If the error message includes REPAIR TABLE, we assume it means + we have to run upgrade on it. In this case we write a nicer message + than "Please do "REPAIR TABLE""... + */ + if (!strcmp(row[2],"error") && strinstr(row[3],"REPAIR TABLE") != 0) + printf("%-50s %s", row[0], "Needs upgrade"); + else + printf("%s\n%-9s: %s", row[0], row[2], row[3]); if (strcmp(row[2],"note")) found_error=1; } @@ -780,7 +795,7 @@ static void print_result() static int dbConnect(char *host, char *user, char *passwd) { DBUG_ENTER("dbConnect"); - if (verbose) + if (verbose > 1) { fprintf(stderr, "# Connecting to %s...\n", host ? host : "localhost"); } @@ -813,7 +828,7 @@ static int dbConnect(char *host, char *user, char *passwd) static void dbDisconnect(char *host) { - if (verbose) + if (verbose > 1) fprintf(stderr, "# Disconnecting from %s...\n", host ? host : "localhost"); mysql_close(sock); } /* dbDisconnect */ diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result index b798b49dd34..602b2d03d80 100644 --- a/mysql-test/r/drop.result +++ b/mysql-test/r/drop.result @@ -115,9 +115,14 @@ create table `#mysql50#abc``def` ( id int ); create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); ERROR 42000: Incorrect table name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); -create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); -create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); -ERROR 42000: Incorrect table name '#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1234` (a int); +create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa12345` (a int); +ERROR 42000: Incorrect table name '#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa12345' +show tables; +Tables_in_mysqltestbug26703 +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1234 +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +#mysql50#abc`def use test; drop database mysqltestbug26703; End of 5.1 tests diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index b8f13723eb8..713b21ce7fd 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -1424,7 +1424,7 @@ ERROR 42S02: Table 'db1.../db2/tb2' doesn't exist SELECT * FROM `../db2`.tb2; ERROR 42000: SELECT command denied to user 'testbug'@'localhost' for table 'tb2' SELECT * FROM `#mysql50#/../db2/tb2`; -ERROR 42S02: Table 'db1.#mysql50#/../db2/tb2' doesn't exist +ERROR 42000: Incorrect table name '#mysql50#/../db2/tb2' DROP USER 'testbug'@localhost; DROP TABLE db2.t1; DROP DATABASE db1; diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index 4da176aa1a6..31c612500d9 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -977,7 +977,7 @@ NULL test t1 c NULL NO int NULL NULL int(11) PRI select,insert,update,reference ---------------------------------------------------------------- SHOW TABLES LIKE 't1'; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def TABLE_NAMES TABLE_NAME Tables_in_test (t1) 253 192 2 N 1 0 33 +def TABLE_NAMES TABLE_NAME Tables_in_test (t1) 253 219 2 N 1 0 33 Tables_in_test (t1) t1 ---------------------------------------------------------------- diff --git a/mysql-test/r/upgrade.result b/mysql-test/r/upgrade.result index da2f55b5bb1..bdfac990a9a 100644 --- a/mysql-test/r/upgrade.result +++ b/mysql-test/r/upgrade.result @@ -139,4 +139,12 @@ USE `#mysql50#.`; ERROR 42000: Incorrect database name '#mysql50#.' USE `#mysql50#../blablabla`; ERROR 42000: Incorrect database name '#mysql50#../blablabla' +show full tables; +Tables_in_test Table_type +#mysql50#ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com BASE TABLE +rename table `#mysql50#ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com` to `ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com`; +show full tables; +Tables_in_test Table_type +ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com BASE TABLE +drop table `ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com`; # End of 5.1 tests diff --git a/mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD b/mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD new file mode 100644 index 0000000000000000000000000000000000000000..2ff33451b5f29ba1683c5f1d2a1d54b514c846ee GIT binary patch literal 56 zcmZQ%5M}zu$iTqBoR*)@mROtuL>mO^e3%)e85#aEfh3X=ix{{V42_IUOwG(KEDb=? F3;EB(yQ$@cJhRJf-6L|T?0yF%e06c;R<8q}V!$oOFw@MK+RW>g2WV?>u z=$$5CqOxTZA?X0Q{-&l4xOqK1PxGGY+B$F9)YL1dbI-iqrtX8s|D+or?u$C$Rq~Ru zBqV|C!_B$=6Hai(4o}!aU0gNRwUXt2#sOFni0VR>x>cH^eBk(uH1;@V{-Mw zeSPh&Rdes^GMcKsX~3#?nhNe#vjzI`%hTo-M&KU;Cz=y~U)Ry}&QB-L&Ak0(N5@7Z zUPz=wmtvMm1>>fds`YKm*%38${Oc`<^5Jl8^%xu@xmZ{lqDS#EOO0E(}wv TZM$5s${lX$R`gv;@4S2iM%OT% literal 0 HcmV?d00001 diff --git a/mysql-test/suite/funcs_1/r/is_tables_is.result b/mysql-test/suite/funcs_1/r/is_tables_is.result index bcfe138206e..59e5c6ecf57 100644 --- a/mysql-test/suite/funcs_1/r/is_tables_is.result +++ b/mysql-test/suite/funcs_1/r/is_tables_is.result @@ -245,351 +245,6 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema -TABLE_NAME INNODB_BUFFER_POOL_PAGES -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_BUFFER_POOL_PAGES_BLOB -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_BUFFER_POOL_PAGES_INDEX -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_CMP -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_CMPMEM -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_CMPMEM_RESET -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_CMP_RESET -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_INDEX_STATS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_LOCKS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_LOCK_WAITS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_RSEG -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_SYS_INDEXES -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_SYS_TABLES -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_TABLE_STATS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_TRX -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema TABLE_NAME KEY_COLUMN_USAGE TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -636,29 +291,6 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema -TABLE_NAME PBXT_STATISTICS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema TABLE_NAME PLUGINS TABLE_TYPE SYSTEM VIEW ENGINE MYISAM_OR_MARIA @@ -1002,52 +634,6 @@ CREATE_OPTIONS #CO# TABLE_COMMENT #TC# user_comment Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME XTRADB_ADMIN_COMMAND -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME XTRADB_ENHANCEMENTS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- DROP USER testuser1@localhost; CREATE USER testuser1@localhost; GRANT SELECT ON test1.* TO testuser1@localhost; @@ -1297,351 +883,6 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema -TABLE_NAME INNODB_BUFFER_POOL_PAGES -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_BUFFER_POOL_PAGES_BLOB -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_BUFFER_POOL_PAGES_INDEX -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_CMP -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_CMPMEM -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_CMPMEM_RESET -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_CMP_RESET -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_INDEX_STATS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_LOCKS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_LOCK_WAITS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_RSEG -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_SYS_INDEXES -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_SYS_TABLES -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_TABLE_STATS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME INNODB_TRX -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema TABLE_NAME KEY_COLUMN_USAGE TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -1688,29 +929,6 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema -TABLE_NAME PBXT_STATISTICS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema TABLE_NAME PLUGINS TABLE_TYPE SYSTEM VIEW ENGINE MYISAM_OR_MARIA @@ -2054,52 +1272,6 @@ CREATE_OPTIONS #CO# TABLE_COMMENT #TC# user_comment Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME XTRADB_ADMIN_COMMAND -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- -TABLE_CATALOG NULL -TABLE_SCHEMA information_schema -TABLE_NAME XTRADB_ENHANCEMENTS -TABLE_TYPE SYSTEM VIEW -ENGINE MEMORY -VERSION 10 -ROW_FORMAT Fixed -TABLE_ROWS #TBLR# -AVG_ROW_LENGTH #ARL# -DATA_LENGTH #DL# -MAX_DATA_LENGTH #MDL# -INDEX_LENGTH #IL# -DATA_FREE #DF# -AUTO_INCREMENT NULL -CREATE_TIME #CRT# -UPDATE_TIME #UT# -CHECK_TIME #CT# -TABLE_COLLATION utf8_general_ci -CHECKSUM NULL -CREATE_OPTIONS #CO# -TABLE_COMMENT #TC# -user_comment -Separator ----------------------------------------------------- # Switch to connection default and close connection testuser1 DROP USER testuser1@localhost; DROP DATABASE test1; diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index bb4dd3e11f9..66fe3bb03b2 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -195,9 +195,10 @@ create table `#mysql50#abc``def` ( id int ); --error ER_WRONG_TABLE_NAME create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); -create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); +create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1234` (a int); --error ER_WRONG_TABLE_NAME -create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); +create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa12345` (a int); +show tables; use test; drop database mysqltestbug26703; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 5bdb3ebe9bf..65e987dfa24 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -1541,7 +1541,7 @@ connect (con1,localhost,testbug,,db1); SELECT * FROM `../db2/tb2`; --error ER_TABLEACCESS_DENIED_ERROR SELECT * FROM `../db2`.tb2; ---error ER_NO_SUCH_TABLE +--error ER_WRONG_TABLE_NAME SELECT * FROM `#mysql50#/../db2/tb2`; connection default; disconnect con1; diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test index a7b9a1531ff..a3ae6b1298a 100644 --- a/mysql-test/t/upgrade.test +++ b/mysql-test/t/upgrade.test @@ -169,5 +169,16 @@ USE `#mysql50#.`; --error ER_WRONG_DB_NAME USE `#mysql50#../blablabla`; +# +# Test of Bug #56441: mysql_upgrade 5.0->5.1 fails for tables with long names +# +copy_file std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYI $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYI; +copy_file std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD; +copy_file std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.frm $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.frm; +show full tables; +rename table `#mysql50#ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com` to `ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com`; +show full tables; +drop table `ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com`; + --echo # End of 5.1 tests diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 9e07ea7258f..bde8ff053e7 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -996,7 +996,7 @@ static bool print_admin_msg(THD* thd, const char* msg_type, Protocol *protocol= thd->protocol; uint length, msg_length; char msgbuf[HA_MAX_MSG_BUF]; - char name[NAME_LEN*2+2]; + char name[SAFE_NAME_LEN*2+2]; va_start(args, fmt); msg_length= my_vsnprintf(msgbuf, sizeof(msgbuf), fmt, args); diff --git a/sql/item.cc b/sql/item.cc index ecd208b838d..1c1137fa75c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3728,7 +3728,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list) int found_match_degree= 0; Item_ident *cur_field; int cur_match_degree= 0; - char name_buff[NAME_LEN+1]; + char name_buff[SAFE_NAME_LEN+1]; if (find_item->type() == Item::FIELD_ITEM || find_item->type() == Item::REF_ITEM) diff --git a/sql/log_event.cc b/sql/log_event.cc index 3db7929331d..262e8cae705 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -6234,7 +6234,7 @@ void Create_file_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) void Create_file_log_event::pack_info(Protocol *protocol) { - char buf[NAME_LEN*2 + 30 + 21*2], *pos; + char buf[SAFE_NAME_LEN*2 + 30 + 21*2], *pos; pos= strmov(buf, "db="); memcpy(pos, db, db_len); pos= strmov(pos + db_len, ";table="); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index bc2cff9ac50..efb92108781 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -2288,6 +2288,7 @@ const char *get_canonical_filename(handler *file, const char *path, #define MYSQL50_TABLE_NAME_PREFIX "#mysql50#" #define MYSQL50_TABLE_NAME_PREFIX_LENGTH 9 +#define SAFE_NAME_LEN (NAME_LEN + MYSQL50_TABLE_NAME_PREFIX_LENGTH) uint build_table_shadow_filename(char *buff, size_t bufflen, ALTER_PARTITION_PARAM_TYPE *lpt); diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc index ee3fc358b60..ae5808de9e9 100644 --- a/sql/rpl_filter.cc +++ b/sql/rpl_filter.cc @@ -91,7 +91,7 @@ Rpl_filter::tables_ok(const char* db, TABLE_LIST* tables) for (; tables; tables= tables->next_global) { - char hash_key[2*NAME_LEN+2]; + char hash_key[SAFE_NAME_LEN*2+2]; char *end; uint len; @@ -225,7 +225,7 @@ Rpl_filter::db_ok_with_wild_table(const char *db) { DBUG_ENTER("Rpl_filter::db_ok_with_wild_table"); - char hash_key[NAME_LEN+2]; + char hash_key[SAFE_NAME_LEN+2]; char *end; int len; end= strmov(hash_key, db); diff --git a/sql/sp.cc b/sql/sp.cc index ddddaee2e10..bcfcb0c4f36 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -717,7 +717,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, { LEX *old_lex= thd->lex, newlex; String defstr; - char saved_cur_db_name_buf[NAME_LEN+1]; + char saved_cur_db_name_buf[SAFE_NAME_LEN+1]; LEX_STRING saved_cur_db_name= { saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) }; bool cur_db_changed; @@ -1928,7 +1928,7 @@ sp_cache_routines_and_add_tables_aux(THD *thd, LEX *lex, Hence, the overrun happens only if the name is in length > 32 and uses multibyte (cyrillic, greek, etc.) */ - char n[NAME_LEN*2+2]; + char n[SAFE_NAME_LEN*2+2]; /* m_qname.str is not always \0 terminated */ memcpy(n, name.m_qname.str, name.m_qname.length); diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 1084c3efc82..2d5eb24de7f 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1085,7 +1085,7 @@ bool sp_head::execute(THD *thd) { DBUG_ENTER("sp_head::execute"); - char saved_cur_db_name_buf[NAME_LEN+1]; + char saved_cur_db_name_buf[SAFE_NAME_LEN+1]; LEX_STRING saved_cur_db_name= { saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) }; bool cur_db_changed= FALSE; @@ -3851,7 +3851,7 @@ sp_head::merge_table_list(THD *thd, TABLE_LIST *table, LEX *lex_for_tmp_check) for (; table ; table= table->next_global) if (!table->derived && !table->schema_table) { - char tname[(NAME_LEN + 1) * 3]; // db\0table\0alias\0 + char tname[(SAFE_NAME_LEN + 1) * 3]; // db\0table\0alias\0 uint tlen, alen; tlen= table->db_length; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 5e03175dd72..24f590f893a 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -313,7 +313,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) READ_RECORD read_record_info; my_bool return_val= TRUE; bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; - char tmp_name[NAME_LEN+1]; + char tmp_name[SAFE_NAME_LEN+1]; int password_length; ulong old_sql_mode= thd->variables.sql_mode; DBUG_ENTER("acl_load"); @@ -2453,7 +2453,7 @@ static GRANT_NAME *name_hash_search(HASH *name_hash, const char *user, const char *tname, bool exact, bool name_tolower) { - char helping [NAME_LEN*2+USERNAME_LENGTH+3], *name_ptr; + char helping [SAFE_NAME_LEN*2+USERNAME_LENGTH+3], *name_ptr; uint len; GRANT_NAME *grant_name,*found=0; HASH_SEARCH_STATE state; @@ -3431,7 +3431,7 @@ bool mysql_grant(THD *thd, const char *db, List &list, { List_iterator str_list (list); LEX_USER *Str, *tmp_Str; - char tmp_db[NAME_LEN+1]; + char tmp_db[SAFE_NAME_LEN+1]; bool create_new_users=0; TABLE_LIST tables[2]; bool save_binlog_row_based; @@ -4316,7 +4316,7 @@ static bool check_grant_db_routine(THD *thd, const char *db, HASH *hash) bool check_grant_db(THD *thd,const char *db) { Security_context *sctx= thd->security_ctx; - char helping [NAME_LEN+USERNAME_LENGTH+2]; + char helping [SAFE_NAME_LEN + USERNAME_LENGTH+2]; uint len; bool error= TRUE; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 1c8648afafd..33ea834247e 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -613,7 +613,7 @@ void release_table_share(TABLE_SHARE *share, enum release_type type) TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name) { - char key[NAME_LEN*2+2]; + char key[SAFE_NAME_LEN*2+2]; TABLE_LIST table_list; uint key_length; safe_mutex_assert_owner(&LOCK_open); @@ -6311,7 +6311,7 @@ find_field_in_tables(THD *thd, Item_ident *item, const char *table_name= item->table_name; const char *name= item->field_name; uint length=(uint) strlen(name); - char name_buff[NAME_LEN+1]; + char name_buff[SAFE_NAME_LEN+1]; TABLE_LIST *cur_table= first_table; TABLE_LIST *actual_table; bool allow_rowid; @@ -6468,7 +6468,7 @@ find_field_in_tables(THD *thd, Item_ident *item, (report_error == REPORT_ALL_ERRORS || report_error == REPORT_EXCEPT_NON_UNIQUE)) { - char buff[NAME_LEN*2 + 2]; + char buff[SAFE_NAME_LEN*2 + 2]; if (db && db[0]) { strxnmov(buff,sizeof(buff)-1,db,".",table_name,NullS); @@ -7854,7 +7854,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, { Field_iterator_table_ref field_iterator; bool found; - char name_buff[NAME_LEN+1]; + char name_buff[SAFE_NAME_LEN+1]; DBUG_ENTER("insert_fields"); DBUG_PRINT("arena", ("stmt arena: 0x%lx", (ulong)thd->stmt_arena)); diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 67d52b26900..4811ce3cb45 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -851,8 +851,8 @@ static int check_connection(THD *thd) char *passwd= strend(user)+1; uint user_len= passwd - user - 1; char *db= passwd; - char db_buff[NAME_LEN + 1]; // buffer to store db in utf8 - char user_buff[USERNAME_LENGTH + 1]; // buffer to store user in utf8 + char db_buff[SAFE_NAME_LEN*2 + 1]; // buffer to store db in utf8 + char user_buff[USERNAME_LENGTH*2 + 1]; // buffer to store user in utf8 uint dummy_errors; /* diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index fddd8626a19..0148854165e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1125,7 +1125,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, Cast *passwd to an unsigned char, so that it doesn't extend the sign for *passwd > 127 and become 2**32-127 after casting to uint. */ - char db_buff[NAME_LEN+1]; // buffer to store db in utf8 + char db_buff[SAFE_NAME_LEN*2+1]; // buffer to store db in utf8 char *db= passwd; char *save_db; /* @@ -1329,7 +1329,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, char *fields, *packet_end= packet + packet_length, *wildcard; /* Locked closure of all tables */ TABLE_LIST table_list; - char db_buff[NAME_LEN+1]; + char db_buff[SAFE_NAME_LEN+1]; uint32 db_length; uint dummy_errors, query_length; @@ -1348,7 +1348,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, db_length= wildcard - packet; wildcard++; query_length= (uint) (packet_end - wildcard); // Don't count end \0 - if (db_length > NAME_LEN || query_length > NAME_LEN) + if (db_length > SAFE_NAME_LEN || query_length > NAME_LEN) { my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); break; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index f5594dfe520..cde5005b038 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -3338,7 +3338,7 @@ reexecute: bool Prepared_statement::reprepare() { - char saved_cur_db_name_buf[NAME_LEN+1]; + char saved_cur_db_name_buf[SAFE_NAME_LEN+1]; LEX_STRING saved_cur_db_name= { saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) }; LEX_STRING stmt_db_name= { db, db_length }; @@ -3499,7 +3499,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) Query_arena *old_stmt_arena; bool error= TRUE; - char saved_cur_db_name_buf[NAME_LEN+1]; + char saved_cur_db_name_buf[SAFE_NAME_LEN+1]; LEX_STRING saved_cur_db_name= { saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) }; bool cur_db_changed; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f7da7413eef..8381e257e26 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -16707,7 +16707,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, the UNION to provide precise EXPLAIN information will hardly be appreciated :) */ - char table_name_buffer[NAME_LEN]; + char table_name_buffer[SAFE_NAME_LEN]; item_list.empty(); /* id */ item_list.push_back(new Item_null); @@ -16780,7 +16780,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, char buff1[512], buff2[512], buff3[512]; char keylen_str_buf[64]; String extra(buff, sizeof(buff),cs); - char table_name_buffer[NAME_LEN]; + char table_name_buffer[SAFE_NAME_LEN]; String tmp1(buff1,sizeof(buff1),cs); String tmp2(buff2,sizeof(buff2),cs); String tmp3(buff3,sizeof(buff3),cs); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 30d6b13b0c9..683b0e67929 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -493,7 +493,7 @@ find_files(THD *thd, List *files, const char *db, for (i=0 ; i < (uint) dirp->number_off_files ; i++) { - char uname[NAME_LEN + 1]; /* Unencoded name */ + char uname[SAFE_NAME_LEN + 1]; /* Unencoded name */ file=dirp->dir_entry+i; if (dir) { /* Return databases */ @@ -4254,7 +4254,7 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, MYSQL_TIME time; LEX *lex= thd->lex; CHARSET_INFO *cs= system_charset_info; - char sp_db_buff[NAME_LEN + 1], sp_name_buff[NAME_LEN + 1], + char sp_db_buff[SAFE_NAME_LEN + 1], sp_name_buff[SAFE_NAME_LEN + 1], definer_buff[USERNAME_LENGTH + HOSTNAME_LENGTH + 2]; String sp_db(sp_db_buff, sizeof(sp_db_buff), cs); String sp_name(sp_name_buff, sizeof(sp_name_buff), cs); @@ -6589,8 +6589,8 @@ ST_FIELD_INFO table_names_fields_info[]= { {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, {"TABLE_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, - {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Tables_in_", - SKIP_OPEN_TABLE}, + {"TABLE_NAME", NAME_CHAR_LEN + MYSQL50_TABLE_NAME_PREFIX_LENGTH, + MYSQL_TYPE_STRING, 0, 0, "Tables_in_", SKIP_OPEN_TABLE}, {"TABLE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_type", OPEN_FRM_ONLY}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 1d3bb23cc3d..a0621dbbdcf 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -54,6 +54,7 @@ static bool mysql_prepare_alter_table(THD *thd, TABLE *table, HA_CREATE_INFO *create_info, Alter_info *alter_info); +static bool admin_recreate_table(THD *thd, TABLE_LIST *table_list); #ifndef DBUG_OFF @@ -4172,7 +4173,7 @@ mysql_rename_table(handlerton *base, const char *old_db, char from[FN_REFLEN + 1], to[FN_REFLEN + 1], lc_from[FN_REFLEN + 1], lc_to[FN_REFLEN + 1]; char *from_base= from, *to_base= to; - char tmp_name[NAME_LEN+1]; + char tmp_name[SAFE_NAME_LEN+1]; handler *file; int error=0; DBUG_ENTER("mysql_rename_table"); @@ -4567,6 +4568,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, Protocol *protocol= thd->protocol; LEX *lex= thd->lex; int result_code; + bool need_repair_or_alter= 0; DBUG_ENTER("mysql_admin_table"); if (end_active_trans(thd)) @@ -4587,7 +4589,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, for (table= tables; table; table= table->next_local) { - char table_name[NAME_LEN*2+2]; + char table_name[SAFE_NAME_LEN*2+2]; char* db = table->db; bool fatal_error=0; @@ -4795,32 +4797,35 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, if (operator_func == &handler::ha_repair && !(check_opt->sql_flags & TT_USEFRM)) { - if ((table->table->file->check_old_types() == HA_ADMIN_NEEDS_ALTER) || - (table->table->file->ha_check_for_upgrade(check_opt) == - HA_ADMIN_NEEDS_ALTER)) + handler *file= table->table->file; + int check_old_types= file->check_old_types(); + int check_for_upgrade= file->ha_check_for_upgrade(check_opt); + + if (check_old_types == HA_ADMIN_NEEDS_ALTER || + check_for_upgrade == HA_ADMIN_NEEDS_ALTER) { - DBUG_PRINT("admin", ("recreating table")); - ha_autocommit_or_rollback(thd, 1); - close_thread_tables(thd); - tmp_disable_binlog(thd); // binlogging is done by caller if wanted - result_code= mysql_recreate_table(thd, table); - reenable_binlog(thd); - /* - mysql_recreate_table() can push OK or ERROR. - Clear 'OK' status. If there is an error, keep it: - we will store the error message in a result set row - and then clear. - */ - if (thd->main_da.is_ok()) - thd->main_da.reset_diagnostics_area(); + result_code= admin_recreate_table(thd, table); goto send_result; } + if (check_old_types || check_for_upgrade) + { + /* If repair is not implemented for the engine, run ALTER TABLE */ + need_repair_or_alter= 1; + } } DBUG_PRINT("admin", ("calling operator_func '%s'", operator_name)); result_code = (table->table->file->*operator_func)(thd, check_opt); DBUG_PRINT("admin", ("operator_func returned: %d", result_code)); + if (result_code == HA_ADMIN_NOT_IMPLEMENTED && need_repair_or_alter) + { + /* + repair was not implemented and we need to upgrade the table + to a new version so we recreate the table with ALTER TABLE + */ + result_code= admin_recreate_table(thd, table); + } send_result: lex->cleanup_after_one_table_open(); @@ -4920,23 +4925,13 @@ send_result_message: system_charset_info); if (protocol->write()) goto err; - ha_autocommit_or_rollback(thd, 0); - close_thread_tables(thd); DBUG_PRINT("info", ("HA_ADMIN_TRY_ALTER, trying analyze...")); TABLE_LIST *save_next_local= table->next_local, *save_next_global= table->next_global; table->next_local= table->next_global= 0; - tmp_disable_binlog(thd); // binlogging is done by caller if wanted - result_code= mysql_recreate_table(thd, table); - reenable_binlog(thd); - /* - mysql_recreate_table() can push OK or ERROR. - Clear 'OK' status. If there is an error, keep it: - we will store the error message in a result set row - and then clear. - */ - if (thd->main_da.is_ok()) - thd->main_da.reset_diagnostics_area(); + + result_code= admin_recreate_table(thd, table); + ha_autocommit_or_rollback(thd, 0); close_thread_tables(thd); if (!result_code) // recreation went ok @@ -7954,6 +7949,30 @@ err: } +/* Prepare, run and cleanup for mysql_recreate_table() */ + +static bool admin_recreate_table(THD *thd, TABLE_LIST *table_list) +{ + bool result_code; + DBUG_ENTER("admin_recreate_table"); + + ha_autocommit_or_rollback(thd, 1); + close_thread_tables(thd); + tmp_disable_binlog(thd); // binlogging is done by caller if wanted + result_code= mysql_recreate_table(thd, table_list); + reenable_binlog(thd); + /* + mysql_recreate_table() can push OK or ERROR. + Clear 'OK' status. If there is an error, keep it: + we will store the error message in a result set row + and then clear. + */ + if (thd->main_da.is_ok()) + thd->main_da.reset_diagnostics_area(); + DBUG_RETURN(result_code); +} + + /* Recreates tables by calling mysql_alter_table(). @@ -8010,7 +8029,7 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, /* Open one table after the other to keep lock time as short as possible. */ for (table= tables; table; table= table->next_local) { - char table_name[NAME_LEN*2+2]; + char table_name[SAFE_NAME_LEN*2+2]; TABLE *t; strxmov(table_name, table->db ,".", table->table_name, NullS); diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index bf4a46a4c67..e8a382ca8f6 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1391,7 +1391,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, To remove this prefix we use check_n_cut_mysql50_prefix(). */ - char fname[NAME_LEN + 1]; + char fname[SAFE_NAME_LEN + 1]; DBUG_ASSERT((!my_strcasecmp(table_alias_charset, lex.query_tables->db, db) || (check_n_cut_mysql50_prefix(db, fname, sizeof(fname)) && !my_strcasecmp(table_alias_charset, lex.query_tables->db, fname))) && @@ -1917,7 +1917,7 @@ bool Table_triggers_list::change_table_name(THD *thd, const char *db, */ if (my_strcasecmp(table_alias_charset, db, new_db)) { - char dbname[NAME_LEN + 1]; + char dbname[SAFE_NAME_LEN + 1]; if (check_n_cut_mysql50_prefix(db, dbname, sizeof(dbname)) && !my_strcasecmp(table_alias_charset, dbname, new_db)) { diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index d455a66c4f2..584704d869f 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -209,7 +209,7 @@ void udf_init() } tmp->dlhandle = dl; { - char buf[NAME_LEN+16], *missing; + char buf[SAFE_NAME_LEN+16], *missing; if ((missing= init_syms(tmp, buf))) { sql_print_error(ER(ER_CANT_FIND_DL_ENTRY), missing); @@ -463,7 +463,7 @@ int mysql_create_function(THD *thd,udf_func *udf) } udf->dlhandle=dl; { - char buf[NAME_LEN+16], *missing; + char buf[SAFE_NAME_LEN+16], *missing; if ((missing= init_syms(udf, buf))) { my_error(ER_CANT_FIND_DL_ENTRY, MYF(0), missing); diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 280d33aa654..4d92f234ed0 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1189,7 +1189,7 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, table->view= lex= thd->lex= (LEX*) new(thd->mem_root) st_lex_local; { - char old_db_buf[NAME_LEN+1]; + char old_db_buf[SAFE_NAME_LEN+1]; LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) }; bool dbchanged; Parser_state parser_state; diff --git a/sql/table.cc b/sql/table.cc index 2129da90a29..a7ed2dd40ff 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2699,15 +2699,15 @@ bool check_db_name(LEX_STRING *org_name) uint name_length= org_name->length; bool check_for_path_chars; - if (!name_length || name_length > NAME_LEN) - return 1; - if ((check_for_path_chars= check_mysql50_prefix(name))) { name+= MYSQL50_TABLE_NAME_PREFIX_LENGTH; name_length-= MYSQL50_TABLE_NAME_PREFIX_LENGTH; } + if (!name_length || name_length > NAME_LEN) + return 1; + if (lower_case_table_names && name != any_db) my_casedn_str(files_charset_info, name); @@ -2725,6 +2725,15 @@ bool check_table_name(const char *name, uint length, bool check_for_path_chars) { uint name_length= 0; // name length in symbols const char *end= name+length; + + + if (!check_for_path_chars && + (check_for_path_chars= check_mysql50_prefix(name))) + { + name+= MYSQL50_TABLE_NAME_PREFIX_LENGTH; + length-= MYSQL50_TABLE_NAME_PREFIX_LENGTH; + } + if (!length || length > NAME_LEN) return 1; #if defined(USE_MB) && defined(USE_MB_IDENT) From 9f85560212241f07b7bdff7df639c0b9a519bed5 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 3 Sep 2010 20:55:56 +0300 Subject: [PATCH 099/118] Enable archive tables to work with mysql_upgrade / repair Made long file names from previous patch shorter mysql-test/r/archive.result: Added testing of repair (for upgrade) of 5.0 tables. mysql-test/std_data/archive_5_0.ARM: Archive table created in MySQL 5.0 mysql-test/std_data/archive_5_0.ARZ: Archive table created in MySQL 5.0 mysql-test/std_data/archive_5_0.frm: Archive table created in MySQL 5.0 mysql-test/std_data/long_table_name.MYD: Made long file names shorter mysql-test/std_data/long_table_name.MYI: Made long file names shorter mysql-test/std_data/long_table_name.frm: Made long file names shorter mysql-test/t/archive.test: Added testing of repair (for upgrade) of 5.0 tables. sql/sql_table.cc: Allow recreate to open crashed tables. sql/table.cc: Fix error message if storage engine doesn't exists. storage/archive/azio.c: Reset status values in case archive is of old versions storage/archive/ha_archive.cc: Fix to allow one to open old versions of table during repair Reset status variables for old version tables If the the table is of old version, force upgrade with ALTER TABLE when doing repair storage/archive/ha_archive.h: Added variables to detect old versions --- mysql-test/r/archive.result | 12 ++++- mysql-test/std_data/archive_5_0.ARM | Bin 0 -> 19 bytes mysql-test/std_data/archive_5_0.ARZ | Bin 0 -> 138 bytes mysql-test/std_data/archive_5_0.frm | Bin 0 -> 8578 bytes ...077376?cio_com.MYD => long_table_name.MYD} | Bin ...077376?cio_com.MYI => long_table_name.MYI} | Bin ...077376?cio_com.frm => long_table_name.frm} | Bin mysql-test/t/archive.test | 13 ++++++ sql/sql_table.cc | 3 ++ sql/table.cc | 3 +- storage/archive/azio.c | 11 +++++ storage/archive/ha_archive.cc | 42 +++++++++++++----- storage/archive/ha_archive.h | 3 +- 13 files changed, 72 insertions(+), 15 deletions(-) create mode 100644 mysql-test/std_data/archive_5_0.ARM create mode 100644 mysql-test/std_data/archive_5_0.ARZ create mode 100644 mysql-test/std_data/archive_5_0.frm rename mysql-test/std_data/{ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD => long_table_name.MYD} (100%) rename mysql-test/std_data/{ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYI => long_table_name.MYI} (100%) rename mysql-test/std_data/{ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.frm => long_table_name.frm} (100%) diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index f90bcb521e1..5a731e6476c 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -12725,8 +12725,7 @@ INSERT INTO t1 (col1, col2) VALUES (1, "value"); ERROR HY000: Table upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it! REPAIR TABLE t1; Table Op Msg_type Msg_text -test.t1 repair Error Table upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it! -test.t1 repair error Corrupt +test.t1 repair status OK DROP TABLE t1; # # BUG#48757 - missing .ARZ file causes server crash @@ -12756,3 +12755,12 @@ a 1 2 DROP TABLE t1; +select * from t1; +ERROR HY000: Table upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it! +repair table t1; +Table Op Msg_type Msg_text +test.t1 repair status OK +select sum(length(a)),sum(b) from t1; +sum(length(a)) sum(b) +8670 187 +drop table t1; diff --git a/mysql-test/std_data/archive_5_0.ARM b/mysql-test/std_data/archive_5_0.ARM new file mode 100644 index 0000000000000000000000000000000000000000..8f1111437d81045087daaefaa2d8dea0e7173954 GIT binary patch literal 19 McmeyzsKkH<02M(2A^-pY literal 0 HcmV?d00001 diff --git a/mysql-test/std_data/archive_5_0.ARZ b/mysql-test/std_data/archive_5_0.ARZ new file mode 100644 index 0000000000000000000000000000000000000000..d24e76884cccf9df7d5c17e9733816fa17411b36 GIT binary patch literal 138 zcmb2|=3oE==HJIT7^2=i+`|Oq%ELu}eYP)5Vb)_~YqS49+0870g$*SC|Nq-dj)Dvd z3@i)R-L`MyKfakQ<-v@ECeD7&nFeYphh|LROmPpm>?L;ENbXELP$W65CndE62kNF7Q7ebO6agi!u~V8{-S9= z+k2Rzv_NTql`e4Fyi0OS02g<8%1Ui+cfhBhu7N6TxKe-u6rcbFC_n)UP=Epypa2CZ z@UsGf(BJLT_0bTUG1jNeZhzhm@$q~!1t>rP3Q&Lo6rcbFC_n)U{GY(p=%@dH%Rtbe z(5VM!M!mxkbIoHlup+Z%^<^Q0v^p~(9WptD*C7`@W~vhuPP~U0EMj0a2yN&Bo*PaT Avj6}9 literal 0 HcmV?d00001 diff --git a/mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD b/mysql-test/std_data/long_table_name.MYD similarity index 100% rename from mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD rename to mysql-test/std_data/long_table_name.MYD diff --git a/mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYI b/mysql-test/std_data/long_table_name.MYI similarity index 100% rename from mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYI rename to mysql-test/std_data/long_table_name.MYI diff --git a/mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.frm b/mysql-test/std_data/long_table_name.frm similarity index 100% rename from mysql-test/std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.frm rename to mysql-test/std_data/long_table_name.frm diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index 6704257f9af..7478c7dcdce 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1680,3 +1680,16 @@ SELECT * FROM t1; REPAIR TABLE t1 EXTENDED; SELECT * FROM t1; DROP TABLE t1; + +# +# Bug #47012 archive tables are not upgradeable, and server crashes on +# any access +# +copy_file std_data/archive_5_0.frm $MYSQLD_DATADIR/test/t1.frm; +copy_file std_data/archive_5_0.ARZ $MYSQLD_DATADIR/test/t1.ARZ; +copy_file std_data/archive_5_0.ARM $MYSQLD_DATADIR/test/t1.ARM; +--error ER_TABLE_NEEDS_UPGRADE +select * from t1; +repair table t1; +select sum(length(a)),sum(b) from t1; +drop table t1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index a0621dbbdcf..96be7c4437c 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4804,7 +4804,10 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, if (check_old_types == HA_ADMIN_NEEDS_ALTER || check_for_upgrade == HA_ADMIN_NEEDS_ALTER) { + /* We use extra_open_options to be able to open crashed tables */ + thd->open_options|= extra_open_options; result_code= admin_recreate_table(thd, table); + thd->open_options= ~extra_open_options; goto send_result; } if (check_old_types || check_for_upgrade) diff --git a/sql/table.cc b/sql/table.cc index a7ed2dd40ff..a3c6f07cddf 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -866,7 +866,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, /* Read extra data segment */ uchar *buff, *next_chunk, *buff_end; DBUG_PRINT("info", ("extra segment size is %u bytes", n_length)); - if (!(next_chunk= buff= (uchar*) my_malloc(n_length, MYF(MY_WME)))) + if (!(next_chunk= buff= (uchar*) my_malloc(n_length+1, MYF(MY_WME)))) goto err; if (my_pread(file, buff, n_length, record_offset + share->reclength, MYF(MY_NABP))) @@ -945,6 +945,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, { /* purecov: begin inspected */ error= 8; + name.str[name.length]= 0; my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), name.str); my_free(buff, MYF(0)); goto err; diff --git a/storage/archive/azio.c b/storage/archive/azio.c index a24350dd454..fc54d98ab15 100644 --- a/storage/archive/azio.c +++ b/storage/archive/azio.c @@ -150,6 +150,17 @@ int az_open (azio_stream *s, const char *path, int Flags, File fd) } else { + /* Reset values in case of old version of archive file */ + s->rows= 0; + s->forced_flushes= 0; + s->shortest_row= 0; + s->longest_row= 0; + s->auto_increment= 0; + s->check_point= 0; + s->comment_start_pos= 0; + s->comment_length= 0; + s->frm_start_pos= 0; + s->frm_length= 0; check_header(s); /* skip the .az header */ } diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 988337ec50e..d0cb34455b9 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -293,7 +293,7 @@ int ha_archive::read_data_header(azio_stream *file_to_read) DBUG_PRINT("ha_archive", ("Version %u", data_buffer[1])); if ((data_buffer[0] != (uchar)ARCHIVE_CHECK_HEADER) && - (data_buffer[1] != (uchar)ARCHIVE_VERSION)) + (data_buffer[1] == 1 || data_buffer[1] == 2)) DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); DBUG_RETURN(0); @@ -360,9 +360,19 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc) my_free(share, MYF(0)); DBUG_RETURN(NULL); } - stats.auto_increment_value= archive_tmp.auto_increment + 1; - share->rows_recorded= (ha_rows)archive_tmp.rows; - share->crashed= archive_tmp.dirty; + share->version= archive_tmp.version; + if (archive_tmp.version == ARCHIVE_VERSION) + { + stats.auto_increment_value= archive_tmp.auto_increment + 1; + share->rows_recorded= (ha_rows)archive_tmp.rows; + share->crashed= archive_tmp.dirty; + } + else + { + /* Used by repair */ + share->rows_recorded= ~(ha_rows) 0; + stats.auto_increment_value= 0; + } /* If archive version is less than 3, It should be upgraded before use. @@ -512,10 +522,19 @@ int ha_archive::open(const char *name, int mode, uint open_options) case 0: break; case HA_ERR_CRASHED_ON_USAGE: + DBUG_PRINT("ha_archive", ("archive table was crashed")); if (open_options & HA_OPEN_FOR_REPAIR) + { + rc= 0; break; + } /* fall through */ case HA_ERR_TABLE_NEEDS_UPGRADE: + if (open_options & HA_OPEN_FOR_REPAIR) + { + rc= 0; + break; + } free_share(); /* fall through */ default: @@ -535,13 +554,6 @@ int ha_archive::open(const char *name, int mode, uint open_options) thr_lock_data_init(&share->lock, &lock, NULL); - DBUG_PRINT("ha_archive", ("archive table was crashed %s", - rc == HA_ERR_CRASHED_ON_USAGE ? "yes" : "no")); - if (rc == HA_ERR_CRASHED_ON_USAGE && open_options & HA_OPEN_FOR_REPAIR) - { - DBUG_RETURN(0); - } - DBUG_RETURN(rc); } @@ -1267,6 +1279,14 @@ int ha_archive::rnd_pos(uchar * buf, uchar *pos) DBUG_RETURN(get_row(&archive, buf)); } +int ha_archive::check_for_upgrade(HA_CHECK_OPT *check_opt) +{ + if (share->version < ARCHIVE_VERSION) + return HA_ADMIN_NEEDS_ALTER; + return 0; +} + + /* This method repairs the meta file. It does this by walking the datafile and rewriting the meta file. If EXTENDED repair is requested, we attempt to diff --git a/storage/archive/ha_archive.h b/storage/archive/ha_archive.h index ab630ed22fd..653a13b242d 100644 --- a/storage/archive/ha_archive.h +++ b/storage/archive/ha_archive.h @@ -35,7 +35,7 @@ typedef struct st_archive_record_buffer { typedef struct st_archive_share { char *table_name; char data_file_name[FN_REFLEN]; - uint table_name_length,use_count; + uint table_name_length,use_count, version; pthread_mutex_t mutex; THR_LOCK lock; azio_stream archive_write; /* Archive file we are working with */ @@ -133,6 +133,7 @@ public: int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); int optimize(THD* thd, HA_CHECK_OPT* check_opt); int repair(THD* thd, HA_CHECK_OPT* check_opt); + int check_for_upgrade(HA_CHECK_OPT *check_opt); void start_bulk_insert(ha_rows rows); int end_bulk_insert(); enum row_type get_row_type() const From 544cdf767a9b70e979085bbc46cf5a4a65c26e58 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 3 Sep 2010 21:07:53 +0300 Subject: [PATCH 100/118] Update test to use the shorter table names --- mysql-test/t/upgrade.test | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test index a3ae6b1298a..fad69902605 100644 --- a/mysql-test/t/upgrade.test +++ b/mysql-test/t/upgrade.test @@ -172,9 +172,9 @@ USE `#mysql50#../blablabla`; # # Test of Bug #56441: mysql_upgrade 5.0->5.1 fails for tables with long names # -copy_file std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYI $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYI; -copy_file std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD; -copy_file std_data/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.frm $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.frm; +copy_file std_data/long_table_name.MYI $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYI; +copy_file std_data/long_table_name.MYD $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD; +copy_file std_data/long_table_name.frm $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.frm; show full tables; rename table `#mysql50#ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com` to `ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com`; show full tables; From 49915031d5b0214da160420bd21b7bca6a908354 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Sep 2010 21:47:16 +0200 Subject: [PATCH 101/118] Enable tests that were previously disabled waiting for XtraDB merge. --- mysql-test/suite/innodb/t/disabled.def | 1 - mysql-test/suite/innodb_plugin/t/disabled.def | 8 -------- 2 files changed, 9 deletions(-) diff --git a/mysql-test/suite/innodb/t/disabled.def b/mysql-test/suite/innodb/t/disabled.def index 80fb6c80bc4..15f02571509 100644 --- a/mysql-test/suite/innodb/t/disabled.def +++ b/mysql-test/suite/innodb/t/disabled.def @@ -11,5 +11,4 @@ ############################################################################## #innodb : Bug#53306 2010-04-30 VasilDimov valgrind warnings -innodb_bug48024 : Waiting for merge with Percona Server; bug fixed in innodb_plugin in MySQL 5.1.48 innodb_bug53756 : Waiting for merge with Percona Server; bug fixed in innodb_plugin in MySQL 5.1.50 diff --git a/mysql-test/suite/innodb_plugin/t/disabled.def b/mysql-test/suite/innodb_plugin/t/disabled.def index 158dd7e7f67..8cae44a3607 100644 --- a/mysql-test/suite/innodb_plugin/t/disabled.def +++ b/mysql-test/suite/innodb_plugin/t/disabled.def @@ -10,11 +10,3 @@ # ############################################################################## -innodb_bug48024 : Waiting for merge/fix from XtraDB -innodb_bug53590 : Waiting for merge/fix from XtraDB -innodb_bug53591 : Waiting for merge/fix from XtraDB -innodb_bug53592 : Waiting for merge/fix from XtraDB -innodb-use-sys-malloc : Waiting for bugfix from Percona for LP#612600 -innodb_bug53290 : Waiting for merge/fix from XtraDB -innodb_bug54679 : Waiting for merge/fix from XtraDB -innodb_bug52745 : Waiting for merge/fix from XtraDB From 688064f87ff9f772dd29b910b7668707552dc7f4 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 4 Sep 2010 21:37:50 +0200 Subject: [PATCH 102/118] Result file update following XtraDB merge. --- mysql-test/suite/pbxt/r/mysqlshow.result | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/pbxt/r/mysqlshow.result b/mysql-test/suite/pbxt/r/mysqlshow.result index 79394980270..1957e00daef 100644 --- a/mysql-test/suite/pbxt/r/mysqlshow.result +++ b/mysql-test/suite/pbxt/r/mysqlshow.result @@ -117,13 +117,14 @@ Database: information_schema | INNODB_TRX | | INNODB_SYS_TABLES | | INNODB_LOCK_WAITS | -| INNODB_CMPMEM_RESET | +| INNODB_SYS_STATS | | INNODB_LOCKS | | INNODB_CMPMEM | | INNODB_TABLE_STATS | | INNODB_SYS_INDEXES | | INNODB_CMP_RESET | | INNODB_BUFFER_POOL_PAGES_BLOB | +| INNODB_CMPMEM_RESET | | INNODB_INDEX_STATS | +---------------------------------------+ Database: INFORMATION_SCHEMA @@ -168,13 +169,14 @@ Database: INFORMATION_SCHEMA | INNODB_TRX | | INNODB_SYS_TABLES | | INNODB_LOCK_WAITS | -| INNODB_CMPMEM_RESET | +| INNODB_SYS_STATS | | INNODB_LOCKS | | INNODB_CMPMEM | | INNODB_TABLE_STATS | | INNODB_SYS_INDEXES | | INNODB_CMP_RESET | | INNODB_BUFFER_POOL_PAGES_BLOB | +| INNODB_CMPMEM_RESET | | INNODB_INDEX_STATS | +---------------------------------------+ Wildcard: inf_rmation_schema From 74af6dfad0d4fd0a0bbf8e69cfba6524a2b99853 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sun, 5 Sep 2010 12:39:17 +0300 Subject: [PATCH 103/118] Nicer output for mysql_upgrade Added --silent option to mysql_upgrade so that one can only get errors printed Don't write unnecessary warning about log tables during upgrade client/mysql_upgrade.c: Don't print connect arguments if not using --verbose --verbose Added option --silent to only print errors. This options is passed to mysqlcheck. Write out phase names The 'verbose' code is a bit strange as I wanted to keep compatibility with old mysql_upgrade client/mysqlcheck.c: Don't upgrade log tables (to avoid confusing warning message that they can't be locked) --- client/mysql_upgrade.c | 36 ++++++++++++++++++++++++++++-------- client/mysqlcheck.c | 8 ++++++++ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 4fc1bf0c537..c9b12112dba 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -34,8 +34,9 @@ static char mysql_path[FN_REFLEN]; static char mysqlcheck_path[FN_REFLEN]; -static my_bool opt_force, opt_verbose, debug_info_flag, debug_check_flag; -static uint my_end_arg= 0; +static my_bool opt_force, debug_info_flag, debug_check_flag, opt_silent; +static my_bool opt_not_used; /* For compatiblity */ +static uint my_end_arg= 0, opt_verbose; static char *opt_user= (char*)"root"; static DYNAMIC_STRING ds_args; @@ -116,6 +117,8 @@ static struct my_option my_long_options[]= "Base name of shared memory.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif + {"silent", 's', "Print less information", &opt_silent, + &opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"socket", 'S', "The socket file to use for connection.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include @@ -124,8 +127,7 @@ static struct my_option my_long_options[]= {"user", 'u', "User for login if not current user.", &opt_user, &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"verbose", 'v', "Display more output about the process.", - &opt_verbose, &opt_verbose, 0, - GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + &opt_not_used, &opt_not_used, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"write-binlog", OPT_WRITE_BINLOG, "All commands including mysqlcheck are binlogged. Enabled by default;" "use --skip-write-binlog when commands should not be sent to replication slaves.", @@ -173,7 +175,7 @@ static void verbose(const char *fmt, ...) { va_list args; - if (!opt_verbose) + if (opt_silent) return; /* Print the verbose message */ @@ -266,6 +268,18 @@ get_one_option(int optid, const struct my_option *opt, /* FALLTHROUGH */ case 'v': /* --verbose */ + opt_verbose++; + if (argument == disabled_my_option) + { + opt_verbose= 0; + opt_silent= 1; + } + add_option= 0; + break; + case 's': + opt_verbose= 0; + add_option= 0; + break; case 'f': /* --force */ add_option= FALSE; break; @@ -496,7 +510,7 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res, "--database=mysql", "--batch", /* Turns off pager etc. */ force ? "--force": "--skip-force", - ds_res ? "--silent": "", + ds_res || opt_silent ? "--silent": "", "<", query_file_path, "2>&1", @@ -649,6 +663,8 @@ static void create_mysql_upgrade_info_file(void) static void print_conn_args(const char *tool_name) { + if (opt_verbose < 2) + return; if (conn_args.str[0]) verbose("Running '%s' with connection arguments: %s", tool_name, conn_args.str); @@ -664,6 +680,7 @@ static void print_conn_args(const char *tool_name) static int run_mysqlcheck_upgrade(void) { + verbose("Phase 2/3: Checking and upgrading tables"); print_conn_args("mysqlcheck"); return run_tool(mysqlcheck_path, NULL, /* Send output from mysqlcheck directly to screen */ @@ -672,7 +689,8 @@ static int run_mysqlcheck_upgrade(void) "--check-upgrade", "--all-databases", "--auto-repair", - opt_verbose ? "--verbose": "", + !opt_silent || opt_verbose ? "--verbose": "", + opt_silent ? "--silent": "", opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", NULL); } @@ -680,6 +698,7 @@ static int run_mysqlcheck_upgrade(void) static int run_mysqlcheck_fixnames(void) { + verbose("Phase 1/3: Fixing table and database names"); print_conn_args("mysqlcheck"); return run_tool(mysqlcheck_path, NULL, /* Send output from mysqlcheck directly to screen */ @@ -689,6 +708,7 @@ static int run_mysqlcheck_fixnames(void) "--fix-db-names", "--fix-table-names", opt_verbose ? "--verbose": "", + opt_silent ? "--silent": "", opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", NULL); } @@ -758,7 +778,7 @@ static int run_sql_fix_privilege_tables(void) if (init_dynamic_string(&ds_result, "", 512, 512)) die("Out of memory"); - verbose("Running 'mysql_fix_privilege_tables'..."); + verbose("Phase 3/3: Running 'mysql_fix_privilege_tables'..."); run_query(mysql_fix_privilege_tables, &ds_result, /* Collect result */ TRUE); diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 57f40e6b9b1..c2feea33223 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -526,6 +526,7 @@ static int process_all_tables_in_db(char *database) MYSQL_RES *res; MYSQL_ROW row; uint num_columns; + my_bool system_database; LINT_INIT(res); if (use_db(database)) @@ -539,6 +540,9 @@ static int process_all_tables_in_db(char *database) return 1; } + if (!strcmp(database, "mysql") || !strcmp(database, "MYSQL")) + system_database= 1; + num_columns= mysql_num_fields(res); if (opt_all_in_1 && what_to_do != DO_UPGRADE) @@ -581,6 +585,10 @@ static int process_all_tables_in_db(char *database) /* Skip views if we don't perform renaming. */ if ((what_to_do != DO_UPGRADE) && (num_columns == 2) && (strcmp(row[1], "VIEW") == 0)) continue; + if (system_database && + (!strcmp(row[0], "general_log") || + !strcmp(row[0], "slow_log"))) + continue; /* Skip logging tables */ handle_request_for_tables(row[0], fixed_name_length(row[0])); } From b74cd1b6b6261ef199aecd99a161147d5f4505bf Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sun, 5 Sep 2010 13:52:33 +0300 Subject: [PATCH 104/118] Fixed failing test cases after update of xtradb mysql-test/r/not_partition.result: Test result changed after I fixed the error message for not existing engine mysql-test/suite/funcs_1/r/is_columns_is.result: Updated results mysql-test/suite/funcs_1/r/is_engines_innodb.result: Updated results mysql-test/suite/funcs_1/r/is_tables_is.result: Updated results mysql-test/suite/funcs_1/t/is_tables_is.test: Test requires innodb as results depends on innodb mysql-test/suite/innodb_plugin/t/disabled.def: Disable test as it shows errors in valgrind mysql-test/suite/innodb_plugin/t/innodb-use-sys-malloc.test: Test can't be run under valgrind as mysql-test-run resets the innodb_use_sys_malloc flag storage/xtradb/buf/buf0buf.c: Fixed compiler warning by adding casts --- mysql-test/r/not_partition.result | 26 +- .../suite/funcs_1/r/is_columns_is.result | 38 +- .../suite/funcs_1/r/is_engines_innodb.result | 2 +- .../suite/funcs_1/r/is_tables_is.result | 874 ++++++++++++++++++ mysql-test/suite/funcs_1/t/is_tables_is.test | 1 + mysql-test/suite/innodb_plugin/t/disabled.def | 1 + .../t/innodb-use-sys-malloc.test | 1 + storage/xtradb/buf/buf0buf.c | 4 +- 8 files changed, 913 insertions(+), 34 deletions(-) diff --git a/mysql-test/r/not_partition.result b/mysql-test/r/not_partition.result index f516f8634ce..b17594d0ded 100644 --- a/mysql-test/r/not_partition.result +++ b/mysql-test/r/not_partition.result @@ -1,47 +1,47 @@ DROP TABLE IF EXISTS t1; FLUSH TABLES; SELECT * FROM t1; -ERROR 42000: Unknown table engine 'partition' +ERROR 42000: Unknown table engine 'partition' TRUNCATE TABLE t1; -ERROR 42000: Unknown table engine 'partition' +ERROR 42000: Unknown table engine 'partition' ANALYZE TABLE t1; Table Op Msg_type Msg_text -test.t1 analyze Error Unknown table engine 'partition' +test.t1 analyze Error Unknown table engine 'partition' test.t1 analyze error Corrupt CHECK TABLE t1; Table Op Msg_type Msg_text -test.t1 check Error Unknown table engine 'partition' +test.t1 check Error Unknown table engine 'partition' test.t1 check error Corrupt OPTIMIZE TABLE t1; Table Op Msg_type Msg_text -test.t1 optimize Error Unknown table engine 'partition' +test.t1 optimize Error Unknown table engine 'partition' test.t1 optimize error Corrupt REPAIR TABLE t1; Table Op Msg_type Msg_text -test.t1 repair Error Unknown table engine 'partition' +test.t1 repair Error Unknown table engine 'partition' test.t1 repair error Corrupt ALTER TABLE t1 REPAIR PARTITION ALL; Table Op Msg_type Msg_text -test.t1 repair Error Unknown table engine 'partition' +test.t1 repair Error Unknown table engine 'partition' test.t1 repair error Corrupt ALTER TABLE t1 CHECK PARTITION ALL; Table Op Msg_type Msg_text -test.t1 check Error Unknown table engine 'partition' +test.t1 check Error Unknown table engine 'partition' test.t1 check error Corrupt ALTER TABLE t1 OPTIMIZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 optimize Error Unknown table engine 'partition' +test.t1 optimize Error Unknown table engine 'partition' test.t1 optimize error Corrupt ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze Error Unknown table engine 'partition' +test.t1 analyze Error Unknown table engine 'partition' test.t1 analyze error Corrupt ALTER TABLE t1 REBUILD PARTITION ALL; -ERROR 42000: Unknown table engine 'partition' +ERROR 42000: Unknown table engine 'partition' ALTER TABLE t1 ENGINE Memory; -ERROR 42000: Unknown table engine 'partition' +ERROR 42000: Unknown table engine 'partition' ALTER TABLE t1 ADD (new INT); -ERROR 42000: Unknown table engine 'partition' +ERROR 42000: Unknown table engine 'partition' DROP TABLE t1; CREATE TABLE t1 ( firstname VARCHAR(25) NOT NULL, diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result index e28ea5078b7..68920c61319 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is.result @@ -127,21 +127,19 @@ NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB next_page_no 5 0 NO bigint NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB page_no 2 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB part_len 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB space_id 1 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX access_time 9 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX data_size 7 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX dirty 11 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX fix_count 14 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX flush_type 15 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX hashed 8 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX index_name 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX lru_position 13 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX modified 10 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX n_recs 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX old 12 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX page_no 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX schema_name 1 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX space_id 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select -NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX table_name 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX access_time 7 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX data_size 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX dirty 9 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX fix_count 12 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX flush_type 13 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX hashed 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX index_id 1 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX lru_position 11 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX modified 8 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX n_recs 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX old 10 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX page_no 3 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX space_id 2 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_CMP compress_ops 2 0 NO int NULL NULL 10 0 NULL NULL int(11) select NULL information_schema INNODB_CMP compress_ops_ok 3 0 NO int NULL NULL 10 0 NULL NULL int(11) select NULL information_schema INNODB_CMP compress_time 4 0 NO int NULL NULL 10 0 NULL NULL int(11) select @@ -198,6 +196,9 @@ NULL information_schema INNODB_SYS_INDEXES PAGE_NO 7 0 NO bigint NULL NULL 20 0 NULL information_schema INNODB_SYS_INDEXES SPACE 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_SYS_INDEXES TABLE_ID 1 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_SYS_INDEXES TYPE 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_SYS_STATS DIFF_VALS 3 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_SYS_STATS INDEX_ID 1 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select +NULL information_schema INNODB_SYS_STATS KEY_COLS 2 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_SYS_TABLES CLUSTER_NAME 8 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select NULL information_schema INNODB_SYS_TABLES ID 3 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select NULL information_schema INNODB_SYS_TABLES MIX_ID 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select @@ -600,9 +601,7 @@ NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB next_page_no bigint NULL N NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB lru_position bigint NULL NULL NULL NULL bigint(21) unsigned NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB fix_count bigint NULL NULL NULL NULL bigint(21) unsigned NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB flush_type bigint NULL NULL NULL NULL bigint(21) unsigned -3.0000 information_schema INNODB_BUFFER_POOL_PAGES_INDEX schema_name varchar 64 192 utf8 utf8_general_ci varchar(64) -3.0000 information_schema INNODB_BUFFER_POOL_PAGES_INDEX table_name varchar 64 192 utf8 utf8_general_ci varchar(64) -3.0000 information_schema INNODB_BUFFER_POOL_PAGES_INDEX index_name varchar 64 192 utf8 utf8_general_ci varchar(64) +NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX index_id bigint NULL NULL NULL NULL bigint(21) unsigned NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX space_id bigint NULL NULL NULL NULL bigint(21) unsigned NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX page_no bigint NULL NULL NULL NULL bigint(21) unsigned NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX n_recs bigint NULL NULL NULL NULL bigint(21) unsigned @@ -671,6 +670,9 @@ NULL information_schema INNODB_SYS_INDEXES N_FIELDS bigint NULL NULL NULL NULL b NULL information_schema INNODB_SYS_INDEXES TYPE bigint NULL NULL NULL NULL bigint(21) unsigned NULL information_schema INNODB_SYS_INDEXES SPACE bigint NULL NULL NULL NULL bigint(21) unsigned NULL information_schema INNODB_SYS_INDEXES PAGE_NO bigint NULL NULL NULL NULL bigint(21) unsigned +NULL information_schema INNODB_SYS_STATS INDEX_ID bigint NULL NULL NULL NULL bigint(21) unsigned +NULL information_schema INNODB_SYS_STATS KEY_COLS bigint NULL NULL NULL NULL bigint(21) unsigned +NULL information_schema INNODB_SYS_STATS DIFF_VALS bigint NULL NULL NULL NULL bigint(21) unsigned 3.0000 information_schema INNODB_SYS_TABLES SCHEMA varchar 192 576 utf8 utf8_general_ci varchar(192) 3.0000 information_schema INNODB_SYS_TABLES NAME varchar 192 576 utf8 utf8_general_ci varchar(192) NULL information_schema INNODB_SYS_TABLES ID bigint NULL NULL NULL NULL bigint(21) unsigned diff --git a/mysql-test/suite/funcs_1/r/is_engines_innodb.result b/mysql-test/suite/funcs_1/r/is_engines_innodb.result index 5713b417cd1..6de31d3ad31 100644 --- a/mysql-test/suite/funcs_1/r/is_engines_innodb.result +++ b/mysql-test/suite/funcs_1/r/is_engines_innodb.result @@ -2,7 +2,7 @@ SELECT * FROM information_schema.engines WHERE ENGINE = 'InnoDB'; ENGINE InnoDB SUPPORT YES -COMMENT Supports transactions, row-level locking, and foreign keys +COMMENT Percona-XtraDB, Supports transactions, row-level locking, and foreign keys TRANSACTIONS YES XA YES SAVEPOINTS YES diff --git a/mysql-test/suite/funcs_1/r/is_tables_is.result b/mysql-test/suite/funcs_1/r/is_tables_is.result index 59e5c6ecf57..4b2b3bff752 100644 --- a/mysql-test/suite/funcs_1/r/is_tables_is.result +++ b/mysql-test/suite/funcs_1/r/is_tables_is.result @@ -245,6 +245,374 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema +TABLE_NAME INNODB_BUFFER_POOL_PAGES +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_BUFFER_POOL_PAGES_BLOB +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_BUFFER_POOL_PAGES_INDEX +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_CMP +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_CMPMEM +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_CMPMEM_RESET +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_CMP_RESET +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_INDEX_STATS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_LOCKS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_LOCK_WAITS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_RSEG +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_SYS_INDEXES +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_SYS_STATS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_SYS_TABLES +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_TABLE_STATS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_TRX +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema TABLE_NAME KEY_COLUMN_USAGE TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -291,6 +659,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema +TABLE_NAME PBXT_STATISTICS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema TABLE_NAME PLUGINS TABLE_TYPE SYSTEM VIEW ENGINE MYISAM_OR_MARIA @@ -634,6 +1025,52 @@ CREATE_OPTIONS #CO# TABLE_COMMENT #TC# user_comment Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME XTRADB_ADMIN_COMMAND +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME XTRADB_ENHANCEMENTS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- DROP USER testuser1@localhost; CREATE USER testuser1@localhost; GRANT SELECT ON test1.* TO testuser1@localhost; @@ -883,6 +1320,374 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema +TABLE_NAME INNODB_BUFFER_POOL_PAGES +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_BUFFER_POOL_PAGES_BLOB +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_BUFFER_POOL_PAGES_INDEX +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_CMP +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_CMPMEM +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_CMPMEM_RESET +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_CMP_RESET +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_INDEX_STATS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_LOCKS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_LOCK_WAITS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_RSEG +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_SYS_INDEXES +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_SYS_STATS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_SYS_TABLES +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_TABLE_STATS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME INNODB_TRX +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema TABLE_NAME KEY_COLUMN_USAGE TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -929,6 +1734,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG NULL TABLE_SCHEMA information_schema +TABLE_NAME PBXT_STATISTICS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema TABLE_NAME PLUGINS TABLE_TYPE SYSTEM VIEW ENGINE MYISAM_OR_MARIA @@ -1272,6 +2100,52 @@ CREATE_OPTIONS #CO# TABLE_COMMENT #TC# user_comment Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME XTRADB_ADMIN_COMMAND +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG NULL +TABLE_SCHEMA information_schema +TABLE_NAME XTRADB_ENHANCEMENTS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 10 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- # Switch to connection default and close connection testuser1 DROP USER testuser1@localhost; DROP DATABASE test1; diff --git a/mysql-test/suite/funcs_1/t/is_tables_is.test b/mysql-test/suite/funcs_1/t/is_tables_is.test index 90da2170281..3db2f7fbdcb 100644 --- a/mysql-test/suite/funcs_1/t/is_tables_is.test +++ b/mysql-test/suite/funcs_1/t/is_tables_is.test @@ -13,6 +13,7 @@ # --source include/not_embedded.inc +--source include/have_innodb.inc let $my_where = WHERE table_schema = 'information_schema' AND table_name <> 'profiling'; --source suite/funcs_1/datadict/tables1.inc diff --git a/mysql-test/suite/innodb_plugin/t/disabled.def b/mysql-test/suite/innodb_plugin/t/disabled.def index 8cae44a3607..4c37bbc87ed 100644 --- a/mysql-test/suite/innodb_plugin/t/disabled.def +++ b/mysql-test/suite/innodb_plugin/t/disabled.def @@ -10,3 +10,4 @@ # ############################################################################## +innodb_bug52745: Disabled as this has valgrind failures (also in MySQL 5.1.50) diff --git a/mysql-test/suite/innodb_plugin/t/innodb-use-sys-malloc.test b/mysql-test/suite/innodb_plugin/t/innodb-use-sys-malloc.test index bc042587287..af08e1c9812 100644 --- a/mysql-test/suite/innodb_plugin/t/innodb-use-sys-malloc.test +++ b/mysql-test/suite/innodb_plugin/t/innodb-use-sys-malloc.test @@ -1,4 +1,5 @@ -- source include/have_innodb_plugin.inc +-- source include/not_valgrind.inc #display current value of innodb_use_sys_malloc SELECT @@GLOBAL.innodb_use_sys_malloc; diff --git a/storage/xtradb/buf/buf0buf.c b/storage/xtradb/buf/buf0buf.c index dd98da19a21..595addb24a1 100644 --- a/storage/xtradb/buf/buf0buf.c +++ b/storage/xtradb/buf/buf0buf.c @@ -1055,8 +1055,8 @@ buf_chunk_init( "InnoDB: Logical offset (blocks) : %ld (%#lx)\n", (void*)((void*)chunk->mem + shm_info->frame_offset), (void*)chunk->blocks[0].frame, (void*)frame, - phys_offset, phys_offset, logi_offset, logi_offset, - blocks_offset, blocks_offset); + (ulong) phys_offset, (ulong) phys_offset, (ulong) logi_offset, (ulong) logi_offset, + (ulong) blocks_offset, (ulong) blocks_offset); } else { fprintf(stderr, "InnoDB: Buffer pool in the shared memory segment can be used as it is.\n"); From 4c7af343e0561e7774cc3c59b55ac2f6f8a9312d Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 6 Sep 2010 02:15:34 +0300 Subject: [PATCH 105/118] Fixed build failures Cleaned up mysql_upgrade --help and mysqlcheck --help client/mysql_upgrade.c: Increased version number. Marked all options that are not used 'Not used'. Don't write 'Looking for tool' if not using --verbose client/mysqlcheck.c: Cleanup output for --help Reset not initialzed variable mysql-test/r/log_tables_upgrade.result: Updated results mysql-test/r/mysql_upgrade.result: Updated results mysql-test/r/mysqlcheck.result: Updated results mysql-test/t/log_tables_upgrade.test: mysql_upgrade is now run without --skip-verbose mysql-test/t/mysql_upgrade.test: mysql_upgrade is now run without --skip-verbose --- client/mysql_upgrade.c | 29 ++++---- client/mysqlcheck.c | 24 +++---- mysql-test/r/log_tables_upgrade.result | 15 +++-- mysql-test/r/mysql_upgrade.result | 91 ++++++++++++++++---------- mysql-test/r/mysqlcheck.result | 8 --- mysql-test/t/log_tables_upgrade.test | 2 +- mysql-test/t/mysql_upgrade.test | 16 ++--- 7 files changed, 102 insertions(+), 83 deletions(-) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index c9b12112dba..c72f13eded6 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -1,4 +1,5 @@ /* Copyright (C) 2000 MySQL AB + Copyright (C) 2010 Monty Program Ab This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,7 +18,7 @@ #include #include "../scripts/mysql_fix_privilege_tables_sql.c" -#define VER "1.1" +#define VER "1.2" #ifdef HAVE_SYS_WAIT_H #include @@ -63,12 +64,14 @@ static struct my_option my_long_options[]= { {"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"basedir", 'b', "Not used by mysql_upgrade. Only for backward compatibility.", + {"basedir", 'b', + "Not used by mysql_upgrade. Only for backward compatibility.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory for character set files.", 0, - 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"compress", OPT_COMPRESS, "Use compression in server/client protocol.", + "Not used by mysql_upgrade. Only for backward compatibility.", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + {"compress", OPT_COMPRESS, + "Not used by mysql_upgrade. Only for backward compatibility.", ¬_used, ¬_used, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"datadir", 'd', "Not used by mysql_upgrade. Only for backward compatibility.", @@ -81,18 +84,17 @@ static struct my_option my_long_options[]= &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.", - &debug_check_flag, &debug_check_flag, 0, - GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + &debug_check_flag, &debug_check_flag, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"debug-info", 'T', "Print some debug info at exit.", &debug_info_flag, &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, - "Set the default character set.", 0, - 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Not used by mysql_upgrade. Only for backward compatibility.", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Force execution of mysqlcheck even if mysql_upgrade " "has already been executed for the current version of MySQL.", - &opt_force, &opt_force, 0, - GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"host",'h', "Connect to host.", 0, + &opt_force, &opt_force, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"host", 'h', "Connect to host.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server. If password is not given," @@ -440,7 +442,8 @@ static void find_tool(char *tool_executable_name, const char *tool_name, len, self_name, FN_LIBCHAR, tool_name); } - verbose("Looking for '%s' as: %s", tool_name, tool_executable_name); + if (opt_verbose) + verbose("Looking for '%s' as: %s", tool_name, tool_executable_name); /* Make sure it can be executed diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index c2feea33223..41249949633 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (C) 2000 MySQL AB & Jani Tolonen Copyright (C) 2010 Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -223,24 +223,26 @@ static void usage(void) { print_version(); puts("By Jani Tolonen, 2001-04-20, MySQL Development Team.\n"); - puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n"); + puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,"); puts("and you are welcome to modify and redistribute it under the GPL license.\n"); + printf("Usage: %s [OPTIONS] database [tables]\n", my_progname); + printf("OR %s [OPTIONS] --databases DB1 [DB2 DB3...]\n", + my_progname); + printf("OR %s [OPTIONS] --all-databases\n\n", my_progname); puts("This program can be used to CHECK (-c, -m, -C), REPAIR (-r), ANALYZE (-a),"); puts("or OPTIMIZE (-o) tables. Some of the options (like -e or -q) can be"); puts("used at the same time. Not all options are supported by all storage engines."); - puts("Please consult the MySQL manual for latest information about the"); - puts("above. The options -c, -r, -a, and -o are exclusive to each other, which"); + puts("The options -c, -r, -a, and -o are exclusive to each other, which"); puts("means that the last option will be used, if several was specified.\n"); - puts("The option -c will be used by default, if none was specified. You"); - puts("can change the default behavior by making a symbolic link, or"); + puts("The option -c (--check) will be used by default, if none was specified."); + puts("You can change the default behavior by making a symbolic link, or"); puts("copying this file somewhere with another name, the alternatives are:"); puts("mysqlrepair: The default option will be -r"); puts("mysqlanalyze: The default option will be -a"); puts("mysqloptimize: The default option will be -o\n"); - printf("Usage: %s [OPTIONS] database [tables]\n", my_progname); - printf("OR %s [OPTIONS] --databases DB1 [DB2 DB3...]\n", - my_progname); - printf("OR %s [OPTIONS] --all-databases\n", my_progname); + puts("Please consult the MariaDB/MySQL knowledgebase at"); + puts("http://kb.askmonty.org/v/mysqlcheck for latest information about"); + puts("this program."); print_defaults("my", load_default_groups); my_print_help(my_long_options); my_print_variables(my_long_options); @@ -526,7 +528,7 @@ static int process_all_tables_in_db(char *database) MYSQL_RES *res; MYSQL_ROW row; uint num_columns; - my_bool system_database; + my_bool system_database= 0; LINT_INIT(res); if (use_db(database)) diff --git a/mysql-test/r/log_tables_upgrade.result b/mysql-test/r/log_tables_upgrade.result index 5d9be85a48a..a9d1b41cf2c 100644 --- a/mysql-test/r/log_tables_upgrade.result +++ b/mysql-test/r/log_tables_upgrade.result @@ -11,15 +11,18 @@ Table Op Msg_type Msg_text test.bug49823 repair status OK RENAME TABLE general_log TO renamed_general_log; RENAME TABLE test.bug49823 TO general_log; +Phase 1/3: Fixing table and database names +Phase 2/3: Checking and upgrading tables +Processing databases +information_schema +mtr mtr.global_suppressions OK mtr.test_suppressions OK +mysql 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.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -31,9 +34,6 @@ 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.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK @@ -41,6 +41,9 @@ mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK +test +Phase 3/3: Running 'mysql_fix_privilege_tables'... +OK DROP TABLE general_log; RENAME TABLE renamed_general_log TO general_log; SET GLOBAL general_log = @saved_general_log; diff --git a/mysql-test/r/mysql_upgrade.result b/mysql-test/r/mysql_upgrade.result index 4541763c7c5..ca23dc9cca1 100644 --- a/mysql-test/r/mysql_upgrade.result +++ b/mysql-test/r/mysql_upgrade.result @@ -1,13 +1,16 @@ Run mysql_upgrade once +Phase 1/3: Fixing table and database names +Phase 2/3: Checking and upgrading tables +Processing databases +information_schema +mtr mtr.global_suppressions OK mtr.test_suppressions OK +mysql 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.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -18,9 +21,6 @@ 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.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK @@ -28,18 +28,24 @@ mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK +test +Phase 3/3: Running 'mysql_fix_privilege_tables'... +OK Run it again - should say already completed This installation of MySQL is already upgraded to VERSION, use --force if you still need to run mysql_upgrade Force should run it regardless of wether it's been run before +Phase 1/3: Fixing table and database names +Phase 2/3: Checking and upgrading tables +Processing databases +information_schema +mtr mtr.global_suppressions OK mtr.test_suppressions OK +mysql 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.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -50,9 +56,6 @@ 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.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK @@ -60,18 +63,24 @@ mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK +test +Phase 3/3: Running 'mysql_fix_privilege_tables'... +OK CREATE USER mysqltest1@'%' IDENTIFIED by 'sakila'; GRANT ALL ON *.* TO mysqltest1@'%'; Run mysql_upgrade with password protected account +Phase 1/3: Fixing table and database names +Phase 2/3: Checking and upgrading tables +Processing databases +information_schema +mtr mtr.global_suppressions OK mtr.test_suppressions OK +mysql 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.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -82,9 +91,6 @@ 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.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK @@ -92,20 +98,27 @@ mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK +test +Phase 3/3: Running 'mysql_fix_privilege_tables'... +OK DROP USER mysqltest1@'%'; Run mysql_upgrade with a non existing server socket +Phase 1/3: Fixing table and database names mysqlcheck: Got error: 2005: Unknown MySQL server host 'not_existing_host' (errno) when trying to connect FATAL ERROR: Upgrade failed set GLOBAL sql_mode='STRICT_ALL_TABLES,ANSI_QUOTES,NO_ZERO_DATE'; +Phase 1/3: Fixing table and database names +Phase 2/3: Checking and upgrading tables +Processing databases +information_schema +mtr mtr.global_suppressions OK mtr.test_suppressions OK +mysql 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.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -116,9 +129,6 @@ 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.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK @@ -126,6 +136,9 @@ mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK +test +Phase 3/3: Running 'mysql_fix_privilege_tables'... +OK set GLOBAL sql_mode=default; # # Bug #41569 mysql_upgrade (ver 5.1) add 3 fields to mysql.proc table @@ -135,15 +148,18 @@ CREATE PROCEDURE testproc() BEGIN END; UPDATE mysql.proc SET character_set_client = NULL WHERE name LIKE 'testproc'; UPDATE mysql.proc SET collation_connection = NULL WHERE name LIKE 'testproc'; UPDATE mysql.proc SET db_collation = NULL WHERE name LIKE 'testproc'; +Phase 1/3: Fixing table and database names +Phase 2/3: Checking and upgrading tables +Processing databases +information_schema +mtr mtr.global_suppressions OK mtr.test_suppressions OK +mysql 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.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -154,9 +170,6 @@ 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.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK @@ -164,6 +177,9 @@ mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK +test +Phase 3/3: Running 'mysql_fix_privilege_tables'... +OK CALL testproc(); DROP PROCEDURE testproc; WARNING: NULL values of the 'character_set_client' column ('mysql.proc' table) have been updated with a default value (latin1). Please verify if necessary. @@ -176,15 +192,18 @@ WARNING: NULL values of the 'db_collation' column ('mysql.proc' table) have been GRANT USAGE ON *.* TO 'user3'@'%'; GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%'; Run mysql_upgrade with all privileges on a user +Phase 1/3: Fixing table and database names +Phase 2/3: Checking and upgrading tables +Processing databases +information_schema +mtr mtr.global_suppressions OK mtr.test_suppressions OK +mysql 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.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -195,9 +214,6 @@ 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.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK @@ -205,6 +221,9 @@ mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK +test +Phase 3/3: Running 'mysql_fix_privilege_tables'... +OK SHOW GRANTS FOR 'user3'@'%'; Grants for user3@% GRANT USAGE ON *.* TO 'user3'@'%' diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result index 5f1a0565b10..812fd12e197 100644 --- a/mysql-test/r/mysqlcheck.result +++ b/mysql-test/r/mysqlcheck.result @@ -7,8 +7,6 @@ mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK -mysql.general_log -note : The storage engine for the table doesn't support optimize mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -19,8 +17,6 @@ mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.servers OK -mysql.slow_log -note : The storage engine for the table doesn't support optimize mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK @@ -32,8 +28,6 @@ mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK -mysql.general_log -note : The storage engine for the table doesn't support optimize mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK @@ -44,8 +38,6 @@ mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.servers OK -mysql.slow_log -note : The storage engine for the table doesn't support optimize mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK diff --git a/mysql-test/t/log_tables_upgrade.test b/mysql-test/t/log_tables_upgrade.test index 5d1b2b5aed6..a638a27c9d1 100644 --- a/mysql-test/t/log_tables_upgrade.test +++ b/mysql-test/t/log_tables_upgrade.test @@ -25,7 +25,7 @@ FLUSH TABLES; REPAIR TABLE test.bug49823; RENAME TABLE general_log TO renamed_general_log; RENAME TABLE test.bug49823 TO general_log; ---exec $MYSQL_UPGRADE --skip-verbose --force 2>&1 +--exec $MYSQL_UPGRADE --force 2>&1 DROP TABLE general_log; RENAME TABLE renamed_general_log TO general_log; SET GLOBAL general_log = @saved_general_log; diff --git a/mysql-test/t/mysql_upgrade.test b/mysql-test/t/mysql_upgrade.test index 66f931275ac..ea127fbcc6d 100644 --- a/mysql-test/t/mysql_upgrade.test +++ b/mysql-test/t/mysql_upgrade.test @@ -33,7 +33,7 @@ if (`SELECT $VALGRIND_TEST`) # expected binaries it uses. # --echo Run mysql_upgrade once ---exec $MYSQL_UPGRADE --skip-verbose --force 2>&1 +--exec $MYSQL_UPGRADE --force 2>&1 # It should have created a file in the MySQL Servers datadir let $MYSQLD_DATADIR= `select @@datadir`; @@ -42,13 +42,13 @@ file_exists $MYSQLD_DATADIR/mysql_upgrade_info; --echo Run it again - should say already completed --replace_result $MYSQL_SERVER_VERSION VERSION --error 1 ---exec $MYSQL_UPGRADE --skip-verbose 2>&1 +--exec $MYSQL_UPGRADE 2>&1 # It should have created a file in the MySQL Servers datadir file_exists $MYSQLD_DATADIR/mysql_upgrade_info; --echo Force should run it regardless of wether it's been run before ---exec $MYSQL_UPGRADE --skip-verbose --force 2>&1 +--exec $MYSQL_UPGRADE --force 2>&1 # It should have created a file in the MySQL Servers datadir file_exists $MYSQLD_DATADIR/mysql_upgrade_info; @@ -63,7 +63,7 @@ file_exists $MYSQLD_DATADIR/mysql_upgrade_info; CREATE USER mysqltest1@'%' IDENTIFIED by 'sakila'; GRANT ALL ON *.* TO mysqltest1@'%'; --echo Run mysql_upgrade with password protected account ---exec $MYSQL_UPGRADE --skip-verbose --force --user=mysqltest1 --password=sakila 2>&1 +--exec $MYSQL_UPGRADE --force --user=mysqltest1 --password=sakila 2>&1 DROP USER mysqltest1@'%'; @@ -76,7 +76,7 @@ DROP USER mysqltest1@'%'; --replace_result $MYSQLTEST_VARDIR var --replace_regex /.*mysqlcheck.*: Got/mysqlcheck: Got/ /\([0-9]*\)/(errno)/ --error 1 ---exec $MYSQL_UPGRADE --skip-verbose --force --host=not_existing_host 2>&1 +--exec $MYSQL_UPGRADE --force --host=not_existing_host 2>&1 # # Bug #28401 mysql_upgrade Failed with STRICT_ALL_TABLES, ANSI_QUOTES and NO_ZERO_DATE @@ -88,7 +88,7 @@ DROP USER mysqltest1@'%'; # Test by setting sql_mode before running mysql_upgrade set GLOBAL sql_mode='STRICT_ALL_TABLES,ANSI_QUOTES,NO_ZERO_DATE'; ---exec $MYSQL_UPGRADE --skip-verbose --force 2>&1 +--exec $MYSQL_UPGRADE --force 2>&1 eval set GLOBAL sql_mode=default; @@ -104,7 +104,7 @@ CREATE PROCEDURE testproc() BEGIN END; UPDATE mysql.proc SET character_set_client = NULL WHERE name LIKE 'testproc'; UPDATE mysql.proc SET collation_connection = NULL WHERE name LIKE 'testproc'; UPDATE mysql.proc SET db_collation = NULL WHERE name LIKE 'testproc'; ---exec $MYSQL_UPGRADE --skip-verbose --force 2> $MYSQLTEST_VARDIR/tmp/41569.txt +--exec $MYSQL_UPGRADE --force 2> $MYSQLTEST_VARDIR/tmp/41569.txt CALL testproc(); DROP PROCEDURE testproc; --cat_file $MYSQLTEST_VARDIR/tmp/41569.txt @@ -119,7 +119,7 @@ DROP PROCEDURE testproc; GRANT USAGE ON *.* TO 'user3'@'%'; GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%'; --echo Run mysql_upgrade with all privileges on a user ---exec $MYSQL_UPGRADE --skip-verbose --force 2>&1 +--exec $MYSQL_UPGRADE --force 2>&1 SHOW GRANTS FOR 'user3'@'%'; DROP USER 'user3'@'%'; From 0f3d4b2f76e4a0ce8573251715b143415149ba4d Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 6 Sep 2010 02:25:44 +0300 Subject: [PATCH 106/118] Fixed bug that 'maria_read_log -a' didn't set max_trid when reparing tables. Fixed bug in Aria when replacing short keys with long keys and a key tree both overflow and underflow at same time. Fixed several bugs when generating recovery logs when using RGQ with replacing long keys with short keys and vice versa. Lots of new DBUG_ASSERT()'s Added more information to recovery log to make it easier to know from where log entry orginated. Introduced MARIA_PAGE->org_size that tells what the size of the page was in last log entry. This allows us to find out if all key changes for index page was logged. Small code cleanups: - Introduced _ma_log_key_changes() to log crc of key page changes - Added share->max_index_block_size as max size of data one can put in key block (block_size - KEYPAGE_CHECKSUM_SIZE) This will later simplify adding a directory to index pages. - Write page number instead of page postition to DBUG log mysql-test/lib/v1/mysql-test-run.pl: Use --general-log instead of --log to disable warning when using RQG sql/mysqld.cc: If we have already sent ok to client when we get an error, log this to stderr Don't disable option --log-output if CSV engine is not supported. storage/maria/ha_maria.cc: Log queries to recovery log also in LOCK TABLES storage/maria/ma_check.c: If param->max_trid is set, use this value instead of max_trid_in_system(). This is used by recovery to set max_trid to max seen trid so far. keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE -> max_index_block_size (Style optimization) storage/maria/ma_delete.c: Mark tables crashed early Write page number instead of page position to debug log. Added parameter to ma_log_delete() and ma_log_prefix() that is logged so that we can find where wrong log entries where generated. Fixed bug where a page was not proplerly written when same key tree had both an overflow and underflow when deleting a key. keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE => max_index_block_size (Style optimization) ma_log_delete() now has extra parameter of how many bytes from end of page should be appended to log for page (for page overflows) storage/maria/ma_key_recover.c: Added extra parameter to ma_log_prefix() to indicate what caused log entry. Update MARIA_PAGE->org_size when logging info about page. Much more DBUG_ASSERT()'s. Fix some bugs in maria_log_add() to handle page overflows. Added _ma_log_key_changes() to log crc of key page changes. If EXTRA_STORE_FULL_PAGE_IN_KEY_CHANGES is defines, log the resulting pages to log so one can trivally see how the resulting page should have looked like (for errors in CRC values) storage/maria/ma_key_recover.h: Added _ma_log_key_changes() which is only called if EXTRA_DEBUG_KEY_CHANGES is defined. Updated function prototypes. storage/maria/ma_loghandler.h: Added more values to en_key_debug, to get more exact location where things went wrong when logging to recovery log. storage/maria/ma_open.c: Initialize share->max_index_block_size storage/maria/ma_page.c: Added updating and testing of MARIA_PAGE->org_size Write page number instead of page postition to DBUG log Generate error if we read page with wrong data. Removed wrong assert: key_del_current != share->state.key_del. Simplify _ma_log_compact_keypage() storage/maria/ma_recovery.c: Set param.max_trid to max seen trid before running repair table (used for alter table to create index) storage/maria/ma_rt_key.c: Update call to _ma_log_delete() storage/maria/ma_rt_split.c: Use _ma_log_key_changes() Update MARIA_PAGE->org_size storage/maria/ma_unique.c: Remove casts storage/maria/ma_write.c: keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE => share->max_index_block_length. Updated calls to _ma_log_prefix() Changed code to use _ma_log_key_changes() Update ma_page->org_size Fixed bug in _ma_log_split() for pages that overflow Added KEY_OP_DEBUG logging to functions Log KEYPAGE_FLAG in all log entries storage/maria/maria_def.h: Added SHARE->max_index_block_size Added MARIA_PAGE->org_size storage/maria/trnman.c: Reset flags for new transaction. --- mysql-test/lib/v1/mysql-test-run.pl | 2 +- sql/mysqld.cc | 23 +-- storage/maria/ha_maria.cc | 11 +- storage/maria/ma_check.c | 28 +-- storage/maria/ma_delete.c | 225 +++++++++++++++++------- storage/maria/ma_key_recover.c | 264 +++++++++++++++++----------- storage/maria/ma_key_recover.h | 13 +- storage/maria/ma_loghandler.h | 25 ++- storage/maria/ma_open.c | 1 + storage/maria/ma_page.c | 66 ++++--- storage/maria/ma_recovery.c | 3 +- storage/maria/ma_rt_key.c | 3 +- storage/maria/ma_rt_split.c | 25 +-- storage/maria/ma_unique.c | 3 +- storage/maria/ma_write.c | 177 +++++++++---------- storage/maria/maria_def.h | 3 + storage/maria/trnman.c | 1 + 17 files changed, 544 insertions(+), 329 deletions(-) diff --git a/mysql-test/lib/v1/mysql-test-run.pl b/mysql-test/lib/v1/mysql-test-run.pl index ddd6e6d936a..2b242954ce9 100755 --- a/mysql-test/lib/v1/mysql-test-run.pl +++ b/mysql-test/lib/v1/mysql-test-run.pl @@ -2959,7 +2959,7 @@ sub run_benchmarks ($) { if ( ! $benchmark ) { - mtr_add_arg($args, "--log"); + mtr_add_arg($args, "--general-log"); mtr_run("$glob_mysql_bench_dir/run-all-tests", $args, "", "", "", ""); # FIXME check result code?! } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8bec9dc474a..c589ededa9c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3070,7 +3070,19 @@ int my_message_sql(uint error, const char *str, myf MyFlags) } else { - if (! thd->main_da.is_error()) // Return only first message + if (thd->main_da.is_ok()) + { + /* + Client has already got ok packet; Write message to error log. + This could happen if we get an error in implicit commit. + This should never happen in normal operation, so lets + assert here in debug builds. + */ + DBUG_ASSERT(0); + func= sql_print_error; + MyFlags|= ME_NOREFRESH; + } + else if (! thd->main_da.is_error()) // Return only first message { thd->main_da.set_error_status(thd, error, str); } @@ -4185,7 +4197,6 @@ a file name for --log-bin-index option", opt_binlog_index_name); unireg_abort(1); } -#ifdef WITH_CSV_STORAGE_ENGINE if (opt_bootstrap) log_output_options= LOG_FILE; else @@ -4219,10 +4230,6 @@ a file name for --log-bin-index option", opt_binlog_index_name); logger.set_handlers(LOG_FILE, opt_slow_log ? log_output_options:LOG_NONE, opt_log ? log_output_options:LOG_NONE); } -#else - logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_FILE:LOG_NONE, - opt_log ? LOG_FILE:LOG_NONE); -#endif /* Check that the default storage engine is actually available. @@ -6297,13 +6304,11 @@ each time the SQL thread starts.", "Log some extra information to update log. Please note that this option " "is deprecated; see --log-short-format option.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, -#ifdef WITH_CSV_STORAGE_ENGINE {"log-output", OPT_LOG_OUTPUT, "Syntax: log-output[=value[,value...]], where \"value\" could be TABLE, " "FILE or NONE.", &log_output_str, &log_output_str, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, -#endif {"log-queries-not-using-indexes", OPT_LOG_QUERIES_NOT_USING_INDEXES, "Log queries that are executed without benefit of any index to the slow log if it is open.", &opt_log_queries_not_using_indexes, &opt_log_queries_not_using_indexes, @@ -8631,7 +8636,6 @@ mysqld_get_one_option(int optid, WARN_DEPRECATED(NULL, "7.0", "--log_slow_queries", "'--slow_query_log'/'--log-slow-file'"); opt_slow_log= 1; break; -#ifdef WITH_CSV_STORAGE_ENGINE case OPT_LOG_OUTPUT: { if (!argument || !argument[0]) @@ -8649,7 +8653,6 @@ mysqld_get_one_option(int optid, } break; } -#endif case OPT_EVENT_SCHEDULER: #ifndef HAVE_EVENT_SCHEDULER sql_perror("Event scheduler is not supported in embedded build."); diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 1bac89b222c..846bfc67a63 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -750,8 +750,11 @@ static int maria_create_trn_for_mysql(MARIA_HA *info) thd->query_length()); } else + { DBUG_PRINT("info", ("lock_type: %d trnman_flags: %u", - info->lock_type, trnman_get_flags(trn))); /* QQ */ + info->lock_type, trnman_get_flags(trn))); + } + #endif DBUG_RETURN(0); } @@ -2347,6 +2350,12 @@ int ha_maria::extra(enum ha_extra_function operation) int ha_maria::reset(void) { + if (file->trn) + { + TRN *trn= file->trn; + /* Next statement is a new statement. Ensure it's logged */ + trnman_set_flags(trn, trnman_get_flags(trn) & ~TRN_STATE_INFO_LOGGED); + } return maria_reset(file); } diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 086cff67dab..fa1933913d4 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -136,11 +136,13 @@ void maria_chk_init_for_check(HA_CHECK *param, MARIA_HA *info) Set up transaction handler so that we can see all rows. When rows is read we will check the found id against param->max_tried */ - if (!ma_control_file_inited()) - param->max_trid= 0; /* Give warning for first trid found */ - else - param->max_trid= max_trid_in_system(); - + if (param->max_trid == 0) + { + if (!ma_control_file_inited()) + param->max_trid= 0; /* Give warning for first trid found */ + else + param->max_trid= max_trid_in_system(); + } maria_ignore_trids(info); } @@ -867,7 +869,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo, llstr(anc_page->pos, llbuff)); } - if (anc_page->size > (uint) keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE) + if (anc_page->size > share->max_index_block_size) { _ma_check_print_error(param, "Page at %s has impossible (too big) pagelength", @@ -2325,11 +2327,13 @@ static int initialize_variables_for_repair(HA_CHECK *param, } /* Set up transaction handler so that we can see all rows */ - if (!ma_control_file_inited()) - param->max_trid= 0; /* Give warning for first trid found */ - else - param->max_trid= max_trid_in_system(); - + if (param->max_trid == 0) + { + if (!ma_control_file_inited()) + param->max_trid= 0; /* Give warning for first trid found */ + else + param->max_trid= max_trid_in_system(); + } maria_ignore_trids(info); /* Don't write transid's during repair */ maria_versioning(info, 0); @@ -5609,7 +5613,7 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param, a_length+=t_length; _ma_store_page_used(share, anc_buff, a_length); key_block->end_pos+=t_length; - if (a_length <= (uint) (keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE)) + if (a_length <= share->max_index_block_size) { MARIA_KEY tmp_key2; tmp_key2.data= key_block->lastkey; diff --git a/storage/maria/ma_delete.c b/storage/maria/ma_delete.c index 0e9e5caafbf..9a5ff4b1d52 100644 --- a/storage/maria/ma_delete.c +++ b/storage/maria/ma_delete.c @@ -1,4 +1,5 @@ /* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + Copyright (C) 2009-2010 Monty Program Ab This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -180,7 +181,11 @@ my_bool _ma_ck_delete(MARIA_HA *info, MARIA_KEY *key) key->data= key_buff; } - res= _ma_ck_real_delete(info, key, &new_root); + if ((res= _ma_ck_real_delete(info, key, &new_root))) + { + /* We have to mark the table crashed before unpin_all_pages() */ + maria_mark_crashed(info); + } key->data= save_key_data; if (!res && share->now_transactional) @@ -218,7 +223,8 @@ my_bool _ma_ck_real_delete(register MARIA_HA *info, MARIA_KEY *key, my_errno=ENOMEM; DBUG_RETURN(1); } - DBUG_PRINT("info",("root_page: %ld", (long) old_root)); + DBUG_PRINT("info",("root_page: %lu", + (ulong) (old_root / keyinfo->block_length))); if (_ma_fetch_keypage(&page, info, keyinfo, old_root, PAGECACHE_LOCK_WRITE, DFLT_INIT_HITS, root_buff, 0)) { @@ -435,7 +441,8 @@ static int d_search(MARIA_HA *info, MARIA_KEY *key, uint32 comp_flag, */ if (share->now_transactional && _ma_log_delete(anc_page, s_temp.key_pos, - s_temp.changed_length, s_temp.move_length)) + s_temp.changed_length, s_temp.move_length, + 0, KEY_OP_DEBUG_LOG_DEL_CHANGE_1)) DBUG_RETURN(-1); if (!nod_flag) @@ -458,7 +465,7 @@ static int d_search(MARIA_HA *info, MARIA_KEY *key, uint32 comp_flag, } if (ret_value >0) { - save_flag=1; + save_flag= 2; if (ret_value == 1) ret_value= underflow(info, keyinfo, anc_page, &leaf_page, keypos); else @@ -474,17 +481,20 @@ static int d_search(MARIA_HA *info, MARIA_KEY *key, uint32 comp_flag, ret_value= _ma_insert(info, key, anc_page, keypos, last_key.data, (MARIA_PAGE*) 0, (uchar*) 0, (my_bool) 0); + + if (_ma_write_keypage(&leaf_page, PAGECACHE_LOCK_LEFT_WRITELOCKED, + DFLT_INIT_HITS)) + ret_value= -1; } } - if (ret_value == 0 && anc_page->size > - (uint) (keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE)) + if (ret_value == 0 && anc_page->size > share->max_index_block_size) { /* parent buffer got too big ; We have to split the page */ - save_flag=1; + save_flag= 3; ret_value= _ma_split_page(info, key, anc_page, - (uint) (keyinfo->block_length - - KEYPAGE_CHECKSUM_SIZE), + share->max_index_block_size, (uchar*) 0, 0, 0, lastkey, 0) | 2; + DBUG_ASSERT(anc_page->org_size == anc_page->size); } if (save_flag && ret_value != 1) { @@ -550,7 +560,8 @@ static int del(MARIA_HA *info, MARIA_KEY *key, MARIA_KEY ret_key; MARIA_PAGE next_page; DBUG_ENTER("del"); - DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx", (long) leaf_page, + DBUG_PRINT("enter",("leaf_page: %lu keypos: 0x%lx", + (ulong) (leaf_page->pos / share->block_size), (ulong) keypos)); DBUG_DUMP("leaf_buff", leaf_page->buff, leaf_page->size); @@ -587,11 +598,10 @@ static int del(MARIA_HA *info, MARIA_KEY *key, ret_value= underflow(info, keyinfo, leaf_page, &next_page, endpos); if (ret_value == 0 && leaf_page->size > - (uint) (keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE)) + share->max_index_block_size) { ret_value= (_ma_split_page(info, key, leaf_page, - (uint) (keyinfo->block_length - - KEYPAGE_CHECKSUM_SIZE), + share->max_index_block_size, (uchar*) 0, 0, 0, ret_key_buff, 0) | 2); } @@ -708,8 +718,7 @@ err: @fn underflow() @param anc_buff Anchestor page data - @param leaf_page Page number of leaf page - @param leaf_buff Leaf page (page that underflowed) + @param leaf_page Leaf page (page that underflowed) @param leaf_page_link Pointer to pin information about leaf page @param keypos Position after current key in anc_buff @@ -743,7 +752,8 @@ static int underflow(MARIA_HA *info, MARIA_KEYDEF *keyinfo, MARIA_KEY tmp_key, anc_key, leaf_key; MARIA_PAGE next_page; DBUG_ENTER("underflow"); - DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx",(long) leaf_page->pos, + DBUG_PRINT("enter",("leaf_page: %lu keypos: 0x%lx", + (ulong) (leaf_page->pos / share->block_size), (ulong) keypos)); DBUG_DUMP("anc_buff", anc_page->buff, anc_page->size); DBUG_DUMP("leaf_buff", leaf_page->buff, leaf_page->size); @@ -841,7 +851,7 @@ static int underflow(MARIA_HA *info, MARIA_KEYDEF *keyinfo, anc_page->size= new_anc_length; page_store_size(share, anc_page); - if (buff_length <= (uint) (keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE)) + if (buff_length <= share->max_index_block_size) { /* All keys fitted into one page */ page_mark_changed(info, &next_page); @@ -854,10 +864,15 @@ static int underflow(MARIA_HA *info, MARIA_KEYDEF *keyinfo, if (share->now_transactional) { - /* Log changes to parent page */ + /* + Log changes to parent page. Note that this page may have been + temporarily bigger than block_size. + */ if (_ma_log_delete(anc_page, key_deleted.key_pos, key_deleted.changed_length, - key_deleted.move_length)) + key_deleted.move_length, + anc_length - anc_page->org_size, + KEY_OP_DEBUG_LOG_DEL_CHANGE_2)) goto err; /* Log changes to leaf page. Data for leaf page is in leaf_buff @@ -986,7 +1001,8 @@ static int underflow(MARIA_HA *info, MARIA_KEYDEF *keyinfo, */ DBUG_ASSERT(new_buff_length <= next_buff_length); if (_ma_log_prefix(&next_page, key_inserted.changed_length, - (int) (new_buff_length - next_buff_length))) + (int) (new_buff_length - next_buff_length), + KEY_OP_DEBUG_LOG_PREFIX_1)) goto err; } page_mark_changed(info, &next_page); @@ -1044,11 +1060,19 @@ static int underflow(MARIA_HA *info, MARIA_KEYDEF *keyinfo, /* Remember for logging how many bytes of leaf_buff that are not changed */ DBUG_ASSERT((int) key_inserted.changed_length >= key_inserted.move_length); - unchanged_leaf_length= leaf_length - (key_inserted.changed_length - - key_inserted.move_length); + unchanged_leaf_length= (leaf_length - p_length - + (key_inserted.changed_length - + key_inserted.move_length)); new_buff_length= buff_length + leaf_length - p_length + t_length; +#ifdef EXTRA_DEBUG + /* Ensure that unchanged_leaf_length is correct */ + DBUG_ASSERT(bcmp(next_page.buff + new_buff_length - unchanged_leaf_length, + leaf_buff + leaf_length - unchanged_leaf_length, + unchanged_leaf_length) == 0); +#endif + page_flag= next_page.flag | leaf_page->flag; if (anc_key.flag & (SEARCH_USER_KEY_HAS_TRANSID | SEARCH_PAGE_KEY_HAS_TRANSID)) @@ -1069,8 +1093,7 @@ static int underflow(MARIA_HA *info, MARIA_KEYDEF *keyinfo, anc_page->size= new_anc_length; page_store_size(share, anc_page); - if (new_buff_length <= (uint) (keyinfo->block_length - - KEYPAGE_CHECKSUM_SIZE)) + if (new_buff_length <= share->max_index_block_size) { /* All keys fitted into one page */ page_mark_changed(info, leaf_page); @@ -1079,10 +1102,14 @@ static int underflow(MARIA_HA *info, MARIA_KEYDEF *keyinfo, if (share->now_transactional) { - /* Log changes to parent page */ + /* + Log changes to parent page. Note that this page may have been + temporarily bigger than block_size. + */ if (_ma_log_delete(anc_page, key_deleted.key_pos, - key_deleted.changed_length, key_deleted.move_length)) - + key_deleted.changed_length, key_deleted.move_length, + anc_length - anc_page->org_size, + KEY_OP_DEBUG_LOG_DEL_CHANGE_3)) goto err; /* Log changes to next page. Data for leaf page is in buff @@ -1192,8 +1219,10 @@ static int underflow(MARIA_HA *info, MARIA_KEYDEF *keyinfo, This contains original data with new data added first */ DBUG_ASSERT(leaf_length <= new_leaf_length); + DBUG_ASSERT(new_leaf_length >= unchanged_leaf_length); if (_ma_log_prefix(leaf_page, new_leaf_length - unchanged_leaf_length, - (int) (new_leaf_length - leaf_length))) + (int) (new_leaf_length - leaf_length), + KEY_OP_DEBUG_LOG_PREFIX_2)) goto err; /* Log changes to next page @@ -1395,7 +1424,9 @@ static uint remove_key(MARIA_KEYDEF *keyinfo, uint page_flag, uint nod_flag, ****************************************************************************/ /** - @brief log entry where some parts are deleted and some things are changed + @brief + log entry where some parts are deleted and some things are changed + and some data could be added last. @fn _ma_log_delete() @param info Maria handler @@ -1404,74 +1435,148 @@ static uint remove_key(MARIA_KEYDEF *keyinfo, uint page_flag, uint nod_flag, @param key_pos Start of change area @param changed_length How many bytes where changed at key_pos @param move_length How many bytes where deleted at key_pos + @param append_length Length of data added last + This is taken from end of ma_page->buff + This is mainly used when a key is deleted. The append happens + when we delete a key from a page with data > block_size kept in + memory and we have to add back the data that was stored > block_size */ my_bool _ma_log_delete(MARIA_PAGE *ma_page, const uchar *key_pos, - uint changed_length, uint move_length) + uint changed_length, uint move_length, + uint append_length, + enum en_key_debug debug_marker __attribute__((unused))) { LSN lsn; - uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 9 + 7], *log_pos; - LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 3]; - uint translog_parts; + uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 2 + 2 + 3 + 3 + 6 + 3 + 7]; + uchar *log_pos; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 7]; + uint translog_parts, current_size, extra_length; uint offset= (uint) (key_pos - ma_page->buff); MARIA_HA *info= ma_page->info; MARIA_SHARE *share= info->s; my_off_t page; DBUG_ENTER("_ma_log_delete"); DBUG_PRINT("enter", ("page: %lu changed_length: %u move_length: %d", - (ulong) ma_page->pos, changed_length, move_length)); + (ulong) (ma_page->pos / share->block_size), + changed_length, move_length)); DBUG_ASSERT(share->now_transactional && move_length); DBUG_ASSERT(offset + changed_length <= ma_page->size); + DBUG_ASSERT(ma_page->org_size - move_length + append_length == ma_page->size); + DBUG_ASSERT(move_length <= ma_page->org_size - share->keypage_header); /* Store address of new root page */ page= ma_page->pos / share->block_size; page_store(log_data + FILEID_STORE_SIZE, page); log_pos= log_data+ FILEID_STORE_SIZE + PAGE_STORE_SIZE; + current_size= ma_page->org_size; + +#ifdef EXTRA_DEBUG_KEY_CHANGES + *log_pos++= KEY_OP_DEBUG; + *log_pos++= debug_marker; +#endif + + /* Store keypage_flag */ + *log_pos++= KEY_OP_SET_PAGEFLAG; + *log_pos++= ma_page->buff[KEYPAGE_TRANSFLAG_OFFSET]; + log_pos[0]= KEY_OP_OFFSET; int2store(log_pos+1, offset); - log_pos[3]= KEY_OP_SHIFT; - int2store(log_pos+4, -(int) move_length); - log_pos+= 6; - translog_parts= 1; + log_pos+= 3; + translog_parts= TRANSLOG_INTERNAL_PARTS + 1; + extra_length= 0; + if (changed_length) { + if (offset + changed_length >= share->max_index_block_size) + { + changed_length= share->max_index_block_size - offset; + move_length= 0; /* Nothing to move */ + current_size= share->max_index_block_size; + } + log_pos[0]= KEY_OP_CHANGE; int2store(log_pos+1, changed_length); log_pos+= 3; - translog_parts= 2; - log_array[TRANSLOG_INTERNAL_PARTS + 1].str= ma_page->buff + offset; - log_array[TRANSLOG_INTERNAL_PARTS + 1].length= changed_length; - } - -#ifdef EXTRA_DEBUG_KEY_CHANGES - { - int page_length= ma_page->size; - ha_checksum crc; - crc= my_checksum(0, ma_page->buff + LSN_STORE_SIZE, - page_length - LSN_STORE_SIZE); - log_pos[0]= KEY_OP_CHECK; - int2store(log_pos+1, page_length); - int4store(log_pos+3, crc); - - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= log_pos; - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7; - changed_length+= 7; + log_array[translog_parts].str= ma_page->buff + offset; + log_array[translog_parts].length= changed_length; translog_parts++; + + /* We only have to move things after offset+changed_length */ + offset+= changed_length; } -#endif log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - log_data); + if (move_length) + { + uint log_length; + if (offset + move_length < share->max_index_block_size) + { + /* + Move down things that is on page. + page_offset in apply_redo_inxed() will be at original offset + + changed_length. + */ + log_pos[0]= KEY_OP_SHIFT; + int2store(log_pos+1, - (int) move_length); + log_length= 3; + current_size-= move_length; + } + else + { + /* Delete to end of page */ + uint tmp= current_size - offset; + current_size= offset; + log_pos[0]= KEY_OP_DEL_SUFFIX; + int2store(log_pos+1, tmp); + log_length= 3; + } + log_array[translog_parts].str= log_pos; + log_array[translog_parts].length= log_length; + translog_parts++; + log_pos+= log_length; + extra_length+= log_length; + } + + if (current_size != ma_page->size && + current_size != share->max_index_block_size) + { + /* Append data that didn't fit on the page before */ + uint length= (min(ma_page->size, share->max_index_block_size) - + current_size); + uchar *data= ma_page->buff + current_size; + + DBUG_ASSERT(length <= append_length); + + log_pos[0]= KEY_OP_ADD_SUFFIX; + int2store(log_pos+1, length); + log_array[translog_parts].str= log_pos; + log_array[translog_parts].length= 3; + log_array[translog_parts + 1].str= data; + log_array[translog_parts + 1].length= length; + log_pos+= 3; + translog_parts+= 2; + current_size+= length; + extra_length+= 3 + length; + } + + _ma_log_key_changes(ma_page, + log_array + translog_parts, + log_pos, &extra_length, &translog_parts); + /* Remember new page length for future log entires for same page */ + ma_page->org_size= current_size; + if (translog_write_record(&lsn, LOGREC_REDO_INDEX, info->trn, info, (translog_size_t) - log_array[TRANSLOG_INTERNAL_PARTS + 0].length + - changed_length, - TRANSLOG_INTERNAL_PARTS + translog_parts, + log_array[TRANSLOG_INTERNAL_PARTS].length + + changed_length + extra_length, translog_parts, log_array, log_data, NULL)) DBUG_RETURN(1); + DBUG_RETURN(0); } diff --git a/storage/maria/ma_key_recover.c b/storage/maria/ma_key_recover.c index 82f8099fe6a..47cfef73ddd 100644 --- a/storage/maria/ma_key_recover.c +++ b/storage/maria/ma_key_recover.c @@ -312,24 +312,33 @@ my_bool write_hook_for_undo_key_delete(enum translog_record_type type, */ my_bool _ma_log_prefix(MARIA_PAGE *ma_page, uint changed_length, - int move_length) + int move_length, + enum en_key_debug debug_marker __attribute__((unused))) { uint translog_parts; LSN lsn; - uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 7 + 7 + 2], *log_pos; + uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 7 + 7 + 2 + 2]; + uchar *log_pos; uchar *buff= ma_page->buff; - LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 3]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 4]; pgcache_page_no_t page; MARIA_HA *info= ma_page->info; DBUG_ENTER("_ma_log_prefix"); DBUG_PRINT("enter", ("page: %lu changed_length: %u move_length: %d", (ulong) ma_page->pos, changed_length, move_length)); + DBUG_ASSERT(ma_page->size == ma_page->org_size + move_length); + page= ma_page->pos / info->s->block_size; log_pos= log_data + FILEID_STORE_SIZE; page_store(log_pos, page); log_pos+= PAGE_STORE_SIZE; +#ifdef EXTRA_DEBUG_KEY_CHANGES + (*log_pos++)= KEY_OP_DEBUG; + (*log_pos++)= debug_marker; +#endif + /* Store keypage_flag */ *log_pos++= KEY_OP_SET_PAGEFLAG; *log_pos++= buff[KEYPAGE_TRANSFLAG_OFFSET]; @@ -373,21 +382,11 @@ my_bool _ma_log_prefix(MARIA_PAGE *ma_page, uint changed_length, translog_parts= 2; } -#ifdef EXTRA_DEBUG_KEY_CHANGES - { - int page_length= ma_page->size; - ha_checksum crc; - crc= my_checksum(0, buff + LSN_STORE_SIZE, page_length - LSN_STORE_SIZE); - log_pos[0]= KEY_OP_CHECK; - int2store(log_pos+1, page_length); - int4store(log_pos+3, crc); - - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= log_pos; - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7; - changed_length+= 7; - translog_parts++; - } -#endif + _ma_log_key_changes(ma_page, log_array + TRANSLOG_INTERNAL_PARTS + + translog_parts, log_pos, &changed_length, + &translog_parts); + /* Remember new page length for future log entires for same page */ + ma_page->org_size= ma_page->size; DBUG_RETURN(translog_write_record(&lsn, LOGREC_REDO_INDEX, info->trn, info, @@ -407,7 +406,7 @@ my_bool _ma_log_prefix(MARIA_PAGE *ma_page, uint changed_length, my_bool _ma_log_suffix(MARIA_PAGE *ma_page, uint org_length, uint new_length) { LSN lsn; - LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 3]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 4]; uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 10 + 7 + 2], *log_pos; uchar *buff= ma_page->buff; int diff; @@ -417,6 +416,8 @@ my_bool _ma_log_suffix(MARIA_PAGE *ma_page, uint org_length, uint new_length) DBUG_ENTER("_ma_log_suffix"); DBUG_PRINT("enter", ("page: %lu org_length: %u new_length: %u", (ulong) ma_page->pos, org_length, new_length)); + DBUG_ASSERT(ma_page->size == new_length); + DBUG_ASSERT(ma_page->org_size == org_length); page= ma_page->pos / info->s->block_size; @@ -451,20 +452,11 @@ my_bool _ma_log_suffix(MARIA_PAGE *ma_page, uint org_length, uint new_length) log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - log_data); -#ifdef EXTRA_DEBUG_KEY_CHANGES - { - ha_checksum crc; - crc= my_checksum(0, buff + LSN_STORE_SIZE, new_length - LSN_STORE_SIZE); - log_pos[0]= KEY_OP_CHECK; - int2store(log_pos+1, new_length); - int4store(log_pos+3, crc); - - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= log_pos; - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7; - extra_length+= 7; - translog_parts++; - } -#endif + _ma_log_key_changes(ma_page, + log_array + TRANSLOG_INTERNAL_PARTS + translog_parts, + log_pos, &extra_length, &translog_parts); + /* Remember new page length for future log entires for same page */ + ma_page->org_size= ma_page->size; DBUG_RETURN(translog_write_record(&lsn, LOGREC_REDO_INDEX, info->trn, info, @@ -481,12 +473,16 @@ my_bool _ma_log_suffix(MARIA_PAGE *ma_page, uint org_length, uint new_length) @param ma_page Changed page @param org_page_length Length of data in page before key was added + Final length in ma_page->size @note If handle_overflow is set, then we have to protect against logging changes that is outside of the page. This may happen during underflow() handling where the buffer in memory temporary contains more data than block_size + + ma_page may be a page that was previously logged and cuted down + becasue it's too big. (org_page_length > ma_page->org_size) */ my_bool _ma_log_add(MARIA_PAGE *ma_page, @@ -496,14 +492,14 @@ my_bool _ma_log_add(MARIA_PAGE *ma_page, { LSN lsn; uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 2 + 3 + 3 + 3 + 3 + 7 + - 2]; + 3 + 2]; uchar *log_pos; uchar *buff= ma_page->buff; - LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 3]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 6]; MARIA_HA *info= ma_page->info; uint offset= (uint) (key_pos - buff); - uint page_length= info->s->block_size - KEYPAGE_CHECKSUM_SIZE; - uint translog_parts; + uint max_page_size= info->s->max_index_block_size; + uint translog_parts, current_size; pgcache_page_no_t page_pos; DBUG_ENTER("_ma_log_add"); DBUG_PRINT("enter", ("page: %lu org_page_length: %u changed_length: %u " @@ -512,6 +508,9 @@ my_bool _ma_log_add(MARIA_PAGE *ma_page, move_length)); DBUG_ASSERT(info->s->now_transactional); DBUG_ASSERT(move_length <= (int) changed_length); + DBUG_ASSERT(ma_page->org_size == min(org_page_length, max_page_size)); + DBUG_ASSERT(ma_page->size == org_page_length + move_length); + DBUG_ASSERT(offset < max_page_size); /* Write REDO entry that contains the logical operations we need @@ -520,6 +519,7 @@ my_bool _ma_log_add(MARIA_PAGE *ma_page, log_pos= log_data + FILEID_STORE_SIZE; page_pos= ma_page->pos / info->s->block_size; page_store(log_pos, page_pos); + current_size= ma_page->org_size; log_pos+= PAGE_STORE_SIZE; #ifdef EXTRA_DEBUG_KEY_CHANGES @@ -531,40 +531,41 @@ my_bool _ma_log_add(MARIA_PAGE *ma_page, *log_pos++= KEY_OP_SET_PAGEFLAG; *log_pos++= buff[KEYPAGE_TRANSFLAG_OFFSET]; - if (org_page_length + move_length > page_length) + /* + Don't overwrite page boundary + It's ok to cut this as we will append the data at end of page + in the next log entry + */ + if (offset + changed_length > max_page_size) { - /* - Overflow. Cut either key or data from page end so that key fits - The code that splits the too big page will ignore logging any - data over org_page_length - */ DBUG_ASSERT(handle_overflow); - if (offset + changed_length > page_length) - { - /* Log that data changed to end of page */ - changed_length= page_length - offset; - move_length= 0; - /* Set page to max length */ - org_page_length= page_length; - *log_pos++= KEY_OP_MAX_PAGELENGTH; - } - else - { - /* They key will not be part of the page ; Don't log it */ - uint diff= org_page_length + move_length - page_length; - log_pos[0]= KEY_OP_DEL_SUFFIX; - int2store(log_pos+1, diff); - log_pos+= 3; - org_page_length-= diff; - DBUG_ASSERT(org_page_length == page_length - move_length); - } - DBUG_ASSERT(offset != org_page_length); + changed_length= max_page_size - offset; /* Update to end of page */ + move_length= 0; /* Nothing to move */ + /* Extend the page to max length on recovery */ + *log_pos++= KEY_OP_MAX_PAGELENGTH; + current_size= max_page_size; } - if (offset == org_page_length) + /* Check if adding the key made the page overflow */ + if (current_size + move_length > max_page_size) + { + /* + Adding the key caused an overflow. Cut away the part of the + page that doesn't fit. + */ + uint diff; + DBUG_ASSERT(handle_overflow); + diff= current_size + move_length - max_page_size; + log_pos[0]= KEY_OP_DEL_SUFFIX; + int2store(log_pos+1, diff); + log_pos+= 3; + current_size= max_page_size - move_length; + } + + if (offset == current_size) { - DBUG_ASSERT(move_length == (int) changed_length); log_pos[0]= KEY_OP_ADD_SUFFIX; + current_size+= changed_length; } else { @@ -576,51 +577,103 @@ my_bool _ma_log_add(MARIA_PAGE *ma_page, log_pos[0]= KEY_OP_SHIFT; int2store(log_pos+1, move_length); log_pos+= 3; + current_size+= move_length; } log_pos[0]= KEY_OP_CHANGE; } int2store(log_pos+1, changed_length); log_pos+= 3; - translog_parts= 2; log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - log_data); log_array[TRANSLOG_INTERNAL_PARTS + 1].str= key_pos; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= changed_length; + translog_parts= TRANSLOG_INTERNAL_PARTS + 2; -#ifdef EXTRA_DEBUG_KEY_CHANGES + /* + If page was originally > block_size before operation and now all data + fits, append the end data that was not part of the previous logged + page to it. + */ + DBUG_ASSERT(current_size <= max_page_size && current_size <= ma_page->size); + if (current_size != ma_page->size && current_size != max_page_size) { - MARIA_SHARE *share= info->s; - ha_checksum crc; - uint save_page_length= ma_page->size; - uint new_length= org_page_length + move_length; - _ma_store_page_used(share, buff, new_length); - crc= my_checksum(0, buff + LSN_STORE_SIZE, new_length - LSN_STORE_SIZE); - log_pos[0]= KEY_OP_CHECK; - int2store(log_pos+1, new_length); - int4store(log_pos+3, crc); + uint length= min(ma_page->size, max_page_size) - current_size; + uchar *data= ma_page->buff + current_size; - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= log_pos; - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7; - changed_length+= 7; - translog_parts++; - _ma_store_page_used(share, buff, save_page_length); + log_pos[0]= KEY_OP_ADD_SUFFIX; + int2store(log_pos+1, length); + log_array[translog_parts].str= log_pos; + log_array[translog_parts].length= 3; + log_array[translog_parts+1].str= data; + log_array[translog_parts+1].length= length; + log_pos+= 3; + translog_parts+= 2; + current_size+= length; + changed_length+= length + 3; } -#endif + + _ma_log_key_changes(ma_page, log_array + translog_parts, + log_pos, &changed_length, &translog_parts); + /* + Remember new page length for future log entries for same page + Note that this can be different from ma_page->size in case of page + overflow! + */ + ma_page->org_size= current_size; + DBUG_ASSERT(ma_page->org_size == min(ma_page->size, max_page_size)); if (translog_write_record(&lsn, LOGREC_REDO_INDEX, info->trn, info, (translog_size_t) log_array[TRANSLOG_INTERNAL_PARTS + 0].length + - changed_length, - TRANSLOG_INTERNAL_PARTS + translog_parts, + changed_length, translog_parts, log_array, log_data, NULL)) DBUG_RETURN(-1); DBUG_RETURN(0); } +#ifdef EXTRA_DEBUG_KEY_CHANGES + +/* Log checksum and optionally key page to log */ + +void _ma_log_key_changes(MARIA_PAGE *ma_page, LEX_CUSTRING *log_array, + uchar *log_pos, uint *changed_length, + uint *translog_parts) +{ + MARIA_SHARE *share= ma_page->info->s; + int page_length= min(ma_page->size, share->max_index_block_size); + uint org_length; + ha_checksum crc; + + DBUG_ASSERT(ma_page->flag == (uint) ma_page->buff[KEYPAGE_TRANSFLAG_OFFSET]); + + /* We have to change length as the page may have been shortened */ + org_length= _ma_get_page_used(share, ma_page->buff); + _ma_store_page_used(share, ma_page->buff, page_length); + crc= my_checksum(0, ma_page->buff + LSN_STORE_SIZE, + page_length - LSN_STORE_SIZE); + _ma_store_page_used(share, ma_page->buff, org_length); + + log_pos[0]= KEY_OP_CHECK; + int2store(log_pos+1, page_length); + int4store(log_pos+3, crc); + + log_array[0].str= log_pos; + log_array[0].length= 7; + (*changed_length)+= 7; + (*translog_parts)++; +#ifdef EXTRA_STORE_FULL_PAGE_IN_KEY_CHANGES + log_array[1].str= ma_page->buff; + log_array[1].length= page_length; + (*changed_length)+= page_length; + (*translog_parts)++; +#endif +#endif +} + /**************************************************************************** Redo of key pages ****************************************************************************/ @@ -716,7 +769,7 @@ uint _ma_apply_redo_index_new_page(MARIA_HA *info, LSN lsn, bzero(buff, LSN_STORE_SIZE); memcpy(buff + LSN_STORE_SIZE, header, length); bzero(buff + LSN_STORE_SIZE + length, - share->block_size - LSN_STORE_SIZE - KEYPAGE_CHECKSUM_SIZE - length); + share->max_index_block_size - LSN_STORE_SIZE - length); bfill(buff + share->block_size - KEYPAGE_CHECKSUM_SIZE, KEYPAGE_CHECKSUM_SIZE, (uchar) 255); @@ -847,7 +900,9 @@ err: KEY_OP_ADD_SUFFIX 2 length, data Add data to end of page KEY_OP_DEL_SUFFIX 2 length Reduce page length with this Sets position to start of page - KEY_OP_CHECK 6 page_length[2},CRC Used only when debugging + KEY_OP_CHECK 6 page_length[2],CRC Used only when debugging + This may be followed by page_length + of data (until end of log record) KEY_OP_COMPACT_PAGE 6 transid KEY_OP_SET_PAGEFLAG 1 flag for page KEY_OP_MAX_PAGELENGTH 0 Set page to max length @@ -870,7 +925,7 @@ uint _ma_apply_redo_index(MARIA_HA *info, const uchar *header_end= header + head_length; uint page_offset= 0, org_page_length; uint nod_flag, page_length, keypage_header, keynr; - uint max_page_length= share->block_size - KEYPAGE_CHECKSUM_SIZE; + uint max_page_size= share->max_index_block_size; int result; MARIA_PAGE page; DBUG_ENTER("_ma_apply_redo_index"); @@ -919,11 +974,14 @@ uint _ma_apply_redo_index(MARIA_HA *info, header+= 2; DBUG_PRINT("redo", ("key_op_shift: %d", length)); DBUG_ASSERT(page_offset != 0 && page_offset <= page_length && - page_length + length <= max_page_length); + page_length + length <= max_page_size); if (length < 0) + { + DBUG_ASSERT(page_offset - length <= page_length); bmove(buff + page_offset, buff + page_offset - length, page_length - page_offset + length); + } else if (page_length != page_offset) bmove_upp(buff + page_length + length, buff + page_length, page_length - page_offset); @@ -937,6 +995,7 @@ uint _ma_apply_redo_index(MARIA_HA *info, DBUG_ASSERT(page_offset != 0 && page_offset + length <= page_length); memcpy(buff + page_offset, header + 2 , length); + page_offset+= length; /* Put offset after changed length */ header+= 2 + length; break; } @@ -948,7 +1007,7 @@ uint _ma_apply_redo_index(MARIA_HA *info, insert_length, changed_length)); DBUG_ASSERT(insert_length <= changed_length && - page_length + changed_length <= max_page_length); + page_length + changed_length <= max_page_size); bmove_upp(buff + page_length + insert_length, buff + page_length, page_length - keypage_header); @@ -974,8 +1033,8 @@ uint _ma_apply_redo_index(MARIA_HA *info, case KEY_OP_ADD_SUFFIX: /* 6 */ { uint insert_length= uint2korr(header); - DBUG_PRINT("redo", ("key_op_add_prefix: %u", insert_length)); - DBUG_ASSERT(page_length + insert_length <= max_page_length); + DBUG_PRINT("redo", ("key_op_add_suffix: %u", insert_length)); + DBUG_ASSERT(page_length + insert_length <= max_page_size); memcpy(buff + page_length, header+2, insert_length); page_length+= insert_length; @@ -1003,13 +1062,22 @@ uint _ma_apply_redo_index(MARIA_HA *info, if (crc != (uint32) my_checksum(0, buff + LSN_STORE_SIZE, page_length - LSN_STORE_SIZE)) { - DBUG_PRINT("error", ("page_length %u",page_length)); - DBUG_DUMP("KEY_OP_CHECK bad page", buff, max_page_length); - DBUG_ASSERT("crc" == "failure in REDO_INDEX"); + DBUG_DUMP("KEY_OP_CHECK bad page", buff, page_length); + if (header + 6 + page_length <= header_end) + { + DBUG_DUMP("KEY_OP_CHECK org page", header + 6, page_length); + } + DBUG_ASSERT("crc failure in REDO_INDEX" == 0); } #endif DBUG_PRINT("redo", ("key_op_check")); - header+= 6; + /* + This is the last entry in the block and it can contain page_length + data or not + */ + DBUG_ASSERT(header + 6 == header_end || + header + 6 + page_length == header_end); + header= header_end; break; } case KEY_OP_DEBUG: @@ -1018,7 +1086,7 @@ uint _ma_apply_redo_index(MARIA_HA *info, break; case KEY_OP_MAX_PAGELENGTH: DBUG_PRINT("redo", ("key_op_max_page_length")); - page_length= max_page_length; + page_length= max_page_size; break; case KEY_OP_MULTI_COPY: /* 9 */ { @@ -1040,7 +1108,7 @@ uint _ma_apply_redo_index(MARIA_HA *info, log_memcpy_length= uint2korr(header); header+= 2; log_memcpy_end= header + log_memcpy_length; - DBUG_ASSERT(full_length <= max_page_length); + DBUG_ASSERT(full_length <= max_page_size); while (header < log_memcpy_end) { uint to, from; @@ -1049,7 +1117,7 @@ uint _ma_apply_redo_index(MARIA_HA *info, from= uint2korr(header); header+= 2; /* "from" is a place in the existing page */ - DBUG_ASSERT(max(from, to) < max_page_length); + DBUG_ASSERT(max(from, to) < max_page_size); memcpy(buff + to, buff + from, full_length); } break; diff --git a/storage/maria/ma_key_recover.h b/storage/maria/ma_key_recover.h index 30830f7d82c..26f5f716c75 100644 --- a/storage/maria/ma_key_recover.h +++ b/storage/maria/ma_key_recover.h @@ -64,17 +64,26 @@ extern my_bool write_hook_for_undo_key_delete(enum translog_record_type type, TRN *trn, MARIA_HA *tbl_info, LSN *lsn, void *hook_arg); -my_bool _ma_log_prefix(MARIA_PAGE *page, uint changed_length, int move_length); +my_bool _ma_log_prefix(MARIA_PAGE *page, uint changed_length, int move_length, + enum en_key_debug debug_marker); my_bool _ma_log_suffix(MARIA_PAGE *page, uint org_length, uint new_length); my_bool _ma_log_add(MARIA_PAGE *page, uint buff_length, uchar *key_pos, uint changed_length, int move_length, my_bool handle_overflow); my_bool _ma_log_delete(MARIA_PAGE *page, const uchar *key_pos, - uint changed_length, uint move_length); + uint changed_length, uint move_length, + uint append_length, enum en_key_debug debug_marker); my_bool _ma_log_change(MARIA_PAGE *page, const uchar *key_pos, uint length, enum en_key_debug debug_marker); my_bool _ma_log_new(MARIA_PAGE *page, my_bool root_page); +#ifdef EXTRA_DEBUG_KEY_CHANGES +void _ma_log_key_changes(MARIA_PAGE *ma_page, LEX_CUSTRING *log_array, + uchar *log_pos, uint *changed_length, + uint *translog_parts); +#else +void _ma_log_key_changes(A,B,C,D,E) +#endif uint _ma_apply_redo_index_new_page(MARIA_HA *info, LSN lsn, const uchar *header, uint length); diff --git a/storage/maria/ma_loghandler.h b/storage/maria/ma_loghandler.h index 2ef082e38dc..8e04164a81a 100644 --- a/storage/maria/ma_loghandler.h +++ b/storage/maria/ma_loghandler.h @@ -172,13 +172,24 @@ enum en_key_op enum en_key_debug { - KEY_OP_DEBUG_RTREE_COMBINE, - KEY_OP_DEBUG_RTREE_SPLIT, - KEY_OP_DEBUG_RTREE_SET_KEY, - KEY_OP_DEBUG_FATHER_CHANGED_1, - KEY_OP_DEBUG_FATHER_CHANGED_2, - KEY_OP_DEBUG_LOG_SPLIT, - KEY_OP_DEBUG_LOG_ADD + KEY_OP_DEBUG_RTREE_COMBINE, /* 0 */ + KEY_OP_DEBUG_RTREE_SPLIT, /* 1 */ + KEY_OP_DEBUG_RTREE_SET_KEY, /* 2 */ + KEY_OP_DEBUG_FATHER_CHANGED_1, /* 3 */ + KEY_OP_DEBUG_FATHER_CHANGED_2, /* 4 */ + KEY_OP_DEBUG_LOG_SPLIT, /* 5 */ + KEY_OP_DEBUG_LOG_ADD, /* 6 */ + KEY_OP_DEBUG_LOG_PREFIX_1, /* 7 */ + KEY_OP_DEBUG_LOG_PREFIX_2, /* 8 */ + KEY_OP_DEBUG_LOG_PREFIX_3, /* 9 */ + KEY_OP_DEBUG_LOG_PREFIX_4, /* 10 */ + KEY_OP_DEBUG_LOG_PREFIX_5, /* 11 */ + KEY_OP_DEBUG_LOG_DEL_CHANGE_1, /* 12 */ + KEY_OP_DEBUG_LOG_DEL_CHANGE_2, /* 13 */ + KEY_OP_DEBUG_LOG_DEL_CHANGE_3, /* 14 */ + KEY_OP_DEBUG_LOG_DEL_CHANGE_RT, /* 15 */ + KEY_OP_DEBUG_LOG_DEL_PREFIX, /* 16 */ + KEY_OP_DEBUG_LOG_MIDDLE /* 17 */ }; diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index a43513cfaa0..39c13e27e15 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -550,6 +550,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) strmov(share->open_file_name.str, name); share->block_size= share->base.block_size; /* Convenience */ + share->max_index_block_size= share->block_size - KEYPAGE_CHECKSUM_SIZE; { HA_KEYSEG *pos=share->keyparts; uint32 ftkey_nr= 1; diff --git a/storage/maria/ma_page.c b/storage/maria/ma_page.c index acbee2a6f07..a4423133270 100644 --- a/storage/maria/ma_page.c +++ b/storage/maria/ma_page.c @@ -59,6 +59,7 @@ void _ma_page_setup(MARIA_PAGE *page, MARIA_HA *info, page->buff= buff; page->pos= pos; page->size= _ma_get_page_used(share, buff); + page->org_size= page->size; page->flag= _ma_get_keypage_flag(share, buff); page->node= ((page->flag & KEYPAGE_FLAG_ISNOD) ? share->base.key_reflength : 0); @@ -68,7 +69,7 @@ void _ma_page_setup(MARIA_PAGE *page, MARIA_HA *info, void page_cleanup(MARIA_SHARE *share, MARIA_PAGE *page) { uint length= page->size; - DBUG_ASSERT(length <= block_size - KEYPAGE_CHECKSUM_SIZE); + DBUG_ASSERT(length <= share->max_index_block_size); bzero(page->buff + length, share->block_size - length); } #endif @@ -103,7 +104,7 @@ my_bool _ma_fetch_keypage(MARIA_PAGE *page, MARIA_HA *info, MARIA_SHARE *share= info->s; uint block_size= share->block_size; DBUG_ENTER("_ma_fetch_keypage"); - DBUG_PRINT("enter",("pos: %ld", (long) pos)); + DBUG_PRINT("enter",("page: %lu", (ulong) (pos / block_size))); tmp= pagecache_read(share->pagecache, &share->kfile, (pgcache_page_no_t) (pos / block_size), level, buff, @@ -142,6 +143,7 @@ my_bool _ma_fetch_keypage(MARIA_PAGE *page, MARIA_HA *info, page->buff= tmp; page->pos= pos; page->size= _ma_get_page_used(share, tmp); + page->org_size= page->size; /* For debugging */ page->flag= _ma_get_keypage_flag(share, tmp); page->node= ((page->flag & KEYPAGE_FLAG_ISNOD) ? share->base.key_reflength : 0); @@ -149,7 +151,7 @@ my_bool _ma_fetch_keypage(MARIA_PAGE *page, MARIA_HA *info, #ifdef EXTRA_DEBUG { uint page_size= page->size; - if (page_size < 4 || page_size > block_size || + if (page_size < 4 || page_size > share->max_index_block_size || _ma_get_keynr(share, tmp) != keyinfo->key_nr) { DBUG_PRINT("error",("page %lu had wrong page length: %u keynr: %u", @@ -159,7 +161,7 @@ my_bool _ma_fetch_keypage(MARIA_PAGE *page, MARIA_HA *info, info->last_keypage = HA_OFFSET_ERROR; maria_print_error(share, HA_ERR_CRASHED); my_errno= HA_ERR_CRASHED; - tmp= 0; + DBUG_RETURN(1); } } #endif @@ -179,6 +181,13 @@ my_bool _ma_write_keypage(MARIA_PAGE *page, enum pagecache_page_lock lock, MARIA_PINNED_PAGE page_link; DBUG_ENTER("_ma_write_keypage"); + /* + The following ensures that for transactional tables we have logged + all changes that changes the page size (as the logging code sets + page->org_size) + */ + DBUG_ASSERT(!share->now_transactional || page->size == page->org_size); + #ifdef EXTRA_DEBUG /* Safety check */ { uint page_length, nod_flag; @@ -193,7 +202,7 @@ my_bool _ma_write_keypage(MARIA_PAGE *page, enum pagecache_page_lock lock, (page->pos & (maria_block_size-1))) { DBUG_PRINT("error",("Trying to write inside key status region: " - "key_start: %lu length: %lu page: %lu", + "key_start: %lu length: %lu page_pos: %lu", (long) share->base.keystart, (long) share->state.state.key_file_length, (long) page->pos)); @@ -201,7 +210,7 @@ my_bool _ma_write_keypage(MARIA_PAGE *page, enum pagecache_page_lock lock, DBUG_ASSERT(0); DBUG_RETURN(1); } - DBUG_PRINT("page",("write page at: %lu",(long) page->pos)); + DBUG_PRINT("page",("write page at: %lu",(ulong) (page->pos / block_size))); DBUG_DUMP("buff", buff, page_length); DBUG_ASSERT(page_length >= share->keypage_header + nod_flag + page->keyinfo->minlength || maria_in_recovery); @@ -274,7 +283,7 @@ int _ma_dispose(register MARIA_HA *info, my_off_t pos, my_bool page_not_read) enum pagecache_page_lock lock_method; enum pagecache_page_pin pin_method; DBUG_ENTER("_ma_dispose"); - DBUG_PRINT("enter",("pos: %ld", (long) pos)); + DBUG_PRINT("enter",("page: %lu", (ulong) (pos / block_size))); DBUG_ASSERT(pos % block_size == 0); (void) _ma_lock_key_del(info, 0); @@ -423,8 +432,7 @@ my_off_t _ma_new(register MARIA_HA *info, int level, share->key_del_current= mi_sizekorr(buff+share->keypage_header); #ifndef DBUG_OFF key_del_current= share->key_del_current; - DBUG_ASSERT(key_del_current != share->state.key_del && - (key_del_current != 0) && + DBUG_ASSERT((key_del_current != 0) && ((key_del_current == HA_OFFSET_ERROR) || (key_del_current <= (share->state.state.key_file_length - block_size)))); @@ -453,32 +461,48 @@ my_off_t _ma_new(register MARIA_HA *info, int level, Log compactation of a index page */ -static my_bool _ma_log_compact_keypage(MARIA_HA *info, my_off_t page, +static my_bool _ma_log_compact_keypage(MARIA_PAGE *ma_page, TrID min_read_from) { LSN lsn; - uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 1 + TRANSID_SIZE]; + uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 1 + 7 + TRANSID_SIZE]; + uchar *log_pos; LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; + MARIA_HA *info= ma_page->info; MARIA_SHARE *share= info->s; + uint translog_parts, extra_length; + my_off_t page= ma_page->pos; DBUG_ENTER("_ma_log_compact_keypage"); - DBUG_PRINT("enter", ("page: %lu", (ulong) page)); + DBUG_PRINT("enter", ("page: %lu", (ulong) (page / share->block_size))); /* Store address of new root page */ page/= share->block_size; page_store(log_data + FILEID_STORE_SIZE, page); - log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE]= KEY_OP_COMPACT_PAGE; - transid_store(log_data + FILEID_STORE_SIZE + PAGE_STORE_SIZE +1, - min_read_from); + log_pos= log_data + FILEID_STORE_SIZE + PAGE_STORE_SIZE; + + log_pos[0]= KEY_OP_COMPACT_PAGE; + transid_store(log_pos + 1, min_read_from); + log_pos+= 1 + TRANSID_SIZE; log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; - log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); + log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - + log_data); + translog_parts= 1; + extra_length= 0; + + _ma_log_key_changes(ma_page, + log_array + TRANSLOG_INTERNAL_PARTS + translog_parts, + log_pos, &extra_length, &translog_parts); + /* Remember new page length for future log entires for same page */ + ma_page->org_size= ma_page->size; if (translog_write_record(&lsn, LOGREC_REDO_INDEX, info->trn, info, - (translog_size_t) sizeof(log_data), - TRANSLOG_INTERNAL_PARTS + 1, log_array, - log_data, NULL)) + log_array[TRANSLOG_INTERNAL_PARTS + + 0].length + extra_length, + TRANSLOG_INTERNAL_PARTS + translog_parts, + log_array, log_data, NULL)) DBUG_RETURN(1); DBUG_RETURN(0); } @@ -526,7 +550,7 @@ my_bool _ma_compact_keypage(MARIA_PAGE *ma_page, TrID min_read_from) { if (!(page= (*ma_page->keyinfo->skip_key)(&key, 0, 0, page))) { - DBUG_PRINT("error",("Couldn't find last key: page: 0x%lx", + DBUG_PRINT("error",("Couldn't find last key: page_pos: 0x%lx", (long) page)); maria_print_error(share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; @@ -588,7 +612,7 @@ my_bool _ma_compact_keypage(MARIA_PAGE *ma_page, TrID min_read_from) if (share->now_transactional) { - if (_ma_log_compact_keypage(info, ma_page->pos, min_read_from)) + if (_ma_log_compact_keypage(ma_page, min_read_from)) DBUG_RETURN(1); } DBUG_RETURN(0); diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index a10fac9a15d..c0205b5ed00 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -545,7 +545,7 @@ static int display_and_apply_record(const LOG_DESC *log_desc, if (log_desc->record_execute_in_redo_phase == NULL) { /* die on all not-yet-handled records :) */ - DBUG_ASSERT("one more hook" == "to write"); + DBUG_ASSERT("one more hook to write" == 0); return 1; } if ((error= (*log_desc->record_execute_in_redo_phase)(rec))) @@ -1063,6 +1063,7 @@ prototype_redo_exec_hook(REDO_REPAIR_TABLE) param.isam_file_name= name= info->s->open_file_name.str; param.testflag= uint8korr(rec->header + FILEID_STORE_SIZE); param.tmpdir= maria_tmpdir; + param.max_trid= max_long_trid; DBUG_ASSERT(maria_tmpdir); info->s->state.key_map= uint8korr(rec->header + FILEID_STORE_SIZE + 8); diff --git a/storage/maria/ma_rt_key.c b/storage/maria/ma_rt_key.c index bc2c8f71f5d..2e204990a3b 100644 --- a/storage/maria/ma_rt_key.c +++ b/storage/maria/ma_rt_key.c @@ -91,7 +91,8 @@ int maria_rtree_delete_key(MARIA_PAGE *page, uchar *key, uint key_length) page->size-= key_length_with_nod_flag; page_store_size(share, page); if (share->now_transactional && - _ma_log_delete(page, key_start, 0, key_length_with_nod_flag)) + _ma_log_delete(page, key_start, 0, key_length_with_nod_flag, + 0, KEY_OP_DEBUG_LOG_DEL_CHANGE_RT)) return -1; return 0; } diff --git a/storage/maria/ma_rt_split.c b/storage/maria/ma_rt_split.c index 8f137c2e0cf..856edc60490 100644 --- a/storage/maria/ma_rt_split.c +++ b/storage/maria/ma_rt_split.c @@ -308,7 +308,7 @@ static my_bool _ma_log_rt_split(MARIA_PAGE *page, LSN lsn; uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 1 + 2 + 1 + 2 + 2 + 7], *log_pos; - LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 5]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 6]; uint translog_parts, extra_length= 0; my_off_t page_pos; DBUG_ENTER("_ma_log_rt_split"); @@ -344,24 +344,11 @@ static my_bool _ma_log_rt_split(MARIA_PAGE *page, translog_parts+= 2; } -#ifdef EXTRA_DEBUG_KEY_CHANGES - { - int page_length= page->size; - ha_checksum crc; - uchar *check_start= log_pos; - crc= my_checksum(0, page->buff + LSN_STORE_SIZE, - page_length - LSN_STORE_SIZE); - log_pos[0]= KEY_OP_CHECK; - log_pos++; - int2store(log_pos, page_length); - log_pos+= 2; - int4store(log_pos, crc); - log_pos+= 4; - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= check_start; - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7; - translog_parts++; - } -#endif + _ma_log_key_changes(page, + log_array + TRANSLOG_INTERNAL_PARTS + translog_parts, + log_pos, &extra_length, &translog_parts); + /* Remember new page length for future log entires for same page */ + page->org_size= page->size; if (translog_write_record(&lsn, LOGREC_REDO_INDEX, info->trn, info, diff --git a/storage/maria/ma_unique.c b/storage/maria/ma_unique.c index bae58fd70cd..a90578c2162 100644 --- a/storage/maria/ma_unique.c +++ b/storage/maria/ma_unique.c @@ -68,8 +68,7 @@ my_bool _ma_check_unique(MARIA_HA *info, MARIA_UNIQUEDEF *def, uchar *record, DBUG_ASSERT(info->last_key.data_length == MARIA_UNIQUE_HASH_LENGTH); if (_ma_search_next(info, &info->last_key, SEARCH_BIGGER, info->s->state.key_root[def->key]) || - bcmp((char*) info->last_key.data, (char*) key_buff, - MARIA_UNIQUE_HASH_LENGTH)) + bcmp(info->last_key.data, key_buff, MARIA_UNIQUE_HASH_LENGTH)) { info->page_changed= 1; /* Can't optimize read next */ info->cur_row.lastpos= lastpos; diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c index 6a5c2995ae5..958a07e1c70 100644 --- a/storage/maria/ma_write.c +++ b/storage/maria/ma_write.c @@ -823,9 +823,9 @@ int _ma_insert(register MARIA_HA *info, MARIA_KEY *key, Check if the new key fits totally into the the page (anc_buff is big enough to contain a full page + one key) */ - if (a_length <= (uint) keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE) + if (a_length <= share->max_index_block_size) { - if (keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE - a_length < 32 && + if (share->max_index_block_size - a_length < 32 && (keyinfo->flag & HA_FULLTEXT) && key_pos == endpos && share->base.key_reflength <= share->base.rec_reflength && share->options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) @@ -885,9 +885,9 @@ ChangeSet@1.2562, 2008-04-09 07:41:40+02:00, serg@janus.mylan +9 -0 } else { - if (share->now_transactional && + if (share->now_transactional && _ma_log_add(anc_page, org_anc_length, - key_pos, s_temp.changed_length, t_length, 0)) + key_pos, s_temp.changed_length, t_length, 1)) DBUG_RETURN(-1); } DBUG_RETURN(0); /* There is room on page */ @@ -1265,7 +1265,7 @@ static int _ma_balance_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo, curr_keylength); if ((right ? right_length : left_length) + curr_keylength <= - (uint) keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE) + share->max_index_block_size) { /* Enough space to hold all keys in the two buffers ; Balance bufferts */ new_left_length= share->keypage_header+nod_flag+(keys/2)*curr_keylength; @@ -1320,7 +1320,8 @@ static int _ma_balance_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo, start of page */ if (_ma_log_prefix(&next_page, 0, - ((int) new_right_length - (int) right_length))) + ((int) new_right_length - (int) right_length), + KEY_OP_DEBUG_LOG_PREFIX_3)) goto err; } else @@ -1383,7 +1384,8 @@ static int _ma_balance_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo, */ if (_ma_log_prefix(&next_page, (uint) (new_right_length - right_length), - (int) (new_right_length - right_length))) + (int) (new_right_length - right_length), + KEY_OP_DEBUG_LOG_PREFIX_4)) goto err; } else @@ -1545,7 +1547,8 @@ static int _ma_balance_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo, This contains the last 'extra_buff' from 'buff' */ if (_ma_log_prefix(&extra_page, - 0, (int) (extra_buff_length - right_length))) + 0, (int) (extra_buff_length - right_length), + KEY_OP_DEBUG_LOG_PREFIX_5)) goto err; /* @@ -1891,6 +1894,9 @@ my_bool _ma_log_new(MARIA_PAGE *ma_page, my_bool root_page) log_array[TRANSLOG_INTERNAL_PARTS + 1].str= ma_page->buff + LSN_STORE_SIZE; log_array[TRANSLOG_INTERNAL_PARTS + 1].length= page_length; + /* Remember new page length for future log entires for same page */ + ma_page->org_size= ma_page->size; + if (translog_write_record(&lsn, LOGREC_REDO_INDEX_NEW_PAGE, info->trn, info, (translog_size_t) @@ -1912,7 +1918,7 @@ my_bool _ma_log_change(MARIA_PAGE *ma_page, const uchar *key_pos, uint length, { LSN lsn; uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 2 + 6 + 7], *log_pos; - LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 3]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 4]; uint offset= (uint) (key_pos - ma_page->buff), translog_parts; my_off_t page; MARIA_HA *info= ma_page->info; @@ -1921,6 +1927,7 @@ my_bool _ma_log_change(MARIA_PAGE *ma_page, const uchar *key_pos, uint length, DBUG_ASSERT(info->s->now_transactional); DBUG_ASSERT(offset + length <= ma_page->size); + DBUG_ASSERT(ma_page->org_size == ma_page->size); /* Store address of new root page */ page= ma_page->pos / info->s->block_size; @@ -1944,21 +1951,9 @@ my_bool _ma_log_change(MARIA_PAGE *ma_page, const uchar *key_pos, uint length, log_array[TRANSLOG_INTERNAL_PARTS + 1].length= length; translog_parts= 2; -#ifdef EXTRA_DEBUG_KEY_CHANGES - { - int page_length= ma_page->size; - ha_checksum crc; - crc= my_checksum(0, ma_page->buff + LSN_STORE_SIZE, - page_length - LSN_STORE_SIZE); - log_pos[0]= KEY_OP_CHECK; - int2store(log_pos+1, page_length); - int4store(log_pos+3, crc); - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= log_pos; - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7; - log_pos+= 7; - translog_parts++; - } -#endif + _ma_log_key_changes(ma_page, + log_array + TRANSLOG_INTERNAL_PARTS + translog_parts, + log_pos, &length, &translog_parts); if (translog_write_record(&lsn, LOGREC_REDO_INDEX, info->trn, info, @@ -1994,8 +1989,6 @@ my_bool _ma_log_change(MARIA_PAGE *ma_page, const uchar *key_pos, uint length, - Page is shortened from end - Data is added to end of page - Data added at front of page - - */ static my_bool _ma_log_split(MARIA_PAGE *ma_page, @@ -2006,9 +1999,9 @@ static my_bool _ma_log_split(MARIA_PAGE *ma_page, uint changed_length) { LSN lsn; - uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 2 + 3+3+3+3+3+2 +7]; + uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 2 + 2 + 3+3+3+3+3+2 +7]; uchar *log_pos; - LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 4]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 6]; uint offset= (uint) (key_pos - ma_page->buff); uint translog_parts, extra_length; MARIA_HA *info= ma_page->info; @@ -2018,6 +2011,7 @@ static my_bool _ma_log_split(MARIA_PAGE *ma_page, (ulong) ma_page->pos, org_length, new_length)); DBUG_ASSERT(changed_length >= data_length); + DBUG_ASSERT(org_length <= info->s->max_index_block_size); log_pos= log_data + FILEID_STORE_SIZE; page= ma_page->pos / info->s->block_size; @@ -2029,6 +2023,10 @@ static my_bool _ma_log_split(MARIA_PAGE *ma_page, (*log_pos++)= KEY_OP_DEBUG_LOG_SPLIT; #endif + /* Store keypage_flag */ + *log_pos++= KEY_OP_SET_PAGEFLAG; + *log_pos++= ma_page->buff[KEYPAGE_TRANSFLAG_OFFSET]; + if (new_length <= offset || !key_pos) { /* @@ -2053,6 +2051,11 @@ static my_bool _ma_log_split(MARIA_PAGE *ma_page, */ max_key_length= new_length - offset; extra_length= min(key_length, max_key_length); + if (offset + move_length > new_length) + { + /* This is true when move_length includes changes for next packed key */ + move_length= new_length - offset; + } if ((int) new_length < (int) (org_length + move_length + data_length)) { @@ -2115,21 +2118,12 @@ static my_bool _ma_log_split(MARIA_PAGE *ma_page, log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - log_data); -#ifdef EXTRA_DEBUG_KEY_CHANGES - { - int page_length= ma_page->size; - ha_checksum crc; - crc= my_checksum(0, ma_page->buff + LSN_STORE_SIZE, - page_length - LSN_STORE_SIZE); - log_pos[0]= KEY_OP_CHECK; - int2store(log_pos+1, page_length); - int4store(log_pos+3, crc); - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= log_pos; - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7; - extra_length+= 7; - translog_parts++; - } -#endif + + _ma_log_key_changes(ma_page, + log_array + TRANSLOG_INTERNAL_PARTS + translog_parts, + log_pos, &extra_length, &translog_parts); + /* Remember new page length for future log entires for same page */ + ma_page->org_size= ma_page->size; DBUG_RETURN(translog_write_record(&lsn, LOGREC_REDO_INDEX, info->trn, info, @@ -2168,8 +2162,9 @@ static my_bool _ma_log_del_prefix(MARIA_PAGE *ma_page, int move_length) { LSN lsn; - uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 12 + 7], *log_pos; - LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 3]; + uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 2 + 2 + 12 + 7]; + uchar *log_pos; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 4]; uint offset= (uint) (key_pos - ma_page->buff); uint diff_length= org_length + move_length - new_length; uint translog_parts, extra_length; @@ -2180,6 +2175,7 @@ static my_bool _ma_log_del_prefix(MARIA_PAGE *ma_page, (ulong) ma_page->pos, org_length, new_length)); DBUG_ASSERT((int) diff_length > 0); + DBUG_ASSERT(ma_page->size == new_length); log_pos= log_data + FILEID_STORE_SIZE; page= ma_page->pos / info->s->block_size; @@ -2189,6 +2185,15 @@ static my_bool _ma_log_del_prefix(MARIA_PAGE *ma_page, translog_parts= 1; extra_length= 0; +#ifdef EXTRA_DEBUG_KEY_CHANGES + *log_pos++= KEY_OP_DEBUG; + *log_pos++= KEY_OP_DEBUG_LOG_DEL_PREFIX; +#endif + + /* Store keypage_flag */ + *log_pos++= KEY_OP_SET_PAGEFLAG; + *log_pos++= ma_page->buff[KEYPAGE_TRANSFLAG_OFFSET]; + if (offset < diff_length + info->s->keypage_header) { /* @@ -2236,21 +2241,11 @@ static my_bool _ma_log_del_prefix(MARIA_PAGE *ma_page, log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - log_data); -#ifdef EXTRA_DEBUG_KEY_CHANGES - { - int page_length= ma_page->size; - ha_checksum crc; - crc= my_checksum(0, ma_page->buff + LSN_STORE_SIZE, - page_length - LSN_STORE_SIZE); - log_pos[0]= KEY_OP_CHECK; - int2store(log_pos+1, page_length); - int4store(log_pos+3, crc); - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= log_pos; - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7; - extra_length+= 7; - translog_parts++; - } -#endif + _ma_log_key_changes(ma_page, + log_array + TRANSLOG_INTERNAL_PARTS + translog_parts, + log_pos, &extra_length, &translog_parts); + /* Remember new page length for future log entires for same page */ + ma_page->org_size= ma_page->size; DBUG_RETURN(translog_write_record(&lsn, LOGREC_REDO_INDEX, info->trn, info, @@ -2277,9 +2272,9 @@ static my_bool _ma_log_key_middle(MARIA_PAGE *ma_page, uint key_length, int move_length) { LSN lsn; - uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 3+5+3+3+3 + 7]; + uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 2 + 2 + 3+5+3+3+3 + 7]; uchar *log_pos; - LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 5]; + LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 6]; uint key_offset; uint translog_parts, extra_length; my_off_t page; @@ -2287,6 +2282,8 @@ static my_bool _ma_log_key_middle(MARIA_PAGE *ma_page, DBUG_ENTER("_ma_log_key_middle"); DBUG_PRINT("enter", ("page: %lu", (ulong) ma_page->pos)); + DBUG_ASSERT(ma_page->size == new_length); + /* new place of key after changes */ key_pos+= data_added_first; key_offset= (uint) (key_pos - ma_page->buff); @@ -2314,6 +2311,15 @@ static my_bool _ma_log_key_middle(MARIA_PAGE *ma_page, page_store(log_pos, page); log_pos+= PAGE_STORE_SIZE; +#ifdef EXTRA_DEBUG_KEY_CHANGES + *log_pos++= KEY_OP_DEBUG; + *log_pos++= KEY_OP_DEBUG_LOG_MIDDLE; +#endif + + /* Store keypage_flag */ + *log_pos++= KEY_OP_SET_PAGEFLAG; + *log_pos++= ma_page->buff[KEYPAGE_TRANSFLAG_OFFSET]; + log_pos[0]= KEY_OP_DEL_SUFFIX; int2store(log_pos+1, data_deleted_last); log_pos+= 3; @@ -2362,21 +2368,11 @@ static my_bool _ma_log_key_middle(MARIA_PAGE *ma_page, key_length); } -#ifdef EXTRA_DEBUG_KEY_CHANGES - { - int page_length= ma_page->size; - ha_checksum crc; - crc= my_checksum(0, ma_page->buff + LSN_STORE_SIZE, - page_length - LSN_STORE_SIZE); - log_pos[0]= KEY_OP_CHECK; - int2store(log_pos+1, page_length); - int4store(log_pos+3, crc); - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= log_pos; - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7; - extra_length+= 7; - translog_parts++; - } -#endif + _ma_log_key_changes(ma_page, + log_array + TRANSLOG_INTERNAL_PARTS + translog_parts, + log_pos, &extra_length, &translog_parts); + /* Remember new page length for future log entires for same page */ + ma_page->org_size= ma_page->size; DBUG_RETURN(translog_write_record(&lsn, LOGREC_REDO_INDEX, info->trn, info, @@ -2401,14 +2397,17 @@ static my_bool _ma_log_middle(MARIA_PAGE *ma_page, uint data_deleted_last) { LSN lsn; - LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 2]; - uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 3 + 5], *log_pos; + LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 4]; + uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 3 + 5 + 7], *log_pos; MARIA_HA *info= ma_page->info; my_off_t page; uint translog_parts, extra_length; DBUG_ENTER("_ma_log_middle"); DBUG_PRINT("enter", ("page: %lu", (ulong) page)); + DBUG_ASSERT(ma_page->org_size + data_added_first - data_deleted_last == + ma_page->size); + page= ma_page->page / info->s->block_size; log_pos= log_data + FILEID_STORE_SIZE; @@ -2434,21 +2433,11 @@ static my_bool _ma_log_middle(MARIA_PAGE *ma_page, translog_parts= 2; extra_length= data_changed_first; -#ifdef EXTRA_DEBUG_KEY_CHANGES - { - int page_length= ma_page->size; - ha_checksum crc; - crc= my_checksum(0, ma_page->buff + LSN_STORE_SIZE, - page_length - LSN_STORE_SIZE); - log_pos[0]= KEY_OP_CHECK; - int2store(log_pos+1, page_length); - int4store(log_pos+3, crc); - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= log_pos; - log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7; - extra_length+= 7; - translog_parts++; - } -#endif + _ma_log_key_changes(ma_page, + log_array + TRANSLOG_INTERNAL_PARTS + translog_parts, + log_pos, &extra_length, &translog_parts); + /* Remember new page length for future log entires for same page */ + ma_page->org_size= ma_page->size; DBUG_RETURN(translog_write_record(&lsn, LOGREC_REDO_INDEX, info->trn, info, diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index f1454502bb1..28f2fd8638d 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -39,6 +39,7 @@ #define SANITY_CHECKS 1 #ifdef EXTRA_DEBUG #define EXTRA_DEBUG_KEY_CHANGES +#define EXTRA_STORE_FULL_PAGE_IN_KEY_CHANGES #endif #define MAX_NONMAPPED_INSERTS 1000 @@ -361,6 +362,7 @@ typedef struct st_maria_share uint in_trans; /* Number of references by trn */ uint w_locks, r_locks, tot_locks; /* Number of read/write locks */ uint block_size; /* block_size of keyfile & data file*/ + uint max_index_block_size; /* block_size - end_of_page_info */ /* Fixed length part of a packed row in BLOCK_RECORD format */ uint base_length; myf write_flag; @@ -833,6 +835,7 @@ typedef struct st_maria_page uchar *buff; /* Data for page */ my_off_t pos; /* Disk address to page */ uint size; /* Size of data on page */ + uint org_size; /* Size of page at read or after log */ uint node; /* 0 or share->base.key_reflength */ uint flag; /* Page flag */ uint link_offset; diff --git a/storage/maria/trnman.c b/storage/maria/trnman.c index 0dbc8ed7fb3..a87b2f0e55b 100644 --- a/storage/maria/trnman.c +++ b/storage/maria/trnman.c @@ -363,6 +363,7 @@ TRN *trnman_new_trn(WT_THD *wt) trn->used_tables= 0; trn->locked_tables= 0; + trn->flags= 0; /* only after the following function TRN is considered initialized, From c507c0280826d638c6bd948b78dd0b8fb0b14942 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 6 Sep 2010 02:31:19 +0300 Subject: [PATCH 107/118] Added missing include file (to get rid of compiler warning) --- storage/xtradb/row/row0mysql.c | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/xtradb/row/row0mysql.c b/storage/xtradb/row/row0mysql.c index 98e2d22c56b..62221fa456d 100644 --- a/storage/xtradb/row/row0mysql.c +++ b/storage/xtradb/row/row0mysql.c @@ -30,6 +30,7 @@ Created 9/17/2000 Heikki Tuuri #include "row0mysql.ic" #endif +#include "ha_prototypes.h" #include "row0ins.h" #include "row0merge.h" #include "row0sel.h" From 7ff256d3c2f19aab03846ad3c6382550b21a835a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Sep 2010 13:42:12 +0200 Subject: [PATCH 108/118] Fix compile failures and warnings on Windows from XtraDB "shm buffer pool" patch. (It is not legal C to do pointer arithmetics on void *). --- storage/xtradb/buf/buf0buddy.c | 6 ++- storage/xtradb/buf/buf0buf.c | 60 +++++++++++++++--------------- storage/xtradb/ha/hash0hash.c | 4 +- storage/xtradb/include/buf0buf.h | 2 +- storage/xtradb/include/hash0hash.h | 8 ++-- storage/xtradb/include/ut0lst.h | 8 ++-- storage/xtradb/os/os0proc.c | 2 + 7 files changed, 47 insertions(+), 43 deletions(-) diff --git a/storage/xtradb/buf/buf0buddy.c b/storage/xtradb/buf/buf0buddy.c index 8ce2d1888ef..e6b80bcda55 100644 --- a/storage/xtradb/buf/buf0buddy.c +++ b/storage/xtradb/buf/buf0buddy.c @@ -452,6 +452,8 @@ buf_buddy_relocate( buf_page_t* bpage; const ulint size = BUF_BUDDY_LOW << i; ullint usec = ut_time_us(NULL); + ulint space; + ulint page_no; //ut_ad(buf_pool_mutex_own()); ut_ad(mutex_own(&zip_free_mutex)); @@ -490,9 +492,9 @@ buf_buddy_relocate( pool), so there is nothing wrong about this. The mach_read_from_4() calls here will only trigger bogus Valgrind memcheck warnings in UNIV_DEBUG_VALGRIND builds. */ - ulint space = mach_read_from_4( + space = mach_read_from_4( (const byte*) src + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); - ulint page_no = mach_read_from_4( + page_no = mach_read_from_4( (const byte*) src + FIL_PAGE_OFFSET); /* Suppress Valgrind warnings about conditional jump on uninitialized value. */ diff --git a/storage/xtradb/buf/buf0buf.c b/storage/xtradb/buf/buf0buf.c index 595addb24a1..abd5f5b15ed 100644 --- a/storage/xtradb/buf/buf0buf.c +++ b/storage/xtradb/buf/buf0buf.c @@ -792,7 +792,7 @@ buf_block_reuse( ptrdiff_t frame_offset) { /* block_init */ - block->frame = ((void*)(block->frame) + frame_offset); + block->frame = ((char*)(block->frame) + frame_offset); UNIV_MEM_DESC(block->frame, UNIV_PAGE_SIZE, block); @@ -809,7 +809,7 @@ buf_block_reuse( #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ if (block->page.zip.data) - block->page.zip.data = ((void*)(block->page.zip.data) + frame_offset); + block->page.zip.data = ((char*)(block->page.zip.data) + frame_offset); block->is_hashed = FALSE; @@ -876,17 +876,17 @@ buf_chunk_init( "InnoDB: You should ensure no change of InnoDB files while using innodb_buffer_pool_shm_key.\n"); /* FIXME: This is vague id still */ - binary_id = (ulint) ((void*)mtr_commit - (void*)btr_root_get) - + (ulint) ((void*)os_get_os_version - (void*)buf_calc_page_new_checksum) - + (ulint) ((void*)page_dir_find_owner_slot - (void*)dfield_data_is_binary_equal) - + (ulint) ((void*)que_graph_publish - (void*)dict_casedn_str) - + (ulint) ((void*)read_view_oldest_copy_or_open_new - (void*)fil_space_get_version) - + (ulint) ((void*)rec_get_n_extern_new - (void*)fsp_get_size_low) - + (ulint) ((void*)row_get_trx_id_offset - (void*)ha_create_func) - + (ulint) ((void*)srv_set_io_thread_op_info - (void*)thd_is_replication_slave_thread) - + (ulint) ((void*)mutex_create_func - (void*)ibuf_inside) - + (ulint) ((void*)trx_set_detailed_error - (void*)lock_check_trx_id_sanity) - + (ulint) ((void*)ut_time - (void*)mem_heap_strdup); + binary_id = (ulint) ((char*)mtr_commit - (char *)btr_root_get) + + (ulint) ((char *)os_get_os_version - (char *)buf_calc_page_new_checksum) + + (ulint) ((char *)page_dir_find_owner_slot - (char *)dfield_data_is_binary_equal) + + (ulint) ((char *)que_graph_publish - (char *)dict_casedn_str) + + (ulint) ((char *)read_view_oldest_copy_or_open_new - (char *)fil_space_get_version) + + (ulint) ((char *)rec_get_n_extern_new - (char *)fsp_get_size_low) + + (ulint) ((char *)row_get_trx_id_offset - (char *)ha_create_func) + + (ulint) ((char *)srv_set_io_thread_op_info - (char *)thd_is_replication_slave_thread) + + (ulint) ((char *)mutex_create_func - (char *)ibuf_inside) + + (ulint) ((char *)trx_set_detailed_error - (char *)lock_check_trx_id_sanity) + + (ulint) ((char *)ut_time - (char *)mem_heap_strdup); chunk->mem = os_shm_alloc(&chunk->mem_size, srv_buffer_pool_shm_key, &is_new); @@ -902,7 +902,7 @@ buf_chunk_init( shm_info = chunk->mem; - zip_hash_tmp = (hash_table_t*)((void*)chunk->mem + chunk->mem_size - zip_hash_mem_size); + zip_hash_tmp = (hash_table_t*)((char *)chunk->mem + chunk->mem_size - zip_hash_mem_size); if (is_new) { strncpy(shm_info->head_str, BUF_SHM_INFO_HEAD, 8); @@ -959,7 +959,7 @@ buf_chunk_init( ut_a(shm_info->zip_hash_n == zip_hash_n); /* check checksum */ - checksum = ut_fold_binary(chunk->mem + sizeof(buf_shm_info_t), + checksum = ut_fold_binary((byte*)chunk->mem + sizeof(buf_shm_info_t), chunk->mem_size - sizeof(buf_shm_info_t)); if (shm_info->checksum != checksum) { fprintf(stderr, @@ -992,7 +992,7 @@ buf_chunk_init( /* Allocate the block descriptors from the start of the memory block. */ if (srv_buffer_pool_shm_key) { - chunk->blocks = chunk->mem + sizeof(buf_shm_info_t); + chunk->blocks = (buf_block_t*)((char*)chunk->mem + sizeof(buf_shm_info_t)); } else { chunk->blocks = chunk->mem; } @@ -1028,7 +1028,7 @@ buf_chunk_init( ptrdiff_t phys_offset; ptrdiff_t logi_offset; ptrdiff_t blocks_offset; - void* previous_frame_address; + byte* previous_frame_address; if (chunk->size < shm_info->chunk_backup.size) { fprintf(stderr, @@ -1039,10 +1039,10 @@ buf_chunk_init( } chunk->size = shm_info->chunk_backup.size; - phys_offset = (void*)frame - (void*)((void*)chunk->mem + shm_info->frame_offset); - logi_offset = (void*)frame - (void*)chunk->blocks[0].frame; + phys_offset = (char*)frame - ((char*)chunk->mem + shm_info->frame_offset); + logi_offset = (char *)frame - (char *)chunk->blocks[0].frame; previous_frame_address = chunk->blocks[0].frame; - blocks_offset = (void*)chunk->blocks - (void*)shm_info->chunk_backup.blocks; + blocks_offset = (char *)chunk->blocks - (char *)shm_info->chunk_backup.blocks; if (phys_offset || logi_offset || blocks_offset) { fprintf(stderr, @@ -1053,8 +1053,8 @@ buf_chunk_init( "InnoDB: Pysical offset : %ld (%#lx)\n" "InnoDB: Logical offset (frames) : %ld (%#lx)\n" "InnoDB: Logical offset (blocks) : %ld (%#lx)\n", - (void*)((void*)chunk->mem + shm_info->frame_offset), - (void*)chunk->blocks[0].frame, (void*)frame, + (char *)chunk->mem + shm_info->frame_offset, + chunk->blocks[0].frame, frame, (ulong) phys_offset, (ulong) phys_offset, (ulong) logi_offset, (ulong) logi_offset, (ulong) blocks_offset, (ulong) blocks_offset); } else { @@ -1066,7 +1066,7 @@ buf_chunk_init( fprintf(stderr, "InnoDB: Aligning physical offset..."); - memmove((void*)frame, (void*)((void*)chunk->mem + shm_info->frame_offset), + memmove(frame, ((char*)chunk->mem + shm_info->frame_offset), chunk->size * UNIV_PAGE_SIZE); fprintf(stderr, @@ -1094,8 +1094,8 @@ buf_chunk_init( previous_frame_address, logi_offset, blocks_offset); if (shm_info->buf_pool_backup.LRU_old) shm_info->buf_pool_backup.LRU_old = - ((void*)(shm_info->buf_pool_backup.LRU_old) - + (((void*)shm_info->buf_pool_backup.LRU_old > previous_frame_address) + (buf_page_t*)((char*)(shm_info->buf_pool_backup.LRU_old) + + (((byte*)shm_info->buf_pool_backup.LRU_old > previous_frame_address) ? logi_offset : blocks_offset)); UT_LIST_OFFSET(unzip_LRU, buf_block_t, shm_info->buf_pool_backup.unzip_LRU, @@ -1141,7 +1141,7 @@ buf_chunk_init( } if (shm_info) { - shm_info->frame_offset = (void*)chunk->blocks[0].frame - (void*)chunk->mem; + shm_info->frame_offset = (char*)chunk->blocks[0].frame - (char*)chunk->mem; } return(chunk); @@ -1396,10 +1396,10 @@ buf_pool_init(void) if (srv_buffer_pool_shm_key) { buf_shm_info_t* shm_info; - ut_a(chunk->blocks == chunk->mem + sizeof(buf_shm_info_t)); + ut_a((char*)chunk->blocks == (char*)chunk->mem + sizeof(buf_shm_info_t)); shm_info = chunk->mem; - buf_pool->zip_hash = (hash_table_t*)((void*)chunk->mem + shm_info->zip_hash_offset); + buf_pool->zip_hash = (hash_table_t*)((char*)chunk->mem + shm_info->zip_hash_offset); if(shm_info->is_new) { shm_info->is_new = FALSE; /* initialization was finished */ @@ -1504,7 +1504,7 @@ buf_pool_free(void) chunk = buf_pool->chunks; shm_info = chunk->mem; - ut_a(chunk->blocks == chunk->mem + sizeof(buf_shm_info_t)); + ut_a((char*)chunk->blocks == (char*)chunk->mem + sizeof(buf_shm_info_t)); /* validation the shared memory segment doesn't have unrecoverable contents. */ /* Currently, validation became not needed */ @@ -1514,7 +1514,7 @@ buf_pool_free(void) memcpy(&(shm_info->chunk_backup), chunk, sizeof(buf_chunk_t)); if (srv_fast_shutdown < 2) { - shm_info->checksum = ut_fold_binary(chunk->mem + sizeof(buf_shm_info_t), + shm_info->checksum = ut_fold_binary((byte*)chunk->mem + sizeof(buf_shm_info_t), chunk->mem_size - sizeof(buf_shm_info_t)); shm_info->clean = TRUE; } diff --git a/storage/xtradb/ha/hash0hash.c b/storage/xtradb/ha/hash0hash.c index bc058cd4729..70516deb005 100644 --- a/storage/xtradb/ha/hash0hash.c +++ b/storage/xtradb/ha/hash0hash.c @@ -161,7 +161,7 @@ hash_create_init( offset = (sizeof(hash_table_t) + 7) / 8; offset *= 8; - table->array = (hash_cell_t*)(((void*)table) + offset); + table->array = (hash_cell_t*)(((char*)table) + offset); table->n_cells = prime; # if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG table->adaptive = FALSE; @@ -187,7 +187,7 @@ hash_create_reuse( offset = (sizeof(hash_table_t) + 7) / 8; offset *= 8; - table->array = (hash_cell_t*)(((void*)table) + offset); + table->array = (hash_cell_t*)(((char*)table) + offset); ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); } diff --git a/storage/xtradb/include/buf0buf.h b/storage/xtradb/include/buf0buf.h index 9484146d8a3..a7854e3038d 100644 --- a/storage/xtradb/include/buf0buf.h +++ b/storage/xtradb/include/buf0buf.h @@ -1305,7 +1305,7 @@ Compute the hash fold value for blocks in buf_pool->zip_hash. */ /* the fold should be relative when srv_buffer_pool_shm_key is enabled */ #define BUF_POOL_ZIP_FOLD_PTR(ptr) (!srv_buffer_pool_shm_key\ ?((ulint) (ptr) / UNIV_PAGE_SIZE)\ - :((ulint) ((void*)ptr - (void*)(buf_pool->chunks->blocks->frame)) / UNIV_PAGE_SIZE)) + :((ulint) ((char*)ptr - (char*)(buf_pool->chunks->blocks->frame)) / UNIV_PAGE_SIZE)) #define BUF_POOL_ZIP_FOLD(b) BUF_POOL_ZIP_FOLD_PTR((b)->frame) #define BUF_POOL_ZIP_FOLD_BPAGE(b) BUF_POOL_ZIP_FOLD((buf_block_t*) (b)) /* @} */ diff --git a/storage/xtradb/include/hash0hash.h b/storage/xtradb/include/hash0hash.h index 9cb410e2ad7..9dc20cc057f 100644 --- a/storage/xtradb/include/hash0hash.h +++ b/storage/xtradb/include/hash0hash.h @@ -363,14 +363,14 @@ do {\ NODE_TYPE* node2222;\ \ if ((TABLE)->array[i2222].node) \ - (TABLE)->array[i2222].node \ - += (((TABLE)->array[i2222].node > (void*)FADDR)?FOFFSET:BOFFSET);\ + (TABLE)->array[i2222].node = (void*)((char*)(TABLE)->array[i2222].node \ + + (((TABLE)->array[i2222].node > (void*)FADDR)?FOFFSET:BOFFSET));\ node2222 = HASH_GET_FIRST((TABLE), i2222);\ \ while (node2222) {\ if (node2222->PTR_NAME) \ - node2222->PTR_NAME = ((void*)node2222->PTR_NAME) \ - + ((((void*)node2222->PTR_NAME) > (void*)FADDR)?FOFFSET:BOFFSET);\ + node2222->PTR_NAME = (void*)((char*)node2222->PTR_NAME \ + + ((((void*)node2222->PTR_NAME) > (void*)FADDR)?FOFFSET:BOFFSET));\ \ node2222 = node2222->PTR_NAME;\ }\ diff --git a/storage/xtradb/include/ut0lst.h b/storage/xtradb/include/ut0lst.h index 69809f22d36..4305f6571b5 100644 --- a/storage/xtradb/include/ut0lst.h +++ b/storage/xtradb/include/ut0lst.h @@ -269,10 +269,10 @@ do { \ TYPE* ut_list_node_313; \ \ if ((BASE).start) \ - (BASE).start = ((void*)((BASE).start) \ + (BASE).start = (void*)((char*)((BASE).start) \ + (((void*)((BASE).start) > (void*)FADDR)?FOFFSET:BOFFSET));\ if ((BASE).end) \ - (BASE).end = ((void*)((BASE).end) \ + (BASE).end = (void*)((char*)((BASE).end) \ + (((void*)((BASE).end) > (void*)FADDR)?FOFFSET:BOFFSET));\ \ ut_list_node_313 = (BASE).start; \ @@ -280,10 +280,10 @@ do { \ for (ut_list_i_313 = (BASE).count; ut_list_i_313--; ) { \ ut_a(ut_list_node_313); \ if ((ut_list_node_313->NAME).prev) \ - (ut_list_node_313->NAME).prev = ((void*)((ut_list_node_313->NAME).prev)\ + (ut_list_node_313->NAME).prev = (void*)((char*)((ut_list_node_313->NAME).prev) \ + (((void*)((ut_list_node_313->NAME).prev) > (void*)FADDR)?FOFFSET:BOFFSET));\ if ((ut_list_node_313->NAME).next) \ - (ut_list_node_313->NAME).next = ((void*)((ut_list_node_313->NAME).next)\ + (ut_list_node_313->NAME).next = (void *)((char*)((ut_list_node_313->NAME).next) \ + (((void*)((ut_list_node_313->NAME).next)> (void*)FADDR)?FOFFSET:BOFFSET));\ ut_list_node_313 = (ut_list_node_313->NAME).next; \ } \ diff --git a/storage/xtradb/os/os0proc.c b/storage/xtradb/os/os0proc.c index 8f6c7f430f7..c101db3d179 100644 --- a/storage/xtradb/os/os0proc.c +++ b/storage/xtradb/os/os0proc.c @@ -243,8 +243,10 @@ os_shm_alloc( ibool* is_new) { void* ptr; +#if defined HAVE_SYS_IPC_H && HAVE_SYS_SHM_H ulint size; int shmid; +#endif *is_new = FALSE; #if defined HAVE_SYS_IPC_H && HAVE_SYS_SHM_H From b4a21b52fd811e83573e09b330da0d5fe8b49ff5 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Tue, 7 Sep 2010 13:57:59 +0300 Subject: [PATCH 109/118] Fixed compiler warnings --- storage/xtradb/buf/buf0buf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/xtradb/buf/buf0buf.c b/storage/xtradb/buf/buf0buf.c index abd5f5b15ed..94a67c1759c 100644 --- a/storage/xtradb/buf/buf0buf.c +++ b/storage/xtradb/buf/buf0buf.c @@ -792,7 +792,7 @@ buf_block_reuse( ptrdiff_t frame_offset) { /* block_init */ - block->frame = ((char*)(block->frame) + frame_offset); + block->frame = ((byte*)(block->frame) + frame_offset); UNIV_MEM_DESC(block->frame, UNIV_PAGE_SIZE, block); @@ -809,7 +809,7 @@ buf_block_reuse( #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ if (block->page.zip.data) - block->page.zip.data = ((char*)(block->page.zip.data) + frame_offset); + block->page.zip.data = ((byte*)(block->page.zip.data) + frame_offset); block->is_hashed = FALSE; From 5288f8c02138051e371b10336d47d6df99d5aac2 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Tue, 7 Sep 2010 13:59:34 +0300 Subject: [PATCH 110/118] Fixed compiler failures when compiling non debug build storage/maria/ha_maria.cc: Don't use 'trn' variable to avoid warning about not used variable storage/maria/ma_delete.c: Added __attribute__((unused)) storage/maria/ma_key_recover.c: Added __attribute__((unused)) Fixed wrong placement of #endif storage/maria/ma_key_recover.h: Fixed typo --- storage/maria/ha_maria.cc | 4 ++-- storage/maria/ma_delete.c | 2 +- storage/maria/ma_key_recover.c | 9 +++++---- storage/maria/ma_key_recover.h | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 846bfc67a63..a611915b7f4 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -2352,9 +2352,9 @@ int ha_maria::reset(void) { if (file->trn) { - TRN *trn= file->trn; /* Next statement is a new statement. Ensure it's logged */ - trnman_set_flags(trn, trnman_get_flags(trn) & ~TRN_STATE_INFO_LOGGED); + trnman_set_flags(file->trn, + trnman_get_flags(file->trn) & ~TRN_STATE_INFO_LOGGED); } return maria_reset(file); } diff --git a/storage/maria/ma_delete.c b/storage/maria/ma_delete.c index 9a5ff4b1d52..2420cac0e93 100644 --- a/storage/maria/ma_delete.c +++ b/storage/maria/ma_delete.c @@ -1445,7 +1445,7 @@ static uint remove_key(MARIA_KEYDEF *keyinfo, uint page_flag, uint nod_flag, my_bool _ma_log_delete(MARIA_PAGE *ma_page, const uchar *key_pos, uint changed_length, uint move_length, - uint append_length, + uint append_length __attribute__((unused)), enum en_key_debug debug_marker __attribute__((unused))) { LSN lsn; diff --git a/storage/maria/ma_key_recover.c b/storage/maria/ma_key_recover.c index 47cfef73ddd..95fc88ca3db 100644 --- a/storage/maria/ma_key_recover.c +++ b/storage/maria/ma_key_recover.c @@ -486,8 +486,8 @@ my_bool _ma_log_suffix(MARIA_PAGE *ma_page, uint org_length, uint new_length) */ my_bool _ma_log_add(MARIA_PAGE *ma_page, - uint org_page_length, uchar *key_pos, - uint changed_length, int move_length, + uint org_page_length __attribute__ ((unused)), + uchar *key_pos, uint changed_length, int move_length, my_bool handle_overflow __attribute__ ((unused))) { LSN lsn; @@ -670,10 +670,11 @@ void _ma_log_key_changes(MARIA_PAGE *ma_page, LEX_CUSTRING *log_array, log_array[1].length= page_length; (*changed_length)+= page_length; (*translog_parts)++; -#endif -#endif +#endif /* EXTRA_STORE_FULL_PAGE_IN_KEY_CHANGES */ } +#endif /* EXTRA_DEBUG_KEY_CHANGES */ + /**************************************************************************** Redo of key pages ****************************************************************************/ diff --git a/storage/maria/ma_key_recover.h b/storage/maria/ma_key_recover.h index 26f5f716c75..3fdb045ee40 100644 --- a/storage/maria/ma_key_recover.h +++ b/storage/maria/ma_key_recover.h @@ -82,7 +82,7 @@ void _ma_log_key_changes(MARIA_PAGE *ma_page, LEX_CUSTRING *log_array, uchar *log_pos, uint *changed_length, uint *translog_parts); #else -void _ma_log_key_changes(A,B,C,D,E) +#define _ma_log_key_changes(A,B,C,D,E) #endif uint _ma_apply_redo_index_new_page(MARIA_HA *info, LSN lsn, From 89e62085c699df26764e90e65def7679fd15d97c Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Tue, 7 Sep 2010 19:58:39 +0300 Subject: [PATCH 111/118] Fixed recovery bug where bitmap pages would not be correctly updated after processing UNDO rows. Fixed test failures in buildbot Don't write errors when failing to send ok packet mysql-test/suite/pbxt/r/range.result: Don't write number of rows as it varies. mysql-test/suite/pbxt/t/range.test: Don't write number of rows as it varies. sql/mysqld.cc: Don't write errors when failing to send ok packet storage/maria/ma_bitmap.c: Added DBUG_ASSERT to detect wrong bitmap pages storage/maria/ma_blockrec.c: Don't reset BLOCKUSED_USE_ORG_BITMAP flag. This fixed a bug where bitmap could be wrong after UNDO of row with blobs --- mysql-test/suite/pbxt/r/range.result | 16 ++++++++-------- mysql-test/suite/pbxt/t/range.test | 5 +++++ sql/mysqld.cc | 5 +++-- storage/maria/ma_bitmap.c | 14 +++++++++++--- storage/maria/ma_blockrec.c | 3 ++- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/mysql-test/suite/pbxt/r/range.result b/mysql-test/suite/pbxt/r/range.result index 2439489581a..a8e97d1c725 100644 --- a/mysql-test/suite/pbxt/r/range.result +++ b/mysql-test/suite/pbxt/r/range.result @@ -422,20 +422,20 @@ test.t1 analyze status OK test.t2 analyze status OK explain select straight_join * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range uid_index uid_index 4 NULL 1 Using where -1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 1 +1 SIMPLE t1 range uid_index uid_index 4 NULL # Using where +1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid # explain select straight_join * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range uid_index uid_index 4 NULL 1 Using where -1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 1 +1 SIMPLE t1 range uid_index uid_index 4 NULL # Using where +1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid # explain select straight_join * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range uid_index uid_index 4 NULL 2 Using where -1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 1 +1 SIMPLE t1 range uid_index uid_index 4 NULL # Using where +1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid # explain select straight_join * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range uid_index uid_index 4 NULL 2 Using where -1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 1 +1 SIMPLE t1 range uid_index uid_index 4 NULL # Using where +1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid # select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; id name uid id name uid 1001 A 1 1001 A 1 diff --git a/mysql-test/suite/pbxt/t/range.test b/mysql-test/suite/pbxt/t/range.test index 2e4e2b7da12..8d02089ee1b 100644 --- a/mysql-test/suite/pbxt/t/range.test +++ b/mysql-test/suite/pbxt/t/range.test @@ -383,9 +383,14 @@ analyze table t1,t2; # This part doesn't make sense for pbxt as the result may vary becasue # records_in_range() gives same results for t1 and t2. # Added straight_join to get predictable results + +--replace_column 9 # explain select straight_join * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; +--replace_column 9 # explain select straight_join * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0; +--replace_column 9 # explain select straight_join * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; +--replace_column 9 # explain select straight_join * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0; select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index c589ededa9c..71d15e873bc 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3070,10 +3070,11 @@ int my_message_sql(uint error, const char *str, myf MyFlags) } else { - if (thd->main_da.is_ok()) + if (thd->main_da.is_ok() && !thd->main_da.can_overwrite_status) { /* - Client has already got ok packet; Write message to error log. + Client has already got ok packet and we are not in net_flush(), so + we write a message to error log. This could happen if we get an error in implicit commit. This should never happen in normal operation, so lets assert here in debug builds. diff --git a/storage/maria/ma_bitmap.c b/storage/maria/ma_bitmap.c index a76b36e1115..ff23c408931 100644 --- a/storage/maria/ma_bitmap.c +++ b/storage/maria/ma_bitmap.c @@ -1875,6 +1875,7 @@ static my_bool set_page_bits(MARIA_HA *info, MARIA_FILE_BITMAP *bitmap, uint offset_page, offset, tmp, org_tmp; uchar *data; DBUG_ENTER("set_page_bits"); + DBUG_ASSERT(fill_pattern <= 7); bitmap_page= page - page % bitmap->pages_covered; if (bitmap_page != bitmap->page && @@ -2296,9 +2297,16 @@ my_bool _ma_bitmap_release_unused(MARIA_HA *info, MARIA_BITMAP_BLOCKS *blocks) The page has all bits set; The following test is an optimization to not set the bits to the same value as before. */ - if (bits != current_bitmap_value && - set_page_bits(info, bitmap, block->page, bits)) - goto err; + if (bits != current_bitmap_value) + { + if (set_page_bits(info, bitmap, block->page, bits)) + goto err; + } + else + { + DBUG_ASSERT(current_bitmap_value == + _ma_bitmap_get_page_bits(info, bitmap, block->page)); + } } else if (!(block->used & BLOCKUSED_USED) && _ma_bitmap_reset_full_page_bits(info, bitmap, diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index 0779564c8af..f582bfb3b97 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -1990,7 +1990,8 @@ static my_bool write_tail(MARIA_HA *info, block->empty_space= (enough_free_entries(row_pos.buff, share->block_size, 1 + share->base.blobs) ? empty_space : 0); - block->used= BLOCKUSED_USED | BLOCKUSED_TAIL; + /* Keep BLOCKUSED_USE_ORG_BITMAP */ + block->used|= BLOCKUSED_USED | BLOCKUSED_TAIL; /* Increase data file size, if extended */ position= (my_off_t) block->page * block_size; From 7027c7facc49cc9b2d50f37e06515134498f8c5e Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Tue, 7 Sep 2010 23:46:10 +0300 Subject: [PATCH 112/118] Added --skip-bdb as a compatibility option for old config files mysql-test/mysql-test-run.pl: Added suppression mysql-test/t/upgrade.test: Added missing path --- mysql-test/mysql-test-run.pl | 1 + mysql-test/t/upgrade.test | 6 +++--- sql/mysqld.cc | 8 ++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 62253b550f3..51ef20c3cfd 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -4228,6 +4228,7 @@ sub extract_warning_lines ($) { qr/slave SQL thread aborted/, qr/unknown option '--loose[-_]/, qr/unknown variable 'loose[-_]/, + or/Invalid .*old.* table or database name/, qr/Now setting lower_case_table_names to [02]/, qr/Setting lower_case_table_names=2/, qr/You have forced lower_case_table_names to 0/, diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test index fad69902605..8e6eed60242 100644 --- a/mysql-test/t/upgrade.test +++ b/mysql-test/t/upgrade.test @@ -172,9 +172,9 @@ USE `#mysql50#../blablabla`; # # Test of Bug #56441: mysql_upgrade 5.0->5.1 fails for tables with long names # -copy_file std_data/long_table_name.MYI $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYI; -copy_file std_data/long_table_name.MYD $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD; -copy_file std_data/long_table_name.frm $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.frm; +copy_file $MYSQL_TEST_DIR/std_data/long_table_name.MYI $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYI; +copy_file $MYSQL_TEST_DIR/std_data/long_table_name.MYD $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.MYD; +copy_file $MYSQL_TEST_DIR/std_data/long_table_name.frm $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com.frm; show full tables; rename table `#mysql50#ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com` to `ltoriaeinnovacionendesarrolloempres?9120761097220077376?cio_com`; show full tables; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8bec9dc474a..7bbc4b4bbb9 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5958,6 +5958,7 @@ enum options_mysqld #if defined(ENABLED_DEBUG_SYNC) OPT_DEBUG_SYNC_TIMEOUT, #endif /* defined(ENABLED_DEBUG_SYNC) */ + OPT_DEPRECATED_OPTION, OPT_SLAVE_EXEC_MODE, OPT_DEADLOCK_SEARCH_DEPTH_SHORT, OPT_DEADLOCK_SEARCH_DEPTH_LONG, @@ -6737,6 +6738,9 @@ thread is in the relay logs.", "Show user and password in SHOW SLAVE HOSTS on this master.", &opt_show_slave_auth_info, &opt_show_slave_auth_info, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"skip-bdb", OPT_DEPRECATED_OPTION, + "Deprecated option; Exist only for compatiblity with old my.cnf files", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DISABLE_GRANT_OPTIONS {"skip-grant-tables", OPT_SKIP_GRANT, "Start without grant tables. This gives all users FULL ACCESS to all tables.", @@ -8409,6 +8413,10 @@ mysqld_get_one_option(int optid, case '0': WARN_DEPRECATED(NULL, VER_CELOSIA, "--log-long-format", "--log-short-format"); break; + case OPT_DEPRECATED_OPTION: + sql_print_warning("'%s' is deprecated and exists only for compatiblity with old my.cnf files; Please remove this option from all your my.cnf files!", + opt->name); + break; case 'a': global_system_variables.sql_mode= fix_sql_mode(MODE_ANSI); global_system_variables.tx_isolation= ISO_SERIALIZABLE; From 01b100b5dd3040daa18791abb88a9ffef06efe67 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 8 Sep 2010 02:00:12 +0300 Subject: [PATCH 113/118] Give a more precise warning why something fails. Fixed typo that caused warnings from mysql-test-run mysql-test/mysql-test-run.pl: Fixed typo sql/mysqld.cc: Give a more precise warning why something fails. --- mysql-test/mysql-test-run.pl | 2 +- sql/mysqld.cc | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 51ef20c3cfd..eb1fad0bbb2 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -4228,7 +4228,7 @@ sub extract_warning_lines ($) { qr/slave SQL thread aborted/, qr/unknown option '--loose[-_]/, qr/unknown variable 'loose[-_]/, - or/Invalid .*old.* table or database name/, + qr/Invalid .*old.* table or database name/, qr/Now setting lower_case_table_names to [02]/, qr/Setting lower_case_table_names=2/, qr/You have forced lower_case_table_names to 0/, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a03e5941558..1218ee666e1 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -8786,8 +8786,7 @@ mysqld_get_one_option(int optid, if (!slave_warning_issued) //only show the warning once { slave_warning_issued = true; - WARN_DEPRECATED(NULL, "6.0", "for replication startup options", - "'CHANGE MASTER'"); + WARN_DEPRECATED(NULL, "6.0", opt->name, "'CHANGE MASTER'"); } break; case OPT_CONSOLE: From 1a0315f1e7d7d7468be3187025c639b024fa88e3 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Thu, 9 Sep 2010 02:01:05 +0300 Subject: [PATCH 114/118] Write message to stderr if recovery is not likely to succeed because we don't log records for batch inserts. Don't do UNDO or REDO on a crashed table. More DBUG_PRINT sql/sql_parse.cc: Remove display of 'packet' which is not useful storage/maria/ma_blockrec.c: More DBUG_PRINT() storage/maria/ma_key_recover.c: Write page number instead of page position storage/maria/ma_recovery.c: Write message to stderr if recovery is not likely to succeed because we don't log records for batch inserts. In normal cases this should never be an issue as we would recreate an empty table if MariaDB dies under batch insert. This warning will be given if you remove all tables and try to recreate them with maria_read_log, which can't be done as the log doesn't contain all data. Don't do UNDO or REDO on a crashed table. storage/maria/ma_write.c: Write page number instead of page position. --- sql/sql_parse.cc | 2 +- storage/maria/ma_blockrec.c | 11 +++++- storage/maria/ma_key_recover.c | 3 +- storage/maria/ma_recovery.c | 65 ++++++++++++++++++++++------------ storage/maria/ma_write.c | 2 +- 5 files changed, 57 insertions(+), 26 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index fddd8626a19..6cb30c6c445 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -997,7 +997,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, NET *net= &thd->net; bool error= 0; DBUG_ENTER("dispatch_command"); - DBUG_PRINT("info",("packet: '%*.s'; command: %d", packet_length, packet, command)); + DBUG_PRINT("info", ("command: %d", command)); thd->command=command; /* diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index f582bfb3b97..e3cb8d14eeb 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -1716,7 +1716,7 @@ static my_bool get_head_or_tail_page(MARIA_HA *info, MARIA_PINNED_PAGE page_link; MARIA_SHARE *share= info->s; DBUG_ENTER("get_head_or_tail_page"); - DBUG_PRINT("enter", ("length: %u", length)); + DBUG_PRINT("enter", ("page_type: %u length: %u", page_type, length)); block_size= share->block_size; if (block->org_bitmap_value == 0) /* Empty block */ @@ -6238,7 +6238,10 @@ uint _ma_apply_redo_insert_row_head_or_tail(MARIA_HA *info, LSN lsn, /* Skip errors when reading outside of file and uninitialized pages */ if (!new_page || (my_errno != HA_ERR_FILE_TOO_SHORT && my_errno != HA_ERR_WRONG_CRC)) + { + DBUG_PRINT("error", ("Error %d when reading page", (int) my_errno)); goto err; + } /* Create new page */ buff= pagecache_block_link_to_buffer(page_link.link); buff[PAGE_TYPE_OFFSET]= UNALLOCATED_PAGE; @@ -6266,7 +6269,13 @@ uint _ma_apply_redo_insert_row_head_or_tail(MARIA_HA *info, LSN lsn, changed to new type. */ if (!new_page) + { + DBUG_PRINT("error", + ("Found page of wrong type: %u, should have been %u", + (uint) (buff[PAGE_TYPE_OFFSET] & PAGE_TYPE_MASK), + page_type)); goto crashed_file; + } make_empty_page(info, buff, page_type, 0); empty_space= block_size - PAGE_HEADER_SIZE - PAGE_SUFFIX_SIZE; (void) extend_directory(page_type == HEAD_PAGE ? info: 0, buff, diff --git a/storage/maria/ma_key_recover.c b/storage/maria/ma_key_recover.c index 95fc88ca3db..1a61731e817 100644 --- a/storage/maria/ma_key_recover.c +++ b/storage/maria/ma_key_recover.c @@ -504,7 +504,8 @@ my_bool _ma_log_add(MARIA_PAGE *ma_page, DBUG_ENTER("_ma_log_add"); DBUG_PRINT("enter", ("page: %lu org_page_length: %u changed_length: %u " "move_length: %d", - (ulong) ma_page->pos, org_page_length, changed_length, + (ulong) (ma_page->pos / info->s->block_size), + org_page_length, changed_length, move_length)); DBUG_ASSERT(info->s->now_transactional); DBUG_ASSERT(move_length <= (int) changed_length); diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index c0205b5ed00..f2d86d1eb1d 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -638,6 +638,16 @@ prototype_redo_exec_hook(INCOMPLETE_LOG) /* no such table, don't need to warn */ return 0; } + if (info->s->state.is_of_horizon > rec->lsn) + { + /* + This table was repaired at a time after this log entry. + We can assume that all rows was inserted sucessfully and we don't + have to warn about that the inserted data was not logged + */ + return 0; + } + /* Example of what can go wrong when replaying DDLs: CREATE TABLE t (logged); INSERT INTO t VALUES(1) (logged); @@ -658,10 +668,15 @@ prototype_redo_exec_hook(INCOMPLETE_LOG) there was a crash during a DDL (see comment in execution of REDO_RENAME_TABLE ). */ - tprint(tracef, "***WARNING: MySQL server currently logs no records" - " about insertion of data by ALTER TABLE and CREATE SELECT," - " as they are not necessary for recovery;" - " present applying of log records may well not work.***\n"); + + eprint(tracef, "***WARNING: Aria engine currently logs no records " + "about insertion of data by ALTER TABLE and CREATE SELECT, " + "as they are not necessary for recovery; " + "present applying of log records to table '%s' may well not work." + "***\n", info->s->index_file_name.str); + + /* Prevent using the table for anything else than undo repair */ + _ma_mark_file_crashed(info->s); recovery_warnings++; return 0; } @@ -1052,7 +1067,11 @@ prototype_redo_exec_hook(REDO_REPAIR_TABLE) } if ((info= get_MARIA_HA_from_REDO_record(rec)) == NULL) DBUG_RETURN(0); - + if (maria_is_crashed(info)) + { + tprint(tracef, "we skip repairing crashed table\n"); + DBUG_RETURN(0); + } /* Otherwise, the mapping is newer than the table, and our record is newer than the mapping, so we can repair. @@ -1367,7 +1386,8 @@ prototype_redo_exec_hook(REDO_INSERT_ROW_HEAD) int error= 1; uchar *buff= NULL; MARIA_HA *info= get_MARIA_HA_from_REDO_record(rec); - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) + { /* Table was skipped at open time (because later dropped/renamed, not @@ -1433,7 +1453,7 @@ prototype_redo_exec_hook(REDO_INSERT_ROW_TAIL) int error= 1; uchar *buff; MARIA_HA *info= get_MARIA_HA_from_REDO_record(rec); - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) return 0; enlarge_buffer(rec); if (log_record_buffer.str == NULL || @@ -1474,7 +1494,7 @@ prototype_redo_exec_hook(REDO_INSERT_ROW_BLOBS) pgcache_page_no_t first_page, last_page; char llbuf1[22], llbuf2[22]; MARIA_HA *info= get_MARIA_HA_from_REDO_record(rec); - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) return 0; enlarge_buffer(rec); if (log_record_buffer.str == NULL || @@ -1508,7 +1528,7 @@ prototype_redo_exec_hook(REDO_PURGE_ROW_HEAD) { int error= 1; MARIA_HA *info= get_MARIA_HA_from_REDO_record(rec); - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) return 0; if (_ma_apply_redo_purge_row_head_or_tail(info, current_group_end_lsn, HEAD_PAGE, @@ -1524,7 +1544,7 @@ prototype_redo_exec_hook(REDO_PURGE_ROW_TAIL) { int error= 1; MARIA_HA *info= get_MARIA_HA_from_REDO_record(rec); - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) return 0; if (_ma_apply_redo_purge_row_head_or_tail(info, current_group_end_lsn, TAIL_PAGE, @@ -1541,7 +1561,7 @@ prototype_redo_exec_hook(REDO_FREE_BLOCKS) int error= 1; uchar *buff; MARIA_HA *info= get_MARIA_HA_from_REDO_record(rec); - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) return 0; enlarge_buffer(rec); @@ -1568,7 +1588,7 @@ prototype_redo_exec_hook(REDO_FREE_HEAD_OR_TAIL) { int error= 1; MARIA_HA *info= get_MARIA_HA_from_REDO_record(rec); - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) return 0; if (_ma_apply_redo_free_head_or_tail(info, current_group_end_lsn, @@ -1600,7 +1620,7 @@ prototype_redo_exec_hook(REDO_INDEX) { int error= 1; MARIA_HA *info= get_MARIA_HA_from_REDO_record(rec); - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) return 0; enlarge_buffer(rec); @@ -1626,7 +1646,7 @@ prototype_redo_exec_hook(REDO_INDEX_NEW_PAGE) { int error= 1; MARIA_HA *info= get_MARIA_HA_from_REDO_record(rec); - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) return 0; enlarge_buffer(rec); @@ -1653,7 +1673,7 @@ prototype_redo_exec_hook(REDO_INDEX_FREE_PAGE) { int error= 1; MARIA_HA *info= get_MARIA_HA_from_REDO_record(rec); - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) return 0; if (_ma_apply_redo_index_free_page(info, current_group_end_lsn, @@ -1669,7 +1689,7 @@ prototype_redo_exec_hook(REDO_BITMAP_NEW_PAGE) { int error= 1; MARIA_HA *info= get_MARIA_HA_from_REDO_record(rec); - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) return 0; enlarge_buffer(rec); @@ -2115,7 +2135,7 @@ prototype_undo_exec_hook(UNDO_ROW_INSERT) MARIA_SHARE *share; const uchar *record_ptr; - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) { /* Unlike for REDOs, if the table was skipped it is abnormal; we have a @@ -2171,7 +2191,7 @@ prototype_undo_exec_hook(UNDO_ROW_DELETE) LSN previous_undo_lsn= lsn_korr(rec->header); MARIA_SHARE *share; - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) { skip_undo_record(previous_undo_lsn, trn); return 0; @@ -2210,7 +2230,7 @@ prototype_undo_exec_hook(UNDO_ROW_UPDATE) LSN previous_undo_lsn= lsn_korr(rec->header); MARIA_SHARE *share; - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) { skip_undo_record(previous_undo_lsn, trn); return 0; @@ -2249,7 +2269,7 @@ prototype_undo_exec_hook(UNDO_KEY_INSERT) LSN previous_undo_lsn= lsn_korr(rec->header); MARIA_SHARE *share; - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) { skip_undo_record(previous_undo_lsn, trn); return 0; @@ -2290,7 +2310,7 @@ prototype_undo_exec_hook(UNDO_KEY_DELETE) LSN previous_undo_lsn= lsn_korr(rec->header); MARIA_SHARE *share; - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) { skip_undo_record(previous_undo_lsn, trn); return 0; @@ -2331,7 +2351,7 @@ prototype_undo_exec_hook(UNDO_KEY_DELETE_WITH_ROOT) LSN previous_undo_lsn= lsn_korr(rec->header); MARIA_SHARE *share; - if (info == NULL) + if (info == NULL || maria_is_crashed(info)) { skip_undo_record(previous_undo_lsn, trn); return 0; @@ -2372,6 +2392,7 @@ prototype_undo_exec_hook(UNDO_BULK_INSERT) LSN previous_undo_lsn= lsn_korr(rec->header); MARIA_SHARE *share; + /* Here we don't check for crashed as we can undo the bulk insert */ if (info == NULL) { skip_undo_record(previous_undo_lsn, trn); diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c index 958a07e1c70..c6718299d17 100644 --- a/storage/maria/ma_write.c +++ b/storage/maria/ma_write.c @@ -613,7 +613,7 @@ static int w_search(register MARIA_HA *info, uint32 comp_flag, MARIA_KEY *key, MARIA_KEYDEF *keyinfo= key->keyinfo; MARIA_PAGE page; DBUG_ENTER("w_search"); - DBUG_PRINT("enter",("page: %ld", (long) page_pos)); + DBUG_PRINT("enter", ("page: %lu", (ulong) (page_pos/keyinfo->block_length))); if (!(temp_buff= (uchar*) my_alloca((uint) keyinfo->block_length+ MARIA_MAX_KEY_BUFF*2))) From 6f59c41d2dfad95ecdb161d6b08ec4cce736f7a8 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Thu, 9 Sep 2010 18:12:06 +0300 Subject: [PATCH 115/118] Updated failure text for maria_install_db Don't give warning about block_insert if table is crashed. scripts/mysql_install_db.sh: Added link to KB. storage/maria/ma_recovery.c: Don't give warning about block_insert if table is crashed. --- scripts/mysql_install_db.sh | 12 ++++-------- storage/maria/ma_recovery.c | 6 +++++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 8bae2ec9db1..2d3775afb3a 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -408,20 +408,16 @@ else echo " shell> $bindir/mysql -u root mysql" echo " mysql> show tables" echo - echo "Try 'mysqld --help' if you have problems with paths. Using --log" - echo "gives you a log in $ldata that may be helpful." + echo "Try 'mysqld --help' if you have problems with paths. Using" + echo "--general-log gives you a log in $ldata that may be helpful." echo - echo "The latest information about MariaDB is available on the web at" - echo "http://askmonty.org/wiki/index.php/MariaDB". - echo "If you have a problem, you can consult the MySQL manual section" - echo "'Problems running mysql_install_db', and the manual section that" - echo "describes problems on your OS at http://dev.mysql.com/doc/" + echo "The latest information about mysql_install_db is available at" + echo "http://kb.askmonty.org/v/installing-system-tables-mysql_install_db." echo "MariaDB is hosted on launchpad; You can find the latest source and" echo "email lists at http://launchpad.net/maria" echo echo "Please check all of the above before mailing us! And remember, if" echo "you do mail us, you should use the $scriptdir/mysqlbug script!" - echo exit 1 fi diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index f2d86d1eb1d..7442bbef1a0 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -638,6 +638,10 @@ prototype_redo_exec_hook(INCOMPLETE_LOG) /* no such table, don't need to warn */ return 0; } + + if (maria_is_crashed(info)) + return 0; + if (info->s->state.is_of_horizon > rec->lsn) { /* @@ -673,7 +677,7 @@ prototype_redo_exec_hook(INCOMPLETE_LOG) "about insertion of data by ALTER TABLE and CREATE SELECT, " "as they are not necessary for recovery; " "present applying of log records to table '%s' may well not work." - "***\n", info->s->index_file_name.str); + "***", info->s->index_file_name.str); /* Prevent using the table for anything else than undo repair */ _ma_mark_file_crashed(info->s); From b7158601d35456fde4167fe44dcf505495b045af Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 10 Sep 2010 02:42:12 +0300 Subject: [PATCH 116/118] Fixed bug LP#605798 "wrong data in bitmap" after recovery. Extend remove_function_from_trace.pl to work with many threads (patch from Sergei) dbug/remove_function_from_trace.pl: Extend remove_function_from_trace.pl to work with many threads (patch from Sergei) storage/maria/ma_bitmap.c: Added marker that table had changed since last checkpoint. This ensures that we will flush all bitmap pages from cache at checkpoint. This fixes bug LP#605798 "wrong data in bitmap" after recovery. storage/maria/ma_check.c: Cleaned up error output storage/maria/ma_recovery.c: Cleaned up error output storage/maria/maria_def.h: Added changed_not_flushed --- dbug/remove_function_from_trace.pl | 11 +++++------ storage/maria/ma_bitmap.c | 9 ++++++++- storage/maria/ma_check.c | 2 +- storage/maria/ma_recovery.c | 6 ++++++ storage/maria/maria_def.h | 3 ++- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/dbug/remove_function_from_trace.pl b/dbug/remove_function_from_trace.pl index 1da9e25f9ba..380df168caf 100755 --- a/dbug/remove_function_from_trace.pl +++ b/dbug/remove_function_from_trace.pl @@ -1,6 +1,5 @@ #!/usr/bin/perl - die <) { - print unless $skip; + ($thd) = /^(T@\d+)/; + print unless $skip{$thd}; next unless /^(?:.*: )*((?:\| )*)([<>])($re)\n/o; if ($2 eq '>') { - $skip=$1.$3 unless $skip; + $skip{$thd}=$1.$3 unless $skip{$thd}; next; } - next if $skip ne $1.$3; - $skip=''; + next if $skip{$thd} ne $1.$3; + delete $skip{$thd}; print; } diff --git a/storage/maria/ma_bitmap.c b/storage/maria/ma_bitmap.c index ff23c408931..4f37d7b9a1f 100644 --- a/storage/maria/ma_bitmap.c +++ b/storage/maria/ma_bitmap.c @@ -147,6 +147,12 @@ static inline my_bool write_changed_bitmap(MARIA_SHARE *share, DBUG_ASSERT(bitmap->file.write_callback != 0); DBUG_PRINT("info", ("bitmap->non_flushable: %u", bitmap->non_flushable)); + /* + Mark that a bitmap page has been written to page cache and we have + to flush it during checkpoint. + */ + bitmap->changed_not_flushed= 1; + if ((bitmap->non_flushable == 0) #ifdef WRONG_BITMAP_FLUSH || 1 @@ -347,7 +353,7 @@ my_bool _ma_bitmap_flush_all(MARIA_SHARE *share) MARIA_FILE_BITMAP *bitmap= &share->bitmap; DBUG_ENTER("_ma_bitmap_flush_all"); pthread_mutex_lock(&bitmap->bitmap_lock); - if (bitmap->changed) + if (bitmap->changed || bitmap->changed_not_flushed) { bitmap->flush_all_requested= TRUE; #ifndef WRONG_BITMAP_FLUSH @@ -384,6 +390,7 @@ my_bool _ma_bitmap_flush_all(MARIA_SHARE *share) &bitmap->pages_covered) & PCFLUSH_PINNED_AND_ERROR) res= TRUE; + bitmap->changed_not_flushed= FALSE; bitmap->flush_all_requested= FALSE; /* Some well-behaved threads may be waiting for flush_all_requested to diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index fa1933913d4..ed3a7a46344 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -1760,7 +1760,7 @@ static my_bool check_head_page(HA_CHECK *param, MARIA_HA *info, uchar *record, _ma_check_print_error(param, "Page %9s: Row: %3d has an extent with " "wrong information in bitmap: " - "Page %9s Page_type: %d Bitmap: %d", + "Page: %9s Page_type: %d Bitmap: %d", llstr(page, llbuff), row, llstr(extent_page, llbuff2), page_type, bitmap_pattern); diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index 7442bbef1a0..b4fe96ae168 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -332,6 +332,8 @@ int maria_apply_log(LSN from_lsn, LSN end_lsn, if (end_lsn != LSN_IMPOSSIBLE) { abort_message_printed= 1; + if (!trace_file) + fputc('\n', stderr); my_message(HA_ERR_INITIALIZATION, "Maria recovery aborted as end_lsn/end of file was reached", MYF(0)); @@ -502,9 +504,13 @@ end: } if (error && !abort_message_printed) + { + if (!trace_file) + fputc('\n', stderr); my_message(HA_ERR_INITIALIZATION, "Maria recovery failed. Please run maria_chk -r on all maria " "tables and delete all maria_log.######## files", MYF(0)); + } procent_printed= 0; /* We don't cleanly close tables if we hit some error (may corrupt them by diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index 28f2fd8638d..6be34aae98c 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -244,7 +244,8 @@ typedef struct st_maria_file_bitmap uchar *map; pgcache_page_no_t page; /* Page number for current bitmap */ uint used_size; /* Size of bitmap head that is not 0 */ - my_bool changed; /* 1 if page needs to be flushed */ + my_bool changed; /* 1 if page needs to be written */ + my_bool changed_not_flushed; /* 1 if some bitmap is not flushed */ my_bool flush_all_requested; /**< If _ma_bitmap_flush_all waiting */ uint non_flushable; /**< 0 if bitmap and log are in sync */ PAGECACHE_FILE file; /* datafile where bitmap is stored */ From 44fec70b7968778808673d9668c5fe08da03a7ca Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 9 Sep 2010 15:35:47 +0200 Subject: [PATCH 117/118] build dynamic plugins with the -shared libtool option to avoid double compilation --- plugin/daemon_example/Makefile.am | 5 +---- plugin/fulltext/Makefile.am | 2 +- storage/archive/Makefile.am | 4 ++-- storage/blackhole/Makefile.am | 4 +--- storage/csv/Makefile.am | 2 +- storage/example/Makefile.am | 5 +---- storage/federated/Makefile.am | 5 ++--- storage/federatedx/Makefile.am | 7 +++---- storage/innobase/Makefile.am | 4 ++-- storage/innodb_plugin/Makefile.am | 4 ++-- storage/pbxt/src/Makefile.am | 4 ++-- storage/xtradb/Makefile.am | 4 ++-- 12 files changed, 20 insertions(+), 30 deletions(-) diff --git a/plugin/daemon_example/Makefile.am b/plugin/daemon_example/Makefile.am index 02310699396..a64aa169606 100644 --- a/plugin/daemon_example/Makefile.am +++ b/plugin/daemon_example/Makefile.am @@ -27,15 +27,12 @@ INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \ EXTRA_LTLIBRARIES = libdaemon_example.la pkgplugin_LTLIBRARIES = @plugin_daemon_example_shared_target@ libdaemon_example_la_LDFLAGS = -module -rpath $(pkgplugindir) -libdaemon_example_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN -libdaemon_example_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +libdaemon_example_la_CXXFLAGS= -shared $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN libdaemon_example_la_SOURCES = daemon_example.cc - EXTRA_LIBRARIES = libdaemon_example.a noinst_LIBRARIES = @plugin_daemon_example_static_target@ libdaemon_example_a_CXXFLAGS = $(AM_CXXFLAGS) -libdaemon_example_a_CFLAGS = $(AM_CFLAGS) libdaemon_example_a_SOURCES= daemon_example.cc # Don't update the files from bitkeeper diff --git a/plugin/fulltext/Makefile.am b/plugin/fulltext/Makefile.am index 343416072dd..45565e9fdb2 100644 --- a/plugin/fulltext/Makefile.am +++ b/plugin/fulltext/Makefile.am @@ -21,7 +21,7 @@ INCLUDES= -I$(top_builddir)/include -I$(top_srcdir)/include pkgplugin_LTLIBRARIES= mypluglib.la mypluglib_la_SOURCES= plugin_example.c mypluglib_la_LDFLAGS= -module -rpath $(pkgplugindir) -mypluglib_la_CFLAGS= -DMYSQL_DYNAMIC_PLUGIN +mypluglib_la_CFLAGS= -shared -DMYSQL_DYNAMIC_PLUGIN # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/storage/archive/Makefile.am b/storage/archive/Makefile.am index 94e98c468ad..254c95bf68b 100644 --- a/storage/archive/Makefile.am +++ b/storage/archive/Makefile.am @@ -36,8 +36,8 @@ noinst_PROGRAMS = archive_test archive_reader EXTRA_LTLIBRARIES = ha_archive.la pkgplugin_LTLIBRARIES = @plugin_archive_shared_target@ ha_archive_la_LDFLAGS = -module -rpath $(pkgplugindir) -ha_archive_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN -ha_archive_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_archive_la_CXXFLAGS= -shared $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_archive_la_CFLAGS = -shared $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_archive_la_SOURCES = ha_archive.cc azio.c diff --git a/storage/blackhole/Makefile.am b/storage/blackhole/Makefile.am index 2d27261b671..148746a9336 100644 --- a/storage/blackhole/Makefile.am +++ b/storage/blackhole/Makefile.am @@ -35,15 +35,13 @@ noinst_HEADERS = ha_blackhole.h EXTRA_LTLIBRARIES = ha_blackhole.la pkgplugin_LTLIBRARIES = @plugin_blackhole_shared_target@ ha_blackhole_la_LDFLAGS=-module -rpath $(pkgplugindir) -ha_blackhole_la_CXXFLAGS=$(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN -ha_blackhole_la_CFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_blackhole_la_CXXFLAGS=-shared $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_blackhole_la_SOURCES=ha_blackhole.cc EXTRA_LIBRARIES = libblackhole.a noinst_LIBRARIES = @plugin_blackhole_static_target@ libblackhole_a_CXXFLAGS=$(AM_CXXFLAGS) -libblackhole_a_CFLAGS = $(AM_CFLAGS) libblackhole_a_SOURCES= ha_blackhole.cc diff --git a/storage/csv/Makefile.am b/storage/csv/Makefile.am index 3a00ae85e20..75ad9062984 100644 --- a/storage/csv/Makefile.am +++ b/storage/csv/Makefile.am @@ -32,7 +32,7 @@ noinst_HEADERS = ha_tina.h transparent_file.h EXTRA_LTLIBRARIES = ha_csv.la pkglib_LTLIBRARIES = @plugin_csv_shared_target@ ha_csv_la_LDFLAGS = -module -rpath $(MYSQLLIBdir) -ha_csv_la_CXXFLAGS = $(AM_CXXFLAGS) -DMYSQL_PLUGIN +ha_csv_la_CXXFLAGS = -shared $(AM_CXXFLAGS) -DMYSQL_PLUGIN ha_csv_la_SOURCES = transparent_file.cc ha_tina.cc EXTRA_LIBRARIES = libcsv.a diff --git a/storage/example/Makefile.am b/storage/example/Makefile.am index 1c87adbbb4c..158b58a2e4c 100644 --- a/storage/example/Makefile.am +++ b/storage/example/Makefile.am @@ -35,15 +35,12 @@ noinst_HEADERS = ha_example.h EXTRA_LTLIBRARIES = ha_example.la pkgplugin_LTLIBRARIES = @plugin_example_shared_target@ ha_example_la_LDFLAGS = -module -rpath $(pkgplugindir) -ha_example_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN -ha_example_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_example_la_CXXFLAGS= -shared $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_example_la_SOURCES = ha_example.cc - EXTRA_LIBRARIES = libexample.a noinst_LIBRARIES = @plugin_example_static_target@ libexample_a_CXXFLAGS = $(AM_CXXFLAGS) -libexample_a_CFLAGS = $(AM_CFLAGS) libexample_a_SOURCES= ha_example.cc diff --git a/storage/federated/Makefile.am b/storage/federated/Makefile.am index 8419e0b866e..414fb5b7d5f 100644 --- a/storage/federated/Makefile.am +++ b/storage/federated/Makefile.am @@ -33,15 +33,14 @@ noinst_HEADERS = ha_federated.h EXTRA_LTLIBRARIES = ha_federated.la pkgplugin_LTLIBRARIES = @plugin_federated_shared_target@ ha_federated_la_LDFLAGS = -module -rpath $(pkgplugindir) -ha_federated_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN -ha_federated_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_federated_la_CXXFLAGS= -shared $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_federated_la_CFLAGS = -shared $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN ha_federated_la_SOURCES = ha_federated.cc $(top_srcdir)/mysys/string.c EXTRA_LIBRARIES = libfederated.a noinst_LIBRARIES = @plugin_federated_static_target@ libfederated_a_CXXFLAGS = $(AM_CXXFLAGS) -libfederated_a_CFLAGS = $(AM_CFLAGS) libfederated_a_SOURCES= ha_federated.cc diff --git a/storage/federatedx/Makefile.am b/storage/federatedx/Makefile.am index 1781a53a0b6..1e76ac15266 100644 --- a/storage/federatedx/Makefile.am +++ b/storage/federatedx/Makefile.am @@ -20,14 +20,13 @@ noinst_HEADERS = ha_federatedx.h federatedx_probes.h EXTRA_LTLIBRARIES = ha_federatedx.la pkgplugin_LTLIBRARIES = @plugin_federatedx_shared_target@ ha_federatedx_la_LDFLAGS = -module -rpath $(pkgplugindir) -ha_federatedx_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN -ha_federatedx_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_federatedx_la_CXXFLAGS= -shared $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_federatedx_la_CFLAGS = -shared $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN EXTRA_LIBRARIES = libfederatedx.a noinst_LIBRARIES = @plugin_federatedx_static_target@ -libfederatedx_a_CXXFLAGS = $(AM_CFLAGS) -libfederatedx_a_CFLAGS = $(AM_CFLAGS) +libfederatedx_a_CXXFLAGS = $(AM_CXXFLAGS) libfederatedx_a_SOURCES= ha_federatedx.cc federatedx_txn.cc \ federatedx_io.cc federatedx_io_null.cc \ federatedx_io_mysql.cc diff --git a/storage/innobase/Makefile.am b/storage/innobase/Makefile.am index 2c93a3a409a..29ba83c0668 100644 --- a/storage/innobase/Makefile.am +++ b/storage/innobase/Makefile.am @@ -163,8 +163,8 @@ EXTRA_LTLIBRARIES= ha_innodb.la pkgplugin_LTLIBRARIES= @plugin_innobase_shared_target@ ha_innodb_la_LDFLAGS= -module -rpath $(pkgplugindir) -ha_innodb_la_CXXFLAGS= $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS) -ha_innodb_la_CFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS) +ha_innodb_la_CXXFLAGS= -shared $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS) +ha_innodb_la_CFLAGS= -shared $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS) ha_innodb_la_SOURCES= $(libinnobase_a_SOURCES) EXTRA_DIST= CMakeLists.txt plug.in \ diff --git a/storage/innodb_plugin/Makefile.am b/storage/innodb_plugin/Makefile.am index f11e5db01f4..0d2c194a3f2 100644 --- a/storage/innodb_plugin/Makefile.am +++ b/storage/innodb_plugin/Makefile.am @@ -332,8 +332,8 @@ EXTRA_LTLIBRARIES= ha_innodb_plugin.la pkgplugin_LTLIBRARIES= @plugin_innodb_plugin_shared_target@ ha_innodb_plugin_la_LDFLAGS= -module -rpath $(pkgplugindir) -ha_innodb_plugin_la_CXXFLAGS= $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS) -ha_innodb_plugin_la_CFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS) +ha_innodb_plugin_la_CXXFLAGS= -shared $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS) +ha_innodb_plugin_la_CFLAGS= -shared $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS) ha_innodb_plugin_la_SOURCES= $(libinnobase_a_SOURCES) EXTRA_DIST= CMakeLists.txt plug.in \ diff --git a/storage/pbxt/src/Makefile.am b/storage/pbxt/src/Makefile.am index fc4c4ef8f1e..20399aee484 100644 --- a/storage/pbxt/src/Makefile.am +++ b/storage/pbxt/src/Makefile.am @@ -40,8 +40,8 @@ libpbxt_la_LDFLAGS = -module # These are the warning Drizzle uses: # DRIZZLE_WARNINGS = -W -Wall -Wextra -pedantic -Wundef -Wredundant-decls -Wno-strict-aliasing -Wno-long-long -Wno-unused-parameter -libpbxt_la_CXXFLAGS = $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN -libpbxt_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN -std=c99 +libpbxt_la_CXXFLAGS = -shared $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN +libpbxt_la_CFLAGS = -shared $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN -std=c99 EXTRA_LIBRARIES = libpbxt.a noinst_LIBRARIES = libpbxt.a diff --git a/storage/xtradb/Makefile.am b/storage/xtradb/Makefile.am index b0b4721a9c5..9b8c2e52383 100644 --- a/storage/xtradb/Makefile.am +++ b/storage/xtradb/Makefile.am @@ -333,8 +333,8 @@ EXTRA_LTLIBRARIES= ha_xtradb.la pkgplugin_LTLIBRARIES= @plugin_xtradb_shared_target@ ha_xtradb_la_LDFLAGS= -module -rpath $(pkgplugindir) -ha_xtradb_la_CXXFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS) -ha_xtradb_la_CFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS) +ha_xtradb_la_CXXFLAGS= -shared $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS) +ha_xtradb_la_CFLAGS= -shared $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS) ha_xtradb_la_SOURCES= $(libxtradb_a_SOURCES) EXTRA_DIST= CMakeLists.txt plug.in \ From 966661c8cc75dd7d540a5fe40b4d893c40e91d26 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 11 Sep 2010 09:46:33 +0200 Subject: [PATCH 118/118] to simpliy and unify the code --- include/my_global.h | 46 +++++++++++++++++--------------------------- sql/item_timefunc.cc | 5 ----- 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/include/my_global.h b/include/my_global.h index 38cc87bb42d..5f917cc110e 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -568,44 +568,34 @@ int __void__; #endif /* DONT_DEFINE_VOID */ /* - Try to suppress warning for not initialized variables. + Deprecated workaround for false-positive uninitialized variables + warnings. Those should be silenced using tool-specific heuristics. - With gcc when using C, we suppress the uninitialized variable warning - without generating code. We can't do this with C++ - for a g++ bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772). + Enabled by default for g++ due to the bug referenced below. */ - -#if defined(FORCE_INIT_OF_VARS) +#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || \ + (defined(__GNUC__) && defined(__cplusplus)) #define LINT_INIT(var) var= 0 -#if defined(__cplusplus) || !defined(__GNUC__) +#else +#define LINT_INIT(var) +#endif + +/* + Suppress uninitialized variable warning without generating code. + + The _cplusplus is a temporary workaround for C++ code pending a fix + for a g++ bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772). +*/ +#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || \ + defined(__cplusplus) || !defined(__GNUC__) #define UNINIT_VAR(x) x= 0 #else /* GCC specific self-initialization which inhibits the warning. */ #define UNINIT_VAR(x) x= x #endif -#else /* !FORCE_INIT_OF_VARS */ -#define LINT_INIT(var) -#if !defined(__cplusplus) && !defined(__GNUC__) -/* GCC specific self-initialization which inhibits the warning. */ -#define UNINIT_VAR(x) x= x -#else -#define UNINIT_VAR(x) x -#endif -#endif /* FORCE_INIT_OF_VARS */ #include -/* - The following is to force some unitialized variables to 0 if we are - running valgrind. This is needed when the compiler may access the variable - even if the value of it is never used. -*/ -#if defined(HAVE_valgrind) -#define VALGRIND_OR_LINT_INIT(var) var=0 -#else -#define VALGRIND_OR_LINT_INIT(var) LINT_INIT(var) -#endif - /* Define some useful general macros */ #if !defined(max) #define max(a, b) ((a) > (b) ? (a) : (b)) @@ -621,7 +611,7 @@ typedef unsigned short ushort; #define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1) #define sgn(a) (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0) -#define swap_variables(t, a, b) { t swap_dummy; swap_dummy= a; a= b; b= swap_dummy; } +#define swap_variables(t, a, b) { t dummy; dummy= a; a= b; b= dummy; } #define test(a) ((a) ? 1 : 0) #define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0) #define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0) diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 96dede612c8..57656f30294 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -288,11 +288,6 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, CHARSET_INFO *cs= &my_charset_bin; DBUG_ENTER("extract_date_time"); - LINT_INIT(strict_week_number); - /* Remove valgrind varnings when using gcc 3.3 and -O1 */ - VALGRIND_OR_LINT_INIT(strict_week_number_year_type); - VALGRIND_OR_LINT_INIT(sunday_first_n_first_week_non_iso); - if (!sub_pattern_end) bzero((char*) l_time, sizeof(*l_time));