~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/btr/btr0btr.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 1994, 2010, Innobase Oy. All Rights Reserved.
 
3
Copyright (C) 1994, 2010, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
619
619
        ut_ad(dict_index_get_page(index) != page_no);
620
620
 
621
621
        level = btr_page_get_level(btr_cur_get_page(cursor), mtr);
 
622
 
622
623
        user_rec = btr_cur_get_rec(cursor);
623
624
        ut_a(page_rec_is_user_rec(user_rec));
624
625
        tuple = dict_index_build_node_ptr(index, user_rec, 0, heap, level);
734
735
        ulint           space,  /*!< in: space where created */
735
736
        ulint           zip_size,/*!< in: compressed page size in bytes
736
737
                                or 0 for uncompressed pages */
737
 
        dulint          index_id,/*!< in: index id */
 
738
        index_id_t      index_id,/*!< in: index id */
738
739
        dict_index_t*   index,  /*!< in: index */
739
740
        mtr_t*          mtr)    /*!< in: mini-transaction handle */
740
741
{
930
931
        ut_a(btr_root_fseg_validate(header, space));
931
932
#endif /* UNIV_BTR_DEBUG */
932
933
 
933
 
        while (!fseg_free_step(header, mtr));
 
934
        while (!fseg_free_step(header, mtr)) {};
934
935
}
935
936
#endif /* !UNIV_HOTBACKUP */
936
937
 
949
950
        dict_index_t*   index,  /*!< in: record descriptor */
950
951
        mtr_t*          mtr)    /*!< in: mtr */
951
952
{
 
953
        buf_pool_t*     buf_pool        = buf_pool_from_bpage(&block->page);
952
954
        page_t*         page            = buf_block_get_frame(block);
953
955
        page_zip_des_t* page_zip        = buf_block_get_page_zip(block);
954
956
        buf_block_t*    temp_block;
979
981
        log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE);
980
982
 
981
983
#ifndef UNIV_HOTBACKUP
982
 
        temp_block = buf_block_alloc(0);
 
984
        temp_block = buf_block_alloc(buf_pool, 0);
983
985
#else /* !UNIV_HOTBACKUP */
984
986
        ut_ad(block == back_block1);
985
987
        temp_block = back_block2;
1016
1018
                /* In crash recovery, dict_index_is_sec_or_ibuf() always
1017
1019
                returns TRUE, even for clustered indexes.  max_trx_id is
1018
1020
                unused in clustered index pages. */
1019
 
                ut_ad(!ut_dulint_is_zero(max_trx_id) || recovery);
 
1021
                ut_ad(max_trx_id != 0 || recovery);
1020
1022
        }
1021
1023
 
