pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
FORMAT_INTEGER is wrong on (some) 64 bit platforms?
4+ messages / 3 participants
[nested] [flat]

* FORMAT_INTEGER is wrong on (some) 64 bit platforms?
@ 2013-07-23 18:32 Matt Lilley <matt.lilley@securitease.com>
  2013-07-24 03:22 ` Re: FORMAT_INTEGER is wrong on (some) 64 bit platforms? Inoue, Hiroshi <inoue@tpf.co.jp>
  0 siblings, 1 reply; 4+ messages in thread

From: Matt Lilley @ 2013-07-23 18:32 UTC (permalink / raw)
  To: pgsql-odbc

Hello,

I'm trying to understand the logic in psqlodbc.h where if the size of a 
long int is not 8 that FORMAT_INTEGER is set to "%ld". I can't find any 
definitive documentation, but I gather from various forum posts that the 
size of SQL_C_LONG is always intended to be 4 bytes, independent of the 
host architecture. (This exact issue was first reported 9 years ago, it 
seems [1]). I don't think it should matter what size long int is on the 
host: surely it should only matter what the type being passed into 
SQLBindParameter is given as, since the data is packed by the caller, 
not the callee. My initial instinct was just to change the macro from 
"%ld" to "%d" (and similarly, "%lu" to "%u" for FORMAT_UINTEGER), but 
since there is quite a bit of code in there trying to make sense of it, 
I thought I'd check here.

FWIW, I got here by trying to bind an integer column to -1 and getting 
an out-of-range error, just like Kelly in [1]. Changing the %ld -> %d 
fixes the symptoms for me. Is there any reason this can't be fixed?

Regards,
Matt

[1] http://www.postgresql.org/message-id/4224F80D.2080103@kkcsm.net

-- 
_____________________________________________
Matt Lilley
Software Engineer
SecuritEase

Tel:    +64 4 912-2100
Fax:    +64 4 912-2101
E-mail: matt.lilley@securitease.com
Web:    http://www.securitease.com
_____________________________________________

This e-mail has passed our content security scan.
It is covered by the confidentiality clauses at http://www.securitease.com/content_and_confidentiality



-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



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

* Re: FORMAT_INTEGER is wrong on (some) 64 bit platforms?
  2013-07-23 18:32 FORMAT_INTEGER is wrong on (some) 64 bit platforms? Matt Lilley <matt.lilley@securitease.com>
@ 2013-07-24 03:22 ` Inoue, Hiroshi <inoue@tpf.co.jp>
  2013-07-24 14:37   ` Re: FORMAT_INTEGER is wrong on (some) 64 bit platforms? Matt Lilley <matt.lilley@securitease.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Inoue, Hiroshi @ 2013-07-24 03:22 UTC (permalink / raw)
  To: Matt Lilley <matt.lilley@securitease.com>; +Cc: pgsql-odbc

Hi Matt,

(2013/07/24 3:32), Matt Lilley wrote:
> Hello,
>
> I'm trying to understand the logic in psqlodbc.h where if the size of a
> long int is not 8 that FORMAT_INTEGER is set to "%ld".

Is the version 9.02.0100?
Does replacing SIZEOF_LONG_INT by SIZEOF_LONG work?

regards,
Hiroshi Inoue

 > I can't find any
> definitive documentation, but I gather from various forum posts that the
> size of SQL_C_LONG is always intended to be 4 bytes, independent of the
> host architecture. (This exact issue was first reported 9 years ago, it
> seems [1]). I don't think it should matter what size long int is on the
> host: surely it should only matter what the type being passed into
> SQLBindParameter is given as, since the data is packed by the caller,
> not the callee. My initial instinct was just to change the macro from
> "%ld" to "%d" (and similarly, "%lu" to "%u" for FORMAT_UINTEGER), but
> since there is quite a bit of code in there trying to make sense of it,
> I thought I'd check here.
>
> FWIW, I got here by trying to bind an integer column to -1 and getting
> an out-of-range error, just like Kelly in [1]. Changing the %ld -> %d
> fixes the symptoms for me. Is there any reason this can't be fixed?
>
> Regards,
> Matt




-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



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

* Re: FORMAT_INTEGER is wrong on (some) 64 bit platforms?
  2013-07-23 18:32 FORMAT_INTEGER is wrong on (some) 64 bit platforms? Matt Lilley <matt.lilley@securitease.com>
  2013-07-24 03:22 ` Re: FORMAT_INTEGER is wrong on (some) 64 bit platforms? Inoue, Hiroshi <inoue@tpf.co.jp>
