diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-04-14 17:05:34 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-04-14 17:05:34 +0000 |
commit | 9b5c8d45f62bd3d243a40cc84deb93893f2f5122 (patch) | |
tree | 2d75607f7bdb96cfa1d73a3a36a4b3328118ff08 /contrib/pg_trgm/trgm_gist.c | |
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/pg_trgm/trgm_gist.c')
-rw-r--r-- | contrib/pg_trgm/trgm_gist.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/contrib/pg_trgm/trgm_gist.c b/contrib/pg_trgm/trgm_gist.c index 4286928d348..9cf88dc45bd 100644 --- a/contrib/pg_trgm/trgm_gist.c +++ b/contrib/pg_trgm/trgm_gist.c @@ -159,12 +159,19 @@ gtrgm_decompress(PG_FUNCTION_ARGS) Datum gtrgm_consistent(PG_FUNCTION_ARGS) { - text *query = (text *) PG_GETARG_TEXT_P(1); - TRGM *key = (TRGM *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key); + GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); + text *query = PG_GETARG_TEXT_P(1); + /* StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); */ + /* Oid subtype = PG_GETARG_OID(3); */ + bool *recheck = (bool *) PG_GETARG_POINTER(4); + TRGM *key = (TRGM *) DatumGetPointer(entry->key); TRGM *qtrg = generate_trgm(VARDATA(query), VARSIZE(query) - VARHDRSZ); - int res = false; + bool res = false; + + /* All cases served by this function are exact */ + *recheck = false; - if (GIST_LEAF((GISTENTRY *) PG_GETARG_POINTER(0))) + if (GIST_LEAF(entry)) { /* all leafs contains orig trgm */ float4 tmpsml = cnt_sml(key, qtrg); |