Re: "could not find pathkey item to sort" for TPC-DS queries 94-96

James Coleman <jtc331@gmail.com>

From: James Coleman <jtc331@gmail.com>
To: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Tomas Vondra <tomas.vondra@enterprisedb.com>, Luc Vlaming <luc@swarm64.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>, Robert Haas <robertmhaas@gmail.com>
Date: 2021-04-20T12:01:47Z
Lists: pgsql-hackers
On Tue, Apr 20, 2021 at 7:11 AM Dagfinn Ilmari Mannsåker
<ilmari@ilmari.org> wrote:
>
> ilmari@ilmari.org (Dagfinn Ilmari Mannsåker) writes:
>
> > Tom Lane <tgl@sss.pgh.pa.us> writes:
> >
> >> +    /* We ignore binary-compatible relabeling on both ends */
> >> +    while (expr && IsA(expr, RelabelType))
> >> +            expr = ((RelabelType *) expr)->arg;
> >
> > There are 10 instances of this exact loop scattered around the codebase.
> > Is it worth it turning it into a static inline function?
>
> Something like the attached, maybe?

I'm not opposed to this, but I think it should go in a separate thread
since it's orthogonal to the bugfix there and also will confuse cfbot.

James



Commits

  1. Rename find_em_expr_usable_for_sorting_rel.

  2. Fix planner failure in some cases of sorting by an aggregate.