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 1j9c14-0008RV-62 for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Mar 2020 21:57:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j9c12-0001TY-9D for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Mar 2020 21:57:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j9c11-0001TR-Sb for pgsql-hackers@lists.postgresql.org; Wed, 04 Mar 2020 21:57:20 +0000 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j9c0z-0000w2-FJ for pgsql-hackers@lists.postgresql.org; Wed, 04 Mar 2020 21:57:19 +0000 Received: by mail-qk1-x734.google.com with SMTP id f198so3265667qke.11 for ; Wed, 04 Mar 2020 13:57:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition :content-transfer-encoding:user-agent; bh=g30zNd4WKy4Yo6k+nCyjAEl3ohHGDmVQbMDQq3KN9SE=; b=NFMAV/JR5aHc5WMs1pnZqZv4iPKBMRJy4fNqEXrZH3UTP8ea5OpgIY3uWlC8BcWmjy 4LbLiCbZG5m+uaUVTHipOAEiYRtk9LIoHobNWkE1HRELIkhawgzYtqCCKQaz9qq8GBLP M9+AK3QeSjiCXhesg6R92nndk4/dLoOYifiiZvcZTUaWHlyOh4isLgef8EniZBFdkokn pJLdqanF1VXtKRyEaLBPpuHnxaGo8XQTOiFMVKc5Sg2SnASCSq5cethvOLt2MVWbECiV HmZJoHpxyoRQjIdRoCLybQF22GGHnYq/emNKQ6s2ID1KEnVUTdQndMdgz1LtFnIo5H/0 63qw== 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:subject:message-id:mime-version :content-disposition:content-transfer-encoding:user-agent; bh=g30zNd4WKy4Yo6k+nCyjAEl3ohHGDmVQbMDQq3KN9SE=; b=jSFoYP6nBMnXMGjdPH0hYOCefNgBl60A1GyAAPsX9RC3eKWzBjcA5njKDX1UvDvlyR +1/21v1rl4TC4VgfToyNL9XI3a8SPLpjZ9ctRUcum9muf6WGtYnUR3HG6JNrMWqOOn8h 6bos5nFjtDGWmqmBei1P5/3hl7buQAiATPLSiHRHe3ypc3lkBzhYSxEN+YNpvjy7bSC+ x4Oz3sbGwJpPf+X+lTD8eU5/v1JpgyLtqmpBNMt5ttP9RNjn5RGSL8CKJLoynid/CanY ZR1tK/S9Ygljbvp9N8r5BTLme9O64bgRQ5SLsItsXa1MpdrsIKSK2X6Y8BAaQCazIO/c njDQ== X-Gm-Message-State: ANhLgQ0moMS0Uw75WksvmiteOgK38JERoRYqm8p22/xZJbnAN1y7x6YY y5oOhhBHaAVO/6ju/sD8JCxIHj3DkqzACEhx/GEMdoCg4apHRkmtkX6PszsZ7iH3O/yHE5y93Y3 t5qYyfG2VrTABHyiaAanZOia1ydS8O5KFpEx536gNw2dP6nGXVYpXBOpJPCbkhJMIg7TXJrIHoX V4B72f3owkTgqNVN8l X-Google-Smtp-Source: ADFU+vuakQQwShWemD2wvEstQ3H6gNq+QJmS2rc+CRwNc+Eep/hGsiQYnz7hL4EkFxh4TeCqjFxHbw== X-Received: by 2002:a37:a6cf:: with SMTP id p198mr5158861qke.298.1583359035302; Wed, 04 Mar 2020 13:57:15 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([190.121.31.1]) by smtp.gmail.com with ESMTPSA id v21sm12069175qto.97.2020.03.04.13.57.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 13:57:14 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 711E73007D2; Wed, 4 Mar 2020 18:57:11 -0300 (-03) Date: Wed, 4 Mar 2020 18:57:11 -0300 From: Alvaro Herrera To: Pg Hackers Subject: useless RangeIOData->typiofunc Message-ID: <20200304215711.GA8732@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="x+6KMIRAuhnl3hBn" Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --x+6KMIRAuhnl3hBn Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit I noticed while going over the multirange types patch that it adds a pointless typiofunc cached OID to a struct used for I/O functions' fn_extra. It seems to go completely unused, so I checked range types (which this was cribbed from) and indeed, it is completely unused there either. My guess is that it was in turn cribbed from array's ArrayMetaState, which is considerably more sophisticated; I suspect nobody noticed that caching it was pointless. Here's a patch to remove it from rangetypes.c. It doesn't really waste much memory anyway, but removing it lessens the cognitive load by one or two bits. -- Álvaro Herrera --x+6KMIRAuhnl3hBn Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="range-typiofunc-cleanup.patch" diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c index 490bc2ae81..412322c6fa 100644 --- a/src/backend/utils/adt/rangetypes.c +++ b/src/backend/utils/adt/rangetypes.c @@ -49,7 +49,6 @@ typedef struct RangeIOData { 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; @@ -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; --x+6KMIRAuhnl3hBn--