Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lYraX-0004iZ-TQ for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Apr 2021 14:42:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lYraW-0001ip-Rz for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Apr 2021 14:42:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lYraW-0001fZ-LK for pgsql-hackers@lists.postgresql.org; Tue, 20 Apr 2021 14:42:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lYraU-00072E-N3 for pgsql-hackers@postgresql.org; Tue, 20 Apr 2021 14:42:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 13KEgkDV525398; Tue, 20 Apr 2021 10:42:46 -0400 From: Tom Lane To: ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) cc: James Coleman , Tomas Vondra , Luc Vlaming , PostgreSQL-development , Robert Haas Subject: Re: "could not find pathkey item to sort" for TPC-DS queries 94-96 In-reply-to: <87im4hnrbw.fsf@wibble.ilmari.org> References: <91f3ec99-85a4-fa55-ea74-33f85a5c651f@swarm64.com> <355670.1618688385@sss.pgh.pa.us> <90179.1618766515@sss.pgh.pa.us> <366787.1618870191@sss.pgh.pa.us> <459042.1618873805@sss.pgh.pa.us> <87lf9dnukn.fsf@wibble.ilmari.org> <87im4hnrbw.fsf@wibble.ilmari.org> Comments: In-reply-to ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) message dated "Tue, 20 Apr 2021 12:11:31 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <525396.1618929765.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Tue, 20 Apr 2021 10:42:45 -0400 Message-ID: <525397.1618929765@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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