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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: ilmari(at)ilmari(dot)org (Dagfinn Ilmari Mannsåker )
Cc: James Coleman <jtc331(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Luc Vlaming <luc(at)swarm64(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: "could not find pathkey item to sort" for TPC-DS queries 94-96
Date: 2021-04-20 14:42:45
Message-ID: 525397.1618929765@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

ilmari(at)ilmari(dot)org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) writes:
> ilmari(at)ilmari(dot)org (Dagfinn Ilmari Mannsåker) writes:
>> 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?

Meh. The trouble with this is that the call sites don't all declare
the pointer variable the same way. While the written-out loops can
look the same regardless, a function can only accommodate one choice
without messy casts. For my money, the notational savings here is
small enough that the casts really discourage doing anything.

So if we wanted to do this, I'd think about using a macro:

#define strip_relabeltype(nodeptr) \
while (nodeptr && IsA(nodeptr, RelabelType))
nodeptr = ((RelabelType *) nodeptr)->arg

...

strip_relabeltype(em_expr);

...

Since the argument would have to be a variable, the usual
multiple-reference hazards of using a macro don't seem to apply.

(Probably the macro could do with "do ... while" decoration
to discourage any syntactic oddities, but you get the idea.)

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-04-20 14:49:43 Re: [bug?] Missed parallel safety checks, and wrong parallel safety
Previous Message Masahiko Sawada 2021-04-20 14:23:44 Re: Replication slot stats misgivings