Re: BUG #17564: Planner bug in combination of generate_series(), unnest() and ORDER BY

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: kleptog@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Date: 2022-08-01T22:17:11Z
Lists: pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> db=# explain SELECT generate_subscripts(ARRAY[]::integer[], 1) AS id, 
>        unnest(ARRAY[]::jsonb[]) ->> 'timestamp'  AS timestamp 
> FROM results 
> JOIN groups ON groups.id = results.group_id 
> WHERE results.search_id = 3336 
> order by timestamp;

> The error is:

> ERROR:  set-valued function called in context that cannot accept a set
> LINE 2:        unnest(ARRAY[]::jsonb[]) ->> 'timestamp'  AS timestam...

Hmm, that certainly seems like a bug, but I fear it's impossible
to investigate without a reproducible test case.

			regards, tom lane



Commits

  1. Add proper regression test for the recent SRFs-in-pathkeys problem.

  2. Fix incorrect tests for SRFs in relation_can_be_sorted_early().

  3. Optimize order of GROUP BY keys