pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
HELP: Scarey pl/pgsql problem
3+ messages / 2 participants
[nested] [flat]

* HELP: Scarey pl/pgsql problem
@ 2001-02-01 02:50  Justin Clift <aa2@bigpond.net.au>
  0 siblings, 2 replies; 3+ messages in thread

From: Justin Clift @ 2001-02-01 02:50 UTC (permalink / raw)
  To: pgsql-sql; +Cc: Jan Wieck <janwieck@Yahoo.com>

Hi all,

I'm having trouble with what MAY BE a bug in PL/PGSQL for PG 7.0.3 on
Linux (Mandrake Linux 7.2).

It appears pl/pgsql is munging values.  When I pass it a 'time' value,
the value is altered without my code touching it.  This is evidenced by
the stripped down function below :

CREATE FUNCTION which_block(time)
RETURNS time
AS 'DECLARE

/* Given a time, this function works out the name of the correct field
in the reservations table for it
 * Written by : Justin Clift
 * Date       : 1st February 2001
 * Version    : 1.00
 */
        hours   char(3);
        minutes char(2);
        result  char(5);
        tempres char(5);
        curnow  datetime;

        BEGIN

        RETURN $1;
        END;'
LANGUAGE 'plpgsql';


foobar=# select which_block(time '12:40:00');
 which_block
-------------
 12:39:00
(1 row)
 
foobar=# 

Having passed it the time value of '12:40:00', I am immediately
returning that value and it is no longer '12:40:00'.

Being over 1 month into using PostgreSQL 7.0.3 for a particular project,
this is scaring me as I'm now doubting the reliability of things.

Regards and best wishes,

Justin Clift
Database Administrator



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

* Re: HELP: Scarey pl/pgsql problem
@ 2001-02-01 03:36  Justin Clift <aa2@bigpond.net.au>
  parent: Justin Clift <aa2@bigpond.net.au>
  1 sibling, 0 replies; 3+ messages in thread

From: Justin Clift @ 2001-02-01 03:36 UTC (permalink / raw)
  To: pgsql-sql; Jan Wieck <janwieck@Yahoo.com>

Hi all,

I must apologise as it turns out the 'culprit' wasn't really pl/pgsql.

The test box I was testing on is Mandrake Linux 7.2, which comes with
PostgreSQL 7.0.2.  Everything else has version 7.0.3 installed on it,
and I naively assumed that 7.0.3 was installed on the test box.

After installing the Postgres 7.0.3 rpms from the PostgreSQL site,
pl/pgsql is working consistently again.  It looks like the rpms for
PostgreSQL supplied with Mandrake Linux 7.2 are broken, I guess they
didn't run the supplied tests before packaging.  :-(

Regards and best wishes,

Justin Clift
Database Administrator


Justin Clift wrote:
> 
> Hi all,
> 
> I'm having trouble with what MAY BE a bug in PL/PGSQL for PG 7.0.3 on
> Linux (Mandrake Linux 7.2).
> 
> It appears pl/pgsql is munging values.  When I pass it a 'time' value,
> the value is altered without my code touching it.  This is evidenced by
> the stripped down function below :
> 
> CREATE FUNCTION which_block(time)
> RETURNS time
> AS 'DECLARE
> 
> /* Given a time, this function works out the name of the correct field
> in the reservations table for it
>  * Written by : Justin Clift
>  * Date       : 1st February 2001
>  * Version    : 1.00
>  */
>         hours   char(3);
>         minutes char(2);
>         result  char(5);
>         tempres char(5);
>         curnow  datetime;
> 
>         BEGIN
> 
>         RETURN $1;
>         END;'
> LANGUAGE 'plpgsql';
> 
> foobar=# select which_block(time '12:40:00');
>  which_block
> -------------
>  12:39:00
> (1 row)
> 
> foobar=#
> 
> Having passed it the time value of '12:40:00', I am immediately
> returning that value and it is no longer '12:40:00'.
> 
> Being over 1 month into using PostgreSQL 7.0.3 for a particular project,
> this is scaring me as I'm now doubting the reliability of things.
> 
> Regards and best wishes,
> 
> Justin Clift
> Database Administrator



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

* Re: HELP: Scarey pl/pgsql problem
@ 2001-02-05 19:35  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Justin Clift <aa2@bigpond.net.au>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2001-02-05 19:35 UTC (permalink / raw)
  To: Justin Clift <aa2@bigpond.net.au>; +Cc: pgsql-sql

Justin Clift <aa2@bigpond.net.au> writes:
> I'm having trouble with what MAY BE a bug in PL/PGSQL for PG 7.0.3 on
> Linux (Mandrake Linux 7.2).
> [ bogus roundoff behavior in date/time display ]

This is a known silliness in the Mandrake distribution: their default
compiler flags include both -O3 and -ffast-math, a combination that the
gcc people will tell you does not work.  The main result we've heard
about is bogus roundoff behavior.

I believe our recent Mandrake RPMs have been built with compiler flags
that actually work, but if you got the files from someplace else or
compiled them yourself then you might be vulnerable to this error.
Check the mail list archives for more info, eg 
http://www.postgresql.org/mhonarc/pgsql-hackers/2000-08/msg00193.html

			regards, tom lane



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


end of thread, other threads:[~2001-02-05 19:35 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-02-01 02:50 HELP: Scarey pl/pgsql problem Justin Clift <aa2@bigpond.net.au>
2001-02-01 03:36 ` Justin Clift <aa2@bigpond.net.au>
2001-02-05 19:35 ` Tom Lane <tgl@sss.pgh.pa.us>

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