summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2007-10-19 22:01:45 +0000
committerTom Lane2007-10-19 22:01:45 +0000
commitab46ae15a6e85707dc576326467e2f9cd8c75abd (patch)
tree75bd58dcb3c0570b149b5047113dbce9cf7c43de
parent44e3346ae76fd71c631d77eed693b5aaca79e007 (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.
-rw-r--r--src/backend/tsearch/dict.c58
-rw-r--r--src/include/catalog/catversion.h2
-rw-r--r--src/include/catalog/pg_proc.h4
-rw-r--r--src/include/tsearch/ts_utils.h3
4 files changed, 11 insertions, 56 deletions
diff --git a/src/backend/tsearch/dict.c b/src/backend/tsearch/dict.c
index 5e821dbd34..8ef1a7c5e6 100644
--- a/src/backend/tsearch/dict.c
+++ b/src/backend/tsearch/dict.c
@@ -13,35 +13,25 @@
*/
#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);
}
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 4e48028fce..58a9af7cd2 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200710191
+#define CATALOG_VERSION_NO 200710192
#endif
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index cbfc636a7f..776e5a21ec 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -4326,9 +4326,7 @@ DESCR("");
DATA(insert OID = 3721 ( prsd_lextype PGNSP PGUID 12 1 0 f f t f i 1 2281 "2281" _null_ _null_ _null_ prsd_lextype - _null_ _null_ ));
DESCR("");
-DATA(insert OID = 3723 ( ts_lexize PGNSP PGUID 12 1 0 f f t f i 2 1009 "26 25" _null_ _null_ _null_ ts_lexize_byid - _null_ _null_ ));
-DESCR("normalize one word by dictionary");
-DATA(insert OID = 3724 ( ts_lexize PGNSP PGUID 12 1 0 f f t f s 2 1009 "25 25" _null_ _null_ _null_ ts_lexize_byname - _null_ _null_ ));
+DATA(insert OID = 3723 ( ts_lexize PGNSP PGUID 12 1 0 f f t f i 2 1009 "3769 25" _null_ _null_ _null_ ts_lexize - _null_ _null_ ));
DESCR("normalize one word by dictionary");
DATA(insert OID = 3725 ( dsimple_init PGNSP PGUID 12 1 0 f f t f i 1 2281 "2281" _null_ _null_ _null_ dsimple_init - _null_ _null_ ));
diff --git a/src/include/tsearch/ts_utils.h b/src/include/tsearch/ts_utils.h
index 88264f3e47..90cd218b6e 100644
--- a/src/include/tsearch/ts_utils.h
+++ b/src/include/tsearch/ts_utils.h
@@ -222,8 +222,7 @@ extern Datum prsd_lextype(PG_FUNCTION_ARGS);
/*
* Dictionary interface to SQL
*/
-extern Datum ts_lexize_byid(PG_FUNCTION_ARGS);
-extern Datum ts_lexize_byname(PG_FUNCTION_ARGS);
+extern Datum ts_lexize(PG_FUNCTION_ARGS);
/*
* Simple built-in dictionary