Re: snprintf causes regression tests to fail - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: snprintf causes regression tests to fail
Date
Msg-id 200503010454.j214sg524406@candle.pha.pa.us
Whole thread Raw
In response to snprintf causes regression tests to fail  ("Magnus Hagander" <mha@sollentuna.net>)
Responses Re: snprintf causes regression tests to fail
List pgsql-hackers
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@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-hackers by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: Execute and PortalSuspended needs explicit transaction
Next
From: Robert Treat
Date:
Subject: mysterious log output