From 35fcb1b3d038a501f3f4c87c05630095abaaadab Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Fri, 15 May 2015 14:26:51 +0300 Subject: Allow GiST distance function to return merely a lower-bound. The distance function can now set *recheck = false, like index quals. The executor will then re-check the ORDER BY expressions, and use a queue to reorder the results on the fly. This makes it possible to do kNN-searches on polygons and circles, which don't store the exact value in the index, but just a bounding box. Alexander Korotkov and me --- src/include/access/genam.h | 3 +++ src/include/access/relscan.h | 9 +++++++++ 2 files changed, 12 insertions(+) (limited to 'src/include/access') diff --git a/src/include/access/genam.h b/src/include/access/genam.h index d86590ac11..f129c4b58f 100644 --- a/src/include/access/genam.h +++ b/src/include/access/genam.h @@ -147,7 +147,10 @@ extern void index_restrpos(IndexScanDesc scan); extern ItemPointer index_getnext_tid(IndexScanDesc scan, ScanDirection direction); extern HeapTuple index_fetch_heap(IndexScanDesc scan); +extern bool index_get_heap_values(IndexScanDesc scan, ItemPointer heapPtr, + Datum values[INDEX_MAX_KEYS], bool isnull[INDEX_MAX_KEYS]); extern HeapTuple index_getnext(IndexScanDesc scan, ScanDirection direction); + extern int64 index_getbitmap(IndexScanDesc scan, TIDBitmap *bitmap); extern IndexBulkDeleteResult *index_bulk_delete(IndexVacuumInfo *info, diff --git a/src/include/access/relscan.h b/src/include/access/relscan.h index 9bb63622fe..865d36403a 100644 --- a/src/include/access/relscan.h +++ b/src/include/access/relscan.h @@ -91,6 +91,15 @@ typedef struct IndexScanDescData /* NB: if xs_cbuf is not InvalidBuffer, we hold a pin on that buffer */ bool xs_recheck; /* T means scan keys must be rechecked */ + /* + * When fetching with an ordering operator, the values of the ORDER BY + * expressions of the last returned tuple, according to the index. If + * xs_recheck is true, these need to be rechecked just like the scan keys, + * and the values returned here are a lower-bound on the actual values. + */ + Datum *xs_orderbyvals; + bool *xs_orderbynulls; + /* state data for traversing HOT chains in index_getnext */ bool xs_continue_hot; /* T if must keep walking HOT chain */ } IndexScanDescData; -- cgit v1.2.1