Commit 5e873b20 authored by peter@mysql.com's avatar peter@mysql.com

Merge mysql.com:/home/pz/mysql/mysql-4.1-root

into mysql.com:/home/pz/mysql/mysql-4.1
parents 9731dbc3 50c39153
......@@ -1396,8 +1396,9 @@ com_go(String *buffer,char *line __attribute__((unused)))
(void) com_print(buffer,0);
if (skip_updates &&
(buffer->length() < 4 || my_sortcmp(system_charset_info,buffer->ptr(),
"SET ",4)))
(buffer->length() < 4 || my_strnncoll(system_charset_info,
(const uchar*)buffer->ptr(),4,
(const uchar*)"SET ",4)))
{
(void) put_info("Ignoring query to other database",INFO_INFO);
return 0;
......
......@@ -401,7 +401,7 @@ int hp_rec_key_cmp(HP_KEYDEF *keydef, const byte *rec1, const byte *rec2)
}
if (seg->type == HA_KEYTYPE_TEXT)
{
if (my_sortcmp(seg->charset,rec1+seg->start,rec2+seg->start,seg->length))
if (my_strnncoll(seg->charset,rec1+seg->start,seg->length,rec2+seg->start,seg->length))
return 1;
}
else
......@@ -433,7 +433,7 @@ int hp_key_cmp(HP_KEYDEF *keydef, const byte *rec, const byte *key)
}
if (seg->type == HA_KEYTYPE_TEXT)
{
if (my_sortcmp(seg->charset,rec+seg->start,key,seg->length))
if (my_strnncoll(seg->charset,rec+seg->start,seg->length,key,seg->length))
return 1;
}
else
......
......@@ -607,8 +607,6 @@ extern my_string my_path(my_string to,const char *progname,
extern my_string my_load_path(my_string to, const char *path,
const char *own_path_prefix);
extern int wild_compare(const char *str,const char *wildstr);
extern int my_sortcmp(CHARSET_INFO *cs, const char *s,const char *t,uint length);
extern int my_sortncmp(CHARSET_INFO *cs, const char *s,uint s_len, const char *t,uint t_len);
extern WF_PACK *wf_comp(my_string str);
extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
extern void wf_end(struct wild_file_pack *buffer);
......
......@@ -49,7 +49,7 @@ dbugobjects = dbug.lo # IT IS IN SAFEMALLOC.C sanity.lo
mysysheaders = mysys_priv.h my_static.h
mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
my_create.lo my_delete.lo mf_tempfile.lo my_open.lo \
mf_casecnv.lo my_read.lo my_write.lo errors.lo \
my_read.lo my_write.lo errors.lo \
my_error.lo my_getwd.lo my_div.lo \
mf_pack.lo my_messnc.lo mf_dirname.lo mf_fn_ext.lo\
mf_wcomp.lo typelib.lo safemalloc.lo my_alloc.lo \
......
......@@ -39,7 +39,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\
mf_format.c mf_same.c mf_dirname.c mf_fn_ext.c \
my_symlink.c my_symlink2.c \
mf_pack.c mf_unixpath.c mf_strip.c \
mf_casecnv.c mf_soundex.c mf_wcomp.c mf_wfile.c \
mf_soundex.c mf_wcomp.c mf_wfile.c \
mf_qsort.c mf_qsort2.c mf_sort.c \
ptr_cmp.c mf_radix.c queues.c \
tree.c list.c hash.c array.c string.c typelib.c \
......
......@@ -373,6 +373,7 @@ static CHARSET_INFO *add_charset(uint cs_number, myf flags)
sizeof(tmp_sort_order));
memcpy((char*) cs->tab_to_uni, (char*) tmp_to_uni, sizeof(tmp_to_uni));
cs->strnncoll = my_strnncoll_simple;
cs->caseup_str = my_caseup_str_8bit;
cs->casedn_str = my_casedn_str_8bit;
cs->caseup = my_caseup_8bit;
......
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
Functions to convert to lover_case and to upper_case.
*/
#include "mysys_priv.h"
#include <m_ctype.h>
#ifndef SCO
#include <m_string.h>
#endif
int my_sortcmp(CHARSET_INFO *cs, const char *s, const char *t, uint len)
{
#ifdef USE_STRCOLL
if (use_strnxfrm(cs))
return my_strnncoll(cs,(uchar *)s, len, (uchar *)t, len);
else
#endif
{
register 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]]);
}
return 0;
}
}
int my_sortncmp(CHARSET_INFO *cs,
const char *s, uint s_len,
const char *t, uint t_len)
{
#ifdef USE_STRCOLL
if (use_strnxfrm(cs))
return my_strnncoll(cs, (uchar *)s, s_len, (uchar *)t, t_len);
else
#endif
{
uint len= min(s_len,t_len);
register 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]]);
}
return (int) (s_len - t_len);
}
}
......@@ -3831,7 +3831,9 @@ int Field_string::cmp(const char *a_ptr, const char *b_ptr)
if (binary_flag)
return memcmp(a_ptr,b_ptr,field_length);
else
return my_sortcmp(field_charset,a_ptr,b_ptr,field_length);
return my_strnncoll(field_charset,
(const uchar*)a_ptr,field_length,
(const uchar*)b_ptr,field_length);
}
void Field_string::sort_string(char *to,uint length)
......@@ -3907,7 +3909,9 @@ int Field_string::pack_cmp(const char *a, const char *b, uint length)
int cmp= memcmp(a,b,min(a_length,b_length));
return cmp ? cmp : (int) (a_length - b_length);
}
return my_sortncmp(field_charset, a,a_length, b,b_length);
return my_strnncoll(field_charset,
(const uchar*)a,a_length,
(const uchar*)b,b_length);
}
......@@ -3924,7 +3928,9 @@ int Field_string::pack_cmp(const char *b, uint length)
int cmp= memcmp(ptr,b,min(a_length,b_length));
return cmp ? cmp : (int) (a_length - b_length);
}
return my_sortncmp(field_charset, ptr,a_length, b, b_length);
return my_strnncoll(field_charset,
(const uchar*)ptr,a_length,
(const uchar*)b, b_length);
}
......@@ -4033,7 +4039,9 @@ int Field_varstring::cmp(const char *a_ptr, const char *b_ptr)
if (binary_flag)
diff=memcmp(a_ptr+2,b_ptr+2,min(a_length,b_length));
else
diff=my_sortcmp(field_charset, a_ptr+2,b_ptr+2,min(a_length,b_length));
diff=my_strnncoll(field_charset,
(const uchar*)a_ptr+2,min(a_length,b_length),
(const uchar*)b_ptr+2,min(a_length,b_length));
return diff ? diff : (int) (a_length - b_length);
}
......@@ -4134,7 +4142,9 @@ int Field_varstring::pack_cmp(const char *a, const char *b, uint key_length)
int cmp= memcmp(a,b,min(a_length,b_length));
return cmp ? cmp : (int) (a_length - b_length);
}
return my_sortncmp(field_charset, a,a_length, b,b_length);
return my_strnncoll(field_charset,
(const uchar *)a,a_length,
(const uchar *)b,b_length);
}
int Field_varstring::pack_cmp(const char *b, uint key_length)
......@@ -4155,7 +4165,9 @@ int Field_varstring::pack_cmp(const char *b, uint key_length)
int cmp= memcmp(a,b,min(a_length,b_length));
return cmp ? cmp : (int) (a_length - b_length);
}
return my_sortncmp(field_charset, a,a_length, b,b_length);
return my_strnncoll(field_charset,
(const uchar *)a,a_length,
(const uchar *)b,b_length);
}
uint Field_varstring::packed_col_length(const char *ptr, uint length)
......@@ -4382,7 +4394,9 @@ int Field_blob::cmp(const char *a,uint32 a_length, const char *b,
if (binary_flag)
diff=memcmp(a,b,min(a_length,b_length));
else
diff=my_sortcmp(field_charset, a,b,min(a_length,b_length));
diff=my_strnncoll(field_charset,
(const uchar*)a,min(a_length,b_length),
(const uchar*)b,min(a_length,b_length));
return diff ? diff : (int) (a_length - b_length);
}
......@@ -4631,7 +4645,9 @@ int Field_blob::pack_cmp(const char *a, const char *b, uint key_length)
int cmp= memcmp(a,b,min(a_length,b_length));
return cmp ? cmp : (int) (a_length - b_length);
}
return my_sortncmp(field_charset, a,a_length, b,b_length);
return my_strnncoll(field_charset,
(const uchar *)a,a_length,
(const uchar *)b,b_length);
}
......@@ -4657,7 +4673,9 @@ int Field_blob::pack_cmp(const char *b, uint key_length)
int cmp= memcmp(a,b,min(a_length,b_length));
return cmp ? cmp : (int) (a_length - b_length);
}
return my_sortncmp(field_charset, a,a_length, b,b_length);
return my_strnncoll(field_charset,
(const uchar *)a,a_length,
(const uchar *)b,b_length);
}
/* Create a packed key that will be used for storage from a MySQL row */
......
......@@ -1366,9 +1366,9 @@ innobase_mysql_cmp(
case FIELD_TYPE_VAR_STRING:
// BAR TODO: Discuss with heikki.tuuri@innodb.com
// so that he sends CHARSET_INFO for the field to this function.
ret = my_sortncmp(default_charset_info,
(const char*) a, a_length,
(const char*) b, b_length);
ret = my_strnncoll(default_charset_info,
a, a_length,
b, b_length);
if (ret < 0) {
return(-1);
} else if (ret > 0) {
......
......@@ -866,7 +866,9 @@ static int simple_raw_key_cmp(void* arg, byte* key1, byte* key2)
static int simple_str_key_cmp(void* arg, byte* key1, byte* key2)
{
/* BAR TODO: remove default_charset_info */
return my_sortcmp(default_charset_info,(char*) key1, (char*) key2, *(uint*) arg);
return my_strnncoll(default_charset_info,
(const uchar*) key1, *(uint*) arg,
(const uchar*) key2, *(uint*) arg);
}
/*
......
......@@ -193,8 +193,9 @@ int key_cmp(TABLE *table,const byte *key,uint idx,uint key_length)
FIELDFLAG_PACK)))
{
/* BAR TODO: I'm not sure this should be system_charset_info */
if (my_sortcmp(system_charset_info,(char*) key,
(char*) table->record[0]+key_part->offset,length))
if (my_strnncoll(system_charset_info,
(const uchar*) key, length,
(const uchar*) table->record[0]+key_part->offset,length))
return 1;
}
else if (memcmp(key,table->record[0]+key_part->offset,length))
......
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