
#At lp:maria/5.2 based on revid:monty@mysql.com-20100810133508-50owjvs5b09m7vpk 2846 Michael Widenius 2010-08-11 [merge] Merge with 5.1 modified: mysql-test/suite/maria/r/maria.result mysql-test/suite/pbxt/r/range.result mysql-test/suite/pbxt/t/range.test mysys/my_sync.c storage/maria/ma_bitmap.c storage/maria/ma_blockrec.c storage/maria/ma_check.c storage/maria/ma_control_file.c storage/maria/maria_chk.c storage/maria/maria_read_log.c === modified file 'mysql-test/suite/maria/r/maria.result' --- a/mysql-test/suite/maria/r/maria.result 2010-08-07 15:03:04 +0000 +++ b/mysql-test/suite/maria/r/maria.result 2010-08-10 22:04:46 +0000 @@ -2139,7 +2139,7 @@ Data records: 0 D Block_size: 8192 Recordlength: 99 -table description: +Table description: Key Start Len Index Type 1 2 30 multip. varchar 2 33 30 multip. char NULL === modified file 'mysql-test/suite/pbxt/r/range.result' --- a/mysql-test/suite/pbxt/r/range.result 2010-05-06 12:43:19 +0000 +++ b/mysql-test/suite/pbxt/r/range.result 2010-08-10 16:06:34 +0000 @@ -420,19 +420,19 @@ analyze table t1,t2; Table Op Msg_type Msg_text test.t1 analyze status OK test.t2 analyze status OK -explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; +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 -explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0; +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 -explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; +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 -explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0; +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 === modified file 'mysql-test/suite/pbxt/t/range.test' --- a/mysql-test/suite/pbxt/t/range.test 2009-04-03 09:12:59 +0000 +++ b/mysql-test/suite/pbxt/t/range.test 2010-08-10 16:06:34 +0000 @@ -380,10 +380,13 @@ select count(*) from t2; analyze table t1,t2; -explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; -explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0; -explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; -explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0; +# 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 +explain select straight_join * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; +explain select straight_join * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0; +explain select straight_join * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; +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; select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; === modified file 'mysys/my_sync.c' --- a/mysys/my_sync.c 2010-08-09 17:54:58 +0000 +++ b/mysys/my_sync.c 2010-08-10 16:06:34 +0000 @@ -68,7 +68,7 @@ int my_sync(File fd, myf my_flags) res= fdatasync(fd); #elif defined(HAVE_FSYNC) res= fsync(fd); - if (res == -1 and errno == ENOLCK) + if (res == -1 && errno == ENOLCK) res= 0; /* Result Bug in Old FreeBSD */ #elif defined(__WIN__) res= _commit(fd); === modified file 'storage/maria/ma_bitmap.c' --- a/storage/maria/ma_bitmap.c 2009-01-12 11:12:00 +0000 +++ b/storage/maria/ma_bitmap.c 2010-08-10 21:58:08 +0000 @@ -2393,6 +2393,8 @@ my_bool _ma_bitmap_set(MARIA_HA *info, p uint bits; my_bool res; DBUG_ENTER("_ma_bitmap_set"); + DBUG_PRINT("enter", ("page: %lu head: %d empty_space: %u", + (ulong) page, head, empty_space)); pthread_mutex_lock(&info->s->bitmap.bitmap_lock); bits= (head ? === modified file 'storage/maria/ma_blockrec.c' --- a/storage/maria/ma_blockrec.c 2010-08-06 13:12:30 +0000 +++ b/storage/maria/ma_blockrec.c 2010-08-10 21:58:08 +0000 @@ -698,7 +698,8 @@ static void check_directory(uchar *buff, @brief Calculate if there is enough entries on the page */ -my_bool enough_free_entries(uchar *buff, uint block_size, uint wanted_entries) +static my_bool enough_free_entries(uchar *buff, uint block_size, + uint wanted_entries) { uint entries= (uint) buff[DIR_COUNT_OFFSET]; uint needed_free_entries, free_entry; @@ -723,6 +724,33 @@ my_bool enough_free_entries(uchar *buff, /** + @brief Check if there is room for more rows on page + + @fn enough_free_entries_on_page + + @return 0 Directory is full + @return 1 There is room for more entries on the page +*/ + +static my_bool enough_free_entries_on_page(MARIA_SHARE *share, + uchar *page_buff) +{ + enum en_page_type page_type; + page_type= (enum en_page_type) (page_buff[PAGE_TYPE_OFFSET] & + ~(uchar) PAGE_CAN_BE_COMPACTED); + + if (page_type == HEAD_PAGE) + { + uint row_count= (uint) page_buff[DIR_COUNT_OFFSET]; + return !(row_count == MAX_ROWS_PER_PAGE && + page_buff[DIR_FREE_OFFSET] == END_OF_DIR_FREE_LIST); + } + return enough_free_entries(page_buff, share->block_size, + 1 + share->base.blobs); +} + + +/** @brief Extend a record area to fit a given size block @fn extend_area_on_page() @@ -6106,6 +6134,9 @@ uint _ma_apply_redo_insert_row_head_or_t { /* Fix bitmap, just in case */ empty_space= uint2korr(buff + EMPTY_SPACE_OFFSET); + if (!enough_free_entries_on_page(share, buff)) + empty_space= 0; /* Page is full */ + if (_ma_bitmap_set(info, page, page_type == HEAD_PAGE, empty_space)) goto err; pagecache_unlock_by_link(share->pagecache, page_link.link, @@ -6178,6 +6209,8 @@ uint _ma_apply_redo_insert_row_head_or_t result= my_errno; /* Fix bitmap */ + if (!enough_free_entries_on_page(share, buff)) + empty_space= 0; /* Page is full */ if (_ma_bitmap_set(info, page, page_type == HEAD_PAGE, empty_space)) goto err; @@ -6265,6 +6298,8 @@ uint _ma_apply_redo_purge_row_head_or_ta if ((uint) (buff[PAGE_TYPE_OFFSET] & PAGE_TYPE_MASK) == page_type) { empty_space= uint2korr(buff+EMPTY_SPACE_OFFSET); + if (!enough_free_entries_on_page(share, buff)) + empty_space= 0; /* Page is full */ if (_ma_bitmap_set(info, page, page_type == HEAD_PAGE, empty_space)) goto err; @@ -6289,6 +6324,8 @@ uint _ma_apply_redo_purge_row_head_or_ta push_dynamic(&info->pinned_pages, (void*) &page_link); result= 0; + if (!enough_free_entries_on_page(share, buff)) + empty_space= 0; /* Page is full */ /* This will work even if the page was marked as UNALLOCATED_PAGE */ if (_ma_bitmap_set(info, page, page_type == HEAD_PAGE, empty_space)) result= my_errno; === modified file 'storage/maria/ma_check.c' --- a/storage/maria/ma_check.c 2010-08-07 14:42:30 +0000 +++ b/storage/maria/ma_check.c 2010-08-10 21:58:08 +0000 @@ -1929,8 +1929,8 @@ static int check_block_record(HA_CHECK * else _ma_check_print_error(param, "Page %9s: Wrong data in bitmap. Page_type: " - "%d empty_space: %u Bitmap-bits: %d", - llstr(page, llbuff), page_type, + "%d full: %d empty_space: %u Bitmap-bits: %d", + llstr(page, llbuff), full_dir, page_type, empty_space, bitmap_pattern); if (param->err_count++ > MAXERR || !(param->testflag & T_VERBOSE)) goto err; @@ -6762,7 +6762,7 @@ static void _ma_check_print_not_visible_ { _ma_check_print_warning(param, "Found row with transaction id %s but no " - "maria_control_file was specified. " + "maria_control_file was used or specified. " "The table may be corrupted", llstr(used_trid, buff)); } === modified file 'storage/maria/ma_control_file.c' --- a/storage/maria/ma_control_file.c 2008-11-04 10:54:04 +0000 +++ b/storage/maria/ma_control_file.c 2010-08-10 21:58:08 +0000 @@ -398,7 +398,7 @@ CONTROL_FILE_ERROR ma_control_file_open( } new_block_size= uint2korr(buffer + CF_BLOCKSIZE_OFFSET); - if (new_block_size != maria_block_size) + if (new_block_size != maria_block_size && maria_block_size) { error= CONTROL_FILE_WRONG_BLOCKSIZE; sprintf(errmsg_buff, @@ -407,6 +407,7 @@ CONTROL_FILE_ERROR ma_control_file_open( errmsg= errmsg_buff; goto err; } + maria_block_size= new_block_size; if (my_checksum(0, buffer, new_cf_create_time_size - CF_CHECKSUM_SIZE) != uint4korr(buffer + new_cf_create_time_size - CF_CHECKSUM_SIZE)) === modified file 'storage/maria/maria_chk.c' --- a/storage/maria/maria_chk.c 2010-08-07 12:27:23 +0000 +++ b/storage/maria/maria_chk.c 2010-08-10 22:04:46 +0000 @@ -71,6 +71,14 @@ static const char *record_formats[]= "Fixed length", "Packed", "Compressed", "Block", "?" }; +static const char *bitmap_description[]= +{ + "Empty page", "Part filled head page","Part filled head page", + "Part filled head page", "Full head page", + "Part filled tail page","Part filled tail page", + "Full tail or blob page" +}; + static const char *maria_stats_method_str="nulls_unequal"; static char default_open_errmsg[]= "%d when opening MARIA-table '%s'"; static char default_close_errmsg[]= "%d when closing MARIA-table '%s'"; @@ -106,7 +114,9 @@ int main(int argc, char **argv) error=0; maria_init(); - if (ma_control_file_open(FALSE, opt_require_control_file) && + maria_block_size= 0; /* Use block size from control file */ + if (ma_control_file_open(FALSE, opt_require_control_file || + !(check_param.testflag & T_SILENT)) && (opt_require_control_file || (opt_transaction_logging && (check_param.testflag & T_REP_ANY)))) { @@ -1516,7 +1526,7 @@ static void descript(HA_CHECK *param, re printf("Using only keys '%s' of %d possibly keys\n", buff, share->base.keys); } - puts("\ntable description:"); + puts("\nTable description:"); printf("Key Start Len Index Type"); if (param->testflag & T_VERBOSE) printf(" Rec/key Root Blocksize"); @@ -1658,6 +1668,14 @@ static void descript(HA_CHECK *param, re } VOID(putchar('\n')); } + if (share->data_file_type == BLOCK_RECORD) + { + uint i; + puts("\nBitmap Data size Description"); + for (i=0 ; i <= 7 ; i++) + printf("%u %5u %s\n", i, share->bitmap.sizes[i], + bitmap_description[i]); + } } DBUG_VOID_RETURN; } /* describe */ === modified file 'storage/maria/maria_read_log.c' --- a/storage/maria/maria_read_log.c 2010-08-05 15:59:44 +0000 +++ b/storage/maria/maria_read_log.c 2010-08-10 21:58:08 +0000 @@ -56,6 +56,7 @@ int main(int argc, char **argv) fprintf(stderr, "Can't init Maria engine (%d)\n", errno); goto err; } + maria_block_size= 0; /* Use block size from file */ /* we don't want to create a control file, it MUST exist */ if (ma_control_file_open(FALSE, TRUE)) { @@ -68,7 +69,7 @@ int main(int argc, char **argv) goto err; } if (init_pagecache(maria_pagecache, opt_page_buffer_size, 0, 0, - TRANSLOG_PAGE_SIZE, MY_WME) == 0) + maria_block_size, MY_WME) == 0) { fprintf(stderr, "Got error in init_pagecache() (errno: %d)\n", errno); goto err;