Bug #47910 Mysql client Segfaults on query 2 byte coll id with column-type-info enabled
Submitted: 8 Oct 2009 8:14 Modified: 5 Apr 2010 6:40
Reporter: Nidhi Shrotriya Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.1.45 OS:Any
Assigned to: CPU Architecture:Any
Tags: 5.1

[8 Oct 2009 8:14] Nidhi Shrotriya
Description:
Start 6.0 server with --character-sets-dir=$PWD/mysql-test/std_data for 2 byte collation IDs. 

Connect with 5.1 client and --column-type-info enabled.
mysql> SHOW COLLATION LIKE 'ucs2_vn_ci';
+------------+---------+-----+---------+----------+---------+
| Collation  | Charset | Id  | Default | Compiled | Sortlen |
+------------+---------+-----+---------+----------+---------+
| ucs2_vn_ci | ucs2    | 359 |         |          |       8 |
+------------+---------+-----+---------+----------+---------+
1 row in set (0.00 sec)

mysql> SET @@character_set_results=NULL;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from db_collation_id.tab_2byte_coll_id;
Segmentation fault 

This happens with 'SET @@character_set_results=NULL' and --column-type-info. Else works fine.

How to repeat:
As mentioned in the description.
[8 Oct 2009 10:51] Valeriy Kravchuk
Thank you for the problem report. Please, send the results of SHOW CREATE TABLE for this db_collation_id.tab_2byte_coll_id table.
[9 Nov 2009 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[24 Nov 2009 8:41] Nidhi Shrotriya
Could not reproduce this issue with mysql-5.1.41 (advanced build).

SHOW CREATE used was:
----------------------

CREATE DATABASE db_collation_id;
CREATE TABLE db_collation_id.tab_2byte_coll_id(c1 CHAR(1) CHARACTER SET ucs2 COLLATE ucs2_vn_ci);
INSERT INTO db_collation_id.tab_2byte_coll_id values (0x0061);

mysql> SHOW CREATE TABLE db_collation_id.tab_2byte_coll_id;
Field   1:  `Table`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  utf8_general_ci (33)
Length:     192
Max_length: 17
Decimals:   31
Flags:      NOT_NULL 

Field   2:  `Create Table`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  utf8_general_ci (33)
Length:     3072
Max_length: 139
Decimals:   31
Flags:      NOT_NULL 

+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
| Table             | Create Table                                                                                                                                |
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
| tab_2byte_coll_id | CREATE TABLE `tab_2byte_coll_id` (
  `c1` char(1) CHARACTER SET ucs2 COLLATE ucs2_vn_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
[5 Apr 2010 6:40] Nidhi Shrotriya
Issue is reproducible on Solaris (not reproducible on Linux) with 5.5.3-m3 server and 5.1.45 client. 
Steps to reproduce are same as mentioned in the bug.

Start 5.5.3-m3 server with --character-sets-dir=<Index.xml with 2 byte collation IDs>
Start 5.1.45 client as
bin/mysql --user=root --socket=/tmp/mysql.sock --column-type-info --table

and execute below stmts.

SHOW COLLATION LIKE 'utf8_test_ci';
drop database if exists db_collation_id;
create database db_collation_id;
CREATE TABLE db_collation_id.tab_2byte_coll_id2(c1 CHAR(1));
INSERT INTO db_collation_id.tab_2byte_coll_id2 VALUES ('a');
SET NAMES 'utf8' COLLATE 'utf8_test_ci';
SELECT * FROM db_collation_id.tab_2byte_coll_id2 ORDER BY c1;

Gives-
mysql> SELECT * FROM db_collation_id.tab_2byte_coll_id2 ORDER BY c1;
Bus Error (core dumped)

with same version mysql client (5.5.3-m3) works fine.
[6 Dec 2010 3:36] Nidhi Shrotriya
For sometime it was seen only on Solaris. It is seen (started appearing) again as earlier with 5.1.53 Linux too, so updating the OS field.