PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "libpq/pqformat.h"
#include "miscadmin.h"
#include "nodes/miscnodes.h"
#include "tsearch/ts_locale.h"
#include "tsearch/ts_type.h"
#include "tsearch/ts_utils.h"
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "utils/pg_crc.h"
#include "varatt.h"
Go to the source code of this file.
Data Structures | |
struct | TSQueryParserStateData |
struct | OperatorElement |
struct | INFIX |
Macros | |
#define | STACKDEPTH 32 |
#define | RESIZEBUF(inf, addsize) |
Typedefs | |
typedef ts_tokentype(* | ts_tokenizer) (TSQueryParserState state, int8 *operator, int *lenval, char **strval, int16 *weight, bool *prefix) |
typedef struct OperatorElement | OperatorElement |
Enumerations | |
enum | ts_parserstate { WAITOPERAND = 1 , WAITOPERATOR = 2 , WAITFIRSTOPERAND = 3 } |
enum | ts_tokentype { PT_END = 0 , PT_ERR = 1 , PT_VAL = 2 , PT_OPR = 3 , PT_OPEN = 4 , PT_CLOSE = 5 } |
Variables | |
const int | tsearch_op_priority [OP_COUNT] |
#define RESIZEBUF | ( | inf, | |
addsize | |||
) |
typedef struct OperatorElement OperatorElement |
typedef ts_tokentype(* ts_tokenizer) (TSQueryParserState state, int8 *operator,int *lenval, char **strval, int16 *weight, bool *prefix) |
enum ts_parserstate |
enum ts_tokentype |
|
static |
Definition at line 648 of file tsquery.c.
References OP_NOT, OP_PRIORITY, and pushOperator().
Referenced by makepol().
Definition at line 784 of file tsquery.c.
References elog, ERROR, findoprnd_recurse(), and size.
Referenced by parse_tsquery(), and tsqueryrecv().
|
static |
Definition at line 726 of file tsquery.c.
References Assert, check_stack_depth(), elog, ERROR, QueryOperator::left, OP_AND, OP_NOT, OP_OR, OP_PHRASE, QueryOperator::oper, QI_OPR, QI_VAL, QI_VALSTOP, QueryItem::qoperator, and type.
Referenced by findoprnd().
Definition at line 114 of file tsquery.c.
References buf, pg_mblen(), and t_iseq.
Referenced by gettoken_query_standard().
|
static |
Definition at line 510 of file tsquery.c.
References PT_END, and PT_VAL.
Referenced by parse_tsquery().
|
static |
Definition at line 286 of file tsquery.c.
References ereturn, errcode(), errmsg(), get_modifiers(), gettoken_tsvector(), OP_AND, OP_NOT, OP_OR, OP_PHRASE, parse_phrase_operator(), pg_mblen(), PT_CLOSE, PT_END, PT_ERR, PT_OPEN, PT_OPR, PT_VAL, reset_tsvector_parser(), SOFT_ERROR_OCCURRED, t_iseq, t_isspace(), WAITFIRSTOPERAND, WAITOPERAND, and WAITOPERATOR.
Referenced by parse_tsquery().
|
static |
Definition at line 398 of file tsquery.c.
References gettoken_tsvector(), ISOPERATOR, OP_AND, OP_NOT, OP_OR, parse_or_operator(), pg_mblen(), PT_END, PT_ERR, PT_OPR, PT_VAL, pushStop(), reset_tsvector_parser(), SOFT_ERROR_OCCURRED, t_iseq, t_isspace(), WAITFIRSTOPERAND, WAITOPERAND, and WAITOPERATOR.
Referenced by parse_tsquery().
Definition at line 991 of file tsquery.c.
References INFIX::buf, INFIX::buflen, check_stack_depth(), COPYCHAR, INFIX::cur, INFIX::curpol, ITEM::distance, QueryOperand::distance, elog, ERROR, QueryOperand::length, INFIX::op, TSQueryParserStateData::op, OP_AND, OP_NOT, OP_OR, OP_PHRASE, palloc(), pfree(), pg_database_encoding_max_length(), pg_mblen(), QueryOperand::prefix, QI_VAL, QO_PRIORITY, RESIZEBUF, sprintf, t_iseq, ITEM::type, and QueryOperand::weight.
Referenced by tsqueryout(), and tsquerytree().
|
static |
Definition at line 672 of file tsquery.c.
References check_stack_depth(), cleanOpStack(), errcode(), errmsg(), errsave, OP_OR, PT_CLOSE, PT_END, PT_ERR, PT_OPEN, PT_OPR, PT_VAL, pushOpStack(), SOFT_ERROR_OCCURRED, STACKDEPTH, and type.
Referenced by parse_tsquery().
|
static |
Definition at line 244 of file tsquery.c.
References TSQueryParserStateData::buf, pg_mblen(), pg_strncasecmp(), t_isalnum(), t_iseq, and t_isspace().
Referenced by gettoken_query_websearch().
|
static |
Definition at line 165 of file tsquery.c.
References TSQueryParserStateData::buf, ereturn, errcode(), errmsg(), TSQueryParserStateData::escontext, MAXENTRYPOS, t_isdigit(), and t_iseq.
Referenced by gettoken_query_standard().
TSQuery parse_tsquery | ( | char * | buf, |
PushFunction | pushval, | ||
Datum | opaque, | ||
int | flags, | ||
Node * | escontext | ||
) |
Definition at line 817 of file tsquery.c.
References Assert, buf, cleanup_tsquery_stopwords(), close_tsvector_parser(), COMPUTESIZE, elog, ereport, ereturn, errcode(), errmsg(), ERROR, TSQueryParserStateData::escontext, findoprnd(), GETOPERAND, GETQUERY, gettoken_query_plain(), gettoken_query_standard(), gettoken_query_websearch(), HDRSIZETQ, i, init_tsvector_parser(), IsA, lfirst, list_length(), makepol(), NIL, NOTICE, P_TSQ_PLAIN, P_TSQ_WEB, P_TSV_IS_TSQUERY, P_TSV_IS_WEB, P_TSV_OPR_IS_DELIM, palloc(), palloc0(), pfree(), QI_OPR, QI_VAL, QI_VALSTOP, SET_VARSIZE, TSQueryData::size, SOFT_ERROR_OCCURRED, TSQUERY_TOO_BIG, QueryItem::type, and WAITFIRSTOPERAND.
Referenced by phraseto_tsquery_byid(), plainto_tsquery_byid(), to_tsquery_byid(), tsqueryin(), and websearch_to_tsquery_byid().
void pushOperator | ( | TSQueryParserState | state, |
int8 | oper, | ||
int16 | distance | ||
) |
Definition at line 531 of file tsquery.c.
References Assert, QueryOperator::distance, lcons(), OP_AND, OP_NOT, OP_OR, OP_PHRASE, oper(), QueryOperator::oper, palloc0(), QI_OPR, and QueryOperator::type.
Referenced by cleanOpStack(), and pushval_morph().
|
static |
Definition at line 636 of file tsquery.c.
References OperatorElement::distance, elog, ERROR, OperatorElement::op, and STACKDEPTH.
Referenced by makepol().
void pushStop | ( | TSQueryParserState | state | ) |
Definition at line 616 of file tsquery.c.
References lcons(), palloc0(), QI_VALSTOP, and QueryOperand::type.
Referenced by gettoken_query_websearch(), and pushval_morph().
|
static |
Definition at line 942 of file tsquery.c.
References pushValue().
Referenced by tsqueryin().
void pushValue | ( | TSQueryParserState | state, |
char * | strval, | ||
int | lenval, | ||
int16 | weight, | ||
bool | prefix | ||
) |
Definition at line 580 of file tsquery.c.
References COMP_LEGACY_CRC32, ereturn, errcode(), errmsg(), FIN_LEGACY_CRC32, INIT_LEGACY_CRC32, MAXSTRLEN, pushValue_internal(), and repalloc().
Referenced by pushval_asis(), and pushval_morph().
|
static |
Definition at line 547 of file tsquery.c.
References QueryOperand::distance, ereturn, errcode(), errmsg(), lcons(), QueryOperand::length, MAXSTRLEN, MAXSTRPOS, palloc0(), QueryOperand::prefix, QI_VAL, QueryOperand::type, QueryOperand::valcrc, and QueryOperand::weight.
Referenced by pushValue().
Datum tsqueryin | ( | PG_FUNCTION_ARGS | ) |
Definition at line 952 of file tsquery.c.
References TSQueryParserStateData::escontext, parse_tsquery(), PG_GETARG_CSTRING, PG_RETURN_TSQUERY, PointerGetDatum(), and pushval_asis().
Datum tsqueryout | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1146 of file tsquery.c.
References b, INFIX::buf, INFIX::buflen, INFIX::cur, INFIX::curpol, GETOPERAND, GETQUERY, infix(), INFIX::op, palloc(), PG_FREE_IF_COPY, PG_GETARG_TSQUERY, PG_RETURN_CSTRING, PG_RETURN_POINTER, and TSQueryData::size.
Datum tsqueryrecv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1226 of file tsquery.c.
References Assert, buf, COMP_LEGACY_CRC32, QueryOperand::distance, QueryOperator::distance, elog, ERROR, FIN_LEGACY_CRC32, findoprnd(), GETOPERAND, GETQUERY, HDRSIZETQ, i, INIT_LEGACY_CRC32, len, QueryOperand::length, MaxAllocSize, MAXSTRLEN, MAXSTRPOS, OP_AND, OP_NOT, OP_OR, OP_PHRASE, oper(), QueryOperator::oper, palloc(), palloc0(), pfree(), PG_GETARG_POINTER, PG_RETURN_TSQUERY, pq_getmsgint(), pq_getmsgstring(), QueryOperand::prefix, QI_OPR, QI_VAL, QueryItem::qoperand, QueryItem::qoperator, repalloc(), SET_VARSIZE, size, TSQueryData::size, QueryItem::type, val, QueryOperand::valcrc, and QueryOperand::weight.
Datum tsquerysend | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1188 of file tsquery.c.
References buf, QueryOperand::distance, QueryOperator::distance, elog, ERROR, GETOPERAND, GETQUERY, i, OP_PHRASE, QueryOperator::oper, PG_FREE_IF_COPY, PG_GETARG_TSQUERY, PG_RETURN_BYTEA_P, pq_begintypsend(), pq_endtypsend(), pq_sendint16(), pq_sendint32(), pq_sendint8(), pq_sendstring(), QueryOperand::prefix, QI_OPR, QI_VAL, QueryItem::qoperand, QueryItem::qoperator, TSQueryData::size, QueryItem::type, and QueryOperand::weight.
Datum tsquerytree | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1362 of file tsquery.c.
References INFIX::buf, INFIX::buflen, clean_NOT(), cstring_to_text(), cstring_to_text_with_len(), INFIX::cur, INFIX::curpol, GETOPERAND, GETQUERY, infix(), len, INFIX::op, palloc(), pfree(), PG_FREE_IF_COPY, PG_GETARG_TSQUERY, PG_RETURN_POINTER, PG_RETURN_TEXT_P, res, SET_VARSIZE, TSQueryData::size, and VARHDRSZ.