Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewwXD-0007sK-GZ for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Mar 2018 21:05:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ewwXC-0002NM-13 for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Mar 2018 21:05:06 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewwXB-0002Mu-N1 for pgsql-hackers@lists.postgresql.org; Fri, 16 Mar 2018 21:05:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewwX8-0006b3-Cs for pgsql-hackers@lists.postgresql.org; Fri, 16 Mar 2018 21:05:04 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w2GL50Mo031554; Fri, 16 Mar 2018 17:05:00 -0400 From: Tom Lane To: Yugo Nagata cc: Anastasia Lubennikova , pgsql-hackers@lists.postgresql.org Subject: Re: CURRENT OF causes an error when IndexOnlyScan is used In-reply-to: <20180315170413.abca0c2b.nagata@sraoss.co.jp> References: <20180201013349.937dfc5f.nagata@sraoss.co.jp> <20180201014444.f78358df.nagata@sraoss.co.jp> <22958.1517451171@sss.pgh.pa.us> <97dc81d3-0ea9-3032-49d9-7983e35fb010@postgrespro.ru> <20180220095252.GA18315@e733.localdomain> <13902.1520877384@sss.pgh.pa.us> <20180315170413.abca0c2b.nagata@sraoss.co.jp> Comments: In-reply-to Yugo Nagata message dated "Thu, 15 Mar 2018 17:04:13 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <31552.1521234300.1@sss.pgh.pa.us> Date: Fri, 16 Mar 2018 17:05:00 -0400 Message-ID: <31553.1521234300@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Yugo Nagata writes: > On Mon, 12 Mar 2018 13:56:24 -0400 > Tom Lane wrote: >> I took a quick look at this, but I'm concerned about a couple of points: > In addition, this patch fixes only nbtree indexes, but the simillar problem > will occur also on GIST indexes which support index-only scan. If we resolve > this bug by fixing index access methods, I think we need to fix all existing > indexes that support index-only scan and also describe the specification in > the documents, comments, or README, etc. for future indexes. Yeah, that's a pretty good point. >> At this point Yugo-san's original patch is starting to look more >> attractive. It's still ugly, but at least it's not imposing a performance >> cost on unrelated queries. > I would like to elaborate my patch if needed and possible. Any suggestion > would be appriciated. I don't think there's much else to be done so far as the IndexOnlyScan case is concerned. However, I notice that somebody's made search_plan_tree accept ForeignScanState and CustomScanState as possible matches for WHERE CURRENT OF, and I find that rather troubling. It seems likely to me that both of those would have the same problem as IndexOnlyScans, ie whatever they're returning is probably a virtual tuple without any ctid field. So we'd get the same unfriendly failure as you complained of originally. I wonder whether it wouldn't be a good idea to provide a way for an FDW or CustomScan provider to return a TID, or at least give a more polite FEATURE_NOT_SUPPORTED error than what happens now. However, that seems more like a new feature than a bug fix; certainly any extension of those APIs is something we'd not back-patch. In the meantime, we could fix execCurrent.c so that it throws FEATURE_NOT_SUPPORTED rather than the current failure if the slot it's looking at doesn't contain a physical tuple. regards, tom lane