~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/btr/btr0sea.c

Merge initial InnoDB+ import.

This was applied by generating a patch between MySQL 5.1.50 InnoDB plugin and
the just-merged innodb+ from mysql-trunk revision-id: vasil.dimov@oracle.com-20100422110752-1zowoqxel5xx3z2e

Then, some manual merge resolving and it worked. This should make it much
easier to merge the rest of InnoDB 1.1 and 1.2 from the mysql tree using
my bzr-reapply script.

This takes us to InnoDB 1.1.1(ish).

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
/** Flag: has the search system been enabled?
47
47
Protected by btr_search_latch and btr_search_enabled_mutex. */
48
48
UNIV_INTERN bool                btr_search_enabled = TRUE;
49
 
UNIV_INTERN ibool               btr_search_fully_disabled = FALSE;
50
49
 
51
50
/** Mutex protecting btr_search_enabled */
52
51
static mutex_t                  btr_search_enabled_mutex;
83
82
/** The adaptive hash index */
84
83
UNIV_INTERN btr_search_sys_t*   btr_search_sys;
85
84
 
 
85
#ifdef UNIV_PFS_RWLOCK
 
86
/* Key to register btr_search_sys with performance schema */
 
87
UNIV_INTERN mysql_pfs_key_t     btr_search_latch_key;
 
88
#endif /* UNIV_PFS_RWLOCK */
 
89
 
86
90
/** If the number of records on the page divided by this parameter
87
91
would have been successfully accessed using a hash index, the index
88
92
is then built on the page, assuming the global limit has been reached */
141
145
        be enough free space in the hash table. */
142
146
 
