mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
03e4b98c7b
into mysql.com:/home/my/mysql-5.0 BitKeeper/etc/ignore: added mysql-test/mysql-test-run-shell client/mysql.cc: Auto merged client/mysql_upgrade.c: Auto merged client/mysqlbinlog.cc: Auto merged client/mysqldump.c: Auto merged client/mysqltest.c: Auto merged client/sql_string.cc: Auto merged client/sql_string.h: Auto merged extra/my_print_defaults.c: Auto merged include/m_ctype.h: Auto merged include/my_pthread.h: Auto merged include/my_sys.h: Auto merged include/my_time.h: Auto merged include/mysql.h: Auto merged libmysql/libmysql.c: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/ft_boolean_search.c: Auto merged myisam/mi_open.c: Auto merged myisam/mi_search.c: Auto merged myisam/mi_unique.c: Auto merged myisam/myisampack.c: Auto merged myisam/rt_index.c: Auto merged myisam/sort.c: Auto merged mysql-test/t/mysql.test: Auto merged mysql-test/t/mysqltest.test: Auto merged mysys/default.c: Auto merged mysys/mf_iocache2.c: Auto merged mysys/mf_keycache.c: Auto merged mysys/my_bitmap.c: Auto merged mysys/sha1.c: Auto merged ndb/include/kernel/signaldata/ArbitSignalData.hpp: Auto merged ndb/include/kernel/signaldata/DictTabInfo.hpp: Auto merged ndb/include/ndbapi/NdbReceiver.hpp: Auto merged ndb/include/transporter/TransporterDefinitions.hpp: Auto merged ndb/include/util/InputStream.hpp: Auto merged ndb/include/util/OutputStream.hpp: Auto merged ndb/include/util/SimpleProperties.hpp: Auto merged ndb/include/util/SocketAuthenticator.hpp: Auto merged ndb/include/util/SocketServer.hpp: Auto merged ndb/src/common/mgmcommon/ConfigRetriever.cpp: Auto merged ndb/src/common/portlib/NdbTick.c: Auto merged ndb/src/common/transporter/SHM_Transporter.cpp: Auto merged ndb/src/common/transporter/TCP_Transporter.cpp: Auto merged ndb/src/common/transporter/TCP_Transporter.hpp: Auto merged ndb/src/common/transporter/Transporter.cpp: Auto merged ndb/src/common/transporter/TransporterRegistry.cpp: Auto merged ndb/src/common/util/Bitmask.cpp: Auto merged ndb/src/common/util/ConfigValues.cpp: Auto merged ndb/src/common/util/File.cpp: Auto merged ndb/src/common/util/Properties.cpp: Auto merged ndb/src/common/util/SocketClient.cpp: Auto merged ndb/src/common/util/random.c: Auto merged ndb/src/common/util/socket_io.cpp: Auto merged ndb/src/cw/cpcd/APIService.cpp: Auto merged ndb/src/cw/cpcd/main.cpp: Auto merged ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Auto merged ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Auto merged ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Auto merged ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Auto merged ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Auto merged ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Auto merged ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Auto merged ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Auto merged ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: Auto merged ndb/src/kernel/blocks/dbtux/DbtuxNode.cpp: Auto merged ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp: Auto merged ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp: Auto merged ndb/src/kernel/blocks/ndbcntr/Ndbcntr.hpp: Auto merged ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Auto merged ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp: Auto merged ndb/src/kernel/blocks/qmgr/Qmgr.hpp: Auto merged ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Auto merged ndb/src/kernel/blocks/suma/Suma.cpp: Auto merged ndb/src/kernel/blocks/suma/Suma.hpp: Auto merged ndb/src/kernel/vm/MetaData.hpp: Auto merged ndb/src/mgmapi/LocalConfig.cpp: Auto merged ndb/src/mgmapi/mgmapi.cpp: Auto merged ndb/src/mgmclient/CommandInterpreter.cpp: Auto merged ndb/src/mgmsrv/ConfigInfo.cpp: Auto merged ndb/src/mgmsrv/ConfigInfo.hpp: Auto merged ndb/src/mgmsrv/InitConfigFileParser.cpp: Auto merged ndb/src/mgmsrv/MgmtSrvr.cpp: Auto merged ndb/src/mgmsrv/MgmtSrvr.hpp: Auto merged ndb/src/mgmsrv/Services.cpp: Auto merged ndb/src/mgmsrv/main.cpp: Auto merged ndb/src/ndbapi/ClusterMgr.hpp: Auto merged ndb/src/ndbapi/Ndb.cpp: Auto merged ndb/src/ndbapi/NdbBlob.cpp: Auto merged ndb/src/ndbapi/NdbDictionaryImpl.cpp: Auto merged ndb/src/ndbapi/NdbIndexOperation.cpp: Auto merged ndb/src/ndbapi/NdbOperationDefine.cpp: Auto merged ndb/src/ndbapi/NdbOperationExec.cpp: Auto merged ndb/src/ndbapi/NdbOperationSearch.cpp: Auto merged ndb/src/ndbapi/NdbScanFilter.cpp: Auto merged ndb/src/ndbapi/NdbScanOperation.cpp: Auto merged ndb/src/ndbapi/SignalSender.cpp: Auto merged ndb/src/ndbapi/ndb_cluster_connection.cpp: Auto merged ndb/tools/delete_all.cpp: Auto merged ndb/tools/desc.cpp: Auto merged ndb/tools/drop_index.cpp: Auto merged ndb/tools/drop_tab.cpp: Auto merged ndb/tools/listTables.cpp: Auto merged ndb/tools/ndb_config.cpp: Auto merged ndb/tools/restore/Restore.hpp: Auto merged ndb/tools/restore/consumer.hpp: Auto merged ndb/tools/restore/restore_main.cpp: Auto merged ndb/tools/select_all.cpp: Auto merged ndb/tools/select_count.cpp: Auto merged server-tools/instance-manager/commands.h: Auto merged server-tools/instance-manager/guardian.cc: Auto merged server-tools/instance-manager/instance_options.cc: Auto merged server-tools/instance-manager/mysql_connection.cc: Auto merged server-tools/instance-manager/options.cc: Auto merged server-tools/instance-manager/options.h: Auto merged server-tools/instance-manager/parse.cc: Auto merged server-tools/instance-manager/user_map.cc: Auto merged server-tools/instance-manager/user_map.h: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/filesort.cc: Auto merged sql/ha_archive.cc: Auto merged sql/ha_archive.h: Auto merged sql/ha_federated.cc: Auto merged sql/ha_heap.cc: Auto merged sql/ha_myisam.cc: Auto merged sql/ha_myisammrg.cc: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/handler.cc: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_func.cc: Auto merged sql/item_geofunc.cc: Auto merged sql/item_row.h: Auto merged sql/item_strfunc.cc: Auto merged sql/item_subselect.cc: Auto merged sql/item_subselect.h: Auto merged sql/item_sum.cc: Auto merged sql/item_timefunc.cc: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/log_event.h: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/net_serv.cc: Auto merged sql/opt_range.cc: Auto merged sql/opt_range.h: Auto merged sql/password.c: Auto merged sql/protocol.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.cc: Auto merged sql/set_var.h: Auto merged sql/slave.cc: Auto merged sql/sp.cc: Auto merged sql/sp_head.cc: Auto merged sql/sp_head.h: Auto merged sql/spatial.cc: Auto merged sql/spatial.h: Auto merged sql/sql_cache.h: Auto merged sql/sql_class.cc: Auto merged sql/sql_derived.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_prepare.cc: Auto merged sql-common/client.c: Auto merged sql-common/my_time.c: Auto merged sql/sql_select.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_string.cc: Auto merged sql/sql_string.h: Auto merged sql/sql_table.cc: Auto merged sql/sql_trigger.cc: Auto merged sql/sql_trigger.h: Auto merged sql/sql_union.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_view.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.cc: Auto merged sql/tztime.cc: Auto merged sql/unireg.cc: Auto merged strings/ctype-bin.c: Auto merged strings/ctype-cp932.c: Auto merged strings/ctype-eucjpms.c: Auto merged strings/ctype-mb.c: Auto merged strings/ctype-simple.c: Auto merged strings/ctype-sjis.c: Auto merged strings/ctype-uca.c: Auto merged strings/ctype-ujis.c: Auto merged strings/ctype-utf8.c: Auto merged strings/decimal.c: Auto merged strings/my_vsnprintf.c: Auto merged tests/mysql_client_test.c: Auto merged mysql-test/t/mysqlbinlog.test: Manual merge sql/sql_class.h: Manual merge sql/sql_parse.cc: Manual merge
962 lines
28 KiB
C
962 lines
28 KiB
C
/* 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; version 2 of the License.
|
|
|
|
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 */
|
|
|
|
#include <my_global.h>
|
|
#include "m_ctype.h"
|
|
#include "m_string.h"
|
|
|
|
#ifdef USE_MB
|
|
|
|
|
|
uint my_caseup_str_mb(CHARSET_INFO * cs, char *str)
|
|
{
|
|
register uint32 l;
|
|
register uchar *map= cs->to_upper;
|
|
char *str_orig= str;
|
|
|
|
while (*str)
|
|
{
|
|
/* Pointing after the '\0' is safe here. */
|
|
if ((l= my_ismbchar(cs, str, str + cs->mbmaxlen)))
|
|
str+= l;
|
|
else
|
|
{
|
|
*str= (char) map[(uchar)*str];
|
|
str++;
|
|
}
|
|
}
|
|
return str - str_orig;
|
|
}
|
|
|
|
uint my_casedn_str_mb(CHARSET_INFO * cs, char *str)
|
|
{
|
|
register uint32 l;
|
|
register uchar *map= cs->to_lower;
|
|
char *str_orig= str;
|
|
|
|
while (*str)
|
|
{
|
|
/* Pointing after the '\0' is safe here. */
|
|
if ((l= my_ismbchar(cs, str, str + cs->mbmaxlen)))
|
|
str+= l;
|
|
else
|
|
{
|
|
*str= (char) map[(uchar)*str];
|
|
str++;
|
|
}
|
|
}
|
|
return str - str_orig;
|
|
}
|
|
|
|
uint my_caseup_mb(CHARSET_INFO * cs, char *src, uint srclen,
|
|
char *dst __attribute__((unused)),
|
|
uint dstlen __attribute__((unused)))
|
|
{
|
|
register uint32 l;
|
|
register char *srcend= src + srclen;
|
|
register uchar *map= cs->to_upper;
|
|
|
|
DBUG_ASSERT(src == dst && srclen == dstlen);
|
|
while (src < srcend)
|
|
{
|
|
if ((l=my_ismbchar(cs, src, srcend)))
|
|
src+= l;
|
|
else
|
|
{
|
|
*src=(char) map[(uchar) *src];
|
|
src++;
|
|
}
|
|
}
|
|
return srclen;
|
|
}
|
|
|
|
uint my_casedn_mb(CHARSET_INFO * cs, char *src, uint srclen,
|
|
char *dst __attribute__((unused)),
|
|
uint dstlen __attribute__((unused)))
|
|
{
|
|
register uint32 l;
|
|
register char *srcend= src + srclen;
|
|
register uchar *map=cs->to_lower;
|
|
|
|
DBUG_ASSERT(src == dst && srclen == dstlen);
|
|
while (src < srcend)
|
|
{
|
|
if ((l= my_ismbchar(cs, src, srcend)))
|
|
src+= l;
|
|
else
|
|
{
|
|
*src= (char) map[(uchar)*src];
|
|
src++;
|
|
}
|
|
}
|
|
return srclen;
|
|
}
|
|
|
|
/*
|
|
my_strcasecmp_mb() returns 0 if strings are equal, non-zero otherwise.
|
|
*/
|
|
int my_strcasecmp_mb(CHARSET_INFO * cs,const char *s, const char *t)
|
|
{
|
|
register uint32 l;
|
|
register uchar *map=cs->to_upper;
|
|
|
|
while (*s && *t)
|
|
{
|
|
/* Pointing after the '\0' is safe here. */
|
|
if ((l=my_ismbchar(cs, s, s + cs->mbmaxlen)))
|
|
{
|
|
while (l--)
|
|
if (*s++ != *t++)
|
|
return 1;
|
|
}
|
|
else if (my_mbcharlen(cs, *t) > 1)
|
|
return 1;
|
|
else if (map[(uchar) *s++] != map[(uchar) *t++])
|
|
return 1;
|
|
}
|
|
/* At least one of '*s' and '*t' is zero here. */
|
|
return (*t != *s);
|
|
}
|
|
|
|
|
|
/*
|
|
** Compare string against string with wildcard
|
|
** 0 if matched
|
|
** -1 if not matched with wildcard
|
|
** 1 if matched with wildcard
|
|
*/
|
|
|
|
#define INC_PTR(cs,A,B) A+=(my_ismbchar(cs,A,B) ? my_ismbchar(cs,A,B) : 1)
|
|
|
|
#define likeconv(s,A) (uchar) (s)->sort_order[(uchar) (A)]
|
|
|
|
int my_wildcmp_mb(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 */
|
|
|
|
while (wildstr != wildend)
|
|
{
|
|
while (*wildstr != w_many && *wildstr != w_one)
|
|
{
|
|
int l;
|
|
if (*wildstr == escape && wildstr+1 != wildend)
|
|
wildstr++;
|
|
if ((l = my_ismbchar(cs, wildstr, wildend)))
|
|
{
|
|
if (str+l > str_end || memcmp(str, wildstr, l) != 0)
|
|
return 1;
|
|
str += l;
|
|
wildstr += l;
|
|
}
|
|
else
|
|
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 */
|
|
}
|
|
if (*wildstr == w_one)
|
|
{
|
|
do
|
|
{
|
|
if (str == str_end) /* Skip one char if possible */
|
|
return (result);
|
|
INC_PTR(cs,str,str_end);
|
|
} while (++wildstr < wildend && *wildstr == w_one);
|
|
if (wildstr == wildend)
|
|
break;
|
|
}
|
|
if (*wildstr == w_many)
|
|
{ /* Found w_many */
|
|
uchar cmp;
|
|
const char* mb = wildstr;
|
|
int mb_len=0;
|
|
|
|
wildstr++;
|
|
/* Remove any '%' and '_' from the wild search string */
|
|
for (; wildstr != wildend ; wildstr++)
|
|
{
|
|
if (*wildstr == w_many)
|
|
continue;
|
|
if (*wildstr == w_one)
|
|
{
|
|
if (str == str_end)
|
|
return (-1);
|
|
INC_PTR(cs,str,str_end);
|
|
continue;
|
|
}
|
|
break; /* Not a wild character */
|
|
}
|
|
if (wildstr == wildend)
|
|
return(0); /* Ok if w_many is last */
|
|
if (str == str_end)
|
|
return -1;
|
|
|
|
if ((cmp= *wildstr) == escape && wildstr+1 != wildend)
|
|
cmp= *++wildstr;
|
|
|
|
mb=wildstr;
|
|
mb_len= my_ismbchar(cs, wildstr, wildend);
|
|
INC_PTR(cs,wildstr,wildend); /* This is compared trough cmp */
|
|
cmp=likeconv(cs,cmp);
|
|
do
|
|
{
|
|
for (;;)
|
|
{
|
|
if (str >= str_end)
|
|
return -1;
|
|
if (mb_len)
|
|
{
|
|
if (str+mb_len <= str_end && memcmp(str, mb, mb_len) == 0)
|
|
{
|
|
str += mb_len;
|
|
break;
|
|
}
|
|
}
|
|
else if (!my_ismbchar(cs, str, str_end) &&
|
|
likeconv(cs,*str) == cmp)
|
|
{
|
|
str++;
|
|
break;
|
|
}
|
|
INC_PTR(cs,str, str_end);
|
|
}
|
|
{
|
|
int tmp=my_wildcmp_mb(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);
|
|
}
|
|
}
|
|
return (str != str_end ? 1 : 0);
|
|
}
|
|
|
|
|
|
uint my_numchars_mb(CHARSET_INFO *cs __attribute__((unused)),
|
|
const char *pos, const char *end)
|
|
{
|
|
register uint32 count=0;
|
|
while (pos < end)
|
|
{
|
|
uint mb_len;
|
|
pos+= (mb_len= my_ismbchar(cs,pos,end)) ? mb_len : 1;
|
|
count++;
|
|
}
|
|
return count;
|
|
}
|
|
|
|
|
|
uint my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)),
|
|
const char *pos, const char *end, uint length)
|
|
{
|
|
const char *start= pos;
|
|
|
|
while (length && pos < end)
|
|
{
|
|
uint mb_len;
|
|
pos+= (mb_len= my_ismbchar(cs, pos, end)) ? mb_len : 1;
|
|
length--;
|
|
}
|
|
return (uint) (length ? end+2-start : pos-start);
|
|
}
|
|
|
|
|
|
uint my_well_formed_len_mb(CHARSET_INFO *cs, const char *b, const char *e,
|
|
uint pos, int *error)
|
|
{
|
|
const char *b_start= b;
|
|
*error= 0;
|
|
while (pos)
|
|
{
|
|
my_wc_t wc;
|
|
int mb_len;
|
|
|
|
if ((mb_len= cs->cset->mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0)
|
|
{
|
|
*error= b < e ? 1 : 0;
|
|
break;
|
|
}
|
|
b+= mb_len;
|
|
pos--;
|
|
}
|
|
return (uint) (b - b_start);
|
|
}
|
|
|
|
|
|
|
|
uint my_instr_mb(CHARSET_INFO *cs,
|
|
const char *b, uint b_length,
|
|
const char *s, uint s_length,
|
|
my_match_t *match, uint nmatch)
|
|
{
|
|
register const char *end, *b0;
|
|
int res= 0;
|
|
|
|
if (s_length <= b_length)
|
|
{
|
|
if (!s_length)
|
|
{
|
|
if (nmatch)
|
|
{
|
|
match->beg= 0;
|
|
match->end= 0;
|
|
match->mb_len= 0;
|
|
}
|
|
return 1; /* Empty string is always found */
|
|
}
|
|
|
|
b0= b;
|
|
end= b+b_length-s_length+1;
|
|
|
|
while (b < end)
|
|
{
|
|
int mb_len;
|
|
|
|
if (!cs->coll->strnncoll(cs, (unsigned char*) b, s_length,
|
|
(unsigned char*) s, s_length, 0))
|
|
{
|
|
if (nmatch)
|
|
{
|
|
match[0].beg= 0;
|
|
match[0].end= (uint) (b-b0);
|
|
match[0].mb_len= res;
|
|
if (nmatch > 1)
|
|
{
|
|
match[1].beg= match[0].end;
|
|
match[1].end= match[0].end+s_length;
|
|
match[1].mb_len= 0; /* Not computed */
|
|
}
|
|
}
|
|
return 2;
|
|
}
|
|
mb_len= (mb_len= my_ismbchar(cs, b, end)) ? mb_len : 1;
|
|
b+= mb_len;
|
|
b_length-= mb_len;
|
|
res++;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
/* BINARY collations handlers for MB charsets */
|
|
|
|
static int my_strnncoll_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
|
|
const uchar *s, uint slen,
|
|
const uchar *t, uint tlen,
|
|
my_bool t_is_prefix)
|
|
{
|
|
uint len=min(slen,tlen);
|
|
int cmp= memcmp(s,t,len);
|
|
return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
|
|
}
|
|
|
|
|
|
/*
|
|
Compare two strings.
|
|
|
|
SYNOPSIS
|
|
my_strnncollsp_mb_bin()
|
|
cs Chararacter set
|
|
s String to compare
|
|
slen Length of 's'
|
|
t String to compare
|
|
tlen Length of 't'
|
|
diff_if_only_endspace_difference
|
|
Set to 1 if the strings should be regarded as different
|
|
if they only difference in end space
|
|
|
|
NOTE
|
|
This function is used for character strings with binary collations.
|
|
The shorter string is extended with end space to be as long as the longer
|
|
one.
|
|
|
|
RETURN
|
|
A negative number if s < t
|
|
A positive number if s > t
|
|
0 if strings are equal
|
|
*/
|
|
|
|
static int my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
|
|
const uchar *a, uint a_length,
|
|
const uchar *b, uint b_length,
|
|
my_bool diff_if_only_endspace_difference)
|
|
{
|
|
const uchar *end;
|
|
uint length;
|
|
int res;
|
|
|
|
#ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
|
|
diff_if_only_endspace_difference= 0;
|
|
#endif
|
|
|
|
end= a + (length= min(a_length, b_length));
|
|
while (a < end)
|
|
{
|
|
if (*a++ != *b++)
|
|
return ((int) a[-1] - (int) b[-1]);
|
|
}
|
|
res= 0;
|
|
if (a_length != b_length)
|
|
{
|
|
int swap= 1;
|
|
if (diff_if_only_endspace_difference)
|
|
res= 1; /* Assume 'a' is bigger */
|
|
/*
|
|
Check the next not space character of the longer key. If it's < ' ',
|
|
then it's smaller than the other key.
|
|
*/
|
|
if (a_length < b_length)
|
|
{
|
|
/* put shorter key in s */
|
|
a_length= b_length;
|
|
a= b;
|
|
swap= -1; /* swap sign of result */
|
|
res= -res;
|
|
}
|
|
for (end= a + a_length-length; a < end ; a++)
|
|
{
|
|
if (*a != ' ')
|
|
return (*a < ' ') ? -swap : swap;
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
|
|
|
|
static int my_strnxfrm_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
|
|
uchar * dest, uint dstlen,
|
|
const uchar *src, uint srclen)
|
|
{
|
|
if (dest != src)
|
|
memcpy(dest, src, min(dstlen, srclen));
|
|
if (dstlen > srclen)
|
|
bfill(dest + srclen, dstlen - srclen, ' ');
|
|
return dstlen;
|
|
}
|
|
|
|
|
|
static int my_strcasecmp_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
|
|
const char *s, const char *t)
|
|
{
|
|
return strcmp(s,t);
|
|
}
|
|
|
|
static void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
|
|
const uchar *key, uint len,ulong *nr1, ulong *nr2)
|
|
{
|
|
const uchar *pos = key;
|
|
|
|
key+= len;
|
|
|
|
for (; pos < (uchar*) key ; pos++)
|
|
{
|
|
nr1[0]^=(ulong) ((((uint) nr1[0] & 63)+nr2[0]) *
|
|
((uint)*pos)) + (nr1[0] << 8);
|
|
nr2[0]+=3;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
Fill the given buffer with 'maximum character' for given charset
|
|
SYNOPSIS
|
|
pad_max_char()
|
|
cs Character set
|
|
str Start of buffer to fill
|
|
end End of buffer to fill
|
|
|
|
DESCRIPTION
|
|
Write max key:
|
|
- for non-Unicode character sets:
|
|
just set to 255.
|
|
- for Unicode character set (utf-8):
|
|
create a buffer with multibyte representation of the max_sort_char
|
|
character, and copy it into max_str in a loop.
|
|
*/
|
|
static void pad_max_char(CHARSET_INFO *cs, char *str, char *end)
|
|
{
|
|
char buf[10];
|
|
char buflen;
|
|
|
|
if (!(cs->state & MY_CS_UNICODE))
|
|
{
|
|
bfill(str, end - str, 255);
|
|
return;
|
|
}
|
|
|
|
buflen= cs->cset->wc_mb(cs, cs->max_sort_char, (uchar*) buf,
|
|
(uchar*) buf + sizeof(buf));
|
|
|
|
DBUG_ASSERT(buflen > 0);
|
|
do
|
|
{
|
|
if ((str + buflen) < end)
|
|
{
|
|
/* Enough space for the characer */
|
|
memcpy(str, buf, buflen);
|
|
str+= buflen;
|
|
}
|
|
else
|
|
{
|
|
/*
|
|
There is no space for whole multibyte
|
|
character, then add trailing spaces.
|
|
*/
|
|
*str++= ' ';
|
|
}
|
|
} while (str < end);
|
|
}
|
|
|
|
/*
|
|
** Calculate min_str and max_str that ranges a LIKE string.
|
|
** Arguments:
|
|
** ptr Pointer to LIKE string.
|
|
** ptr_length Length of LIKE string.
|
|
** escape Escape character in LIKE. (Normally '\').
|
|
** All escape characters should be removed from min_str and max_str
|
|
** res_length Length of min_str and max_str.
|
|
** min_str Smallest case sensitive string that ranges LIKE.
|
|
** Should be space padded to res_length.
|
|
** max_str Largest case sensitive string that ranges LIKE.
|
|
** Normally padded with the biggest character sort value.
|
|
**
|
|
** The function should return 0 if ok and 1 if the LIKE string can't be
|
|
** optimized !
|
|
*/
|
|
|
|
my_bool my_like_range_mb(CHARSET_INFO *cs,
|
|
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)
|
|
{
|
|
uint mb_len;
|
|
const char *end= ptr + ptr_length;
|
|
char *min_org= min_str;
|
|
char *min_end= min_str + res_length;
|
|
char *max_end= max_str + res_length;
|
|
uint maxcharlen= res_length / cs->mbmaxlen;
|
|
|
|
for (; ptr != end && min_str != min_end && maxcharlen ; maxcharlen--)
|
|
{
|
|
/* We assume here that escape, w_any, w_namy are one-byte characters */
|
|
if (*ptr == escape && ptr+1 != end)
|
|
ptr++; /* Skip escape */
|
|
else if (*ptr == w_one || *ptr == w_many) /* '_' and '%' in SQL */
|
|
{
|
|
/*
|
|
Calculate length of keys:
|
|
'a\0\0... is the smallest possible string when we have space expand
|
|
a\ff\ff... is the biggest possible string
|
|
*/
|
|
*min_length= ((cs->state & MY_CS_BINSORT) ? (uint) (min_str - min_org) :
|
|
res_length);
|
|
*max_length= res_length;
|
|
/* Create min key */
|
|
do
|
|
{
|
|
*min_str++= (char) cs->min_sort_char;
|
|
} while (min_str != min_end);
|
|
|
|
/*
|
|
Write max key: create a buffer with multibyte
|
|
representation of the max_sort_char character,
|
|
and copy it into max_str in a loop.
|
|
*/
|
|
*max_length= res_length;
|
|
pad_max_char(cs, max_str, max_end);
|
|
return 0;
|
|
}
|
|
if ((mb_len= my_ismbchar(cs, ptr, end)) > 1)
|
|
{
|
|
if (ptr+mb_len > end || min_str+mb_len > min_end)
|
|
break;
|
|
while (mb_len--)
|
|
*min_str++= *max_str++= *ptr++;
|
|
}
|
|
else
|
|
*min_str++= *max_str++= *ptr++;
|
|
|
|
}
|
|
|
|
*min_length= *max_length = (uint) (min_str - min_org);
|
|
while (min_str != min_end)
|
|
*min_str++= *max_str++= ' '; /* Because if key compression */
|
|
return 0;
|
|
}
|
|
|
|
|
|
static int my_wildcmp_mb_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 */
|
|
|
|
while (wildstr != wildend)
|
|
{
|
|
while (*wildstr != w_many && *wildstr != w_one)
|
|
{
|
|
int l;
|
|
if (*wildstr == escape && wildstr+1 != wildend)
|
|
wildstr++;
|
|
if ((l = my_ismbchar(cs, wildstr, wildend)))
|
|
{
|
|
if (str+l > str_end || memcmp(str, wildstr, l) != 0)
|
|
return 1;
|
|
str += l;
|
|
wildstr += l;
|
|
}
|
|
else
|
|
if (str == str_end || *wildstr++ != *str++)
|
|
return(1); /* No match */
|
|
if (wildstr == wildend)
|
|
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 */
|
|
return (result);
|
|
INC_PTR(cs,str,str_end);
|
|
} while (++wildstr < wildend && *wildstr == w_one);
|
|
if (wildstr == wildend)
|
|
break;
|
|
}
|
|
if (*wildstr == w_many)
|
|
{ /* Found w_many */
|
|
uchar cmp;
|
|
const char* mb = wildstr;
|
|
int mb_len=0;
|
|
|
|
wildstr++;
|
|
/* Remove any '%' and '_' from the wild search string */
|
|
for (; wildstr != wildend ; wildstr++)
|
|
{
|
|
if (*wildstr == w_many)
|
|
continue;
|
|
if (*wildstr == w_one)
|
|
{
|
|
if (str == str_end)
|
|
return (-1);
|
|
INC_PTR(cs,str,str_end);
|
|
continue;
|
|
}
|
|
break; /* Not a wild character */
|
|
}
|
|
if (wildstr == wildend)
|
|
return(0); /* Ok if w_many is last */
|
|
if (str == str_end)
|
|
return -1;
|
|
|
|
if ((cmp= *wildstr) == escape && wildstr+1 != wildend)
|
|
cmp= *++wildstr;
|
|
|
|
mb=wildstr;
|
|
mb_len= my_ismbchar(cs, wildstr, wildend);
|
|
INC_PTR(cs,wildstr,wildend); /* This is compared trough cmp */
|
|
do
|
|
{
|
|
for (;;)
|
|
{
|
|
if (str >= str_end)
|
|
return -1;
|
|
if (mb_len)
|
|
{
|
|
if (str+mb_len <= str_end && memcmp(str, mb, mb_len) == 0)
|
|
{
|
|
str += mb_len;
|
|
break;
|
|
}
|
|
}
|
|
else if (!my_ismbchar(cs, str, str_end) && *str == cmp)
|
|
{
|
|
str++;
|
|
break;
|
|
}
|
|
INC_PTR(cs,str, str_end);
|
|
}
|
|
{
|
|
int tmp=my_wildcmp_mb_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);
|
|
}
|
|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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
};
|
|
|
|
static struct {int page; char *p;} utr11_data[256]=
|
|
{
|
|
{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},
|
|
{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},
|
|
{0,NULL},{0,pg11},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},
|
|
{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},
|
|
{0,NULL},{0,NULL},{0,NULL},{0,pg23},{0,NULL},{0,NULL},{0,NULL},{0,NULL},
|
|
{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,pg2E},{0,pg2F},
|
|
{0,pg30},{0,pg31},{0,pg32},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{0,pg4D},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{0,pg9F},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{0,pgA4},{0,NULL},{0,NULL},{0,NULL},
|
|
{0,NULL},{0,NULL},{0,NULL},{0,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},
|
|
{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{1,NULL},{0,pgD7},
|
|
{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},
|
|
{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},
|
|
{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},
|
|
{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},{0,NULL},
|
|
{0,NULL},{1,NULL},{0,pgFA},{0,NULL},{0,NULL},{0,NULL},{0,pgFE},{0,pgFF}
|
|
};
|
|
|
|
uint my_numcells_mb(CHARSET_INFO *cs, const char *b, const char *e)
|
|
{
|
|
my_wc_t wc;
|
|
int clen= 0;
|
|
|
|
while (b < e)
|
|
{
|
|
int mb_len;
|
|
uint pg;
|
|
if ((mb_len= cs->cset->mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0)
|
|
{
|
|
mb_len= 1; /* Let's think a wrong sequence takes 1 dysplay cell */
|
|
b++;
|
|
continue;
|
|
}
|
|
b+= mb_len;
|
|
pg= (wc >> 8) & 0xFF;
|
|
clen+= utr11_data[pg].p ? utr11_data[pg].p[wc & 0xFF] : utr11_data[pg].page;
|
|
clen++;
|
|
}
|
|
return clen;
|
|
}
|
|
|
|
|
|
MY_COLLATION_HANDLER my_collation_mb_bin_handler =
|
|
{
|
|
NULL, /* init */
|
|
my_strnncoll_mb_bin,
|
|
my_strnncollsp_mb_bin,
|
|
my_strnxfrm_mb_bin,
|
|
my_strnxfrmlen_simple,
|
|
my_like_range_mb,
|
|
my_wildcmp_mb_bin,
|
|
my_strcasecmp_mb_bin,
|
|
my_instr_mb,
|
|
my_hash_sort_mb_bin,
|
|
my_propagate_simple
|
|
};
|
|
|
|
|
|
#endif
|