~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2000-2006 MySQL AB
2
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; version 2 of the License.
6
7
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
12
   You should have received a copy of the GNU General Public License
13
   along with this program; if not, write to the Free Software
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
1130.3.28 by Monty Taylor
Moved heapdef.h and myisamdef.h to *_priv.h for easier filtering for include guard check.
16
#include "heap_priv.h"
612.2.13 by Monty Taylor
Work on removing global.h from headers that should be installed.
17
18
#include <drizzled/common.h>
19
#include <drizzled/error.h>
20
21
#include <string.h>
1067.4.8 by Nathan Williams
Converted all usages of cmin/cmax in plugin directory to std::min/max.
22
#include <algorithm>
23
24
using namespace std;
1 by brian
clean slate
25
481 by Brian Aker
Remove all of uchar.
26
static int keys_compare(heap_rb_param *param, unsigned char *key1, unsigned char *key2);
482 by Brian Aker
Remove uint.
27
static void init_block(HP_BLOCK *block,uint32_t chunk_length, uint32_t min_records,
291 by Brian Aker
Head ulong conversion.
28
                        uint32_t max_records);
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
29
481 by Brian Aker
Remove all of uchar.
30
#define FIXED_REC_OVERHEAD (sizeof(unsigned char))
937.2.14 by Stewart Smith
align HEAP data structure for dynamic tables to SPARC alignment boundary.
31
#define VARIABLE_REC_OVERHEAD (sizeof(unsigned char**) + ALIGN_SIZE(sizeof(unsigned char)))
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
32
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
33
/* Minimum size that a chunk can take, 12 bytes on 32bit, 24 bytes on 64bit */
34
#define VARIABLE_MIN_CHUNK_SIZE \
481 by Brian Aker
Remove all of uchar.
35
        ((sizeof(unsigned char**) + VARIABLE_REC_OVERHEAD + sizeof(unsigned char**) - 1) & ~(sizeof(unsigned char**) - 1))
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
36
1 by brian
clean slate
37
38
/* Create a heap table */
39
482 by Brian Aker
Remove uint.
40
int heap_create(const char *name, uint32_t keys, HP_KEYDEF *keydef,
41
    uint32_t columns, HP_COLUMNDEF *columndef,
42
    uint32_t max_key_fieldnr, uint32_t key_part_size,
43
    uint32_t reclength, uint32_t keys_memory_size,
291 by Brian Aker
Head ulong conversion.
44
    uint32_t max_records, uint32_t min_records,
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
45
    HP_CREATE_INFO *create_info, HP_SHARE **res)
1 by brian
clean slate
46
{
482 by Brian Aker
Remove uint.
47
  uint32_t i, j, key_segs, max_length, length;
291 by Brian Aker
Head ulong conversion.
48
  uint32_t max_rows_for_stated_memory;
1 by brian
clean slate
49
  HP_SHARE *share= 0;
50
  HA_KEYSEG *keyseg;
51
52
  if (!create_info->internal_table)
53
  {
54
    pthread_mutex_lock(&THR_LOCK_heap);
55
    if ((share= hp_find_named_heap(name)) && share->open_count == 0)
56
    {
57
      hp_free(share);
58
      share= 0;
59
    }
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
60
  }
1 by brian
clean slate
61
62
  if (!share)
63
  {
942.1.11 by Monty Taylor
Fixed a coupla build things.
64
    size_t chunk_dataspace_length;
65
    uint32_t chunk_length, is_variable_size;
482 by Brian Aker
Remove uint.
66
    uint32_t fixed_data_length, fixed_column_count;
1 by brian
clean slate
67
    HP_KEYDEF *keyinfo;
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
68
69
    if (create_info->max_chunk_size)
70
    {
482 by Brian Aker
Remove uint.
71
      uint32_t configured_chunk_size= create_info->max_chunk_size;
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
72
73
      /* User requested variable-size records, let's see if they're possible */
74
75
      if (configured_chunk_size < key_part_size)
76
      {
77
        /* Eventual chunk_size cannot be smaller than key data,
78
           which allows all keys to fit into the first chunk */
79
        my_error(ER_CANT_USE_OPTION_HERE, MYF(0), "block_size");
80
        pthread_mutex_unlock(&THR_LOCK_heap);
81
        return(ER_CANT_USE_OPTION_HERE);
82
      }
83
84
      if ((reclength - configured_chunk_size) >= VARIABLE_MIN_CHUNK_SIZE<<1)
85
      {
86
        /* Allow variable size only if we're saving at least two smallest chunks */
87
        /* There has to be at least one field after indexed fields */
88
        /* Note that NULL bits are already included in key_part_size */
89
        is_variable_size= 1;
90
        chunk_dataspace_length= configured_chunk_size;
91
      }
92
      else
93
      {
94
        /* max_chunk_size is near the full reclength, let's use fixed size */
95
        is_variable_size= 0;
96
        chunk_dataspace_length= reclength;
97
      }
98
    }
99
    else if (create_info->is_dynamic)
100
    {
101
      /* User asked for dynamic records - use 256 as the chunk size */
102
      if ((key_part_size + VARIABLE_REC_OVERHEAD) > 256)
103
        chunk_dataspace_length= key_part_size;
104
      else
105
        chunk_dataspace_length= 256 - VARIABLE_REC_OVERHEAD;
106
107
      is_variable_size= 1;
108
    }
109
    else
110
    {
111
      /* if max_chunk_size is not specified, put the whole record in one chunk */
112
      is_variable_size= 0;
113
      chunk_dataspace_length= reclength;
114
    }
115
116
    if (is_variable_size)
117
    {
118
      /* Check whether we have any variable size records past key data */
482 by Brian Aker
Remove uint.
119
      uint32_t has_variable_fields= 0;
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
120
121
      fixed_data_length= key_part_size;
122
      fixed_column_count= max_key_fieldnr;
123
124
      for (i= max_key_fieldnr; i < columns; i++)
125
      {
126
        HP_COLUMNDEF* column= columndef + i;
127
        if (column->type == DRIZZLE_TYPE_VARCHAR && column->length >= 32)
128
        {
129
            /* The field has to be >= 5.0.3 true VARCHAR and have substantial length */
130
            /* TODO: do we want to calculate minimum length? */
131
            has_variable_fields= 1;
132
            break;
133
        }
134
135
        if (has_variable_fields)
136
        {
137
          break;
138
        }
139
140
        if ((column->offset + column->length) <= chunk_dataspace_length)
141
        {
142
          /* Still no variable-size columns, add one fixed-length */
143
          fixed_column_count= i + 1;
144
          fixed_data_length= column->offset + column->length;
145
        }
146
      }
147
148
      if (!has_variable_fields)
149
      {
150
        /* There is no need to use variable-size records without variable-size columns */
151
        /* Reset sizes if it's not variable size anymore */
152
        is_variable_size= 0;
153
        chunk_dataspace_length= reclength;
154
        fixed_data_length= reclength;
155
        fixed_column_count= columns;
156
      }
157
    }
158
    else
159
    {
160
      fixed_data_length= reclength;
161
      fixed_column_count= columns;
162
    }
163
1 by brian
clean slate
164
    /*
481 by Brian Aker
Remove all of uchar.
165
      We store unsigned char* del_link inside the data area of deleted records,
166
      so the data length should be at least sizeof(unsigned char*)
1 by brian
clean slate
167
    */
481 by Brian Aker
Remove all of uchar.
168
    set_if_bigger(chunk_dataspace_length, sizeof (unsigned char**));
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
169
170
    if (is_variable_size)
171
    {
172
      chunk_length= chunk_dataspace_length + VARIABLE_REC_OVERHEAD;
173
    }
174
    else
175
    {
176
      chunk_length= chunk_dataspace_length + FIXED_REC_OVERHEAD;
177
    }
178
179
    /* Align chunk length to the next pointer */
481 by Brian Aker
Remove all of uchar.
180
    chunk_length= (uint) (chunk_length + sizeof(unsigned char**) - 1) & ~(sizeof(unsigned char**) - 1);
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
181
182
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
183
1 by brian
clean slate
184
    for (i= key_segs= max_length= 0, keyinfo= keydef; i < keys; i++, keyinfo++)
185
    {
212.6.8 by Mats Kindahl
Removing extreneous explicit casts for the heap storage engine.
186
      memset(&keyinfo->block, 0, sizeof(keyinfo->block));
187
      memset(&keyinfo->rb_tree , 0, sizeof(keyinfo->rb_tree));
1 by brian
clean slate
188
      for (j= length= 0; j < keyinfo->keysegs; j++)
189
      {
190
	length+= keyinfo->seg[j].length;
191
	if (keyinfo->seg[j].null_bit)
192
	{
193
	  length++;
194
	  if (!(keyinfo->flag & HA_NULL_ARE_EQUAL))
195
	    keyinfo->flag|= HA_NULL_PART_KEY;
196
	  if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
197
	    keyinfo->rb_tree.size_of_element++;
198
	}
199
	switch (keyinfo->seg[j].type) {
200
	case HA_KEYTYPE_LONG_INT:
201
	case HA_KEYTYPE_DOUBLE:
202
	case HA_KEYTYPE_ULONG_INT:
203
	case HA_KEYTYPE_LONGLONG:
204
	case HA_KEYTYPE_ULONGLONG:
205
	case HA_KEYTYPE_UINT24:
206
	  keyinfo->seg[j].flag|= HA_SWAP_KEY;
207
          break;
208
        case HA_KEYTYPE_VARBINARY1:
209
          /* Case-insensitiveness is handled in coll->hash_sort */
210
          keyinfo->seg[j].type= HA_KEYTYPE_VARTEXT1;
211
          /* fall_through */
212
        case HA_KEYTYPE_VARTEXT1:
213
          keyinfo->flag|= HA_VAR_LENGTH_KEY;
214
          length+= 2;
215
          /* Save number of bytes used to store length */
216
          keyinfo->seg[j].bit_start= 1;
217
          break;
218
        case HA_KEYTYPE_VARBINARY2:
219
          /* Case-insensitiveness is handled in coll->hash_sort */
220
          /* fall_through */
221
        case HA_KEYTYPE_VARTEXT2:
222
          keyinfo->flag|= HA_VAR_LENGTH_KEY;
223
          length+= 2;
224
          /* Save number of bytes used to store length */
225
          keyinfo->seg[j].bit_start= 2;
226
          /*
227
            Make future comparison simpler by only having to check for
228
            one type
229
          */
230
          keyinfo->seg[j].type= HA_KEYTYPE_VARTEXT1;
231
          break;
232
	default:
233
	  break;
234
	}
235
      }
236
      keyinfo->length= length;
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
237
      length+= keyinfo->rb_tree.size_of_element +
481 by Brian Aker
Remove all of uchar.
238
	       ((keyinfo->algorithm == HA_KEY_ALG_BTREE) ? sizeof(unsigned char*) : 0);
1 by brian
clean slate
239
      if (length > max_length)
240
	max_length= length;
241
      key_segs+= keyinfo->keysegs;
242
      if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
243
      {
244
        key_segs++; /* additional HA_KEYTYPE_END segment */
245
        if (keyinfo->flag & HA_VAR_LENGTH_KEY)
246
          keyinfo->get_key_length= hp_rb_var_key_length;
247
        else if (keyinfo->flag & HA_NULL_PART_KEY)
248
          keyinfo->get_key_length= hp_rb_null_key_length;
249
        else
250
          keyinfo->get_key_length= hp_rb_key_length;
251
      }
252
    }
910.4.1 by Stewart Smith
fix memory alignment issues in hp_create for sparc.
253
    share= NULL;
254
    if (!(share= (HP_SHARE*) malloc(sizeof(HP_SHARE))))
255
      goto err;
256
257
    memset(share, 0, sizeof(HP_SHARE));
258
908.4.1 by Stewart Smith
valgrind warnings in hp_create: around memory allocation fixes for alignment done for sparc
259
    if (keys && !(share->keydef= (HP_KEYDEF*) malloc(keys*sizeof(HP_KEYDEF))))
910.4.1 by Stewart Smith
fix memory alignment issues in hp_create for sparc.
260
      goto err;
261
262
    memset(share->keydef, 0, keys*sizeof(HP_KEYDEF));
263
908.4.1 by Stewart Smith
valgrind warnings in hp_create: around memory allocation fixes for alignment done for sparc
264
    if (keys && !(share->keydef->seg= (HA_KEYSEG*) malloc(key_segs*sizeof(HA_KEYSEG))))
910.4.1 by Stewart Smith
fix memory alignment issues in hp_create for sparc.
265
      goto err;
266
    if (!(share->column_defs= (HP_COLUMNDEF*)
267
	  malloc(columns*sizeof(HP_COLUMNDEF))))
268
      goto err;
269
270
    memset(share->column_defs, 0, columns*sizeof(HP_COLUMNDEF));
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
271
272
    /*
273
       Max_records is used for estimating block sizes and for enforcement.
274
       Calculate the very maximum number of rows (if everything was one chunk) and
275
       then take either that value or configured max_records (pick smallest one)
276
    */
988.2.2 by Trond Norbye
size_t and uint64_t is not the same in 32 bit builds. Add explicit casting
277
    max_rows_for_stated_memory= (uint32_t)(create_info->max_table_size /
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
278
      (keys_memory_size + chunk_length));
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
279
    max_records = ((max_records && max_records < max_rows_for_stated_memory) ?
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
280
                      max_records : max_rows_for_stated_memory);
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
281
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
282
    memcpy(share->column_defs, columndef, (size_t) (sizeof(columndef[0]) * columns));
283
1 by brian
clean slate
284
    share->key_stat_version= 1;
908.4.1 by Stewart Smith
valgrind warnings in hp_create: around memory allocation fixes for alignment done for sparc
285
    keyseg= keys ? share->keydef->seg : NULL;
910.4.1 by Stewart Smith
fix memory alignment issues in hp_create for sparc.
286
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
287
    init_block(&share->recordspace.block, chunk_length, min_records, max_records);
288
    /* Fix keys */
1 by brian
clean slate
289
    memcpy(share->keydef, keydef, (size_t) (sizeof(keydef[0]) * keys));
290
    for (i= 0, keyinfo= share->keydef; i < keys; i++, keyinfo++)
291
    {
292
      keyinfo->seg= keyseg;
293
      memcpy(keyseg, keydef[i].seg,
294
	     (size_t) (sizeof(keyseg[0]) * keydef[i].keysegs));
295
      keyseg+= keydef[i].keysegs;
296
297
      if (keydef[i].algorithm == HA_KEY_ALG_BTREE)
298
      {
299
	/* additional HA_KEYTYPE_END keyseg */
300
	keyseg->type=     HA_KEYTYPE_END;
481 by Brian Aker
Remove all of uchar.
301
	keyseg->length=   sizeof(unsigned char*);
1 by brian
clean slate
302
	keyseg->flag=     0;
303
	keyseg->null_bit= 0;
304
	keyseg++;
305
481 by Brian Aker
Remove all of uchar.
306
	init_tree(&keyinfo->rb_tree, 0, 0, sizeof(unsigned char*),
1164 by Brian Aker
Small cleanup.
307
		  (qsort_cmp2)keys_compare, true, NULL, NULL);
1 by brian
clean slate
308
	keyinfo->delete_key= hp_rb_delete_key;
309
	keyinfo->write_key= hp_rb_write_key;
310
      }
311
      else
312
      {
313
	init_block(&keyinfo->block, sizeof(HASH_INFO), min_records,
314
		   max_records);
315
	keyinfo->delete_key= hp_delete_key;
316
	keyinfo->write_key= hp_write_key;
317
        keyinfo->hash_buckets= 0;
318
      }
319
      if ((keyinfo->flag & HA_AUTO_KEY) && create_info->with_auto_increment)
320
        share->auto_key= i + 1;
321
    }
322
    share->min_records= min_records;
323
    share->max_records= max_records;
324
    share->max_table_size= create_info->max_table_size;
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
325
    share->index_length= 0;
1 by brian
clean slate
326
    share->blength= 1;
327
    share->keys= keys;
328
    share->max_key_length= max_length;
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
329
    share->column_count= columns;
1 by brian
clean slate
330
    share->changed= 0;
331
    share->auto_key= create_info->auto_key;
332
    share->auto_key_type= create_info->auto_key_type;
333
    share->auto_increment= create_info->auto_increment;
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
334
335
    share->fixed_data_length= fixed_data_length;
336
    share->fixed_column_count= fixed_column_count;
337
338
    share->recordspace.chunk_length= chunk_length;
339
    share->recordspace.chunk_dataspace_length= chunk_dataspace_length;
340
    share->recordspace.is_variable_size= is_variable_size;
341
    share->recordspace.total_data_length= 0;
342
343
    if (is_variable_size) {
344
      share->recordspace.offset_link= chunk_dataspace_length;
481 by Brian Aker
Remove all of uchar.
345
      share->recordspace.offset_status= share->recordspace.offset_link + sizeof(unsigned char**);
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
346
    } else {
347
      share->recordspace.offset_link= 1<<22; /* Make it likely to fail if anyone uses this offset */
348
      share->recordspace.offset_status= chunk_dataspace_length;
349
    }
350
1 by brian
clean slate
351
    /* Must be allocated separately for rename to work */
656.1.25 by Monty Taylor
Removed my_malloc stuff from storage/
352
    if (!(share->name= strdup(name)))
1 by brian
clean slate
353
    {
354
      goto err;
355
    }
356
    thr_lock_init(&share->lock);
398.1.10 by Monty Taylor
Actually removed VOID() this time.
357
    pthread_mutex_init(&share->intern_lock,MY_MUTEX_INIT_FAST);
1 by brian
clean slate
358
    if (!create_info->internal_table)
359
    {
916.1.26 by Padraig O'Sullivan
Initial work on removing LIST from the heap storage engine.
360
      heap_share_list.push_front(share);
1 by brian
clean slate
361
    }
362
    else
363
      share->delete_on_close= 1;
364
  }
365
  if (!create_info->internal_table)
366
    pthread_mutex_unlock(&THR_LOCK_heap);
367
368
  *res= share;
51.3.1 by Jay Pipes
Removed all DBUG symbols from heap storage engine
369
  return(0);
1 by brian
clean slate
370
371
err:
910.4.1 by Stewart Smith
fix memory alignment issues in hp_create for sparc.
372
  if(share && share->keydef && share->keydef->seg)
373
    free(share->keydef->seg);
374
  if(share && share->keydef)
375
    free(share->keydef);
376
  if(share && share->column_defs)
377
    free(share->column_defs);
378
  if(share)
379
    free(share);
1 by brian
clean slate
380
  if (!create_info->internal_table)
381
    pthread_mutex_unlock(&THR_LOCK_heap);
51.3.1 by Jay Pipes
Removed all DBUG symbols from heap storage engine
382
  return(1);
1 by brian
clean slate
383
} /* heap_create */
384
385
481 by Brian Aker
Remove all of uchar.
386
static int keys_compare(heap_rb_param *param, unsigned char *key1, unsigned char *key2)
1 by brian
clean slate
387
{
482 by Brian Aker
Remove uint.
388
  uint32_t not_used[2];
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
389
  return ha_key_cmp(param->keyseg, key1, key2, param->key_length,
1 by brian
clean slate
390
		    param->search_flag, not_used);
391
}
392
482 by Brian Aker
Remove uint.
393
static void init_block(HP_BLOCK *block, uint32_t chunk_length, uint32_t min_records,
291 by Brian Aker
Head ulong conversion.
394
		       uint32_t max_records)
