~maria-captains/maria/xtradb-mergetree-5.5

« back to all changes in this revision

Viewing changes to ha/ha0ha.c

  • Committer: knielsen at knielsen-hq
  • Date: 2012-02-15 10:49:53 UTC
  • Revision ID: knielsen@knielsen-hq.org-20120215104953-wzcl57vil72bbmp1
Updated with XtraDB from Percona Server 5.5.20-24.1
Files copied from Percona-Server-5.5.20-rel24.1.tar.gz source tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1994, 2011, Oracle and/or its affiliates. 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
89
89
}
90
90
 
91
91
/*************************************************************//**
92
 
Empties a hash table and frees the memory heaps. */
93
 
UNIV_INTERN
94
 
void
95
 
ha_clear(
96
 
/*=====*/
97
 
        hash_table_t*   table)  /*!< in, own: hash table */
98
 
{
99
 
        ulint   i;
100
 
        ulint   n;
101
 
 
102
 
        ut_ad(table);
103
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
104
 
#ifdef UNIV_SYNC_DEBUG
105
 
        /* cannot identificate which btr_search_latch[i] for now */
106
 
        //ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EXCLUSIVE));
107
 
#endif /* UNIV_SYNC_DEBUG */
108
 
 
109
 
#ifndef UNIV_HOTBACKUP
110
 
        /* Free the memory heaps. */
111
 
        n = table->n_mutexes;
112
 
 
113
 
        for (i = 0; i < n; i++) {
114
 
                mem_heap_free(table->heaps[i]);
115
 
        }
116
 
#endif /* !UNIV_HOTBACKUP */
117
 
 
118
 
        /* Clear the hash table. */
119
 
        n = hash_get_n_cells(table);
120
 
 
121
 
        for (i = 0; i < n; i++) {
122
 
                hash_get_nth_cell(table, i)->node = NULL;
123
 
        }
124
 
}
125
 
 
126
 
/*************************************************************//**
127
92
Inserts an entry into a hash table. If an entry with the same fold number
128
93
is found, its node is updated to point to the new data, and no new node
129
94
is inserted. If btr_search_enabled is set to FALSE, we will only allow
141
106
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
142
107
        buf_block_t*    block,  /*!< in: buffer block containing the data */
143
108
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
144
 
        void*           data)   /*!< in: data, must not be NULL */
 
109
        const rec_t*    data)   /*!< in: data, must not be NULL */
145
110
{
146
111
        hash_cell_t*    cell;
147
112
        ha_node_t*      node;
154
119
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
155
120
        ut_a(block->frame == page_align(data));
156
121
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
 
122
#ifdef UNIV_SYNC_DEBUG
 
123
        ut_ad(rw_lock_own(block->btr_search_latch, RW_LOCK_EX));
 
124
#endif /* UNIV_SYNC_DEBUG */
157
125
        ASSERT_HASH_MUTEX_OWN(table, fold);
 
126
        ut_ad(btr_search_enabled);
158
127
 
159
128
        hash = hash_calc_hash(fold, table);
160
129
 
174
143
                                prev_block->n_pointers--;
175
144
                                block->n_pointers++;
176
145
                        }
177
 
                        ut_ad(!btr_search_fully_disabled);
178
146
# endif /* !UNIV_HOTBACKUP */
179
147
 
180
148
                        prev_node->block = block;
187
155
                prev_node = prev_node->next;
188
156
        }
189
157
 
190
 
        /* We are in the process of disabling hash index, do not add
191
 
        new chain node */
192
 
        if (!btr_search_enabled) {
193
 
                ut_ad(!btr_search_fully_disabled);
194
 
                return(TRUE);
195
 
        }
196
 
 
197
158
        /* We have to allocate a new chain node */
198
159
 
199
160
        node = mem_heap_alloc(hash_get_heap(table, fold), sizeof(ha_node_t));
251
212
{
252
213
        ut_ad(table);
253
214
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
 
215
#ifdef UNIV_SYNC_DEBUG
 
216
        //      ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX));
 
217
#endif /* UNIV_SYNC_DEBUG */
 
218
        ut_ad(btr_search_enabled);
254
219
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
255
220
# ifndef UNIV_HOTBACKUP
256
221
        if (table->adaptive) {
273
238
/*===============================*/
274
239
        hash_table_t*   table,  /*!< in/out: hash table */
275
240
        ulint           fold,   /*!< in: folded value of the searched data */
276
 
        void*           data,   /*!< in: pointer to the data */
 
241
        const rec_t*    data,   /*!< in: pointer to the data */
277
242
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
278
243
        buf_block_t*    new_block,/*!< in: block containing new_data */
279
244
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
280
 
        void*           new_data)/*!< in: new pointer to the data */
 
245
        const rec_t*    new_data)/*!< in: new pointer to the data */
281
246
{
282
247
        ha_node_t*      node;
283
248
 
287
252
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
288
253
        ut_a(new_block->frame == page_align(new_data));
289
254
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
 
255
#ifdef UNIV_SYNC_DEBUG
 
256
        //      ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX));
 
257
#endif /* UNIV_SYNC_DEBUG */
 
258
 
 
259
        if (!btr_search_enabled) {
 
260
                return;
 
261
        }
290
262
 
291
263
        node = ha_search_with_data(table, fold, data);
292
264
 
323
295
        ut_ad(table);
324
296
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
325
297
        ASSERT_HASH_MUTEX_OWN(table, fold);
 
298
#ifdef UNIV_SYNC_DEBUG
 
299
        //      ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX));
 
300
#endif /* UNIV_SYNC_DEBUG */
 
301
        ut_ad(btr_search_enabled);
326
302
 
327
303
        node = ha_chain_get_first(table, fold);
328
304