diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index c61563e6010a078350a999385a4b2ee01c6ffeed..b6d9f512c1ab8c006fd669661baf7e8cd06c32a9 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -288,6 +288,21 @@ latin2_general_ci 3 select collation(trim(BOTH _latin2' ' FROM _latin2'a')), coercibility(trim(BOTH _latin2'a' FROM _latin2'a')); collation(trim(BOTH _latin2' ' FROM _latin2'a')) coercibility(trim(BOTH _latin2'a' FROM _latin2'a')) latin2_general_ci 3 +select collation(repeat(_latin2'a',10)), coercibility(repeat(_latin2'a',10)); +collation(repeat(_latin2'a',10)) coercibility(repeat(_latin2'a',10)) +latin2_general_ci 3 +select collation(reverse(_latin2'ab')), coercibility(reverse(_latin2'ab')); +collation(reverse(_latin2'ab')) coercibility(reverse(_latin2'ab')) +latin2_general_ci 3 +select collation(quote(_latin2'ab')), coercibility(quote(_latin2'ab')); +collation(quote(_latin2'ab')) coercibility(quote(_latin2'ab')) +latin2_general_ci 3 +select collation(soundex(_latin2'ab')), coercibility(soundex(_latin2'ab')); +collation(soundex(_latin2'ab')) coercibility(soundex(_latin2'ab')) +latin2_general_ci 3 +select collation(substring(_latin2'ab',1)), coercibility(substring(_latin2'ab',1)); +collation(substring(_latin2'ab',1)) coercibility(substring(_latin2'ab',1)) +latin2_general_ci 3 create table t1 select left(_latin2'a',1), @@ -302,7 +317,12 @@ ltrim(_latin2' a '), rtrim(_latin2' a '), trim(LEADING _latin2' ' FROM _latin2' a '), trim(TRAILING _latin2' ' FROM _latin2' a '), -trim(BOTH _latin2' ' FROM _latin2' a ') +trim(BOTH _latin2' ' FROM _latin2' a '), +repeat(_latin2'a',10), +reverse(_latin2'ab'), +quote(_latin2'ab'), +soundex(_latin2'ab'), +substring(_latin2'ab',1) ; show create table t1; Table Create Table @@ -319,6 +339,11 @@ t1 CREATE TABLE `t1` ( `rtrim(_latin2' a ')` char(3) character set latin2 NOT NULL default '', `trim(LEADING _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default '', `trim(TRAILING _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default '', - `trim(BOTH _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default '' + `trim(BOTH _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default '', + `repeat(_latin2'a',10)` char(10) character set latin2 NOT NULL default '', + `reverse(_latin2'ab')` char(2) character set latin2 NOT NULL default '', + `quote(_latin2'ab')` char(6) character set latin2 NOT NULL default '', + `soundex(_latin2'ab')` char(4) character set latin2 NOT NULL default '', + `substring(_latin2'ab',1)` char(2) character set latin2 NOT NULL default '' ) TYPE=MyISAM CHARSET=latin1 drop table t1; diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index d99b54d88ff408d29ce57871da6b5b65330862af..7bb83058281dea8c75bad64d34b0d15d188fccb1 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -149,6 +149,12 @@ select collation(rtrim(_latin2' a ')), coercibility(rtrim(_latin2' a ')); select collation(trim(LEADING _latin2' ' FROM _latin2'a')), coercibility(trim(LEADING _latin2'a' FROM _latin2'a')); select collation(trim(TRAILING _latin2' ' FROM _latin2'a')), coercibility(trim(TRAILING _latin2'a' FROM _latin2'a')); select collation(trim(BOTH _latin2' ' FROM _latin2'a')), coercibility(trim(BOTH _latin2'a' FROM _latin2'a')); +select collation(repeat(_latin2'a',10)), coercibility(repeat(_latin2'a',10)); +select collation(reverse(_latin2'ab')), coercibility(reverse(_latin2'ab')); +select collation(quote(_latin2'ab')), coercibility(quote(_latin2'ab')); +select collation(soundex(_latin2'ab')), coercibility(soundex(_latin2'ab')); +select collation(substring(_latin2'ab',1)), coercibility(substring(_latin2'ab',1)); + create table t1 select left(_latin2'a',1), @@ -163,7 +169,12 @@ select rtrim(_latin2' a '), trim(LEADING _latin2' ' FROM _latin2' a '), trim(TRAILING _latin2' ' FROM _latin2' a '), - trim(BOTH _latin2' ' FROM _latin2' a ') + trim(BOTH _latin2' ' FROM _latin2' a '), + repeat(_latin2'a',10), + reverse(_latin2'ab'), + quote(_latin2'ab'), + soundex(_latin2'ab'), + substring(_latin2'ab',1) ; show create table t1; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 4438b9020111a244bb7e1d8515bfc5651e57a133..549839b4f96b2ed4dcd667ae6816380afcbad7e1 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -263,13 +263,6 @@ class Item_func_strcmp :public Item_bool_func2 public: Item_func_strcmp(Item *a,Item *b) :Item_bool_func2(a,b) {} longlong val_int(); - void fix_length_and_dec() - { - max_length=2; - /* QQ: COERCIBILITY */ - cmp_charset= args[0]->binary() || args[1]->binary() ? - &my_charset_bin : args[0]->charset(); - } optimize_type select_optimize() const { return OPTIMIZE_NONE; } const char *func_name() const { return "strcmp"; } }; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index e5b73e7670fb4c1c2b817ca86acc0346d3757c01..b9d44295f35fdeea6cada607b1ef22f74bf1ce57 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -702,6 +702,7 @@ String *Item_func_reverse::val_str(String *str) void Item_func_reverse::fix_length_and_dec() { + set_charset(args[0]->charset(),args[0]->coercibility); max_length = args[0]->max_length; } @@ -1521,6 +1522,7 @@ String *Item_func_user::val_str(String *str) void Item_func_soundex::fix_length_and_dec() { + set_charset(args[0]->charset(), args[0]->coercibility); max_length=args[0]->max_length; set_if_bigger(max_length,4); } @@ -1552,7 +1554,7 @@ String *Item_func_soundex::val_str(String *str) { String *res =args[0]->val_str(str); char last_ch,ch; - CHARSET_INFO *cs= &my_charset_latin1; + CHARSET_INFO *cs= charset(); if ((null_value=args[0]->null_value)) return 0; /* purecov: inspected */ @@ -2538,6 +2540,7 @@ String *Item_func_quote::val_str(String *str) } *to= '\''; str->length(new_length); + str->set_charset(charset()); return str; null: diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index a70c9b392556ab129093ab00c44b57273f03b8d7..31d6c1fe89db70de9a2c0cc062ae60cfafb1fb42 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -571,7 +571,11 @@ public: Item_func_quote(Item *a) :Item_str_func(a) {} const char *func_name() const { return "quote"; } String *val_str(String *); - void fix_length_and_dec() { max_length= args[0]->max_length * 2 + 2; } + void fix_length_and_dec() + { + set_charset(args[0]->charset(), args[0]->coercibility); + max_length= args[0]->max_length * 2 + 2; + } }; class Item_func_conv_charset :public Item_str_func