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 "common/int.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/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 |
Definition at line 354 of file tsvector_op.c.
Definition at line 2310 of file tsvector_op.c.
#define STATENTRYHDRSZ (offsetof(StatEntry, lexeme)) |
Definition at line 56 of file tsvector_op.c.
#define TSPO_BOTH 0x04 /* emit positions appearing in both L&R */ |
Definition at line 1465 of file tsvector_op.c.
#define TSPO_L_ONLY 0x01 /* emit positions appearing only in L */ |
Definition at line 1463 of file tsvector_op.c.
#define TSPO_R_ONLY 0x02 /* emit positions appearing only in R */ |
Definition at line 1464 of file tsvector_op.c.
#define TSVECTORCMPFUNC | ( | type, | |
action, | |||
ret | |||
) |
Definition at line 145 of file tsvector_op.c.
|
static |
Definition at line 364 of file tsvector_op.c.
References _POSVECPTR, generate_unaccent_rules::dest, 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 747 of file tsvector_op.c.
References ARRPTR, CALCDATASIZE, compare_text_lexemes(), cur, deconstruct_array_builtin(), ereport, errcode(), errmsg(), ERROR, WordEntry::haspos, i, WordEntry::len, nitems, 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 2295 of file tsvector_op.c.
References len, POSDATALEN, POSDATAPTR, and WEP_GETWEIGHT.
Referenced by insertStatEntry().
|
static |
Definition at line 1189 of file tsvector_op.c.
References Assert, data, WordEntry::haspos, WordEntry::len, WordEntryPosVector::npos, palloc(), pfree(), WordEntry::pos, WordEntryPosVector::pos, SHORTALIGN, TS_MAYBE, TS_NO, TS_YES, val, CHKVAL::values, WEP_GETPOS, and WEP_GETWEIGHT.
Referenced by checkcondition_str().
|
static |
Definition at line 1295 of file tsvector_op.c.
References CHKVAL::arrb, CHKVAL::arre, checkclass_str(), compareWordEntryPos(), data, difference(), WordEntry::len, CHKVAL::operand, palloc(), pfree(), WordEntry::pos, qsort, qunique(), repalloc(), res, TS_MAYBE, TS_NO, TS_YES, tsCompareString(), val, and CHKVAL::values.
Referenced by ts_match_vq().
|
static |
Definition at line 2381 of file tsvector_op.c.
References insertStatEntry(), and size.
Referenced by ts_accum().
|
static |
Definition at line 433 of file tsvector_op.c.
References a, b, and pg_cmp_s32().
Referenced by tsvector_delete_by_indices().
|
static |
Definition at line 442 of file tsvector_op.c.
References a, b, tsCompareString(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Referenced by array_to_tsvector().
|
static |
Definition at line 2316 of file tsvector_op.c.
References ARRPTR, check_weight(), compareStatWord, WordEntry::haspos, StatEntry::left, WordEntry::len, StatEntry::lenlexeme, StatEntry::lexeme, MemoryContextAlloc(), StatEntry::ndoc, StatEntry::nentry, WordEntry::pos, POSDATALEN, res, StatEntry::right, STATENTRYHDRSZ, and STRPTR.
Referenced by chooseNextStatEntry(), and ts_accum().
Definition at line 86 of file tsvector_op.c.
References a, ARRPTR, b, WordEntry::haspos, i, j, WordEntry::len, WordEntry::pos, POSDATALEN, POSDATAPTR, res, STRPTR, tsCompareString(), VARSIZE, WEP_GETPOS, and WEP_GETWEIGHT.
|
static |
Definition at line 2413 of file tsvector_op.c.
References chooseNextStatEntry(), data, DatumGetPointer(), DatumGetTSVector(), i, insertStatEntry(), 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 1854 of file tsvector_op.c.
References arg, TS_execute_recurse(), and TS_NO.
Referenced by Cover(), gtsvector_consistent(), hlCover(), and ts_match_vq().
List* TS_execute_locations | ( | QueryItem * | curitem, |
void * | arg, | ||
uint32 | flags, | ||
TSExecuteCallback | chkcond | ||
) |
Definition at line 2007 of file tsvector_op.c.
References arg, Assert, NIL, TS_EXEC_EMPTY, and TS_execute_locations_recurse().
Referenced by prsd_headline().
|
static |
Definition at line 2025 of file tsvector_op.c.
References arg, CHECK_FOR_INTERRUPTS, check_stack_depth(), data, elog, ERROR, lappend(), QueryOperator::left, lfirst, list_concat(), list_make1, Max, NIL, ExecPhraseData::npos, OP_AND, OP_NOT, OP_OR, OP_PHRASE, QueryOperator::oper, palloc0_object, pfree(), QI_VAL, QueryItem::qoperator, TS_EXEC_EMPTY, TS_phrase_execute(), TS_phrase_output(), TS_YES, TSPO_BOTH, TSPO_L_ONLY, TSPO_R_ONLY, QueryItem::type, and ExecPhraseData::width.
Referenced by TS_execute_locations().
|
static |
Definition at line 1883 of file tsvector_op.c.
References arg, CHECK_FOR_INTERRUPTS, check_stack_depth(), elog, ERROR, QueryOperator::left, OP_AND, OP_NOT, OP_OR, OP_PHRASE, QueryOperator::oper, QI_VAL, QueryItem::qoperator, 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 1871 of file tsvector_op.c.
References arg, and TS_execute_recurse().
Referenced by gin_tsquery_consistent(), and gin_tsquery_triconsistent().
Datum ts_match_qv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2206 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 2266 of file tsvector_op.c.
References DatumGetBool(), DatumGetTSVector(), DirectFunctionCall1, DirectFunctionCall2, pfree(), PG_FREE_IF_COPY, PG_GETARG_DATUM, PG_GETARG_TSQUERY, PG_RETURN_BOOL, res, to_tsvector(), ts_match_vq(), TSQueryGetDatum(), and TSVectorGetDatum().
Datum ts_match_tt | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2244 of file tsvector_op.c.
References DatumGetBool(), DatumGetTSQuery(), DatumGetTSVector(), DirectFunctionCall1, DirectFunctionCall2, pfree(), PG_GETARG_DATUM, PG_RETURN_BOOL, plainto_tsquery(), res, to_tsvector(), ts_match_vq(), TSQueryGetDatum(), and TSVectorGetDatum().
Datum ts_match_vq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2214 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, 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 1609 of file tsvector_op.c.
References arg, Assert, CHECK_FOR_INTERRUPTS, check_stack_depth(), data, QueryOperator::distance, elog, ERROR, QueryOperator::left, Max, Min, ExecPhraseData::negate, ExecPhraseData::npos, OP_AND, OP_NOT, OP_OR, OP_PHRASE, QueryOperator::oper, QI_VAL, QueryItem::qoperator, 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_locations_recurse(), and TS_execute_recurse().
|
static |
Definition at line 1468 of file tsvector_op.c.
References Assert, data, palloc(), ExecPhraseData::pos, TS_NO, TS_YES, TSPO_BOTH, TSPO_L_ONLY, TSPO_R_ONLY, and WEP_GETPOS.
Referenced by TS_execute_locations_recurse(), and TS_phrase_execute().
|
static |
Definition at line 2535 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 2448 of file tsvector_op.c.
References Assert, FuncCallContext::attinmeta, elog, ERROR, get_call_result_type(), StatEntry::left, MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, palloc0(), stat, FuncCallContext::tuple_desc, TupleDescGetAttInMetadata(), TYPEFUNC_COMPOSITE, and FuncCallContext::user_fctx.
Referenced by ts_stat1(), and ts_stat2().
Datum ts_stat1 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2664 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 2689 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 2575 of file tsvector_op.c.
References buf, data, elog, ereport, errcode(), errmsg(), ERROR, i, IsBinaryCoercible(), MemoryContextAllocZero(), TupleDescData::natts, pfree(), pg_mblen(), plan, 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, and VARSIZE_ANY_EXHDR.
Referenced by ts_stat1(), and ts_stat2().
int32 tsCompareString | ( | char * | a, |
int | lena, | ||
char * | b, | ||
int | lenb, | ||
bool | prefix | ||
) |
Definition at line 1152 of file tsvector_op.c.
References a, b, cmp(), and Min.
Referenced by checkcondition_str(), compare_text_lexemes(), compareentry(), compareQueryOperand(), compareWORD(), gin_cmp_prefix(), gin_cmp_tslexeme(), hlfinditem(), QTNodeCompare(), silly_cmp_tsvector(), and tsvector_bsearch().
bool tsquery_requires_match | ( | QueryItem * | curitem | ) |
Definition at line 2156 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, and QueryItem::type.
Referenced by gin_extract_tsquery().
|
static |
Definition at line 400 of file tsvector_op.c.
References ARRPTR, cmp(), len, StatEntry::lexeme, 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 925 of file tsvector_op.c.
References _POSVECPTR, add_pos(), ARRPTR, Assert, CALCDATASIZE, cmp(), compareEntry, data, ereport, errcode(), errmsg(), ERROR, WordEntry::haspos, i, j, WordEntry::len, MAXSTRPOS, palloc0(), PG_FREE_IF_COPY, PG_GETARG_TSVECTOR, PG_RETURN_POINTER, WordEntry::pos, POSDATALEN, POSDATAPTR, SET_VARSIZE, SHORTALIGN, size, 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_builtin(), 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(), data, WordEntry::haspos, i, j, WordEntry::len, 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 819 of file tsvector_op.c.
References _POSVECPTR, ARRPTR, CALCDATASIZE, DatumGetChar(), deconstruct_array_builtin(), ereport, errcode(), errmsg(), ERROR, i, j, WordEntry::len, 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, and WEP_GETWEIGHT.
Datum tsvector_length | ( | PG_FUNCTION_ARGS | ) |
Definition at line 201 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 211 of file tsvector_op.c.
References ARRPTR, elog, ERROR, i, j, 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 273 of file tsvector_op.c.
References ARRPTR, deconstruct_array_builtin(), elog, ERROR, i, j, 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 168 of file tsvector_op.c.
References ARRPTR, CALCDATASIZE, cur, i, WordEntry::len, 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 720 of file tsvector_op.c.
References ARRPTR, construct_array_builtin(), cstring_to_text_with_len(), i, len, 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 632 of file tsvector_op.c.
References _POSVECPTR, ARRPTR, FuncCallContext::call_cntr, construct_array_builtin(), CreateTemplateTupleDesc(), cstring_to_text_with_len(), data, elog, ERROR, get_call_result_type(), heap_form_tuple(), HeapTupleGetDatum(), i, if(), Int16GetDatum(), j, len, 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(), TYPEFUNC_COMPOSITE, FuncCallContext::user_fctx, values, WEP_GETPOS, and WEP_GETWEIGHT.
|
static |
Definition at line 2739 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, if(), 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 2733 of file tsvector_op.c.
References tsvector_update_trigger().
Datum tsvector_update_trigger_byid | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2727 of file tsvector_op.c.
References tsvector_update_trigger().
TSVECTORCMPFUNC | ( | cmp | , |
+ | , | ||
INT32 | |||
) |
TSVECTORCMPFUNC | ( | eq | , |
BOOL | |||
) |
TSVECTORCMPFUNC | ( | ge | , |
>= | , | ||
BOOL | |||
) |
TSVECTORCMPFUNC | ( | gt | , |
BOOL | |||
) |
TSVECTORCMPFUNC | ( | le | , |
<= | , | ||
BOOL | |||
) |
TSVECTORCMPFUNC | ( | lt | ) |
TSVECTORCMPFUNC | ( | ne | , |
! | , | ||
BOOL | |||
) |
|
static |
Definition at line 2489 of file tsvector_op.c.
References Assert, StatEntry::left, StatEntry::ndoc, and StatEntry::right.
Referenced by ts_process_call().