~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_handler.c

  • Committer: Patrick Galbraith
  • Date: 2008-07-24 16:57:40 UTC
  • mto: (202.2.4 rename-mysql-to-drizzle)
  • mto: This revision was merged to the branch mainline in revision 212.
  • Revision ID: patg@ishvara-20080724165740-x58yw6zs6d9o17lf
Most everything working with client rename
mysqlslap test still fails... can't connect to the server

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16
16
   MA 02111-1307, USA */
17
17
 
18
 
#include "mysys_priv.h"
19
 
 
20
 
#include <mystrings/m_ctype.h>
21
 
#include <drizzled/base.h>
 
18
#include <my_global.h>
 
19
#include <m_ctype.h>
 
20
#include <my_base.h>
22
21
#include <my_handler.h>
23
22
#include <my_sys.h>
24
23
 
 
24
#include "mysys_priv.h"
25
25
#include "my_handler_errors.h"
26
26
 
27
 
/**
28
 
  Swap the contents of two variables.
29
 
 */
30
 
#define swap_variables(TYPE, a, b) \
31
 
  do {                             \
32
 
    TYPE dummy;                    \
33
 
    dummy= a;                      \
34
 
    a= b;                          \
35
 
    b= dummy;                      \
36
 
  } while (0)
37
 
 
38
 
#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
39
 
 
40
 
 
41
 
int ha_compare_text(const CHARSET_INFO * const charset_info, unsigned char *a, uint32_t a_length,
42
 
                    unsigned char *b, uint32_t b_length, bool part_key,
 
27
int ha_compare_text(CHARSET_INFO *charset_info, uchar *a, uint a_length,
 
28
                    uchar *b, uint b_length, bool part_key,
43
29
                    bool skip_end_space)
44
30
{
45
31
  if (!part_key)
50
36
}
51
37
 
52
38
 
53
 
static int compare_bin(unsigned char *a, uint32_t a_length, unsigned char *b, uint32_t b_length,
 
39
static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
54
40
                       bool part_key, bool skip_end_space)
55
41
{
56
 
  uint32_t length= cmin(a_length,b_length);
57
 
  unsigned char *end= a+ length;
 
42
  uint length= min(a_length,b_length);
 
43
  uchar *end= a+ length;
58
44
  int flag;
59
45
 
60
46
  while (a < end)
133
119
 
134
120
#define FCMP(A,B) ((int) (A) - (int) (B))
135
121
 
136
 
int ha_key_cmp(register HA_KEYSEG *keyseg, register unsigned char *a,
137
 
               register unsigned char *b, uint32_t key_length, uint32_t nextflag,
138
 
               uint32_t *diff_pos)
 
122
int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
 
123
               register uchar *b, uint key_length, uint nextflag,
 
124
               uint *diff_pos)
139
125
{
140
126
  int flag;
141
127
  int16_t s_1,s_2;
143
129
  uint32_t u_1,u_2;
144
130
  float f_1,f_2;
145
131
  double d_1,d_2;
146
 
  uint32_t next_key_length;
147
 
  unsigned char *orig_b= b;
 
132
  uint next_key_length;
 
133
  uchar *orig_b= b;
148
134
 
149
135
  *diff_pos=0;
150
136
  for ( ; (int) key_length >0 ; key_length=next_key_length, keyseg++)
151
137
  {
152
 
    unsigned char *end;
153
 
    uint32_t piks=! (keyseg->flag & HA_NO_SORT);
 
138
    uchar *end;
 
139
    uint piks=! (keyseg->flag & HA_NO_SORT);
154
140
    (*diff_pos)++;
155
141
    diff_pos[1]= (uint)(b - orig_b);
156
142
 
181
167
        continue;                               /* To next key part */
182
168
      }
183
169
    }
184
 
    end= a+ cmin(keyseg->length,key_length);
 
170
    end= a+ min(keyseg->length,key_length);
185
171
    next_key_length=key_length-keyseg->length;
186
172
 
187
173
    switch ((enum ha_base_keytype) keyseg->type) {
205
191
      }
206
192
      else
207
193
      {
208
 
        uint32_t length=(uint) (end-a), a_length=length, b_length=length;
 
194
        uint length=(uint) (end-a), a_length=length, b_length=length;
209
195
        if (piks &&
210
196
            (flag= ha_compare_text(keyseg->charset, a, a_length, b, b_length,
211
197
                                   (bool) ((nextflag & SEARCH_PREFIX) &&
236
222
      }
237
223
      else
238
224
      {
239
 
        uint32_t length=keyseg->length;
 
225
        uint length=keyseg->length;
240
226
        if (piks &&
241
227
            (flag=compare_bin(a,length,b,length,
242
228
                              (bool) ((nextflag & SEARCH_PREFIX) &&
381
367
 
382
368
      if (keyseg->flag & HA_REVERSE_SORT)
383
369
      {
384
 
        swap_variables(unsigned char*, a, b);
 
370
        swap_variables(uchar*, a, b);
385
371
        swap_flag=1;                            /* Remember swap of a & b */
386
372
        end= a+ (int) (end-b);
387
373
      }
406
392
          if (*b != '-')
407
393
            return -1;
408
394
          a++; b++;
409
 
          swap_variables(unsigned char*, a, b);
 
395
          swap_variables(uchar*, a, b);
410
396
          swap_variables(int, alength, blength);
411
397
          swap_flag=1-swap_flag;
412
398
          alength--; blength--;
435
421
      }
436
422
 
437
423
      if (swap_flag)                            /* Restore pointers */
438
 
        swap_variables(unsigned char*, a, b);
 
424
        swap_variables(uchar*, a, b);
439
425
      break;
440
426
    }
441
427
    case HA_KEYTYPE_LONGLONG:
468
454
end:
469
455
  if (!(nextflag & SEARCH_FIND))
470
456
  {
471
 
    uint32_t i;
 
457
    uint i;
472
458
    if (nextflag & (SEARCH_NO_FIND | SEARCH_LAST)) /* Find record after key */
473
459
      return (nextflag & (SEARCH_BIGGER | SEARCH_LAST)) ? -1 : 1;
474
460
    flag=0;
511
497
    NULLs.
512
498
*/
513
499
 
514
 
HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, unsigned char *a)
 
500
HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a)
515
501
{
516
502
  for (; (enum ha_base_keytype) keyseg->type != HA_KEYTYPE_END; keyseg++)
517
503
  {
518
 
    unsigned char *end;
 
504
    uchar *end;
519
505
    if (keyseg->null_bit)
520
506
    {
521
507
      if (!*a++)
595
581
    that every HA_ERR_xxx constant has a corresponding error message in
596
582
    handler_error_messages[] list (check mysys/ma_handler_errors.h and
597
583
    include/my_base.h).
598
 
 
599
 
    TODO: Remove fix the handler_error_messages so that this hack isn't 
600
 
          necessary.
601
584
  */
602
 
#ifdef __GNUC__
603
 
  char compile_time_assert[(HA_ERR_FIRST +
604
 
                            array_elements(handler_error_messages) ==
605
 
                            HA_ERR_LAST + 1) ? 1 : -1]
606
 
      __attribute__ ((__unused__));
607
 
#endif
 
585
  compile_time_assert(HA_ERR_FIRST + array_elements(handler_error_messages) ==
 
586
                      HA_ERR_LAST + 1);
608
587
  my_error_register(handler_error_messages, HA_ERR_FIRST,
609
588
                    HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
610
589
}