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

From Tom Lane
Subject Re: "could not find pathkey item to sort" for TPC-DS queries 94-96
Date
Msg-id 525397.1618929765@sss.pgh.pa.us
Whole thread Raw
In response to Re: "could not find pathkey item to sort" for TPC-DS queries 94-96  (ilmari@ilmari.org (Dagfinn Ilmari Mannsåker))
List pgsql-hackers
ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) writes:
> ilmari@ilmari.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



pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: Replication slot stats misgivings
Next
From: Tom Lane
Date:
Subject: Re: [bug?] Missed parallel safety checks, and wrong parallel safety