1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Merge with public tree

This commit is contained in:
monty@mysql.com
2004-02-16 10:31:05 +02:00
285 changed files with 7841 additions and 4047 deletions

View File

@ -247,8 +247,8 @@ int my_strnncollsp_big5(CHARSET_INFO * cs,
const uchar *s, uint slen,
const uchar *t, uint tlen)
{
for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--);
for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--);
for ( ; slen && s[slen-1] == ' ' ; slen--);
for ( ; tlen && t[tlen-1] == ' ' ; tlen--);
return my_strnncoll_big5(cs,s,slen,t,tlen);
}
@ -343,10 +343,10 @@ static int my_strxfrm_big5(uchar * dest, const uchar * src, int len)
#define max_sort_char ((char) 255)
static my_bool my_like_range_big5(CHARSET_INFO *cs __attribute__((unused)),
const char *ptr,uint ptr_length,
int escape, int w_one, int w_many,
uint res_length, char *min_str,char *max_str,
uint *min_length,uint *max_length)
const char *ptr,uint ptr_length,
pbool escape, pbool w_one, pbool w_many,
uint res_length, char *min_str,char *max_str,
uint *min_length,uint *max_length)
{
const char *end=ptr+ptr_length;
char *min_org=min_str;

View File

@ -67,6 +67,28 @@ static uchar bin_char_array[] =
};
/*
Compare two strings. Result is sign(first_argument - second_argument)
SYNOPSIS
my_strnncoll_binary()
cs Chararacter set
s String to compare
slen Length of 's'
t String to compare
tlen Length of 't'
NOTE
This is used also when comparing with end space removal, as end space
is significant for binary strings
RETURN
< 0 s < t
0 s == t
> 0 s > t
*/
static int my_strnncoll_binary(CHARSET_INFO * cs __attribute__((unused)),
const uchar *s, uint slen,
const uchar *t, uint tlen)
@ -75,59 +97,39 @@ static int my_strnncoll_binary(CHARSET_INFO * cs __attribute__((unused)),
return cmp ? cmp : (int) (slen - tlen);
}
static int my_strnncollsp_binary(CHARSET_INFO * cs,
const uchar *s, uint slen,
const uchar *t, uint tlen)
{
int len, cmp;
for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--);
for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--);
/* This function is used for all conversion functions */
len = ( slen > tlen ) ? tlen : slen;
cmp= memcmp(s,t,len);
return cmp ? cmp : (int) (slen - tlen);
}
static void my_caseup_str_bin(CHARSET_INFO *cs __attribute__((unused)),
char *str __attribute__((unused)))
static void my_case_str_bin(CHARSET_INFO *cs __attribute__((unused)),
char *str __attribute__((unused)))
{
}
static void my_casedn_str_bin(CHARSET_INFO * cs __attribute__((unused)),
char *str __attribute__((unused)))
static void my_case_bin(CHARSET_INFO *cs __attribute__((unused)),
char *str __attribute__((unused)),
uint length __attribute__((unused)))
{
}
static void my_caseup_bin(CHARSET_INFO * cs __attribute__((unused)),
char *str __attribute__((unused)),
uint length __attribute__((unused)))
{
}
static void my_casedn_bin(CHARSET_INFO * cs __attribute__((unused)),
char *str __attribute__((unused)),
uint length __attribute__((unused)))
{
}
static int my_strcasecmp_bin(CHARSET_INFO * cs __attribute__((unused)),
const char *s, const char *t)
const char *s, const char *t)
{
return strcmp(s,t);
}
int my_mbcharlen_8bit(CHARSET_INFO *cs __attribute__((unused)),
uint c __attribute__((unused)))
uint c __attribute__((unused)))
{
return 1;
}
static int my_mb_wc_bin(CHARSET_INFO *cs __attribute__((unused)),
my_wc_t *wc,
const unsigned char *str,
const unsigned char *end __attribute__((unused)))
my_wc_t *wc,
const unsigned char *str,
const unsigned char *end __attribute__((unused)))
{
if (str >= end)
return MY_CS_TOOFEW(0);
@ -136,10 +138,11 @@ static int my_mb_wc_bin(CHARSET_INFO *cs __attribute__((unused)),
return 1;
}
static int my_wc_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
my_wc_t wc,
unsigned char *s,
unsigned char *e __attribute__((unused)))
my_wc_t wc,
unsigned char *s,
unsigned char *e __attribute__((unused)))
{
if (s >= e)
return MY_CS_TOOSMALL;
@ -169,12 +172,21 @@ void my_hash_sort_bin(CHARSET_INFO *cs __attribute__((unused)),
}
/*
The following defines is here to keep the following code identical to
the one in ctype-simple.c
*/
#define likeconv(s,A) (A)
#define INC_PTR(cs,A,B) (A)++
static int my_wildcmp_bin(CHARSET_INFO *cs,
const char *str,const char *str_end,
const char *wildstr,const char *wildend,
int escape, int w_one, int w_many)
{
int result= -1; /* Not found, using wildcards */
int result= -1; /* Not found, using wildcards */
while (wildstr != wildend)
{
@ -182,31 +194,26 @@ static int my_wildcmp_bin(CHARSET_INFO *cs,
{
if (*wildstr == escape && wildstr+1 != wildend)
wildstr++;
if (str == str_end || *wildstr++ != *str++)
{
return(1);
}
if (str == str_end || likeconv(cs,*wildstr++) != likeconv(cs,*str++))
return(1); /* No match */
if (wildstr == wildend)
{
return(str != str_end); /* Match if both are at end */
}
result=1; /* Found an anchor char */
return(str != str_end); /* Match if both are at end */
result=1; /* Found an anchor char */
}
if (*wildstr == w_one)
{
do
{
if (str == str_end) /* Skip one char if possible */
if (str == str_end) /* Skip one char if possible */
return(result);
str++;
} while (*++wildstr == w_one && wildstr != wildend);
INC_PTR(cs,str,str_end);
} while (++wildstr < wildend && *wildstr == w_one);
if (wildstr == wildend)
break;
}
if (*wildstr == w_many)
{ /* Found w_many */
char cmp;
{ /* Found w_many */
uchar cmp;
wildstr++;
/* Remove any '%' and '_' from the wild search string */
for (; wildstr != wildend ; wildstr++)
@ -216,40 +223,33 @@ static int my_wildcmp_bin(CHARSET_INFO *cs,
if (*wildstr == w_one)
{
if (str == str_end)
{
return(-1);
}
str++;
INC_PTR(cs,str,str_end);
continue;
}
break; /* Not a wild character */
break; /* Not a wild character */
}
if (wildstr == wildend)
{
return(0); /* Ok if w_many is last */
}
return(0); /* match if w_many is last */
if (str == str_end)
{
return(-1);
}
if ((cmp= *wildstr) == escape && wildstr+1 != wildend)
cmp= *++wildstr;
wildstr++; /* This is compared trough cmp */
INC_PTR(cs,wildstr,wildend); /* This is compared through cmp */
cmp=likeconv(cs,cmp);
do
{
while (str != str_end && *str != cmp)
while (str != str_end && (uchar) likeconv(cs,*str) != cmp)
str++;
if (str++ == str_end)
{
return(-1);
}
{
int tmp=my_wildcmp_bin(cs,str,str_end,wildstr,wildend,escape,w_one,w_many);
int tmp=my_wildcmp_bin(cs,str,str_end,wildstr,wildend,escape,w_one,
w_many);
if (tmp <= 0)
{
return(tmp);
}
}
} while (str != str_end && wildstr[0] != w_many);
return(-1);
@ -258,6 +258,7 @@ static int my_wildcmp_bin(CHARSET_INFO *cs,
return(str != str_end ? 1 : 0);
}
static int my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)),
uchar * dest, uint len,
const uchar *src,
@ -268,11 +269,12 @@ static int my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)),
return len;
}
static
uint my_instr_bin(CHARSET_INFO *cs __attribute__((unused)),
const char *b, uint b_length,
const char *s, uint s_length,
my_match_t *match, uint nmatch)
const char *b, uint b_length,
const char *s, uint s_length,
my_match_t *match, uint nmatch)
{
register const uchar *str, *search, *end, *search_end;
@ -332,7 +334,7 @@ skip:
MY_COLLATION_HANDLER my_collation_8bit_bin_handler =
{
my_strnncoll_binary,
my_strnncollsp_binary,
my_strnncoll_binary,
my_strnxfrm_bin,
my_like_range_simple,
my_wildcmp_bin,
@ -341,6 +343,7 @@ MY_COLLATION_HANDLER my_collation_8bit_bin_handler =
my_hash_sort_bin
};
static MY_CHARSET_HANDLER my_charset_handler=
{
NULL, /* ismbchar */
@ -351,10 +354,10 @@ static MY_CHARSET_HANDLER my_charset_handler=
my_lengthsp_8bit,
my_mb_wc_bin,
my_wc_mb_bin,
my_caseup_str_bin,
my_casedn_str_bin,
my_caseup_bin,
my_casedn_bin,
my_case_str_bin,
my_case_str_bin,
my_case_bin,
my_case_bin,
my_snprintf_8bit,
my_long10_to_str_8bit,
my_longlong10_to_str_8bit,
@ -367,6 +370,7 @@ static MY_CHARSET_HANDLER my_charset_handler=
my_scan_8bit
};
CHARSET_INFO my_charset_bin =
{
63,0,0, /* number */

View File

@ -379,10 +379,11 @@ static int my_strnxfrm_czech(CHARSET_INFO *cs __attribute__((unused)),
#define EXAMPLE
static my_bool my_like_range_czech(CHARSET_INFO *cs __attribute__((unused)),
const char *ptr,uint ptr_length,
int escape, int w_one, int w_many,
uint res_length, char *min_str,char *max_str,
uint *min_length,uint *max_length)
const char *ptr,uint ptr_length,
pbool escape, pbool w_one, pbool w_many,
uint res_length, char *min_str,
char *max_str,
uint *min_length,uint *max_length)
{
#ifdef EXAMPLE
uchar value;
@ -599,8 +600,8 @@ int my_strnncollsp_czech(CHARSET_INFO * cs,
const uchar *s, uint slen,
const uchar *t, uint tlen)
{
for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--);
for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--);
for ( ; slen && s[slen-1] == ' ' ; slen--);
for ( ; tlen && t[tlen-1] == ' ' ; tlen--);
return my_strnncoll_czech(cs,s,slen,t,tlen);
}

View File

@ -2613,8 +2613,8 @@ int my_strnncollsp_gbk(CHARSET_INFO * cs,
const uchar *s, uint slen,
const uchar *t, uint tlen)
{
for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--);
for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--);
for ( ; slen && s[slen-1] == ' ' ; slen--);
for ( ; tlen && t[tlen-1] == ' ' ; tlen--);
return my_strnncoll_gbk(cs,s,slen,t,tlen);
}
@ -2663,7 +2663,7 @@ static int my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)),
static my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)),
const char *ptr,uint ptr_length,
int escape, int w_one, int w_many,
pbool escape, pbool w_one, pbool w_many,
uint res_length, char *min_str,char *max_str,
uint *min_length,uint *max_length)
{

View File

@ -360,8 +360,8 @@ static int my_strnncollsp_latin1_de(CHARSET_INFO *cs,
const uchar *s, uint slen,
const uchar *t, uint tlen)
{
for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--);
for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--);
for ( ; slen && s[slen-1] == ' ' ; slen--);
for ( ; tlen && t[tlen-1] == ' ' ; tlen--);
return my_strnncoll_latin1_de(cs,s,slen,t,tlen);
}

