The following bug has been logged on the website:
Bug reference: 15669
Logged by: Thibaut MADELAINE
Email address: thibaut.madelaine@dalibo.com
PostgreSQL version: 11.2
Operating system: Debian
Description:
Hello,
A client found a possible bug in version 11.2.
Trying to use "unnest" on an array record with the predicate "false" fails
with the message:
ERROR: set-valued function called in context that cannot accept a set
In PostgreSQL 10.7 and before, it is possible to run the following query:
==========
thibaut=# select version();
version
-------------------------------------------------------------------------------------------------------------------
PostgreSQL 10.7 (Debian 10.7-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled
by gcc (Debian 8.2.0-16) 8.2.0, 64-bit
(1 ligne)
thibaut=# WITH test AS ( SELECT array[1,2] AS intarr )
SELECT unnest(intarr) AS lot_id FROM test WHERE false;
lot_id
--------
(0 ligne)
==========
In version 11.2, the same query fails:
==========
thibaut=# select version();
version
-------------------------------------------------------------------------------------------------------------------
PostgreSQL 11.2 (Debian 11.2-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled
by gcc (Debian 8.2.0-16) 8.2.0, 64-bit
(1 ligne)
thibaut=# \set VERBOSITY verbose
thibaut=# WITH test AS ( SELECT array[1,2] AS intarr )
SELECT unnest(intarr) AS lot_id FROM test WHERE false;
ERROR: 0A000: set-valued function called in context that cannot accept a
set
LIGNE 2 : SELECT unnest(intarr) as lot_id FROM test where false;
^
EMPLACEMENT : ExecInitFunc, execExpr.c : 2212
==========
The same query with a false predicate that needs to be evaluated succeeds:
==========
thibaut=# with test as ( SELECT array[1,2] as intarr )
SELECT unnest(intarr) as lot_id FROM test where now()<'1996-01-01';
lot_id
--------
(0 ligne)
==========