diff options
author | unknown <monty@mashka.mysql.fi> | 2003-09-12 04:18:07 +0300 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2003-09-12 04:18:07 +0300 |
commit | 3500763b6e156bcdcb627fbc448681ec3c74c50e (patch) | |
tree | d50c5c2c1a243241a31006d775628dd2fcc29a03 | |
parent | 41824a35338012ff8196eb975f961d5e0f0e2a22 (diff) | |
download | mariadb-git-3500763b6e156bcdcb627fbc448681ec3c74c50e.tar.gz |
Optimize thai character handling
Remove sel000xxxx tests
After merge fixes
BitKeeper/deleted/.del-sel000033.test~3971fbe746eec069:
Delete: mysql-test/t/sel000033.test
BitKeeper/deleted/.del-sel000033.result~56d1d02d72b94602:
Delete: mysql-test/r/sel000033.result
BitKeeper/deleted/.del-sel000100.result~84ed46856cb3a69f:
Delete: mysql-test/r/sel000100.result
BitKeeper/deleted/.del-sel000100.test~548501cad19a1a59:
Delete: mysql-test/t/sel000100.test
mysql-test/r/distinct.result:
Merge test with sel000100
mysql-test/r/grant.result:
Update result after merge
mysql-test/r/range.result:
After merge fix
Merge test with sel000033
mysql-test/t/distinct.test:
Merge test with sel000100
mysql-test/t/range.test:
Merge test with sel000033
sql/log_event.cc:
Remove duplicate allocation
sql/sql_select.cc:
After merge fixes
strings/ctype-tis620.c:
Remove usage of strnlen
Optimize code and make it \0 safe
-rw-r--r-- | mysql-test/r/distinct.result | 37 | ||||
-rw-r--r-- | mysql-test/r/grant.result | 2 | ||||
-rw-r--r-- | mysql-test/r/range.result | 25 | ||||
-rw-r--r-- | mysql-test/r/sel000033.result | 14 | ||||
-rw-r--r-- | mysql-test/r/sel000100.result | 38 | ||||
-rw-r--r-- | mysql-test/t/distinct.test | 47 | ||||
-rw-r--r-- | mysql-test/t/range.test | 8 | ||||
-rw-r--r-- | mysql-test/t/sel000033.test | 20 | ||||
-rw-r--r-- | mysql-test/t/sel000100.test | 48 | ||||
-rw-r--r-- | sql/log_event.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 15 | ||||
-rw-r--r-- | strings/ctype-tis620.c | 190 |
12 files changed, 223 insertions, 223 deletions
diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index c7ce157a670..5e713f59100 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -427,3 +427,40 @@ name a e drop table t1; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +NAME varchar(75) DEFAULT '' NOT NULL, +LINK_ID int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (ID), +KEY NAME (NAME), +KEY LINK_ID (LINK_ID) +); +INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0); +INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (2,'Jack',0); +INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (3,'Bill',0); +CREATE TABLE t2 ( +ID int(11) NOT NULL auto_increment, +NAME varchar(150) DEFAULT '' NOT NULL, +PRIMARY KEY (ID), +KEY NAME (NAME) +); +SELECT DISTINCT +t2.id AS key_link_id, +t2.name AS link +FROM t1 +LEFT JOIN t2 ON t1.link_id=t2.id +GROUP BY t1.id +ORDER BY link; +key_link_id link +NULL NULL +drop table t1,t2; +CREATE TABLE t1 ( +html varchar(5) default NULL, +rin int(11) default '0', +out int(11) default '0' +) TYPE=MyISAM; +INSERT INTO t1 VALUES ('1',1,0); +SELECT DISTINCT html,SUM(out)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin; +html prod +1 0.00 +drop table t1; diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 0a54072d260..89426edb000 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -145,7 +145,7 @@ show grants for drop_user@localhost; Grants for drop_user@localhost GRANT ALL PRIVILEGES ON *.* TO 'drop_user'@'localhost' WITH GRANT OPTION GRANT ALL PRIVILEGES ON `test`.* TO 'drop_user'@'localhost' WITH GRANT OPTION -GRANT USAGE ON `test`.`t1` TO 'drop_user'@'localhost' +GRANT SELECT (a) ON `test`.`t1` TO 'drop_user'@'localhost' revoke all privileges, grant from drop_user@localhost; show grants for drop_user@localhost; Grants for drop_user@localhost diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index ec090cf4b94..9f76676ee1a 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -265,11 +265,24 @@ INSERT INTO t1 VALUES (0),(0),(1),(1); CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya)); INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3; -table type possible_keys key key_len ref rows Extra -t2 ref j1 j1 4 const 1 Using where; Using index -t1 ALL i1,i2 NULL NULL NULL 4 Range checked for each record (index map: 3) +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref j1 j1 4 const 1 Using where; Using index +1 SIMPLE t1 ALL i1,i2 NULL NULL NULL 4 Range checked for each record (index map: 3) explain select * from t1 force index(i2), t2 where (t1.key1 <t2.keya + 1) and t2.keya=3; -table type possible_keys key key_len ref rows Extra -t2 ref j1 j1 4 const 1 Using where; Using index -t1 ALL i2 NULL NULL NULL 4 Range checked for each record (index map: 2) +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref j1 j1 4 const 1 Using where; Using index +1 SIMPLE t1 ALL i2 NULL NULL NULL 4 Range checked for each record (index map: 2) DROP TABLE t1,t2; +create table t1 (id int(10) primary key); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select id from t1 where id in (2,5,9) ; +id +2 +5 +9 +select id from t1 where id=2 or id=5 or id=9 ; +id +2 +5 +9 +drop table t1; diff --git a/mysql-test/r/sel000033.result b/mysql-test/r/sel000033.result deleted file mode 100644 index 1bfafaf5b27..00000000000 --- a/mysql-test/r/sel000033.result +++ /dev/null @@ -1,14 +0,0 @@ -drop table if exists t1; -create table t1 (id int(10) primary key); -insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); -select id from t1 where id in (2,5,9) ; -id -2 -5 -9 -select id from t1 where id=2 or id=5 or id=9 ; -id -2 -5 -9 -drop table t1; diff --git a/mysql-test/r/sel000100.result b/mysql-test/r/sel000100.result deleted file mode 100644 index 3ffa4004b84..00000000000 --- a/mysql-test/r/sel000100.result +++ /dev/null @@ -1,38 +0,0 @@ -DROP TABLE IF EXISTS t1,t2; -CREATE TABLE t1 ( -ID int(11) NOT NULL auto_increment, -NAME varchar(75) DEFAULT '' NOT NULL, -LINK_ID int(11) DEFAULT '0' NOT NULL, -PRIMARY KEY (ID), -KEY NAME (NAME), -KEY LINK_ID (LINK_ID) -); -INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0); -INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (2,'Jack',0); -INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (3,'Bill',0); -CREATE TABLE t2 ( -ID int(11) NOT NULL auto_increment, -NAME varchar(150) DEFAULT '' NOT NULL, -PRIMARY KEY (ID), -KEY NAME (NAME) -); -SELECT DISTINCT -t2.id AS key_link_id, -t2.name AS link -FROM t1 -LEFT JOIN t2 ON t1.link_id=t2.id -GROUP BY t1.id -ORDER BY link; -key_link_id link -NULL NULL -drop table t1,t2; -CREATE TABLE t1 ( -html varchar(5) default NULL, -rin int(11) default '0', -out int(11) default '0' -) TYPE=MyISAM; -INSERT INTO t1 VALUES ('1',1,0); -SELECT DISTINCT html,SUM(out)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin; -html prod -1 0.00 -drop table t1; diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test index 0563b432873..56c00e7501c 100644 --- a/mysql-test/t/distinct.test +++ b/mysql-test/t/distinct.test @@ -285,3 +285,50 @@ INSERT INTO t1 VALUES (3, 'aaaaa'); INSERT INTO t1 VALUES (2, 'eeeeeee'); select distinct left(name,1) as name from t1; drop table t1; + +# +# Test case from sel000100 +# + +CREATE TABLE t1 ( + ID int(11) NOT NULL auto_increment, + NAME varchar(75) DEFAULT '' NOT NULL, + LINK_ID int(11) DEFAULT '0' NOT NULL, + PRIMARY KEY (ID), + KEY NAME (NAME), + KEY LINK_ID (LINK_ID) +); + +INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0); +INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (2,'Jack',0); +INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (3,'Bill',0); + +CREATE TABLE t2 ( + ID int(11) NOT NULL auto_increment, + NAME varchar(150) DEFAULT '' NOT NULL, + PRIMARY KEY (ID), + KEY NAME (NAME) +); + +SELECT DISTINCT + t2.id AS key_link_id, + t2.name AS link +FROM t1 +LEFT JOIN t2 ON t1.link_id=t2.id +GROUP BY t1.id +ORDER BY link; +drop table t1,t2; + +# +# test case for #674 +# + +CREATE TABLE t1 ( + html varchar(5) default NULL, + rin int(11) default '0', + out int(11) default '0' +) TYPE=MyISAM; + +INSERT INTO t1 VALUES ('1',1,0); +SELECT DISTINCT html,SUM(out)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin; +drop table t1; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index e8f51344ce1..7bf6570b558 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -217,3 +217,11 @@ explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3; explain select * from t1 force index(i2), t2 where (t1.key1 <t2.keya + 1) and t2.keya=3; DROP TABLE t1,t2; +# test for a bug with in() and unique key + +create table t1 (id int(10) primary key); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); + +select id from t1 where id in (2,5,9) ; +select id from t1 where id=2 or id=5 or id=9 ; +drop table t1; diff --git a/mysql-test/t/sel000033.test b/mysql-test/t/sel000033.test deleted file mode 100644 index 72e096311ce..00000000000 --- a/mysql-test/t/sel000033.test +++ /dev/null @@ -1,20 +0,0 @@ -# sel000033 -# -# Versions -# -------- -# 3.22 -# 3.23 -# -# Description -# ----------- -# test for a bug with in() and unique key - ---disable_warnings -drop table if exists t1; ---enable_warnings -create table t1 (id int(10) primary key); -insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); - -select id from t1 where id in (2,5,9) ; -select id from t1 where id=2 or id=5 or id=9 ; -drop table t1; diff --git a/mysql-test/t/sel000100.test b/mysql-test/t/sel000100.test deleted file mode 100644 index c9923d178c6..00000000000 --- a/mysql-test/t/sel000100.test +++ /dev/null @@ -1,48 +0,0 @@ ---disable_warnings -DROP TABLE IF EXISTS t1,t2; ---enable_warnings - -CREATE TABLE t1 ( - ID int(11) NOT NULL auto_increment, - NAME varchar(75) DEFAULT '' NOT NULL, - LINK_ID int(11) DEFAULT '0' NOT NULL, - PRIMARY KEY (ID), - KEY NAME (NAME), - KEY LINK_ID (LINK_ID) -); - -INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0); -INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (2,'Jack',0); -INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (3,'Bill',0); - -CREATE TABLE t2 ( - ID int(11) NOT NULL auto_increment, - NAME varchar(150) DEFAULT '' NOT NULL, - PRIMARY KEY (ID), - KEY NAME (NAME) -); - -SELECT DISTINCT - t2.id AS key_link_id, - t2.name AS link -FROM t1 -LEFT JOIN t2 ON t1.link_id=t2.id -GROUP BY t1.id -ORDER BY link; - -drop table t1,t2; - -# -# test case for #674 -# -CREATE TABLE t1 ( - html varchar(5) default NULL, - rin int(11) default '0', - out int(11) default '0' -) TYPE=MyISAM; - -INSERT INTO t1 VALUES ('1',1,0); - -SELECT DISTINCT html,SUM(out)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin; - -drop table t1; diff --git a/sql/log_event.cc b/sql/log_event.cc index 91349feec39..6be8fe54854 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -875,7 +875,6 @@ void Query_log_event::print(FILE* file, bool short_form, char* last_db) int Query_log_event::exec_event(struct st_relay_log_info* rli) { int expected_error,actual_error= 0; - init_sql_alloc(&thd->mem_root, 8192,0); thd->db= (char*) rewrite_db(db); /* @@ -1589,7 +1588,6 @@ void Load_log_event::set_fields(List<Item> &field_list) int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, bool use_rli_only_for_errors) { - init_sql_alloc(&thd->mem_root, 8192,0); thd->db= (char*) rewrite_db(db); DBUG_ASSERT(thd->query == 0); thd->query = 0; // Should not be needed diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ccc6e10dee8..a3a8fe288fa 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2185,9 +2185,9 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, if (cond_func->key_item()->real_item()->type() == Item::FIELD_ITEM && !(cond_func->used_tables() & OUTER_REF_TABLE_BIT)) add_key_field(key_fields,*and_level, - ((Item_field*) (cond_func->key_item()->real_item()))->field, 0, + ((Item_field*) (cond_func->key_item()->real_item()))-> + field, 0, cond_func->arguments()+1, cond_func->argument_count()-1, -#endif usable_tables); break; case Item_func::OPTIMIZE_OP: @@ -3356,8 +3356,11 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) OPTION_FOUND_ROWS ? HA_POS_ERROR : join->unit->select_limit_cnt)) < 0) - { /* before reporting "Impossible WHERE" for the whole query - we have to check isn't it only "impossible ON" instead */ + { + /* + Before reporting "Impossible WHERE" for the whole query + we have to check isn't it only "impossible ON" instead + */ sel->cond=orig_cond; if (!tab->on_expr || sel->test_quick_select(tab->keys, @@ -3365,8 +3368,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) (join->select_options & OPTION_FOUND_ROWS ? HA_POS_ERROR : - join->thd->select_limit)) < 0) - DBUG_RETURN(1); // Impossible WHERE + join->unit->select_limit_cnt)) < 0) + DBUG_RETURN(1); // Impossible WHERE } else sel->cond=orig_cond; diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index da212d06a3d..33bd41f3236 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (C) 2000-2003 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 @@ -51,10 +51,7 @@ #ifdef HAVE_CHARSET_tis620 -static uchar* thai2sortable(const uchar *tstr,int len); - #define BUFFER_MULTIPLY 4 -#define buffsize(s) (BUFFER_MULTIPLY * (strlen(s) + 1)) #define M L_MIDDLE #define U L_UPPER #define L L_LOWER @@ -451,34 +448,50 @@ 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 - Arg: const source string and length of converted string - Ret: Sortable string -*/ /* - NOTE: isn't it faster to alloc buffer in calling function? - */ -static uchar* thai2sortable(const uchar * tstr,int len) -{ -/* We use only 3 levels (neglect capitalization). */ + Convert thai string to "Standard C String Function" sortable string - const uchar* p= tstr; + SYNOPSIS + 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) +{ + const uchar *p= tstr; uchar *outBuf; uchar *pRight1, *pRight2, *pRight3; uchar *pLeft1, *pLeft2, *pLeft3; - uint bufSize; - uint RightSize; + uint bufSize; + uint RightSize; - len= (int) strnlen((char*) tstr,len); - bufSize= (uint) buffsize((char*) tstr); + bufSize= (uint) (len + 1) * BUFFER_MULTIPLY; RightSize= sizeof(uchar) * (len + 1); - if (!(outBuf= pLeft1= pRight1= + if (!(outBuf= pLeft1= pRight1= (uchar *)malloc(sizeof(uchar) * bufSize + RightSize*2))) + { + /* + 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; - while (--len > 0) + while ((int) --len > 0) { int *t_ctype0= t_ctype[p[0]]; if (isldvowel(*p) && isconsnt(p[1])) @@ -507,17 +520,14 @@ static uchar* thai2sortable(const uchar * tstr,int len) p++; } } - if (!len) + if (!len) /* If last was not double byte */ { int *t_ctype0= t_ctype[p[0]]; - *pRight1= t_ctype0[0]; - if (*pRight1 != IGNORE) + if ((*pRight1= t_ctype0[0] != IGNORE)) pRight1++; - *pRight2= t_ctype0[1]; - if (*pRight2 != IGNORE) + if ((*pRight2= t_ctype0[1]) != IGNORE) pRight2++; - *pRight3= t_ctype0[2]; - if (*pRight3 != IGNORE) + if ((*pRight3= t_ctype0[2]) != IGNORE) pRight3++; } *pRight1++= L2_BLANK; @@ -526,31 +536,45 @@ static uchar* thai2sortable(const uchar * tstr,int len) memcpy(pRight1, pLeft2, pRight2 - pLeft2); pRight1+= pRight2 - pLeft2; memcpy(pRight1, pLeft3, pRight3 - pLeft3); + *out_length= (uint) ((pRight1+ (uint) (pRight3 - pLeft3)) - outBuf); return outBuf; } -/* strncoll() replacement, compare 2 string, both are conveted to sortable string - Arg: 2 Strings and it compare length - Ret: strcmp result + +/* + strncoll() replacement, compare 2 string, both are conveted to sortable + string + + Arg: 2 Strings and it compare length + Ret: strcmp result */ + int my_strnncoll_tis620(CHARSET_INFO *cs __attribute__((unused)), const uchar * s1, uint len1, const uchar * s2, uint len2) { uchar *tc1, *tc2; - int i; - tc1= thai2sortable(s1, len1); - tc2= thai2sortable(s2, len2); - i= strcmp((char*)tc1, (char*)tc2); - free(tc1); - free(tc2); - return i; + uint tc1_length, tc2_length, length; + int res; + + 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) + free(tc1); + if (tc2 != s2) + free(tc2); + return (res || tc1_length == tc2_length ? res : + (tc1_length < tc2_length ? -1 : 1)); } + static int my_strnncollsp_tis620(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--); @@ -566,63 +590,48 @@ int my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)), uchar * dest, uint len, const uchar * src, uint srclen) { - uint bufSize; - uchar *tmp; - bufSize= (uint) buffsize((char*)src); - tmp= thai2sortable(src,srclen); - set_if_smaller(bufSize,(uint) len); - memcpy((uchar *)dest, tmp, bufSize); - free(tmp); - return (int)bufSize; + 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; } + /* strcoll replacment, compare 2 strings Arg: 2 strings - Ret: strcmp result + Ret: memcmp result */ + int my_strcoll_tis620(const uchar * s1, const uchar * s2) { - uchar *tc1, *tc2; - int i; - tc1= thai2sortable(s1, (int) strlen((char*)s1)); - tc2= thai2sortable(s2, (int) strlen((char*)s2)); - i= strcmp((char*)tc1, (char*)tc2); - free(tc1); - free(tc2); - return i; + return my_strnncoll_tis620((CHARSET_INFO *) 0, s1, strlen(s1), s2, + strlen(s1)); } -/* strxfrm replacment, convert Thai string to sortable string - Arg: Destination buffer, String and dest buffer size - Ret: Converting string size -*/ -int my_strxfrm_tis620(uchar * dest, const uchar * src, int len) -{ - uint bufSize; - uchar *tmp; - - bufSize= (uint)buffsize((char*) src); - tmp= thai2sortable(src, len); - memcpy((uchar *)dest, tmp, bufSize); - free(tmp); - return bufSize; -} -/* Convert SQL like string to C string - Arg: String, its length, escape character, resource length, minimal string and maximum string - Ret: Alway 0 +/* + Convert SQL LIKE string to C string + + 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 + converted there. + + RETURN VALUES + 0 */ -/* 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 - converted there. */ #define max_sort_chr ((char) 255) 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, - uint res_length, char *min_str, char *max_str, - uint *min_length, uint *max_length) + 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 *end=ptr+ptr_length; char *min_org=min_str; @@ -636,18 +645,18 @@ my_bool my_like_range_tis620(CHARSET_INFO *cs __attribute__((unused)), *min_str++ = *max_str++ = *ptr; continue; } - if (*ptr == w_one) /* '_' in SQL */ + if (*ptr == w_one) /* '_' in SQL */ { *min_str++='\0'; /* This should be min char */ *max_str++=max_sort_chr; continue; } - if (*ptr == w_many) /* '%' in SQL */ + if (*ptr == w_many) /* '%' in SQL */ { *min_length= (uint) (min_str - min_org); *max_length=res_length; do { - *min_str++ = ' '; /* Because if key compression */ + *min_str++ = ' '; /* For key compression */ *max_str++ = max_sort_chr; } while (min_str != min_end); return 0; @@ -657,14 +666,18 @@ 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++ = ' '; /* Because if key compression */ + *min_str++ = *max_str++ = ' '; /* For key compression */ return 0; } -/* Thai normalization for input sub system - Arg: Buffer, 's length, String, 'length - Ret: Void +#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; @@ -686,6 +699,7 @@ void ThNormalize(uchar* ptr, uint field_length, const uchar* from, uint length) else *p++ = *fr++; } +#endif /* NOT_NEEDED */ static MY_COLLATION_HANDLER my_collation_ci_handler = |