PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <limits.h>
#include "access/htup_details.h"
#include "catalog/namespace.h"
#include "catalog/pg_type.h"
#include "commands/trigger.h"
#include "executor/spi.h"
#include "funcapi.h"
#include "lib/qunique.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "parser/parse_coerce.h"
#include "tsearch/ts_utils.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/regproc.h"
#include "utils/rel.h"
Go to the source code of this file.
Data Structures | |
struct | CHKVAL |
struct | StatEntry |
struct | TSVectorStat |
Macros | |
#define | STATENTRYHDRSZ (offsetof(StatEntry, lexeme)) |
#define | TSVECTORCMPFUNC(type, action, ret) |
#define | compareEntry(pa, a, pb, b) |
#define | TSPO_L_ONLY 0x01 /* emit positions appearing only in L */ |
#define | TSPO_R_ONLY 0x02 /* emit positions appearing only in R */ |
#define | TSPO_BOTH 0x04 /* emit positions appearing in both L&R */ |
#define | compareStatWord(a, e, t) |
Typedefs | |
typedef struct StatEntry | StatEntry |
#define compareEntry | ( | pa, | |
a, | |||
pb, | |||
b | |||
) |
Definition at line 352 of file tsvector_op.c.
Referenced by tsvector_concat().
#define compareStatWord | ( | a, | |
e, | |||
t | |||
) |
Definition at line 2131 of file tsvector_op.c.
Referenced by insertStatEntry().
Definition at line 56 of file tsvector_op.c.
Referenced by insertStatEntry().
#define TSPO_BOTH 0x04 /* emit positions appearing in both L&R */ |
Definition at line 1460 of file tsvector_op.c.
Referenced by TS_phrase_execute(), and TS_phrase_output().
#define TSPO_L_ONLY 0x01 /* emit positions appearing only in L */ |
Definition at line 1458 of file tsvector_op.c.
Referenced by TS_phrase_execute(), and TS_phrase_output().
#define TSPO_R_ONLY 0x02 /* emit positions appearing only in R */ |
Definition at line 1459 of file tsvector_op.c.
Referenced by TS_phrase_execute(), and TS_phrase_output().
#define TSVECTORCMPFUNC | ( | type, | |
action, | |||
ret | |||
) |
Definition at line 141 of file tsvector_op.c.
|
static |
Definition at line 362 of file tsvector_op.c.
References _POSVECPTR, WordEntry::haspos, i, LIMITPOS, MAXENTRYPOS, MAXNUMPOS, POSDATALEN, POSDATAPTR, WEP_GETPOS, WEP_GETWEIGHT, WEP_SETPOS, and WEP_SETWEIGHT.
Referenced by tsvector_concat().
Datum array_to_tsvector | ( | PG_FUNCTION_ARGS | ) |
Definition at line 749 of file tsvector_op.c.
References ARRPTR, CALCDATASIZE, compare_text_lexemes(), cur, deconstruct_array(), ereport, errcode(), errmsg(), ERROR, WordEntry::haspos, i, WordEntry::len, palloc0(), PG_FREE_IF_COPY, PG_GETARG_ARRAYTYPE_P, PG_RETURN_POINTER, WordEntry::pos, qsort, qunique(), SET_VARSIZE, TSVectorData::size, STRPTR, VARDATA, VARHDRSZ, and VARSIZE.
Definition at line 2116 of file tsvector_op.c.
References POSDATALEN, POSDATAPTR, and WEP_GETWEIGHT.
Referenced by insertStatEntry().
|
static |
Definition at line 1184 of file tsvector_op.c.
References ExecPhraseData::allocated, Assert, WordEntry::haspos, WordEntry::len, WordEntryPosVector::npos, ExecPhraseData::npos, palloc(), pfree(), WordEntry::pos, WordEntryPosVector::pos, ExecPhraseData::pos, SHORTALIGN, TS_MAYBE, TS_NO, TS_YES, CHKVAL::values, QueryOperand::weight, WEP_GETPOS, and WEP_GETWEIGHT.
Referenced by checkcondition_str().
|
static |
Definition at line 1290 of file tsvector_op.c.
References ExecPhraseData::allocated, CHKVAL::arrb, CHKVAL::arre, checkclass_str(), compareWordEntryPos(), difference(), QueryOperand::distance, WordEntry::len, QueryOperand::length, ExecPhraseData::npos, CHKVAL::operand, palloc(), pfree(), WordEntry::pos, ExecPhraseData::pos, QueryOperand::prefix, qsort, qunique(), repalloc(), TS_MAYBE, TS_NO, TS_YES, tsCompareString(), and CHKVAL::values.
Referenced by ts_match_vq().
|
static |
Definition at line 2203 of file tsvector_op.c.
References insertStatEntry().
Referenced by ts_accum().
|
static |
Definition at line 431 of file tsvector_op.c.
Referenced by tsvector_delete_by_indices().
|
static |
Definition at line 442 of file tsvector_op.c.
References tsCompareString(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Referenced by array_to_tsvector().
|
static |
Definition at line 2137 of file tsvector_op.c.
References ARRPTR, check_weight(), compareStatWord, WordEntry::haspos, StatEntry::left, WordEntry::len, StatEntry::lenlexeme, StatEntry::lexeme, TSVectorStat::maxdepth, MemoryContextAlloc(), StatEntry::ndoc, StatEntry::nentry, WordEntry::pos, POSDATALEN, StatEntry::right, TSVectorStat::root, STATENTRYHDRSZ, STRPTR, and TSVectorStat::weight.
Referenced by chooseNextStatEntry(), and ts_accum().
Definition at line 82 of file tsvector_op.c.
References ARRPTR, WordEntry::haspos, i, WordEntry::len, WordEntry::pos, POSDATALEN, POSDATAPTR, TSVectorData::size, STRPTR, tsCompareString(), VARSIZE, WEP_GETPOS, and WEP_GETWEIGHT.
|
static |
Definition at line 2235 of file tsvector_op.c.
References chooseNextStatEntry(), DatumGetPointer, DatumGetTSVector, i, insertStatEntry(), TSVectorStat::maxdepth, MemoryContextAllocZero(), pfree(), TSVectorData::size, and stat.
Referenced by ts_stat_sql().
bool TS_execute | ( | QueryItem * | curitem, |
void * | arg, | ||
uint32 | flags, | ||
TSExecuteCallback | chkcond | ||
) |
Definition at line 1846 of file tsvector_op.c.
References TS_execute_recurse(), and TS_NO.
Referenced by Cover(), gtsvector_consistent(), hlCover(), and ts_match_vq().
|
static |
Definition at line 1875 of file tsvector_op.c.
References CHECK_FOR_INTERRUPTS, check_stack_depth(), elog, ERROR, OP_AND, OP_NOT, OP_OR, OP_PHRASE, QI_VAL, TS_EXEC_PHRASE_NO_POS, TS_EXEC_SKIP_NOT, TS_MAYBE, TS_NO, TS_phrase_execute(), TS_YES, and QueryItem::type.
Referenced by TS_execute(), and TS_execute_ternary().
TSTernaryValue TS_execute_ternary | ( | QueryItem * | curitem, |
void * | arg, | ||
uint32 | flags, | ||
TSExecuteCallback | chkcond | ||
) |
Definition at line 1863 of file tsvector_op.c.
References TS_execute_recurse().
Referenced by gin_tsquery_consistent(), and gin_tsquery_triconsistent().
Datum ts_match_qv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2027 of file tsvector_op.c.
References DirectFunctionCall2, PG_GETARG_DATUM, PG_RETURN_DATUM, and ts_match_vq().
Datum ts_match_tq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2087 of file tsvector_op.c.
References DatumGetBool, DatumGetTSVector, DirectFunctionCall1, DirectFunctionCall2, pfree(), PG_FREE_IF_COPY, PG_GETARG_DATUM, PG_GETARG_TSQUERY, PG_RETURN_BOOL, to_tsvector(), ts_match_vq(), TSQueryGetDatum, and TSVectorGetDatum.
Datum ts_match_tt | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2065 of file tsvector_op.c.
References DatumGetBool, DatumGetTSQuery, DatumGetTSVector, DirectFunctionCall1, DirectFunctionCall2, pfree(), PG_GETARG_DATUM, PG_RETURN_BOOL, plainto_tsquery(), to_tsvector(), ts_match_vq(), TSQueryGetDatum, and TSVectorGetDatum.
Datum ts_match_vq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2035 of file tsvector_op.c.
References CHKVAL::arrb, CHKVAL::arre, ARRPTR, checkcondition_str(), GETOPERAND, GETQUERY, CHKVAL::operand, PG_FREE_IF_COPY, PG_GETARG_TSQUERY, PG_GETARG_TSVECTOR, PG_RETURN_BOOL, TSVectorData::size, TSQueryData::size, STRPTR, TS_EXEC_EMPTY, TS_execute(), val, and CHKVAL::values.
Referenced by ts_match_qv(), ts_match_tq(), and ts_match_tt().
|
static |
Definition at line 1604 of file tsvector_op.c.
References Assert, check_stack_depth(), QueryOperand::distance, elog, ERROR, Max, Min, ExecPhraseData::negate, ExecPhraseData::npos, OP_AND, OP_NOT, OP_OR, OP_PHRASE, QI_VAL, TS_EXEC_SKIP_NOT, TS_MAYBE, TS_NO, TS_phrase_output(), TS_YES, TSPO_BOTH, TSPO_L_ONLY, TSPO_R_ONLY, QueryItem::type, and ExecPhraseData::width.
Referenced by TS_execute_recurse().
|
static |
Definition at line 1463 of file tsvector_op.c.
References ExecPhraseData::allocated, Assert, ExecPhraseData::npos, palloc(), ExecPhraseData::pos, TS_NO, TS_YES, TSPO_BOTH, TSPO_L_ONLY, TSPO_R_ONLY, and WEP_GETPOS.
Referenced by TS_phrase_execute().
|
static |
Definition at line 2362 of file tsvector_op.c.
References FuncCallContext::attinmeta, BuildTupleFromCStrings(), HeapTupleGetDatum, StatEntry::lenlexeme, StatEntry::lexeme, StatEntry::ndoc, StatEntry::nentry, palloc(), pfree(), sprintf, FuncCallContext::user_fctx, values, and walkStatEntryTree().
Referenced by ts_stat1(), and ts_stat2().
|
static |
Definition at line 2270 of file tsvector_op.c.
References Assert, FuncCallContext::attinmeta, BlessTupleDesc(), CreateTemplateTupleDesc(), StatEntry::left, TSVectorStat::maxdepth, MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, palloc0(), TSVectorStat::root, TSVectorStat::stack, TSVectorStat::stackpos, FuncCallContext::tuple_desc, TupleDescGetAttInMetadata(), TupleDescInitEntry(), and FuncCallContext::user_fctx.
Referenced by ts_stat1(), and ts_stat2().
Datum ts_stat1 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2491 of file tsvector_op.c.
References FuncCallContext::multi_call_memory_ctx, PG_FREE_IF_COPY, PG_GETARG_TEXT_PP, SPI_connect(), SPI_finish(), SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, stat, ts_process_call(), ts_setup_firstcall(), and ts_stat_sql().
Datum ts_stat2 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2516 of file tsvector_op.c.
References FuncCallContext::multi_call_memory_ctx, PG_FREE_IF_COPY, PG_GETARG_TEXT_PP, SPI_connect(), SPI_finish(), SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, stat, ts_process_call(), ts_setup_firstcall(), and ts_stat_sql().
|
static |
Definition at line 2402 of file tsvector_op.c.
References buf, elog, ereport, errcode(), errmsg(), ERROR, i, IsBinaryCoercible(), TSVectorStat::maxdepth, MemoryContextAllocZero(), TupleDescData::natts, pfree(), pg_mblen(), SPI_cursor_close(), SPI_cursor_fetch(), SPI_cursor_open(), SPI_freeplan(), SPI_freetuptable(), SPI_getbinval(), SPI_gettypeid(), SPI_prepare(), SPI_processed, SPI_tuptable, stat, text_to_cstring(), ts_accum(), SPITupleTable::tupdesc, SPITupleTable::vals, VARDATA_ANY, VARSIZE_ANY_EXHDR, and TSVectorStat::weight.
Referenced by ts_stat1(), and ts_stat2().
Definition at line 1147 of file tsvector_op.c.
Referenced by checkcondition_str(), compare_text_lexemes(), compareentry(), compareQueryOperand(), compareWORD(), gin_cmp_prefix(), gin_cmp_tslexeme(), hlfinditem(), QTNodeCompare(), silly_cmp_tsvector(), and tsvector_bsearch().
Definition at line 1977 of file tsvector_op.c.
References check_stack_depth(), elog, ERROR, QueryOperator::left, OP_AND, OP_NOT, OP_OR, OP_PHRASE, QueryOperator::oper, QI_VAL, QueryItem::qoperator, tsquery_requires_match(), and QueryItem::type.
Referenced by gin_extract_tsquery(), and tsquery_requires_match().
|
static |
Definition at line 398 of file tsvector_op.c.
References ARRPTR, cmp(), TSVectorData::size, STRPTR, and tsCompareString().
Referenced by tsvector_delete_arr(), tsvector_delete_str(), and tsvector_setweight_by_filter().
Datum tsvector_concat | ( | PG_FUNCTION_ARGS | ) |
Definition at line 920 of file tsvector_op.c.
References _POSVECPTR, add_pos(), ARRPTR, Assert, CALCDATASIZE, cmp(), compareEntry, ereport, errcode(), errmsg(), ERROR, WordEntry::haspos, i, WordEntry::len, MAXSTRPOS, palloc0(), PG_FREE_IF_COPY, PG_GETARG_TSVECTOR, PG_RETURN_POINTER, WordEntry::pos, POSDATALEN, POSDATAPTR, SET_VARSIZE, SHORTALIGN, TSVectorData::size, STRPTR, VARSIZE, and WEP_GETPOS.
Datum tsvector_delete_arr | ( | PG_FUNCTION_ARGS | ) |
Definition at line 578 of file tsvector_op.c.
References deconstruct_array(), ereport, errcode(), errmsg(), ERROR, i, palloc0(), pfree(), PG_FREE_IF_COPY, PG_GETARG_ARRAYTYPE_P, PG_GETARG_TSVECTOR, PG_RETURN_POINTER, tsvector_bsearch(), tsvector_delete_by_indices(), VARDATA, VARHDRSZ, and VARSIZE.
|
static |
Definition at line 464 of file tsvector_op.c.
References ARRPTR, Assert, CALCDATASIZE, compare_int(), WordEntry::haspos, i, WordEntry::len, palloc0(), POSDATALEN, qsort, qunique(), SET_VARSIZE, SHORTALIGN, TSVectorData::size, STRPTR, and VARSIZE.
Referenced by tsvector_delete_arr(), and tsvector_delete_str().
Datum tsvector_delete_str | ( | PG_FUNCTION_ARGS | ) |
Definition at line 554 of file tsvector_op.c.
References StatEntry::lexeme, PG_FREE_IF_COPY, PG_GETARG_TEXT_PP, PG_GETARG_TSVECTOR, PG_RETURN_POINTER, tsvector_bsearch(), tsvector_delete_by_indices(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Datum tsvector_filter | ( | PG_FUNCTION_ARGS | ) |
Definition at line 813 of file tsvector_op.c.
References _POSVECPTR, ARRPTR, CALCDATASIZE, DatumGetChar, deconstruct_array(), ereport, errcode(), errmsg(), ERROR, i, WordEntry::len, WordEntryPosVector::npos, palloc0(), PG_FREE_IF_COPY, PG_GETARG_ARRAYTYPE_P, PG_GETARG_TSVECTOR, PG_RETURN_POINTER, WordEntryPosVector::pos, POSDATALEN, SET_VARSIZE, SHORTALIGN, TSVectorData::size, STRPTR, VARSIZE, weights, and WEP_GETWEIGHT.
Datum tsvector_length | ( | PG_FUNCTION_ARGS | ) |
Definition at line 197 of file tsvector_op.c.
References PG_FREE_IF_COPY, PG_GETARG_TSVECTOR, PG_RETURN_INT32, and TSVectorData::size.
Datum tsvector_setweight | ( | PG_FUNCTION_ARGS | ) |
Definition at line 207 of file tsvector_op.c.
References ARRPTR, elog, ERROR, i, palloc(), PG_FREE_IF_COPY, PG_GETARG_CHAR, PG_GETARG_TSVECTOR, PG_RETURN_POINTER, POSDATALEN, POSDATAPTR, TSVectorData::size, VARSIZE, and WEP_SETWEIGHT.
Datum tsvector_setweight_by_filter | ( | PG_FUNCTION_ARGS | ) |
Definition at line 269 of file tsvector_op.c.
References ARRPTR, deconstruct_array(), elog, ereport, errcode(), errmsg(), ERROR, i, palloc(), PG_FREE_IF_COPY, PG_GETARG_ARRAYTYPE_P, PG_GETARG_CHAR, PG_GETARG_TSVECTOR, PG_RETURN_POINTER, POSDATALEN, POSDATAPTR, tsvector_bsearch(), VARDATA, VARHDRSZ, VARSIZE, and WEP_SETWEIGHT.
Datum tsvector_strip | ( | PG_FUNCTION_ARGS | ) |
Definition at line 164 of file tsvector_op.c.
References ARRPTR, CALCDATASIZE, cur, i, WordEntry::len, palloc0(), PG_FREE_IF_COPY, PG_GETARG_TSVECTOR, PG_RETURN_POINTER, SET_VARSIZE, TSVectorData::size, and STRPTR.
Datum tsvector_to_array | ( | PG_FUNCTION_ARGS | ) |
Definition at line 722 of file tsvector_op.c.
References ARRPTR, construct_array(), cstring_to_text_with_len(), i, palloc(), pfree(), PG_FREE_IF_COPY, PG_GETARG_TSVECTOR, PG_RETURN_POINTER, PointerGetDatum, TSVectorData::size, and STRPTR.
Datum tsvector_unnest | ( | PG_FUNCTION_ARGS | ) |
Definition at line 634 of file tsvector_op.c.
References _POSVECPTR, ARRPTR, BlessTupleDesc(), FuncCallContext::call_cntr, construct_array(), CreateTemplateTupleDesc(), cstring_to_text_with_len(), heap_form_tuple(), HeapTupleGetDatum, i, Int16GetDatum, MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, WordEntryPosVector::npos, palloc(), PG_GETARG_TSVECTOR_COPY, PointerGetDatum, WordEntryPosVector::pos, TSVectorData::size, SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, STRPTR, FuncCallContext::tuple_desc, TupleDescInitEntry(), FuncCallContext::user_fctx, values, weights, WEP_GETPOS, and WEP_GETWEIGHT.
|
static |
Definition at line 2566 of file tsvector_op.c.
References bms_is_member(), CALLED_AS_TRIGGER, ParsedText::curwords, DatumGetObjectId, DatumGetPointer, DatumGetTextPP, elog, ereport, errcode(), errmsg(), ERROR, FirstLowInvalidHeapAttributeNumber, get_ts_config_oid(), heap_modify_tuple_by_cols(), i, IsBinaryCoercible(), ParsedText::lenwords, list_length(), make_tsvector(), numattr, palloc(), parsetext(), pfree(), PointerGetDatum, ParsedText::pos, RelationData::rd_att, SPI_ERROR_NOATTRIBUTE, SPI_fnumber(), SPI_getbinval(), SPI_gettypeid(), stringToQualifiedNameList(), TriggerData::tg_event, TriggerData::tg_newtuple, TriggerData::tg_relation, TriggerData::tg_trigger, TriggerData::tg_trigtuple, TriggerData::tg_updatedcols, Trigger::tgargs, Trigger::tgnargs, TRIGGER_FIRED_BEFORE, TRIGGER_FIRED_BY_INSERT, TRIGGER_FIRED_BY_UPDATE, TRIGGER_FIRED_FOR_ROW, TSVectorGetDatum, VARDATA_ANY, VARSIZE_ANY_EXHDR, and ParsedText::words.
Referenced by tsvector_update_trigger_bycolumn(), and tsvector_update_trigger_byid().
Datum tsvector_update_trigger_bycolumn | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2560 of file tsvector_op.c.
References tsvector_update_trigger().
Datum tsvector_update_trigger_byid | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2554 of file tsvector_op.c.
References tsvector_update_trigger().
TSVECTORCMPFUNC | ( | lt | ) |
TSVECTORCMPFUNC | ( | le | , |
<= | , | ||
BOOL | |||
) |
TSVECTORCMPFUNC | ( | eq | , |
BOOL | |||
) |
TSVECTORCMPFUNC | ( | ge | , |
>= | , | ||
BOOL | |||
) |
TSVECTORCMPFUNC | ( | gt | , |
BOOL | |||
) |
TSVECTORCMPFUNC | ( | ne | , |
! | , | ||
BOOL | |||
) |
TSVECTORCMPFUNC | ( | cmp | , |
+ | , | ||
INT32 | |||
) |
|
static |
Definition at line 2316 of file tsvector_op.c.
References Assert, StatEntry::left, TSVectorStat::maxdepth, StatEntry::ndoc, StatEntry::right, TSVectorStat::stack, and TSVectorStat::stackpos.
Referenced by ts_process_call().