diff options
| author | Tom Lane | 2008-04-14 17:05:34 +0000 |
|---|---|---|
| committer | Tom Lane | 2008-04-14 17:05:34 +0000 |
| commit | 9b5c8d45f62bd3d243a40cc84deb93893f2f5122 (patch) | |
| tree | 2d75607f7bdb96cfa1d73a3a36a4b3328118ff08 /contrib/ltree | |
| parent | 10be77c173211a75718f50fe6061862f6a0cb4a2 (diff) | |
Push index operator lossiness determination down to GIST/GIN opclass
"consistent" functions, and remove pg_amop.opreqcheck, as per recent
discussion. The main immediate benefit of this is that we no longer need
8.3's ugly hack of requiring @@@ rather than @@ to test weight-using tsquery
searches on GIN indexes. In future it should be possible to optimize some
other queries better than is done now, by detecting at runtime whether the
index match is exact or not.
Tom Lane, after an idea of Heikki's, and with some help from Teodor.
Diffstat (limited to 'contrib/ltree')
| -rw-r--r-- | contrib/ltree/_ltree_gist.c | 7 | ||||
| -rw-r--r-- | contrib/ltree/ltree.sql.in | 26 | ||||
| -rw-r--r-- | contrib/ltree/ltree_gist.c | 11 | ||||
| -rw-r--r-- | contrib/ltree/uninstall_ltree.sql | 6 |
4 files changed, 30 insertions, 20 deletions
diff --git a/contrib/ltree/_ltree_gist.c b/contrib/ltree/_ltree_gist.c index 34ec2552ca4..1c9b6b03eaa 100644 --- a/contrib/ltree/_ltree_gist.c +++ b/contrib/ltree/_ltree_gist.c @@ -554,10 +554,15 @@ _ltree_consistent(PG_FUNCTION_ARGS) { GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); char *query = (char *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(1))); - ltree_gist *key = (ltree_gist *) DatumGetPointer(entry->key); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ + bool *recheck = (bool *) PG_GETARG_POINTER(4); + ltree_gist *key = (ltree_gist *) DatumGetPointer(entry->key); bool res = false; + /* All cases served by this function are inexact */ + *recheck = true; + switch (strategy) { case 10: diff --git a/contrib/ltree/ltree.sql.in b/contrib/ltree/ltree.sql.in index 1d7c288fc74..4d378823ca0 100644 --- a/contrib/ltree/ltree.sql.in +++ b/contrib/ltree/ltree.sql.in @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/contrib/ltree/ltree.sql.in,v 1.16 2007/11/13 04:24:28 momjian Exp $ */ +/* $PostgreSQL: pgsql/contrib/ltree/ltree.sql.in,v 1.17 2008/04/14 17:05:32 tgl Exp $ */ -- Adjust this setting to control where the objects get created. SET search_path = public; @@ -496,7 +496,7 @@ CREATE TYPE ltree_gist ( ); -CREATE OR REPLACE FUNCTION ltree_consistent(internal,internal,int2) +CREATE OR REPLACE FUNCTION ltree_consistent(internal,internal,int2,oid,internal) RETURNS bool as 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE; CREATE OR REPLACE FUNCTION ltree_compress(internal) @@ -532,7 +532,7 @@ CREATE OPERATOR CLASS gist_ltree_ops OPERATOR 15 @ (ltxtquery, ltree) , OPERATOR 16 ? (ltree, _lquery) , OPERATOR 17 ? (_lquery, ltree) , - FUNCTION 1 ltree_consistent (internal, internal, int2), + FUNCTION 1 ltree_consistent (internal, internal, int2, oid, internal), FUNCTION 2 ltree_union (internal, internal), FUNCTION 3 ltree_compress (internal), FUNCTION 4 ltree_decompress (internal), @@ -822,7 +822,7 @@ CREATE OPERATOR ?@ ( ); --GiST support for ltree[] -CREATE OR REPLACE FUNCTION _ltree_consistent(internal,internal,int2) +CREATE OR REPLACE FUNCTION _ltree_consistent(internal,internal,int2,oid,internal) RETURNS bool AS 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE; @@ -854,15 +854,15 @@ LANGUAGE C IMMUTABLE; CREATE OPERATOR CLASS gist__ltree_ops DEFAULT FOR TYPE _ltree USING gist AS - OPERATOR 10 <@ (_ltree, ltree) RECHECK , - OPERATOR 11 @> (ltree, _ltree) RECHECK , - OPERATOR 12 ~ (_ltree, lquery) RECHECK , - OPERATOR 13 ~ (lquery, _ltree) RECHECK , - OPERATOR 14 @ (_ltree, ltxtquery) RECHECK , - OPERATOR 15 @ (ltxtquery, _ltree) RECHECK , - OPERATOR 16 ? (_ltree, _lquery) RECHECK , - OPERATOR 17 ? (_lquery, _ltree) RECHECK , - FUNCTION 1 _ltree_consistent (internal, internal, int2), + OPERATOR 10 <@ (_ltree, ltree), + OPERATOR 11 @> (ltree, _ltree), + OPERATOR 12 ~ (_ltree, lquery), + OPERATOR 13 ~ (lquery, _ltree), + OPERATOR 14 @ (_ltree, ltxtquery), + OPERATOR 15 @ (ltxtquery, _ltree), + OPERATOR 16 ? (_ltree, _lquery), + OPERATOR 17 ? (_lquery, _ltree), + FUNCTION 1 _ltree_consistent (internal, internal, int2, oid, internal), FUNCTION 2 _ltree_union (internal, internal), FUNCTION 3 _ltree_compress (internal), FUNCTION 4 ltree_decompress (internal), diff --git a/contrib/ltree/ltree_gist.c b/contrib/ltree/ltree_gist.c index dea0b9c3863..17c44b93aac 100644 --- a/contrib/ltree/ltree_gist.c +++ b/contrib/ltree/ltree_gist.c @@ -1,7 +1,7 @@ /* * GiST support for ltree * Teodor Sigaev <teodor@stack.net> - * $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.22 2007/11/16 01:12:24 momjian Exp $ + * $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.23 2008/04/14 17:05:32 tgl Exp $ */ #include "ltree.h" @@ -624,11 +624,16 @@ Datum ltree_consistent(PG_FUNCTION_ARGS) { GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); - void *query = NULL; - ltree_gist *key = (ltree_gist *) DatumGetPointer(entry->key); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ + bool *recheck = (bool *) PG_GETARG_POINTER(4); + ltree_gist *key = (ltree_gist *) DatumGetPointer(entry->key); + void *query = NULL; bool res = false; + /* All cases served by this function are exact */ + *recheck = false; + switch (strategy) { case BTLessStrategyNumber: diff --git a/contrib/ltree/uninstall_ltree.sql b/contrib/ltree/uninstall_ltree.sql index 4d976839a4a..acd07df1e8a 100644 --- a/contrib/ltree/uninstall_ltree.sql +++ b/contrib/ltree/uninstall_ltree.sql @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/contrib/ltree/uninstall_ltree.sql,v 1.5 2007/11/13 04:24:28 momjian Exp $ */ +/* $PostgreSQL: pgsql/contrib/ltree/uninstall_ltree.sql,v 1.6 2008/04/14 17:05:32 tgl Exp $ */ -- Adjust this setting to control where the objects get dropped. SET search_path = public; @@ -15,7 +15,7 @@ DROP FUNCTION _ltree_penalty(internal,internal,internal); DROP FUNCTION _ltree_compress(internal); -DROP FUNCTION _ltree_consistent(internal,internal,int2); +DROP FUNCTION _ltree_consistent(internal,internal,int2,oid,internal); DROP OPERATOR ?@ (_ltree, ltxtquery); @@ -107,7 +107,7 @@ DROP FUNCTION ltree_decompress(internal); DROP FUNCTION ltree_compress(internal); -DROP FUNCTION ltree_consistent(internal,internal,int2); +DROP FUNCTION ltree_consistent(internal,internal,int2,oid,internal); DROP TYPE ltree_gist CASCADE; |
