Re: pg18 bug? SELECT query doesn't work

David G. Johnston <david.g.johnston@gmail.com>

From: "David G. Johnston" <david.g.johnston@gmail.com>
To: Eric Ridge <eebbrr@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Date: 2026-01-06T16:04:01Z
Lists: pgsql-hackers, pgsql-general
On Tue, Jan 6, 2026 at 8:22 AM Eric Ridge <eebbrr@gmail.com> wrote:

> drop table if exists wth;
> create table wth (id serial8, json_data json);
> insert into wth (json_data) values ('[{"animal": "cats"}, {"animal":
> "dogs"}]');
>
> -- this ERRORs on pg18
> select animal
> from (select upper(json_array_elements(json_data) ->> 'animal') animal,
> count(*) from wth group by 1) x
> where animal ilike 'c%';
>
> On pg18 I'm presented with:
>
> ERROR:  set-valued function called in context that cannot accept a set
> LINE 1: select animal from (select upper(json_array_elements(json_da...
>
> Just thought I'd bring this to y'alls attention.
>
>
It was an intentional change.  You now should be putting set-producing
functions into the FROM clause of a query or subquery.  A lateral join is
often required.

David J.

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix unsafe pushdown of quals referencing grouping Vars

  2. Introduce an RTE for the grouping step