Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j9rLC-0006j0-AF for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Mar 2020 14:19:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j9rLA-0002bW-Kc for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Mar 2020 14:19:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j9rLA-0002Zk-3j for pgsql-hackers@lists.postgresql.org; Thu, 05 Mar 2020 14:19:08 +0000 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j9rL5-0007tU-Nm for pgsql-hackers@lists.postgresql.org; Thu, 05 Mar 2020 14:19:06 +0000 Received: by mail-qt1-x844.google.com with SMTP id x21so4154062qto.13 for ; Thu, 05 Mar 2020 06:19:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=5j2qPUuswSqkqLTTB/Cg87BrENTi7HCvO32QtQ3hu1w=; b=mn+6Y8tv2uTU6ZR+oBQdgnFGl7GBc8MVCl77fjUKQ+4GqfZdtF8d9czHT7iYrBmB0X A9ML8nknz50yn+xU74W1aPnq9TE+VIpCyAohOAJN2aND/NC0KeZv5Mh2Pcnl73NW8KQx rtwsD9m5+zl8IZ8qq3fL0Pri0vlzEnqp2BOdwtCPxn8LAClKOWiOCK9Jq2mqChRt060d 7/MxJlyVf+GolWGeShNe1pN97PbykxTYUCe3HJu40rV1YLpO7n12qgnye0IuzTH1eihJ RZBIeWuaY2fDfl2yFHYgwdt+CtmnnWSLijVlnr10TMnPmw7589PXrznA/EHJXBTcJ77X 0aIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=5j2qPUuswSqkqLTTB/Cg87BrENTi7HCvO32QtQ3hu1w=; b=qVEKmWLDRL3HLavgiry5ptbd3/Nrd3gznPXW4HZbHCjO0tIHZ15GbPWsUXx7ZqG6DE NwOV4Kci00t5zW6QaQ55dLiw0Gdx0IRmbA+doc7+ejVkxSNPWdpFkODA0e7amb8uKHxR 3JBS9HMPF8zCWMgaE/pdeEKwyBWGmpf3V4Hw1WAzRiR2fgmg0brWb+VYrtvQ/s831pUl ck9IwQ9PC7LpQJytUd64lR7sfVwj2CAV4QLYw3ipx9Emo/S7j5KAL2LjBDxBILEc53oi tOHLTwAAX150+ItNJ1IkDofa+9/JJcrvP/TV3yWzGEJdu9suEE84gC5nlud/qyRbOXYO lz5w== X-Gm-Message-State: ANhLgQ2xN2TLLtLpolwHE8XpdJY0mG+y+0+L4FkCdIKG2x+k+nK1mXgw LmbJMpBiFca5yylsEdNVCxvRJAc/30g= X-Google-Smtp-Source: ADFU+vsQInFcplpKvYTZfxrM9NRlgpVeqj1U+LpkzM/Dk5p37Gy7Pbmg9gBZMTrpMyDF6exuNKSD/g== X-Received: by 2002:ac8:1198:: with SMTP id d24mr7425551qtj.105.1583417941984; Thu, 05 Mar 2020 06:19:01 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([179.56.30.174]) by smtp.gmail.com with ESMTPSA id h34sm16363342qtc.62.2020.03.05.06.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2020 06:19:01 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 27C4C3007D2; Thu, 5 Mar 2020 11:18:59 -0300 (-03) Date: Thu, 5 Mar 2020 11:18:59 -0300 From: Alvaro Herrera To: Tom Lane Cc: Pg Hackers , Paul Jungwirth Subject: Re: useless RangeIOData->typiofunc Message-ID: <20200305141859.GA6736@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="jRHKVT23PllUwdXP" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8261.1583361293@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --jRHKVT23PllUwdXP Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2020-Mar-04, Tom Lane wrote: > Hm, I'm not sure that really lessens the cognitive load any, but > if you do commit this please fix the dangling reference you left > in the nearby comment: > > { > TypeCacheEntry *typcache; /* range type's typcache entry */ > - Oid typiofunc; /* element type's I/O function */ > Oid typioparam; /* element type's I/O parameter */ > FmgrInfo proc; /* lookup result for typiofunc */ > ^^^^^^^^^^^^^^^^^^^^^^^^^^^ > } RangeIOData; Thanks -- ISTM it makes more sense to put the FmgrInfo before the typioparam too: typedef struct RangeIOData { TypeCacheEntry *typcache; /* range type's typcache entry */ FmgrInfo proc; /* element type's I/O function */ Oid typioparam; /* element type's I/O parameter */ } RangeIOData; -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --jRHKVT23PllUwdXP Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="range-typiofunc-cleanup-2.patch" diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c index 490bc2ae81..c6bb21219b 100644 --- a/src/backend/utils/adt/rangetypes.c +++ b/src/backend/utils/adt/rangetypes.c @@ -49,9 +49,8 @@ typedef struct RangeIOData { TypeCacheEntry *typcache; /* range type's typcache entry */ - Oid typiofunc; /* element type's I/O function */ + FmgrInfo proc; /* element type's I/O function */ Oid typioparam; /* element type's I/O parameter */ - FmgrInfo proc; /* lookup result for typiofunc */ } RangeIOData; @@ -309,6 +308,7 @@ get_range_io_data(FunctionCallInfo fcinfo, Oid rngtypid, IOFuncSelector func) bool typbyval; char typalign; char typdelim; + Oid typiofunc; cache = (RangeIOData *) MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, sizeof(RangeIOData)); @@ -324,9 +324,9 @@ get_range_io_data(FunctionCallInfo fcinfo, Oid rngtypid, IOFuncSelector func) &typalign, &typdelim, &cache->typioparam, - &cache->typiofunc); + &typiofunc); - if (!OidIsValid(cache->typiofunc)) + if (!OidIsValid(typiofunc)) { /* this could only happen for receive or send */ if (func == IOFunc_receive) @@ -340,7 +340,7 @@ get_range_io_data(FunctionCallInfo fcinfo, Oid rngtypid, IOFuncSelector func) errmsg("no binary output function available for type %s", format_type_be(cache->typcache->rngelemtype->type_id)))); } - fmgr_info_cxt(cache->typiofunc, &cache->proc, + fmgr_info_cxt(typiofunc, &cache->proc, fcinfo->flinfo->fn_mcxt); fcinfo->flinfo->fn_extra = (void *) cache; --jRHKVT23PllUwdXP--