Commit edb8ae0f authored by unknown's avatar unknown

Simple charsets now have strncoll() field too

parent ac97cce4
......@@ -507,7 +507,7 @@ int sortcmp(const String *x,const String *y)
uint32 x_len=x->length(),y_len=y->length(),len=min(x_len,y_len);
#ifdef USE_STRCOLL
if (use_strcoll(x->str_charset))
if (use_strnxfrm(x->str_charset))
{
#ifndef CMP_ENDSPACE
while (x_len && my_isspace(x->str_charset,s[x_len-1]))
......
......@@ -92,12 +92,13 @@ typedef struct charset_info_st
int (*wc_mb)(struct charset_info_st *cs,my_wc_t wc,
unsigned char *s,unsigned char *e);
/* Functions for case convertion */
/* Functions for case and sort convertion */
void (*caseup_str)(struct charset_info_st *, char *);
void (*casedn_str)(struct charset_info_st *, char *);
void (*caseup)(struct charset_info_st *, char *, uint);
void (*casedn)(struct charset_info_st *, char *, uint);
void (*tosort)(struct charset_info_st *, char *, uint);
/* Functions for case comparison */
int (*strcasecmp)(struct charset_info_st *, const char *, const char *);
int (*strncasecmp)(struct charset_info_st *, const char *, const char *,
......@@ -125,14 +126,15 @@ extern const char *compiled_charset_name(uint charset_number);
#define MY_CHARSET_CURRENT (default_charset_info->number)
/* declarations for simple charsets */
extern int my_strnxfrm_simple(CHARSET_INFO *, char *, uint, const char *, uint);
extern int my_strnncoll_simple(CHARSET_INFO *, const char *, uint, const char *, uint);
extern int my_strnxfrm_simple(CHARSET_INFO *, uchar *, uint, const uchar *, uint);
extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, uint, const uchar *, uint);
/* Functions for 8bit */
extern void my_caseup_str_8bit(CHARSET_INFO *, char *);
extern void my_casedn_str_8bit(CHARSET_INFO *, char *);
extern void my_caseup_8bit(CHARSET_INFO *, char *, uint);
extern void my_casedn_8bit(CHARSET_INFO *, char *, uint);
extern void my_tosort_8bit(CHARSET_INFO *, char *, uint);
extern int my_strcasecmp_8bit(CHARSET_INFO * cs, const char *, const char *);
extern int my_strncasecmp_8bit(CHARSET_INFO * cs, const char *, const char *, uint);
......@@ -364,7 +366,7 @@ void my_hash_sort_ucs2(struct charset_info_st *cs, const uchar *key, uint len, u
#define my_isvar(s,c) (my_isalnum(s,c) || (c) == '_')
#define my_isvar_start(s,c) (my_isalpha(s,c) || (c) == '_')
#define use_strcoll(s) ((s)->strnncoll != NULL)
#define use_strnxfrm(s) ((s)->strnxfrm != NULL)
#define my_strnxfrm(s, a, b, c, d) ((s)->strnxfrm((s), (a), (b), (c), (d)))
#define my_strnncoll(s, a, b, c, d) ((s)->strnncoll((s), (a), (b), (c), (d)))
#define my_like_range(s, a, b, c, d, e, f, g, h) \
......@@ -377,6 +379,7 @@ void my_hash_sort_ucs2(struct charset_info_st *cs, const uchar *key, uint len, u
#define my_caseup(s, a, l) ((s)->caseup((s), (a), (l)))
#define my_casedn(s, a, l) ((s)->casedn((s), (a), (l)))
#define my_tosort(s, a, l) ((s)->tosort((s), (a), (l)))
#define my_caseup_str(s, a) ((s)->caseup_str((s), (a)))
#define my_casedn_str(s, a) ((s)->casedn_str((s), (a)))
#define my_strcasecmp(s, a, b) ((s)->strcasecmp((s), (a), (b)))
......
......@@ -583,7 +583,6 @@ extern void allow_break(void);
#endif
extern void my_remember_signal(int signal_number,sig_handler (*func)(int));
extern void case_sort(CHARSET_INFO *cs, my_string str,uint length);
extern uint dirname_part(my_string to,const char *name);
extern uint dirname_length(const char *name);
#define base_name(A) (A+dirname_length(A))
......
......@@ -54,11 +54,11 @@ uint _nisam_make_key(register N_INFO *info, uint keynr, uchar *key, const char *
*key++= (uchar) (length=(uint) (end-pos));
memcpy((byte*) key,(byte*) pos,(size_t) length);
#ifdef USE_STRCOLL
if (!use_strcoll(default_charset_info))
if (!use_strnxfrm(default_charset_info))
#endif
{
if (type == HA_KEYTYPE_TEXT)
case_sort(default_charset_info,(byte*) key,length);
my_tosort(default_charset_info,(byte*) key,length);
}
key+=length;
}
......@@ -67,11 +67,11 @@ uint _nisam_make_key(register N_INFO *info, uint keynr, uchar *key, const char *
memcpy((byte*) key,(byte*) record+keyseg->base.start,
(size_t) keyseg->base.length);
#ifdef USE_STRCOLL
if (!use_strcoll(default_charset_info))
if (!use_strnxfrm(default_charset_info))
#endif
{
if (type == HA_KEYTYPE_TEXT)
case_sort(default_charset_info,(byte*) key,(uint) keyseg->base.length);
my_tosort(default_charset_info,(byte*) key,(uint) keyseg->base.length);
}
#ifdef NAN_TEST
else if (type == HA_KEYTYPE_FLOAT)
......@@ -150,11 +150,11 @@ uint _nisam_pack_key(register N_INFO *info, uint keynr, uchar *key, uchar *old,
else
memcpy((byte*) key,old,(size_t) length);
#ifdef USE_STRCOLL
if (!use_strcoll(default_charset_info))
if (!use_strnxfrm(default_charset_info))
#endif
{
if (type == HA_KEYTYPE_TEXT)
case_sort(default_charset_info,(byte*) key,length);
my_tosort(default_charset_info,(byte*) key,length);
}
key+= length;
}
......
......@@ -332,7 +332,7 @@ int _nisam_key_cmp(register N_KEYSEG *keyseg, register uchar *a, register uchar
end= a+ min(key_length,(uint) length);
#ifdef USE_STRCOLL
if (use_strcoll(default_charset_info)) {
if (use_strnxfrm(default_charset_info)) {
if (((enum ha_base_keytype) keyseg->base.type) == HA_KEYTYPE_BINARY)
{
while (a < end)
......@@ -383,7 +383,7 @@ int _nisam_key_cmp(register N_KEYSEG *keyseg, register uchar *a, register uchar
else
{
#ifdef USE_STRCOLL
if (use_strcoll(default_charset_info)) {
if (use_strnxfrm(default_charset_info)) {
if (((enum ha_base_keytype) keyseg->base.type) == HA_KEYTYPE_BINARY)
{
while (a < end)
......
......@@ -685,7 +685,7 @@ static void setup_key_functions(register MI_KEYDEF *keyinfo)
keyinfo->get_key= _mi_get_pack_key;
if (keyinfo->seg[0].flag & HA_PACK_KEY)
{ /* Prefix compression */
if (!keyinfo->seg->charset || use_strcoll(keyinfo->seg->charset) ||
if (!keyinfo->seg->charset || use_strnxfrm(keyinfo->seg->charset) ||
(keyinfo->seg->flag & HA_NULL_PART))
keyinfo->bin_search=_mi_seq_search;
else
......
......@@ -1287,7 +1287,7 @@ _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key,
if ((keyinfo->flag & HA_FULLTEXT) &&
((keyseg->type == HA_KEYTYPE_TEXT) ||
(keyseg->type == HA_KEYTYPE_VARTEXT)) &&
!use_strcoll(keyseg->charset))
!use_strnxfrm(keyseg->charset))
sort_order=keyseg->charset->sort_order;
/* diff flag contains how many bytes is needed to pack key */
......
......@@ -377,6 +377,7 @@ static CHARSET_INFO *add_charset(uint cs_number, myf flags)
cs->casedn_str = my_casedn_str_8bit;
cs->caseup = my_caseup_8bit;
cs->casedn = my_casedn_8bit;
cs->tosort = my_tosort_8bit;
cs->strcasecmp = my_strcasecmp_8bit;
cs->strncasecmp = my_strncasecmp_8bit;
cs->mb_wc = my_mb_wc_8bit;
......
......@@ -15,11 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
Functions to convert to lover_case and to upper_case in scandinavia.
case_sort converts a character string to a representaion that can
be compared by strcmp to find with is alfabetical bigger.
(lower- and uppercase letters is compared as the same)
Functions to convert to lover_case and to upper_case.
*/
#include "mysys_priv.h"
......@@ -29,21 +25,11 @@
#endif
/* to sort-string that can be compared to get text in order */
void case_sort(CHARSET_INFO *cs, my_string str, uint length)
{
register uchar *map=cs->sort_order;
for ( ; length>0 ; length--, str++)
*str= (char) map[(uchar) *str];
} /* case_sort */
int my_sortcmp(CHARSET_INFO *cs, const char *s, const char *t, uint len)
{
#ifdef USE_STRCOLL
if (use_strcoll(cs))
if (use_strnxfrm(cs))
return my_strnncoll(cs,(uchar *)s, len, (uchar *)t, len);
else
#endif
......@@ -63,7 +49,7 @@ int my_sortncmp(CHARSET_INFO *cs,
const char *t, uint t_len)
{
#ifdef USE_STRCOLL
if (use_strcoll(cs))
if (use_strnxfrm(cs))
return my_strnncoll(cs, (uchar *)s, s_len, (uchar *)t, t_len);
else
#endif
......
......@@ -23,7 +23,7 @@ int mi_compare_text(CHARSET_INFO *charset_info, uchar *a, uint a_length,
int flag;
#ifdef USE_STRCOLL
if (use_strcoll(charset_info))
if (use_strnxfrm(charset_info))
{
if (part_key && b_length < a_length)
a_length=b_length;
......
......@@ -3841,7 +3841,7 @@ void Field_string::sort_string(char *to,uint length)
else
{
#ifdef USE_STRCOLL
if (use_strcoll(field_charset)) {
if (use_strnxfrm(field_charset)) {
uint tmp=my_strnxfrm(field_charset,
(unsigned char *)to, length,
(unsigned char *) ptr, field_length);
......@@ -4045,7 +4045,7 @@ void Field_varstring::sort_string(char *to,uint length)
else
{
#ifdef USE_STRCOLL
if (use_strcoll(field_charset))
if (use_strnxfrm(field_charset))
tot_length=my_strnxfrm(field_charset,
(unsigned char *) to, length,
(unsigned char *)ptr+2, tot_length);
......@@ -4536,7 +4536,7 @@ void Field_blob::sort_string(char *to,uint length)
else
{
#ifdef USE_STRCOLL
if (use_strcoll(field_charset))
if (use_strnxfrm(field_charset))
{
blob_length=my_strnxfrm(field_charset,
(unsigned char *)to, length,
......
......@@ -140,7 +140,7 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
records=param.max_rows; /* purecov: inspected */
#ifdef USE_STRCOLL
if (use_strcoll(charset) &&
if (use_strnxfrm(charset) &&
!(param.tmp_buffer=my_malloc(param.sort_length,MYF(MY_WME))))
goto err;
#endif
......@@ -511,7 +511,7 @@ static void make_sortkey(register SORTPARAM *param,
length=sort_field->length;
}
#ifdef USE_STRCOLL
if(use_strcoll(cs))
if(use_strnxfrm(cs))
{
if (item->binary)
{
......@@ -541,7 +541,7 @@ static void make_sortkey(register SORTPARAM *param,
memcpy(to,res->ptr(),length);
bzero((char *)to+length,diff);
if (!item->binary)
case_sort(cs, (char*) to,length);
my_tosort(cs, (char*) to,length);
#ifdef USE_STRCOLL
}
#endif
......@@ -946,7 +946,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length)
if (!sortorder->field->binary())
{
CHARSET_INFO *cs=((Field_str*)(sortorder->field))->charset();
if (use_strcoll(cs))
if (use_strnxfrm(cs))
sortorder->length= sortorder->length*cs->strxfrm_multiply;
}
#endif
......@@ -966,7 +966,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length)
if (!sortorder->item->binary)
{
CHARSET_INFO *cs=sortorder->item->str_value.charset();
if (use_strcoll(cs))
if (use_strnxfrm(cs))
sortorder->length= sortorder->length*cs->strxfrm_multiply;
}
#endif
......
......@@ -978,7 +978,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
{
CHARSET_INFO *charset=((Field_str*)(field))->charset();
#ifdef USE_STRCOLL
if (use_strcoll(charset))
if (use_strnxfrm(charset))
like_error= my_like_range(charset,
res->ptr(),res->length(),wild_prefix,
field_length, min_str+maybe_null,
......
......@@ -505,7 +505,7 @@ int sortcmp(const String *x,const String *y)
uint32 x_len=x->length(),y_len=y->length(),len=min(x_len,y_len);
#ifdef USE_STRCOLL
if (use_strcoll(x->str_charset))
if (use_strnxfrm(x->str_charset))
{
#ifndef CMP_ENDSPACE
while (x_len && my_isspace(x->str_charset,s[x_len-1]))
......
......@@ -20,32 +20,30 @@
#include "assert.h"
int my_strnxfrm_simple(CHARSET_INFO * cs,
char *dest, uint len,
const char *src, uint srclen)
uchar *dest, uint len,
const uchar *src, uint srclen)
{
uchar *map= cs->sort_order;
DBUG_ASSERT(len >= srclen);
for ( ; len > 0 ; len-- )
*dest++= (char) map[(uchar) *src++];
*dest++= map[*src++];
return srclen;
}
int my_strnncoll_simple(CHARSET_INFO * cs, const char *s, uint slen,
const char *t, uint tlen)
int my_strnncoll_simple(CHARSET_INFO * cs, const uchar *s, uint slen,
const uchar *t, uint tlen)
{
int len = ( slen > tlen ) ? tlen : slen;
uchar *map= cs->sort_order;
while (len--)
{
if (map[(uchar) *s++] != map[(uchar) *t++])
return ((int) map[(uchar) s[-1]] -
(int) map[(uchar) t[-1]]);
if (map[*s++] != map[*t++])
return ((int) map[s[-1]] - (int) map[t[-1]]);
}
return (int) (slen-tlen);
}
void my_caseup_str_8bit(CHARSET_INFO * cs,char *str)
{
register uchar *map=cs->to_upper;
......@@ -53,7 +51,6 @@ void my_caseup_str_8bit(CHARSET_INFO * cs,char *str)
str++;
}
void my_casedn_str_8bit(CHARSET_INFO * cs,char *str)
{
register uchar *map=cs->to_lower;
......@@ -61,7 +58,6 @@ void my_casedn_str_8bit(CHARSET_INFO * cs,char *str)
str++;
}
void my_caseup_8bit(CHARSET_INFO * cs, char *str, uint length)
{
register uchar *map=cs->to_upper;
......@@ -76,6 +72,12 @@ void my_casedn_8bit(CHARSET_INFO * cs, char *str, uint length)
*str= (char) map[(uchar) *str];
}
void my_tosort_8bit(CHARSET_INFO *cs, char *str, uint length)
{
register uchar *map=cs->sort_order;
for ( ; length>0 ; length--, str++)
*str= (char) map[(uchar) *str];
}
int my_strcasecmp_8bit(CHARSET_INFO * cs,const char *s, const char *t)
{
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment