~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
1802.10.2 by Monty Taylor
Update all of the copyright headers to include the correct address.
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
1 by brian
clean slate
15
16
/* Functions to handle keys */
17
1130.3.28 by Monty Taylor
Moved heapdef.h and myisamdef.h to *_priv.h for easier filtering for include guard check.
18
#include "myisam_priv.h"
2281.5.1 by Muhammad Umair
Merged charset declarations of global_charset_info.h and charset_info.h into charset.h header file.
19
#include <drizzled/charset.h>
1 by brian
clean slate
20
#ifdef HAVE_IEEEFP_H
21
#include <ieeefp.h>
22
#endif
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
23
#include <math.h>
24
#include <cassert>
1 by brian
clean slate
25
1711.3.1 by Lee Bieber
fix build failure on OSX
26
using namespace drizzled;
27
using namespace std;
28
1 by brian
clean slate
29
#define CHECK_KEYS                              /* Enable safety checks */
30
31
#define FIX_LENGTH(cs, pos, length, char_length)                            \
32
            do {                                                            \
33
              if (length > char_length)                                     \
34
                char_length= my_charpos(cs, pos, pos+length, char_length);  \
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
35
              drizzled::set_if_smaller(char_length,length);                           \
1 by brian
clean slate
36
            } while(0)
37
482 by Brian Aker
Remove uint.
38
static int _mi_put_key_in_record(MI_INFO *info,uint32_t keynr,unsigned char *record);
1 by brian
clean slate
39
40
/*
41
  Make a intern key from a record
42
43
  SYNOPSIS
44
    _mi_make_key()
45
    info		MyiSAM handler
46
    keynr		key number
47
    key			Store created key here
48
    record		Record
49
    filepos		Position to record in the data file
50
51
  RETURN
52
    Length of key
53
*/
54
482 by Brian Aker
Remove uint.
55
uint32_t _mi_make_key(register MI_INFO *info, uint32_t keynr, unsigned char *key,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
56
                      const unsigned char *record, drizzled::internal::my_off_t filepos)
