1
/* Copyright (C) 2002-2006 MySQL AB
3
This library is free software; you can redistribute it and/or
4
modify it under the terms of the GNU Library General Public
5
License as published by the Free Software Foundation; version 2
8
This library is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
Library General Public License for more details.
13
You should have received a copy of the GNU Library General Public
14
License along with this library; if not, write to the Free
15
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18
#include "mysys_priv.h"
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#include <drizzled/global.h>
20
22
#include <mystrings/m_ctype.h>
21
23
#include <drizzled/base.h>
22
#include <my_handler.h>
25
#include "my_handler_errors.h"
27
int ha_compare_text(const CHARSET_INFO * const charset_info, uchar *a, uint a_length,
28
uchar *b, uint b_length, bool part_key,
24
#include <plugin/myisam/my_handler.h>
25
#include <mysys/my_sys.h>
32
Swap the contents of two variables.
34
#define swap_variables(TYPE, a, b) \
42
#define CMP_NUM(a,b) (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
45
int ha_compare_text(const CHARSET_INFO * const charset_info, unsigned char *a, uint32_t a_length,
46
unsigned char *b, uint32_t b_length, bool part_key,
29
47
bool skip_end_space)
39
static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
57
static int compare_bin(unsigned char *a, uint32_t a_length, unsigned char *b, uint32_t b_length,
40
58
bool part_key, bool skip_end_space)
42
uint length= min(a_length,b_length);
43
uchar *end= a+ length;
60
uint32_t length= min(a_length,b_length);
61
unsigned char *end= a+ length;
91
109
next_flag How keys should be compared
92
110
If bit SEARCH_FIND is not set the keys includes the row
93
111
position and this should also be compared
94
diff_pos OUT Number of first keypart where values differ, counting
112
diff_pos OUT Number of first keypart where values differ, counting
96
114
diff_pos[1] OUT (b + diff_pos[1]) points to first value in tuple b
97
115
that is different from corresponding value in tuple a.
100
118
Example1: if the function is called for tuples
101
119
('aaa','bbb') and ('eee','fff'), then
102
120
diff_pos[0] = 1 (as 'aaa' != 'eee')
120
138
#define FCMP(A,B) ((int) (A) - (int) (B))
122
int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
123
register uchar *b, uint key_length, uint nextflag,
140
int ha_key_cmp(register HA_KEYSEG *keyseg, register unsigned char *a,
141
register unsigned char *b, uint32_t key_length, uint32_t nextflag,
194
uint length=(uint) (end-a), a_length=length, b_length=length;
212
uint32_t length=(uint) (end-a), a_length=length, b_length=length;
196
214
(flag= ha_compare_text(keyseg->charset, a, a_length, b, b_length,
197
215
(bool) ((nextflag & SEARCH_PREFIX) &&
569
Register handler error messages for usage with my_error()
572
This is safe to call multiple times as my_error_register()
573
will ignore calls to register already registered error numbers.
577
void my_handler_error_register(void)
580
If you got compilation error here about compile_time_assert array, check
581
that every HA_ERR_xxx constant has a corresponding error message in
582
handler_error_messages[] list (check mysys/ma_handler_errors.h and
585
compile_time_assert(HA_ERR_FIRST + array_elements(handler_error_messages) ==
587
my_error_register(handler_error_messages, HA_ERR_FIRST,
588
HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
592
void my_handler_error_unregister(void)
594
my_error_unregister(HA_ERR_FIRST,
595
HA_ERR_FIRST+ array_elements(handler_error_messages)-1);