~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/ha/ha0ha.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

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
31
31
#ifdef UNIV_DEBUG
32
32
# include "buf0buf.h"
33
33
#endif /* UNIV_DEBUG */
34
 
#ifdef UNIV_SYNC_DEBUG
35
 
# include "btr0sea.h"
36
 
#endif /* UNIV_SYNC_DEBUG */
 
34
#include "btr0sea.h"
37
35
#include "page0page.h"
38
36
 
39
37
/*************************************************************//**
91
89
}
92
90
 
93
91
/*************************************************************//**
94
 
Empties a hash table and frees the memory heaps. */
95
 
UNIV_INTERN
96
 
void
97
 
ha_clear(
98
 
/*=====*/
99
 
        hash_table_t*   table)  /*!< in, own: hash table */
100
 
{
101
 
        ulint   i;
102
 
        ulint   n;
103
 
 
104
 
        ut_ad(table);
105
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
106
 
#ifdef UNIV_SYNC_DEBUG
107
 
        ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EXCLUSIVE));
108
 
#endif /* UNIV_SYNC_DEBUG */
109
 
 
110
 
#ifndef UNIV_HOTBACKUP
111
 
        /* Free the memory heaps. */
112
 
        n = table->n_mutexes;
113
 
 
114
 
        for (i = 0; i < n; i++) {
115
 
                mem_heap_free(table->heaps[i]);
116
 
        }
117
 
#endif /* !UNIV_HOTBACKUP */
118
 
 
119
 
        /* Clear the hash table. */
120
 
        n = hash_get_n_cells(table);
121
 
 
122
 
        for (i = 0; i < n; i++) {
123
 
                hash_get_nth_cell(table, i)->node = NULL;
124
 
        }
125
 
}
126
 
 
127
 
/*************************************************************//**
128
92
Inserts an entry into a hash table. If an entry with the same fold number
129
93
is found, its node is updated to point to the new data, and no new node
130
 
is inserted.
 
94
is inserted. If btr_search_enabled is set to FALSE, we will only allow
 
95
updating existing nodes, but no new node is allowed to be added.
131
96
@return TRUE if succeed, FALSE if no more memory could be allocated */
132
97
UNIV_INTERN
133
98
ibool
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(&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
 
243
212
{
244
213
        ut_ad(table);
245
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);
246
219
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
247
220
# ifndef UNIV_HOTBACKUP
248
221
        if (table->adaptive) {
265
238
/*===============================*/
266
239
        hash_table_t*   table,  /*!< in/out: hash table */
267
240
        ulint           fold,   /*!< in: folded value of the searched data */
268
 
        void*           data,   /*!< in: pointer to the data */
 
241
        const rec_t*    data,   /*!< in: pointer to the data */
269
242
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
270
243
        buf_block_t*    new_block,/*!< in: block containing new_data */
271
244
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
272
 
        void*           new_data)/*!< in: new pointer to the data */
 
245
        const rec_t*    new_data)/*!< in: new pointer to the data */
273
246
{
274
247
        ha_node_t*      node;
275
248
 
279
252
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
280
253
        ut_a(new_block->frame == page_align(new_data));
281
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
        }
282
262
 
283
263
        node = ha_search_with_data(table, fold, data);
284
264
 
315
295
        ut_ad(table);
316
296
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
317
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);
318
302
 
319
303
        node = ha_chain_get_first(table, fold);
320
304
 
347
331
#endif
348
332
}
349
333
 
 
334
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
350
335
/*************************************************************//**
351
336
Validates a given range of the cells in hash table.
352
337
@return TRUE if ok */
393
378
 
394
379
        return(ok);
395
380
}
 
381
#endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */
396
382
 
397
383
/*************************************************************//**
398
384
Prints info of a hash table. */