]> granicus.if.org Git - postgresql/commitdiff
Introduce filtering dictionary support to tsearch. Propagate --nolocale option
authorTeodor Sigaev <teodor@sigaev.ru>
Tue, 18 Aug 2009 10:30:41 +0000 (10:30 +0000)
committerTeodor Sigaev <teodor@sigaev.ru>
Tue, 18 Aug 2009 10:30:41 +0000 (10:30 +0000)
to CREATE DATABASE command in pg_regress to allow correct checking of
locale-sensitive contrib modules.

src/backend/tsearch/ts_parse.c
src/include/tsearch/ts_public.h
src/test/regress/pg_regress.c

index f503306aa00c771caa4334a5cc0eef0a9fc3c47e..e895761836b7cd9169e2f6c844edee90908421cf 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/tsearch/ts_parse.c,v 1.13 2009/07/16 06:33:44 petere Exp $
+ *       $PostgreSQL: pgsql/src/backend/tsearch/ts_parse.c,v 1.14 2009/08/18 10:30:41 teodor Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -29,7 +29,6 @@ typedef struct ParsedLex
        int                     type;
        char       *lemm;
        int                     lenlemm;
-       bool            resfollow;
        struct ParsedLex *next;
 } ParsedLex;
 
@@ -189,6 +188,8 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem)
                while (ld->towork.head)
                {
                        ParsedLex  *curVal = ld->towork.head;
+                       char       *curValLemm = curVal->lemm;
+                       int                     curValLenLemm = curVal->lenlemm;
 
                        map = ld->cfg->map + curVal->type;
 
@@ -208,8 +209,8 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem)
                                res = (TSLexeme *) DatumGetPointer(FunctionCall4(
                                                                                                                         &(dict->lexize),
                                                                                         PointerGetDatum(dict->dictData),
-                                                                                          PointerGetDatum(curVal->lemm),
-                                                                                         Int32GetDatum(curVal->lenlemm),
+                                                                                            PointerGetDatum(curValLemm),
+                                                                                           Int32GetDatum(curValLenLemm),
                                                                                          PointerGetDatum(&ld->dictState)
                                                                                                                                 ));
 
@@ -231,6 +232,13 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem)
                                if (!res)               /* dictionary doesn't know this lexeme */
                                        continue;
 
+                               if ( res->flags & TSL_FILTER )
+                               {
+                                       curValLemm = res->lexeme;
+                                       curValLenLemm = strlen(res->lexeme);
+                                       continue;
+                               }
+
                                RemoveHead(ld);
                                setCorrLex(ld, correspondLexem);
                                return res;
index 61a3d220255941a26add1b8c0072cdd22467c1e2..ffdc698f41db71862651878b6cffa39eabd4c13f 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1998-2009, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/include/tsearch/ts_public.h,v 1.15 2009/07/16 06:33:45 petere Exp $
+ * $PostgreSQL: pgsql/src/include/tsearch/ts_public.h,v 1.16 2009/08/18 10:30:41 teodor Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -101,6 +101,7 @@ typedef struct
 
 #define TSL_ADDPOS             0x01
 #define TSL_PREFIX             0x02
+#define TSL_FILTER             0x04
 
 /*
  * Struct for supporting complex dictionaries like thesaurus.
index a2bc0af1a3e15ba0f745c7a93ef4ef8e5e873a4c..3f27dbfec17ffb704d029347d0b357952691627a 100644 (file)
@@ -11,7 +11,7 @@
  * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.63 2009/06/11 14:49:15 momjian Exp $
+ * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.64 2009/08/18 10:30:41 teodor Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1767,9 +1767,11 @@ create_database(const char *dbname)
         */
        header(_("creating database \"%s\""), dbname);
        if (encoding)
-               psql_command("postgres", "CREATE DATABASE \"%s\" TEMPLATE=template0 ENCODING='%s'", dbname, encoding);
+               psql_command("postgres", "CREATE DATABASE \"%s\" TEMPLATE=template0 ENCODING='%s'%s", dbname, encoding,
+                                        (nolocale) ? " LC_COLLATE='C' LC_CTYPE='C'" : "");
        else
-               psql_command("postgres", "CREATE DATABASE \"%s\" TEMPLATE=template0", dbname);
+               psql_command("postgres", "CREATE DATABASE \"%s\" TEMPLATE=template0%s", dbname,
+                                        (nolocale) ? " LC_COLLATE='C' LC_CTYPE='C'" : "");
        psql_command(dbname,
                                 "ALTER DATABASE \"%s\" SET lc_messages TO 'C';"
                                 "ALTER DATABASE \"%s\" SET lc_monetary TO 'C';"