Re: CURRENT OF causes an error when IndexOnlyScan is used
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Yugo Nagata <nagata@sraoss.co.jp>
Cc: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>,
pgsql-hackers@lists.postgresql.org
Date: 2018-03-16T21:05:00Z
Lists: pgsql-hackers
Yugo Nagata <nagata@sraoss.co.jp> writes: > On Mon, 12 Mar 2018 13:56:24 -0400 > Tom Lane <tgl@sss.pgh.pa.us> 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
Commits
-
Fix WHERE CURRENT OF when the referenced cursor uses an index-only scan.
- 8f5ac440430a 11.0 landed
- ee7bf0fd9fa7 10.4 landed
- 7de7ddb27a86 9.5.13 landed
- 5b77c11da24a 9.3.23 landed
- 12d18b4870a2 9.6.9 landed
- 0a0721f84c40 9.4.18 landed