View File

@ -357,14 +357,14 @@ static int my_strnncoll_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
return cmp ? cmp : (int) (slen - tlen);
}
static int my_strnncollsp_mb_bin(CHARSET_INFO * cs,
const uchar *s, uint slen,
const uchar *t, uint tlen)
static int my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
const uchar *s, uint slen,
const uchar *t, uint tlen)
{
int len, cmp;
for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--);
for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--);
for ( ; slen && s[slen-1] == ' ' ; slen--);
for ( ; tlen && t[tlen-1] == ' ' ; tlen--);
len = ( slen > tlen ) ? tlen : slen;

View File

@ -66,8 +66,8 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *s, uint slen,
uchar *map= cs->sort_order;
int len;
for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--);
for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--);
for ( ; slen && s[slen-1] == ' ' ; slen--);
for ( ; tlen && t[tlen-1] == ' ' ; tlen--);
len = ( slen > tlen ) ? tlen : slen;
@ -186,9 +186,9 @@ void my_hash_sort_simple(CHARSET_INFO *cs,
}
long my_strntol_8bit(CHARSET_INFO *cs,
const char *nptr, uint l, int base,
char **endptr, int *err)
long my_strntol_8bit(CHARSET_INFO *cs,
const char *nptr, uint l, int base,
char **endptr, int *err)
{
int negative;
register ulong cutoff;
@ -309,9 +309,9 @@ noconv:
}
ulong my_strntoul_8bit(CHARSET_INFO *cs,
const char *nptr, uint l, int base,
char **endptr, int *err)
ulong my_strntoul_8bit(CHARSET_INFO *cs,
const char *nptr, uint l, int base,
char **endptr, int *err)
{
int negative;
register ulong cutoff;
@ -423,9 +423,9 @@ noconv:
}
longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)),
const char *nptr, uint l, int base,
char **endptr,int *err)
longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)),
const char *nptr, uint l, int base,
char **endptr,int *err)
{
int negative;
register ulonglong cutoff;
@ -825,7 +825,7 @@ cnv:
#define likeconv(s,A) (uchar) (s)->sort_order[(uchar) (A)]
#endif
#define INC_PTR(cs,A,B) A++
#define INC_PTR(cs,A,B) (A)++
int my_wildcmp_8bit(CHARSET_INFO *cs,
@ -833,7 +833,7 @@ int my_wildcmp_8bit(CHARSET_INFO *cs,
const char *wildstr,const char *wildend,
int escape, int w_one, int w_many)
{
int result= -1; /* Not found, using wildcards */
int result= -1; /* Not found, using wildcards */
while (wildstr != wildend)
{
@ -845,7 +845,7 @@ int my_wildcmp_8bit(CHARSET_INFO *cs,
if (str == str_end || likeconv(cs,*wildstr++) != likeconv(cs,*str++))
return(1); /* No match */
if (wildstr == wildend)
return (str != str_end); /* Match if both are at end */
return(str != str_end); /* Match if both are at end */
result=1; /* Found an anchor char */
}
if (*wildstr == w_one)
@ -853,7 +853,7 @@ int my_wildcmp_8bit(CHARSET_INFO *cs,
do
{
if (str == str_end) /* Skip one char if possible */
return (result);
return(result);
INC_PTR(cs,str,str_end);
} while (++wildstr < wildend && *wildstr == w_one);
if (wildstr == wildend)
@ -872,7 +872,7 @@ int my_wildcmp_8bit(CHARSET_INFO *cs,
if (*wildstr == w_one)
{
if (str == str_end)
return (-1);
return(-1);
INC_PTR(cs,str,str_end);
continue;
}
@ -881,28 +881,29 @@ int my_wildcmp_8bit(CHARSET_INFO *cs,
if (wildstr == wildend)
return(0); /* Ok if w_many is last */
if (str == str_end)
return -1;
return(-1);
if ((cmp= *wildstr) == escape && wildstr+1 != wildend)
cmp= *++wildstr;
INC_PTR(cs,wildstr,wildend); /* This is compared trough cmp */
cmp=likeconv(cs,cmp);
INC_PTR(cs,wildstr,wildend); /* This is compared trough cmp */
cmp=likeconv(cs,cmp);
do
{
while (str != str_end && likeconv(cs,*str) != cmp)
str++;
if (str++ == str_end) return (-1);
while (str != str_end && (uchar) likeconv(cs,*str) != cmp)
str++;
if (str++ == str_end) return(-1);
{
int tmp=my_wildcmp_8bit(cs,str,str_end,wildstr,wildend,escape,w_one,w_many);
int tmp=my_wildcmp_8bit(cs,str,str_end,wildstr,wildend,escape,w_one,
w_many);
if (tmp <= 0)
return (tmp);
return(tmp);
}
} while (str != str_end && wildstr[0] != w_many);
return(-1);
}
}
return (str != str_end ? 1 : 0);
return(str != str_end ? 1 : 0);
}
@ -924,11 +925,11 @@ int my_wildcmp_8bit(CHARSET_INFO *cs,
*/
my_bool my_like_range_simple(CHARSET_INFO *cs,
const char *ptr,uint ptr_length,
int escape, int w_one, int w_many,
uint res_length,
char *min_str,char *max_str,
uint *min_length,uint *max_length)
const char *ptr,uint ptr_length,
pbool escape, pbool w_one, pbool w_many,
uint res_length,
char *min_str,char *max_str,
uint *min_length,uint *max_length)
{
const char *end=ptr+ptr_length;
char *min_org=min_str;
@ -953,7 +954,7 @@ my_bool my_like_range_simple(CHARSET_INFO *cs,
*min_length= (uint) (min_str - min_org);
*max_length=res_length;
do {
*min_str++ = ' '; /* Because if key compression */
*min_str++ = ' '; /* Because if key compression */
*max_str++ = cs->max_sort_char;
} while (min_str != min_end);
return 0;
@ -970,7 +971,7 @@ my_bool my_like_range_simple(CHARSET_INFO *cs,
}
while (min_str != min_end)
*min_str++ = *max_str++ = ' '; /* Because if key compression */
*min_str++ = *max_str++ = ' '; /* Because if key compression */
return 0;
}

View File

@ -227,8 +227,8 @@ int my_strnncollsp_sjis(CHARSET_INFO * cs,
const uchar *s, uint slen,
const uchar *t, uint tlen)
{
for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--);
for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--);
for ( ; slen && s[slen-1] == ' ' ; slen--);
for ( ; tlen && t[tlen-1] == ' ' ; tlen--);
return my_strnncoll_sjis(cs,s,slen,t,tlen);
}
@ -270,10 +270,10 @@ static int my_strnxfrm_sjis(CHARSET_INFO *cs __attribute__((unused)),
#define max_sort_char ((char) 255)
static my_bool my_like_range_sjis(CHARSET_INFO *cs __attribute__((unused)),
const char *ptr,uint ptr_length,
int escape, int w_one, int w_many,
uint res_length, char *min_str,char *max_str,
uint *min_length,uint *max_length)
const char *ptr,uint ptr_length,
pbool escape, pbool w_one, pbool w_many,
uint res_length, char *min_str,char *max_str,
uint *min_length,uint *max_length)
{
const char *end=ptr+ptr_length;
char *min_org=min_str;

View File

@ -15,6 +15,11 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
Copyright (C) 2003 by Sathit Jittanupat
<jsat66@hotmail.com,jsat66@yahoo.com>
* solving bug crash with long text field string
* sorting with different number of space or sign char. within string
Copyright (C) 2001 by Korakot Chaovavanich <korakot@iname.com> and
Apisilp Trunganont <apisilp@pantip.inet.co.th>
Copyright (C) 1998, 1999 by Pruet Boonma <pruet@eng.cmu.ac.th>
@ -448,6 +453,7 @@ uchar NEAR sort_order_tis620[]=
(uchar) '\370',(uchar) '\371',(uchar) '\372',(uchar) '\373',(uchar) '\374',(uchar) '\375',(uchar) '\376',(uchar) '\377',
};
/*
Convert thai string to "Standard C String Function" sortable string
@ -455,94 +461,61 @@ uchar NEAR sort_order_tis620[]=
thai2sortable()
tstr String to convert. Does not have to end with \0
len Length of tstr
out_length Will contain length of sortable string
NOTE
We use only 3 levels (neglect capitalization).
OPTIMIZE SUGGESTION
Should be faster to alloc buffer in calling function.
RETURN
Pointer to sortable string. Should be freed with 'free'
*/
static uchar *thai2sortable(const uchar *tstr, uint len, uint *out_length)
static uint thai2sortable(uchar *tstr, uint len)
{
const uchar *p= tstr;
uchar *outBuf;
uchar *pRight1, *pRight2, *pRight3;
uchar *pLeft2, *pLeft3;
uint bufSize;
uint RightSize;
uchar *p;
int tlen;
uchar l2bias;
bufSize= (uint) (len + 1) * BUFFER_MULTIPLY;
RightSize= sizeof(uchar) * (len + 1);
if (!(outBuf= pRight1=
(uchar *)malloc(sizeof(uchar) * bufSize + RightSize*2)))
tlen= len;
l2bias= 256 - 8;
for (p= tstr; tlen > 0; p++, tlen--)
{
/*
Can't allocate buffer; Use original string for sorting
This is not perfect, but better than nothing...
*/
*out_length= len;
return (uchar*) tstr;
}
pLeft2= pRight2= pRight1 + sizeof(uchar) * bufSize;
pLeft3= pRight3= pRight2 + RightSize;
uchar c= *p;
while ((int) --len > 0)
{
int *t_ctype0= t_ctype[p[0]];
if (isldvowel(*p) && isconsnt(p[1]))
if (isthai(c))
{
int *t_ctype1= t_ctype[p[1]];
*pRight1++= t_ctype1[0];
*pRight2++= t_ctype1[1];
*pRight3++= t_ctype1[2];
*pRight1++= t_ctype0[0];
*pRight2++= t_ctype0[1];
*pRight3++= t_ctype0[2];
p+= 2;
len--;
int *t_ctype0= t_ctype[c];
if (isconsnt(c))
l2bias -= 8;
if (isldvowel(c) && tlen != 1 && isconsnt(p[1]))
{
/* simply swap between leading-vowel and consonant */
*p= p[1];
p[1]= c;
tlen--;
p++;
continue;
}
/* if found level 2 char (L2_GARAN,L2_TONE*,L2_TYKHU) move to last */
if (t_ctype0[1] >= L2_GARAN)
{
/*
l2bias use to control position weight of l2char
example (*=l2char) XX*X must come before X*XX
*/
memcpy_overlap(p, p+1, tlen-1);
tstr[len-1]= l2bias + t_ctype0[1]- L2_GARAN +1;
p--;
continue;
}
}
else
{
*pRight1= t_ctype0[0];
if(*pRight1 != IGNORE)
pRight1++;
*pRight2= t_ctype0[1];
if (*pRight2 != IGNORE)
pRight2++;
*pRight3= t_ctype0[2];
if(*pRight3 != IGNORE)
pRight3++;
p++;
l2bias-= 8;
*p= to_lower_tis620[c];
}
}
if (!len) /* If last was not double byte */
{
int *t_ctype0= t_ctype[p[0]];
if ((*pRight1= t_ctype0[0] != IGNORE))
pRight1++;
if ((*pRight2= t_ctype0[1]) != IGNORE)
pRight2++;
if ((*pRight3= t_ctype0[2]) != IGNORE)
pRight3++;
}
*pRight1++= L2_BLANK;
*pRight2++= L3_BLANK;
*pRight3++= '\0';
memcpy(pRight1, pLeft2, pRight2 - pLeft2);
pRight1+= pRight2 - pLeft2;
memcpy(pRight1, pLeft3, pRight3 - pLeft3);
*out_length= (uint) ((pRight1+ (uint) (pRight3 - pLeft3)) - outBuf);
return outBuf;
return len;
}
/*
strncoll() replacement, compare 2 string, both are conveted to sortable
strncoll() replacement, compare 2 string, both are converted to sortable
string
Arg: 2 Strings and it compare length
@ -553,21 +526,27 @@ int my_strnncoll_tis620(CHARSET_INFO *cs __attribute__((unused)),
const uchar * s1, uint len1,
const uchar * s2, uint len2)
{
uchar buf[80] ;
uchar *tc1, *tc2;
uint tc1_length, tc2_length, length;
int res;
int i;
tc1= thai2sortable(s1, len1, &tc1_length);
tc2= thai2sortable(s2, len2, &tc2_length);
length= min(tc1_length, tc2_length);
res= memcmp((char*)tc1, (char*) tc2, length);
if (tc1 != s1)
/* Cut strings at end \0 */
len1= (int) strnlen((char*) s1,len1);
len2= (int) strnlen((char*) s2,len2);
tc1= buf;
if ((len1 + len2 +2) > (int) sizeof(buf))
tc1= (uchar*) malloc(len1+len2);
tc2= tc1 + len1+1;
memcpy((char*) tc1, (char*) s1, len1);
tc1[len1]= 0; /* if length(s1)> len1, need to put 'end of string' */
memcpy((char *)tc2, (char *)s2, len2);
tc2[len2]= 0; /* put end of string */
thai2sortable(tc1, len1);
thai2sortable(tc2, len2);
i= strcmp((char*)tc1, (char*)tc2);
if (tc1 != buf)
free(tc1);
if (tc2 != s2)
free(tc2);
return (res || tc1_length == tc2_length ? res :
(tc1_length < tc2_length ? -1 : 1));
return i;
}
@ -576,34 +555,33 @@ int my_strnncollsp_tis620(CHARSET_INFO * cs,
const uchar *s, uint slen,
const uchar *t, uint tlen)
{
for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--);
for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--);
for ( ; slen && s[slen-1] == ' ' ; slen--);
for ( ; tlen && t[tlen-1] == ' ' ; tlen--);
return my_strnncoll_tis620(cs,s,slen,t,tlen);
}
/* strnxfrm replacment, convert Thai string to sortable string
Arg: Destination buffer, source string, dest length and source length
Ret: Conveted string size
/*
strnxfrm replacment, convert Thai string to sortable string
Arg: Destination buffer, source string, dest length and source length
Ret: Conveted string size
*/
int my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)),
uchar * dest, uint len,
const uchar * src, uint srclen)
{
uint out_length;
uchar *tmp= thai2sortable(src, srclen, &out_length);
set_if_smaller(out_length, len);
memcpy(dest, tmp, out_length);
if (tmp != src)
free(tmp);
return (int) out_length;
len= (uint) (strmake((char*) dest, (char*) src, min(len, srclen)) -
(char*) dest);
return (int) thai2sortable(dest, len);
}
/* strcoll replacment, compare 2 strings
Arg: 2 strings
Ret: memcmp result
/*
strcoll replacment, compare 2 strings
Arg: 2 strings
Ret: strcmp result
*/
int my_strcoll_tis620(const uchar * s1, const uchar * s2)
@ -616,6 +594,10 @@ int my_strcoll_tis620(const uchar * s1, const uchar * s2)
/*
Convert SQL LIKE string to C string
Arg: String, its length, escape character, resource length,
minimal string and maximum string
Ret: Always 0
IMPLEMENTATION
We just copy this function from opt_range.cc. No need to convert to
thai2sortable string. min_str and max_str will be use for comparison and
@ -629,7 +611,7 @@ int my_strcoll_tis620(const uchar * s1, const uchar * s2)
my_bool my_like_range_tis620(CHARSET_INFO *cs __attribute__((unused)),
const char *ptr, uint ptr_length,
int escape, int w_one, int w_many,
pbool escape, pbool w_one, pbool w_many,
uint res_length, char *min_str, char *max_str,
uint *min_length, uint *max_length)
{
@ -656,7 +638,7 @@ my_bool my_like_range_tis620(CHARSET_INFO *cs __attribute__((unused)),
*min_length= (uint) (min_str - min_org);
*max_length=res_length;
do {
*min_str++ = ' '; /* For key compression */
*min_str++ = ' '; /* Because of key compression */
*max_str++ = max_sort_chr;
} while (min_str != min_end);
return 0;
@ -666,40 +648,10 @@ my_bool my_like_range_tis620(CHARSET_INFO *cs __attribute__((unused)),
*min_length= *max_length = (uint) (min_str - min_org);
while (min_str != min_end)
*min_str++ = *max_str++ = ' '; /* For key compression */
*min_str++ = *max_str++ = ' '; /* Because of key compression */
return 0;
}
#ifdef NOT_NEEDED
/*
Thai normalization for input sub system
Arg: Buffer, 's length, String, 'length
Ret: Void
*/
void ThNormalize(uchar* ptr, uint field_length, const uchar* from, uint length)
{
const uchar* fr= from;
uchar* p= ptr;
if (length > field_length)
length= field_length;
while (length--)
if ((istone(*fr) || isdiacrt1(*fr)) &&
(islwrvowel(fr[1]) || isuprvowel(fr[1])))
{
*p= fr[1];
p[1]= *fr;
fr+= 2;
p+= 2;
length--;
}
else
*p++ = *fr++;
}
#endif /* NOT_NEEDED */
static unsigned short cs_to_uni[256]={
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,
@ -911,7 +863,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler =
my_like_range_tis620,
my_wildcmp_8bit, /* wildcmp */
my_strcasecmp_8bit,
NULL,
my_instr_simple, /* QQ: To be fixed */
my_hash_sort_simple,
};

