aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gistscan.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-05-15 14:26:51 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-05-15 14:26:51 +0300
commit35fcb1b3d038a501f3f4c87c05630095abaaadab (patch)
treed67f36684fb18b8523e78f13c0a358b376f50d4b /src/backend/access/gist/gistscan.c
parentecd222e770d352121590363ffdf981147a43e976 (diff)
downloadpostgresql-35fcb1b3d038a501f3f4c87c05630095abaaadab.tar.gz
postgresql-35fcb1b3d038a501f3f4c87c05630095abaaadab.zip
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
Diffstat (limited to 'src/backend/access/gist/gistscan.c')
-rw-r--r--src/backend/access/gist/gistscan.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c
index 6f653982302..099849a606b 100644
--- a/src/backend/access/gist/gistscan.c
+++ b/src/backend/access/gist/gistscan.c
@@ -85,6 +85,11 @@ gistbeginscan(PG_FUNCTION_ARGS)
/* workspaces with size dependent on numberOfOrderBys: */
so->distances = palloc(sizeof(double) * scan->numberOfOrderBys);
so->qual_ok = true; /* in case there are zero keys */
+ if (scan->numberOfOrderBys > 0)
+ {
+ scan->xs_orderbyvals = palloc(sizeof(Datum) * scan->numberOfOrderBys);
+ scan->xs_orderbynulls = palloc(sizeof(bool) * scan->numberOfOrderBys);
+ }
scan->opaque = so;