Bug #6911 resultset metadata always return client character set

Submitted: 1 Dec 2004 9:31 Modified: 14 Dec 2004 12:04
Reporter: Georg Richter Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.1.x and 5.0.x OS:Any (all)
Assigned to: Alexander Barkov CPU Architecture:Any

[1 Dec 2004 9:31] Georg Richter
Description:
When retrieving resultset metadata, charsetnr in fields always contain the client character set 
instead of the character set for the column in the database. 
 
This behaviour makes it impossible to determine the correct columnDisplaySize (a function which 
is used in most of the MySQL connectors). 
 
 
Output from test.c 
 
1st) with client character set utf8 
Charsetnr: 33 
CharsetName: utf8 
ColumnDisplaySize: 50 
 
2nd) with client character set latin1 
Charsetnr: 8 
CharsetName: latin1 
ColumnDisplaySize: 150 

How to repeat:
#include <my_global.h> 
#include <m_ctype.h> 
#include <mysql.h> 
#include <stdio.h> 
 
CHARSET_INFO *get_charset(uint, myf); 
 
main() { 
	MYSQL		*mysql; 
	MYSQL_RES	*result; 
	CHARSET_INFO *cs; 
 
	mysql = mysql_init(NULL); 
 
	mysql_real_connect(mysql, "localhost", "root", "", "test", 0, NULL, 0); 
 
	mysql_query(mysql, "DROP TABLE IF EXISTS t3"); 
	mysql_query(mysql, "CREATE TABLE t3 (a varchar(50) character set utf8)"); 
 
	mysql_query(mysql, "SELECT a FROM t3 WHERE 0=1"); 
	result = mysql_store_result(mysql); 
 
	cs = get_charset(result->fields[0].charsetnr, 0); 
 
	printf("Charsetnr: %d\n", result->fields[0].charsetnr); 
	printf("CharsetName: %s\n", cs->csname); 
	printf("ColumnDisplaySize: %d\n", result->fields[0].length / cs->mbmaxlen); 
 
	mysql_free_result(result); 
	mysql_close(mysql);     
}
[14 Dec 2004 12:04] 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

Additional info:

Fixed in 4.1.8

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.038 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.