On Fri, Nov 3, 2017 at 12:37 PM, Connor Wolf < conn...@imaginaryindustries.com> wrote:
> EDIT: That's actually exactly how the example I'm working off of works. > DERP. The SQL is > > CREATE TYPE vptree_area AS > ( > center _int4, > distance float8 > ); > > CREATE OR REPLACE FUNCTION vptree_area_match(_int4, vptree_area) RETURNS > boolean AS > 'MODULE_PATHNAME','vptree_area_match' > LANGUAGE C IMMUTABLE STRICT; > > CREATE OPERATOR <@ ( > LEFTARG = _int4, > RIGHTARG = vptree_area, > PROCEDURE = vptree_area_match, > RESTRICT = contsel, > JOIN = contjoinsel); > > so I just need to understand how to parse out the custom type in my index > operator. > You can see the implementation of vptree_area_match function located in vptree.c. It just calls GetAttributeByNum() function. There is also alternative approach for that implemented in pg_trgm contrib module. It has "text % text" operator which checks if two strings are similar enough. The similarity threshold is defined by pg_trgm.similarity_threshold GUC. Thus, you can also define GUC with threshold distance value. However, it would place some limitations. For instance, you wouldn't be able to use different distance threshold in the same query. ------ Alexander Korotkov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company