diff options
author | unknown <aivanov@mysql.com> | 2006-06-01 10:34:04 +0400 |
---|---|---|
committer | unknown <aivanov@mysql.com> | 2006-06-01 10:34:04 +0400 |
commit | f68500fa3864e45cba10e01fa45be77785235041 (patch) | |
tree | 6e3a741f3a17d4092daffffbb0e8e1e0f47ab029 /storage/innobase/btr/btr0btr.c | |
parent | 42c2c0b6a583d69fcb4282d150f53f2bee30ed32 (diff) | |
download | mariadb-git-f68500fa3864e45cba10e01fa45be77785235041.tar.gz |
Applied innodb-5.1-ss594 snapshot.
Fixed BUG#19542 "InnoDB doesn't increase the Handler_read_prev couter".
Fixed BUG#19609 "Case sensitivity of innodb_data_file_path gives stupid error".
Fixed BUG#19727 "InnoDB crashed server and crashed tables are ot recoverable".
Also:
* Remove remnants of the obsolete concept of memoryfixing tables and indexes.
* Remove unused dict_table_LRU_trim().
* Remove unused 'trx' parameter from dict_table_get_on_id_low(),
dict_table_get(), dict_table_get_and_increment_handle_count().
* Add a normal linked list implementation.
* Add a work queue implementation.
* Add 'level' parameter to mutex_create() and rw_lock_create().
Remove mutex_set_level() and rw_lock_set_level().
* Rename SYNC_LEVEL_NONE to SYNC_LEVEL_VARYING.
* Add support for bound ids in InnoDB's parser.
* Define UNIV_BTR_DEBUG for enabling consistency checks of
FIL_PAGE_NEXT and FIL_PAGE_PREV when accessing sibling
pages of B-tree indexes.
btr_validate_level(): Check the validity of the doubly linked
list formed by FIL_PAGE_NEXT and FIL_PAGE_PREV.
* Adapt InnoDB to the new tablename to filename encoding in MySQL 5.1.
ut_print_name(), ut_print_name1(): Add parameter 'table_id' for
distinguishing names of tables from other identifiers.
New: innobase_convert_from_table_id(), innobase_convert_from_id(),
innobase_convert_from_filename(), innobase_get_charset.
dict_accept(), dict_scan_id(), dict_scan_col(), dict_scan_table_name(),
dict_skip_word(), dict_create_foreign_constraints_low(): Add
parameter 'cs' so that isspace() can be replaced with my_isspace(),
whose operation depends on the connection character set.
dict_scan_id(): Convert identifier to UTF-8.
dict_str_starts_with_keyword(): New extern function, to replace
dict_accept() in row_search_for_mysql().
mysql_get_identifier_quote_char(): Replaced with innobase_print_identifier().
ha_innobase::create(): Remove the thd->convert_strin() call. Pass the
statement to InnoDB in the connection character set and let InnoDB
convert the identifier to UTF-8.
* Add max_row_size to dict_table_t.
* btr0cur.c
btr_copy_externally_stored_field(): Only set the 'offset' variable
when needed.
* buf0buf.c
buf_page_io_complete(): Write to the error log if the page number or
the space id o the disk do not match those in memory. Also write to
the error log if a page was read from the doublewrite buffer. The
doublewrite buffer should be only read by the lower-level function
fil_io() at database startup.
* dict0dict.c
dict_scan_table_name(): Remove fallback to differently encoded name
when the table is not found. The encoding is handled at a higher level.
* ha_innodb.cc
Increment statistic counter in ha_innobase::index_prev() (bug 19542).
Add innobase_convert_string wrapper function and a new file
ha_prototypes.h.
innobase_print_identifier(): Remove TODO comment before calling
get_quote_char_for_identifier(). That function apparently assumes
the identifier to be encoded in UTF-8.
* ibuf0ibuf.c|h
ibuf_count_get(), ibuf_counts[], ibuf_count_inited(): Define these
only #ifdef UNIV_IBUF_DEBUG. Previously, when compiled without
UNIV_IBUF_DEBUG, invoking ibuf_count_get() would crash InnoDB.
The function is only being called #ifdef UNIV_IBUF_DEBUG.
* innodb.result
Adjust the results for changes in the foreign key error messages.
* mem0mem.c|h
New: mem_heap_dup(), mem_heap_printf(), mem_heap_cat().
* os0file.c
Check the page trailers also after writing to disk. This improves
chances of diagnosing bug 18886.
os_file_check_page_trailers(): New function for checking that the
two copies of the LSN stamped on the page match.
os_aio_simulated_handle(): Call os_file_check_page_trailers()
before and after os_file_write().
* row0mysql.c
Move trx_commit_for_mysql(trx) calls before calls to
row_mysql_unlock_data_dictionary(trx) (bug 19727).
* row0sel.c
row_fetch_print(): Handle SQL NULL values without crashing.
row_sel_store_mysql_rec(): Remove useless call to rec_get_nth_field
when handling an externally stored column.
Fetch externally stored fields when using InnoDB's internal SQL
parser.
Optimize BLOB selects by using prebuilt->blob_heap directly instead
of first reading BLOB data to a temporary heap and then copying it
to prebuilt->blob_heap.
* srv0srv.c
srv_master_thread(): Remove unreachable code.
* srv0start.c
srv_parse_data_file_paths_and_sizes(): Accept lower-case 'm' and
'g' as abbreviations of megabyte and gigabyte (bug 19609).
srv_parse_megabytes(): New fuction.
* ut0dbg.c|h
Implement InnoDB assertions (ut_a and ut_error) with abort() when
the code is compiled with GCC 3 or later on other platforms than
Windows or Netware. Also disable the variable ut_dbg_stop_threads
and the function ut_dbg_stop_thread() i this case, unless
UNIV_SYC_DEBUG is defined. This should allow the compiler to
generate more compact code for assertions.
* ut0list.c|h
Add ib_list_create_heap().
mysql-test/r/innodb.result:
Applied innodb-5.1-ss594 snapshot.
mysql-test/t/innodb.test:
Copy the comment from the beginning of the file
to the end because MySQL developers continue
adding test cases to this file.
sql/ha_innodb.cc:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/CMakeLists.txt:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/Makefile.am:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/btr/btr0btr.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/btr/btr0cur.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/btr/btr0pcur.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/btr/btr0sea.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/buf/buf0buf.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/buf/buf0flu.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/data/data0type.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/dict/dict0crea.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/dict/dict0dict.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/dict/dict0load.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/dict/dict0mem.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/fil/fil0fil.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/ha/hash0hash.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/ibuf/ibuf0ibuf.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/data0type.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/dict0dict.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/dict0dict.ic:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/dict0mem.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/fil0fil.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/fsp0fsp.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/ibuf0ibuf.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/mem0mem.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/pars0pars.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/pars0sym.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/pars0types.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/rem0rec.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/row0purge.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/row0undo.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/srv0srv.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/sync0rw.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/sync0sync.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/univ.i:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/ut0dbg.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/ut0ut.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/lock/lock0lock.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/log/log0log.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/log/log0recv.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/mem/mem0dbg.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/mem/mem0mem.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/mem/mem0pool.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/os/os0file.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/os/os0thread.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/pars/lexyy.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/pars/pars0lex.l:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/pars/pars0pars.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/pars/pars0sym.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/row/row0ins.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/row/row0mysql.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/row/row0purge.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/row/row0row.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/row/row0sel.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/row/row0upd.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/srv/srv0srv.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/srv/srv0start.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/sync/sync0arr.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/sync/sync0rw.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/sync/sync0sync.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/thr/thr0loc.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/trx/trx0purge.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/trx/trx0rec.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/trx/trx0roll.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/trx/trx0rseg.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/trx/trx0sys.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/trx/trx0trx.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/ut/Makefile.am:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/ut/ut0dbg.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/ut/ut0ut.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/ha_prototypes.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/ut0list.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/ut0list.ic:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/include/ut0wqueue.h:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/ut/ut0list.c:
Applied innodb-5.1-ss594 snapshot.
storage/innobase/ut/ut0wqueue.c:
Applied innodb-5.1-ss594 snapshot.
Diffstat (limited to 'storage/innobase/btr/btr0btr.c')
-rw-r--r-- | storage/innobase/btr/btr0btr.c | 91 |
1 files changed, 72 insertions, 19 deletions
diff --git a/storage/innobase/btr/btr0btr.c b/storage/innobase/btr/btr0btr.c index 5e338f97982..ae3e722b513 100644 --- a/storage/innobase/btr/btr0btr.c +++ b/storage/innobase/btr/btr0btr.c @@ -190,6 +190,10 @@ btr_get_prev_user_rec( || (mtr_memo_contains(mtr, buf_block_align(prev_page), MTR_MEMO_PAGE_X_FIX))); ut_a(page_is_comp(prev_page) == page_is_comp(page)); +#ifdef UNIV_BTR_DEBUG + ut_a(btr_page_get_next(prev_page, mtr) + == buf_frame_get_page_no(page)); +#endif /* UNIV_BTR_DEBUG */ return(page_rec_get_prev(page_get_supremum_rec(prev_page))); } @@ -237,6 +241,10 @@ btr_get_next_user_rec( MTR_MEMO_PAGE_S_FIX)) || (mtr_memo_contains(mtr, buf_block_align(next_page), MTR_MEMO_PAGE_X_FIX))); +#ifdef UNIV_BTR_DEBUG + ut_a(btr_page_get_prev(next_page, mtr) + == buf_frame_get_page_no(page)); +#endif /* UNIV_BTR_DEBUG */ ut_a(page_is_comp(next_page) == page_is_comp(page)); return(page_rec_get_next(page_get_infimum_rec(next_page))); @@ -597,9 +605,9 @@ btr_page_get_father_for_rec( buf_page_print(buf_frame_align(node_ptr)); fputs("InnoDB: Corruption of an index tree: table ", stderr); - ut_print_name(stderr, NULL, index->table_name); + ut_print_name(stderr, NULL, TRUE, index->table_name); fputs(", index ", stderr); - ut_print_name(stderr, NULL, index->name); + ut_print_name(stderr, NULL, FALSE, index->name); fprintf(stderr, ",\n" "InnoDB: father ptr page no %lu, child page no %lu\n", (ulong) @@ -1518,6 +1526,10 @@ btr_attach_half_pages( prev_page = btr_page_get(space, prev_page_no, RW_X_LATCH, mtr); ut_a(page_is_comp(prev_page) == page_is_comp(page)); +#ifdef UNIV_BTR_DEBUG + ut_a(btr_page_get_next(prev_page, mtr) + == buf_frame_get_page_no(page)); +#endif /* UNIV_BTR_DEBUG */ btr_page_set_next(prev_page, lower_page_no, mtr); } @@ -1805,6 +1817,10 @@ btr_level_list_remove( prev_page = btr_page_get(space, prev_page_no, RW_X_LATCH, mtr); ut_a(page_is_comp(prev_page) == page_is_comp(page)); +#ifdef UNIV_BTR_DEBUG + ut_a(btr_page_get_next(prev_page, mtr) + == buf_frame_get_page_no(page)); +#endif /* UNIV_BTR_DEBUG */ btr_page_set_next(prev_page, next_page_no, mtr); } @@ -1813,6 +1829,10 @@ btr_level_list_remove( next_page = btr_page_get(space, next_page_no, RW_X_LATCH, mtr); ut_a(page_is_comp(next_page) == page_is_comp(page)); +#ifdef UNIV_BTR_DEBUG + ut_a(btr_page_get_prev(next_page, mtr) + == buf_frame_get_page_no(page)); +#endif /* UNIV_BTR_DEBUG */ btr_page_set_prev(next_page, prev_page_no, mtr); } @@ -2032,16 +2052,24 @@ btr_compress( /* Decide the page to which we try to merge and which will inherit the locks */ - if (left_page_no != FIL_NULL) { + is_left = left_page_no != FIL_NULL; + + if (is_left) { - is_left = TRUE; merge_page = btr_page_get(space, left_page_no, RW_X_LATCH, mtr); +#ifdef UNIV_BTR_DEBUG + ut_a(btr_page_get_next(merge_page, mtr) + == buf_frame_get_page_no(page)); +#endif /* UNIV_BTR_DEBUG */ } else if (right_page_no != FIL_NULL) { - is_left = FALSE; merge_page = btr_page_get(space, right_page_no, RW_X_LATCH, mtr); +#ifdef UNIV_BTR_DEBUG + ut_a(btr_page_get_prev(merge_page, mtr) + == buf_frame_get_page_no(page)); +#endif /* UNIV_BTR_DEBUG */ } else { /* The page is the only one on the level, lift the records to the father */ @@ -2203,7 +2231,6 @@ btr_discard_page( ulint left_page_no; ulint right_page_no; page_t* merge_page; - ibool is_left; page_t* page; rec_t* node_ptr; @@ -2223,13 +2250,19 @@ btr_discard_page( right_page_no = btr_page_get_next(page, mtr); if (left_page_no != FIL_NULL) { - is_left = TRUE; merge_page = btr_page_get(space, left_page_no, RW_X_LATCH, mtr); +#ifdef UNIV_BTR_DEBUG + ut_a(btr_page_get_next(merge_page, mtr) + == buf_frame_get_page_no(page)); +#endif /* UNIV_BTR_DEBUG */ } else if (right_page_no != FIL_NULL) { - is_left = FALSE; merge_page = btr_page_get(space, right_page_no, RW_X_LATCH, mtr); +#ifdef UNIV_BTR_DEBUG + ut_a(btr_page_get_prev(merge_page, mtr) + == buf_frame_get_page_no(page)); +#endif /* UNIV_BTR_DEBUG */ } else { btr_discard_only_page_on_level(tree, page, mtr); @@ -2256,11 +2289,11 @@ btr_discard_page( /* Remove the page from the level list */ btr_level_list_remove(tree, page, mtr); - if (is_left) { + if (left_page_no != FIL_NULL) { lock_update_discard(page_get_supremum_rec(merge_page), page); } else { lock_update_discard(page_rec_get_next( - page_get_infimum_rec(merge_page)), page); + page_get_infimum_rec(merge_page)), page); } /* Free the file page */ @@ -2745,7 +2778,29 @@ loop: rec_t* right_rec; right_page = btr_page_get(space, right_page_no, RW_X_LATCH, &mtr); - ut_a(page_is_comp(right_page) == page_is_comp(page)); + if (UNIV_UNLIKELY(btr_page_get_prev(right_page, &mtr) + != buf_frame_get_page_no(page))) { + btr_validate_report2(index, level, page, right_page); + fputs("InnoDB: broken FIL_PAGE_NEXT" + " or FIL_PAGE_PREV links\n", stderr); + buf_page_print(page); + buf_page_print(right_page); + + ret = FALSE; + } + + if (UNIV_UNLIKELY(page_is_comp(right_page) + != page_is_comp(page))) { + btr_validate_report2(index, level, page, right_page); + fputs("InnoDB: 'compact' flag mismatch\n", stderr); + buf_page_print(page); + buf_page_print(right_page); + + ret = FALSE; + + goto node_ptr_fails; + } + rec = page_rec_get_prev(page_get_supremum_rec(page)); right_rec = page_rec_get_next( page_get_infimum_rec(right_page)); @@ -2753,8 +2808,8 @@ loop: offsets, ULINT_UNDEFINED, &heap); offsets2 = rec_get_offsets(right_rec, index, offsets2, ULINT_UNDEFINED, &heap); - if (cmp_rec_rec(rec, right_rec, offsets, offsets2, index) - >= 0) { + if (UNIV_UNLIKELY(cmp_rec_rec(rec, right_rec, + offsets, offsets2, index) >= 0)) { btr_validate_report2(index, level, page, right_page); @@ -2869,10 +2924,7 @@ loop: ut_a(node_ptr == page_rec_get_prev( page_get_supremum_rec(father_page))); ut_a(btr_page_get_next(father_page, &mtr) == FIL_NULL); - } - - if (right_page_no != FIL_NULL) { - + } else { right_node_ptr = btr_page_get_father_node_ptr(tree, right_page, &mtr); if (page_rec_get_next(node_ptr) != @@ -2934,14 +2986,15 @@ loop: } node_ptr_fails: + /* Commit the mini-transaction to release the latch on 'page'. + Re-acquire the latch on right_page, which will become 'page' + on the next loop. The page has already been checked. */ mtr_commit(&mtr); if (right_page_no != FIL_NULL) { - ulint comp = page_is_comp(page); mtr_start(&mtr); page = btr_page_get(space, right_page_no, RW_X_LATCH, &mtr); - ut_a(page_is_comp(page) == comp); goto loop; } |