problem with volatile functions in subselects ?

From: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
To: pgsql-hackers(at)postgresql(dot)org
Subject: problem with volatile functions in subselects ?
Date: 2006-07-30 18:33:56
Message-ID: Pine.LNX.4.64.0607302214050.30743@lnfm1.sai.msu.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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()::numeric as 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()::numeric as 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()::numeric as 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(at)sai(dot)msu(dot)ru

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-07-30 18:39:44 Relation locking and relcache load (was Re: Going for "all green" buildfarm results)
Previous Message Joe Conway 2006-07-30 18:21:36 Re: [PATCHES] 8.2 features?