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 |
Definition at line 351 of file tsvector_op.c.
Definition at line 2137 of file tsvector_op.c.
Definition at line 56 of file tsvector_op.c.
#define TSPO_BOTH 0x04 /* emit positions appearing in both L&R */ |
Definition at line 1466 of file tsvector_op.c.
#define TSPO_L_ONLY 0x01 /* emit positions appearing only in L */ |
Definition at line 1464 of file tsvector_op.c.
#define TSPO_R_ONLY 0x02 /* emit positions appearing only in R */ |
Definition at line 1465 of file tsvector_op.c.
#define TSVECTORCMPFUNC | ( | type, | |
action, | |||
ret | |||
) |
Definition at line 141 of file tsvector_op.c.
|
static |
Definition at line 361 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(), 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 2122 of file tsvector_op.c.
References len, POSDATALEN, POSDATAPTR, and WEP_GETWEIGHT.
Referenced by insertStatEntry().
|
static |
Definition at line 1190 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 1296 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 2208 of file tsvector_op.c.
References insertStatEntry().
Referenced by ts_accum().
|
static |
|
static |
Definition at line 441 of file tsvector_op.c.
References a, b, tsCompareString(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Referenced by array_to_tsvector().
|
static |
Definition at line 2143 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 82 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 2240 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 1852 of file tsvector_op.c.
References arg, TS_execute_recurse(), and TS_NO.
Referenced by Cover(), gtsvector_consistent(), hlCover(), and ts_match_vq().
|
static |
Definition at line 1881 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 1869 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 2033 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 2093 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 2071 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 2041 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 1610 of file tsvector_op.c.
References arg, Assert(), 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_recurse().
|
static |
Definition at line 1469 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_phrase_execute().
|
static |
Definition at line 2367 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 2275 of file tsvector_op.c.
References Assert(), FuncCallContext::attinmeta, BlessTupleDesc(), CreateTemplateTupleDesc(), StatEntry::left, MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, palloc0(), 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 2496 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 2521 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 2407 of file tsvector_op.c.
References buf, data, elog, ereport, errcode(), errmsg(), ERROR, i, IsBinaryCoercible(), 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, and VARSIZE_ANY_EXHDR.
Referenced by ts_stat1(), and ts_stat2().
Definition at line 1153 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().
Definition at line 1983 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 397 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 926 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, TSVectorData::size, STRPTR, VARSIZE, and WEP_GETPOS.
Datum tsvector_delete_arr | ( | PG_FUNCTION_ARGS | ) |
Definition at line 577 of file tsvector_op.c.
References deconstruct_array(), 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 463 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 553 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(), 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, 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, 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 269 of file tsvector_op.c.
References ARRPTR, deconstruct_array(), 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 164 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(), 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, BlessTupleDesc(), FuncCallContext::call_cntr, construct_array(), CreateTemplateTupleDesc(), cstring_to_text_with_len(), data, 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(), FuncCallContext::user_fctx, values, weights, WEP_GETPOS, and WEP_GETWEIGHT.
|
static |
Definition at line 2571 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 2565 of file tsvector_op.c.
References tsvector_update_trigger().
Datum tsvector_update_trigger_byid | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2559 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 2321 of file tsvector_op.c.
References Assert(), StatEntry::left, StatEntry::ndoc, and StatEntry::right.
Referenced by ts_process_call().