143
147
        if (heap->free_block == NULL) {
144
 
                buf_block_t*    block = buf_block_alloc(0);
 
148
                buf_block_t*    block = buf_block_alloc(NULL, 0);
145
149
 
146
150
                rw_lock_x_lock(&btr_search_latch);
147
151
 
168
172
 
169
173
        btr_search_latch_temp = mem_alloc(sizeof(rw_lock_t));
170
174
 
171
 
        rw_lock_create(&btr_search_latch, SYNC_SEARCH_SYS);
172
 
        mutex_create(&btr_search_enabled_mutex, SYNC_SEARCH_SYS_CONF);
 
175
        rw_lock_create(btr_search_latch_key, &btr_search_latch,
 
176
                       SYNC_SEARCH_SYS);
 
177
        mutex_create(btr_search_enabled_mutex_key,
 
178
                     &btr_search_enabled_mutex, SYNC_SEARCH_SYS_CONF);
173
179
 
174
180
        btr_search_sys = mem_alloc(sizeof(btr_search_sys_t));
175
181
 
183
189
btr_search_sys_free(void)
184
190
/*=====================*/
185
191
{
186
 
        rw_lock_free(&btr_search_latch);
187
192
        mem_free(btr_search_latch_temp);
188
193
        btr_search_latch_temp = NULL;
189
194
        mem_heap_free(btr_search_sys->hash_index->heap);
202
207
        mutex_enter(&btr_search_enabled_mutex);
203
208
        rw_lock_x_lock(&btr_search_latch);
204
209
 
205
 
        /* Disable access to hash index, also tell ha_insert_for_fold()
206
 
        stop adding new nodes to hash index, but still allow updating
207
 
        existing nodes */
208
210
        btr_search_enabled = FALSE;
209
211
 
210
212
        /* Clear all block->is_hashed flags and remove all entries
211
213
        from btr_search_sys->hash_index. */
212
214
        buf_pool_drop_hash_index();
213
215
 
214
 
        /* hash index has been cleaned up, disallow any operation to
215
 
        the hash index */
216
 
        btr_search_fully_disabled = TRUE;
217
 
 
218
216
        /* btr_search_enabled_mutex should guarantee this. */
219
217
        ut_ad(!btr_search_enabled);
220
218
 
233
231
        rw_lock_x_lock(&btr_search_latch);
234
232
 
235
233
        btr_search_enabled = TRUE;
236
 
        btr_search_fully_disabled = FALSE;
237
234
 
238
235
        rw_lock_x_unlock(&btr_search_latch);
239
236
        mutex_exit(&btr_search_enabled_mutex);
823
820
                                        RW_S_LATCH, RW_X_LATCH, or 0 */
824
821
        mtr_t*          mtr)            /*!< in: mtr */
825
822
{
 
823
        buf_pool_t*     buf_pool;
826
824
        buf_block_t*    block;
827
825
        rec_t*          rec;
828
826
        ulint           fold;
981
979
 
982
980
        /* Increment the page get statistics though we did not really
983
981
        fix the page: for user info only */
984
 
 
 
982
        buf_pool = buf_pool_from_bpage(&block->page);
985
983
        buf_pool->stat.n_page_gets++;
986
984
 
987
985
        return(TRUE);
1372
1370
 
1373
1371
        rw_lock_x_lock(&btr_search_latch);
1374
1372
 
1375
 
        if (UNIV_UNLIKELY(btr_search_fully_disabled)) {
 
1373
        if (UNIV_UNLIKELY(!btr_search_enabled)) {
1376
1374
                goto exit_func;
1377
1375
        }
1378
1376
 
1758
1756
        rec_offs_init(offsets_);
1759
1757
 
1760
1758
        rw_lock_x_lock(&btr_search_latch);
1761
 
        buf_pool_mutex_enter();
 
1759
        buf_pool_mutex_enter_all();
1762
1760
 
1763
1761
        cell_count = hash_get_n_cells(btr_search_sys->hash_index);
1764
1762
 
1766
1764
                /* We release btr_search_latch every once in a while to
1767
1765
                give other queries a chance to run. */
1768
1766
                if ((i != 0) && ((i % chunk_size) == 0)) {
1769
 
                        buf_pool_mutex_exit();
 
1767
                        buf_pool_mutex_exit_all();
1770
1768
                        rw_lock_x_unlock(&btr_search_latch);
1771
1769
                        os_thread_yield();
1772
1770
                        rw_lock_x_lock(&btr_search_latch);
1773
 
                        buf_pool_mutex_enter();
 
1771
                        buf_pool_mutex_enter_all();
1774
1772
                }
1775
1773
 
1776
1774
                node = hash_get_nth_cell(btr_search_sys->hash_index, i)->node;
1779
1777
                        const buf_block_t*      block
1780
1778
                                = buf_block_align(node->data);
1781
1779
                        const buf_block_t*      hash_block;
 
1780
                        buf_pool_t*             buf_pool;
 
1781
 
 
1782
                        buf_pool = buf_pool_from_bpage((buf_page_t*) block);
1782
1783
 
1783
1784
                        if (UNIV_LIKELY(buf_block_get_state(block)
1784
1785
                                        == BUF_BLOCK_FILE_PAGE)) {
1789
1790
                                (BUF_BLOCK_REMOVE_HASH, see the
1790
1791
                                assertion and the comment below) */
1791
1792
                                hash_block = buf_block_hash_get(
 
1793
                                        buf_pool,
1792
1794
                                        buf_block_get_space(block),
1793
1795
                                        buf_block_get_page_no(block));
1794
1796
                        } else {
1877
1879
                /* We release btr_search_latch every once in a while to
1878
1880
                give other queries a chance to run. */
1879
1881
                if (i != 0) {
1880
 
                        buf_pool_mutex_exit();
 
1882
                        buf_pool_mutex_exit_all();
1881
1883
                        rw_lock_x_unlock(&btr_search_latch);
1882
1884
                        os_thread_yield();
1883
1885
                        rw_lock_x_lock(&btr_search_latch);
1884
 
                        buf_pool_mutex_enter();
 
1886
                        buf_pool_mutex_enter_all();
1885
1887
                }
1886
1888
 
1887
1889
                if (!ha_validate(btr_search_sys->hash_index, i, end_index)) {
1889
1891
                }
1890
1892
        }
1891
1893
 
1892
 
        buf_pool_mutex_exit();
 
1894
        buf_pool_mutex_exit_all();
1893
1895
        rw_lock_x_unlock(&btr_search_latch);
1894
1896
        if (UNIV_LIKELY_NULL(heap)) {
1895
1897
                mem_heap_free(heap);