~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/ha/ha0ha.c

  • Committer: lbieber
  • Date: 2010-10-06 16:34:16 UTC
  • mfrom: (1816.1.3 build)
  • Revision ID: lbieber@orisndriz08-20101006163416-ea0sl59qgpglk21y
Merge Monty - Change the requirement from either libinnodb to libhaildb. Also, tied it to version 2.2
Merge Andrew - fix bug 650935: remove --compress from all clients
Merge Andrew - fix bug 653471: Add -A to drizzle client
Merge Travis - 621861 = To change C structs to C++ classes in Drizzle

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, 2009, 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
31
31
#ifdef UNIV_DEBUG
32
32
# include "buf0buf.h"
33
33
#endif /* UNIV_DEBUG */
34
 
#include "btr0sea.h"
 
34
#ifdef UNIV_SYNC_DEBUG
 
35
# include "btr0sea.h"
 
36
#endif /* UNIV_SYNC_DEBUG */
35
37
#include "page0page.h"
36
38
 
37
39
/*************************************************************//**
77
79
#ifndef UNIV_HOTBACKUP
78
80
        hash_create_mutexes(table, n_mutexes, mutex_level);
79
81
 
80
 
        table->heaps = static_cast<mem_block_info_t **>(mem_alloc(n_mutexes * sizeof(mem_block_info_t *)));
 
82
        table->heaps = mem_alloc(n_mutexes * sizeof(void*));
81
83
 
82
84
        for (i = 0; i < n_mutexes; i++) {
83
85
                table->heaps[i] = mem_heap_create_in_btr_search(4096);
99
101
        ulint   i;
100
102
        ulint   n;
101
103
 
102
 
        ut_ad(table);
103
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
104
104
#ifdef UNIV_SYNC_DEBUG
105
105
        ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EXCLUSIVE));
106
106
#endif /* UNIV_SYNC_DEBUG */
125
125
/*************************************************************//**
126
126
Inserts an entry into a hash table. If an entry with the same fold number
127
127
is found, its node is updated to point to the new data, and no new node
128
 
is inserted. If btr_search_enabled is set to FALSE, we will only allow
129
 
updating existing nodes, but no new node is allowed to be added.
 
128
is inserted.
130
129
@return TRUE if succeed, FALSE if no more memory could be allocated */
131
130
UNIV_INTERN
132
131
ibool
147
146
        ha_node_t*      prev_node;
148
147
        ulint           hash;
149
148
 
150
 
        ut_ad(data);
151
 
        ut_ad(table);
152
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
 
149
        ut_ad(table && data);
153
150
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
154
151
        ut_a(block->frame == page_align(data));
155
152
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
159
156
 
160
157
        cell = hash_get_nth_cell(table, hash);
161
158
 
162
 
        prev_node = static_cast<ha_node_t *>(cell->node);
 
159
        prev_node = cell->node;
163
160
 
164
161
        while (prev_node != NULL) {
165
162
                if (prev_node->fold == fold) {
173
170
                                prev_block->n_pointers--;
174
171
                                block->n_pointers++;
175
172
                        }
176
 
                        ut_ad(!btr_search_fully_disabled);
177
173
# endif /* !UNIV_HOTBACKUP */
178
174
 
179
175
                        prev_node->block = block;
186
182
                prev_node = prev_node->next;
187
183
        }
188
184
 
189
 
        /* We are in the process of disabling hash index, do not add
190
 
        new chain node */
191
 
        if (!btr_search_enabled) {
192
 
                ut_ad(!btr_search_fully_disabled);
193
 
                return(TRUE);
194
 
        }
195
 
 
196
185
        /* We have to allocate a new chain node */
197
186
 
198
 
        node = static_cast<ha_node_t *>(mem_heap_alloc(hash_get_heap(table, fold), sizeof(ha_node_t)));
 
187
        node = mem_heap_alloc(hash_get_heap(table, fold), sizeof(ha_node_t));
199
188
 
200
189
        if (node == NULL) {
201
190
                /* It was a btr search type memory heap and at the moment
220
209
 
221
210
        node->next = NULL;
222
211
 
223
 
        prev_node = static_cast<ha_node_t *>(cell->node);
 
212
        prev_node = cell->node;
224
213
 
225
214
        if (prev_node == NULL) {
226
215
 
248
237
        hash_table_t*   table,          /*!< in: hash table */
249
238
        ha_node_t*      del_node)       /*!< in: node to be deleted */
250
239
{
251
 
        ut_ad(table);
252
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
253
240
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
254
241
# ifndef UNIV_HOTBACKUP
255
242
        if (table->adaptive) {
280
267
{
281
268
        ha_node_t*      node;
282
269
 
283
 
        ut_ad(table);
284
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
285
270
        ASSERT_HASH_MUTEX_OWN(table, fold);
286
271
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
287
272
        ut_a(new_block->frame == page_align(new_data));
319
304
{
320
305
        ha_node_t*      node;
321
306
 
322
 
        ut_ad(table);
323
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
324
307
        ASSERT_HASH_MUTEX_OWN(table, fold);
325
308
 
326
309
        node = ha_chain_get_first(table, fold);
354
337
#endif
355
338
}
356
339
 
357
 
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
358
340
/*************************************************************//**
359
341
Validates a given range of the cells in hash table.
360
342
@return TRUE if ok */
371
353
        ibool           ok      = TRUE;
372
354
        ulint           i;
373
355
 
374
 
        ut_ad(table);
375
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
376
356
        ut_a(start_index <= end_index);
377
357
        ut_a(start_index < hash_get_n_cells(table));
378
358
        ut_a(end_index < hash_get_n_cells(table));
401
381
 
402
382
        return(ok);
403
383
}
404
 
#endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */
405
384
 
406
385
/*************************************************************//**
407
386
Prints info of a hash table. */
412
391
        FILE*           file,   /*!< in: file where to print */
413
392
        hash_table_t*   table)  /*!< in: hash table */
414
393
{
415
 
        ut_ad(table);
416
 
        ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
417
394
#ifdef UNIV_DEBUG
418
395
/* Some of the code here is disabled for performance reasons in production
419
396
builds, see http://bugs.mysql.com/36941 */