~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_key.c

  • 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:
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 "m_ctype.h"
 
20
#include "sp_defs.h"
20
21
#ifdef HAVE_IEEEFP_H
21
22
#include <ieeefp.h>
22
23
#endif
23
 
#include <math.h>
24
 
#include <cassert>
25
24
 
26
25
#define CHECK_KEYS                              /* Enable safety checks */
27
26
 
32
31
              set_if_smaller(char_length,length);                           \
33
32
            } while(0)
34
33
 
35
 
static int _mi_put_key_in_record(MI_INFO *info,uint32_t keynr,unsigned char *record);
 
34
static int _mi_put_key_in_record(MI_INFO *info,uint keynr,uchar *record);
36
35
 
37
36
/*
38
37
  Make a intern key from a record
49
48
    Length of key
50
49
*/
51
50
 
52
 
uint32_t _mi_make_key(register MI_INFO *info, uint32_t keynr, unsigned char *key,
53
 
                  const unsigned char *record, my_off_t filepos)
 
51
uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
 
52
                  const uchar *record, my_off_t filepos)
54
53
{
55
 
  unsigned char *pos;
56
 
  unsigned char *start;
 
54
  uchar *pos;
 
55
  uchar *start;
57
56
  register HA_KEYSEG *keyseg;
 
57
  my_bool is_ft= info->s->keyinfo[keynr].flag & HA_FULLTEXT;
 
58
  DBUG_ENTER("_mi_make_key");
 
59
 
 
60
  if (info->s->keyinfo[keynr].flag & HA_SPATIAL)
 
61
  {
 
62
    /*
 
63
      TODO: nulls processing
 
64
    */
 
65
#ifdef HAVE_SPATIAL
 
66
    DBUG_RETURN(sp_make_key(info,keynr,key,record,filepos));
 
67
#else
 
68
    DBUG_ASSERT(0); /* mi_open should check that this never happens*/
 
69
#endif
 
70
  }
58
71
 
59
72
  start=key;
60
73
  for (keyseg=info->s->keyinfo[keynr].seg ; keyseg->type ;keyseg++)
61
74
  {
62
75
    enum ha_base_keytype type=(enum ha_base_keytype) keyseg->type;
63
 
    uint32_t length=keyseg->length;
64
 
    uint32_t char_length;
65
 
    const CHARSET_INFO * const cs=keyseg->charset;
 
76
    uint length=keyseg->length;
 
77
    uint char_length;
 
78
    CHARSET_INFO *cs=keyseg->charset;
66
79
 
67
80
    if (keyseg->null_bit)
68
81
    {
74
87
      *key++=1;                                 /* Not NULL */
75
88
    }
76
89
 
77
 
    char_length= ((cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen :
 
90
    char_length= ((!is_ft && cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen :
78
91
                  length);
79
92
 
80
 
    pos= (unsigned char*) record+keyseg->start;
81
 
 
 
93
    pos= (uchar*) record+keyseg->start;
 
94
    if (type == HA_KEYTYPE_BIT)
 
95
    {
 
96
      if (keyseg->bit_length)
 
97
      {
 
98
        uchar bits= get_rec_bits((uchar*) record + keyseg->bit_pos,
 
99
                                 keyseg->bit_start, keyseg->bit_length);
 
100
        *key++= bits;
 
101
        length--;
 
102
      }
 
103
      memcpy((uchar*) key, pos, length);
 
104
      key+= length;
 
105
      continue;
 
106
    }
82
107
    if (keyseg->flag & HA_SPACE_PACK)
83
108
    {
84
 
      length= cs->cset->lengthsp(cs, (char*) pos, length);
85
 
 
 
109
      if (type != HA_KEYTYPE_NUM)
 
110
      {
 
111
        length= cs->cset->lengthsp(cs, (char*) pos, length);
 
112
      }
 
113
      else
 
114
      {
 
115
        uchar *end= pos + length;
 
116
        while (pos < end && pos[0] == ' ')
 
117
          pos++;
 
118
        length=(uint) (end-pos);
 
119
      }
86
120
      FIX_LENGTH(cs, pos, length, char_length);
87
121
      store_key_length_inc(key,char_length);
88
 
      memcpy(key, pos, char_length);
 
122
      memcpy((uchar*) key,(uchar*) pos,(size_t) char_length);
89
123
      key+=char_length;
90
124
      continue;
91
125
    }
92
126
    if (keyseg->flag & HA_VAR_LENGTH_PART)
93
127
    {
94
 
      uint32_t pack_length= (keyseg->bit_start == 1 ? 1 : 2);
95
 
      uint32_t tmp_length= (pack_length == 1 ? (uint) *(unsigned char*) pos :
 
128
      uint pack_length= (keyseg->bit_start == 1 ? 1 : 2);
 
129
      uint tmp_length= (pack_length == 1 ? (uint) *(uchar*) pos :
96
130
                        uint2korr(pos));
97
131
      pos+= pack_length;                        /* Skip VARCHAR length */
98
132
      set_if_smaller(length,tmp_length);
99
133
      FIX_LENGTH(cs, pos, length, char_length);
100
134
      store_key_length_inc(key,char_length);
101
 
      memcpy(key, pos, char_length);
 
135
      memcpy((uchar*) key,(uchar*) pos,(size_t) char_length);
102
136
      key+= char_length;
103
137
      continue;
104
138
    }
105
139
    else if (keyseg->flag & HA_BLOB_PART)
106
140
    {
107
 
      uint32_t tmp_length=_mi_calc_blob_length(keyseg->bit_start,pos);
108
 
      memcpy(&pos, pos+keyseg->bit_start, sizeof(char*));
 
141
      uint tmp_length=_mi_calc_blob_length(keyseg->bit_start,pos);
 
142
      memcpy_fixed((uchar*) &pos,pos+keyseg->bit_start,sizeof(char*));
109
143
      set_if_smaller(length,tmp_length);
110
144
      FIX_LENGTH(cs, pos, length, char_length);
111
145
      store_key_length_inc(key,char_length);
112
 
      memcpy(key, pos, char_length);
 
146
      memcpy((uchar*) key,(uchar*) pos,(size_t) char_length);
113
147
      key+= char_length;
114
148
      continue;
115
149
    }
116
150
    else if (keyseg->flag & HA_SWAP_KEY)
117
151
    {                                           /* Numerical column */
118
 
      if (type == HA_KEYTYPE_DOUBLE)
 
152
#ifdef HAVE_ISNAN
 
153
      if (type == HA_KEYTYPE_FLOAT)
 
154
      {
 
155
        float nr;
 
156
        float4get(nr,pos);
 
157
        if (isnan(nr))
 
158
        {
 
159
          /* Replace NAN with zero */
 
160
          bzero(key,length);
 
161
          key+=length;
 
162
          continue;
 
163
        }
 
164
      }
 
165
      else if (type == HA_KEYTYPE_DOUBLE)
119
166
      {
120
167
        double nr;
121
168
        float8get(nr,pos);
122
169
        if (isnan(nr))
123
170
        {
124
 
          memset(key, 0, length);
 
171
          bzero(key,length);
125
172
          key+=length;
126
173
          continue;
127
174
        }
128
175
      }
 
176
#endif
129
177
      pos+=length;
130
178
      while (length--)
131
179
      {
134
182
      continue;
135
183
    }
136
184
    FIX_LENGTH(cs, pos, length, char_length);
137
 
    memcpy(key, pos, char_length);
 
185
    memcpy((uchar*) key, pos, char_length);
138
186
    if (length > char_length)
139
187
      cs->cset->fill(cs, (char*) key+char_length, length-char_length, ' ');
140
188
    key+= length;
141
189
  }
142
190
  _mi_dpointer(info,key,filepos);
143
 
  return((uint) (key-start));           /* Return keylength */
 
191
  DBUG_PRINT("exit",("keynr: %d",keynr));
 
192
  DBUG_DUMP("key",(uchar*) start,(uint) (key-start)+keyseg->length);
 
193
  DBUG_EXECUTE("key",
 
194
               _mi_print_key(DBUG_FILE,info->s->keyinfo[keynr].seg,start,
 
195
                             (uint) (key-start)););
 
196
  DBUG_RETURN((uint) (key-start));              /* Return keylength */
144
197
} /* _mi_make_key */
145
198
 
146
199
 
150
203
  SYNOPSIS
151
204
    _mi_pack_key()
152
205
    info                MyISAM handler
153
 
    uint32_t keynr              key number
 
206
    uint keynr          key number
154
207
    key                 Store packed key here
155
208
    old                 Not packed key
156
209
    keypart_map         bitmap of used keyparts
162
215
     last_use_keyseg    Store pointer to the keyseg after the last used one
163
216
*/
164
217
 
165
 
uint32_t _mi_pack_key(register MI_INFO *info, uint32_t keynr, unsigned char *key, unsigned char *old,
 
218
uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old,
166
219
                  key_part_map keypart_map, HA_KEYSEG **last_used_keyseg)
167
220
{
168
 
  unsigned char *start_key=key;
 
221
  uchar *start_key=key;
169
222
  HA_KEYSEG *keyseg;
 
223
  my_bool is_ft= info->s->keyinfo[keynr].flag & HA_FULLTEXT;
 
224
  DBUG_ENTER("_mi_pack_key");
 
225
 
 
226
  /* "one part" rtree key is 2*SPDIMS part key in MyISAM */
 
227
  if (info->s->keyinfo[keynr].key_alg == HA_KEY_ALG_RTREE)
 
228
    keypart_map= (((key_part_map)1) << (2*SPDIMS)) - 1;
170
229
 
171
230
  /* only key prefixes are supported */
172
 
  assert(((keypart_map+1) & keypart_map) == 0);
 
231
  DBUG_ASSERT(((keypart_map+1) & keypart_map) == 0);
173
232
 
174
233
  for (keyseg= info->s->keyinfo[keynr].seg ; keyseg->type && keypart_map;
175
234
       old+= keyseg->length, keyseg++)
176
235
  {
177
236
    enum ha_base_keytype type= (enum ha_base_keytype) keyseg->type;
178
 
    uint32_t length= keyseg->length;
179
 
    uint32_t char_length;
180
 
    unsigned char *pos;
181
 
    const CHARSET_INFO * const cs=keyseg->charset;
 
237
    uint length= keyseg->length;
 
238
    uint char_length;
 
239
    uchar *pos;
 
240
    CHARSET_INFO *cs=keyseg->charset;
182
241
    keypart_map>>= 1;
183
242
    if (keyseg->null_bit)
184
243
    {
189
248
        continue;                                       /* Found NULL */
190
249
      }
191
250
    }
192
 
    char_length= (cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen : length;
 
251
    char_length= (!is_ft && cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen : length;
193
252
    pos=old;
194
253
    if (keyseg->flag & HA_SPACE_PACK)
195
254
    {
196
 
      unsigned char *end=pos+length;
197
 
 
198
 
      if (type != HA_KEYTYPE_BINARY)
 
255
      uchar *end=pos+length;
 
256
      if (type == HA_KEYTYPE_NUM)
 
257
      {
 
258
        while (pos < end && pos[0] == ' ')
 
259
          pos++;
 
260
      }
 
261
      else if (type != HA_KEYTYPE_BINARY)
199
262
      {
200
263
        while (end > pos && end[-1] == ' ')
201
264
          end--;
203
266
      length=(uint) (end-pos);
204
267
      FIX_LENGTH(cs, pos, length, char_length);
205
268
      store_key_length_inc(key,char_length);
206
 
      memcpy(key, pos, char_length);
 
269
      memcpy((uchar*) key,pos,(size_t) char_length);
207
270
      key+= char_length;
208
271
      continue;
209
272
    }
210
273
    else if (keyseg->flag & (HA_VAR_LENGTH_PART | HA_BLOB_PART))
211
274
    {
212
275
      /* Length of key-part used with mi_rkey() always 2 */
213
 
      uint32_t tmp_length=uint2korr(pos);
 
276
      uint tmp_length=uint2korr(pos);
214
277
      pos+=2;
215
278
      set_if_smaller(length,tmp_length);        /* Safety */
216
279
      FIX_LENGTH(cs, pos, length, char_length);
217
280
      store_key_length_inc(key,char_length);
218
281
      old+=2;                                   /* Skip length */
219
 
      memcpy(key, pos, char_length);
 
282
      memcpy((uchar*) key, pos,(size_t) char_length);
220
283
      key+= char_length;
221
284
      continue;
222
285
    }
228
291
      continue;
229
292
    }
230
293
    FIX_LENGTH(cs, pos, length, char_length);
231
 
    memcpy(key, pos, char_length);
 
294
    memcpy((uchar*) key, pos, char_length);
232
295
    if (length > char_length)
233
296
      cs->cset->fill(cs, (char*) key+char_length, length-char_length, ' ');
234
297
    key+= length;
236
299
  if (last_used_keyseg)
237
300
    *last_used_keyseg= keyseg;
238
301
 
239
 
  return((uint) (key-start_key));
 
302
  DBUG_RETURN((uint) (key-start_key));
240
303
} /* _mi_pack_key */
241
304
 
242
305
 
260
323
   1   error
261
324
*/
262
325
 
263
 
static int _mi_put_key_in_record(register MI_INFO *info, uint32_t keynr,
264
 
                                 unsigned char *record)
 
326
static int _mi_put_key_in_record(register MI_INFO *info, uint keynr,
 
327
                                 uchar *record)
265
328
{
266
 
  register unsigned char *key;
267
 
  unsigned char *pos,*key_end;
 
329
  register uchar *key;
 
330
  uchar *pos,*key_end;
268
331
  register HA_KEYSEG *keyseg;
269
 
  unsigned char *blob_ptr;
 
332
  uchar *blob_ptr;
 
333
  DBUG_ENTER("_mi_put_key_in_record");
270
334
 
271
 
  blob_ptr= (unsigned char*) info->lastkey2;             /* Place to put blob parts */
272
 
  key=(unsigned char*) info->lastkey;                    /* KEy that was read */
 
335
  blob_ptr= (uchar*) info->lastkey2;             /* Place to put blob parts */
 
336
  key=(uchar*) info->lastkey;                    /* KEy that was read */
273
337
  key_end=key+info->lastkey_length;
274
338
  for (keyseg=info->s->keyinfo[keynr].seg ; keyseg->type ;keyseg++)
275
339
  {
282
346
      }
283
347
      record[keyseg->null_pos]&= ~keyseg->null_bit;
284
348
    }
 
349
    if (keyseg->type == HA_KEYTYPE_BIT)
 
350
    {
 
351
      uint length= keyseg->length;
285
352
 
 
353
      if (keyseg->bit_length)
 
354
      {
 
355
        uchar bits= *key++;
 
356
        set_rec_bits(bits, record + keyseg->bit_pos, keyseg->bit_start,
 
357
                     keyseg->bit_length);
 
358
        length--;
 
359
      }
 
360
      else
 
361
      {
 
362
        clr_rec_bits(record + keyseg->bit_pos, keyseg->bit_start,
 
363
                     keyseg->bit_length);
 
364
      }
 
365
      memcpy(record + keyseg->start, (uchar*) key, length);
 
366
      key+= length;
 
367
      continue;
 
368
    }
286
369
    if (keyseg->flag & HA_SPACE_PACK)
287
370
    {
288
 
      uint32_t length;
 
371
      uint length;
289
372
      get_key_length(length,key);
290
373
#ifdef CHECK_KEYS
291
374
      if (length > keyseg->length || key+length > key_end)
292
375
        goto err;
293
376
#endif
294
377
      pos= record+keyseg->start;
295
 
 
296
 
      memcpy(pos, key, length);
297
 
      keyseg->charset->cset->fill(keyseg->charset,
298
 
                                  (char*) pos + length,
299
 
                                  keyseg->length - length,
300
 
                                  ' ');
 
378
      if (keyseg->type != (int) HA_KEYTYPE_NUM)
 
379
      {
 
380
        memcpy(pos,key,(size_t) length);
 
381
        keyseg->charset->cset->fill(keyseg->charset,
 
382
                                    (char*) pos + length,
 
383
                                    keyseg->length - length,
 
384
                                    ' ');
 
385
      }
 
386
      else
 
387
      {
 
388
        bfill(pos,keyseg->length-length,' ');
 
389
        memcpy(pos+keyseg->length-length,key,(size_t) length);
 
390
      }
301
391
      key+=length;
302
392
      continue;
303
393
    }
304
394
 
305
395
    if (keyseg->flag & HA_VAR_LENGTH_PART)
306
396
    {
307
 
      uint32_t length;
 
397
      uint length;
308
398
      get_key_length(length,key);
309
399
#ifdef CHECK_KEYS
310
400
      if (length > keyseg->length || key+length > key_end)
312
402
#endif
313
403
      /* Store key length */
314
404
      if (keyseg->bit_start == 1)
315
 
        *(unsigned char*) (record+keyseg->start)= (unsigned char) length;
 
405
        *(uchar*) (record+keyseg->start)= (uchar) length;
316
406
      else
317
407
        int2store(record+keyseg->start, length);
318
408
      /* And key data */
319
 
      memcpy(record+keyseg->start + keyseg->bit_start, key, length);
 
409
      memcpy(record+keyseg->start + keyseg->bit_start, (uchar*) key, length);
320
410
      key+= length;
321
411
    }
322
412
    else if (keyseg->flag & HA_BLOB_PART)
323
413
    {
324
 
      uint32_t length;
 
414
      uint length;
325
415
      get_key_length(length,key);
326
416
#ifdef CHECK_KEYS
327
417
      if (length > keyseg->length || key+length > key_end)
328
418
        goto err;
329
419
#endif
330
420
      memcpy(record+keyseg->start+keyseg->bit_start,
331
 
             &blob_ptr,sizeof(char*));
 
421
             (char*) &blob_ptr,sizeof(char*));
332
422
      memcpy(blob_ptr,key,length);
333
423
      blob_ptr+=length;
334
424
 
341
431
    }
342
432
    else if (keyseg->flag & HA_SWAP_KEY)
343
433
    {
344
 
      unsigned char *to=  record+keyseg->start+keyseg->length;
345
 
      unsigned char *end= key+keyseg->length;
 
434
      uchar *to=  record+keyseg->start+keyseg->length;
 
435
      uchar *end= key+keyseg->length;
346
436
#ifdef CHECK_KEYS
347
437
      if (end > key_end)
348
438
        goto err;
359
449
      if (key+keyseg->length > key_end)
360
450
        goto err;
361
451
#endif
362
 
      memcpy(record+keyseg->start, key, keyseg->length);
 
452
      memcpy(record+keyseg->start,(uchar*) key,
 
453
             (size_t) keyseg->length);
363
454
      key+= keyseg->length;
364
455
    }
365
456
  }
366
 
  return(0);
 
457
  DBUG_RETURN(0);
367
458
 
368
459
err:
369
 
  return(1);                            /* Crashed row */
 
460
  DBUG_RETURN(1);                               /* Crashed row */
370
461
} /* _mi_put_key_in_record */
371
462
 
372
463
 
373
464
        /* Here when key reads are used */
374
465
 
375
 
int _mi_read_key_record(MI_INFO *info, my_off_t filepos, unsigned char *buf)
 
466
int _mi_read_key_record(MI_INFO *info, my_off_t filepos, uchar *buf)
376
467
{
377
468
  fast_mi_writeinfo(info);
378
469
  if (filepos != HA_OFFSET_ERROR)
382
473
      if (_mi_put_key_in_record(info,(uint) info->lastinx,buf))
383
474
      {
384
475
        mi_print_error(info->s, HA_ERR_CRASHED);
385
 
        errno=HA_ERR_CRASHED;
 
476
        my_errno=HA_ERR_CRASHED;
386
477
        return -1;
387
478
      }
388
479
      info->update|= HA_STATE_AKTIV; /* We should find a record */
389
480
      return 0;
390
481
    }
391
 
    errno=HA_ERR_WRONG_INDEX;
 
482
    my_errno=HA_ERR_WRONG_INDEX;
392
483
  }
393
484
  return(-1);                           /* Wrong data to read */
394
485
}
401
492
    mi_check_index_cond()
402
493
      info    MyISAM handler
403
494
      keynr   Index we're running a scan on
404
 
      record  Record buffer to use (it is assumed that index check function
 
495
      record  Record buffer to use (it is assumed that index check function 
405
496
              will look for column values there)
406
497
 
407
498
  RETURN
408
 
    -1  Error
 
499
    -1  Error 
409
500
    0   Index condition is not satisfied, continue scanning
410
501
    1   Index condition is satisfied
411
 
    2   Index condition is not satisfied, end the scan.
 
502
    2   Index condition is not satisfied, end the scan. 
412
503
*/
413
504
 
414
 
int mi_check_index_cond(register MI_INFO *info, uint32_t keynr, unsigned char *record)
 
505
int mi_check_index_cond(register MI_INFO *info, uint keynr, uchar *record)
415
506
{
416
507
  if (_mi_put_key_in_record(info, keynr, record))
417
508
  {
418
509
    mi_print_error(info->s, HA_ERR_CRASHED);
419
 
    errno=HA_ERR_CRASHED;
 
510
    my_errno=HA_ERR_CRASHED;
420
511
    return -1;
421
512
  }
422
513
  return info->index_cond_func(info->index_cond_func_arg);
436
527
    less than zero.
437
528
*/
438
529
 
439
 
uint64_t retrieve_auto_increment(MI_INFO *info,const unsigned char *record)
 
530
ulonglong retrieve_auto_increment(MI_INFO *info,const uchar *record)
440
531
{
441
 
  uint64_t value= 0;                    /* Store unsigned values here */
442
 
  int64_t s_value= 0;                   /* Store signed values here */
 
532
  ulonglong value= 0;                   /* Store unsigned values here */
 
533
  longlong s_value= 0;                  /* Store signed values here */
443
534
  HA_KEYSEG *keyseg= info->s->keyinfo[info->s->base.auto_key-1].seg;
444
 
  const unsigned char *key= (unsigned char*) record + keyseg->start;
 
535
  const uchar *key= (uchar*) record + keyseg->start;
445
536
 
446
537
  switch (keyseg->type) {
 
538
  case HA_KEYTYPE_INT8:
 
539
    s_value= (longlong) *(char*)key;
 
540
    break;
447
541
  case HA_KEYTYPE_BINARY:
448
 
    value=(uint64_t)  *(unsigned char*) key;
 
542
    value=(ulonglong)  *(uchar*) key;
 
543
    break;
 
544
  case HA_KEYTYPE_SHORT_INT:
 
545
    s_value= (longlong) sint2korr(key);
 
546
    break;
 
547
  case HA_KEYTYPE_USHORT_INT:
 
548
    value=(ulonglong) uint2korr(key);
449
549
    break;
450
550
  case HA_KEYTYPE_LONG_INT:
451
 
    s_value= (int64_t) sint4korr(key);
 
551
    s_value= (longlong) sint4korr(key);
452
552
    break;
453
553
  case HA_KEYTYPE_ULONG_INT:
454
 
    value=(uint64_t) uint4korr(key);
 
554
    value=(ulonglong) uint4korr(key);
 
555
    break;
 
556
  case HA_KEYTYPE_INT24:
 
557
    s_value= (longlong) sint3korr(key);
455
558
    break;
456
559
  case HA_KEYTYPE_UINT24:
457
 
    value=(uint64_t) uint3korr(key);
458
 
    break;
 
560
    value=(ulonglong) uint3korr(key);
 
561
    break;
 
562
  case HA_KEYTYPE_FLOAT:                        /* This shouldn't be used */
 
563
  {
 
564
    float f_1;
 
565
    float4get(f_1,key);
 
566
    /* Ignore negative values */
 
567
    value = (f_1 < (float) 0.0) ? 0 : (ulonglong) f_1;
 
568
    break;
 
569
  }
459
570
  case HA_KEYTYPE_DOUBLE:                       /* This shouldn't be used */
460
571
  {
461
572
    double f_1;
462
573
    float8get(f_1,key);
463
574
    /* Ignore negative values */
464
 
    value = (f_1 < 0.0) ? 0 : (uint64_t) f_1;
 
575
    value = (f_1 < 0.0) ? 0 : (ulonglong) f_1;
465
576
    break;
466
577
  }
467
578
  case HA_KEYTYPE_LONGLONG:
471
582
    value= uint8korr(key);
472
583
    break;
473
584
  default:
474
 
    assert(0);
 
585
    DBUG_ASSERT(0);
475
586
    value=0;                                    /* Error */
476
587
    break;
477
588
  }
481
592
    and if s_value == 0 then value will contain either s_value or the
482
593
    correct value.
483
594
  */
484
 
  return (s_value > 0) ? (uint64_t) s_value : value;
 
595
  return (s_value > 0) ? (ulonglong) s_value : value;
485
596
}