~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_key.cc

  • Committer: Stewart Smith
  • Date: 2009-10-19 04:17:38 UTC
  • mto: This revision was merged to the branch mainline in revision 1192.
  • Revision ID: stewart@flamingspork.com-20091019041738-bsjyzmittghcomqj
remove some unused PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP related things as errorcheck mutexes are never used (and haven't been since at least MySQL 4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/* Functions to handle keys */
17
17
 
18
 
#include "myisam_priv.h"
19
 
#include "drizzled/charset_info.h"
 
18
#include "myisamdef.h"
 
19
#include <mystrings/m_ctype.h>
20
20
#ifdef HAVE_IEEEFP_H
21
21
#include <ieeefp.h>
22
22
#endif
23
 
#include <math.h>
24
 
#include <cassert>
25
 
 
26
 
using namespace drizzled;
27
 
using namespace std;
28
23
 
29
24
#define CHECK_KEYS                              /* Enable safety checks */
30
25
 
32
27
            do {                                                            \
33
28
              if (length > char_length)                                     \
34
29
                char_length= my_charpos(cs, pos, pos+length, char_length);  \
35
 
              drizzled::set_if_smaller(char_length,length);                           \
 
30
              set_if_smaller(char_length,length);                           \
36
31
            } while(0)
37
32
 
38
33
static int _mi_put_key_in_record(MI_INFO *info,uint32_t keynr,unsigned char *record);
53
48
*/
54
49
 
55
50
uint32_t _mi_make_key(register MI_INFO *info, uint32_t keynr, unsigned char *key,
56
 
                      const unsigned char *record, drizzled::internal::my_off_t filepos)
 
51
                  const unsigned char *record, my_off_t filepos)
57
52
{
58
53
  unsigned char *pos;
59
54
  unsigned char *start;
62
57
  start=key;
63
58
  for (keyseg=info->s->keyinfo[keynr].seg ; keyseg->type ;keyseg++)
64
59
  {
65
 
    enum drizzled::ha_base_keytype type=(enum drizzled::ha_base_keytype) keyseg->type;
 
60
    enum ha_base_keytype type=(enum ha_base_keytype) keyseg->type;
66
61
    uint32_t length=keyseg->length;
67
62
    uint32_t char_length;
68
 
    const drizzled::CHARSET_INFO * const cs=keyseg->charset;
 
63
    const CHARSET_INFO * const cs=keyseg->charset;
69
64
 
70
65
    if (keyseg->null_bit)
71
66
    {
98
93
      uint32_t tmp_length= (pack_length == 1 ? (uint) *(unsigned char*) pos :
99
94
                        uint2korr(pos));
100
95
      pos+= pack_length;                        /* Skip VARCHAR length */
101
 
      drizzled::set_if_smaller(length,tmp_length);
 
96
      set_if_smaller(length,tmp_length);
102
97
      FIX_LENGTH(cs, pos, length, char_length);
103
98
      store_key_length_inc(key,char_length);
104
99
      memcpy(key, pos, char_length);
109
104
    {
110
105
      uint32_t tmp_length=_mi_calc_blob_length(keyseg->bit_start,pos);
111
106
      memcpy(&pos, pos+keyseg->bit_start, sizeof(char*));
112
 
      drizzled::set_if_smaller(length,tmp_length);
 
107
      set_if_smaller(length,tmp_length);
113
108
      FIX_LENGTH(cs, pos, length, char_length);
114
109
      store_key_length_inc(key,char_length);
115
110
      memcpy(key, pos, char_length);
118
113
    }
119
114
    else if (keyseg->flag & HA_SWAP_KEY)
120
115
    {                                           /* Numerical column */
121
 
      if (type == drizzled::HA_KEYTYPE_DOUBLE)
 
116
#ifdef HAVE_ISNAN
 
117
      if (type == HA_KEYTYPE_DOUBLE)
122
118
      {
123
119
        double nr;
124
120
        float8get(nr,pos);
129
125
          continue;
130
126
        }
131
127
      }
 
128
#endif
132
129
      pos+=length;
133
130
      while (length--)
134
131
      {
166
163
*/
167
164
 
168
165
uint32_t _mi_pack_key(register MI_INFO *info, uint32_t keynr, unsigned char *key, unsigned char *old,
169
 
                      drizzled::key_part_map keypart_map, HA_KEYSEG **last_used_keyseg)
 
166
                  key_part_map keypart_map, HA_KEYSEG **last_used_keyseg)
170
167
{
171
168
  unsigned char *start_key=key;
172
169
  HA_KEYSEG *keyseg;
177
174
  for (keyseg= info->s->keyinfo[keynr].seg ; keyseg->type && keypart_map;
178
175
       old+= keyseg->length, keyseg++)
179
176
  {
180
 
    enum drizzled::ha_base_keytype type= (enum drizzled::ha_base_keytype) keyseg->type;
 
177
    enum ha_base_keytype type= (enum ha_base_keytype) keyseg->type;
181
178
    uint32_t length= keyseg->length;
182
179
    uint32_t char_length;
183
180
    unsigned char *pos;
184
 
    const drizzled::CHARSET_INFO * const cs=keyseg->charset;
 
181
    const CHARSET_INFO * const cs=keyseg->charset;
185
182
    keypart_map>>= 1;
186
183
    if (keyseg->null_bit)
187
184
    {
198
195
    {
199
196
      unsigned char *end=pos+length;
200
197
 
201
 
      if (type != drizzled::HA_KEYTYPE_BINARY)
 
198
      if (type != HA_KEYTYPE_BINARY)
202
199
      {
203
200
        while (end > pos && end[-1] == ' ')
204
201
          end--;
215
212
      /* Length of key-part used with mi_rkey() always 2 */
216
213
      uint32_t tmp_length=uint2korr(pos);
217
214
      pos+=2;
218
 
      drizzled::set_if_smaller(length,tmp_length);      /* Safety */
 
215
      set_if_smaller(length,tmp_length);        /* Safety */
219
216
      FIX_LENGTH(cs, pos, length, char_length);
220
217
      store_key_length_inc(key,char_length);
221
218
      old+=2;                                   /* Skip length */
375
372
 
376
373
        /* Here when key reads are used */
377
374
 
378
 
int _mi_read_key_record(MI_INFO *info, drizzled::internal::my_off_t filepos, unsigned char *buf)
 
375
int _mi_read_key_record(MI_INFO *info, my_off_t filepos, unsigned char *buf)
379
376
{
380
377
  fast_mi_writeinfo(info);
381
378
  if (filepos != HA_OFFSET_ERROR)
385
382
      if (_mi_put_key_in_record(info,(uint) info->lastinx,buf))
386
383
      {
387
384
        mi_print_error(info->s, HA_ERR_CRASHED);
388
 
        errno=HA_ERR_CRASHED;
 
385
        my_errno=HA_ERR_CRASHED;
389
386
        return -1;
390
387
      }
391
388
      info->update|= HA_STATE_AKTIV; /* We should find a record */
392
389
      return 0;
393
390
    }
394
 
    errno=HA_ERR_WRONG_INDEX;
 
391
    my_errno=HA_ERR_WRONG_INDEX;
395
392
  }
396
393
  return(-1);                           /* Wrong data to read */
397
394
}
419
416
  if (_mi_put_key_in_record(info, keynr, record))
420
417
  {
421
418
    mi_print_error(info->s, HA_ERR_CRASHED);
422
 
    errno=HA_ERR_CRASHED;
 
419
    my_errno=HA_ERR_CRASHED;
423
420
    return -1;
424
421
  }
425
422
  return info->index_cond_func(info->index_cond_func_arg);
447
444
  const unsigned char *key= (unsigned char*) record + keyseg->start;
448
445
 
449
446
  switch (keyseg->type) {
450
 
  case drizzled::HA_KEYTYPE_BINARY:
 
447
  case HA_KEYTYPE_BINARY:
451
448
    value=(uint64_t)  *(unsigned char*) key;
452
449
    break;
453
 
  case drizzled::HA_KEYTYPE_LONG_INT:
 
450
  case HA_KEYTYPE_LONG_INT:
454
451
    s_value= (int64_t) sint4korr(key);
455
452
    break;
456
 
  case drizzled::HA_KEYTYPE_ULONG_INT:
 
453
  case HA_KEYTYPE_ULONG_INT:
457
454
    value=(uint64_t) uint4korr(key);
458
455
    break;
459
 
  case drizzled::HA_KEYTYPE_DOUBLE:                       /* This shouldn't be used */
 
456
  case HA_KEYTYPE_UINT24:
 
457
    value=(uint64_t) uint3korr(key);
 
458
    break;
 
459
  case HA_KEYTYPE_DOUBLE:                       /* This shouldn't be used */
460
460
  {
461
461
    double f_1;
462
462
    float8get(f_1,key);
464
464
    value = (f_1 < 0.0) ? 0 : (uint64_t) f_1;
465
465
    break;
466
466
  }
467
 
  case drizzled::HA_KEYTYPE_LONGLONG:
 
467
  case HA_KEYTYPE_LONGLONG:
468
468
    s_value= sint8korr(key);
469
469
    break;
470
 
  case drizzled::HA_KEYTYPE_ULONGLONG:
 
470
  case HA_KEYTYPE_ULONGLONG:
471
471
    value= uint8korr(key);
472
472
    break;
473
473
  default: