~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_range.cc

  • Committer: Brian Aker
  • Date: 2010-02-07 01:33:54 UTC
  • Revision ID: brian@gaz-20100207013354-d2pg1n68u5c09pgo
Remove giant include header to its own file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
  Used when optimizing querries.
19
19
 */
20
20
 
21
 
#include "myisamdef.h"
22
 
 
23
 
static ha_rows _mi_record_pos(MI_INFO *, const uchar *, key_part_map,
 
21
#include "myisam_priv.h"
 
22
 
 
23
using namespace drizzled;
 
24
 
 
25
static ha_rows _mi_record_pos(MI_INFO *, const unsigned char *, key_part_map,
24
26
                              enum ha_rkey_function);
25
 
static double _mi_search_pos(MI_INFO *,MI_KEYDEF *,uchar *, uint,uint,my_off_t);
26
 
static uint _mi_keynr(MI_INFO *info,MI_KEYDEF *,uchar *, uchar *,uint *);
 
27
static double _mi_search_pos(MI_INFO *,MI_KEYDEF *,unsigned char *, uint,uint,internal::my_off_t);
 
28
static uint32_t _mi_keynr(MI_INFO *info,MI_KEYDEF *,unsigned char *, unsigned char *,uint32_t *);
27
29
 
28
30
/*
29
31
  Estimate how many records there is in a given range
42
44
    HA_POS_ERROR  error (or we can't estimate number of rows)
43
45
    number        Estimated number of rows
44
46
*/
45
 
  
 
47
 
46
48
ha_rows mi_records_in_range(MI_INFO *info, int inx,
47
49
                            key_range *min_key, key_range *max_key)
48
50
{
55
57
    return(HA_POS_ERROR);
56
58
  info->update&= (HA_STATE_CHANGED+HA_STATE_ROW_CHANGED);
57
59
  if (info->s->concurrent_insert)
58
 
    rw_rdlock(&info->s->key_root_lock[inx]);
 
60
    pthread_rwlock_rdlock(&info->s->key_root_lock[inx]);
59
61
 
60
62
  switch(info->s->keyinfo[inx].key_alg){
61
63
  case HA_KEY_ALG_BTREE:
73
75
  }
74
76
 
75
77
  if (info->s->concurrent_insert)
76
 
    rw_unlock(&info->s->key_root_lock[inx]);
 
78
    pthread_rwlock_unlock(&info->s->key_root_lock[inx]);
77
79
  fast_mi_writeinfo(info);
78
80
 
79
81
  return(res);
82
84
 
83
85
        /* Find relative position (in records) for key in index-tree */
84
86
 
85
 
static ha_rows _mi_record_pos(MI_INFO *info, const uchar *key,
 
87
static ha_rows _mi_record_pos(MI_INFO *info, const unsigned char *key,
86
88
                              key_part_map keypart_map,
87
89
                              enum ha_rkey_function search_flag)
88
90
{
89
 
  uint inx=(uint) info->lastinx, nextflag, key_len;
 
91
  uint32_t inx=(uint) info->lastinx, nextflag, key_len;
90
92
  MI_KEYDEF *keyinfo=info->s->keyinfo+inx;
91
 
  uchar *key_buff;
 
93
  unsigned char *key_buff;
92
94
  double pos;
93
95
 
94
96
  assert(keypart_map);
95
97
 
96
98
  key_buff=info->lastkey+info->s->base.max_key_length;
97
 
  key_len=_mi_pack_key(info,inx,key_buff,(uchar*) key, keypart_map,
 
99
  key_len=_mi_pack_key(info,inx,key_buff,(unsigned char*) key, keypart_map,
98
100
                       (HA_KEYSEG**) 0);
99
101
  nextflag=myisam_read_vec[search_flag];
100
102
  if (!(nextflag & (SEARCH_FIND | SEARCH_NO_FIND | SEARCH_LAST)))
150
152
 
151
153
static double _mi_search_pos(register MI_INFO *info,
152
154
                             register MI_KEYDEF *keyinfo,
153
 
                             uchar *key, uint key_len, uint nextflag,
154
 
                             register my_off_t pos)
 
155
                             unsigned char *key, uint32_t key_len, uint32_t nextflag,
 
156
                             register internal::my_off_t pos)
155
157
{
156
158
  int flag;
157
 
  uint nod_flag, keynr, max_keynr= 0;
 
159
  uint32_t nod_flag, keynr, max_keynr= 0;
158
160
  bool after_key;
159
 
  uchar *keypos,*buff;
 
161
  unsigned char *keypos,*buff;
160
162
  double offset;
161
163
 
162
164
  if (pos == HA_OFFSET_ERROR)
212
214
 
213
215
        /* Get keynummer of current key and max number of keys in nod */
214
216
 
215
 
static uint _mi_keynr(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page,
216
 
                      uchar *keypos, uint *ret_max_key)
 
217
static uint32_t _mi_keynr(MI_INFO *info, register MI_KEYDEF *keyinfo, unsigned char *page,
 
218
                      unsigned char *keypos, uint32_t *ret_max_key)
217
219
{
218
 
  uint nod_flag,keynr,max_key;
219
 
  uchar t_buff[MI_MAX_KEY_BUFF],*end;
 
220
  uint32_t nod_flag,keynr,max_key;
 
221
  unsigned char t_buff[MI_MAX_KEY_BUFF],*end;
220
222
 
221
223
  end= page+mi_getint(page);
222
224
  nod_flag=mi_test_if_nod(page);