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-03T14:56:13Z
Lists: pgsql-bugs
Richard Guo <guofenglinux@gmail.com> writes:
> On Tue, Aug 2, 2022 at 4:50 PM Martijn van Oosterhout <kleptog@gmail.com>
> wrote:
>> Now it's morning I've thought of a way to reproduce it more easily, see
>> the attached script.

> Thanks for the report! I can reproduce it on HEAD.

FWIW, this reproduces the bug for me in v13 and v14, but not v15 or HEAD.
While the method to fix the bug seems clear enough, it doesn't seem
like we have a test case that's stable enough to be worth anything
as a regression test.  Hmmm...

			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