BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: thibaut(dot)madelaine(at)dalibo(dot)com
Subject: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000)
Date: 2019-03-05 11:06:00
Message-ID: 15669-02fb3296cca26203@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 15669
Logged by: Thibaut MADELAINE
Email address: thibaut(dot)madelaine(at)dalibo(dot)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)
==========

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2019-03-05 13:52:16 BUG #15670: alter table .. add column if not exists ... references ...; adds a FK constraint on each execution
Previous Message PG Bug reporting form 2019-03-05 09:05:55 BUG #15668: Server crash in transformPartitionRangeBounds