diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-12-03 20:52:18 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-12-03 20:53:29 -0500 |
commit | 554506871bd3a73a5d9fa4ee3aa0b0fbf406f8ab (patch) | |
tree | 92d303d13214cc8dc37d5891f1df3a66b6f3ab53 /src/backend/access/gist/gist.c | |
parent | c0a4d3e0511b4d1f7996451329deaa2acd0e18fa (diff) | |
download | postgresql-554506871bd3a73a5d9fa4ee3aa0b0fbf406f8ab.tar.gz postgresql-554506871bd3a73a5d9fa4ee3aa0b0fbf406f8ab.zip |
KNNGIST, otherwise known as order-by-operator support for GIST.
This commit represents a rather heavily editorialized version of
Teodor's builtin_knngist_itself-0.8.2 and builtin_knngist_proc-0.8.1
patches. I redid the opclass API to add a separate Distance method
instead of turning the Consistent method into an illogical mess,
fixed some bit-rot in the rbtree interfaces, and generally worked over
the code style and comments.
There's still no non-code documentation to speak of, but I'll work on
that separately. Some contrib-module changes are also yet to come
(right now, point <-> point is the only KNN-ified operator).
Teodor Sigaev and Tom Lane
Diffstat (limited to 'src/backend/access/gist/gist.c')
-rw-r--r-- | src/backend/access/gist/gist.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c index 8c2dbc940f4..d6aaea2162d 100644 --- a/src/backend/access/gist/gist.c +++ b/src/backend/access/gist/gist.c @@ -1030,6 +1030,9 @@ gistnewroot(Relation r, Buffer buffer, IndexTuple *itup, int len, ItemPointer ke END_CRIT_SECTION(); } +/* + * Fill a GISTSTATE with information about the index + */ void initGISTstate(GISTSTATE *giststate, Relation index) { @@ -1064,6 +1067,13 @@ initGISTstate(GISTSTATE *giststate, Relation index) fmgr_info_copy(&(giststate->equalFn[i]), index_getprocinfo(index, i + 1, GIST_EQUAL_PROC), CurrentMemoryContext); + /* opclasses are not required to provide a Distance method */ + if (OidIsValid(index_getprocid(index, i + 1, GIST_DISTANCE_PROC))) + fmgr_info_copy(&(giststate->distanceFn[i]), + index_getprocinfo(index, i + 1, GIST_DISTANCE_PROC), + CurrentMemoryContext); + else + giststate->distanceFn[i].fn_oid = InvalidOid; } } |