]> granicus.if.org Git - postgresql/commitdiff
Found another small glitch in tsearch API: the two versions of ts_lexize()
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 19 Oct 2007 22:01:45 +0000 (22:01 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 19 Oct 2007 22:01:45 +0000 (22:01 +0000)
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.

src/backend/tsearch/dict.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.h
src/include/tsearch/ts_utils.h

index 15deb71af620512bbdd0c2173f511f67fb5b2a91..0459a5c1b058d944ce09bc0bd4dc3b4c1cb32830 100644 (file)
@@ -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);
 }
index 8342727f0f47ff4fddee1a78dde6523af28ac02f..467277d8ad0ac11562c8ffaab355d6b57264bea7 100644 (file)
@@ -37,7 +37,7 @@
  * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.433 2007/10/19 19:48:34 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.434 2007/10/19 22:01:45 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -53,6 +53,6 @@
  */
 
 /*                                                     yyyymmddN */
-#define CATALOG_VERSION_NO     200710191
+#define CATALOG_VERSION_NO     200710192
 
 #endif
index 045c6e52f565e7300f60dd1f2ff74c4148522d00..bd3eb5abc3cf74f501657cdd2f48d434d85bd4d8 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.475 2007/10/19 19:48:34 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.476 2007/10/19 22:01:45 tgl Exp $
  *
  * NOTES
  *       The script catalog/genbki.sh reads this file and generates .bki
@@ -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_ ));
index 93da9cb4a9d2bcd2cac74596390f89ea98097d0f..60f176054ae55c6d41a7a542044504c6dc59afbf 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright (c) 1998-2007, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/include/tsearch/ts_utils.h,v 1.4 2007/09/10 12:36:41 teodor Exp $
+ * $PostgreSQL: pgsql/src/include/tsearch/ts_utils.h,v 1.5 2007/10/19 22:01:45 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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