| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #ifndef _PG_TS_UTILS_H_ |
| #define _PG_TS_UTILS_H_ |
|
|
| #include "nodes/pg_list.h" |
| #include "tsearch/ts_public.h" |
| #include "tsearch/ts_type.h" |
|
|
| |
| |
| |
|
|
| |
|
|
| struct TSVectorParseStateData; |
| typedef struct TSVectorParseStateData *TSVectorParseState; |
|
|
| |
| #define P_TSV_OPR_IS_DELIM (1 << 0) |
| #define P_TSV_IS_TSQUERY (1 << 1) |
| #define P_TSV_IS_WEB (1 << 2) |
|
|
| extern TSVectorParseState init_tsvector_parser(char *input, int flags, |
| Node *escontext); |
| extern void reset_tsvector_parser(TSVectorParseState state, char *input); |
| extern bool gettoken_tsvector(TSVectorParseState state, |
| char **strval, int *lenval, |
| WordEntryPos **pos_ptr, int *poslen, |
| char **endptr); |
| extern void close_tsvector_parser(TSVectorParseState state); |
|
|
| |
| #define ISOPERATOR(x) \ |
| ( pg_mblen(x) == 1 && ( *(x) == '!' || \ |
| *(x) == '&' || \ |
| *(x) == '|' || \ |
| *(x) == '(' || \ |
| *(x) == ')' || \ |
| *(x) == '<' \ |
| ) ) |
|
|
| |
|
|
| struct TSQueryParserStateData; |
| typedef struct TSQueryParserStateData *TSQueryParserState; |
|
|
| typedef void (*PushFunction) (Datum opaque, TSQueryParserState state, |
| char *token, int tokenlen, |
| int16 tokenweights, |
| |
| bool prefix); |
|
|
| |
| #define P_TSQ_PLAIN (1 << 0) |
| #define P_TSQ_WEB (1 << 1) |
|
|
| extern TSQuery parse_tsquery(char *buf, |
| PushFunction pushval, |
| Datum opaque, |
| int flags, |
| Node *escontext); |
|
|
| |
| extern void pushValue(TSQueryParserState state, |
| char *strval, int lenval, int16 weight, bool prefix); |
| extern void pushStop(TSQueryParserState state); |
| extern void pushOperator(TSQueryParserState state, int8 oper, int16 distance); |
|
|
| |
| |
| |
| typedef struct |
| { |
| uint16 len; |
| uint16 nvariant; |
| union |
| { |
| uint16 pos; |
|
|
| |
| |
| |
| |
| |
| uint16 *apos; |
| } pos; |
| uint16 flags; |
| char *word; |
| uint32 alen; |
| } ParsedWord; |
|
|
| typedef struct |
| { |
| ParsedWord *words; |
| int32 lenwords; |
| int32 curwords; |
| int32 pos; |
| } ParsedText; |
|
|
| extern void parsetext(Oid cfgId, ParsedText *prs, char *buf, int32 buflen); |
|
|
| |
| |
| |
| |
| |
| |
|
|
| extern void hlparsetext(Oid cfgId, HeadlineParsedText *prs, TSQuery query, |
| char *buf, int32 buflen); |
| extern text *generateHeadline(HeadlineParsedText *prs); |
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| typedef enum |
| { |
| TS_NO, |
| TS_YES, |
| TS_MAYBE |
| } TSTernaryValue; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| typedef struct ExecPhraseData |
| { |
| int npos; |
| bool allocated; |
| bool negate; |
| WordEntryPos *pos; |
| int width; |
| } ExecPhraseData; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| typedef TSTernaryValue (*TSExecuteCallback) (void *arg, QueryOperand *val, |
| ExecPhraseData *data); |
|
|
| |
| |
| |
| #define TS_EXEC_EMPTY (0x00) |
| |
| |
| |
| |
| |
| |
| #define TS_EXEC_SKIP_NOT (0x01) |
| |
| |
| |
| |
| |
| |
| #define TS_EXEC_PHRASE_NO_POS (0x02) |
|
|
| extern bool TS_execute(QueryItem *curitem, void *arg, uint32 flags, |
| TSExecuteCallback chkcond); |
| extern TSTernaryValue TS_execute_ternary(QueryItem *curitem, void *arg, |
| uint32 flags, |
| TSExecuteCallback chkcond); |
| extern List *TS_execute_locations(QueryItem *curitem, void *arg, |
| uint32 flags, |
| TSExecuteCallback chkcond); |
| extern bool tsquery_requires_match(QueryItem *curitem); |
|
|
| |
| |
| |
| extern TSVector make_tsvector(ParsedText *prs); |
| extern int32 tsCompareString(char *a, int lena, char *b, int lenb, bool prefix); |
|
|
| |
| |
| |
| |
| |
| #define TSearchStrategyNumber 1 |
| #define TSearchWithClassStrategyNumber 2 |
|
|
| |
| |
| |
| extern QueryItem *clean_NOT(QueryItem *ptr, int32 *len); |
| extern TSQuery cleanup_tsquery_stopwords(TSQuery in, bool noisy); |
|
|
| typedef struct QTNode |
| { |
| QueryItem *valnode; |
| uint32 flags; |
| int32 nchild; |
| char *word; |
| uint32 sign; |
| struct QTNode **child; |
| } QTNode; |
|
|
| |
| #define QTN_NEEDFREE 0x01 |
| #define QTN_NOCHANGE 0x02 |
| #define QTN_WORDFREE 0x04 |
|
|
| typedef uint64 TSQuerySign; |
|
|
| #define TSQS_SIGLEN (sizeof(TSQuerySign)*BITS_PER_BYTE) |
|
|
| static inline Datum |
| TSQuerySignGetDatum(TSQuerySign X) |
| { |
| return Int64GetDatum((int64) X); |
| } |
|
|
| static inline TSQuerySign |
| DatumGetTSQuerySign(Datum X) |
| { |
| return (TSQuerySign) DatumGetInt64(X); |
| } |
|
|
| #define PG_RETURN_TSQUERYSIGN(X) return TSQuerySignGetDatum(X) |
| #define PG_GETARG_TSQUERYSIGN(n) DatumGetTSQuerySign(PG_GETARG_DATUM(n)) |
|
|
|
|
| extern QTNode *QT2QTN(QueryItem *in, char *operand); |
| extern TSQuery QTN2QT(QTNode *in); |
| extern void QTNFree(QTNode *in); |
| extern void QTNSort(QTNode *in); |
| extern void QTNTernary(QTNode *in); |
| extern void QTNBinary(QTNode *in); |
| extern int QTNodeCompare(QTNode *an, QTNode *bn); |
| extern QTNode *QTNCopy(QTNode *in); |
| extern void QTNClearFlags(QTNode *in, uint32 flags); |
| extern bool QTNEq(QTNode *a, QTNode *b); |
| extern TSQuerySign makeTSQuerySign(TSQuery a); |
| extern QTNode *findsubquery(QTNode *root, QTNode *ex, QTNode *subs, |
| bool *isfind); |
|
|
| #endif |
|
|