1 by brian
clean slate
57
{
481 by Brian Aker
Remove all of uchar.
58
  unsigned char *pos;
59
  unsigned char *start;
1 by brian
clean slate
60
  register HA_KEYSEG *keyseg;
61
62
  start=key;
63
  for (keyseg=info->s->keyinfo[keynr].seg ; keyseg->type ;keyseg++)
64
  {
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
65
    enum drizzled::ha_base_keytype type=(enum drizzled::ha_base_keytype) keyseg->type;
482 by Brian Aker
Remove uint.
66
    uint32_t length=keyseg->length;
67
    uint32_t char_length;
2254 by Brian Aker
Shift CHARSET_INFO to charset_info_st
68
    const drizzled::charset_info_st * const cs=keyseg->charset;
1 by brian
clean slate
69
70
    if (keyseg->null_bit)
71
    {
72
      if (record[keyseg->null_pos] & keyseg->null_bit)
73
      {
74
	*key++= 0;				/* NULL in key */
75
	continue;
76
      }
77
      *key++=1;					/* Not NULL */
78
    }
79
249 by Brian Aker
Random key cleanup (it is a friday...)
80
    char_length= ((cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen :
1 by brian
clean slate
81
                  length);
82
481 by Brian Aker
Remove all of uchar.
83
    pos= (unsigned char*) record+keyseg->start;
1161.1.7 by Stewart Smith
remove unused HA_KEYTYPE_BIT
84
1 by brian
clean slate
85
    if (keyseg->flag & HA_SPACE_PACK)
86
    {
1161.1.5 by Stewart Smith
remove unused HA_KEYTYPE_NUM
87
      length= cs->cset->lengthsp(cs, (char*) pos, length);
88
1 by brian
clean slate
89
      FIX_LENGTH(cs, pos, length, char_length);
90
      store_key_length_inc(key,char_length);
212.6.12 by Mats Kindahl
Removing redundant use of casts in MyISAM storage for memcmp(), memcpy(), memset(), and memmove().
91
      memcpy(key, pos, char_length);
1 by brian
clean slate
92
      key+=char_length;
93
      continue;
94
    }
95
    if (keyseg->flag & HA_VAR_LENGTH_PART)
96
    {
482 by Brian Aker
Remove uint.
97
      uint32_t pack_length= (keyseg->bit_start == 1 ? 1 : 2);
98
      uint32_t tmp_length= (pack_length == 1 ? (uint) *(unsigned char*) pos :
1 by brian
clean slate
99
                        uint2korr(pos));
100
      pos+= pack_length;			/* Skip VARCHAR length */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
101
      drizzled::set_if_smaller(length,tmp_length);
1 by brian
clean slate
102
      FIX_LENGTH(cs, pos, length, char_length);
103
      store_key_length_inc(key,char_length);
212.6.12 by Mats Kindahl
Removing redundant use of casts in MyISAM storage for memcmp(), memcpy(), memset(), and memmove().
104
      memcpy(key, pos, char_length);
1 by brian
clean slate
105
      key+= char_length;
106
      continue;
107
    }
108
    else if (keyseg->flag & HA_BLOB_PART)
109
    {
482 by Brian Aker
Remove uint.
110
      uint32_t tmp_length=_mi_calc_blob_length(keyseg->bit_start,pos);
212.6.12 by Mats Kindahl
Removing redundant use of casts in MyISAM storage for memcmp(), memcpy(), memset(), and memmove().
111
      memcpy(&pos, pos+keyseg->bit_start, sizeof(char*));
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
112
      drizzled::set_if_smaller(length,tmp_length);
1 by brian
clean slate
113
      FIX_LENGTH(cs, pos, length, char_length);
114
      store_key_length_inc(key,char_length);
212.6.12 by Mats Kindahl
Removing redundant use of casts in MyISAM storage for memcmp(), memcpy(), memset(), and memmove().
115
      memcpy(key, pos, char_length);
1 by brian
clean slate
116
      key+= char_length;
117
      continue;
118
    }
119
    else if (keyseg->flag & HA_SWAP_KEY)
120
    {						/* Numerical column */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
121
      if (type == drizzled::HA_KEYTYPE_DOUBLE)
1 by brian
clean slate
122
      {
123
	double nr;
124
	float8get(nr,pos);
125
	if (isnan(nr))
126
	{
212.6.1 by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file.
127
	  memset(key, 0, length);
1 by brian
clean slate
128
	  key+=length;
129
	  continue;
130
	}
131
      }
132
      pos+=length;
133
      while (length--)
134
      {
135
	*key++ = *--pos;
136
      }
137
      continue;
138
    }
139
    FIX_LENGTH(cs, pos, length, char_length);
212.6.12 by Mats Kindahl
Removing redundant use of casts in MyISAM storage for memcmp(), memcpy(), memset(), and memmove().
140
    memcpy(key, pos, char_length);
1 by brian
clean slate
141
    if (length > char_length)
142
      cs->cset->fill(cs, (char*) key+char_length, length-char_length, ' ');
143
    key+= length;
144
  }
145
  _mi_dpointer(info,key,filepos);
51.1.101 by Jay Pipes
Removed/replaced DBUG symbols and TRUE/FALSE
146
  return((uint) (key-start));		/* Return keylength */
1 by brian
clean slate
147
} /* _mi_make_key */
148
149
150
/*
151
  Pack a key to intern format from given format (c_rkey)
152
153
  SYNOPSIS
154
    _mi_pack_key()
155
    info		MyISAM handler
482 by Brian Aker
Remove uint.
156
    uint32_t keynr		key number
1 by brian
clean slate
157
    key			Store packed key here
158
    old			Not packed key
159
    keypart_map         bitmap of used keyparts
160
    last_used_keyseg	out parameter.  May be NULL
161
162
   RETURN
163
     length of packed key
164
165
     last_use_keyseg    Store pointer to the keyseg after the last used one
166
*/
167
482 by Brian Aker
Remove uint.
168
uint32_t _mi_pack_key(register MI_INFO *info, uint32_t keynr, unsigned char *key, unsigned char *old,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
169
                      drizzled::key_part_map keypart_map, HA_KEYSEG **last_used_keyseg)
1 by brian
clean slate
170
{
481 by Brian Aker
Remove all of uchar.
171
  unsigned char *start_key=key;
1 by brian
clean slate
172
  HA_KEYSEG *keyseg;
173
174
  /* only key prefixes are supported */
51.1.101 by Jay Pipes
Removed/replaced DBUG symbols and TRUE/FALSE
175
  assert(((keypart_map+1) & keypart_map) == 0);
1 by brian
clean slate
176
177
  for (keyseg= info->s->keyinfo[keynr].seg ; keyseg->type && keypart_map;
178
       old+= keyseg->length, keyseg++)
179
  {
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
180
    enum drizzled::ha_base_keytype type= (enum drizzled::ha_base_keytype) keyseg->type;
482 by Brian Aker
Remove uint.
181
    uint32_t length= keyseg->length;
182
    uint32_t char_length;
481 by Brian Aker
Remove all of uchar.
183
    unsigned char *pos;
2254 by Brian Aker
Shift CHARSET_INFO to charset_info_st
184
    const drizzled::charset_info_st * const cs=keyseg->charset;
1 by brian
clean slate
185
    keypart_map>>= 1;
186
    if (keyseg->null_bit)
187
    {
188
      if (!(*key++= (char) 1-*old++))			/* Copy null marker */
189
      {
190
        if (keyseg->flag & (HA_VAR_LENGTH_PART | HA_BLOB_PART))
191
          old+= 2;
192
	continue;					/* Found NULL */
193
      }
194
    }
249 by Brian Aker
Random key cleanup (it is a friday...)
195
    char_length= (cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen : length;
1 by brian
clean slate
196
    pos=old;
197
    if (keyseg->flag & HA_SPACE_PACK)
198
    {
481 by Brian Aker
Remove all of uchar.
199
      unsigned char *end=pos+length;
1161.1.5 by Stewart Smith
remove unused HA_KEYTYPE_NUM
200
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
201
      if (type != drizzled::HA_KEYTYPE_BINARY)
1 by brian
clean slate
202
      {
203
	while (end > pos && end[-1] == ' ')
204
	  end--;
205
      }
206
      length=(uint) (end-pos);
207
      FIX_LENGTH(cs, pos, length, char_length);
208
      store_key_length_inc(key,char_length);
212.6.12 by Mats Kindahl
Removing redundant use of casts in MyISAM storage for memcmp(), memcpy(), memset(), and memmove().
209
      memcpy(key, pos, char_length);
1 by brian
clean slate
210
      key+= char_length;
211
      continue;
212
    }
213
    else if (keyseg->flag & (HA_VAR_LENGTH_PART | HA_BLOB_PART))
214
    {
215
      /* Length of key-part used with mi_rkey() always 2 */
482 by Brian Aker
Remove uint.
216
      uint32_t tmp_length=uint2korr(pos);
1 by brian
clean slate
217
      pos+=2;
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
218
      drizzled::set_if_smaller(length,tmp_length);	/* Safety */
1 by brian
clean slate
219
      FIX_LENGTH(cs, pos, length, char_length);
220
      store_key_length_inc(key,char_length);
221
      old+=2;					/* Skip length */
212.6.12 by Mats Kindahl
Removing redundant use of casts in MyISAM storage for memcmp(), memcpy(), memset(), and memmove().
222
      memcpy(key, pos, char_length);
1 by brian
clean slate
223
      key+= char_length;
224
      continue;
225
    }
226
    else if (keyseg->flag & HA_SWAP_KEY)
227
    {						/* Numerical column */
228
      pos+=length;
229
      while (length--)
230
	*key++ = *--pos;
231
      continue;
232
    }
233
    FIX_LENGTH(cs, pos, length, char_length);
212.6.12 by Mats Kindahl
Removing redundant use of casts in MyISAM storage for memcmp(), memcpy(), memset(), and memmove().
234
    memcpy(key, pos, char_length);
1 by brian
clean slate
235
    if (length > char_length)
236
      cs->cset->fill(cs, (char*) key+char_length, length-char_length, ' ');
237
    key+= length;
238
  }
239
  if (last_used_keyseg)
240
    *last_used_keyseg= keyseg;
241
51.1.101 by Jay Pipes
Removed/replaced DBUG symbols and TRUE/FALSE
242
  return((uint) (key-start_key));
1 by brian
clean slate
243
} /* _mi_pack_key */
244
245
246
247
/*
248
  Store found key in record
249
250
  SYNOPSIS
251
    _mi_put_key_in_record()
252
    info		MyISAM handler
253
    keynr		Key number that was used
254
    record 		Store key here
255
256
    Last read key is in info->lastkey
257
258
 NOTES
259
   Used when only-keyread is wanted
260
261
 RETURN
262
   0   ok
263
   1   error
264
*/
265
482 by Brian Aker
Remove uint.
266
static int _mi_put_key_in_record(register MI_INFO *info, uint32_t keynr,
481 by Brian Aker
Remove all of uchar.
267
				 unsigned char *record)
1 by brian
clean slate
268
{
481 by Brian Aker
Remove all of uchar.
269
  register unsigned char *key;
270
  unsigned char *pos,*key_end;
1 by brian
clean slate
271
  register HA_KEYSEG *keyseg;
481 by Brian Aker
Remove all of uchar.
272
  unsigned char *blob_ptr;
1 by brian
clean slate
273
481 by Brian Aker
Remove all of uchar.
274
  blob_ptr= (unsigned char*) info->lastkey2;             /* Place to put blob parts */
275
  key=(unsigned char*) info->lastkey;                    /* KEy that was read */
1 by brian
clean slate
276
  key_end=key+info->lastkey_length;
277
  for (keyseg=info->s->keyinfo[keynr].seg ; keyseg->type ;keyseg++)
278
  {
279
    if (keyseg->null_bit)
280
    {
281
      if (!*key++)
282
      {
283
	record[keyseg->null_pos]|= keyseg->null_bit;
284
	continue;
285
      }
286
      record[keyseg->null_pos]&= ~keyseg->null_bit;
287
    }
288
289
    if (keyseg->flag & HA_SPACE_PACK)
290
    {
482 by Brian Aker
Remove uint.
291
      uint32_t length;
1 by brian
clean slate
292
      get_key_length(length,key);
293
#ifdef CHECK_KEYS
294
      if (length > keyseg->length || key+length > key_end)
295
	goto err;
296
#endif
297
      pos= record+keyseg->start;
1161.1.5 by Stewart Smith
remove unused HA_KEYTYPE_NUM
298
299
      memcpy(pos, key, length);
300
      keyseg->charset->cset->fill(keyseg->charset,
301
                                  (char*) pos + length,
302
                                  keyseg->length - length,
303
                                  ' ');
1 by brian
clean slate
304
      key+=length;
305
      continue;
306
    }
307
308
    if (keyseg->flag & HA_VAR_LENGTH_PART)
309
    {
482 by Brian Aker
Remove uint.
310
      uint32_t length;
1 by brian
clean slate
311
      get_key_length(length,key);
312
#ifdef CHECK_KEYS
313
      if (length > keyseg->length || key+length > key_end)
314
	goto err;
315
#endif
316
      /* Store key length */
317
      if (keyseg->bit_start == 1)
481 by Brian Aker
Remove all of uchar.
318
        *(unsigned char*) (record+keyseg->start)= (unsigned char) length;
1 by brian
clean slate
319
      else
320
        int2store(record+keyseg->start, length);
321
      /* And key data */
212.6.12 by Mats Kindahl
Removing redundant use of casts in MyISAM storage for memcmp(), memcpy(), memset(), and memmove().
322
      memcpy(record+keyseg->start + keyseg->bit_start, key, length);
1 by brian
clean slate
323
      key+= length;
324
    }
325
    else if (keyseg->flag & HA_BLOB_PART)
326
    {
482 by Brian Aker
Remove uint.
327
      uint32_t length;
1 by brian
clean slate
328
      get_key_length(length,key);
329
#ifdef CHECK_KEYS
330
      if (length > keyseg->length || key+length > key_end)
331
	goto err;
332
#endif
333
      memcpy(record+keyseg->start+keyseg->bit_start,
212.6.12 by Mats Kindahl
Removing redundant use of casts in MyISAM storage for memcmp(), memcpy(), memset(), and memmove().
334
	     &blob_ptr,sizeof(char*));
1 by brian
clean slate
335
      memcpy(blob_ptr,key,length);
336
      blob_ptr+=length;
337
338
      /* The above changed info->lastkey2. Inform mi_rnext_same(). */
339
      info->update&= ~HA_STATE_RNEXT_SAME;
340
341
      _my_store_blob_length(record+keyseg->start,
342
			    (uint) keyseg->bit_start,length);
343
      key+=length;
344
    }
345
    else if (keyseg->flag & HA_SWAP_KEY)
346
    {
481 by Brian Aker
Remove all of uchar.
347
      unsigned char *to=  record+keyseg->start+keyseg->length;
348
      unsigned char *end= key+keyseg->length;
1 by brian
clean slate
349
#ifdef CHECK_KEYS
350
      if (end > key_end)
351
	goto err;
352
#endif
353
      do
354
      {
355
	 *--to= *key++;
356
      } while (key != end);
357
      continue;
358
    }
359
    else
360
    {
361
#ifdef CHECK_KEYS
362
      if (key+keyseg->length > key_end)
363
	goto err;
364
#endif
212.6.12 by Mats Kindahl
Removing redundant use of casts in MyISAM storage for memcmp(), memcpy(), memset(), and memmove().
365
      memcpy(record+keyseg->start, key, keyseg->length);
1 by brian
clean slate
366
      key+= keyseg->length;
367
    }
368
  }
51.1.101 by Jay Pipes
Removed/replaced DBUG symbols and TRUE/FALSE
369
  return(0);
1 by brian
clean slate
370
371
err:
51.1.101 by Jay Pipes
Removed/replaced DBUG symbols and TRUE/FALSE
372
  return(1);				/* Crashed row */
1 by brian
clean slate
373
} /* _mi_put_key_in_record */
374
375
376
	/* Here when key reads are used */
377
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
378
int _mi_read_key_record(MI_INFO *info, drizzled::internal::my_off_t filepos, unsigned char *buf)
1 by brian
clean slate
379
{
380
  fast_mi_writeinfo(info);
381
  if (filepos != HA_OFFSET_ERROR)
382
  {
383
    if (info->lastinx >= 0)
384
    {				/* Read only key */
385
      if (_mi_put_key_in_record(info,(uint) info->lastinx,buf))
386
      {
387
        mi_print_error(info->s, HA_ERR_CRASHED);
1241.9.57 by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined.
388
	errno=HA_ERR_CRASHED;
1 by brian
clean slate
389
	return -1;
390
      }
391
      info->update|= HA_STATE_AKTIV; /* We should find a record */
392
      return 0;
393
    }
1241.9.57 by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined.
394
    errno=HA_ERR_WRONG_INDEX;
1 by brian
clean slate
395
  }
396
  return(-1);				/* Wrong data to read */
397
}
398
399
400
/*
401
  Save current key tuple to record and call index condition check function
402
403
  SYNOPSIS
404
    mi_check_index_cond()
405
      info    MyISAM handler
406
      keynr   Index we're running a scan on
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
407
      record  Record buffer to use (it is assumed that index check function
1 by brian
clean slate
408
              will look for column values there)
409
410
  RETURN
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
411
    -1  Error
1 by brian
clean slate
412
    0   Index condition is not satisfied, continue scanning
413
    1   Index condition is satisfied
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
414
    2   Index condition is not satisfied, end the scan.
1 by brian
clean slate
415
*/
416
482 by Brian Aker
Remove uint.
417
int mi_check_index_cond(register MI_INFO *info, uint32_t keynr, unsigned char *record)
1 by brian
clean slate
418
{
419
  if (_mi_put_key_in_record(info, keynr, record))
420
  {
421
    mi_print_error(info->s, HA_ERR_CRASHED);
1241.9.57 by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined.
422
    errno=HA_ERR_CRASHED;
1 by brian
clean slate
423
    return -1;
424
  }
425
  return info->index_cond_func(info->index_cond_func_arg);
426
}
427
428
429
/*
430
  Retrieve auto_increment info
431
432
  SYNOPSIS
433
    retrieve_auto_increment()
434
    info			MyISAM handler
435
    record			Row to update
436
437
  IMPLEMENTATION
438
    For signed columns we don't retrieve the auto increment value if it's
439
    less than zero.
440
*/
441
481 by Brian Aker
Remove all of uchar.
442
uint64_t retrieve_auto_increment(MI_INFO *info,const unsigned char *record)
1 by brian
clean slate
443
{
151 by Brian Aker
Ulonglong to uint64_t
444
  uint64_t value= 0;			/* Store unsigned values here */
152 by Brian Aker
longlong replacement
445
  int64_t s_value= 0;			/* Store signed values here */
1 by brian
clean slate
446
  HA_KEYSEG *keyseg= info->s->keyinfo[info->s->base.auto_key-1].seg;
481 by Brian Aker
Remove all of uchar.
447
  const unsigned char *key= (unsigned char*) record + keyseg->start;
1 by brian
clean slate
448
449
  switch (keyseg->type) {
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
450
  case drizzled::HA_KEYTYPE_BINARY:
481 by Brian Aker
Remove all of uchar.
451
    value=(uint64_t)  *(unsigned char*) key;
1 by brian
clean slate
452
    break;
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
453
  case drizzled::HA_KEYTYPE_LONG_INT:
152 by Brian Aker
longlong replacement
454
    s_value= (int64_t) sint4korr(key);
1 by brian
clean slate
455
    break;
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
456
  case drizzled::HA_KEYTYPE_ULONG_INT:
151 by Brian Aker
Ulonglong to uint64_t
457
    value=(uint64_t) uint4korr(key);
1 by brian
clean slate
458
    break;
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
459
  case drizzled::HA_KEYTYPE_DOUBLE:                       /* This shouldn't be used */
1 by brian
clean slate
460
  {
461
    double f_1;
462
    float8get(f_1,key);
463
    /* Ignore negative values */
151 by Brian Aker
Ulonglong to uint64_t
464
    value = (f_1 < 0.0) ? 0 : (uint64_t) f_1;
1 by brian
clean slate
465
    break;
466
  }
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
467
  case drizzled::HA_KEYTYPE_LONGLONG:
1 by brian
clean slate
468
    s_value= sint8korr(key);
469
    break;
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
470
  case drizzled::HA_KEYTYPE_ULONGLONG:
1 by brian
clean slate
471
    value= uint8korr(key);
472
    break;
473
  default:
51.1.101 by Jay Pipes
Removed/replaced DBUG symbols and TRUE/FALSE
474
    assert(0);
1 by brian
clean slate
475
    value=0;                                    /* Error */
476
    break;
477
  }
478
479
  /*
480
    The following code works becasue if s_value < 0 then value is 0
481
    and if s_value == 0 then value will contain either s_value or the
482
    correct value.
483
  */
151 by Brian Aker
Ulonglong to uint64_t
484
  return (s_value > 0) ? (uint64_t) s_value : value;
1 by brian
clean slate
485
}