1 by brian
clean slate
395
{
482 by Brian Aker
Remove uint.
396
  uint32_t i,recbuffer,records_in_block;
1 by brian
clean slate
397
1067.4.8 by Nathan Williams
Converted all usages of cmin/cmax in plugin directory to std::min/max.
398
  max_records= max(min_records,max_records);
1 by brian
clean slate
399
  if (!max_records)
400
    max_records= 1000;			/* As good as quess as anything */
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
401
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
402
  /* we want to start each chunk at 8 bytes boundary, round recbuffer to the next 8 */
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
403
  recbuffer= (uint) (chunk_length + sizeof(unsigned char**) - 1) & ~(sizeof(unsigned char**) - 1);
1 by brian
clean slate
404
  records_in_block= max_records / 10;
405
  if (records_in_block < 10 && max_records)
406
    records_in_block= 10;
407
  if (!records_in_block || records_in_block*recbuffer >
408
      (my_default_record_cache_size-sizeof(HP_PTRS)*HP_MAX_LEVELS))
409
    records_in_block= (my_default_record_cache_size - sizeof(HP_PTRS) *
410
		      HP_MAX_LEVELS) / recbuffer + 1;
411
  block->records_in_block= records_in_block;
412
  block->recbuffer= recbuffer;
413
  block->last_allocated= 0L;
414
415
  for (i= 0; i <= HP_MAX_LEVELS; i++)
416
    block->level_info[i].records_under_level=
417
      (!i ? 1 : i == 1 ? records_in_block :
418
       HP_PTRS_IN_NOD * block->level_info[i - 1].records_under_level);
419
}
420
421
422
static inline void heap_try_free(HP_SHARE *share)
423
{
424
  if (share->open_count == 0)
425
    hp_free(share);
426
  else
427
    share->delete_on_close= 1;
428
}
429
430
431
int heap_delete_table(const char *name)
432
{
433
  int result;
434
  register HP_SHARE *share;
435
436
  pthread_mutex_lock(&THR_LOCK_heap);
437
  if ((share= hp_find_named_heap(name)))
438
  {
439
    heap_try_free(share);
440
    result= 0;
441
  }
442
  else
443
  {
444
    result= my_errno=ENOENT;
445
  }
446
  pthread_mutex_unlock(&THR_LOCK_heap);
51.3.1 by Jay Pipes
Removed all DBUG symbols from heap storage engine
447
  return(result);
1 by brian
clean slate
448
}
449
450
451
void heap_drop_table(HP_INFO *info)
452
{
453
  pthread_mutex_lock(&THR_LOCK_heap);
454
  heap_try_free(info->s);
455
  pthread_mutex_unlock(&THR_LOCK_heap);
51.3.1 by Jay Pipes
Removed all DBUG symbols from heap storage engine
456
  return;
1 by brian
clean slate
457
}
458
459
460
void hp_free(HP_SHARE *share)
461
{
916.1.26 by Padraig O'Sullivan
Initial work on removing LIST from the heap storage engine.
462
  heap_share_list.remove(share);        /* If not internal table */
1 by brian
clean slate
463
  hp_clear(share);			/* Remove blocks from memory */
464
  thr_lock_delete(&share->lock);
398.1.10 by Monty Taylor
Actually removed VOID() this time.
465
  pthread_mutex_destroy(&share->intern_lock);
1106.2.1 by Stewart Smith
correct conditional free() on parts of HEAP share. fixes valgrind leak warnings
466
  if (share->keydef && share->keydef->seg)
908.4.1 by Stewart Smith
valgrind warnings in hp_create: around memory allocation fixes for alignment done for sparc
467
    free(share->keydef->seg);
1106.2.1 by Stewart Smith
correct conditional free() on parts of HEAP share. fixes valgrind leak warnings
468
  if (share->keydef)
908.4.1 by Stewart Smith
valgrind warnings in hp_create: around memory allocation fixes for alignment done for sparc
469
    free(share->keydef);
910.4.1 by Stewart Smith
fix memory alignment issues in hp_create for sparc.
470
  free(share->column_defs);
481 by Brian Aker
Remove all of uchar.
471
  free((unsigned char*) share->name);
472
  free((unsigned char*) share);
1 by brian
clean slate
473
  return;
474
}