Bug #26216 Binding of TINYINT type of column fails
Submitted: 9 Feb 2007 8:38 Modified: 22 Feb 2007 8:38
Reporter: Mikko metsola Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:Beta 5.00.11 OS:Windows (Win XP)
Assigned to: CPU Architecture:Any

[9 Feb 2007 8:38] Mikko metsola
Description:
pf              17b4-15b8	ENTER SQLBindParameter 
		HSTMT               003C2048
		UWORD                        5 
		SWORD                        1 <SQL_PARAM_INPUT>
		SWORD                       -6 <SQL_C_TINYINT>
		SWORD                       -6 <SQL_TINYINT>
		SQLULEN                    0
		SWORD                        0 
		PTR                0x003A5CE8
		SQLLEN                     2
		SQLLEN *            0x0012ED48

pf              17b4-15b8	EXIT  SQLBindParameter  with return code -1 (SQL_ERROR)
		HSTMT               003C2048
		UWORD                        5 
		SWORD                        1 <SQL_PARAM_INPUT>
		SWORD                       -6 <SQL_C_TINYINT>
		SWORD                       -6 <SQL_TINYINT>
		SQLULEN                    0
		SWORD                        0 
		PTR                0x003A5CE8
		SQLLEN                     2
		SQLLEN *            0x0012ED48

		DIAG [S1092] [MySQL][MyODBC 5.00.10] Option type out of range (0) 

How to repeat:
 SQLBindParameter(
    SQLHSTMT           hstmt,
    SQLUSMALLINT       ipar,
    SQLSMALLINT        fParamType,
    SQLSMALLINT        fCType,
    SQLSMALLINT        fSqlType,
    SQLULEN            cbColDef,
    SQLSMALLINT        ibScale,
    SQLPOINTER         rgbValue,
    SQLLEN             cbValueMax,
    SQLLEN     		   *pcbValue);

with

fCType = SQL_C_TINYINT
fSqlType = SQL_TINYINT

Suggested fix:
See fault http://bugs.mysql.com/bug.php?id=24920
[13 Feb 2007 7:22] Tonci Grgin
Hi and thanks for contacting us.

I have two problems with your report:
 - There is no test case
 - You are using wrong types

What happens with your test case if you try to use SQL_C_STINYINT or SQL_C_UTINYINT as in
http://msdn2.microsoft.com/en-us/library/ms714556.aspx?
[14 Feb 2007 8:13] Mikko metsola
Yes,

I want be able to use a signed tinyint type of column with -128 <= value <= 127.

So I am trying to INSERT a tinytint value to a tinyint colummn, i.e. trying to bind "TINYINT" column with sql_ctype SQL_C_TINYINT, sqltype SQL_TINYINT, and value 127 

as follows:

SQLBindParameter( stmtHandle,columnIndex, SQL_PARAM_INPUT, SQL_C_TINYINT, SQL_TINYINT, 0, 0, value, 2, SQL_NTS);

With SQL_C_TINYINT - SQL_TINYINT binding
i get an error message 'option type out of range'. That combination works with 3.51.12 driver.

With SQL_C_STINYINT - SQL_TINYINT binding is successful, but SQLExecute( stmtHandle ) returns syntax error because the INSERT value for TINYINT column has been left empty.

insert into <schema>.InsertTable values ('2007-02-14 07:51:58',2388641,'3584147483650','3584147083647',<EMPTY_VALUE_HERE = should be 127>,-2147483648,47483648,...,...

So which SQL C type and SQL type combination should I use for binding a signed TINYINT column in 5.0 driver?

rgds, 

MMe
[14 Feb 2007 14:10] Mikko metsola
I was able to bind with SQL_C_SSHORT - SQL_SMALLINT pair for a TINYINT column.

But I've not been able to find a matching TINYINT pair for binding..
[15 Feb 2007 7:27] Mikko metsola
For SQL_C_TINYINT - SQL_TINYINT, 5.00.11 connector Bind returns:

retCode: -1
Sql state: HY092
errorMsg: "[MySQL][MyODBC 5.00.11] Invalid attribute/option identifier"
[15 Feb 2007 15:52] Jess Balint
The following combinations have been tested, and meet the spec:

/* tinyint */
SQLBindParameter(stmt, paramNum, SQL_PARAM_INPUT, SQL_C_STINYINT, SQL_TINYINT, 0, 0, &value, 0, NULL)
/* utinyint */
SQLBindParameter(stmt, paramNum, SQL_PARAM_INPUT, SQL_C_UTINYINT, SQL_TINYINT, 0, 0, &value, 0, NULL)

What type is value? Please confirm that it matches the type you specified:
http://msdn2.microsoft.com/en-us/library/ms714556.aspx
[19 Feb 2007 15:47] Tonci Grgin
We're sorry, but the bug system is not the appropriate forum for asking help on using MySQL products. Your problem is not the result of a bug.

Support on using our products is available both free in our forums at http://forums.mysql.com/ and for a reasonable fee direct from our skilled support engineers at http://www.mysql.com/support/

Thank you for your interest in MySQL.

Explanation: I am sorry but we are unable to help you unless you provide us with complete test case as aked before. When you provide all that's requested, please reopen the report.