View File

@ -1840,8 +1840,8 @@ int my_strnncollsp_utf8(CHARSET_INFO * cs,
const uchar *s, uint slen,
const uchar *t, uint tlen)
{
for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--);
for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--);
for ( ; slen && s[slen-1] == ' ' ; slen--);
for ( ; tlen && t[tlen-1] == ' ' ; tlen--);
return my_strnncoll_utf8(cs,s,slen,t,tlen);
}

View File

@ -38,7 +38,6 @@
*/
#define REAL_MYSQL
#ifdef REAL_MYSQL
#include "my_global.h"
@ -445,103 +444,65 @@ static struct wordvalue doubles[] = {
break; \
}
#define IS_END(p, src, len) (!(*p))
#if UNUSED
static int my_strcoll_win1250ch(const uchar * s1, const uchar * s2) {
int v1, v2;
const uchar * p1, * p2;
int pass1 = 0, pass2 = 0;
int diff;
p1 = s1; p2 = s2;
do {
NEXT_CMP_VALUE(s1, p1, pass1, v1, 0);
NEXT_CMP_VALUE(s2, p2, pass2, v2, 0);
diff = v1 - v2;
if (diff != 0) return diff;
} while (v1);
return 0;
}
#endif
#ifdef UNUSED
static int my_strxfrm_win1250ch(uchar * dest, const uchar * src, int len) {
int value;
const uchar * p;
int pass = 0;
int totlen = 0;
p = src;
do {
NEXT_CMP_VALUE(src, p, pass, value, 0);
if (totlen <= len)
dest[totlen] = value;
totlen++;
} while (value);
return totlen;
}
#endif
#undef IS_END
#define IS_END(p, src, len) (((char *)p - (char *)src) >= (len))
static int my_strnncoll_win1250ch(CHARSET_INFO *cs __attribute__((unused)),
const uchar * s1, uint len1,
const uchar * s2, uint len2) {
int v1, v2;
const uchar * p1, * p2;
int pass1 = 0, pass2 = 0;
int diff;
const uchar * s1, uint len1,
const uchar * s2, uint len2)
{
int v1, v2;
const uchar * p1, * p2;
int pass1 = 0, pass2 = 0;
int diff;
p1 = s1; p2 = s2;
p1 = s1; p2 = s2;
do {
NEXT_CMP_VALUE(s1, p1, pass1, v1, (int)len1);
NEXT_CMP_VALUE(s2, p2, pass2, v2, (int)len2);
diff = v1 - v2;
if (diff != 0) return diff;
} while (v1);
return 0;
do {
NEXT_CMP_VALUE(s1, p1, pass1, v1, (int)len1);
NEXT_CMP_VALUE(s2, p2, pass2, v2, (int)len2);
diff = v1 - v2;
if (diff != 0) return diff;
} while (v1);
return 0;
}
static
int my_strnncollsp_win1250ch(CHARSET_INFO * cs,
const uchar *s, uint slen,
const uchar *t, uint tlen)
const uchar *s, uint slen,
const uchar *t, uint tlen)
{
for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--);
for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--);
for ( ; slen && s[slen-1] == ' ' ; slen--);
for ( ; tlen && t[tlen-1] == ' ' ; tlen--);
return my_strnncoll_win1250ch(cs,s,slen,t,tlen);
}
static int my_strnxfrm_win1250ch(CHARSET_INFO * cs __attribute__((unused)),
uchar * dest, uint len,
const uchar * src, uint srclen) {
int value;
const uchar * p;
int pass = 0;
uint totlen = 0;
p = src;
uchar * dest, uint len,
const uchar * src, uint srclen)
{
int value;
const uchar * p;
int pass = 0;
uint totlen = 0;
p = src;
do {
NEXT_CMP_VALUE(src, p, pass, value, (int)srclen);
if (totlen <= len)
dest[totlen] = value;
totlen++;
} while (value) ;
return totlen;
do {
NEXT_CMP_VALUE(src, p, pass, value, (int)srclen);
if (totlen <= len)
dest[totlen] = value;
totlen++;
} while (value) ;
return totlen;
}
#undef IS_END
#ifdef REAL_MYSQL
static uchar NEAR like_range_prefix_min_win1250ch[] = {
static uchar NEAR like_range_prefix_min_win1250ch[] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
@ -598,87 +559,82 @@ static uchar NEAR like_range_prefix_max_win1250ch[] = {
** optimized !
*/
static my_bool my_like_range_win1250ch(CHARSET_INFO *cs __attribute__((unused)),
const char *ptr, uint ptr_length,
int escape, int w_one, int w_many,
uint res_length,
char *min_str, char *max_str,
uint *min_length, uint *max_length) {
static my_bool
my_like_range_win1250ch(CHARSET_INFO *cs __attribute__((unused)),
const char *ptr, uint ptr_length,
pbool escape, pbool w_one, pbool w_many,
uint res_length,
char *min_str, char *max_str,
uint *min_length, uint *max_length)
{
int was_other_than_min = 0;
const char *end = ptr + ptr_length;
char *min_org = min_str;
char *min_end = min_str + res_length;
int only_min_found= 1;
const char *end = ptr + ptr_length;
char *min_org = min_str;
char *min_end = min_str + res_length;
/* return 1; */
/* return 1; */
for (; ptr != end && min_str != min_end ; ptr++) {
if (*ptr == w_one) { /* '_' in SQL */
break;
}
if (*ptr == w_many) { /* '%' in SQL */
break;
}
if (*ptr == escape && ptr + 1 != end) { /* Skip escape */
ptr++;
}
*min_str = like_range_prefix_min_win1250ch[(uint)(*ptr)];
if (*min_str != min_sort_char) {
was_other_than_min = 1;
}
min_str++;
*max_str++ = like_range_prefix_max_win1250ch[(uint)(*ptr)];
}
for (; ptr != end && min_str != min_end ; ptr++)
{
if (*ptr == escape && ptr+1 != end)
ptr++; /* Skip escape */
else if (*ptr == w_one || *ptr == w_many) /* '_' or '%' in SQL */
break;
*min_str = like_range_prefix_min_win1250ch[(uint)(*ptr)];
if (*min_str != min_sort_char)
only_min_found= 0;
min_str++;
*max_str++ = like_range_prefix_max_win1250ch[(uint)(*ptr)];
}
*min_length = (uint) (min_str - min_org);
*max_length = res_length;
while (min_str != min_end) {
*min_str++ = min_sort_char;
*max_str++ = max_sort_char;
}
if (! was_other_than_min) {
return 1;
}
return 0;
*min_length = (uint) (min_str - min_org);
*max_length = res_length;
while (min_str != min_end)
{
*min_str++ = min_sort_char;
*max_str++ = max_sort_char;
}
return (only_min_found);
}
static MY_COLLATION_HANDLER my_collation_czech_ci_handler =
{
my_strnncoll_win1250ch,
my_strnncollsp_win1250ch,
my_strnxfrm_win1250ch,
my_like_range_win1250ch,
my_wildcmp_8bit,
my_strcasecmp_8bit,
my_instr_simple,
my_hash_sort_simple
my_strnncoll_win1250ch,
my_strnncollsp_win1250ch,
my_strnxfrm_win1250ch,
my_like_range_win1250ch,
my_wildcmp_8bit,
my_strcasecmp_8bit,
my_instr_simple,
my_hash_sort_simple
};
CHARSET_INFO my_charset_cp1250_czech_ci =
{
34,0,0, /* number */
MY_CS_COMPILED|MY_CS_STRNXFRM, /* state */
"cp1250", /* cs name */
"cp1250_czech_ci", /* name */
"", /* comment */
ctype_win1250ch,
to_lower_win1250ch,
to_upper_win1250ch,
sort_order_win1250ch,
tab_cp1250_uni, /* tab_to_uni */
idx_uni_cp1250, /* tab_from_uni */
"","",
2, /* strxfrm_multiply */
1, /* mbminlen */
1, /* mbmaxlen */
0,
&my_charset_8bit_handler,
&my_collation_czech_ci_handler
34,0,0, /* number */
MY_CS_COMPILED|MY_CS_STRNXFRM, /* state */
"cp1250", /* cs name */
"cp1250_czech_ci", /* name */
"", /* comment */
ctype_win1250ch,
to_lower_win1250ch,
to_upper_win1250ch,
sort_order_win1250ch,
tab_cp1250_uni, /* tab_to_uni */
idx_uni_cp1250, /* tab_from_uni */
"","",
2, /* strxfrm_multiply */
1, /* mbminlen */
1, /* mbmaxlen */
0,
&my_charset_8bit_handler,
&my_collation_czech_ci_handler
};
#endif
#endif /* REAL_MYSQL */
#endif
#endif /* HAVE_CHARSET_cp1250 */

View File

@ -95,7 +95,7 @@ function (const char *nptr,char **endptr,int base)
s = nptr;
/* Skip white space. */
while (my_isspace (&my_charset_latin1, *s))
while (my_isspace(&my_charset_latin1, *s))
++s;
if (*s == '\0')
{