pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedgen_random_uuid() is immutable in Pg 13devel
8+ messages / 5 participants
[nested] [flat]
* gen_random_uuid() is immutable in Pg 13devel
@ 2020-02-18 18:54 hubert depesz lubaczewski <depesz@depesz.com>
0 siblings, 2 replies; 8+ messages in thread
From: hubert depesz lubaczewski @ 2020-02-18 18:54 UTC (permalink / raw)
To: pgsql-bugs
Hi,
I noticed that get_random_uuid() from pgcrypt is marked as immutable.
Up to 12.2 it was volatile, and in 13 it became immutable.
This leads to "interesting" change, that:
select gen_random_uuid() from generate_series(1,10);
returns 10 different uuids before 13, and 10 identical ones on 13devel.
It looks that commit 5925e5549890416bcf588334d9d0bc99f8ad6c7f forgot to
mark the function as volatile. Not sure if it was intentional.
Best regards,
depesz
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: gen_random_uuid() is immutable in Pg 13devel
@ 2020-02-18 19:01 Alvaro Herrera <alvherre@2ndquadrant.com>
parent: hubert depesz lubaczewski <depesz@depesz.com>
1 sibling, 1 reply; 8+ messages in thread
From: Alvaro Herrera @ 2020-02-18 19:01 UTC (permalink / raw)
To: hubert depesz lubaczewski <depesz@depesz.com>; +Cc: pgsql-bugs; Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
On 2020-Feb-18, hubert depesz lubaczewski wrote:
> Hi,
> I noticed that get_random_uuid() from pgcrypt is marked as immutable.
>
> Up to 12.2 it was volatile, and in 13 it became immutable.
>
> This leads to "interesting" change, that:
>
> select gen_random_uuid() from generate_series(1,10);
>
> returns 10 different uuids before 13, and 10 identical ones on 13devel.
>
> It looks that commit 5925e5549890416bcf588334d9d0bc99f8ad6c7f forgot to
> mark the function as volatile. Not sure if it was intentional.
It seems an oversight to me.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: gen_random_uuid() is immutable in Pg 13devel
@ 2020-02-18 19:36 Peter Geoghegan <pg@bowt.ie>
parent: Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 8+ messages in thread
From: Peter Geoghegan @ 2020-02-18 19:36 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: hubert depesz lubaczewski <depesz@depesz.com>; pgsql-bugs; Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
On Tue, Feb 18, 2020 at 11:01 AM Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
> > It looks that commit 5925e5549890416bcf588334d9d0bc99f8ad6c7f forgot to
> > mark the function as volatile. Not sure if it was intentional.
>
> It seems an oversight to me.
Maybe this happened because the default volatility for pg_proc.dat
entries is not 'volatile' -- it's 'immutable'.
--
Peter Geoghegan
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: gen_random_uuid() is immutable in Pg 13devel
@ 2020-02-18 20:01 Alvaro Herrera <alvherre@2ndquadrant.com>
parent: Peter Geoghegan <pg@bowt.ie>
0 siblings, 2 replies; 8+ messages in thread
From: Alvaro Herrera @ 2020-02-18 20:01 UTC (permalink / raw)
To: Peter Geoghegan <pg@bowt.ie>; +Cc: hubert depesz lubaczewski <depesz@depesz.com>; pgsql-bugs; Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
On 2020-Feb-18, Peter Geoghegan wrote:
> On Tue, Feb 18, 2020 at 11:01 AM Alvaro Herrera
> <alvherre@2ndquadrant.com> wrote:
> > > It looks that commit 5925e5549890416bcf588334d9d0bc99f8ad6c7f forgot to
> > > mark the function as volatile. Not sure if it was intentional.
> >
> > It seems an oversight to me.
>
> Maybe this happened because the default volatility for pg_proc.dat
> entries is not 'volatile' -- it's 'immutable'.
That makes me wonder what should be the default --- and should there
even *be* a default in the first place? Maybe it's better to make
everyone *think* about it every time rather than hoping we'll all
remember, and frequently having it got wrong.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: gen_random_uuid() is immutable in Pg 13devel
@ 2020-02-18 20:34 Peter Geoghegan <pg@bowt.ie>
parent: Alvaro Herrera <alvherre@2ndquadrant.com>
1 sibling, 0 replies; 8+ messages in thread
From: Peter Geoghegan @ 2020-02-18 20:34 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: hubert depesz lubaczewski <depesz@depesz.com>; pgsql-bugs; Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
On Tue, Feb 18, 2020 at 12:01 PM Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
> That makes me wonder what should be the default --- and should there
> even *be* a default in the first place? Maybe it's better to make
> everyone *think* about it every time rather than hoping we'll all
> remember, and frequently having it got wrong.
I'd say that there is a good argument for that. Though note that
opr_sanity.sql does a good job of detecting functions that are not
marked immutable, but need to be -- things like indexable operators,
pg_amproc entries, etc.
--
Peter Geoghegan
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: gen_random_uuid() is immutable in Pg 13devel
@ 2020-02-18 22:58 Tom Lane <tgl@sss.pgh.pa.us>
parent: Alvaro Herrera <alvherre@2ndquadrant.com>
1 sibling, 0 replies; 8+ messages in thread
From: Tom Lane @ 2020-02-18 22:58 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Peter Geoghegan <pg@bowt.ie>; hubert depesz lubaczewski <depesz@depesz.com>; pgsql-bugs; Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> On 2020-Feb-18, Peter Geoghegan wrote:
>> Maybe this happened because the default volatility for pg_proc.dat
>> entries is not 'volatile' -- it's 'immutable'.
> That makes me wonder what should be the default --- and should there
> even *be* a default in the first place? Maybe it's better to make
> everyone *think* about it every time rather than hoping we'll all
> remember, and frequently having it got wrong.
Yeah. That default was chosen just to reduce the size of pg_proc.dat
(since a large majority of C functions are indeed immutable). But
it might be too error-prone this way. I remember worrying about that
when we put it in.
regards, tom lane
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: gen_random_uuid() is immutable in Pg 13devel
@ 2020-02-19 19:19 Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
parent: hubert depesz lubaczewski <depesz@depesz.com>
1 sibling, 1 reply; 8+ messages in thread
From: Peter Eisentraut @ 2020-02-19 19:19 UTC (permalink / raw)
To: pgsql-bugs
On 2020-02-18 19:54, hubert depesz lubaczewski wrote:
> Hi,
> I noticed that get_random_uuid() from pgcrypt is marked as immutable.
>
> Up to 12.2 it was volatile, and in 13 it became immutable.
>
> This leads to "interesting" change, that:
>
> select gen_random_uuid() from generate_series(1,10);
>
> returns 10 different uuids before 13, and 10 identical ones on 13devel.
>
> It looks that commit 5925e5549890416bcf588334d9d0bc99f8ad6c7f forgot to
> mark the function as volatile. Not sure if it was intentional.
Fixed, thanks.
It was indeed the result of confusion about the default value.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: gen_random_uuid() is immutable in Pg 13devel
@ 2020-02-20 11:12 hubert depesz lubaczewski <depesz@depesz.com>
parent: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
0 siblings, 0 replies; 8+ messages in thread
From: hubert depesz lubaczewski @ 2020-02-20 11:12 UTC (permalink / raw)
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: pgsql-bugs
On Wed, Feb 19, 2020 at 08:19:00PM +0100, Peter Eisentraut wrote:
> > It looks that commit 5925e5549890416bcf588334d9d0bc99f8ad6c7f forgot to
> > mark the function as volatile. Not sure if it was intentional.
> Fixed, thanks.
> It was indeed the result of confusion about the default value.
Thank you.
Mistakes happen, no big deal :)
Best regards,
depesz
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2020-02-20 11:12 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-02-18 18:54 gen_random_uuid() is immutable in Pg 13devel hubert depesz lubaczewski <depesz@depesz.com>
2020-02-18 19:01 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2020-02-18 19:36 ` Peter Geoghegan <pg@bowt.ie>
2020-02-18 20:01 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2020-02-18 20:34 ` Peter Geoghegan <pg@bowt.ie>
2020-02-18 22:58 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-02-19 19:19 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2020-02-20 11:12 ` hubert depesz lubaczewski <depesz@depesz.com>
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