|
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 1905 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 1888 of file wparser_def.c.
Definition at line 1889 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 1901 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 1892 of file wparser_def.c.
Definition at line 1891 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 388 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 1575 of file wparser_def.c.
Definition at line 1887 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 1890 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 495 of file wparser_def.c.
|
static |
Definition at line 1936 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 2175 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 1987 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 2139 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 2226 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 2409 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 270 of file wparser_def.c.
References palloc(), TParserPosition::prev, and TParserPosition::pushedAtAction.
Referenced by p_isURLPath(), TParserCopyInit(), TParserGet(), and TParserInit().
|
static |
Definition at line 451 of file wparser_def.c.
References TParserPosition::charlen, TParserPosition::posbyte, TParser::state, and TParser::str.
Referenced by p_isasclet().
|
static |
|
static |
Definition at line 432 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 439 of file wparser_def.c.
References TParser::c.
Referenced by _make_compiler_happy().
|
static |
Definition at line 587 of file wparser_def.c.
References TParserPosition::charlen, check_stack_depth(), HOST, TParserPosition::lenbytetoken, TParser::lenbytetoken, TParserPosition::lenchartoken, TParser::lenchartoken, TParserPosition::posbyte, TParserPosition::poschar, TParser::state, TParserCopyClose(), TParserCopyInit(), TParserGet(), TParser::type, and TParser::wanthost.
|
static |
Definition at line 581 of file wparser_def.c.
References TParser::ignore.
|
static |
Definition at line 445 of file wparser_def.c.
References TParser::c.
Referenced by _make_compiler_happy().
|
static |
Definition at line 650 of file wparser_def.c.
References GetDatabaseEncoding(), lengthof, pg_dsplen(), PG_UTF8, TParser::pgwstr, TParserPosition::posbyte, TParserPosition::poschar, TParser::state, and TParser::str.
|
static |
Definition at line 570 of file wparser_def.c.
References TParser::wanthost.
|
static |
Definition at line 463 of file wparser_def.c.
References TParserPosition::charlen, TParserPosition::posbyte, TParser::state, and TParser::str.
|
static |
Definition at line 615 of file wparser_def.c.
References TParserPosition::charlen, check_stack_depth(), TParserPosition::lenbytetoken, TParser::lenbytetoken, TParserPosition::lenchartoken, TParser::lenchartoken, newTParserPosition(), TParserPosition::posbyte, TParserPosition::poschar, TParserPosition::state, TParser::state, TParserCopyClose(), TParserCopyInit(), TParserGet(), TPS_InURLPathFirst, TParser::type, and URLPATH.
| p_iswhat | ( | alnum | , |
| 1 | |||
| ) |
Definition at line 412 of file wparser_def.c.
References Assert().
| Datum prsd_end | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1873 of file wparser_def.c.
References PG_GETARG_POINTER, PG_RETURN_VOID, and TParserClose().
| Datum prsd_headline | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2571 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 1833 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 1857 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 1851 of file wparser_def.c.
References PG_GETARG_INT32, PG_GETARG_POINTER, PG_RETURN_POINTER, and TParserInit().
|
static |
Definition at line 546 of file wparser_def.c.
References TParserPosition::lenbytetoken, TParserPosition::lenchartoken, TParserPosition::posbyte, TParserPosition::poschar, TParser::state, and TParser::wanthost.
|
static |
Definition at line 554 of file wparser_def.c.
References TParserPosition::lenbytetoken, TParserPosition::lenchartoken, TParserPosition::posbyte, TParserPosition::poschar, and TParser::state.
|
static |
Definition at line 522 of file wparser_def.c.
References TParser::ignore, TParserPosition::lenchartoken, pg_strncasecmp(), TParser::state, and TParser::token.
|
static |
Definition at line 561 of file wparser_def.c.
References TParserPosition::lenbytetoken, TParserPosition::lenchartoken, TParserPosition::posbyte, TParserPosition::poschar, and TParser::state.
|
static |
Definition at line 342 of file wparser_def.c.
References fprintf, pfree(), TParser::pgwstr, TParserPosition::prev, and TParser::state.
Referenced by prsd_end().
|
static |
Definition at line 365 of file wparser_def.c.
References fprintf, pfree(), TParserPosition::prev, and TParser::state.
Referenced by p_ishost(), and p_isURLPath().
Definition at line 319 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, and TPS_Base.
Referenced by p_ishost(), and p_isURLPath().
|
static |
Definition at line 1665 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 287 of file wparser_def.c.
References TParser::charmaxlen, 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, and TPS_Base.
Referenced by prsd_start().
|
static |
Definition at line 1583 of file wparser_def.c.
Referenced by TParserGet().
|
static |
Definition at line 926 of file wparser_def.c.
|
static |
Definition at line 954 of file wparser_def.c.
|
static |
Definition at line 1264 of file wparser_def.c.
|
static |
Definition at line 1270 of file wparser_def.c.
|
static |
Definition at line 1258 of file wparser_def.c.
|
static |
Definition at line 1277 of file wparser_def.c.
|
static |
|
static |
Definition at line 1252 of file wparser_def.c.
|
static |
Definition at line 1046 of file wparser_def.c.
|
static |
Definition at line 1040 of file wparser_def.c.
|
static |
Definition at line 1346 of file wparser_def.c.
|
static |
Definition at line 1396 of file wparser_def.c.
|
static |
Definition at line 1352 of file wparser_def.c.
|
static |
Definition at line 1407 of file wparser_def.c.
|
static |
Definition at line 1362 of file wparser_def.c.
|
static |
Definition at line 1431 of file wparser_def.c.
|
static |
Definition at line 1335 of file wparser_def.c.
|
static |
Definition at line 1299 of file wparser_def.c.
|
static |
Definition at line 1288 of file wparser_def.c.
|
static |
Definition at line 1328 of file wparser_def.c.
|
static |
Definition at line 1281 of file wparser_def.c.
|
static |
Definition at line 1461 of file wparser_def.c.
|
static |
Definition at line 1453 of file wparser_def.c.
|
static |
Definition at line 1534 of file wparser_def.c.
|
static |
Definition at line 1502 of file wparser_def.c.
|
static |
Definition at line 1494 of file wparser_def.c.
|
static |
Definition at line 1487 of file wparser_def.c.
|
static |
Definition at line 1543 of file wparser_def.c.
|
static |
Definition at line 1550 of file wparser_def.c.
|
static |
Definition at line 1478 of file wparser_def.c.
|
static |
Definition at line 1471 of file wparser_def.c.
|
static |
Definition at line 1526 of file wparser_def.c.
|
static |
Definition at line 1095 of file wparser_def.c.
|
static |
Definition at line 1081 of file wparser_def.c.
|
static |
Definition at line 1089 of file wparser_def.c.
|
static |
Definition at line 943 of file wparser_def.c.
|
static |
Definition at line 1510 of file wparser_def.c.
|
static |
Definition at line 1519 of file wparser_def.c.
|
static |
Definition at line 1371 of file wparser_def.c.
|
static |
Definition at line 1381 of file wparser_def.c.
|
static |
Definition at line 1388 of file wparser_def.c.
|
static |
Definition at line 1320 of file wparser_def.c.
|
static |
Definition at line 1314 of file wparser_def.c.
|
static |
Definition at line 1449 of file wparser_def.c.
|
static |
Definition at line 1437 of file wparser_def.c.
|
static |
Definition at line 1443 of file wparser_def.c.
|
static |
Definition at line 1004 of file wparser_def.c.
|
static |
Definition at line 998 of file wparser_def.c.
|
static |
Definition at line 1013 of file wparser_def.c.
|
static |
|
static |
Definition at line 1198 of file wparser_def.c.
|
static |
|
static |
Definition at line 1192 of file wparser_def.c.
|
static |
Definition at line 1172 of file wparser_def.c.
|
static |
|
static |
Definition at line 1220 of file wparser_def.c.
|
static |
Definition at line 1227 of file wparser_def.c.
|
static |
Definition at line 1153 of file wparser_def.c.
|
static |
Definition at line 1178 of file wparser_def.c.
|
static |
Definition at line 1031 of file wparser_def.c.
|
static |
Definition at line 1025 of file wparser_def.c.
|
static |
Definition at line 981 of file wparser_def.c.
|
static |
Definition at line 1425 of file wparser_def.c.
|
static |
Definition at line 1415 of file wparser_def.c.
|
static |
Definition at line 1421 of file wparser_def.c.
|
static |
Definition at line 1074 of file wparser_def.c.
|
static |
Definition at line 1068 of file wparser_def.c.
|
static |
Definition at line 1055 of file wparser_def.c.
|
static |
Definition at line 972 of file wparser_def.c.
|
static |
|
static |
Definition at line 1110 of file wparser_def.c.
|
static |
Definition at line 1149 of file wparser_def.c.
|
static |
Definition at line 1101 of file wparser_def.c.
|
static |
Definition at line 1142 of file wparser_def.c.
|
static |
Definition at line 1129 of file wparser_def.c.
|
static |
Definition at line 1135 of file wparser_def.c.
|
static |
Definition at line 1121 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().