Commit 38558343 authored by unknown's avatar unknown

Merge paul@bk-internal.mysql.com:/home/bk/mysql-4.1

into teton.kitebird.com:/home/paul/mysql-4.1

parents ced40f13 03f098d5
set names latin1;
set @@collation_connection=latin1_german2_ci;
select @@collation_connection; select @@collation_connection;
@@collation_connection @@collation_connection
latin1_german2_ci latin1_german2_ci
......
...@@ -77,6 +77,9 @@ a ...@@ -77,6 +77,9 @@ a
test test
select * from t1 where a like "%a%"; select * from t1 where a like "%a%";
a a
a
abc
abcd
select * from t1 where a like "%abcd%"; select * from t1 where a like "%abcd%";
a a
abcd abcd
...@@ -84,6 +87,78 @@ select * from t1 where a like "%abc\d%"; ...@@ -84,6 +87,78 @@ select * from t1 where a like "%abc\d%";
a a
abcd abcd
drop table t1; drop table t1;
select 'AA' like 'AA';
'AA' like 'AA'
1
select 'AA' like 'A%A';
'AA' like 'A%A'
1
select 'AA' like 'A%%A';
'AA' like 'A%%A'
1
select 'AA' like 'AA%';
'AA' like 'AA%'
1
select 'AA' like '%AA%';
'AA' like '%AA%'
1
select 'AA' like '%A';
'AA' like '%A'
1
select 'AA' like '%AA';
'AA' like '%AA'
1
select 'AA' like 'A%A%';
'AA' like 'A%A%'
1
select 'AA' like '_%_%';
'AA' like '_%_%'
1
select 'AA' like '%A%A';
'AA' like '%A%A'
1
select 'AAA'like 'A%A%A';
'AAA'like 'A%A%A'
1
select 'AZ' like 'AZ';
'AZ' like 'AZ'
1
select 'AZ' like 'A%Z';
'AZ' like 'A%Z'
1
select 'AZ' like 'A%%Z';
'AZ' like 'A%%Z'
1
select 'AZ' like 'AZ%';
'AZ' like 'AZ%'
1
select 'AZ' like '%AZ%';
'AZ' like '%AZ%'
1
select 'AZ' like '%Z';
'AZ' like '%Z'
1
select 'AZ' like '%AZ';
'AZ' like '%AZ'
1
select 'AZ' like 'A%Z%';
'AZ' like 'A%Z%'
1
select 'AZ' like '_%_%';
'AZ' like '_%_%'
1
select 'AZ' like '%A%Z';
'AZ' like '%A%Z'
1
select 'AZ' like 'A_';
'AZ' like 'A_'
1
select 'AZ' like '_Z';
'AZ' like '_Z'
1
select 'AMZ'like 'A%M%Z';
'AMZ'like 'A%M%Z'
1
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET ucs2); CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET ucs2);
INSERT INTO t1 VALUES (''),(''),(''),(''),(''),(''); INSERT INTO t1 VALUES (''),(''),(''),(''),(''),('');
INSERT INTO t1 VALUES (''),(''),(''),(''); INSERT INTO t1 VALUES (''),(''),(''),('');
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
# Test latin_de character set # Test latin_de character set
# #
set names latin1;
set @@collation_connection=latin1_german2_ci;
select @@collation_connection; select @@collation_connection;
--disable_warnings --disable_warnings
......
...@@ -69,6 +69,35 @@ select * from t1 where a like "%abcd%"; ...@@ -69,6 +69,35 @@ select * from t1 where a like "%abcd%";
select * from t1 where a like "%abc\d%"; select * from t1 where a like "%abc\d%";
drop table t1; drop table t1;
#
# More LIKE test: bug#2619
#
select 'AA' like 'AA';
select 'AA' like 'A%A';
select 'AA' like 'A%%A';
select 'AA' like 'AA%';
select 'AA' like '%AA%';
select 'AA' like '%A';
select 'AA' like '%AA';
select 'AA' like 'A%A%';
select 'AA' like '_%_%';
select 'AA' like '%A%A';
select 'AAA'like 'A%A%A';
select 'AZ' like 'AZ';
select 'AZ' like 'A%Z';
select 'AZ' like 'A%%Z';
select 'AZ' like 'AZ%';
select 'AZ' like '%AZ%';
select 'AZ' like '%Z';
select 'AZ' like '%AZ';
select 'AZ' like 'A%Z%';
select 'AZ' like '_%_%';
select 'AZ' like '%A%Z';
select 'AZ' like 'A_';
select 'AZ' like '_Z';
select 'AMZ'like 'A%M%Z';
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET ucs2); CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET ucs2);
INSERT INTO t1 VALUES (''),(''),(''),(''),(''),(''); INSERT INTO t1 VALUES (''),(''),(''),(''),(''),('');
INSERT INTO t1 VALUES (''),(''),(''),(''); INSERT INTO t1 VALUES (''),(''),(''),('');
......
...@@ -1429,14 +1429,13 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, ...@@ -1429,14 +1429,13 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db, const char *passwd, const char *db,
uint port, const char *unix_socket,ulong client_flag) uint port, const char *unix_socket,ulong client_flag)
{ {
char buff[NAME_LEN+USERNAME_LENGTH+100],charset_name_buff[16]; char buff[NAME_LEN+USERNAME_LENGTH+100];
char *end,*host_info,*charset_name; char *end,*host_info;
my_socket sock; my_socket sock;
in_addr_t ip_addr; in_addr_t ip_addr;
struct sockaddr_in sock_addr; struct sockaddr_in sock_addr;
ulong pkt_length; ulong pkt_length;
NET *net= &mysql->net; NET *net= &mysql->net;
uint charset_number;
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
thr_alarm_t alarmed; thr_alarm_t alarmed;
ALARM alarm_buff; ALARM alarm_buff;
...@@ -1762,10 +1761,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, ...@@ -1762,10 +1761,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
goto error; goto error;
} }
charset_number= mysql->server_language;
/* Set character set */ /* Set character set */
if ((charset_name=mysql->options.charset_name)) if (mysql->options.charset_name)
{ {
const char *save= charsets_dir; const char *save= charsets_dir;
if (mysql->options.charset_dir) if (mysql->options.charset_dir)
...@@ -1773,23 +1770,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, ...@@ -1773,23 +1770,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
mysql->charset=get_charset_by_csname(mysql->options.charset_name, mysql->charset=get_charset_by_csname(mysql->options.charset_name,
MY_CS_PRIMARY, MY_CS_PRIMARY,
MYF(MY_WME)); MYF(MY_WME));
charset_number= mysql->charset ? mysql->charset->number : 0;
charsets_dir= save; charsets_dir= save;
}
else if (mysql->server_language)
{
charset_name=charset_name_buff;
/* Save name in case of errors */
int10_to_str(mysql->server_language, charset_name, 10);
if (!(mysql->charset =
get_charset((uint8) mysql->server_language, MYF(0))))
mysql->charset = default_charset_info; /* shouldn't be fatal */
}
else
{
mysql->charset= default_charset_info;
charset_number= mysql->charset->number;
}
if (!mysql->charset) if (!mysql->charset)
{ {
...@@ -1798,7 +1779,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, ...@@ -1798,7 +1779,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
if (mysql->options.charset_dir) if (mysql->options.charset_dir)
my_snprintf(net->last_error, sizeof(net->last_error)-1, my_snprintf(net->last_error, sizeof(net->last_error)-1,
ER(net->last_errno), ER(net->last_errno),
charset_name ? charset_name : "unknown", mysql->options.charset_name,
mysql->options.charset_dir); mysql->options.charset_dir);
else else
{ {
...@@ -1806,11 +1787,17 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, ...@@ -1806,11 +1787,17 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
get_charsets_dir(cs_dir_name); get_charsets_dir(cs_dir_name);
my_snprintf(net->last_error, sizeof(net->last_error)-1, my_snprintf(net->last_error, sizeof(net->last_error)-1,
ER(net->last_errno), ER(net->last_errno),
charset_name ? charset_name : "unknown", mysql->options.charset_name,
cs_dir_name); cs_dir_name);
} }
goto error; goto error;
} }
}
else
{
mysql->charset= default_charset_info;
}
/* Save connection information */ /* Save connection information */
if (!my_multi_malloc(MYF(0), if (!my_multi_malloc(MYF(0),
...@@ -1870,7 +1857,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, ...@@ -1870,7 +1857,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
/* 4.1 server and 4.1 client has a 32 byte option flag */ /* 4.1 server and 4.1 client has a 32 byte option flag */
int4store(buff,client_flag); int4store(buff,client_flag);
int4store(buff+4, net->max_packet_size); int4store(buff+4, net->max_packet_size);
buff[8]= (char) charset_number; buff[8]= (char) mysql->charset->number;
bzero(buff+9, 32-9); bzero(buff+9, 32-9);
end= buff+32; end= buff+32;
} }
......
...@@ -1779,17 +1779,9 @@ Item *resolve_const_item(Item *item,Item *comp_item) ...@@ -1779,17 +1779,9 @@ Item *resolve_const_item(Item *item,Item *comp_item)
String tmp(buff,sizeof(buff),&my_charset_bin),*result; String tmp(buff,sizeof(buff),&my_charset_bin),*result;
result=item->val_str(&tmp); result=item->val_str(&tmp);
if (item->null_value) if (item->null_value)
{
#ifdef DELETE_ITEMS
delete item;
#endif
return new Item_null(name); return new Item_null(name);
}
uint length=result->length(); uint length=result->length();
char *tmp_str=sql_strmake(result->ptr(),length); char *tmp_str=sql_strmake(result->ptr(),length);
#ifdef DELETE_ITEMS
delete item;
#endif
return new Item_string(name,tmp_str,length,result->charset()); return new Item_string(name,tmp_str,length,result->charset());
} }
if (res_type == INT_RESULT) if (res_type == INT_RESULT)
...@@ -1797,9 +1789,6 @@ Item *resolve_const_item(Item *item,Item *comp_item) ...@@ -1797,9 +1789,6 @@ Item *resolve_const_item(Item *item,Item *comp_item)
longlong result=item->val_int(); longlong result=item->val_int();
uint length=item->max_length; uint length=item->max_length;
bool null_value=item->null_value; bool null_value=item->null_value;
#ifdef DELETE_ITEMS
delete item;
#endif
return (null_value ? (Item*) new Item_null(name) : return (null_value ? (Item*) new Item_null(name) :
(Item*) new Item_int(name,result,length)); (Item*) new Item_int(name,result,length));
} }
...@@ -1808,9 +1797,6 @@ Item *resolve_const_item(Item *item,Item *comp_item) ...@@ -1808,9 +1797,6 @@ Item *resolve_const_item(Item *item,Item *comp_item)
double result=item->val(); double result=item->val();
uint length=item->max_length,decimals=item->decimals; uint length=item->max_length,decimals=item->decimals;
bool null_value=item->null_value; bool null_value=item->null_value;
#ifdef DELETE_ITEMS
delete item;
#endif
return (null_value ? (Item*) new Item_null(name) : return (null_value ? (Item*) new Item_null(name) :
(Item*) new Item_real(name,result,decimals,length)); (Item*) new Item_real(name,result,decimals,length));
} }
......
...@@ -1703,9 +1703,6 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -1703,9 +1703,6 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
{ // Identical function { // Identical function
li.replace(((Item_cond*) item)->list); li.replace(((Item_cond*) item)->list);
((Item_cond*) item)->list.empty(); ((Item_cond*) item)->list.empty();
#ifdef DELETE_ITEMS
delete (Item_cond*) item;
#endif
item= *li.ref(); // new current item item= *li.ref(); // new current item
} }
if (abort_on_null) if (abort_on_null)
......
...@@ -1899,10 +1899,6 @@ mysql_execute_command(THD *thd) ...@@ -1899,10 +1899,6 @@ mysql_execute_command(THD *thd)
if (!(result=new select_send())) if (!(result=new select_send()))
{ {
res= -1; res= -1;
#ifdef DELETE_ITEMS
delete select_lex->having;
delete select_lex->where;
#endif
break; break;
} }
} }
......
...@@ -4395,17 +4395,9 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value) ...@@ -4395,17 +4395,9 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value)
{ {
Item *new_item=remove_eq_conds(item,&tmp_cond_value); Item *new_item=remove_eq_conds(item,&tmp_cond_value);
if (!new_item) if (!new_item)
{
#ifdef DELETE_ITEMS
delete item; // This may be shared
#endif
li.remove(); li.remove();
}
else if (item != new_item) else if (item != new_item)
{ {
#ifdef DELETE_ITEMS
delete item; // This may be shared
#endif
VOID(li.replace(new_item)); VOID(li.replace(new_item));
should_fix_fields=1; should_fix_fields=1;
} }
......
...@@ -1044,14 +1044,13 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs, ...@@ -1044,14 +1044,13 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs,
scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, (const uchar*)wildend); scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, (const uchar*)wildend);
if (scan <= 0) if (scan <= 0)
return 1; return 1;
wildstr+= scan;
if (w_wc == (my_wc_t)escape) if (w_wc == (my_wc_t)escape)
{ {
wildstr+= scan;
scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, (const uchar*)wildend); scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, (const uchar*)wildend);
if (scan <= 0) if (scan <= 0)
return 1; return 1;
wildstr+= scan;
} }
if (w_wc == (my_wc_t)w_many) if (w_wc == (my_wc_t)w_many)
...@@ -1060,6 +1059,7 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs, ...@@ -1060,6 +1059,7 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs,
break; break;
} }
wildstr+= scan;
scan= my_ucs2_uni(cs, &s_wc, (const uchar*)str, (const uchar*)str_end); scan= my_ucs2_uni(cs, &s_wc, (const uchar*)str, (const uchar*)str_end);
if (scan <=0) if (scan <=0)
return 1; return 1;
...@@ -1095,13 +1095,16 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs, ...@@ -1095,13 +1095,16 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs,
scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, (const uchar*)wildend); scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, (const uchar*)wildend);
if (scan <= 0) if (scan <= 0)
return 1; return 1;
wildstr+= scan;
if (w_wc == (my_wc_t)w_many) if (w_wc == (my_wc_t)w_many)
{
wildstr+= scan;
continue; continue;
}
if (w_wc == (my_wc_t)w_one) if (w_wc == (my_wc_t)w_one)
{ {
wildstr+= scan;
scan= my_ucs2_uni(cs, &s_wc, (const uchar*)str, (const uchar*)str_end); scan= my_ucs2_uni(cs, &s_wc, (const uchar*)str, (const uchar*)str_end);
if (scan <=0) if (scan <=0)
return 1; return 1;
...@@ -1120,17 +1123,16 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs, ...@@ -1120,17 +1123,16 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs,
scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, (const uchar*)wildend); scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, (const uchar*)wildend);
if (scan <= 0) if (scan <= 0)
return 1; return 1;
wildstr+= scan;
if (w_wc == (my_wc_t)escape) if (w_wc == (my_wc_t)escape)
{ {
wildstr+= scan;
scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, (const uchar*)wildend); scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, (const uchar*)wildend);
if (scan <= 0) if (scan <= 0)
return 1; return 1;
wildstr+= scan;
} }
do while (1)
{ {
/* Skip until the first character from wildstr is found */ /* Skip until the first character from wildstr is found */
while (str != str_end) while (str != str_end)
...@@ -1138,8 +1140,6 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs, ...@@ -1138,8 +1140,6 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs,
scan= my_ucs2_uni(cs,&s_wc, (const uchar*)str, (const uchar*)str_end); scan= my_ucs2_uni(cs,&s_wc, (const uchar*)str, (const uchar*)str_end);
if (scan <= 0) if (scan <= 0)
return 1; return 1;
str+= scan;
if (weights) if (weights)
{ {
plane=(s_wc>>8) & 0xFF; plane=(s_wc>>8) & 0xFF;
...@@ -1150,17 +1150,19 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs, ...@@ -1150,17 +1150,19 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs,
if (s_wc == w_wc) if (s_wc == w_wc)
break; break;
str+= scan;
} }
if (str == str_end) if (str == str_end)
return -1; return -1;
result= my_wildcmp_ucs2(cs,str,str_end,wildstr,wildend,escape, result= my_wildcmp_ucs2(cs,str,str_end,wildstr,wildend,escape,
w_one,w_many,weights); w_one,w_many,weights);
if (result <= 0) if (result <= 0)
return result; return result;
} while (str != str_end && w_wc != (my_wc_t)w_many); str+= scan;
return -1; }
} }
} }
return (str != str_end ? 1 : 0); return (str != str_end ? 1 : 0);
......
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