problem with volatile functions in subselects ? - Mailing list pgsql-hackers

From Sergey E. Koposov
Subject problem with volatile functions in subselects ?
Date
Msg-id Pine.LNX.4.64.0607302214050.30743@lnfm1.sai.msu.ru
Whole thread Raw
Responses Re: problem with volatile functions in subselects ?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hello Hackers,

I see the very strange behaviour with the following set of queries:

wsdb=# select na,nb, na::double precision as da, nb::double precision  as db from ( select random()::numeric as
na,random()::numericas nb from generate_series(1,2)) as xx;        na         |        nb         |        da         |
      db 
 
-------------------+-------------------+-------------------+------------------- 0.756045001445359 | 0.505602368389071 |
0.283893094995941| 0.160685719065687 0.792114335015469 | 0.416411793053342 | 0.342387438445532 | 0.531201674850286
 
(2 rows)

On my understanding that should produce the "na" column equal to "da" ?

When I do the same with the select from the table the result is similar:

wsdb=# select na,nb, na::double precision as da, nb::double precision  as db from ( select random()::numeric as
na,random()::numericas nb from pg_proc) as xx;         na           |          nb           |          da          |
     db 
 
-----------------------+-----------------------+----------------------+----------------------     0.125243402610181 |
 0.620239329347498 |     0.64666960465101 |    0.257827353318141     0.934299875951512 |    0.0322264223509591 |
0.96565025298188|   0.0439542480949099
 
........

But when I limit the select, I get the expected result.

wsdb=# select na,nb, na::double precision as da, nb::double precision  as db from ( select random()::numeric as
na,random()::numericas nb from pg_proc limit 2) as xx;        na         |        nb         |        da         |
 db 
 
-------------------+-------------------+-------------------+------------------- 0.543030349324937 | 0.925069289712733 |
0.543030349324937| 0.925069289712733 0.934251406665077 | 0.292522935332974 | 0.934251406665077 | 0.292522935332974
 
(2 rows)

Is that a bug, or I'm missing something ?

PG version is 8.1.4 or 8.2dev.

Regards,    Sergey

*******************************************************************
Sergey E. Koposov
Max Planck Institute for Astronomy/Sternberg Astronomical Institute
Tel: +49-6221-528-349
Web: http://lnfm1.sai.msu.ru/~math
E-mail: math@sai.msu.ru


pgsql-hackers by date:

Previous
From: Joe Conway
Date:
Subject: Re: [PATCHES] 8.2 features?
Next
From: Tom Lane
Date:
Subject: Relation locking and relcache load (was Re: Going for "all green" buildfarm results)