diff options
author | Michael Widenius <monty@mysql.com> | 2010-08-11 01:04:46 +0300 |
---|---|---|
committer | Michael Widenius <monty@mysql.com> | 2010-08-11 01:04:46 +0300 |
commit | 99b79db5dca6909456a40d859298ba3992b145da (patch) | |
tree | 5144cf8f645c01c403a72e14e5087b991fecef21 | |
parent | f458432f6869a329d4f0db2c3ff26accee5148a8 (diff) | |
parent | e6cf286b5dcebc78332cdf05d6e20d9ae39d1875 (diff) | |
download | mariadb-git-99b79db5dca6909456a40d859298ba3992b145da.tar.gz |
Merge with 5.1
-rw-r--r-- | mysql-test/suite/maria/r/maria.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/pbxt/r/range.result | 8 | ||||
-rw-r--r-- | mysql-test/suite/pbxt/t/range.test | 11 | ||||
-rw-r--r-- | mysys/my_sync.c | 2 | ||||
-rw-r--r-- | storage/maria/ma_bitmap.c | 2 | ||||
-rw-r--r-- | storage/maria/ma_blockrec.c | 39 | ||||
-rw-r--r-- | storage/maria/ma_check.c | 6 | ||||
-rw-r--r-- | storage/maria/ma_control_file.c | 3 | ||||
-rw-r--r-- | storage/maria/maria_chk.c | 22 | ||||
-rw-r--r-- | storage/maria/maria_read_log.c | 3 |
10 files changed, 80 insertions, 18 deletions
diff --git a/mysql-test/suite/maria/r/maria.result b/mysql-test/suite/maria/r/maria.result index 7616f5dbff4..a56ae6ac401 100644 --- a/mysql-test/suite/maria/r/maria.result +++ b/mysql-test/suite/maria/r/maria.result @@ -2139,7 +2139,7 @@ Data records: 0 Deleted blocks: 0 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 diff --git a/mysql-test/suite/pbxt/r/range.result b/mysql-test/suite/pbxt/r/range.result index 4d5e0c4ab64..2439489581a 100644 --- a/mysql-test/suite/pbxt/r/range.result +++ b/mysql-test/suite/pbxt/r/range.result @@ -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 diff --git a/mysql-test/suite/pbxt/t/range.test b/mysql-test/suite/pbxt/t/range.test index 8615c76888d..2e4e2b7da12 100644 --- a/mysql-test/suite/pbxt/t/range.test +++ b/mysql-test/suite/pbxt/t/range.test @@ -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; diff --git a/mysys/my_sync.c b/mysys/my_sync.c index cb0f5794b2e..a2b615a8661 100644 --- a/mysys/my_sync.c +++ b/mysys/my_sync.c @@ -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); diff --git a/storage/maria/ma_bitmap.c b/storage/maria/ma_bitmap.c index 882c6e4cd06..70617160d03 100644 --- a/storage/maria/ma_bitmap.c +++ b/storage/maria/ma_bitmap.c @@ -2393,6 +2393,8 @@ my_bool _ma_bitmap_set(MARIA_HA *info, pgcache_page_no_t page, my_bool head, 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 ? diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index e3210fff860..f62a4e2ce6d 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -698,7 +698,8 @@ static void check_directory(uchar *buff, uint block_size, uint min_row_length) @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, uint block_size, uint wanted_entries) /** + @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_tail(MARIA_HA *info, LSN lsn, { /* 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_tail(MARIA_HA *info, LSN lsn, 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_tail(MARIA_HA *info, LSN lsn, 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_tail(MARIA_HA *info, LSN lsn, 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; diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 2a19b5e9075..28b808cf27e 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -1929,8 +1929,8 @@ static int check_block_record(HA_CHECK *param, MARIA_HA *info, int extend, 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_error(HA_CHECK *param, TrID used_trid) { _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)); } diff --git a/storage/maria/ma_control_file.c b/storage/maria/ma_control_file.c index 1e1fc34c77e..ac246f09337 100644 --- a/storage/maria/ma_control_file.c +++ b/storage/maria/ma_control_file.c @@ -398,7 +398,7 @@ CONTROL_FILE_ERROR ma_control_file_open(my_bool create_if_missing, } 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(my_bool create_if_missing, 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)) diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c index 35f7f0f6c29..511488b977a 100644 --- a/storage/maria/maria_chk.c +++ b/storage/maria/maria_chk.c @@ -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, register MARIA_HA *info, char *name) 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, register MARIA_HA *info, char *name) } 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 */ diff --git a/storage/maria/maria_read_log.c b/storage/maria/maria_read_log.c index a526eede4d7..1002260afe5 100644 --- a/storage/maria/maria_read_log.c +++ b/storage/maria/maria_read_log.c @@ -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; |