Bug #61830 MySQL 5.1.8. Connector not identifying VARCHAR type in views.
Submitted: 12 Jul 2011 8:51 Modified: 12 Jul 2011 9:29
Reporter: d f Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:MySQL Enterprise 5.5.9 OS:Any
Assigned to: Bogdan Degtyariov CPU Architecture:Any
Tags: MS Access, ODBC, SQL_C_BINARY

[12 Jul 2011 8:51] d f
Description:
What I am trying to do: Link / Import a view in MS Access 2003 / 2007.
What happens: Every char / varchar field is considered binary by MS Access.
What is the result: The char / varchar fields are shown as in Korean.
LOGS: The SQL.LOG example (Will beattached as .zip to the bug):
db4             17f8-1058	EXIT  SQLGetData  with return code 0 (SQL_SUCCESS)
		HSTMT               10EB1A48
		UWORD                        2 
		SWORD                       -2 <SQL_C_BINARY>
		PTR                 <unknown type>
		SQLLEN                   512
		SQLLEN *            0x0013C668 (3)

db4             17f8-1058	ENTER SQLFetch 
		HSTMT               10EB1A48

db4             17f8-1058	EXIT  SQLFetch  with return code 0 (SQL_SUCCESS)
		HSTMT               10EB1A48

The view is:
mysql> show create view borrame;
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| View    | Create View                                                                                                                                                                                 | character_set_client | collation_connection |
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| borrame | CREATE ALGORITHM=UNDEFINED DEFINER=`itx`@`%` SQL SECURITY DEFINER VIEW `borrame` AS select `animals`.`id` AS `id`,cast(`animals`.`name` as char(50) charset utf8) AS `Aname` from `animals` | utf8                 | utf8_general_ci      |
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
1 row in set (0.00 sec)
mysql> show full columns from borrame;
+-------+--------------+-----------------+------+-----+---------+-------+---------------------------------+---------+
| Field | Type         | Collation       | Null | Key | Default | Extra | Privileges                      | Comment |
+-------+--------------+-----------------+------+-----+---------+-------+---------------------------------+---------+
| id    | mediumint(9) | NULL            | NO   |     | 0       |       | select,insert,update,references |         |
| Aname | varchar(50)  | utf8_general_ci | YES  |     | NULL    |       | select,insert,update,references |         |
+-------+--------------+-----------------+------+-----+---------+-------+---------------------------------+---------+
2 rows in set (0.00 sec)

How to repeat:
Create a dtabase (latin1/latin1_swedish_ci):
CREATE TABLE animals (
 id MEDIUMINT NOT NULL AUTO_INCREMENT,
 name CHAR(30) NOT NULL,
 PRIMARY KEY (id)) DEFAULT CHARSET='latin1' COLLATE='latin1_bin';
INSERT INTO animals (name) VALUES ('dog'),('cat'),('penguin'),
 ('lax'),('whale'),('ostrich');

CREATE OR REPLACE VIEW borrame AS select id, name AS Aname from animals;

Open a msaccess database (2003/2007) and link the view borrame.

The Aname looks like Korean.
[12 Jul 2011 8:53] d f
SQL.LOG with the data from the connection

Attachment: SQL.zip (application/zip, text), 24.33 KiB.

[12 Jul 2011 9:08] d f
The wierd thing is that it works fine in Excel with the same conexión configuration:
[ODBC]
DRIVER=MySQL ODBC 5.1 Driver
UID=***
DFLT_BIGINT_BIND_STR=1
FOUND_ROWS=1
CHARSET=latin1
PORT=3307
DATABASE=intercon
SERVER=localhost
OPTION=3
PWD=******
STMT="SET CHARACTER SET latin1"
[12 Jul 2011 9:09] Bogdan Degtyariov
This is MySQL 5.5 server problem in MYSQL_LIST_FIELDS() function, which has been fixed in the source tree for version 5.5.15.

Connector/ODBC cannot workaround this server problem and you have to wait for the official release of MySQL 5.5.15 or build it from the sources.
[12 Jul 2011 9:29] d f
A questio: The 5.5.15 is the Enterprise Edition, right? When is the relase expected?

Thanks for the fast answer.