From 108b211ee2aa3944f060850a2522fb28c75f6158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 16 Feb 2017 12:02:31 +0200 Subject: Fix gcc 6.3.x compiler warnings. These are caused by fact that functions are declared with __attribute__((nonnull)) or left shit like ~0 << macro when ~0U << macro should be used. --- storage/innobase/btr/btr0btr.c | 1 - storage/innobase/btr/btr0cur.c | 8 +------- storage/innobase/buf/buf0buddy.c | 1 - storage/innobase/dict/dict0crea.c | 10 +++++----- storage/innobase/dict/dict0dict.c | 1 - storage/innobase/dict/dict0load.c | 8 ++++---- storage/innobase/dict/dict0mem.c | 2 +- storage/innobase/dyn/dyn0dyn.c | 1 - storage/innobase/fil/fil0fil.c | 2 +- storage/innobase/fsp/fsp0fsp.c | 5 ----- storage/innobase/include/dict0dict.ic | 7 ------- storage/innobase/include/dict0mem.h | 12 ++++++------ storage/innobase/include/dyn0dyn.ic | 10 ---------- storage/innobase/include/fsp0fsp.h | 2 +- storage/innobase/include/mach0data.ic | 13 ------------- storage/innobase/include/mtr0mtr.ic | 1 - storage/innobase/include/page0page.ic | 1 - storage/innobase/include/rem0rec.ic | 1 - storage/innobase/include/ut0lst.h | 3 --- storage/innobase/mtr/mtr0mtr.c | 1 - storage/innobase/page/page0page.c | 2 -- storage/innobase/page/page0zip.c | 1 - storage/innobase/rem/rem0rec.c | 3 +-- storage/innobase/row/row0merge.c | 12 ------------ storage/innobase/row/row0purge.c | 3 --- storage/innobase/row/row0upd.c | 4 ---- storage/innobase/trx/trx0trx.c | 1 - 27 files changed, 20 insertions(+), 96 deletions(-) (limited to 'storage/innobase') diff --git a/storage/innobase/btr/btr0btr.c b/storage/innobase/btr/btr0btr.c index ede72ba57bb..58d816559d4 100644 --- a/storage/innobase/btr/btr0btr.c +++ b/storage/innobase/btr/btr0btr.c @@ -2932,7 +2932,6 @@ btr_level_list_remove_func( ulint prev_page_no; ulint next_page_no; - ut_ad(page && mtr); ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(space == page_get_space_id(page)); /* Get the previous and next page numbers of page */ diff --git a/storage/innobase/btr/btr0cur.c b/storage/innobase/btr/btr0cur.c index 3b533909e67..2c1ab4bffae 100644 --- a/storage/innobase/btr/btr0cur.c +++ b/storage/innobase/btr/btr0cur.c @@ -1877,7 +1877,6 @@ btr_cur_update_alloc_zip( mtr_t* mtr) /*!< in: mini-transaction */ { ut_a(page_zip == buf_block_get_page_zip(block)); - ut_ad(page_zip); ut_ad(!dict_index_is_ibuf(index)); if (page_zip_available(page_zip, dict_index_is_clust(index), @@ -2837,7 +2836,7 @@ btr_cur_del_mark_set_clust_rec( ut_ad(page_is_leaf(page_align(rec))); #ifdef UNIV_DEBUG - if (btr_cur_print_record_ops && thr) { + if (btr_cur_print_record_ops) { btr_cur_trx_report(thr_get_trx(thr), index, "del mark "); rec_print_new(stderr, rec, offsets); } @@ -4128,7 +4127,6 @@ btr_cur_disown_inherited_fields( ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(!rec_offs_comp(offsets) || !rec_get_node_ptr_flag(rec)); ut_ad(rec_offs_any_extern(offsets)); - ut_ad(mtr); for (i = 0; i < rec_offs_n_fields(offsets); i++) { if (rec_offs_nth_extern(offsets, i) @@ -4191,9 +4189,6 @@ btr_push_update_extern_fields( ulint n; const upd_field_t* uf; - ut_ad(tuple); - ut_ad(update); - uf = update->fields; n = upd_get_n_fields(update); @@ -4366,7 +4361,6 @@ btr_store_big_rec_extern_fields( ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(rec_offs_any_extern(offsets)); - ut_ad(btr_mtr); ut_ad(mtr_memo_contains(btr_mtr, dict_index_get_lock(index), MTR_MEMO_X_LOCK)); ut_ad(mtr_memo_contains(btr_mtr, rec_block, MTR_MEMO_PAGE_X_FIX)); diff --git a/storage/innobase/buf/buf0buddy.c b/storage/innobase/buf/buf0buddy.c index 9277a89ce66..fa2515eddc2 100644 --- a/storage/innobase/buf/buf0buddy.c +++ b/storage/innobase/buf/buf0buddy.c @@ -276,7 +276,6 @@ buf_buddy_alloc_low( { buf_block_t* block; - ut_ad(lru); ut_ad(buf_pool_mutex_own(buf_pool)); ut_ad(!mutex_own(&buf_pool->zip_mutex)); ut_ad(i >= buf_buddy_get_slot(PAGE_ZIP_MIN_SIZE)); diff --git a/storage/innobase/dict/dict0crea.c b/storage/innobase/dict/dict0crea.c index f8bcc6f2d5f..4e173fb905d 100644 --- a/storage/innobase/dict/dict0crea.c +++ b/storage/innobase/dict/dict0crea.c @@ -112,13 +112,13 @@ dict_create_sys_tables_tuple( dfield = dtuple_get_nth_field(entry, 3/*TYPE*/); ptr = mem_heap_alloc(heap, 4); - if (table->flags & (~DICT_TF_COMPACT & ~(~0 << DICT_TF_BITS))) { + if (table->flags & (~DICT_TF_COMPACT & ~(~0U << DICT_TF_BITS))) { ut_a(table->flags & DICT_TF_COMPACT); ut_a(dict_table_get_format(table) >= DICT_TF_FORMAT_ZIP); ut_a((table->flags & DICT_TF_ZSSIZE_MASK) <= (DICT_TF_ZSSIZE_MAX << DICT_TF_ZSSIZE_SHIFT)); - ut_a(!(table->flags & (~0 << DICT_TF2_BITS))); - mach_write_to_4(ptr, table->flags & ~(~0 << DICT_TF_BITS)); + ut_a(!(table->flags & (~0U << DICT_TF2_BITS))); + mach_write_to_4(ptr, table->flags & ~(~0U << DICT_TF_BITS)); } else { mach_write_to_4(ptr, DICT_TABLE_ORDINARY); } @@ -306,7 +306,7 @@ dict_build_table_def_step( ut_ad(!dict_table_zip_size(table) || dict_table_get_format(table) >= DICT_TF_FORMAT_ZIP); - flags = table->flags & ~(~0 << DICT_TF_BITS); + flags = table->flags & ~(~0U << DICT_TF_BITS); error = fil_create_new_single_table_tablespace( space, path_or_name, is_path, flags == DICT_TF_COMPACT ? 0 : flags, @@ -325,7 +325,7 @@ dict_build_table_def_step( mtr_commit(&mtr); } else { /* Create in the system tablespace: disallow new features */ - table->flags &= (~0 << DICT_TF_BITS) | DICT_TF_COMPACT; + table->flags &= (~0U << DICT_TF_BITS) | DICT_TF_COMPACT; } row = dict_create_sys_tables_tuple(table, node->heap); diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c index 33b110ce97a..588c2968b6a 100644 --- a/storage/innobase/dict/dict0dict.c +++ b/storage/innobase/dict/dict0dict.c @@ -5848,7 +5848,6 @@ dict_set_corrupted( const char* status; btr_cur_t cursor; - ut_ad(index); ut_ad(mutex_own(&dict_sys->mutex)); ut_ad(!dict_table_is_comp(dict_sys->sys_tables)); ut_ad(!dict_table_is_comp(dict_sys->sys_indexes)); diff --git a/storage/innobase/dict/dict0load.c b/storage/innobase/dict/dict0load.c index 22de23af7ee..d7168b6e4bb 100644 --- a/storage/innobase/dict/dict0load.c +++ b/storage/innobase/dict/dict0load.c @@ -643,7 +643,7 @@ dict_sys_tables_get_flags( return(ULINT_UNDEFINED); } - if (UNIV_UNLIKELY(flags & (~0 << DICT_TF_BITS))) { + if (UNIV_UNLIKELY(flags & (~0U << DICT_TF_BITS))) { /* Some unused bits are set. */ return(ULINT_UNDEFINED); } @@ -1332,7 +1332,7 @@ err_len: goto err_len; } type = mach_read_from_4(field); - if (UNIV_UNLIKELY(type & (~0 << DICT_IT_BITS))) { + if (UNIV_UNLIKELY(type & (~0U << DICT_IT_BITS))) { return("unknown SYS_INDEXES.TYPE bits"); } @@ -1696,7 +1696,7 @@ err_len: flags2 = mach_read_from_4(field); - if (flags2 & (~0 << (DICT_TF2_BITS - DICT_TF2_SHIFT))) { + if (flags2 & (~0U << (DICT_TF2_BITS - DICT_TF2_SHIFT))) { ut_print_timestamp(stderr); fputs(" InnoDB: Warning: table ", stderr); ut_print_filename(stderr, name); @@ -1705,7 +1705,7 @@ err_len: " has unknown flags %lx.\n", (ulong) flags2); - flags2 &= ~(~0 << (DICT_TF2_BITS - DICT_TF2_SHIFT)); + flags2 &= ~(~0U << (DICT_TF2_BITS - DICT_TF2_SHIFT)); } flags |= flags2 << DICT_TF2_SHIFT; diff --git a/storage/innobase/dict/dict0mem.c b/storage/innobase/dict/dict0mem.c index cea7a253ba0..87d03eff3c2 100644 --- a/storage/innobase/dict/dict0mem.c +++ b/storage/innobase/dict/dict0mem.c @@ -69,7 +69,7 @@ dict_mem_table_create( DBUG_ENTER("dict_mem_table_create"); ut_ad(name); - ut_a(!(flags & (~0 << DICT_TF2_BITS))); + ut_a(!(flags & (~0U << DICT_TF2_BITS))); heap = mem_heap_create(DICT_HEAP_SIZE); diff --git a/storage/innobase/dyn/dyn0dyn.c b/storage/innobase/dyn/dyn0dyn.c index d0f50ad0c32..b723877d648 100644 --- a/storage/innobase/dyn/dyn0dyn.c +++ b/storage/innobase/dyn/dyn0dyn.c @@ -40,7 +40,6 @@ dyn_array_add_block( mem_heap_t* heap; dyn_block_t* block; - ut_ad(arr); ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N); if (arr->heap == NULL) { diff --git a/storage/innobase/fil/fil0fil.c b/storage/innobase/fil/fil0fil.c index b30e8056c0a..d7ac3dd14eb 100644 --- a/storage/innobase/fil/fil0fil.c +++ b/storage/innobase/fil/fil0fil.c @@ -3308,7 +3308,7 @@ fil_open_single_table_tablespace( } if (space_id != id - || space_flags != (flags & ~(~0 << DICT_TF_BITS))) { + || space_flags != (flags & ~(~0U << DICT_TF_BITS))) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: tablespace id and flags in file ", diff --git a/storage/innobase/fsp/fsp0fsp.c b/storage/innobase/fsp/fsp0fsp.c index 6d00a1f1d4a..e2e27608e5d 100644 --- a/storage/innobase/fsp/fsp0fsp.c +++ b/storage/innobase/fsp/fsp0fsp.c @@ -1285,7 +1285,6 @@ fsp_fill_free_list( ulint i; mtr_t ibuf_mtr; - ut_ad(header && mtr); ut_ad(page_offset(header) == FSP_HEADER_OFFSET); /* Check if we can fill free list from above the free list limit */ @@ -1584,9 +1583,6 @@ fsp_alloc_free_page( ulint page_no; ulint space_size; - ut_ad(mtr); - ut_ad(init_mtr); - header = fsp_get_space_header(space, zip_size, mtr); /* Get the hinted descriptor */ @@ -2602,7 +2598,6 @@ fseg_alloc_free_page_low( ibool success; ulint n; - ut_ad(mtr); ut_ad((direction >= FSP_UP) && (direction <= FSP_NO_DIR)); ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE); diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic index b65cae2a1d8..dbc3ce99ab0 100644 --- a/storage/innobase/include/dict0dict.ic +++ b/storage/innobase/include/dict0dict.ic @@ -247,7 +247,6 @@ dict_index_is_clust( /*================*/ const dict_index_t* index) /*!< in: index */ { - ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); return(UNIV_UNLIKELY(index->type & DICT_CLUSTERED)); @@ -261,7 +260,6 @@ dict_index_is_unique( /*=================*/ const dict_index_t* index) /*!< in: index */ { - ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); return(UNIV_UNLIKELY(index->type & DICT_UNIQUE)); @@ -276,7 +274,6 @@ dict_index_is_ibuf( /*===============*/ const dict_index_t* index) /*!< in: index */ { - ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); return(UNIV_UNLIKELY(index->type & DICT_IBUF)); @@ -293,7 +290,6 @@ dict_index_is_sec_or_ibuf( { ulint type; - ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); type = index->type; @@ -311,7 +307,6 @@ dict_table_get_n_user_cols( /*=======================*/ const dict_table_t* table) /*!< in: table */ { - ut_ad(table); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); return(table->n_cols - DATA_N_SYS_COLS); @@ -343,7 +338,6 @@ dict_table_get_n_cols( /*==================*/ const dict_table_t* table) /*!< in: table */ { - ut_ad(table); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); return(table->n_cols); @@ -937,7 +931,6 @@ dict_index_is_corrupted( /*====================*/ const dict_index_t* index) /*!< in: index */ { - ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); return(UNIV_UNLIKELY((index->type & DICT_CORRUPT) diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index a58bb914be2..1b12c8303bb 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -85,9 +85,14 @@ combination of types */ /** File format */ /* @{ */ +#define DICT_TF_BITS 6 /*!< number of flag bits */ +#if (1 << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT)) <= DICT_TF_FORMAT_MAX +# error "DICT_TF_BITS is insufficient for DICT_TF_FORMAT_MAX" +#endif + #define DICT_TF_FORMAT_SHIFT 5 /* file format */ #define DICT_TF_FORMAT_MASK \ -((~(~0 << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT))) << DICT_TF_FORMAT_SHIFT) +((~(~0U << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT))) << DICT_TF_FORMAT_SHIFT) #define DICT_TF_FORMAT_51 0 /*!< InnoDB/MySQL up to 5.1 */ #define DICT_TF_FORMAT_ZIP 1 /*!< InnoDB plugin for 5.1: compressed tables, @@ -98,11 +103,6 @@ combination of types */ /** Minimum supported file format */ #define DICT_TF_FORMAT_MIN DICT_TF_FORMAT_51 -/* @} */ -#define DICT_TF_BITS 6 /*!< number of flag bits */ -#if (1 << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT)) <= DICT_TF_FORMAT_MAX -# error "DICT_TF_BITS is insufficient for DICT_TF_FORMAT_MAX" -#endif /* @} */ /** @brief Additional table flags. diff --git a/storage/innobase/include/dyn0dyn.ic b/storage/innobase/include/dyn0dyn.ic index 177877ed1fd..2565a249271 100644 --- a/storage/innobase/include/dyn0dyn.ic +++ b/storage/innobase/include/dyn0dyn.ic @@ -47,8 +47,6 @@ dyn_block_get_used( /*===============*/ const dyn_block_t* block) /*!< in: dyn array block */ { - ut_ad(block); - return((block->used) & ~DYN_BLOCK_FULL_FLAG); } @@ -61,8 +59,6 @@ dyn_block_get_data( /*===============*/ const dyn_block_t* block) /*!< in: dyn array block */ { - ut_ad(block); - return((byte*) block->data); } @@ -76,7 +72,6 @@ dyn_array_create( dyn_array_t* arr) /*!< in/out: memory buffer of size sizeof(dyn_array_t) */ { - ut_ad(arr); #if DYN_ARRAY_DATA_SIZE >= DYN_BLOCK_FULL_FLAG # error "DYN_ARRAY_DATA_SIZE >= DYN_BLOCK_FULL_FLAG" #endif @@ -119,7 +114,6 @@ dyn_array_push( dyn_block_t* block; ulint used; - ut_ad(arr); ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N); ut_ad(size <= DYN_ARRAY_DATA_SIZE); ut_ad(size); @@ -159,7 +153,6 @@ dyn_array_open( { dyn_block_t* block; - ut_ad(arr); ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N); ut_ad(size <= DYN_ARRAY_DATA_SIZE); ut_ad(size); @@ -195,7 +188,6 @@ dyn_array_close( { dyn_block_t* block; - ut_ad(arr); ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N); block = dyn_array_get_last_block(arr); @@ -222,7 +214,6 @@ dyn_array_get_element( { const dyn_block_t* block; - ut_ad(arr); ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N); /* Get the first array block */ @@ -260,7 +251,6 @@ dyn_array_get_data_size( const dyn_block_t* block; ulint sum = 0; - ut_ad(arr); ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N); if (arr->heap == NULL) { diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h index f07e3decc66..0b813182947 100644 --- a/storage/innobase/include/fsp0fsp.h +++ b/storage/innobase/include/fsp0fsp.h @@ -42,7 +42,7 @@ Created 12/18/1995 Heikki Tuuri #define FSP_FLAGS_POS_PAGE_SSIZE 6 /** Bit mask of the PAGE_SSIZE field */ #define FSP_FLAGS_MASK_PAGE_SSIZE \ - ((~(~0 << FSP_FLAGS_WIDTH_PAGE_SSIZE)) \ + ((~(~0U << FSP_FLAGS_WIDTH_PAGE_SSIZE)) \ << FSP_FLAGS_POS_PAGE_SSIZE) /** Return the value of the PAGE_SSIZE field */ #define FSP_FLAGS_GET_PAGE_SSIZE(flags) \ diff --git a/storage/innobase/include/mach0data.ic b/storage/innobase/include/mach0data.ic index 238a56577af..fdcb07ca29b 100644 --- a/storage/innobase/include/mach0data.ic +++ b/storage/innobase/include/mach0data.ic @@ -50,7 +50,6 @@ mach_read_from_1( /*=============*/ const byte* b) /*!< in: pointer to byte */ { - ut_ad(b); return((ulint)(b[0])); } @@ -143,7 +142,6 @@ mach_read_from_3( /*=============*/ const byte* b) /*!< in: pointer to 3 bytes */ { - ut_ad(b); return( ((ulint)(b[0]) << 16) | ((ulint)(b[1]) << 8) | (ulint)(b[2]) @@ -178,7 +176,6 @@ mach_read_from_4( /*=============*/ const byte* b) /*!< in: pointer to four bytes */ { - ut_ad(b); return( ((ulint)(b[0]) << 24) | ((ulint)(b[1]) << 16) | ((ulint)(b[2]) << 8) @@ -255,8 +252,6 @@ mach_read_compressed( { ulint flag; - ut_ad(b); - flag = mach_read_from_1(b); if (flag < 0x80UL) { @@ -333,8 +328,6 @@ mach_read_from_7( /*=============*/ const byte* b) /*!< in: pointer to 7 bytes */ { - ut_ad(b); - return(ut_ull_create(mach_read_from_3(b), mach_read_from_4(b + 3))); } @@ -364,8 +357,6 @@ mach_read_from_6( /*=============*/ const byte* b) /*!< in: pointer to 6 bytes */ { - ut_ad(b); - return(ut_ull_create(mach_read_from_2(b), mach_read_from_4(b + 2))); } @@ -413,8 +404,6 @@ mach_ull_read_compressed( ib_uint64_t n; ulint size; - ut_ad(b); - n = (ib_uint64_t) mach_read_compressed(b); size = mach_get_compressed_size((ulint) n); @@ -480,8 +469,6 @@ mach_ull_read_much_compressed( ib_uint64_t n; ulint size; - ut_ad(b); - if (*b != (byte)0xFF) { n = 0; size = 0; diff --git a/storage/innobase/include/mtr0mtr.ic b/storage/innobase/include/mtr0mtr.ic index a03a0271535..c9e2f2e39de 100644 --- a/storage/innobase/include/mtr0mtr.ic +++ b/storage/innobase/include/mtr0mtr.ic @@ -149,7 +149,6 @@ mtr_memo_contains( dyn_array_t* memo; ulint offset; - ut_ad(mtr); ut_ad(mtr->magic_n == MTR_MAGIC_N); ut_ad(mtr->state == MTR_ACTIVE || mtr->state == MTR_COMMITTING); diff --git a/storage/innobase/include/page0page.ic b/storage/innobase/include/page0page.ic index 781ad029e87..1689c0ade6b 100644 --- a/storage/innobase/include/page0page.ic +++ b/storage/innobase/include/page0page.ic @@ -154,7 +154,6 @@ page_header_get_offs( { ulint offs; - ut_ad(page); ut_ad((field == PAGE_FREE) || (field == PAGE_LAST_INSERT) || (field == PAGE_HEAP_TOP)); diff --git a/storage/innobase/include/rem0rec.ic b/storage/innobase/include/rem0rec.ic index 564d2d1b31c..c81388391d7 100644 --- a/storage/innobase/include/rem0rec.ic +++ b/storage/innobase/include/rem0rec.ic @@ -1545,7 +1545,6 @@ rec_copy( ulint extra_len; ulint data_len; - ut_ad(rec && buf); ut_ad(rec_offs_validate((rec_t*) rec, NULL, offsets)); ut_ad(rec_validate(rec, offsets)); diff --git a/storage/innobase/include/ut0lst.h b/storage/innobase/include/ut0lst.h index a010f464570..1fb43fd4805 100644 --- a/storage/innobase/include/ut0lst.h +++ b/storage/innobase/include/ut0lst.h @@ -88,7 +88,6 @@ Adds the node as the first element in a two-way linked list. */ #define UT_LIST_ADD_FIRST(NAME, BASE, N)\ {\ - ut_ad(N);\ ((BASE).count)++;\ ((N)->NAME).next = (BASE).start;\ ((N)->NAME).prev = NULL;\ @@ -134,7 +133,6 @@ Inserts a NODE2 after NODE1 in a list. #define UT_LIST_INSERT_AFTER(NAME, BASE, NODE1, NODE2)\ {\ ut_ad(NODE1);\ - ut_ad(NODE2);\ ut_ad((NODE1) != (NODE2));\ ((BASE).count)++;\ ((NODE2)->NAME).prev = (NODE1);\ @@ -169,7 +167,6 @@ Removes a node from a two-way linked list. */ #define UT_LIST_REMOVE(NAME, BASE, N) \ do { \ - ut_ad(N); \ ut_a((BASE).count > 0); \ ((BASE).count)--; \ if (((N)->NAME).next != NULL) { \ diff --git a/storage/innobase/mtr/mtr0mtr.c b/storage/innobase/mtr/mtr0mtr.c index a5c98761523..ebad6e7bfa1 100644 --- a/storage/innobase/mtr/mtr0mtr.c +++ b/storage/innobase/mtr/mtr0mtr.c @@ -257,7 +257,6 @@ mtr_commit( /*=======*/ mtr_t* mtr) /*!< in: mini-transaction */ { - ut_ad(mtr); ut_ad(mtr->magic_n == MTR_MAGIC_N); ut_ad(mtr->state == MTR_ACTIVE); ut_ad(!mtr->inside_ibuf); diff --git a/storage/innobase/page/page0page.c b/storage/innobase/page/page0page.c index 81051f8f4fe..9af4b1c8faa 100644 --- a/storage/innobase/page/page0page.c +++ b/storage/innobase/page/page0page.c @@ -1345,7 +1345,6 @@ page_dir_split_slot( ulint i; ulint n_owned; - ut_ad(page); ut_ad(!page_zip || page_is_comp(page)); ut_ad(slot_no > 0); @@ -1407,7 +1406,6 @@ page_dir_balance_slot( rec_t* old_rec; rec_t* new_rec; - ut_ad(page); ut_ad(!page_zip || page_is_comp(page)); ut_ad(slot_no > 0); diff --git a/storage/innobase/page/page0zip.c b/storage/innobase/page/page0zip.c index 7c04e0b9183..faa004be730 100644 --- a/storage/innobase/page/page0zip.c +++ b/storage/innobase/page/page0zip.c @@ -4739,7 +4739,6 @@ page_zip_parse_compress( ulint size; ulint trailer_size; - ut_ad(ptr && end_ptr); ut_ad(!page == !page_zip); if (UNIV_UNLIKELY(ptr + (2 + 2) > end_ptr)) { diff --git a/storage/innobase/rem/rem0rec.c b/storage/innobase/rem/rem0rec.c index f7252594c29..7f435a92489 100644 --- a/storage/innobase/rem/rem0rec.c +++ b/storage/innobase/rem/rem0rec.c @@ -791,8 +791,7 @@ rec_get_converted_size_comp_prefix_low( ulint extra_size; ulint data_size; ulint i; - ut_ad(index); - ut_ad(fields); + ut_ad(n_fields > 0); ut_ad(n_fields <= dict_index_get_n_fields(index)); ut_ad(!temp || extra); diff --git a/storage/innobase/row/row0merge.c b/storage/innobase/row/row0merge.c index 7d87d1f9c8f..a393254d145 100644 --- a/storage/innobase/row/row0merge.c +++ b/storage/innobase/row/row0merge.c @@ -807,14 +807,8 @@ row_merge_read_rec( ulint data_size; ulint avail_size; - ut_ad(block); - ut_ad(buf); ut_ad(b >= block[0]); ut_ad(b < block[1]); - ut_ad(index); - ut_ad(foffs); - ut_ad(mrec); - ut_ad(offsets); ut_ad(*offsets == 1 + REC_OFFS_HEADER_SIZE + dict_index_get_n_fields(index)); @@ -1175,12 +1169,6 @@ row_merge_read_clustered_index( trx->op_info = "reading clustered index"; - ut_ad(trx); - ut_ad(old_table); - ut_ad(new_table); - ut_ad(index); - ut_ad(files); - /* Create and initialize memory for record buffers */ merge_buf = mem_alloc(n_index * sizeof *merge_buf); diff --git a/storage/innobase/row/row0purge.c b/storage/innobase/row/row0purge.c index 9018582f5d6..5f3e4175544 100644 --- a/storage/innobase/row/row0purge.c +++ b/storage/innobase/row/row0purge.c @@ -751,9 +751,6 @@ row_purge( { ibool updated_extern; - ut_ad(node); - ut_ad(thr); - node->undo_rec = trx_purge_fetch_next_rec(&node->roll_ptr, &node->reservation, node->heap); diff --git a/storage/innobase/row/row0upd.c b/storage/innobase/row/row0upd.c index e7ac42a566f..4b23165cc59 100644 --- a/storage/innobase/row/row0upd.c +++ b/storage/innobase/row/row0upd.c @@ -1066,8 +1066,6 @@ row_upd_index_replace_new_col_vals_index_pos( ulint n_fields; const ulint zip_size = dict_table_zip_size(index->table); - ut_ad(index); - dtuple_set_info_bits(entry, update->info_bits); if (order_only) { @@ -1250,8 +1248,6 @@ row_upd_changes_ord_field_binary_func( ulint i; const dict_index_t* clust_index; - ut_ad(index); - ut_ad(update); ut_ad(thr); ut_ad(thr->graph); ut_ad(thr->graph->trx); diff --git a/storage/innobase/trx/trx0trx.c b/storage/innobase/trx/trx0trx.c index 2d585b7507f..151e70013f9 100644 --- a/storage/innobase/trx/trx0trx.c +++ b/storage/innobase/trx/trx0trx.c @@ -97,7 +97,6 @@ trx_create( trx_t* trx; ut_ad(mutex_own(&kernel_mutex)); - ut_ad(sess); trx = mem_alloc(sizeof(trx_t)); -- cgit v1.2.1 From 2bfe83adec576a27aed2d87ff65cebddc3430d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 20 Feb 2017 17:16:59 +0200 Subject: Remove a bogus Valgrind "suppression". fsp_init_file_page_low() does initialize all pages nowadays, even those in the InnoDB system tablespace. --- storage/innobase/buf/buf0buf.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'storage/innobase') diff --git a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c index 4963f1c30c3..a5e1c045b7b 100644 --- a/storage/innobase/buf/buf0buf.c +++ b/storage/innobase/buf/buf0buf.c @@ -2,6 +2,7 @@ Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. +Copyright (c) 2014, 2017, MariaDB Corporation. All Rights Reserved. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -2997,15 +2998,6 @@ buf_page_init( /* Set the state of the block */ buf_block_set_file_page(block, space, offset); -#ifdef UNIV_DEBUG_VALGRIND - if (!space) { - /* Silence valid Valgrind warnings about uninitialized - data being written to data files. There are some unused - bytes on some pages that InnoDB does not initialize. */ - UNIV_MEM_VALID(block->frame, UNIV_PAGE_SIZE); - } -#endif /* UNIV_DEBUG_VALGRIND */ - buf_block_init_low(block); block->lock_hash_val = lock_rec_hash(space, offset); -- cgit v1.2.1 From 978179a9d4933d3d8d2ac99028798e8a07095dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 20 Feb 2017 17:58:42 +0200 Subject: MDEV-11520 Extending an InnoDB data file unnecessarily allocates a large memory buffer on Windows fil_extend_space_to_desired_size(), os_file_set_size(): Use calloc() for memory allocation, and handle failures. Properly check the return status of posix_fallocate(). On Windows, instead of extending the file by at most 1 megabyte at a time, write a zero-filled page at the end of the file. According to the Microsoft blog post https://blogs.msdn.microsoft.com/oldnewthing/20110922-00/?p=9573 this will physically extend the file by writing zero bytes. (InnoDB never uses DeviceIoControl() to set the file sparse.) For innodb_plugin, port the XtraDB fix for MySQL Bug#56433 (introducing fil_system->file_extend_mutex). The bug was fixed differently in MySQL 5.6 (and MariaDB Server 10.0). --- storage/innobase/fil/fil0fil.c | 85 ++++++++++++++++++++++++------------ storage/innobase/include/sync0sync.h | 1 + storage/innobase/os/os0file.c | 82 ++++++++++++---------------------- 3 files changed, 85 insertions(+), 83 deletions(-) (limited to 'storage/innobase') diff --git a/storage/innobase/fil/fil0fil.c b/storage/innobase/fil/fil0fil.c index d7ac3dd14eb..195fa7adde9 100644 --- a/storage/innobase/fil/fil0fil.c +++ b/storage/innobase/fil/fil0fil.c @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2014, 2017, MariaDB Corporation. 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 @@ -248,6 +249,7 @@ the ib_logfiles form a 'space' and it is handled here */ struct fil_system_struct { #ifndef UNIV_HOTBACKUP mutex_t mutex; /*!< The mutex protecting the cache */ + mutex_t file_extend_mutex; #endif /* !UNIV_HOTBACKUP */ hash_table_t* spaces; /*!< The hash table of spaces in the system; they are hashed on the space @@ -1658,6 +1660,8 @@ fil_init( mutex_create(fil_system_mutex_key, &fil_system->mutex, SYNC_ANY_LATCH); + mutex_create(fil_system_mutex_key, + &fil_system->file_extend_mutex, SYNC_OUTER_ANY_LATCH); fil_system->spaces = hash_create(hash_size); fil_system->name_hash = hash_create(hash_size); @@ -4096,6 +4100,10 @@ fil_extend_space_to_desired_size( ulint page_size; ibool success = TRUE; + /* fil_system->file_extend_mutex is for http://bugs.mysql.com/56433 + to prevent concurrent fil_extend_space_to_desired_size() + while fil_system->mutex is temporarily released */ + mutex_enter(&fil_system->file_extend_mutex); fil_mutex_enter_and_prepare_for_io(space_id); space = fil_space_get_by_id(space_id); @@ -4107,6 +4115,7 @@ fil_extend_space_to_desired_size( *actual_size = space->size; mutex_exit(&fil_system->mutex); + mutex_exit(&fil_system->file_extend_mutex); return(TRUE); } @@ -4123,22 +4132,24 @@ fil_extend_space_to_desired_size( start_page_no = space->size; file_start_page_no = space->size - node->size; + mutex_exit(&fil_system->mutex); + #ifdef HAVE_POSIX_FALLOCATE if (srv_use_posix_fallocate) { ib_int64_t start_offset = start_page_no * page_size; ib_int64_t end_offset = (size_after_extend - start_page_no) * page_size; ib_int64_t desired_size = size_after_extend*page_size; + int err = posix_fallocate( + node->handle, start_offset, end_offset); - mutex_exit(&fil_system->mutex); + success = !err; - if (posix_fallocate(node->handle, start_offset, end_offset) == -1) { - fprintf(stderr, "InnoDB: Error: preallocating file " - "space for file \'%s\' failed. Current size " - " %lld, len %lld, desired size %lld\n", - node->name, start_offset, end_offset, desired_size); - success = FALSE; - } else { - success = TRUE; + if (!success) { + fprintf(stderr, + "InnoDB: Error: extending file %s" + " from %lld to %lld bytes" + " failed with error %d\n", + node->name, start_offset, end_offset, err); } mutex_enter(&fil_system->mutex); @@ -4154,14 +4165,25 @@ fil_extend_space_to_desired_size( } #endif +#ifdef _WIN32 + /* Write 1 page of zeroes at the desired end. */ + start_page_no = size_after_extend - 1; + buf_size = page_size; +#else /* Extend at most 64 pages at a time */ buf_size = ut_min(64, size_after_extend - start_page_no) * page_size; - buf2 = mem_alloc(buf_size + page_size); +#endif + buf2 = calloc(1, buf_size + page_size); + if (!buf2) { + fprintf(stderr, "InnoDB: Cannot allocate " ULINTPF + " bytes to extend file\n", + buf_size + page_size); + mutex_exit(&fil_system->file_extend_mutex); + return(FALSE); + } buf = ut_align(buf2, page_size); - memset(buf, 0, buf_size); - - while (start_page_no < size_after_extend) { + for (;;) { ulint n_pages = ut_min(buf_size / page_size, size_after_extend - start_page_no); @@ -4170,6 +4192,7 @@ fil_extend_space_to_desired_size( offset_low = ((start_page_no - file_start_page_no) % (4096 * ((1024 * 1024) / page_size))) * page_size; + #ifdef UNIV_HOTBACKUP success = os_file_write(node->name, node->handle, buf, offset_low, offset_high, @@ -4181,34 +4204,37 @@ fil_extend_space_to_desired_size( page_size * n_pages, NULL, NULL); #endif - if (success) { - node->size += n_pages; - space->size += n_pages; - os_has_said_disk_full = FALSE; - } else { - /* Let us measure the size of the file to determine - how much we were able to extend it */ + /* Let us measure the size of the file to determine + how much we were able to extend it */ - n_pages = ((ulint) - (os_file_get_size_as_iblonglong( - node->handle) - / page_size)) - node->size; + n_pages = (ulint) (os_file_get_size_as_iblonglong(node->handle) + / page_size); - node->size += n_pages; - space->size += n_pages; + mutex_enter(&fil_system->mutex); + ut_a(n_pages >= node->size); + + start_page_no += n_pages - node->size; + space->size += n_pages - node->size; + node->size = n_pages; + if (success) { + os_has_said_disk_full = FALSE; + } + + if (!success || start_page_no >= size_after_extend) { break; } - start_page_no += n_pages; + mutex_exit(&fil_system->mutex); } - mem_free(buf2); - + free(buf2); fil_node_complete_io(node, fil_system, OS_FILE_WRITE); +#ifdef HAVE_POSIX_FALLOCATE complete_io: +#endif /* HAVE_POSIX_FALLOCATE */ *actual_size = space->size; @@ -4228,6 +4254,7 @@ complete_io: printf("Extended %s to %lu, actual size %lu pages\n", space->name, size_after_extend, *actual_size); */ mutex_exit(&fil_system->mutex); + mutex_exit(&fil_system->file_extend_mutex); fil_flush(space_id); diff --git a/storage/innobase/include/sync0sync.h b/storage/innobase/include/sync0sync.h index bc8d0d27be3..f074ca2f189 100644 --- a/storage/innobase/include/sync0sync.h +++ b/storage/innobase/include/sync0sync.h @@ -675,6 +675,7 @@ or row lock! */ #define SYNC_BUF_BLOCK 146 /* Block mutex */ #define SYNC_BUF_FLUSH_LIST 145 /* Buffer flush list mutex */ #define SYNC_DOUBLEWRITE 140 +#define SYNC_OUTER_ANY_LATCH 136 #define SYNC_ANY_LATCH 135 #define SYNC_MEM_HASH 131 #define SYNC_MEM_POOL 130 diff --git a/storage/innobase/os/os0file.c b/storage/innobase/os/os0file.c index d792e7a61d8..72b9651f596 100644 --- a/storage/innobase/os/os0file.c +++ b/storage/innobase/os/os0file.c @@ -2,6 +2,7 @@ Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. +Copyright (c) 2012, 2017, MariaDB Corporation. All Rights Reserved. Portions of this file contain modifications contributed and copyrighted by Percona Inc.. Those modifications are @@ -2027,48 +2028,44 @@ os_file_set_size( ut_a(size == (size & 0xFFFFFFFF)); - current_size = 0; desired_size = (ib_int64_t)size + (((ib_int64_t)size_high) << 32); #ifdef HAVE_POSIX_FALLOCATE - if (srv_use_posix_fallocate) { - if (posix_fallocate(file, current_size, desired_size) == -1) { + if (srv_use_posix_fallocate) { + int err = posix_fallocate(file, 0, desired_size); + if (err) { fprintf(stderr, - "InnoDB: Error: preallocating data for" - " file %s failed at\n" - "InnoDB: offset 0 size %lld %lld. Operating system" - " error number %d.\n" - "InnoDB: Check that the disk is not full" - " or a disk quota exceeded.\n" - "InnoDB: Some operating system error numbers" - " are described at\n" - "InnoDB: " - REFMAN "operating-system-error-codes.html\n", - name, (long long)size_high, (long long)size, errno); - - return (FALSE); + "InnoDB: Error: preallocating %lld bytes for" + " file %s failed with error %d.\n", + desired_size, name, err); } - return (TRUE); + return(!err); } #endif +#ifdef _WIN32 + /* Write 1 page of zeroes at the desired end. */ + buf_size = UNIV_PAGE_SIZE; + current_size = desired_size - buf_size; +#else /* Write up to 1 megabyte at a time. */ buf_size = ut_min(64, (ulint) (desired_size / UNIV_PAGE_SIZE)) * UNIV_PAGE_SIZE; - buf2 = ut_malloc(buf_size + UNIV_PAGE_SIZE); + current_size = 0; +#endif + buf2 = calloc(1, buf_size + UNIV_PAGE_SIZE); + + if (!buf2) { + fprintf(stderr, "InnoDB: Cannot allocate " ULINTPF + " bytes to extend file\n", + buf_size + UNIV_PAGE_SIZE); + return(FALSE); + } /* Align the buffer for possible raw i/o */ buf = ut_align(buf2, UNIV_PAGE_SIZE); - /* Write buffer full of zeros */ - memset(buf, 0, buf_size); - - if (desired_size >= (ib_int64_t)(100 * 1024 * 1024)) { - - fprintf(stderr, "InnoDB: Progress in MB:"); - } - - while (current_size < desired_size) { + do { ulint n_bytes; if (desired_size - current_size < (ib_int64_t) buf_size) { @@ -2082,37 +2079,14 @@ os_file_set_size( (ulint)(current_size >> 32), n_bytes); if (!ret) { - ut_free(buf2); - goto error_handling; - } - - /* Print about progress for each 100 MB written */ - if ((ib_int64_t) (current_size + n_bytes) / (ib_int64_t)(100 * 1024 * 1024) - != current_size / (ib_int64_t)(100 * 1024 * 1024)) { - - fprintf(stderr, " %lu00", - (ulong) ((current_size + n_bytes) - / (ib_int64_t)(100 * 1024 * 1024))); + break; } current_size += n_bytes; - } - - if (desired_size >= (ib_int64_t)(100 * 1024 * 1024)) { - - fprintf(stderr, "\n"); - } + } while (current_size < desired_size); - ut_free(buf2); - - ret = os_file_flush(file); - - if (ret) { - return(TRUE); - } - -error_handling: - return(FALSE); + free(buf2); + return(ret && os_file_flush(file)); } /***********************************************************************//** -- cgit v1.2.1 From 6de50b2c7fd3a956ef8e32f5a76a65fd7a10969a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 22 Feb 2017 09:17:30 +0200 Subject: MDEV-11520 post-fixes Remove the unused variable desired_size. Also, correct the expression for the posix_fallocate() start_offset, and actually test that it works with a multi-file system tablespace. Before MDEV-11520, the expression was wrong in both innodb_plugin and xtradb, in different ways. The start_offset formula was tested with the following: ./mtr --big-test --mysqld=--innodb-use-fallocate \ --mysqld=--innodb-data-file-path='ibdata1:5M;ibdata2:5M:autoextend' \ --parallel=auto --force --retry=0 --suite=innodb & ls -lsh mysql-test/var/*/mysqld.1/data/ibdata2 --- storage/innobase/fil/fil0fil.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'storage/innobase') diff --git a/storage/innobase/fil/fil0fil.c b/storage/innobase/fil/fil0fil.c index 195fa7adde9..d3b1d2bc1d9 100644 --- a/storage/innobase/fil/fil0fil.c +++ b/storage/innobase/fil/fil0fil.c @@ -4136,9 +4136,11 @@ fil_extend_space_to_desired_size( #ifdef HAVE_POSIX_FALLOCATE if (srv_use_posix_fallocate) { - ib_int64_t start_offset = start_page_no * page_size; - ib_int64_t end_offset = (size_after_extend - start_page_no) * page_size; - ib_int64_t desired_size = size_after_extend*page_size; + + ib_int64_t start_offset + = (start_page_no - file_start_page_no) * page_size; + ib_int64_t end_offset + = (size_after_extend - file_start_page_no) * page_size; int err = posix_fallocate( node->handle, start_offset, end_offset); -- cgit v1.2.1 From 365c4e971a684151762058befb27b54832dc8779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 22 Feb 2017 10:03:33 +0200 Subject: MDEV-11520/MDEV-5746 post-fix: Do not posix_fallocate() too much. Before the MDEV-11520 fixes, fil_extend_space_to_desired_size() in MariaDB Server 5.5 incorrectly passed the desired file size as the third argument to posix_fallocate(), even though the length of the extension should have been passed. This looks like a regression that was introduced in the 5.5 version of MDEV-5746. --- storage/innobase/fil/fil0fil.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'storage/innobase') diff --git a/storage/innobase/fil/fil0fil.c b/storage/innobase/fil/fil0fil.c index d3b1d2bc1d9..46338b079da 100644 --- a/storage/innobase/fil/fil0fil.c +++ b/storage/innobase/fil/fil0fil.c @@ -4136,13 +4136,11 @@ fil_extend_space_to_desired_size( #ifdef HAVE_POSIX_FALLOCATE if (srv_use_posix_fallocate) { - ib_int64_t start_offset = (start_page_no - file_start_page_no) * page_size; - ib_int64_t end_offset - = (size_after_extend - file_start_page_no) * page_size; - int err = posix_fallocate( - node->handle, start_offset, end_offset); + ib_int64_t len + = (size_after_extend - start_page_no) * page_size; + int err = posix_fallocate(node->handle, start_offset, len); success = !err; @@ -4151,7 +4149,8 @@ fil_extend_space_to_desired_size( "InnoDB: Error: extending file %s" " from %lld to %lld bytes" " failed with error %d\n", - node->name, start_offset, end_offset, err); + node->name, + start_offset, len + start_offset, err); } mutex_enter(&fil_system->mutex); -- cgit v1.2.1