1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

Merge with new VARCHAR code

This commit is contained in:
monty@mysql.com
2004-12-06 19:18:35 +02:00
167 changed files with 3256 additions and 19115 deletions

View File

@ -1923,12 +1923,20 @@ static void my_caseup_utf8(CHARSET_INFO *cs, char *s, uint slen)
}
}
static void my_hash_sort_utf8(CHARSET_INFO *cs, const uchar *s, uint slen, ulong *n1, ulong *n2)
static void my_hash_sort_utf8(CHARSET_INFO *cs, const uchar *s, uint slen,
ulong *n1, ulong *n2)
{
my_wc_t wc;
int res;
const uchar *e=s+slen;
/*
Remove end space. We have to do this to be able to compare
'A ' and 'A' as identical
*/
while (e > s && e[-1] == ' ')
e--;
while ((s < e) && (res=my_utf8_uni(cs,&wc, (uchar *)s, (uchar*)e))>0 )
{
int plane = (wc>>8) & 0xFF;
@ -2021,6 +2029,9 @@ static int my_strnncoll_utf8(CHARSET_INFO *cs,
a_length Length of 'a'
b Second string to compare
b_length Length of 'b'
diff_if_only_endspace_difference
Set to 1 if the strings should be regarded as different
if they only difference in end space
IMPLEMENTATION
If one string is shorter as the other, then we space extend the other
@ -2039,13 +2050,17 @@ static int my_strnncoll_utf8(CHARSET_INFO *cs,
*/
static int my_strnncollsp_utf8(CHARSET_INFO *cs,
const uchar *s, uint slen,
const uchar *t, uint tlen)
const uchar *s, uint slen,
const uchar *t, uint tlen,
my_bool diff_if_only_endspace_difference)
{
int s_res,t_res;
int s_res, t_res, res;
my_wc_t s_wc,t_wc;
const uchar *se= s+slen;
const uchar *te= t+tlen;
const uchar *se= s+slen, *te= t+tlen;
#ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
diff_if_only_endspace_difference= 0;
#endif
while ( s < se && t < te )
{
@ -2074,16 +2089,20 @@ static int my_strnncollsp_utf8(CHARSET_INFO *cs,
slen= se-s;
tlen= te-t;
res= 0;
if (slen != tlen)
{
int swap= 0;
if (diff_if_only_endspace_difference)
res= 1; /* Assume 'a' is bigger */
if (slen < tlen)
{
slen= tlen;
s= t;
se= te;
swap= -1;
res= -res;
}
/*
This following loop uses the fact that in UTF-8
@ -2101,7 +2120,7 @@ static int my_strnncollsp_utf8(CHARSET_INFO *cs,
return ((int)*s - (int) ' ') ^ swap;
}
}
return 0;
return res;
}