Bug #35615 Unable to insert values to a bit column if it is bound with SQL_C_CHAR
Submitted: 27 Mar 2008 15:42 Modified: 10 Dec 2008 15:04
Reporter: John Water Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.1.3-20080320 OS:Microsoft Windows (XP)
Assigned to: CPU Architecture:Any
Tags: bit, ODBC, SQL_C_CHAR
Triage: D3 (Medium)

[27 Mar 2008 15:42] John Water
Description:
With the 5.1.3 ODBC driver built on the 20th of March, 2008, the driver would complain
    Data too long for column 'column_name' at row row_number
when we were trying to insert a value of 1 into a bit column, if the parameter is bound using SQL_C_CHAR, shown as
    char c1[256];
    SQLINTEGER ind1 = 1;

    strcpy( c1, "1" );
    ret = SQLBindParameter( stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR,
	SQL_BIT, 1, 0, c1, 0, &ind1  );

By the way, the driver works well, if we bind the column with SQL_C_SLONG.

How to repeat:
A repro will be attached, odbcbug.zip and the zip file contains the source code for the repro and the executable file for Windows.  To run the repro, the command line would be
                  odbcbug "dsn=...;uid=...;pwd=..."
then you will see the error as
  error at line: 292
  SQLSTATE = HY000
  NATIVE ERROR = 1406
  MSG = [MySQL][ODBC 5.1 Driver][mysqld-5.1.22-rc-community]Data too long for column 'c1' at row 1

It works well, if you run the repro with the 3.5.20 MyODBC driver.
[28 Mar 2008 9:04] Tonci Grgin
Test case

Attachment: Bug35615.cpp (text/x-c++), 4.45 KiB.

[28 Mar 2008 9:06] Tonci Grgin
Hi John and thanks for your report.

You are right, only default conversions seems to be supported as per http://msdn2.microsoft.com/en-us/library/ms716298(VS.85).aspx.
[28 Mar 2008 9:08] Tonci Grgin
Hm, my mistake. Even though it might not be that obvious, this report is duplicate of Bug#30349 and Lawrin is working on fix right now.
[29 Mar 2008 20:09] Lawrenty Novitsky
BTW John, your test case works for me w/ 5.1.23 server, but doesn't with 5.0.*
(if you try "insert into test values(5,'1')" you will see it doesn't work w/ 5.0.*)
It's weird that 5.1.22 produces same error for you.
So, it may be also 5.0 server bug, but we will fix driver anyway.
[10 Dec 2008 15:04] John Water
Hi,

This bug still shows up with the 5.1 GA server and 5.1.5 ODBC driver.  Please try to run my repro against the 5.1 GA server and the 5.1.5 ODBC driver.  The server will complain with the following error:
[MySQL][ODBC 5.1 Driver][mysqld-5.1.30-community]Data too long for column 'c1' at row 1

Thanks,

John