Bug #14140 libmysqld returns column type NEWDECIMAL
Submitted: 19 Oct 2005 13:29 Modified: 19 Apr 2006 16:59
Reporter: Peter Schäfer Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.0.16, nightly build 20051017 OS:Any (*)
Assigned to: Paul DuBois CPU Architecture:Any

[19 Oct 2005 13:29] Peter Schäfer
Description:
I'm using the Embedded Library, version 5.0.16 on Windows and Mac OS X. 

Prepared Statements with aggregate functions return buffers with type 246 (MYSQL_TYPE_NEWDECIMAL).

Unfortunately, this type is undocumented and I have no idea how to decode the returned values in my client program.

How to repeat:
CREATE TABLE Test (a int)
INSERT INTO Test (a) VALUES (1),(2),(3)

 MYSQL_STMT* statement;
 MYSQL_BIND* result;

 mysql_stmt_prepare(statement,"SELECT a FROM Test");
 mysql_stmt_execute(statement);
 mysql_stmt_store_result(statement);
 mysql_stmt_bind_result(statement,result);
                
-- alright:  result[0].buffer_type = 3 (MYSQL_TYPE_LONG)

 mysql_stmt_prepare(statement,"SELECT SUM(a) FROM Test");

-- wrong: result[0].buffer_type = 246 (MYSQL_TYPE_NEWDECIMAL)

Suggested fix:
* return the appropriate data type
* add documentation how to handle NEWDECIMAL return values
[20 Oct 2005 7:13] Peter Schäfer
I found out  that the NEWDECIMAL return values are simply strings,
so I can live with it :-)

down-graded the bug to "non-critical"
[3 Feb 2006 14:14] Hartmut Holzgraefe
couldn't find any format specification for this in the current docs either
[19 Apr 2006 16:59] Paul DuBois
Thank you for your bug report. This issue has been addressed in the
documentation. The updated documentation will appear on our website
shortly, and will be included in the next release of the relevant
product(s).

Additional info:

I've added MYSQL_TYPE_NEWDECIMAL to the table at:

http://dev.mysql.com/doc/refman/5.0/en/c-api-prepared-statement-datatypes.html

and included some remarks about data conversions.