@ 2013-07-24 14:37   ` Matt Lilley <matt.lilley@securitease.com>
  2013-07-24 14:57     ` Re: FORMAT_INTEGER is wrong on (some) 64 bit platforms? Hiroshi Inoue <inoue@tpf.co.jp>
  0 siblings, 1 reply; 4+ messages in thread

From: Matt Lilley @ 2013-07-24 14:37 UTC (permalink / raw)
  To: Inoue, Hiroshi <inoue@tpf.co.jp>; +Cc: pgsql-odbc


On 24/07/13 3:22 PM, Inoue, Hiroshi wrote:
> Hi Matt,
>
> (2013/07/24 3:32), Matt Lilley wrote:
>> Hello,
>>
>> I'm trying to understand the logic in psqlodbc.h where if the size of a
>> long int is not 8 that FORMAT_INTEGER is set to "%ld".
>
> Is the version 9.02.0100?
Yes. Tip of master.
> Does replacing SIZEOF_LONG_INT by SIZEOF_LONG work?
Yes. Then I get the first branch, which has "%d" and "%u".

Regards,
Matt
>
> regards,
> Hiroshi Inoue
>
> > I can't find any
>> definitive documentation, but I gather from various forum posts that the
>> size of SQL_C_LONG is always intended to be 4 bytes, independent of the
>> host architecture. (This exact issue was first reported 9 years ago, it
>> seems [1]). I don't think it should matter what size long int is on the
>> host: surely it should only matter what the type being passed into
>> SQLBindParameter is given as, since the data is packed by the caller,
>> not the callee. My initial instinct was just to change the macro from
>> "%ld" to "%d" (and similarly, "%lu" to "%u" for FORMAT_UINTEGER), but
>> since there is quite a bit of code in there trying to make sense of it,
>> I thought I'd check here.
>>
>> FWIW, I got here by trying to bind an integer column to -1 and getting
>> an out-of-range error, just like Kelly in [1]. Changing the %ld -> %d
>> fixes the symptoms for me. Is there any reason this can't be fixed?
>>
>> Regards,
>> Matt
>
>

-- 
_____________________________________________
Matt Lilley
Software Engineer
SecuritEase

Tel:    +64 4 912-2100
Fax:    +64 4 912-2101
E-mail: matt.lilley@securitease.com
Web:    http://www.securitease.com
_____________________________________________

This e-mail has passed our content security scan.
It is covered by the confidentiality clauses at http://www.securitease.com/content_and_confidentiality



-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



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

* Re: FORMAT_INTEGER is wrong on (some) 64 bit platforms?
  2013-07-23 18:32 FORMAT_INTEGER is wrong on (some) 64 bit platforms? Matt Lilley <matt.lilley@securitease.com>
  2013-07-24 03:22 ` Re: FORMAT_INTEGER is wrong on (some) 64 bit platforms? Inoue, Hiroshi <inoue@tpf.co.jp>
  2013-07-24 14:37   ` Re: FORMAT_INTEGER is wrong on (some) 64 bit platforms? Matt Lilley <matt.lilley@securitease.com>
@ 2013-07-24 14:57     ` Hiroshi Inoue <inoue@tpf.co.jp>
  0 siblings, 0 replies; 4+ messages in thread

From: Hiroshi Inoue @ 2013-07-24 14:57 UTC (permalink / raw)
  To: Matt Lilley <matt.lilley@securitease.com>; +Cc: pgsql-odbc

(2013/07/24 23:37), Matt Lilley wrote:
>
> On 24/07/13 3:22 PM, Inoue, Hiroshi wrote:
>> Hi Matt,
>>
>> (2013/07/24 3:32), Matt Lilley wrote:
>>> Hello,
>>>
>>> I'm trying to understand the logic in psqlodbc.h where if the size of a
>>> long int is not 8 that FORMAT_INTEGER is set to "%ld".
>>
>> Is the version 9.02.0100?
> Yes. Tip of master.
>> Does replacing SIZEOF_LONG_INT by SIZEOF_LONG work?
> Yes. Then I get the first branch, which has "%d" and "%u".

Hmm 9.02.0100 seems to have introduced the bug.
What configure is checking is SIZEOF_LONG not SIZEOF_LONG_INT.

regards,
Hiroshi Inoue



-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



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


end of thread, other threads:[~2013-07-24 14:57 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-07-23 18:32 FORMAT_INTEGER is wrong on (some) 64 bit platforms? Matt Lilley <matt.lilley@securitease.com>
2013-07-24 03:22 ` Inoue, Hiroshi <inoue@tpf.co.jp>
2013-07-24 14:37   ` Matt Lilley <matt.lilley@securitease.com>
2013-07-24 14:57     ` 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