BUG #16121: 12 regression: Volatile function in target list subquery behave as stable - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #16121: 12 regression: Volatile function in target list subquery behave as stable
Date
Msg-id 16121-b8e8dc82e608b89d@postgresql.org
Whole thread Raw
Responses Re: BUG #16121: 12 regression: Volatile function in target list subquery behave as stable  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      16121
Logged by:          Elvis Pranskevichus
Email address:      elprans@gmail.com
PostgreSQL version: 12.1
Operating system:   Gentoo Linux
Description:

There seems to be a regression in Postgres 12 related to how volatile
functions are handled. If put inside a subquery in the target list, the
volatile function seems to behave like a stable one:

volatility=# SELECT
   v.i,
   (SELECT random() from (values (v.i)) as q) AS v1
FROM
   generate_series(1, 2) as v(i);
 i │         v1
───┼────────────────────
 1 │ 0.8303615124282295
 2 │ 0.8303615124282295
(2 rows)

Postgres 11 and earlier worked correctly:

volatility=# SELECT
   v.i,
   (SELECT random() from (values (v.i)) as q) AS v1
FROM
   generate_series(1, 2) as v(i);
 i │        v1
───┼───────────────────
 1 │ 0.137472071684897
 2 │ 0.288798084016889
(2 rows)


pgsql-bugs by date:

Previous
From: Floris Van Nee
Date:
Subject: Re: incorrect pg_dump output due to not handling dropped rolescorrectly
Next
From: PG Bug reporting form
Date:
Subject: BUG #16122: segfault pg_detoast_datum (datum=0x0) at fmgr.c:1833 numrange query