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: Richard Guo <guofenglinux@gmail.com>
Cc: Martijn van Oosterhout <kleptog@gmail.com>, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2022-08-04T15:13:22Z
Lists: pgsql-bugs
Richard Guo <guofenglinux@gmail.com> writes:
> Yeah, I tested in bc76f5ac4. Attached is a regression test I composed.
> I tested it locally and it can catch this bug before 1aa8dad41 and give
> the expected answer after 1aa8dad41.

Nice!  I found we could simplify it even further: we don't seem to
need the generate_subscripts() to provoke the error in this query.
And it fails in v13-v14, too.  Pushed.

			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