Bug #66235 MySQL_ResultSet::getString() returns bad value for BIT data
Submitted: 7 Aug 2012 3:56 Modified: 2 Feb 2015 16:26
Reporter: Alfredo Kojima Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / C++ Severity:S3 (Non-critical)
Version:1.1.0 OS:Any
Assigned to: Hemant Dangi CPU Architecture:Any

[7 Aug 2012 3:56] Alfredo Kojima
Description:
getString() on resultset of SELECT max(bit_field) FROM table_with_bit_field will yield wrong result

How to repeat:
As per bug #63457:

1. Create a table with a BIT field:

CREATE TABLE t(b BIT NOT NULL DEFAULT 0);

2. Insert some data into the table:

INSERT INTO t(b) VALUES(1), (0), (1), (1), (0), (0);

3. Perform a SELECT with a MAX aggregation function over the BIT field:

SELECT MAX(b) FROM t;

The result of a getString() on the resultset returns various values that are not 1 or 0.
[23 Apr 2013 21:13] Lawrenty Novitsky
btw, should really getString for bit field return '0' or '1'? what for bit(n>1) fields? ...
[23 Jan 2015 9:22] Hemant Dangi
Conversion in getString() and getInt() from bit to integer can be skipped, in
case of aggregate functions (MAX() here) as they are already returning values
as unsigned binary.
Committed revision 1024 in C/C++ 1.1.6.
[2 Feb 2015 16:26] Paul DuBois
Noted in 1.1.6 changelog.

For queries of the form SELECT MAX(bit_col) FROM table_with_bit_col,
getString() returned an incorrect result.