diff options
| author | Tom Lane | 2007-10-19 22:01:45 +0000 |
|---|---|---|
| committer | Tom Lane | 2007-10-19 22:01:45 +0000 |
| commit | 638bd34f899fbcbb6571458be8e8e09d82c70020 (patch) | |
| tree | 3abfc4474c26bda592a8e5bc82a7438d6b13afc3 /src/backend | |
| parent | ba6b0bfd6356400d0f8b08c684b09a9a8fafe259 (diff) | |
Found another small glitch in tsearch API: the two versions of ts_lexize()
are really redundant, since we invented a regdictionary alias type.
We can have just one function, declared as taking regdictionary, and
it will handle both behaviors. Noted while working on documentation.
Diffstat (limited to 'src/backend')
| -rw-r--r-- | src/backend/tsearch/dict.c | 60 |
1 files changed, 9 insertions, 51 deletions
diff --git a/src/backend/tsearch/dict.c b/src/backend/tsearch/dict.c index 15deb71af62..0459a5c1b05 100644 --- a/src/backend/tsearch/dict.c +++ b/src/backend/tsearch/dict.c @@ -7,41 +7,31 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tsearch/dict.c,v 1.1 2007/08/21 01:11:18 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/tsearch/dict.c,v 1.2 2007/10/19 22:01:45 tgl Exp $ * *------------------------------------------------------------------------- */ #include "postgres.h" -#include "funcapi.h" -#include "access/genam.h" -#include "access/heapam.h" -#include "access/skey.h" -#include "catalog/indexing.h" -#include "catalog/namespace.h" -#include "catalog/pg_ts_dict.h" #include "catalog/pg_type.h" #include "tsearch/ts_cache.h" -#include "tsearch/ts_public.h" #include "tsearch/ts_utils.h" -#include "utils/array.h" #include "utils/builtins.h" -#include "utils/fmgroids.h" -#include "utils/rel.h" -#include "utils/syscache.h" /* * Lexize one word by dictionary, mostly debug function */ -static ArrayType * -ts_lexize_workhorse(Oid dictId, text *in) +Datum +ts_lexize(PG_FUNCTION_ARGS) { + Oid dictId = PG_GETARG_OID(0); + text *in = PG_GETARG_TEXT_P(1); + ArrayType *a; TSDictionaryCacheEntry *dict; TSLexeme *res, *ptr; Datum *da; - ArrayType *a; DictSubState dstate = {false, false, NULL}; dict = lookup_ts_dictionary_cache(dictId); @@ -65,12 +55,12 @@ ts_lexize_workhorse(Oid dictId, text *in) } if (!res) - return NULL; + PG_RETURN_NULL(); ptr = res; while (ptr->lexeme) ptr++; - da = (Datum *) palloc(sizeof(Datum) * (ptr - res + 1)); + da = (Datum *) palloc(sizeof(Datum) * (ptr - res)); ptr = res; while (ptr->lexeme) { @@ -95,37 +85,5 @@ ts_lexize_workhorse(Oid dictId, text *in) pfree(res); pfree(da); - return a; -} - -Datum -ts_lexize_byid(PG_FUNCTION_ARGS) -{ - Oid dictId = PG_GETARG_OID(0); - text *in = PG_GETARG_TEXT_P(1); - ArrayType *a; - - a = ts_lexize_workhorse(dictId, in); - - if (a) - PG_RETURN_POINTER(a); - else - PG_RETURN_NULL(); -} - -Datum -ts_lexize_byname(PG_FUNCTION_ARGS) -{ - text *dictname = PG_GETARG_TEXT_P(0); - text *in = PG_GETARG_TEXT_P(1); - Oid dictId; - ArrayType *a; - - dictId = TSDictionaryGetDictid(textToQualifiedNameList(dictname), false); - a = ts_lexize_workhorse(dictId, in); - - if (a) - PG_RETURN_POINTER(a); - else - PG_RETURN_NULL(); + PG_RETURN_POINTER(a); } |
