From: Date: June 20 2008 12:51am Subject: bzr push into mysql-5.1 branch (timothy.smith:2671 to 2672) Bug#36793, Bug#35602, Bug#36600 List-Archive: http://lists.mysql.com/commits/48204 X-Bug: 36793 Message-Id: <20080619225108.2E2F62780ED@ramayana.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 2672 Timothy Smith 2008-06-19 Apply high-priority bug fixes from InnoDB into 5.1: Fix for Bug#36793. This is a back port from branches/zip. This code has been tested on a big-endian machine too. Fix Bug#36600 SHOW STATUS takes a lot of CPU in buf_get_latched_pages_number by removing the Innodb_buffer_pool_pages_latched variable from SHOW STATUS output in non-UNIV_DEBUG compilation. Fix for Bug#35602, "Failed to read auto-increment value from storage engine". The test for REPLACE was an error of ommission since it's classified as a simple INSERT. For REPLACE statements we don't acquire the special AUTOINC lock for AUTOINC_NEW_STYLE_LOCKING with this fix. These fixes are cherry-picked from the 5.1-ss2479, -ss2479, and -ss2485 snapshots, respectively. modified: storage/innobase/buf/buf0buf.c storage/innobase/handler/ha_innodb.cc storage/innobase/include/buf0buf.h storage/innobase/include/mach0data.h storage/innobase/include/mach0data.ic storage/innobase/include/srv0srv.h storage/innobase/row/row0sel.c storage/innobase/srv/srv0srv.c 2671 Davi Arnaut 2008-06-19 Silence unused variable warning by printing the variables value. modified: mysys/stacktrace.c === modified file 'storage/innobase/buf/buf0buf.c' --- a/storage/innobase/buf/buf0buf.c 2008-02-01 10:55:39 +0000 +++ b/storage/innobase/buf/buf0buf.c 2008-06-19 22:46:55 +0000 @@ -2328,7 +2328,6 @@ buf_print(void) ut_a(buf_validate()); } -#endif /* UNIV_DEBUG */ /************************************************************************* Returns the number of latched pages in the buffer pool. */ @@ -2361,6 +2360,7 @@ buf_get_latched_pages_number(void) return(fixed_pages_number); } +#endif /* UNIV_DEBUG */ /************************************************************************* Returns the number of pending buf pool ios. */ === modified file 'storage/innobase/handler/ha_innodb.cc' --- a/storage/innobase/handler/ha_innodb.cc 2008-05-14 08:45:32 +0000 +++ b/storage/innobase/handler/ha_innodb.cc 2008-06-19 22:46:55 +0000 @@ -334,8 +334,10 @@ static SHOW_VAR innodb_status_variables[ (char*) &export_vars.innodb_buffer_pool_pages_flushed, SHOW_LONG}, {"buffer_pool_pages_free", (char*) &export_vars.innodb_buffer_pool_pages_free, SHOW_LONG}, +#ifdef UNIV_DEBUG {"buffer_pool_pages_latched", (char*) &export_vars.innodb_buffer_pool_pages_latched, SHOW_LONG}, +#endif /* UNIV_DEBUG */ {"buffer_pool_pages_misc", (char*) &export_vars.innodb_buffer_pool_pages_misc, SHOW_LONG}, {"buffer_pool_pages_total", @@ -3275,7 +3277,8 @@ ha_innobase::innobase_autoinc_lock(void) old style only if another transaction has already acquired the AUTOINC lock on behalf of a LOAD FILE or INSERT ... SELECT etc. type of statement. */ - if (thd_sql_command(user_thd) == SQLCOM_INSERT) { + if (thd_sql_command(user_thd) == SQLCOM_INSERT + || thd_sql_command(user_thd) == SQLCOM_REPLACE) { dict_table_t* table = prebuilt->table; /* Acquire the AUTOINC mutex. */ === modified file 'storage/innobase/include/buf0buf.h' --- a/storage/innobase/include/buf0buf.h 2008-02-01 10:55:39 +0000 +++ b/storage/innobase/include/buf0buf.h 2008-06-19 22:46:55 +0000 @@ -495,7 +495,15 @@ Prints info of the buffer pool data stru void buf_print(void); /*============*/ + +/************************************************************************* +Returns the number of latched pages in the buffer pool. */ + +ulint +buf_get_latched_pages_number(void); +/*==============================*/ #endif /* UNIV_DEBUG */ + /************************************************************************ Prints a page to stderr. */ @@ -503,12 +511,7 @@ void buf_page_print( /*===========*/ byte* read_buf); /* in: a database page */ -/************************************************************************* -Returns the number of latched pages in the buffer pool. */ -ulint -buf_get_latched_pages_number(void); -/*==============================*/ /************************************************************************* Returns the number of pending buf pool ios. */ === modified file 'storage/innobase/include/mach0data.h' --- a/storage/innobase/include/mach0data.h 2007-11-06 22:42:58 +0000 +++ b/storage/innobase/include/mach0data.h 2008-06-19 22:46:55 +0000 @@ -331,10 +331,10 @@ mach_write_to_2_little_endian( Convert integral type from storage byte order (big endian) to host byte order. */ UNIV_INLINE -void +ullint mach_read_int_type( /*===============*/ - byte* dest, /* out: where to write */ + /* out: integer value */ const byte* src, /* in: where to read from */ ulint len, /* in: length of src */ ibool unsigned_type); /* in: signed or unsigned flag */ === modified file 'storage/innobase/include/mach0data.ic' --- a/storage/innobase/include/mach0data.ic 2007-11-06 22:42:58 +0000 +++ b/storage/innobase/include/mach0data.ic 2008-06-19 22:46:55 +0000 @@ -696,33 +696,39 @@ mach_write_to_2_little_endian( Convert integral type from storage byte order (big endian) to host byte order. */ UNIV_INLINE -void +ullint mach_read_int_type( /*===============*/ - byte* dest, /* out: where to write */ + /* out: integer value */ const byte* src, /* in: where to read from */ ulint len, /* in: length of src */ ibool unsigned_type) /* in: signed or unsigned flag */ { -#ifdef WORDS_BIGENDIAN - memcpy(dest, src, len); + /* XXX this can be optimized on big-endian machines */ - if (!unsigned_type) { - dest[0] ^= 128; + ullint ret; + uint i; + + if (unsigned_type || (src[0] & 0x80)) { + + ret = 0x0000000000000000ULL; + } else { + + ret = 0xFFFFFFFFFFFFFF00ULL; } -#else - byte* ptr; - /* Convert integer data from Innobase to a little-endian format, - sign bit restored to normal. */ + if (unsigned_type) { - for (ptr = dest + len; ptr != dest; ++src) { - --ptr; - *ptr = *src; + ret |= src[0]; + } else { + + ret |= src[0] ^ 0x80; } - if (!unsigned_type) { - dest[len - 1] ^= 128; + for (i = 1; i < len; i++) { + ret <<= 8; + ret |= src[i]; } -#endif + + return(ret); } === modified file 'storage/innobase/include/srv0srv.h' --- a/storage/innobase/include/srv0srv.h 2008-03-27 14:13:10 +0000 +++ b/storage/innobase/include/srv0srv.h 2008-06-19 22:46:55 +0000 @@ -501,7 +501,9 @@ struct export_var_struct{ ulint innodb_buffer_pool_pages_dirty; ulint innodb_buffer_pool_pages_misc; ulint innodb_buffer_pool_pages_free; +#ifdef UNIV_DEBUG ulint innodb_buffer_pool_pages_latched; +#endif /* UNIV_DEBUG */ ulint innodb_buffer_pool_read_requests; ulint innodb_buffer_pool_reads; ulint innodb_buffer_pool_wait_free; === modified file 'storage/innobase/row/row0sel.c' --- a/storage/innobase/row/row0sel.c 2008-05-14 08:45:32 +0000 +++ b/storage/innobase/row/row0sel.c 2008-06-19 22:46:55 +0000 @@ -4563,8 +4563,6 @@ row_search_autoinc_read_column( const byte* data; ib_ulonglong value; mem_heap_t* heap = NULL; - /* Our requirement is that dest should be word aligned. */ - byte dest[sizeof(value)]; ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint* offsets = offsets_; @@ -4582,40 +4580,13 @@ row_search_autoinc_read_column( ut_a(len != UNIV_SQL_NULL); ut_a(len <= sizeof value); - mach_read_int_type(dest, data, len, unsigned_type); - - /* The assumption here is that the AUTOINC value can't be negative - and that dest is word aligned. */ - switch (len) { - case 8: - value = *(ib_ulonglong*) dest; - break; - - case 4: - value = *(ib_uint32_t*) dest; - break; - - case 3: - value = *(ib_uint32_t*) dest; - value &= 0xFFFFFF; - break; - - case 2: - value = *(uint16 *) dest; - break; - - case 1: - value = *dest; - break; - - default: - ut_error; - } + value = mach_read_int_type(data, len, unsigned_type); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } + /* We assume that the autoinc counter can't be negative. */ if (!unsigned_type && (ib_longlong) value < 0) { value = 0; } === modified file 'storage/innobase/srv/srv0srv.c' --- a/storage/innobase/srv/srv0srv.c 2008-03-27 14:13:10 +0000 +++ b/storage/innobase/srv/srv0srv.c 2008-06-19 22:46:55 +0000 @@ -1825,8 +1825,10 @@ srv_export_innodb_status(void) = UT_LIST_GET_LEN(buf_pool->flush_list); export_vars.innodb_buffer_pool_pages_free = UT_LIST_GET_LEN(buf_pool->free); +#ifdef UNIV_DEBUG export_vars.innodb_buffer_pool_pages_latched = buf_get_latched_pages_number(); +#endif /* UNIV_DEBUG */ export_vars.innodb_buffer_pool_pages_total = buf_pool->curr_size; export_vars.innodb_buffer_pool_pages_misc = buf_pool->max_size