1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-25 01:02:05 +03:00

Support indexing of regular-expression searches in contrib/pg_trgm.

This works by extracting trigrams from the given regular expression,
in generally the same spirit as the previously-existing support for
LIKE searches, though of course the details are far more complicated.

Currently, only GIN indexes are supported.  We might be able to make
it work with GiST indexes later.

The implementation includes adding API functions to backend/regex/
to provide a view of the search NFA created from a regular expression.
These functions are meant to be generic enough to be supportable in
a standalone version of the regex library, should that ever happen.

Alexander Korotkov, reviewed by Heikki Linnakangas and Tom Lane
This commit is contained in:
Tom Lane
2013-04-09 01:05:55 -04:00
parent e60d20a35e
commit 3ccae48f44
17 changed files with 2865 additions and 43 deletions

View File

@ -6746,6 +6746,7 @@ gincost_pattern(IndexOptInfo *index, int indexcol,
GinQualCounts *counts)
{
Oid extractProcOid;
Oid collation;
int strategy_op;
Oid lefttype,
righttype;
@ -6783,7 +6784,16 @@ gincost_pattern(IndexOptInfo *index, int indexcol,
get_rel_name(index->indexoid));
}
OidFunctionCall7(extractProcOid,
/*
* Choose collation to pass to extractProc (should match initGinState).
*/
if (OidIsValid(index->indexcollations[indexcol]))
collation = index->indexcollations[indexcol];
else
collation = DEFAULT_COLLATION_OID;
OidFunctionCall7Coll(extractProcOid,
collation,
query,
PointerGetDatum(&nentries),
UInt16GetDatum(strategy_op),