Bug #43023 On big endian system (power arch with mono), tinyint(4) is converted to Boolean
Submitted: 19 Feb 2009 15:08 Modified: 16 Mar 2009 17:42
Reporter: Arthur Valadares Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:5.2.5.0 OS:Linux
Assigned to: CPU Architecture:Any
Tags: tinyint boolean endian power ppc

[19 Feb 2009 15:08] Arthur Valadares
Description:
Environment: Using the MySQL Connector on mono in a ppc64 (big endian) architecture

Issue: When saving a byte value to a tinyint(4) column on a table, the data gets saved right but when retrieving the data with IDataReader, it always comes back as a boolean. 

How to repeat:
Take this example code from mono:
http://www.mono-project.com/MySQL

Add an extra column test tinyint(4), store a byte value there (byte test = 4), retrieve it with IDataReader and check it's value and type. It will show as a Boolean and it is True

Suggested fix:
Check for big endian related issues, as this does not happen to x86
[19 Feb 2009 15:21] Arthur Valadares
Changing to MySQL Connector/Net
[19 Feb 2009 19:46] Arthur Valadares
Added version info
[20 Feb 2009 17:30] Arthur Valadares
New update: Made sure that this is a connector issue. I started a MySQL server on an X machine, and I'm still having trouble retrieving the tinyint(4) value. 

It's still coming as 1 on PPC64, and as the right number (on my test, 4) on a x86 machine.
[21 Feb 2009 6:54] Sveta Smirnova
Thank you for the report.

> Add an extra column test tinyint(4), store a byte value there (byte test = 4),

Please provide byte value you store, i.e. exact INSERT statement you use to store a byte value.
[23 Feb 2009 13:33] Arthur Valadares
Hi Sveta, thanks for the support..

Assuming I'm using a table called testme with one column called test which is a tinyint(4), I insert it like this:
insert into testme(test) values (4);
[23 Feb 2009 13:39] Arthur Valadares
I thought I should make this clear, because I ruled out the possibility of storing the value wrong after I posted this bug. On my original code I was storing the value using:
byte test = 4;

then creating a insert MySqlCommand c and executing c.ExecuteNonQuery()

I thought this could be the problem as well, but as I mentioned on my last post, even if I create a value in tinyint using Insert Into it still fails to retrieve the right value.
[26 Feb 2009 14:17] Arthur Valadares
I'm raising the priority on this one, as I this is a blocking issue for my application.
[4 Mar 2009 9:37] Tonci Grgin
Arthur, this is not a common platform so that we can test quickly. So far, a colleague of mine confirmed there is no such problem with C API test case. Now I have to find a matching box that I'm allowed to put mono and driver to...
[4 Mar 2009 9:42] Tonci Grgin
Arthur, what happens if you add Treat Tiny As Boolean=false to your connection string?

  - Added connection string option 'Treat Tiny As Boolean' so applications that expect TINYINT(1) to return an integer will not break (bug #34052)
[4 Mar 2009 11:48] Arthur Valadares
Tonci, have you tried this on another big endian architecture, if you have any available? 

I just tried that option you sent, it just converts True to 1, but the value I had was actually 4, so no luck.
[16 Mar 2009 17:06] Arthur Valadares
This seemed to be a mono issue. Current 2.4 version of mono solves the problem.
Thank you for the support!
[16 Mar 2009 17:42] Tonci Grgin
Arthur, I must say I'm relieved.

Thanks for your interest in MySQL.