Bug #3087 CONCAT_WS makes the server die in case of illegal mix of collations
Submitted: 7 Mar 2004 2:38 Modified: 19 Mar 2004 0:15
Reporter: [ name withheld ] Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.2 OS:Linux (Linux/Windows)
Assigned to: Alexander Barkov CPU Architecture:Any

[7 Mar 2004 2:38] [ name withheld ]
Description:
See synopsis.

Environment:
- MySQL server 4.1.2-alpha-nightly-20040229 on Linux. (Mandrake 8.1)

How to repeat:
drop table test1;
create table test1 (
  str varchar(10)
) TYPE=InnoDB DEFAULT CHARSET=utf8;
insert into test1 values ('aaaaaaaaaa');
commit;
select concat(str,'|',str) from test1; #-> illegal mix of collations, OK.
select concat_ws('|',str,str) from test1; #->server dies
select concat(str,_utf8'|',str) from test1; #->works 
select concat_ws(_utf8'|',str,str) from test1; #->works
[7 Mar 2004 2:44] [ name withheld ]
Stack trace file

Attachment: stack.trc (application/octet-stream, text), 3.29 KiB.

[7 Mar 2004 8:28] MySQL Verification Team
Thank you for the bug report, I was able for to get the server's crash:

\sql\item_strfunc.cpp
--47--

static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fname)
{
  my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0),
  	   c1.collation->name,c1.derivation_name(),
	   c2.collation->name,c2.derivation_name(),
	   fname);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}

below call stack:

>	mysqld.exe!my_coll_agg_error(DTCollation & c1={...}, DTCollation & c2={...}, const char * fname=0x00785fd4)  Line 47 + 0x24	C++
 	mysqld.exe!Item_func_concat_ws::fix_length_and_dec()  Line 634 + 0x2b	C++
 	mysqld.exe!Item_func::fix_fields(THD * thd=0x02eeee78, st_table_list * tables=0x02ef0358, Item * * ref=0x02ef02e4)  Line 222	C++
 	mysqld.exe!Item_func_concat_ws::fix_fields(THD * thd=0x02eeee78, st_table_list * tlist=0x02ef0358, Item * * ref=0x02ef02e4)  Line 105 + 0x56	C++
 	mysqld.exe!setup_fields(THD * thd=0x02eeee78, Item * * ref_pointer_array=0x02ef0dd0, st_table_list * tables=0x02ef0358, List<Item> & fields={...}, int set_query_id=1, List<Item> * sum_func_list=0x02ef0d30, int allow_sum_func=1)  Line 2144 + 0x1c	C++
 	mysqld.exe!JOIN::prepare(Item * * * rref_pointer_array=0x02eef074, st_table_list * tables_init=0x02ef0358, unsigned int wild_num=0, Item * conds_init=0x00000000, unsigned int og_num=0, st_order * order_init=0x00000000, st_order * group_init=0x00000000, Item * having_init=0x00000000, st_order * proc_param_init=0x00000000, st_select_lex * select_lex_arg=0x02eeef8c, st_select_lex_unit * unit_arg=0x02eeee9c)  Line 308 + 0xb1	C++
 	mysqld.exe!mysql_select(THD * thd=0x02eeee78, Item * * * rref_pointer_array=0x02eef074, st_table_list * tables=0x02ef0358, unsigned int wild_num=0, List<Item> & fields={...}, Item * conds=0x00000000, unsigned int og_num=0, st_order * order=0x00000000, st_order * group=0x00000000, Item * having=0x00000000, st_order * proc_param=0x00000000, unsigned long select_options=8669696, select_result * result=0x02ef03c8, st_select_lex_unit * unit=0x02eeee9c, st_select_lex * select_lex=0x02eeef8c)  Line 1588 + 0x34	C++
 	mysqld.exe!handle_select(THD * thd=0x02eeee78, st_lex * lex=0x02eeee90, select_result * result=0x02ef03c8)  Line 190 + 0x87	C++
 	mysqld.exe!mysql_execute_command(THD * thd=0x02eeee78)  Line 1913 + 0x11	C++
 	mysqld.exe!mysql_parse(THD * thd=0x02eeee78, char * inBuf=0x02ef00f0, unsigned int length=40)  Line 3886 + 0x9	C++
 	mysqld.exe!dispatch_command(enum_server_command command=COM_QUERY, THD * thd=0x02eeee78, char * packet=0x02ee0769, unsigned int packet_length=41)  Line 1404 + 0x1d	C++
 	mysqld.exe!do_command(THD * thd=0x02eeee78)  Line 1235 + 0x31	C++
 	mysqld.exe!handle_one_connection(void * arg=0x02eeee78)  Line 1003 + 0x9	C++
 	mysqld.exe!pthread_start(void * param=0x00e3ffe8)  Line 63 + 0x7	C
 	mysqld.exe!_threadstart(void * ptd=0x02eec468)  Line 173 + 0xd	C
 	kernel32.dll!77e6d33b()
[19 Mar 2004 0:15] Alexander Barkov
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html