pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Conversion problem with unsigned long in psqlodbc-7.3.2
2+ messages / 2 participants
[nested] [flat]

* Conversion problem with unsigned long in psqlodbc-7.3.2
@ 2003-12-03 14:31 Ruud Overeem <overeem@astron.nl>
  2003-12-19 14:41 ` Re: Conversion problem with unsigned long in psqlodbc-7.3.2 Hiroshi Inoue <inoue@tpf.co.jp>
  0 siblings, 1 reply; 2+ messages in thread

From: Ruud Overeem @ 2003-12-03 14:31 UTC (permalink / raw)
  To: pgsql-odbc; +Cc: Ger van Diepen <diepen@astron.nl>; Marcel Loose <loose@astron.nl>

Hi,

We just installed version 7.3.2 of the postgres ODBC driver on a RedHat
9.0 system. When testing the limits all the variable-types it appeared
that unsigned long values are stored correct in the database but we they
are read back we hit the LONG_MAX range.

E.g. assign the value 2345678901 to an unsigned long, write that to the
database and read it back. The database contains 2345678901 but the
unsigned long variable is set to LONG_MAX (2147483647).

Digging into the sources I think I found the problem. In convert.c at
line 1184 the code says:
case SQL_C_ULONG:
    len = 4;
    if (bind_size > 0)
        *((UDWORD *) rgbValueBindRow) = atol(neut_str);
    else
        *((UDWORD *) rgbValue + bind_row) = atol(neut_str);
    break;

The function atol only works for signed long integers. When you replace
'atol(neut_str)' with 'strtoul(neut_str, 0 , 10)' it works fine.


With kind Regards,


Ruud Overeem
Astron



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Conversion problem with unsigned long in psqlodbc-7.3.2
  2003-12-03 14:31 Conversion problem with unsigned long in psqlodbc-7.3.2 Ruud Overeem <overeem@astron.nl>
@ 2003-12-19 14:41 ` Hiroshi Inoue <inoue@tpf.co.jp>
  0 siblings, 0 replies; 2+ messages in thread

From: Hiroshi Inoue @ 2003-12-19 14:41 UTC (permalink / raw)
  To: 'Ruud Overeem' <overeem@astron.nl>; +Cc: 'Ger van Diepen' <diepen@astron.nl>; 'Marcel Loose' <loose@astron.nl>; pgsql-odbc

> -----Original Message-----
> From: Ruud Overeem
> 
> Hi,
> 
> We just installed version 7.3.2 of the postgres ODBC driver 
> on a RedHat
> 9.0 system. When testing the limits all the variable-types it appeared
> that unsigned long values are stored correct in the database 
> but we they
> are read back we hit the LONG_MAX range.
> 
> E.g. assign the value 2345678901 to an unsigned long, write 
> that to the
> database and read it back. The database contains 2345678901 but the
> unsigned long variable is set to LONG_MAX (2147483647).
> 
> Digging into the sources I think I found the problem. In convert.c at
> line 1184 the code says:
> case SQL_C_ULONG:
>     len = 4;
>     if (bind_size > 0)
>         *((UDWORD *) rgbValueBindRow) = atol(neut_str);
>     else
>         *((UDWORD *) rgbValue + bind_row) = atol(neut_str);
>     break;
> 
> The function atol only works for signed long integers. When 
> you replace
> 'atol(neut_str)' with 'strtoul(neut_str, 0 , 10)' it works fine.

I would take care of it.
Thanks.

Hiroshi Inoue




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-12-19 14:41 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-12-03 14:31 Conversion problem with unsigned long in psqlodbc-7.3.2 Ruud Overeem <overeem@astron.nl>
2003-12-19 14:41 ` Hiroshi Inoue <inoue@tpf.co.jp>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox