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 1lT7fR-0004om-1V for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Apr 2021 18:40:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lT7fP-00052x-D7 for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Apr 2021 18:40:11 +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 1lT7fP-00052q-6c for pgsql-hackers@lists.postgresql.org; Sun, 04 Apr 2021 18:40:11 +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 1lT7fJ-0004Sw-0h for pgsql-hackers@lists.postgresql.org; Sun, 04 Apr 2021 18:40:10 +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 134Ie1Xr252441; Sun, 4 Apr 2021 14:40:02 -0400 From: Tom Lane To: Peter Geoghegan cc: pgsql-hackers@lists.postgresql.org, Pavel Borisov Subject: Re: SP-GiST confusion: indexed column's type vs. index column type In-reply-to: <3728741.1617381471@sss.pgh.pa.us> References: <3728741.1617381471@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 02 Apr 2021 12:37:51 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <252439.1617561601.1@sss.pgh.pa.us> Date: Sun, 04 Apr 2021 14:40:01 -0400 Message-ID: <252440.1617561601@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > I propose changing things so that > (B) We enforce that leafType agrees with the opclass opckeytype, > ensuring the index tupdesc can be used for leaf tuples. After looking at PostGIS I realized that a hard restriction of this sort won't fly, because it'd make upgrades impossible for them. They have some lossy SPGiST opclasses, in which leafType is returned as different from the original input datatype. Since up to now we've disallowed the STORAGE clause for user-defined SPGiST opclasses, they are unable to declare these opclasses honestly in existing releases, but it didn't matter. If we enforce that STORAGE matches leafType then their existing opclass definitions won't work in v14, but they can't fix them before upgrading either. So I backed off the complaint about that to be just an amvalidate warning, and pushed it. This means the INCLUDE patch will still have to account for the possibility that the index tupdesc is an inaccurate representation of the actual leaf tuple contents, but we can treat that case less efficiently without feeling bad about it. So we should be able to do something similar for the leaf tupdesc as for the index-only-scan output tupdesc, that is use the relcache's tupdesc if it's got the right first column type, otherwise copy-and-modify that tupdesc. regards, tom lane