mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 21:12:26 +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
556 lines
14 KiB
C
556 lines
14 KiB
C
/* Copyright (C) 2002 MySQL AB & tommy@valley.ne.jp.
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Library General Public
|
|
License as published by the Free Software Foundation; version 2
|
|
of the License.
|
|
|
|
This library 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
|
|
Library General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
License along with this library; if not, write to the Free
|
|
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
|
MA 02111-1307, USA */
|
|
|
|
/* This file is for binary pseudo charset, created by bar@mysql.com */
|
|
|
|
|
|
#include <my_global.h>
|
|
#include "m_string.h"
|
|
#include "m_ctype.h"
|
|
|
|
static uchar ctype_bin[]=
|
|
{
|
|
0,
|
|
32, 32, 32, 32, 32, 32, 32, 32, 32, 40, 40, 40, 40, 40, 32, 32,
|
|
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
|
|
72, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
|
|
132,132,132,132,132,132,132,132,132,132, 16, 16, 16, 16, 16, 16,
|
|
16,129,129,129,129,129,129, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, 16, 16, 16, 16,
|
|
16,130,130,130,130,130,130, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16, 16, 16, 16, 32,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
};
|
|
|
|
|
|
/* Dummy array for toupper / tolower / sortorder */
|
|
|
|
static uchar bin_char_array[] =
|
|
{
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
|
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
|
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
|
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
|
|
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
|
|
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
|
|
96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
|
|
112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
|
|
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
|
|
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
|
|
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
|
|
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
|
|
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
|
|
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
|
|
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
|
|
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
|
|
};
|
|
|
|
|
|
static my_bool
|
|
my_coll_init_8bit_bin(CHARSET_INFO *cs,
|
|
void *(*alloc)(uint) __attribute__((unused)))
|
|
{
|
|
cs->max_sort_char=255;
|
|
return FALSE;
|
|
}
|
|
|
|
static int my_strnncoll_binary(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);
|
|
}
|
|
|
|
|
|
uint my_lengthsp_binary(CHARSET_INFO *cs __attribute__((unused)),
|
|
const char *ptr __attribute__((unused)),
|
|
uint length)
|
|
{
|
|
return length;
|
|
}
|
|
|
|
|
|
/*
|
|
Compare two strings. Result is sign(first_argument - second_argument)
|
|
|
|
SYNOPSIS
|
|
my_strnncollsp_binary()
|
|
cs Chararacter set
|
|
s String to compare
|
|
slen Length of 's'
|
|
t String to compare
|
|
tlen Length of 't'
|
|
|
|
NOTE
|
|
This function is used for real binary strings, i.e. for
|
|
BLOB, BINARY(N) and VARBINARY(N).
|
|
It compares trailing spaces as spaces.
|
|
|
|
RETURN
|
|
< 0 s < t
|
|
0 s == t
|
|
> 0 s > t
|
|
*/
|
|
|
|
static int my_strnncollsp_binary(CHARSET_INFO * cs __attribute__((unused)),
|
|
const uchar *s, uint slen,
|
|
const uchar *t, uint tlen,
|
|
my_bool diff_if_only_endspace_difference
|
|
__attribute__((unused)))
|
|
{
|
|
return my_strnncoll_binary(cs,s,slen,t,tlen,0);
|
|
}
|
|
|
|
|
|
static int my_strnncoll_8bit_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. Result is sign(first_argument - second_argument)
|
|
|
|
SYNOPSIS
|
|
my_strnncollsp_8bit_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
|
|
< 0 s < t
|
|
0 s == t
|
|
> 0 s > t
|
|
*/
|
|
|
|
static int my_strnncollsp_8bit_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;
|
|
/*
|
|
Check the next not space character of the longer key. If it's < ' ',
|
|
then it's smaller than the other key.
|
|
*/
|
|
if (diff_if_only_endspace_difference)
|
|
res= 1; /* Assume 'a' is bigger */
|
|
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;
|
|
}
|
|
|
|
|
|
/* This function is used for all conversion functions */
|
|
|
|
static uint my_case_str_bin(CHARSET_INFO *cs __attribute__((unused)),
|
|
char *str __attribute__((unused)))
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static uint my_case_bin(CHARSET_INFO *cs __attribute__((unused)),
|
|
char *src __attribute__((unused)),
|
|
uint srclen,
|
|
char *dst __attribute__((unused)),
|
|
uint dstlen __attribute__((unused)))
|
|
{
|
|
return srclen;
|
|
}
|
|
|
|
|
|
static int my_strcasecmp_bin(CHARSET_INFO * cs __attribute__((unused)),
|
|
const char *s, const char *t)
|
|
{
|
|
return strcmp(s,t);
|
|
}
|
|
|
|
|
|
int my_mbcharlen_8bit(CHARSET_INFO *cs __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)))
|
|
{
|
|
if (str >= end)
|
|
return MY_CS_TOOSMALL;
|
|
|
|
*wc=str[0];
|
|
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)))
|
|
{
|
|
if (s >= e)
|
|
return MY_CS_TOOSMALL;
|
|
|
|
if (wc < 256)
|
|
{
|
|
s[0]= (char) wc;
|
|
return 1;
|
|
}
|
|
return MY_CS_ILUNI;
|
|
}
|
|
|
|
|
|
void my_hash_sort_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;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
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)++
|
|
|
|
|
|
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 */
|
|
|
|
while (wildstr != wildend)
|
|
{
|
|
while (*wildstr != w_many && *wildstr != w_one)
|
|
{
|
|
if (*wildstr == escape && wildstr+1 != wildend)
|
|
wildstr++;
|
|
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;
|
|
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); /* match if w_many is last */
|
|
if (str == str_end)
|
|
return(-1);
|
|
|
|
if ((cmp= *wildstr) == escape && wildstr+1 != wildend)
|
|
cmp= *++wildstr;
|
|
|
|
INC_PTR(cs,wildstr,wildend); /* This is compared through cmp */
|
|
cmp=likeconv(cs,cmp);
|
|
do
|
|
{
|
|
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);
|
|
if (tmp <= 0)
|
|
return(tmp);
|
|
}
|
|
} while (str != str_end && wildstr[0] != w_many);
|
|
return(-1);
|
|
}
|
|
}
|
|
return(str != str_end ? 1 : 0);
|
|
}
|
|
|
|
|
|
static int my_strnxfrm_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, 0);
|
|
return dstlen;
|
|
}
|
|
|
|
|
|
static
|
|
int my_strnxfrm_8bit_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
|
|
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)
|
|
{
|
|
register const uchar *str, *search, *end, *search_end;
|
|
|
|
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 */
|
|
}
|
|
|
|
str= (const uchar*) b;
|
|
search= (const uchar*) s;
|
|
end= (const uchar*) b+b_length-s_length+1;
|
|
search_end= (const uchar*) s + s_length;
|
|
|
|
skip:
|
|
while (str != end)
|
|
{
|
|
if ( (*str++) == (*search))
|
|
{
|
|
register const uchar *i,*j;
|
|
|
|
i= str;
|
|
j= search+1;
|
|
|
|
while (j != search_end)
|
|
if ((*i++) != (*j++))
|
|
goto skip;
|
|
|
|
if (nmatch > 0)
|
|
{
|
|
match[0].beg= 0;
|
|
match[0].end= (uint) (str- (const uchar*)b-1);
|
|
match[0].mb_len= match[0].end;
|
|
|
|
if (nmatch > 1)
|
|
{
|
|
match[1].beg= match[0].end;
|
|
match[1].end= match[0].end+s_length;
|
|
match[1].mb_len= match[1].end-match[1].beg;
|
|
}
|
|
}
|
|
return 2;
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
MY_COLLATION_HANDLER my_collation_8bit_bin_handler =
|
|
{
|
|
my_coll_init_8bit_bin,
|
|
my_strnncoll_8bit_bin,
|
|
my_strnncollsp_8bit_bin,
|
|
my_strnxfrm_8bit_bin,
|
|
my_strnxfrmlen_simple,
|
|
my_like_range_simple,
|
|
my_wildcmp_bin,
|
|
my_strcasecmp_bin,
|
|
my_instr_bin,
|
|
my_hash_sort_bin,
|
|
my_propagate_simple
|
|
};
|
|
|
|
|
|
static MY_COLLATION_HANDLER my_collation_binary_handler =
|
|
{
|
|
NULL, /* init */
|
|
my_strnncoll_binary,
|
|
my_strnncollsp_binary,
|
|
my_strnxfrm_bin,
|
|
my_strnxfrmlen_simple,
|
|
my_like_range_simple,
|
|
my_wildcmp_bin,
|
|
my_strcasecmp_bin,
|
|
my_instr_bin,
|
|
my_hash_sort_bin,
|
|
my_propagate_simple
|
|
};
|
|
|
|
|
|
static MY_CHARSET_HANDLER my_charset_handler=
|
|
{
|
|
NULL, /* init */
|
|
NULL, /* ismbchar */
|
|
my_mbcharlen_8bit, /* mbcharlen */
|
|
my_numchars_8bit,
|
|
my_charpos_8bit,
|
|
my_well_formed_len_8bit,
|
|
my_lengthsp_binary,
|
|
my_numcells_8bit,
|
|
my_mb_wc_bin,
|
|
my_wc_mb_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,
|
|
my_fill_8bit,
|
|
my_strntol_8bit,
|
|
my_strntoul_8bit,
|
|
my_strntoll_8bit,
|
|
my_strntoull_8bit,
|
|
my_strntod_8bit,
|
|
my_strtoll10_8bit,
|
|
my_strntoull10rnd_8bit,
|
|
my_scan_8bit
|
|
};
|
|
|
|
|
|
CHARSET_INFO my_charset_bin =
|
|
{
|
|
63,0,0, /* number */
|
|
MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_PRIMARY,/* state */
|
|
"binary", /* cs name */
|
|
"binary", /* name */
|
|
"", /* comment */
|
|
NULL, /* tailoring */
|
|
ctype_bin, /* ctype */
|
|
bin_char_array, /* to_lower */
|
|
bin_char_array, /* to_upper */
|
|
NULL, /* sort_order */
|
|
NULL, /* contractions */
|
|
NULL, /* sort_order_big*/
|
|
NULL, /* tab_to_uni */
|
|
NULL, /* tab_from_uni */
|
|
my_unicase_default, /* caseinfo */
|
|
NULL, /* state_map */
|
|
NULL, /* ident_map */
|
|
1, /* strxfrm_multiply */
|
|
1, /* caseup_multiply */
|
|
1, /* casedn_multiply */
|
|
1, /* mbminlen */
|
|
1, /* mbmaxlen */
|
|
0, /* min_sort_char */
|
|
255, /* max_sort_char */
|
|
0, /* pad char */
|
|
0, /* escape_with_backslash_is_dangerous */
|
|
&my_charset_handler,
|
|
&my_collation_binary_handler
|
|
};
|