]> granicus.if.org Git - postgresql/commitdiff
Fix URL generation in headline. Only tag lexeme will be replaced by space.
authorTeodor Sigaev <teodor@sigaev.ru>
Thu, 15 Jan 2009 17:06:03 +0000 (17:06 +0000)
committerTeodor Sigaev <teodor@sigaev.ru>
Thu, 15 Jan 2009 17:06:03 +0000 (17:06 +0000)
Per http://archives.postgresql.org/pgsql-bugs/2008-12/msg00013.php

src/backend/tsearch/ts_parse.c
src/backend/tsearch/wparser_def.c
src/include/tsearch/ts_public.h

index 22862bdb806b363069a8c84473cb56b2e4b43296..9f12d66bf6e38a2f61b1449dad040a516641ff88 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/tsearch/ts_parse.c,v 1.7 2008/01/01 19:45:52 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/tsearch/ts_parse.c,v 1.7.2.1 2009/01/15 17:06:03 teodor Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -607,7 +607,7 @@ generateHeadline(HeadlineParsedText *prs)
                                *ptr = ' ';
                                ptr++;
                        }
-                       else
+                       else if (!wrd->skip)
                        {
                                if (wrd->selected)
                                {
index 24f371ab95dd725f6fb7cd894834016c7da9406b..0ab06ad0f15bf57986381539ef122e40f6474e52 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/tsearch/wparser_def.c,v 1.14.2.2 2009/01/15 17:05:39 teodor Exp $
+ *       $PostgreSQL: pgsql/src/backend/tsearch/wparser_def.c,v 1.14.2.3 2009/01/15 17:06:03 teodor Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1587,10 +1587,11 @@ prsd_end(PG_FUNCTION_ARGS)
 #define COMPLEXTOKEN(x) ( (x)==URL_T || (x)==NUMHWORD || (x)==ASCIIHWORD || (x)==HWORD )
 #define ENDPUNCTOKEN(x) ( (x)==SPACE )
 
-#define TS_IDIGNORE(x) ( (x)==TAG_T || (x)==PROTOCOL || (x)==SPACE || (x)==XMLENTITY )
-#define HLIDIGNORE(x) ( (x)==URL_T || (x)==TAG_T || (x)==NUMHWORD || (x)==ASCIIHWORD || (x)==HWORD )
-#define XMLHLIDIGNORE(x) ( (x)==URL_T || (x)==NUMHWORD || (x)==ASCIIHWORD || (x)==HWORD )
-#define NONWORDTOKEN(x) ( (x)==SPACE || HLIDIGNORE(x) )
+#define TS_IDIGNORE(x)  ( (x)==TAG_T || (x)==PROTOCOL || (x)==SPACE || (x)==XMLENTITY )
+#define HLIDREPLACE(x)  ( (x)==TAG_T )
+#define HLIDSKIP(x)     ( (x)==URL_T || (x)==NUMHWORD || (x)==ASCIIHWORD || (x)==HWORD )
+#define XMLHLIDSKIP(x)  ( (x)==URL_T || (x)==NUMHWORD || (x)==ASCIIHWORD || (x)==HWORD )
+#define NONWORDTOKEN(x) ( (x)==SPACE || HLIDREPLACE(x) || HLIDSKIP(x) )
 #define NOENDTOKEN(x)  ( NONWORDTOKEN(x) || (x)==SCIENTIFIC || (x)==VERSIONNUMBER || (x)==DECIMAL || (x)==SIGNEDINT || (x)==UNSIGNEDINT || TS_IDIGNORE(x) )
 
 typedef struct
@@ -1867,13 +1868,15 @@ prsd_headline(PG_FUNCTION_ARGS)
                        prs->words[i].selected = 1;
                if (highlight == 0)
                {
-                       if (HLIDIGNORE(prs->words[i].type))
+                       if (HLIDREPLACE(prs->words[i].type))
                                prs->words[i].replace = 1;
+                       else if ( HLIDSKIP(prs->words[i].type) )
+                               prs->words[i].skip = 1;
                }
                else
                {
-                       if (XMLHLIDIGNORE(prs->words[i].type))
-                               prs->words[i].replace = 1;
+                       if (XMLHLIDSKIP(prs->words[i].type))
+                               prs->words[i].skip = 1;
                }
 
                prs->words[i].in = (prs->words[i].repeated) ? 0 : 1;
index 8f21abf032cd1a02751950efb3b612e9969268a8..071965b132a114650999e0cbc4d11a8facf8b7e7 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1998-2008, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/include/tsearch/ts_public.h,v 1.8 2008/01/01 19:45:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/tsearch/ts_public.h,v 1.8.2.1 2009/01/15 17:06:03 teodor Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -38,7 +38,8 @@ typedef struct
                                in:1,
                                replace:1,
                                repeated:1,
-                               unused:4,
+                               skip:1,
+                               unused:3,
                                type:8,
                                len:16;
        char       *word;