1022
1024
        if (UNIV_LIKELY_NULL(page_zip)
1118
1120
btr_parse_page_reorganize(
1119
1121
/*======================*/
1120
1122
        byte*           ptr,    /*!< in: buffer */
1121
 
        byte*           end_ptr __attribute__((unused)),
 
1123
        byte*           /*end_ptr __attribute__((unused))*/,
1122
1124
                                /*!< in: buffer end */
1123
1125
        dict_index_t*   index,  /*!< in: record descriptor */
1124
1126
        buf_block_t*    block,  /*!< in: page to be reorganized, or NULL */
1895
1897
        buf_block_t*    left_block;
1896
1898
        buf_block_t*    right_block;
1897
1899
        buf_block_t*    insert_block;
1898
 
        page_t*         insert_page;
1899
1900
        page_cur_t*     page_cursor;
1900
1901
        rec_t*          first_rec;
1901
1902
        byte*           buf = 0; /* remove warning */
1937
1938
        if (n_iterations > 0) {
1938
1939
                direction = FSP_UP;
1939
1940
                hint_page_no = page_no + 1;
1940
 
                split_rec = btr_page_get_split_rec(cursor, tuple, n_ext);
 
1941
                split_rec = btr_page_get_split_rec(cursor, tuple, n_ext);
1941
1942
 
1942
1943
                if (UNIV_UNLIKELY(split_rec == NULL)) {
1943
1944
                        insert_left = btr_page_tuple_smaller(
1946
1947
        } else if (btr_page_get_split_rec_to_right(cursor, &split_rec)) {
1947
1948
                direction = FSP_UP;
1948
1949
                hint_page_no = page_no + 1;
1949
 
 
1950
1950
        } else if (btr_page_get_split_rec_to_left(cursor, &split_rec)) {
1951
1951
                direction = FSP_DOWN;
1952
1952
                hint_page_no = page_no - 1;
1953
 
                ut_ad(split_rec);
 
1953
                ut_ad(split_rec);
1954
1954
        } else {
1955
1955
                direction = FSP_UP;
1956
1956
                hint_page_no = page_no + 1;
1957
 
 
1958
1957
                /* If there is only one record in the index page, we
1959
1958
                can't split the node in the middle by default. We need
1960
1959
                to determine whether the new record will be inserted
1961
1960
                to the left or right. */
1962
1961
 
1963
1962
                if (page_get_n_recs(page) > 1) {
1964
 
                        split_rec = page_get_middle_rec(page);
 
1963
                  split_rec = page_get_middle_rec(page);
1965
1964
                } else if (btr_page_tuple_smaller(cursor, tuple,
1966
1965
                                                  offsets, n_uniq, &heap)) {
1967
1966
                        split_rec = page_rec_get_next(
2007
2006
insert_empty:
2008
2007
                ut_ad(!split_rec);
2009
2008
                ut_ad(!insert_left);
2010
 
                buf = mem_alloc(rec_get_converted_size(cursor->index,
2011
 
                                                       tuple, n_ext));
 
2009
                buf = (unsigned char *)mem_alloc(rec_get_converted_size(cursor->index,
 
2010
                                                                        tuple, n_ext));
2012
2011
 
2013
2012
                first_rec = rec_convert_dtuple_to_rec(buf, cursor->index,
2014
2013
                                                      tuple, n_ext);
2047
2046
        }
2048
2047
 
2049
2048
        /* 5. Move then the records to the new page */
2050
 
        if (direction == FSP_DOWN
2051
 
#ifdef UNIV_BTR_AVOID_COPY
2052
 
            && page_rec_is_supremum(move_limit)) {
2053
 
                /* Instead of moving all records, make the new page
2054
 
                the empty page. */
2055
 
 
2056
 
                left_block = block;
2057
 
                right_block = new_block;
2058
 
        } else if (direction == FSP_DOWN
2059
 
#endif /* UNIV_BTR_AVOID_COPY */
2060
 
                   ) {
 
2049
        if (direction == FSP_DOWN) {
2061
2050
                /*              fputs("Split left\n", stderr); */
2062
2051
 
2063
2052
                if (0
2100
2089
                right_block = block;
2101
2090
 
2102
2091
                lock_update_split_left(right_block, left_block);
2103
 
#ifdef UNIV_BTR_AVOID_COPY
2104
 
        } else if (!split_rec) {
2105
 
                /* Instead of moving all records, make the new page
2106
 
                the empty page. */
2107
 
 
2108
 
                left_block = new_block;
2109
 
                right_block = block;
2110
 
#endif /* UNIV_BTR_AVOID_COPY */
2111
2092
        } else {
2112
2093
                /*              fputs("Split right\n", stderr); */
2113
2094
 
2171
2152
                insert_block = right_block;
2172
2153
        }
2173
2154
 
2174
 
        insert_page = buf_block_get_frame(insert_block);
2175
 
 
2176
2155
        /* 7. Reposition the cursor for insert and try insertion */
2177
2156
        page_cursor = btr_cur_get_page_cur(cursor);
2178
2157
 
2184
2163
 
2185
2164
#ifdef UNIV_ZIP_DEBUG
2186
2165
        {
 
2166
                page_t*         insert_page
 
2167
                        = buf_block_get_frame(insert_block);
 
2168
 
2187
2169
                page_zip_des_t* insert_page_zip
2188
2170
                        = buf_block_get_page_zip(insert_block);
 
2171
 
2189
2172
                ut_a(!insert_page_zip
2190
2173
                     || page_zip_validate(insert_page_zip, insert_page));
2191
2174
        }
2518
2501
 
2519
2502
        /* Go upward to root page, decrementing levels by one. */
2520
2503
        for (i = 0; i < n_blocks; i++, page_level++) {
2521
 
                page_t*         page    = buf_block_get_frame(blocks[i]);
 
2504
                page_t*         inner_page      = buf_block_get_frame(blocks[i]);
2522
2505
                page_zip_des_t* page_zip= buf_block_get_page_zip(blocks[i]);
2523
2506
 
2524
2507
                ut_ad(btr_page_get_level(page, mtr) == page_level + 1);
2525
2508
 
2526
 
                btr_page_set_level(page, page_zip, page_level, mtr);
 
2509
                btr_page_set_level(inner_page, page_zip, page_level, mtr);
2527
2510
#ifdef UNIV_ZIP_DEBUG
2528
 
                ut_a(!page_zip || page_zip_validate(page_zip, page));
 
2511
                ut_a(!page_zip || page_zip_validate(page_zip, inner_page));
2529
2512
#endif /* UNIV_ZIP_DEBUG */
2530
2513
        }
2531
2514
 
2578
2561
        ulint           n_recs;
2579
2562
        ulint           max_ins_size;
2580
2563
        ulint           max_ins_size_reorg;
2581
 
        ulint           level;
2582
2564
 
2583
2565
        block = btr_cur_get_block(cursor);
2584
2566
        page = btr_cur_get_page(cursor);
2588
2570
        ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
2589
2571
                                MTR_MEMO_X_LOCK));
2590
2572
        ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
2591
 
        level = btr_page_get_level(page, mtr);
2592
2573
        space = dict_index_get_space(index);
2593
2574
        zip_size = dict_table_zip_size(index->table);
2594
2575
 
2897
2878
                ibuf_reset_free_bits(block);
2898
2879
 
2899
2880
                if (page_is_leaf(buf_block_get_frame(block))) {
2900
 
                        ut_a(!ut_dulint_is_zero(max_trx_id));
 
2881
                        ut_a(max_trx_id);
2901
2882
                        page_set_max_trx_id(block,
2902
2883
                                            buf_block_get_page_zip(block),
2903
2884
                                            max_trx_id, mtr);