Add error check for lossy distance functions in index-only scans.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 23 May 2015 20:24:31 +0000 (16:24 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 23 May 2015 20:24:31 +0000 (16:24 -0400)
Maybe we should actually support this, but for the moment let's just
throw an error if the opclass tries it.

src/backend/executor/nodeIndexonlyscan.c

index 61bd644ab7135c446e3b467c455f415a917f5cde..976c77b76c653108791ba469d38b12504bf37fe7 100644 (file)
@@ -165,6 +165,19 @@ IndexOnlyNext(IndexOnlyScanState *node)
            }
        }
 
+       /*
+        * We don't currently support rechecking ORDER BY distances.  (In
+        * principle, if the index can support retrieval of the originally
+        * indexed value, it should be able to produce an exact distance
+        * calculation too.  So it's not clear that adding code here for
+        * recheck/re-sort would be worth the trouble.  But we should at least
+        * throw an error if someone tries it.)
+        */
+       if (scandesc->numberOfOrderBys > 0 && scandesc->xs_recheckorderby)
+           ereport(ERROR,
+                   (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+                    errmsg("lossy distance functions are not supported in index-only scans")));
+
        /*
         * Predicate locks for index-only scans must be acquired at the page
         * level when the heap is not accessed, since tuple-level predicate