[unixODBC-support] SQLINTEGER

Nick Gorham nick.gorham at easysoft.com
Mon Jun 2 10:08:43 BST 2008

Suren A. Chilingaryan wrote:

>Dear developers,
>There is some mess with SQLINTEGER definition. MSDN
>(http://msdn.microsoft.com/en-us/library/ms714556.aspx) defines
>SQLINTEGER to be 'long int'. The unixODBC defines it just 'int' (in
>sqltypes.h). This cause a lot of troubles on 64bit platforms. Most of
>applications expect to see the 64bit 'long int' number and got 32-bit
>'int' instead.
>As one of the examples of problems: the PDO_ODBC driver in PHP 5.2.x
>will end up with segmentation fault while accessing NULL columns over
>unixODBC-support mailing list
>unixODBC-support at easysoft.com
Yep, and if you check, you will find that on windows sizeof(long int) == 
32 so the *nix equivilant would be incorrect if it was a 64 bit type, 
there is a seperate 64 bit type in ODBC for this.

I suspect from your description, you are talking about the definition of 
a indicator variable (given you mention NULL), and thats a different 
thing, the type should be defined as a SQLLEN, and then you can choose 
what length you want to use with that. Have a look in the archives for 
several descrriptions of SQLLEN issues.

2.2.13pre will be out soon (if people could test the existing snapshot 
and report it woild make my life a lot simpiler) and that will default 
to sizeof( SQLLEN ) == 64 on 64 bit platforms, but there will still be 
problems with apps and drivers that expect 32, so its not a problem 
thats going to go away just yet.

Nick Gorham
Easysoft Limited
http://www.easysoft.com, http://www.unixODBC.org

More information about the unixODBC-support mailing list