Bug #46359 BOOLEAN not recognized
Submitted: 24 Jul 2009 3:37 Modified: 24 Jul 2009 6:25
Reporter: qdyoung qdyoung Email Updates:
Status: Duplicate Impact on me:
Category:Connector / NET Severity:S2 (Serious)
Version:6.0.4 OS:Microsoft Windows
Assigned to: CPU Architecture:Any

[24 Jul 2009 3:37] qdyoung qdyoung
Mysql bool type recognize as sbyte, 5.2.3 ok, not correct since 5.2.4。

How to repeat:
create table testTable ( a bool not null);
insert into testTable ( a ) values ( false );

MySqlCommand command=new MySqlCommand("SELECT a FROM testTable", connection);
DataSet dataSet=new DataSet();

will output sbyte, not bool。

When database charset is not DBCS, no problem; database charset is gbk, has problem.

Suggested fix:
Field.cs class MySqlField, method SetTypeAndFlags, before the end
v5.2.4 add codes:
  if (CharacterSetIndex==63)
    CharacterSetIndex = connection.driver.ConnectionCharSetIndex;

So bool type field CharacterSetIndex change to 28, CharacterSet is "gb2312", which MaxLengh=2.

In method GetValueObject:
  if (...&& this.MaxLength == 1)
     b.TreatAsBoolean = true;

Because this.MaxLength=2, so TreatAsBoolean is false, then field value type is not changed from sbyte to bool.
[24 Jul 2009 6:25] Tonci Grgin
Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Because of this, we hope you add your comments to the original bug instead.

Thank you for your interest in MySQL.

Explanation: This is a duplicate of verified Bug#46205 and several other reports (Bug#41953 for example). Please search bugsdb before posting report.