Bug #34052 Patch http://lists.mysql.com/commits/37203 for Bug#27959 needs better docs.
Submitted: 25 Jan 2008 10:09 Modified: 15 Jul 2008 18:10
Reporter: Tonci Grgin
Status: Closed
Category:Connector/Net: Docs Severity:S2 (Serious)
Version: OS:Any
Assigned to: MC Brown Target Version:
Triage: D4 (Minor) / R3 (Medium) / E3 (Medium)

[25 Jan 2008 10:09] Tonci Grgin
Description:
Looking into patch source one can see a problem as reporter described in last comment in
Bug#27959: "GetValue() on a field tinyint(1) returning a Boolean is causing a bug in our
software where we expect an int object returned."

Part of patch:
         public IMySqlValue GetValueObject()
         {
-            return GetIMySqlValue(Type);
+            IMySqlValue v = GetIMySqlValue(Type);
+            if (v is MySqlByte && ColumnLength == 1)
+            {
+                MySqlByte b = (MySqlByte)v;
+                b.TreatAsBoolean = true;
+                v = b;
+            }
+            return v;
         }

How to repeat:
mysql> CREATE TABLE bug27959 (f_bool BOOLEAN);
Query OK, 0 rows affected (0.09 sec)

mysql> SHOW CREATE TABLE bug27959\G
*************************** 1. row ***************************
       Table: bug27959
Create Table: CREATE TABLE `bug27959` (
  `f_bool` tinyint(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

and

mysql> CREATE TABLE bug27959_1 (f_tint TINYINT(1));
Query OK, 0 rows affected (0.05 sec)

mysql> SHOW CREATE TABLE bug27959_1\G
*************************** 1. row ***************************
       Table: bug27959_1
Create Table: CREATE TABLE `bug27959_1` (
  `f_tint` tinyint(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

Suggested fix:
Please modify the patch and/or add a note to manual that TINYINT fields should be defined
at least as TINYINT(2) so not to be treated as BOOLEAN fields (explicitly).
[25 Jan 2008 10:21] Tonci Grgin
After considering http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html I've
decided that it would be enough for MC to add link from c/NET pages to the above one
along with previously proposed text. Changing the synopsis.
[6 Feb 2008 19:29] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/41806
[6 Feb 2008 19:30] Reggie Burnett
Fixed in 5.1.5 and 5.2+
[15 Jul 2008 18:10] Tony Bedford
The .NET connector documentation has been updated to include the new 'Treat Tiny As
Boolean' connection string option.

An entry has also been added to the 5.1.5 and 5.2.0 changelogs:

Performing GetValue() on a field TINYINT(1) returned a BOOLEAN. While not a bug, this
caused problems in software that expected an INT to be returned. A new connection string
option Treat Tiny As Boolean has been added with a default value of true. If set to false
the provider will treat TINYINT(1) as INT.