[unixODBC-dev] SQL_C integer sizes in 64-bit Linux

Kelly Burkhart pgkrb at kkcsm.net
Wed Mar 2 20:20:13 GMT 2005


Eric Sharkey wrote:
<snip>
 >
> If the PostgreSQL driver has taken this table literally, then
> I think that's something you need to bring up with the authors of that
> driver, but I don't you're correct here.  As far as I can tell,
> in the PostgreSQL driver, SQL_C_SLONG maps to a 4 byte int.
> 
> For example, see this in convert.c:
> 
>       case SQL_C_SLONG:
>       case SQL_C_LONG:
>               len = 4;
>               if (bind_size > 0)
>                       *((SDWORD *) rgbValueBindRow) = atol(neut_str);
>               else
>                       *((SDWORD *) rgbValue + bind_row) = atol(neut_str);
>               break;
> 
> An SDWORD isn't always a long:
> 
> #if (SIZEOF_LONG == 4)
> typedef long int                SDWORD;
> typedef unsigned long int       UDWORD;
> #else
> typedef int                     SDWORD;
> typedef unsigned int            UDWORD;
> #endif

Thanks Eric.

The problem I'm seeing is elsewhere in convert.c in 
copy_statement_with_parameters:

		case SQL_C_SLONG:
		case SQL_C_LONG:
			sprintf(param_string, "%ld",
				*((SDWORD *) buffer));
			break;

The "%ld" format string will expect a 64 bit argument on a 64 bit platform.

A fix seems fairly straightforward; do the authors of this driver 
monitor this list?



More information about the unixODBC-dev mailing list