~stewart/drizzle/embedded-innodb-create-select-transaction-arrgh

« back to all changes in this revision

Viewing changes to storage/heap/heapdef.h

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000-2002, 2004 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
 
 
16
/* This file is included in all heap-files */
 
17
 
 
18
#include <my_base.h>                    /* This includes global */
 
19
C_MODE_START
 
20
#ifdef THREAD
 
21
#include <my_pthread.h>
 
22
#endif
 
23
#include "heap.h"                       /* Structs & some defines */
 
24
#include "my_tree.h"
 
25
 
 
26
/*
 
27
  When allocating keys /rows in the internal block structure, do it
 
28
  within the following boundaries.
 
29
 
 
30
  The challenge is to find the balance between allocate as few blocks
 
31
  as possible and keep memory consumption down.
 
32
*/
 
33
 
 
34
#define HP_MIN_RECORDS_IN_BLOCK 16
 
35
#define HP_MAX_RECORDS_IN_BLOCK 8192
 
36
 
 
37
        /* Some extern variables */
 
38
 
 
39
extern LIST *heap_open_list,*heap_share_list;
 
40
 
 
41
#define test_active(info) \
 
42
if (!(info->update & HA_STATE_AKTIV))\
 
43
{ my_errno=HA_ERR_NO_ACTIVE_RECORD; DBUG_RETURN(-1); }
 
44
#define hp_find_hash(A,B) ((HASH_INFO*) hp_find_block((A),(B)))
 
45
 
 
46
        /* Find pos for record and update it in info->current_ptr */
 
47
#define hp_find_record(info,pos) (info)->current_ptr= hp_find_block(&(info)->s->block,pos)
 
48
 
 
49
typedef struct st_hp_hash_info
 
50
{
 
51
  struct st_hp_hash_info *next_key;
 
52
  uchar *ptr_to_rec;
 
53
} HASH_INFO;
 
54
 
 
55
typedef struct {
 
56
  HA_KEYSEG *keyseg;
 
57
  uint key_length;
 
58
  uint search_flag;
 
59
} heap_rb_param;
 
60
      
 
61
        /* Prototypes for intern functions */
 
62
 
 
63
extern HP_SHARE *hp_find_named_heap(const char *name);
 
64
extern int hp_rectest(HP_INFO *info,const uchar *old);
 
65
extern uchar *hp_find_block(HP_BLOCK *info,ulong pos);
 
66
extern int hp_get_new_block(HP_BLOCK *info, size_t* alloc_length);
 
67
extern void hp_free(HP_SHARE *info);
 
68
extern uchar *hp_free_level(HP_BLOCK *block,uint level,HP_PTRS *pos,
 
69
                           uchar *last_pos);
 
70
extern int hp_write_key(HP_INFO *info, HP_KEYDEF *keyinfo,
 
71
                        const uchar *record, uchar *recpos);
 
72
extern int hp_rb_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, 
 
73
                           const uchar *record, uchar *recpos);
 
74
extern int hp_rb_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo,
 
75
                            const uchar *record,uchar *recpos,int flag);
 
76
extern int hp_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo,
 
77
                         const uchar *record,uchar *recpos,int flag);
 
78
extern HASH_INFO *_heap_find_hash(HP_BLOCK *block,ulong pos);
 
79
extern uchar *hp_search(HP_INFO *info,HP_KEYDEF *keyinfo,const uchar *key,
 
80
                       uint nextflag);
 
81
extern uchar *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo,
 
82
                            const uchar *key, HASH_INFO *pos);
 
83
extern ulong hp_hashnr(HP_KEYDEF *keyinfo,const uchar *key);
 
84
extern ulong hp_rec_hashnr(HP_KEYDEF *keyinfo,const uchar *rec);
 
85
extern ulong hp_mask(ulong hashnr,ulong buffmax,ulong maxlength);
 
86
extern void hp_movelink(HASH_INFO *pos,HASH_INFO *next_link,
 
87
                         HASH_INFO *newlink);
 
88
extern int hp_rec_key_cmp(HP_KEYDEF *keydef,const uchar *rec1,
 
89
                          const uchar *rec2,
 
90
                          my_bool diff_if_only_endspace_difference);
 
91
extern int hp_key_cmp(HP_KEYDEF *keydef,const uchar *rec,
 
92
                      const uchar *key);
 
93
extern void hp_make_key(HP_KEYDEF *keydef,uchar *key,const uchar *rec);
 
94
extern uint hp_rb_make_key(HP_KEYDEF *keydef, uchar *key,
 
95
                           const uchar *rec, uchar *recpos);
 
96
extern uint hp_rb_key_length(HP_KEYDEF *keydef, const uchar *key);
 
97
extern uint hp_rb_null_key_length(HP_KEYDEF *keydef, const uchar *key);
 
98
extern uint hp_rb_var_key_length(HP_KEYDEF *keydef, const uchar *key);
 
99
extern my_bool hp_if_null_in_key(HP_KEYDEF *keyinfo, const uchar *record);
 
100
extern int hp_close(register HP_INFO *info);
 
101
extern void hp_clear(HP_SHARE *info);
 
102
extern void hp_clear_keys(HP_SHARE *info);
 
103
extern uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old,
 
104
                           key_part_map keypart_map);
 
105
#ifdef THREAD
 
106
extern pthread_mutex_t THR_LOCK_heap;
 
107
#else
 
108
#define pthread_mutex_lock(A)
 
109
#define pthread_mutex_unlock(A)
 
110
#endif
 
111
C_MODE_END