Lists: | pgsql-hackerspgsql-hackers-win32 |
---|
From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Nicolai Tufar <ntufar(at)gmail(dot)com> |
Cc: | Magnus Hagander <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org, pgsql-hackers-win32(at)postgresql(dot)org |
Subject: | Re: snprintf causes regression tests to fail |
Date: | 2005-03-01 04:54:42 |
Message-ID: | 200503010454.j214sg524406@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-hackers-win32 |
Nicolai Tufar wrote:
> Regression test diff is attached.
> It fails on the following tests:
> int8
> subselect
> union
> sequence
>
> It fails to display correctly number "4567890123456789".
> In output is shows "-869367531". Apparent overflow or
> interpreting int8 as int4.
>
> while rewriting snprintf() I did not touch the actual functions
> that convert number to ASCII digit string. In truth, if you
> force PostgreSQL to use snprintf.c without my patch applied
> it produces the same errors.
>
> What can be wrong? GCC bug? The one I use is:
> gcc.exe (GCC) 3.3.1 (mingw special 20030804-1)
I can confirm your failure in current sources on Win32:
template1=# create table test(x int8);
CREATE TABLE
template1=# insert into test values ('4567890123456789');
INSERT 17235 1
template1=# select * from test;
x
------------
-869367531
(1 row)
and it knows it is a large number:
template1=# select * from test where x > 1000::int8;
x
------------
-869367531
(1 row)
template1=# select * from test where x < 1000::int8;
x
---
(0 rows)
I am going to add some debugs to see what is being passed to *printf().
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
Cc: | Nicolai Tufar <ntufar(at)gmail(dot)com>, Magnus Hagander <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org, pgsql-hackers-win32(at)postgresql(dot)org |
Subject: | Re: snprintf causes regression tests to fail |
Date: | 2005-03-01 05:55:20 |
Message-ID: | 200503010555.j215tKk00448@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-hackers-win32 |
Bruce Momjian wrote:
> I can confirm your failure in current sources on Win32:
>
> template1=# create table test(x int8);
> CREATE TABLE
> template1=# insert into test values ('4567890123456789');
> INSERT 17235 1
> template1=# select * from test;
> x
> ------------
> -869367531
> (1 row)
>
> and it knows it is a large number:
>
> template1=# select * from test where x > 1000::int8;
> x
> ------------
> -869367531
> (1 row)
> template1=# select * from test where x < 1000::int8;
> x
> ---
> (0 rows)
>
> I am going to add some debugs to see what is being passed to *printf().
I have not found the solution yet but am heading to bed. My next guess
is that Win32 isn't handling va_arg(..., long long int) properly.
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From: | Nicolai Tufar <ntufar(at)gmail(dot)com> |
---|---|
To: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
Cc: | Magnus Hagander <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org, pgsql-hackers-win32(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: [pgsql-hackers-win32] snprintf causes regression tests to fail |
Date: | 2005-03-01 14:22:05 |
Message-ID: | d809293905030106226dd66151@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-hackers-win32 |
On Tue, 1 Mar 2005 00:55:20 -0500 (EST), Bruce Momjian
> My next guess
> is that Win32 isn't handling va_arg(..., long long int) properly.
>
I am trying various combination of number and types
of parameters in my test program and everything prints fine.
When it comes to pg, it fails :(
> > template1=# select * from test where x > 1000::int8;
> > x
> > ------------
> > -869367531
> > (1 row)
I am not too fluent in source code, could someone
point me to there actual call to snprintf() is being done
when a query like this is executed. I could not find it myslef
:(
Regards,
Nick
From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Nicolai Tufar <ntufar(at)gmail(dot)com> |
Cc: | Magnus Hagander <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org, pgsql-hackers-win32(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: [pgsql-hackers-win32] snprintf causes regression tests |
Date: | 2005-03-01 14:29:07 |
Message-ID: | 200503011429.j21ET7e15227@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-hackers-win32 |
Nicolai Tufar wrote:
> On Tue, 1 Mar 2005 00:55:20 -0500 (EST), Bruce Momjian
> > My next guess
> > is that Win32 isn't handling va_arg(..., long long int) properly.
> >
>
> I am trying various combination of number and types
> of parameters in my test program and everything prints fine.
> When it comes to pg, it fails :(
>
> > > template1=# select * from test where x > 1000::int8;
> > > x
> > > ------------
> > > -869367531
> > > (1 row)
>
> I am not too fluent in source code, could someone
> point me to there actual call to snprintf() is being done
> when a query like this is executed. I could not find it myslef
Sure, in src/backend/utils/adt/int8.c, there is a call in int8out():
if ((len = snprintf(buf, MAXINT8LEN, INT64_FORMAT, val)) < 0)
and that calls port/snprintf.c.
I have added a puts() in snprintf.c to make sure it is getting the
long/long specifier.
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From: | Nicolai Tufar <ntufar(at)gmail(dot)com> |
---|---|
To: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
Cc: | Magnus Hagander <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org, pgsql-hackers-win32(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: [pgsql-hackers-win32] snprintf causes regression tests to fail |
Date: | 2005-03-01 20:19:31 |
Message-ID: | d809293905030112196b9bd625@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-hackers-win32 |
I spent all day debugging it. Still have absolutely
no idea what could possibly go wrong. Does
anyone have a slightest clue what can it be and
why it manifests itself only on win32?
On Tue, 1 Mar 2005 09:29:07 -0500 (EST), Bruce Momjian
<pgman(at)candle(dot)pha(dot)pa(dot)us> wrote:
> Nicolai Tufar wrote:
> > On Tue, 1 Mar 2005 00:55:20 -0500 (EST), Bruce Momjian
> > > My next guess
> > > is that Win32 isn't handling va_arg(..., long long int) properly.
> > >
> >
> > I am trying various combination of number and types
> > of parameters in my test program and everything prints fine.
> > When it comes to pg, it fails :(
> >
> > > > template1=# select * from test where x > 1000::int8;
> > > > x
> > > > ------------
> > > > -869367531
> > > > (1 row)
> >
> > I am not too fluent in source code, could someone
> > point me to there actual call to snprintf() is being done
> > when a query like this is executed. I could not find it myslef
>
> Sure, in src/backend/utils/adt/int8.c, there is a call in int8out():
>
> if ((len = snprintf(buf, MAXINT8LEN, INT64_FORMAT, val)) < 0)
>
> and that calls port/snprintf.c.
>
> I have added a puts() in snprintf.c to make sure it is getting the
> long/long specifier.
>
> --
> Bruce Momjian | http://candle.pha.pa.us
> pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
> + If your life is a hard drive, | 13 Roberts Road
> + Christ can be your backup. | Newtown Square, Pennsylvania 19073
>
From: | pgsql(at)mohawksoft(dot)com |
---|---|
To: | "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us> |
Cc: | "Nicolai Tufar" <ntufar(at)gmail(dot)com>, "Magnus Hagander" <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org, pgsql-hackers-win32(at)postgresql(dot)org, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: [pgsql-hackers-win32] snprintf causes regression |
Date: | 2005-03-01 20:29:43 |
Message-ID: | 16572.24.91.171.78.1109708983.squirrel@mail.mohawksoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-hackers-win32 |
> Nicolai Tufar wrote:
>> On Tue, 1 Mar 2005 00:55:20 -0500 (EST), Bruce Momjian
>> > My next guess
>> > is that Win32 isn't handling va_arg(..., long long int) properly.
>> >
>>
>> I am trying various combination of number and types
>> of parameters in my test program and everything prints fine.
>> When it comes to pg, it fails :(
>>
>> > > template1=# select * from test where x > 1000::int8;
>> > > x
>> > > ------------
>> > > -869367531
>> > > (1 row)
>>
>> I am not too fluent in source code, could someone
>> point me to there actual call to snprintf() is being done
>> when a query like this is executed. I could not find it myslef
>
> Sure, in src/backend/utils/adt/int8.c, there is a call in int8out():
>
> if ((len = snprintf(buf, MAXINT8LEN, INT64_FORMAT, val)) < 0)
>
> and that calls port/snprintf.c.
>
> I have added a puts() in snprintf.c to make sure it is getting the
> long/long specifier.
Just a question, and don't mind me if I am being rude, isn't this the
WRONG PLACE for a "printf" function? Wouldn't an "itoa" function be more
efficient and be less problematic?
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql(at)mohawksoft(dot)com |
Cc: | "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>, "Nicolai Tufar" <ntufar(at)gmail(dot)com>, "Magnus Hagander" <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org, pgsql-hackers-win32(at)postgresql(dot)org |
Subject: | Re: [pgsql-hackers-win32] snprintf causes regression tests |
Date: | 2005-03-01 20:31:22 |
Message-ID: | 20730.1109709082@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers Postg토토 사이트 순위SQL : |
pgsql(at)mohawksoft(dot)com writes:
> Just a question, and don't mind me if I am being rude, isn't this the
> WRONG PLACE for a "printf" function? Wouldn't an "itoa" function be more
> efficient and be less problematic?
This particular call could be so replaced, but it wouldn't solve the
general problem. snprintf has to work.
regards, tom lane
From: | pgsql(at)mohawksoft(dot)com |
---|---|
To: | "Nicolai Tufar" <ntufar(at)gmail(dot)com> |
Cc: | "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>, "Magnus Hagander" <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org, pgsql-hackers-win32(at)postgresql(dot)org, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: [pgsql-hackers-win32] snprintf causes regression |
Date: | 2005-03-01 20:38:58 |
Message-ID: | 16547.24.91.171.78.1109709538.squirrel@mail.mohawksoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-hackers-win32 |
> I spent all day debugging it. Still have absolutely
> no idea what could possibly go wrong. Does
> anyone have a slightest clue what can it be and
> why it manifests itself only on win32?
It may be that the CLIB has badly broken support for 64bit integers on 32
bit platforms. Does anyone know of any Cygwin/Ming issues?
Is this only with the new snprintf code in Win32?
Is this a problem with snprintf as implemented in src/port?
Is there a reason why we don't use the snprintf that comes with the
various C compilers?
>
>
> On Tue, 1 Mar 2005 09:29:07 -0500 (EST), Bruce Momjian
> <pgman(at)candle(dot)pha(dot)pa(dot)us> wrote:
>> Nicolai Tufar wrote:
>> > On Tue, 1 Mar 2005 00:55:20 -0500 (EST), Bruce Momjian
>> > > My next guess
>> > > is that Win32 isn't handling va_arg(..., long long int) properly.
>> > >
>> >
>> > I am trying various combination of number and types
>> > of parameters in my test program and everything prints fine.
>> > When it comes to pg, it fails :(
>> >
>> > > > template1=# select * from test where x > 1000::int8;
>> > > > x
>> > > > ------------
>> > > > -869367531
>> > > > (1 row)
>> >
>> > I am not too fluent in source code, could someone
>> > point me to there actual call to snprintf() is being done
>> > when a query like this is executed. I could not find it myslef
>>
>> Sure, in src/backend/utils/adt/int8.c, there is a call in int8out():
>>
>> if ((len = snprintf(buf, MAXINT8LEN, INT64_FORMAT, val)) < 0)
>>
>> and that calls port/snprintf.c.
>>
>> I have added a puts() in snprintf.c to make sure it is getting the
>> long/long specifier.
>>
>> --
>> Bruce Momjian | http://candle.pha.pa.us
>> pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
>> + If your life is a hard drive, | 13 Roberts Road
>> + Christ can be your backup. | Newtown Square, Pennsylvania
>> 19073
>>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>
From: | Nicolai Tufar <ntufar(at)gmail(dot)com> |
---|---|
To: | "pgsql(at)mohawksoft(dot)com" <pgsql(at)mohawksoft(dot)com> |
Cc: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Magnus Hagander <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org, pgsql-hackers-win32(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: [pgsql-hackers-win32] snprintf causes regression tests to fail |
Date: | 2005-03-01 20:57:28 |
Message-ID: | d8092939050301125722d9078f@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-hackers-win32 |
On Tue, 1 Mar 2005 15:38:58 -0500 (EST), pgsql(at)mohawksoft(dot)com
<pgsql(at)mohawksoft(dot)com> wrote:
> Is there a reason why we don't use the snprintf that comes with the
> various C compilers?
snprintf() is usually buried in OS libraries. We implement
our own snprintf to make things like this:
snprintf(buf,"%2$s %1$s","world","Hello");
which is not supported on some platforms work.
We do it for national language translation of
messages. In some languages you may need
to change order of parameters to make a meaningful
sentence.
Another question is why we are using it for printing
values from database. I am not too good on function
overriding in standard C but maybe there is a way
to usage of standard snprintf() in a particular place.
From: | pgsql(at)mohawksoft(dot)com |
---|---|
To: | "Nicolai Tufar" <ntufar(at)gmail(dot)com> |
Cc: | "pgsql(at)mohawksoft(dot)com" <pgsql(at)mohawksoft(dot)com>, "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>, "Magnus Hagander" <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org, pgsql-hackers-win32(at)postgresql(dot)org, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: [pgsql-hackers-win32] snprintf causes regression |
Date: | 2005-03-01 21:20:50 |
Message-ID: | 16457.24.91.171.78.1109712050.squirrel@mail.mohawksoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-hackers-win32 |
> On Tue, 1 Mar 2005 15:38:58 -0500 (EST), pgsql(at)mohawksoft(dot)com
> <pgsql(at)mohawksoft(dot)com> wrote:
>> Is there a reason why we don't use the snprintf that comes with the
>> various C compilers?
>
> snprintf() is usually buried in OS libraries. We implement
> our own snprintf to make things like this:
> snprintf(buf,"%2$s %1$s","world","Hello");
> which is not supported on some platforms work.
>
> We do it for national language translation of
> messages. In some languages you may need
> to change order of parameters to make a meaningful
> sentence.
>
> Another question is why we are using it for printing
> values from database. I am not too good on function
> overriding in standard C but maybe there is a way
> to usage of standard snprintf() in a particular place.
>
Well, here is a stupid question, do we even know which snprintf we are
using on Win32? May it be possible that we are using the MingW version
which may be broken?
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql(at)mohawksoft(dot)com |
Cc: | "Nicolai Tufar" <ntufar(at)gmail(dot)com>, "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>, "Magnus Hagander" <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org, pgsql-hackers-win32(at)postgresql(dot)org |
Subject: | Re: [pgsql-hackers-win32] snprintf causes regression tests to fail |
Date: | 2005-03-01 21:22:28 |
Message-ID: | 22581.1109712148@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-hackers-win32 |
pgsql(at)mohawksoft(dot)com writes:
> Well, here is a stupid question, do we even know which snprintf we are
> using on Win32? May it be possible that we are using the MingW version
> which may be broken?
The regression tests were not failing until we started using the port/
version ...
regards, tom lane
From: | Nicolai Tufar <ntufar(at)gmail(dot)com> |
---|---|
To: | "pgsql(at)mohawksoft(dot)com" <pgsql(at)mohawksoft(dot)com> |
Cc: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Magnus Hagander <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org, pgsql-hackers-win32(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: [pgsql-hackers-win32] snprintf causes regression |
Date: | 2005-03-01 22:26:37 |
Message-ID: | d809293905030114261c257075@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers pgsql-hackers-win32 |
On Tue, 1 Mar 2005 16:20:50 -0500 (EST), pgsql(at)mohawksoft(dot)com
<pgsql(at)mohawksoft(dot)com> wrote:
>
> Well, here is a stupid question, do we even know which snprintf we are
> using on Win32? May it be possible that we are using the MingW version
> which may be broken?
Defenitely not. I checked it by placing debugging print
statements in code.