PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID15669
PG Version11.2
OSDebian
Opened2019-03-05 11:06:00+00
Reported byThibaut MADELAINE
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      15669
Logged by:          Thibaut MADELAINE
Email address:      (redacted)
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)
==========

Messages

DateAuthorSubject
2019-03-05 11:06:00+00PG Bug reporting formBUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-05 15:39:07+00Tom LaneRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-05 16:34:21+00Julien RouhaudRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-05 17:16:10+00Julien RouhaudRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-05 17:28:57+00Tom LaneRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-05 18:22:32+00Julien RouhaudRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-05 21:02:56+00Tom LaneRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-05 22:21:56+00Tom LaneRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-05 22:59:59+00Tom LaneRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-06 17:08:30+00Julien RouhaudRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-06 18:23:49+00Tom LaneRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-06 20:12:15+00Tom LaneRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-06 20:23:33+00Julien RouhaudRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-07 10:51:34+00Julien RouhaudRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-07 15:52:33+00Tom LaneRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-07 18:14:29+00Julien RouhaudRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-07 18:40:10+00Tom LaneRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
2019-03-07 20:58:03+00Julien RouhaudRe: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)