pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: ilmari@ilmari.org
Cc: James Coleman <jtc331@gmail.com>
Cc: Tomas Vondra <tomas.vondra@enterprisedb.com>
Cc: Luc Vlaming <luc@swarm64.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: Robert Haas <robertmhaas@gmail.com>
Subject: Re: "could not find pathkey item to sort" for TPC-DS queries 94-96
Date: Tue, 20 Apr 2021 10:42:45 -0400
Message-ID: <525397.1618929765@sss.pgh.pa.us> (raw)
In-Reply-To: <87im4hnrbw.fsf@wibble.ilmari.org>
References: <91f3ec99-85a4-fa55-ea74-33f85a5c651f@swarm64.com>
	<b386c655-ba5d-a1e2-9791-83b103f5a638@enterprisedb.com>
	<CAAaqYe_NU4hO9COoJdcXWqjtH=dGMknYdsSdJjZ=JOHPTea-Nw@mail.gmail.com>
	<CAAaqYe8hst0zS4FDc-gS++u=NRkdKYEn5-zi8FLjDp2+DELBdw@mail.gmail.com>
	<d34620b9-3585-553a-3b76-ef7151c16f0e@swarm64.com>
	<CAAaqYe90ASC2deAaVou6ev5ppXMGG_epWK+D5yeqpwxG3-OEzw@mail.gmail.com>
	<ffd9a157-9c7c-6efe-19e4-2af81a6eb220@enterprisedb.com>
	<355670.1618688385@sss.pgh.pa.us>
	<90179.1618766515@sss.pgh.pa.us>
	<CAAaqYe_vcq4vjF7+B8PPwQ5HvMb-7pi0C8Kzb4o3vC_4k_x-KQ@mail.gmail.com>
	<366787.1618870191@sss.pgh.pa.us>
	<459042.1618873805@sss.pgh.pa.us>
	<87lf9dnukn.fsf@wibble.ilmari.org>
	<87im4hnrbw.fsf@wibble.ilmari.org>

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





view thread (29+ messages)  latest in thread

Message-ID: <525397.1618929765@sss.pgh.pa.us>
Permalink:  ../525397.1618929765@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/525397.1618929765@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ilmari@ilmari.org, jtc331@gmail.com, tomas.vondra@enterprisedb.com, luc@swarm64.com, robertmhaas@gmail.com
  Subject: Re: "could not find pathkey item to sort" for TPC-DS queries 94-96
  In-Reply-To: <525397.1618929765@sss.pgh.pa.us>
  References: <91f3ec99-85a4-fa55-ea74-33f85a5c651f@swarm64.com> <b386c655-ba5d-a1e2-9791-83b103f5a638@enterprisedb.com> <CAAaqYe_NU4hO9COoJdcXWqjtH=dGMknYdsSdJjZ=JOHPTea-Nw@mail.gmail.com> <CAAaqYe8hst0zS4FDc-gS++u=NRkdKYEn5-zi8FLjDp2+DELBdw@mail.gmail.com> <d34620b9-3585-553a-3b76-ef7151c16f0e@swarm64.com> <CAAaqYe90ASC2deAaVou6ev5ppXMGG_epWK+D5yeqpwxG3-OEzw@mail.gmail.com> <ffd9a157-9c7c-6efe-19e4-2af81a6eb220@enterprisedb.com> <355670.1618688385@sss.pgh.pa.us> <90179.1618766515@sss.pgh.pa.us> <CAAaqYe_vcq4vjF7+B8PPwQ5HvMb-7pi0C8Kzb4o3vC_4k_x-KQ@mail.gmail.com> <366787.1618870191@sss.pgh.pa.us> <459042.1618873805@sss.pgh.pa.us> <87lf9dnukn.fsf@wibble.ilmari.org> <87im4hnrbw.fsf@wibble.ilmari.org> <525397.1618929765@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox