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

Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>

From: ilmari@ilmari.org (Dagfinn Ilmari Mannsåker )
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: James Coleman <jtc331@gmail.com>, 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-20T11:11:31Z
Lists: pgsql-hackers

Attachments

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?

- ilmari
-- 
"A disappointingly low fraction of the human race is,
 at any given time, on fire." - Stig Sandbeck Mathisen

Commits

  1. Rename find_em_expr_usable_for_sorting_rel.

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