Bug #74 stmt->fields contains wrong information
Submitted: 14 Feb 2003 8:15 Modified: 9 Jun 2003 18:40
Reporter: Georg Richter Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1 OS:Any (all)
Assigned to: Venu Anuganti CPU Architecture:Any

[14 Feb 2003 8:15] Georg Richter
Description:
Length and field (struct stmt->fields) contain wrong information.

How to repeat:
stmt = mysql_prepare(mysql, "SELECT @@autocommit");
mysql_execute(stmt);

stmt->fields[0] now contains the following information:

type = MYSQL_TYPE_LONGLONG
length = 1

Length should be sizeof(my_ulonglong) or type should be MYSQL_TYPE_STRING
[15 Feb 2003 15:27] Venu Anuganti
Thank you for taking the time to report a problem.  Unfortunately
you are not using a current version of the product your reported a
problem with -- the problem might already be fixed. Please download
a new version from http://www.mysql.com/downloads/

If you are able to reproduce the bug with one of the latest versions,
please change the version on this bug report to the version you
tested and change the status back to "Open".  Again, thank you for
your continued support of MySQL.

Hi !! 
 
As @@autocommit is a bit/bool flag, the length returned is 
always 1.  
 
I just added a test 'test_field_misc()' in client_test.c, 
for all misc cases to validate for all various members from 
MYSQL_FIELDS.  
 
Regarding the returned type, all these boolean variables 
are also returned with default MYSQL_TYPE_LONGLONG as the 
result type, I will cross check with 'monty', if we can 
make this to return other means, so that it can represent a 
char(1). 
 
Thanks for the report.
[15 Feb 2003 17:21] Georg Richter
Venu,

we should have definitely clear definitions:

It makes no sense if there are certain cases, where length is shorter than field_type.

Cause I don't know what the application will do or what type of query it is, I have to allocate the memory in 
ext/mysqli PHP-Extension via length in bind_result and convert it to the right type in mysql_fetch. This will definitely not work, when I try to convert 1 byte to longlong.