PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <limits.h>
#include <wctype.h>
#include "commands/defrem.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "tsearch/ts_public.h"
#include "tsearch/ts_type.h"
#include "tsearch/ts_utils.h"
#include "utils/builtins.h"
#include "utils/pg_locale.h"
Go to the source code of this file.
Data Structures | |
struct | TParserStateActionItem |
struct | TParserPosition |
struct | TParser |
struct | TParserStateAction |
struct | CoverPos |
struct | hlCheck |
Macros | |
#define | ASCIIWORD 1 |
#define | WORD_T 2 |
#define | NUMWORD 3 |
#define | EMAIL 4 |
#define | URL_T 5 |
#define | HOST 6 |
#define | SCIENTIFIC 7 |
#define | VERSIONNUMBER 8 |
#define | NUMPARTHWORD 9 |
#define | PARTHWORD 10 |
#define | ASCIIPARTHWORD 11 |
#define | SPACE 12 |
#define | TAG_T 13 |
#define | PROTOCOL 14 |
#define | NUMHWORD 15 |
#define | ASCIIHWORD 16 |
#define | HWORD 17 |
#define | URLPATH 18 |
#define | FILEPATH 19 |
#define | DECIMAL_T 20 |
#define | SIGNEDINT 21 |
#define | UNSIGNEDINT 22 |
#define | XMLENTITY 23 |
#define | LASTNUM 23 |
#define | A_NEXT 0x0000 |
#define | A_BINGO 0x0001 |
#define | A_POP 0x0002 |
#define | A_PUSH 0x0004 |
#define | A_RERUN 0x0008 |
#define | A_CLEAR 0x0010 |
#define | A_MERGE 0x0020 |
#define | A_CLRALL 0x0040 |
#define | p_iswhat(type, nonascii) |
#define | TPARSERSTATEACTION(state) { CppConcat(action,state), state } |
#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_T || (x)==SIGNEDINT || (x)==UNSIGNEDINT || TS_IDIGNORE(x) ) |
#define | INTERESTINGWORD(j) (prs->words[j].item && !prs->words[j].repeated) |
#define | BADENDPOINT(j) |
Typedefs | |
typedef int(* | TParserCharTest) (struct TParser *) |
typedef void(* | TParserSpecial) (struct TParser *) |
typedef struct TParserPosition | TParserPosition |
typedef struct TParser | TParser |
Functions | |
static bool | TParserGet (TParser *prs) |
static TParserPosition * | newTParserPosition (TParserPosition *prev) |
static TParser * | TParserInit (char *str, int len) |
static TParser * | TParserCopyInit (const TParser *orig) |
static void | TParserClose (TParser *prs) |
static void | TParserCopyClose (TParser *prs) |
p_iswhat (alnum, 1) | |
static int | p_isEOF (TParser *prs) |
static int | p_iseqC (TParser *prs) |
static int | p_isneC (TParser *prs) |
static int | p_isascii (TParser *prs) |
static int | p_isasclet (TParser *prs) |
static int | p_isurlchar (TParser *prs) |
void | _make_compiler_happy (void) |
static void | SpecialTags (TParser *prs) |
static void | SpecialFURL (TParser *prs) |
static void | SpecialHyphen (TParser *prs) |
static void | SpecialVerVersion (TParser *prs) |
static int | p_isstophost (TParser *prs) |
static int | p_isignore (TParser *prs) |
static int | p_ishost (TParser *prs) |
static int | p_isURLPath (TParser *prs) |
static int | p_isspecial (TParser *prs) |
Datum | prsd_lextype (PG_FUNCTION_ARGS) |
Datum | prsd_start (PG_FUNCTION_ARGS) |
Datum | prsd_nexttoken (PG_FUNCTION_ARGS) |
Datum | prsd_end (PG_FUNCTION_ARGS) |
static TSTernaryValue | checkcondition_HL (void *opaque, QueryOperand *val, ExecPhraseData *data) |
static bool | hlCover (HeadlineParsedText *prs, TSQuery query, List *locations, int *nextpos, int *p, int *q) |
static void | mark_fragment (HeadlineParsedText *prs, bool highlightall, int startpos, int endpos) |
static void | get_next_fragment (HeadlineParsedText *prs, int *startpos, int *endpos, int *curlen, int *poslen, int max_words) |
static void | mark_hl_fragments (HeadlineParsedText *prs, TSQuery query, List *locations, bool highlightall, int shortword, int min_words, int max_words, int max_fragments) |
static void | mark_hl_words (HeadlineParsedText *prs, TSQuery query, List *locations, bool highlightall, int shortword, int min_words, int max_words) |
Datum | prsd_headline (PG_FUNCTION_ARGS) |
#define A_BINGO 0x0001 |
Definition at line 221 of file wparser_def.c.
#define A_CLEAR 0x0010 |
Definition at line 225 of file wparser_def.c.
#define A_CLRALL 0x0040 |
Definition at line 227 of file wparser_def.c.
#define A_MERGE 0x0020 |
Definition at line 226 of file wparser_def.c.
#define A_NEXT 0x0000 |
Definition at line 220 of file wparser_def.c.
#define A_POP 0x0002 |
Definition at line 222 of file wparser_def.c.
#define A_PUSH 0x0004 |
Definition at line 223 of file wparser_def.c.
#define A_RERUN 0x0008 |
Definition at line 224 of file wparser_def.c.
#define ASCIIHWORD 16 |
Definition at line 51 of file wparser_def.c.
#define ASCIIPARTHWORD 11 |
Definition at line 46 of file wparser_def.c.
#define ASCIIWORD 1 |
Definition at line 36 of file wparser_def.c.
#define BADENDPOINT | ( | j | ) |
Definition at line 1950 of file wparser_def.c.
#define DECIMAL_T 20 |
Definition at line 55 of file wparser_def.c.
#define EMAIL 4 |
Definition at line 39 of file wparser_def.c.
#define FILEPATH 19 |
Definition at line 54 of file wparser_def.c.
Definition at line 1933 of file wparser_def.c.
Definition at line 1934 of file wparser_def.c.
#define HOST 6 |
Definition at line 41 of file wparser_def.c.
#define HWORD 17 |
Definition at line 52 of file wparser_def.c.
Definition at line 1946 of file wparser_def.c.
#define LASTNUM 23 |
Definition at line 60 of file wparser_def.c.
#define NOENDTOKEN | ( | x | ) | ( NONWORDTOKEN(x) || (x)==SCIENTIFIC || (x)==VERSIONNUMBER || (x)==DECIMAL_T || (x)==SIGNEDINT || (x)==UNSIGNEDINT || TS_IDIGNORE(x) ) |
Definition at line 1937 of file wparser_def.c.
Definition at line 1936 of file wparser_def.c.
#define NUMHWORD 15 |
Definition at line 50 of file wparser_def.c.
#define NUMPARTHWORD 9 |
Definition at line 44 of file wparser_def.c.
#define NUMWORD 3 |
Definition at line 38 of file wparser_def.c.
#define p_iswhat | ( | type, | |
nonascii | |||
) |
Definition at line 424 of file wparser_def.c.
#define PARTHWORD 10 |
Definition at line 45 of file wparser_def.c.
#define PROTOCOL 14 |
Definition at line 49 of file wparser_def.c.
#define SCIENTIFIC 7 |
Definition at line 42 of file wparser_def.c.
#define SIGNEDINT 21 |
Definition at line 56 of file wparser_def.c.
#define SPACE 12 |
Definition at line 47 of file wparser_def.c.
#define TAG_T 13 |
Definition at line 48 of file wparser_def.c.
Definition at line 1620 of file wparser_def.c.
Definition at line 1932 of file wparser_def.c.
#define UNSIGNEDINT 22 |
Definition at line 57 of file wparser_def.c.
#define URL_T 5 |
Definition at line 40 of file wparser_def.c.
#define URLPATH 18 |
Definition at line 53 of file wparser_def.c.
#define VERSIONNUMBER 8 |
Definition at line 43 of file wparser_def.c.
#define WORD_T 2 |
Definition at line 37 of file wparser_def.c.
#define XMLENTITY 23 |
Definition at line 58 of file wparser_def.c.
Definition at line 1935 of file wparser_def.c.
typedef int(* TParserCharTest) (struct TParser *) |
Definition at line 204 of file wparser_def.c.
typedef struct TParserPosition TParserPosition |
typedef void(* TParserSpecial) (struct TParser *) |
Definition at line 206 of file wparser_def.c.
enum TParserState |
Definition at line 119 of file wparser_def.c.
void _make_compiler_happy | ( | void | ) |
Definition at line 537 of file wparser_def.c.
|
static |
Definition at line 1981 of file wparser_def.c.
References data, i, HeadlineWordEntry::item, hlCheck::len, palloc(), HeadlineWordEntry::pos, TS_NO, TS_YES, val, and hlCheck::words.
Referenced by hlCover(), and prsd_headline().
|
static |
Definition at line 2220 of file wparser_def.c.
References endpos, i, INTERESTINGWORD, NONWORDTOKEN, startpos, HeadlineWordEntry::type, and HeadlineParsedText::words.
Referenced by mark_hl_fragments().
|
static |
Definition at line 2032 of file wparser_def.c.
References checkcondition_HL(), HeadlineParsedText::curwords, GETQUERY, i, HeadlineWordEntry::item, hlCheck::len, lfirst, Max, ExecPhraseData::npos, HeadlineWordEntry::pos, ExecPhraseData::pos, TS_EXEC_EMPTY, TS_execute(), ExecPhraseData::width, hlCheck::words, and HeadlineParsedText::words.
Referenced by mark_hl_fragments(), and mark_hl_words().
|
static |
Definition at line 2184 of file wparser_def.c.
References endpos, HLIDREPLACE, HLIDSKIP, i, HeadlineWordEntry::in, HeadlineWordEntry::item, HeadlineWordEntry::repeated, HeadlineWordEntry::replace, HeadlineWordEntry::selected, HeadlineWordEntry::skip, startpos, HeadlineWordEntry::type, HeadlineParsedText::words, and XMLHLIDSKIP.
Referenced by mark_hl_fragments(), and mark_hl_words().
|
static |
Definition at line 2271 of file wparser_def.c.
References BADENDPOINT, CoverPos::chosen, CoverPos::curlen, HeadlineParsedText::curwords, CoverPos::endpos, endpos, CoverPos::excluded, get_next_fragment(), hlCover(), i, HeadlineWordEntry::in, mark_fragment(), NONWORDTOKEN, palloc(), pfree(), PG_INT32_MAX, CoverPos::poslen, repalloc(), CoverPos::startpos, startpos, HeadlineWordEntry::type, and HeadlineParsedText::words.
Referenced by prsd_headline().
|
static |
Definition at line 2454 of file wparser_def.c.
References BADENDPOINT, HeadlineParsedText::curwords, hlCover(), i, INTERESTINGWORD, mark_fragment(), NONWORDTOKEN, HeadlineWordEntry::type, and HeadlineParsedText::words.
Referenced by prsd_headline().
|
static |
Definition at line 272 of file wparser_def.c.
Referenced by p_isURLPath(), TParserCopyInit(), TParserGet(), and TParserInit().
|
static |
Definition at line 493 of file wparser_def.c.
References TParserPosition::charlen, TParserPosition::posbyte, TParser::state, and TParser::str.
Referenced by p_isasclet().
|
static |
|
static |
Definition at line 474 of file wparser_def.c.
References Assert, TParserPosition::charlen, TParser::lenstr, TParserPosition::posbyte, and TParser::state.
Referenced by _make_compiler_happy().
|
static |
Definition at line 481 of file wparser_def.c.
References TParser::c.
Referenced by _make_compiler_happy().
|
static |
Definition at line 629 of file wparser_def.c.
References TParserPosition::charlen, check_stack_depth(), HOST, TParserPosition::lenbytetoken, TParser::lenbytetoken, TParserPosition::lenchartoken, TParser::lenchartoken, TParserPosition::posbyte, TParserPosition::poschar, res, TParser::state, TParserCopyClose(), TParserCopyInit(), TParserGet(), TParser::type, and TParser::wanthost.
|
static |
|
static |
Definition at line 487 of file wparser_def.c.
References TParser::c.
Referenced by _make_compiler_happy().
|
static |
Definition at line 692 of file wparser_def.c.
References GetDatabaseEncoding(), lengthof, pg_dsplen(), PG_UTF8, TParser::pgwstr, TParserPosition::posbyte, TParserPosition::poschar, TParser::state, TParser::str, TParser::usewide, and TParser::wstr.
|
static |
|
static |
Definition at line 505 of file wparser_def.c.
References TParserPosition::charlen, TParserPosition::posbyte, TParser::state, and TParser::str.
|
static |
Definition at line 657 of file wparser_def.c.
References TParserPosition::charlen, check_stack_depth(), TParserPosition::lenbytetoken, TParser::lenbytetoken, TParserPosition::lenchartoken, TParser::lenchartoken, newTParserPosition(), TParserPosition::posbyte, TParserPosition::poschar, res, TParserPosition::state, TParser::state, TParserCopyClose(), TParserCopyInit(), TParserGet(), TPS_InURLPathFirst, TParser::type, and URLPATH.
p_iswhat | ( | alnum | , |
1 | |||
) |
Datum prsd_end | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1918 of file wparser_def.c.
References PG_GETARG_POINTER, PG_RETURN_VOID, and TParserClose().
Datum prsd_headline | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2616 of file wparser_def.c.
References checkcondition_HL(), HeadlineParsedText::curwords, defGetString(), DefElem::defname, ereport, errcode(), errmsg(), ERROR, HeadlineParsedText::fragdelim, HeadlineParsedText::fragdelimlen, GETQUERY, hlCheck::len, lfirst, mark_hl_fragments(), mark_hl_words(), NIL, PG_GETARG_POINTER, PG_GETARG_TSQUERY, PG_RETURN_POINTER, pg_strcasecmp(), pg_strtoint32(), pstrdup(), TSQueryData::size, HeadlineParsedText::startsel, HeadlineParsedText::startsellen, HeadlineParsedText::stopsel, HeadlineParsedText::stopsellen, TS_EXEC_EMPTY, TS_execute_locations(), val, hlCheck::words, and HeadlineParsedText::words.
Datum prsd_lextype | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1878 of file wparser_def.c.
References LexDescr::alias, LexDescr::descr, i, LASTNUM, lex_descr, LexDescr::lexid, palloc(), PG_RETURN_POINTER, pstrdup(), and tok_alias.
Datum prsd_nexttoken | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1902 of file wparser_def.c.
References TParser::lenbytetoken, PG_GETARG_POINTER, PG_RETURN_INT32, TParser::token, TParserGet(), and TParser::type.
Datum prsd_start | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1896 of file wparser_def.c.
References PG_GETARG_INT32, PG_GETARG_POINTER, PG_RETURN_POINTER, and TParserInit().
|
static |
Definition at line 588 of file wparser_def.c.
References TParserPosition::lenbytetoken, TParserPosition::lenchartoken, TParserPosition::posbyte, TParserPosition::poschar, TParser::state, and TParser::wanthost.
|
static |
Definition at line 596 of file wparser_def.c.
References TParserPosition::lenbytetoken, TParserPosition::lenchartoken, TParserPosition::posbyte, TParserPosition::poschar, and TParser::state.
|
static |
Definition at line 564 of file wparser_def.c.
References TParser::ignore, TParserPosition::lenchartoken, pg_strncasecmp(), TParser::state, and TParser::token.
|
static |
Definition at line 603 of file wparser_def.c.
References TParserPosition::lenbytetoken, TParserPosition::lenchartoken, TParserPosition::posbyte, TParserPosition::poschar, and TParser::state.
|
static |
Definition at line 372 of file wparser_def.c.
References fprintf, pfree(), TParser::pgwstr, TParserPosition::prev, TParser::state, and TParser::wstr.
Referenced by prsd_end().
|
static |
Definition at line 397 of file wparser_def.c.
References fprintf, pfree(), TParserPosition::prev, and TParser::state.
Referenced by p_ishost(), and p_isURLPath().
Definition at line 346 of file wparser_def.c.
References TParser::charmaxlen, fprintf, TParser::lenstr, newTParserPosition(), palloc0(), TParser::pgwstr, TParserPosition::posbyte, TParserPosition::poschar, TParserPosition::state, TParser::state, TParser::str, TPS_Base, TParser::usewide, and TParser::wstr.
Referenced by p_ishost(), and p_isURLPath().
Definition at line 1710 of file wparser_def.c.
References A_BINGO, A_CLEAR, A_CLRALL, A_MERGE, A_POP, A_PUSH, A_RERUN, TParserStateAction::action, Actions, Assert, TParserStateActionItem::c, TParser::c, TParserPosition::charlen, TParser::charmaxlen, CHECK_FOR_INTERRUPTS, TParserStateActionItem::flags, fprintf, TParserStateActionItem::isclass, TParserPosition::lenbytetoken, TParser::lenbytetoken, TParserPosition::lenchartoken, TParser::lenchartoken, TParser::lenstr, newTParserPosition(), pfree(), pg_mblen(), TParserPosition::posbyte, TParserPosition::poschar, TParserPosition::prev, TParserPosition::pushedAtAction, TParserStateActionItem::special, TParserPosition::state, TParser::state, TParserStateAction::state, TParser::str, tok_alias, TParser::token, TParserStateActionItem::tostate, TPS_Base, TPS_Null, TParserStateActionItem::type, and TParser::type.
Referenced by p_ishost(), p_isURLPath(), and prsd_nexttoken().
|
static |
Definition at line 289 of file wparser_def.c.
References char2wchar(), TParser::charmaxlen, database_ctype_is_c, fprintf, len, TParser::lenstr, newTParserPosition(), palloc(), palloc0(), pg_database_encoding_max_length(), pg_mb2wchar_with_len(), TParser::pgwstr, TParserPosition::state, TParser::state, TParser::str, str, TPS_Base, TParser::usewide, and TParser::wstr.
Referenced by prsd_start().
|
static |
Definition at line 1628 of file wparser_def.c.
Referenced by TParserGet().
|
static |
Definition at line 971 of file wparser_def.c.
|
static |
Definition at line 999 of file wparser_def.c.
|
static |
Definition at line 1309 of file wparser_def.c.
|
static |
Definition at line 1315 of file wparser_def.c.
|
static |
Definition at line 1303 of file wparser_def.c.
|
static |
Definition at line 1322 of file wparser_def.c.
|
static |
|
static |
Definition at line 1297 of file wparser_def.c.
|
static |
Definition at line 1091 of file wparser_def.c.
|
static |
Definition at line 1085 of file wparser_def.c.
|
static |
Definition at line 1391 of file wparser_def.c.
|
static |
Definition at line 1441 of file wparser_def.c.
|
static |
Definition at line 1397 of file wparser_def.c.
|
static |
Definition at line 1452 of file wparser_def.c.
|
static |
Definition at line 1407 of file wparser_def.c.
|
static |
Definition at line 1476 of file wparser_def.c.
|
static |
Definition at line 1380 of file wparser_def.c.
|
static |
Definition at line 1344 of file wparser_def.c.
|
static |
Definition at line 1333 of file wparser_def.c.
|
static |
Definition at line 1373 of file wparser_def.c.
|
static |
Definition at line 1326 of file wparser_def.c.
|
static |
Definition at line 1506 of file wparser_def.c.
|
static |
Definition at line 1498 of file wparser_def.c.
|
static |
Definition at line 1579 of file wparser_def.c.
|
static |
Definition at line 1547 of file wparser_def.c.
|
static |
Definition at line 1539 of file wparser_def.c.
|
static |
Definition at line 1532 of file wparser_def.c.
|
static |
Definition at line 1588 of file wparser_def.c.
|
static |
Definition at line 1595 of file wparser_def.c.
|
static |
Definition at line 1523 of file wparser_def.c.
|
static |
Definition at line 1516 of file wparser_def.c.
|
static |
Definition at line 1571 of file wparser_def.c.
|
static |
Definition at line 1140 of file wparser_def.c.
|
static |
Definition at line 1126 of file wparser_def.c.
|
static |
Definition at line 1134 of file wparser_def.c.
|
static |
Definition at line 988 of file wparser_def.c.
|
static |
Definition at line 1555 of file wparser_def.c.
|
static |
Definition at line 1564 of file wparser_def.c.
|
static |
Definition at line 1416 of file wparser_def.c.
|
static |
Definition at line 1426 of file wparser_def.c.
|
static |
Definition at line 1433 of file wparser_def.c.
|
static |
Definition at line 1365 of file wparser_def.c.
|
static |
Definition at line 1359 of file wparser_def.c.
|
static |
Definition at line 1494 of file wparser_def.c.
|
static |
Definition at line 1482 of file wparser_def.c.
|
static |
Definition at line 1488 of file wparser_def.c.
|
static |
Definition at line 1049 of file wparser_def.c.
|
static |
Definition at line 1043 of file wparser_def.c.
|
static |
Definition at line 1058 of file wparser_def.c.
|
static |
|
static |
Definition at line 1243 of file wparser_def.c.
|
static |
|
static |
Definition at line 1237 of file wparser_def.c.
|
static |
Definition at line 1217 of file wparser_def.c.
|
static |
|
static |
Definition at line 1265 of file wparser_def.c.
|
static |
Definition at line 1272 of file wparser_def.c.
|
static |
Definition at line 1198 of file wparser_def.c.
|
static |
Definition at line 1223 of file wparser_def.c.
|
static |
Definition at line 1076 of file wparser_def.c.
|
static |
Definition at line 1070 of file wparser_def.c.
|
static |
Definition at line 1026 of file wparser_def.c.
|
static |
Definition at line 1470 of file wparser_def.c.
|
static |
Definition at line 1460 of file wparser_def.c.
|
static |
Definition at line 1466 of file wparser_def.c.
|
static |
Definition at line 1119 of file wparser_def.c.
|
static |
Definition at line 1113 of file wparser_def.c.
|
static |
Definition at line 1100 of file wparser_def.c.
|
static |
Definition at line 1017 of file wparser_def.c.
|
static |
|
static |
Definition at line 1155 of file wparser_def.c.
|
static |
Definition at line 1194 of file wparser_def.c.
|
static |
Definition at line 1146 of file wparser_def.c.
|
static |
Definition at line 1187 of file wparser_def.c.
|
static |
Definition at line 1174 of file wparser_def.c.
|
static |
Definition at line 1180 of file wparser_def.c.
|
static |
Definition at line 1166 of file wparser_def.c.
|
static |
Definition at line 89 of file wparser_def.c.
Referenced by prsd_lextype().
|
static |
Definition at line 62 of file wparser_def.c.
Referenced by prsd_lextype(), and TParserGet().