1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-24 01:29:19 +03:00

Add comments and a missing CHECK_FOR_INTERRUPTS in ts_headline.

I just spent an annoying amount of time reverse-engineering the
100%-undocumented API between ts_headline and the text search
parser's prsheadline function.  Add some commentary about that
while it's fresh in mind.  Also remove some unused macros in
wparser_def.c.

While at it, I noticed that when commit 78e73e875 added a
CHECK_FOR_INTERRUPTS call in TS_execute_recurse, it missed
doing so in the parallel function TS_phrase_execute, which
surely needs one just as much.

Back-patch because of the missing CHECK_FOR_INTERRUPTS.
Might as well back-patch the rest of this too.
This commit is contained in:
Tom Lane
2022-11-21 17:07:07 -05:00
parent f686ae82f2
commit 5644d6f909
4 changed files with 60 additions and 21 deletions

View File

@@ -433,6 +433,8 @@ parsetext(Oid cfgId, ParsedText *prs, char *buf, int buflen)
/*
* Headline framework
*/
/* Add a word to prs->words[] */
static void
hladdword(HeadlineParsedText *prs, char *buf, int buflen, int type)
{
@@ -449,6 +451,14 @@ hladdword(HeadlineParsedText *prs, char *buf, int buflen, int type)
prs->curwords++;
}
/*
* Add pos and matching-query-item data to the just-added word.
* Here, buf/buflen represent a processed lexeme, not raw token text.
*
* If the query contains more than one matching item, we replicate
* the last-added word so that each item can be pointed to. The
* duplicate entries are marked with repeated = 1.
*/
static void
hlfinditem(HeadlineParsedText *prs, TSQuery query, int32 pos, char *buf, int buflen)
{
@@ -589,6 +599,9 @@ hlparsetext(Oid cfgId, HeadlineParsedText *prs, TSQuery query, char *buf, int bu
FunctionCall1(&(prsobj->prsend), PointerGetDatum(prsdata));
}
/*
* Generate the headline, as a text object, from HeadlineParsedText.
*/
text *
generateHeadline(HeadlineParsedText *prs)
{

View File

@@ -1914,10 +1914,6 @@ prsd_end(PG_FUNCTION_ARGS)
*/
/* token type classification macros */
#define LEAVETOKEN(x) ( (x)==SPACE )
#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 HLIDREPLACE(x) ( (x)==TAG_T )
#define HLIDSKIP(x) ( (x)==URL_T || (x)==NUMHWORD || (x)==ASCIIHWORD || (x)==HWORD )