|
PostgreSQL Source Code git master
|
#include "postgres.h"#include "catalog/pg_collation_d.h"#include "regex/regexport.h"#include "trgm.h"#include "tsearch/ts_locale.h"#include "utils/formatting.h"#include "utils/hsearch.h"#include "utils/memutils.h"#include "varatt.h"
Go to the source code of this file.
Data Structures | |
| struct | trgm_mb_char |
| struct | TrgmColorInfo |
| struct | TrgmPrefix |
| struct | ColorTrgm |
| struct | TrgmStateKey |
| struct | TrgmState |
| struct | TrgmArc |
| struct | TrgmArcInfo |
| struct | ColorTrgmInfo |
| struct | TrgmNFA |
| struct | TrgmPackedArc |
| struct | TrgmPackedState |
| struct | TrgmPackedGraph |
| struct | TrgmPackArcInfo |
Macros | |
| #define | MAX_EXPANDED_STATES 128 |
| #define | MAX_EXPANDED_ARCS 1024 |
| #define | MAX_TRGM_COUNT 256 |
| #define | WISH_TRGM_PENALTY 16 |
| #define | COLOR_COUNT_LIMIT 256 |
| #define | COLOR_UNKNOWN (-3) |
| #define | COLOR_BLANK (-4) |
| #define | TSTATE_INIT 0x01 /* flag indicating this state is initial */ |
| #define | TSTATE_FIN 0x02 /* flag indicating this state is final */ |
Typedefs | |
| typedef int | TrgmColor |
| typedef struct TrgmState | TrgmState |
Variables | |
| static const float4 | penalties [8] |
| #define COLOR_BLANK (-4) |
Definition at line 289 of file trgm_regexp.c.
| #define COLOR_COUNT_LIMIT 256 |
Definition at line 225 of file trgm_regexp.c.
| #define COLOR_UNKNOWN (-3) |
Definition at line 288 of file trgm_regexp.c.
| #define MAX_EXPANDED_ARCS 1024 |
Definition at line 222 of file trgm_regexp.c.
| #define MAX_EXPANDED_STATES 128 |
Definition at line 221 of file trgm_regexp.c.
| #define MAX_TRGM_COUNT 256 |
Definition at line 223 of file trgm_regexp.c.
Definition at line 332 of file trgm_regexp.c.
Definition at line 331 of file trgm_regexp.c.
| #define WISH_TRGM_PENALTY 16 |
Definition at line 224 of file trgm_regexp.c.
Definition at line 285 of file trgm_regexp.c.
|
static |
Definition at line 1287 of file trgm_regexp.c.
References fb(), getState(), lappend(), lfirst, palloc_object, prefixContains(), and validArcLabel().
Referenced by addArcs().
Definition at line 1189 of file trgm_regexp.c.
References addArc(), Assert, arc::co, COLOR_BLANK, TrgmColorInfo::containsNonWord, TrgmColorInfo::expandable, fb(), i, lfirst, MemSet, palloc_array, pfree(), pg_reg_getnumoutarcs(), pg_reg_getoutarcs(), arc::to, and TrgmColorInfo::wordCharsCount.
Referenced by processState().
|
static |
Definition at line 1008 of file trgm_regexp.c.
References addKeyToQueue(), arc::co, COLOR_BLANK, COLOR_UNKNOWN, TrgmColorInfo::containsNonWord, TrgmColorInfo::expandable, fb(), foreach_delete_current, i, lappend(), lfirst, MemSet, palloc_array, pfree(), pg_reg_colorisbegin(), pg_reg_colorisend(), pg_reg_getfinalstate(), pg_reg_getnumoutarcs(), pg_reg_getoutarcs(), prefixContains(), arc::to, TSTATE_FIN, validArcLabel(), and TrgmColorInfo::wordCharsCount.
Referenced by processState().
|
static |
Definition at line 1177 of file trgm_regexp.c.
References fb(), lappend(), and palloc_object.
Referenced by addKey().
Definition at line 1893 of file trgm_regexp.c.
References fb().
Referenced by packGraph(), and selectColorTrigrams().
Definition at line 1906 of file trgm_regexp.c.
References fb().
Referenced by selectColorTrigrams().
|
static |
Definition at line 828 of file trgm_regexp.c.
References trgm_mb_char::bytes, fb(), MAX_MULTIBYTE_CHAR_LEN, pfree(), pg_wchar2mb_with_len(), and str_tolower().
Referenced by getColorInfo().
| TRGM * createTrgmNFA | ( | text * | text_re, |
| Oid | collation, | ||
| TrgmPackedGraph ** | graph, | ||
| MemoryContext | rcontext | ||
| ) |
Definition at line 524 of file trgm_regexp.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, createTrgmNFAInternal(), CurrentMemoryContext, fb(), MemoryContextDelete(), MemoryContextSwitchTo(), RE_compile(), REG_ADVANCED, REG_ICASE, REG_NOSUB, and regex_t.
Referenced by gin_extract_query_trgm(), and gtrgm_consistent().
|
static |
Definition at line 567 of file trgm_regexp.c.
References expandColorTrigrams(), fb(), getColorInfo(), packGraph(), TrgmNFA::regex, selectColorTrigrams(), transformGraph(), and TSTATE_FIN.
Referenced by createTrgmNFA().
|
static |
Definition at line 1776 of file trgm_regexp.c.
References ARRKEY, CALCGTSIZE, COLOR_BLANK, ColorTrgm::colors, ColorTrgmInfo::ctrgm, ColorTrgmInfo::expanded, fb(), fillTrgm(), TRGM::flag, GETARR, i, j, MemoryContextAllocZero(), SET_VARSIZE(), and TRGMHDRSIZE.
Referenced by createTrgmNFAInternal().
|
static |
Definition at line 1844 of file trgm_regexp.c.
References trgm_mb_char::bytes, compact_trigram(), fb(), i, j, MAX_MULTIBYTE_CHAR_LEN, and str.
Referenced by expandColorTrigrams().
Definition at line 765 of file trgm_regexp.c.
References chars, COLOR_COUNT_LIMIT, TrgmColorInfo::containsNonWord, convertPgWchar(), TrgmColorInfo::expandable, fb(), i, ISWORDCHR, j, palloc0(), palloc_array, pfree(), pg_reg_getcharacters(), pg_reg_getnumcharacters(), pg_reg_getnumcolors(), TrgmColorInfo::wordChars, and TrgmColorInfo::wordCharsCount.
Referenced by createTrgmNFAInternal().
|
static |
Definition at line 1384 of file trgm_regexp.c.
References fb(), HASH_ENTER, hash_search(), lappend(), and NIL.
Referenced by addArc(), and transformGraph().
Definition at line 1876 of file trgm_regexp.c.
Referenced by selectColorTrigrams().
Definition at line 2091 of file trgm_regexp.c.
Referenced by packGraph().
|
static |
Definition at line 1931 of file trgm_regexp.c.
References TrgmPackedState::arcs, TrgmPackedState::arcsCount, Assert, ColorTrgmInfo::cnumber, TrgmPackArcInfo::colorTrgm, colorTrgmInfoCmp(), TrgmPackedGraph::colorTrigramGroups, TrgmPackedGraph::colorTrigramsActive, TrgmPackedGraph::colorTrigramsCount, ColorTrgmInfo::expanded, fb(), hash_seq_init(), hash_seq_search(), i, j, lfirst, MemoryContextAlloc(), packArcInfoCmp(), palloc_array, TrgmState::parent, qsort, TrgmState::snumber, source, TrgmPackArcInfo::sourceState, TrgmPackedGraph::states, TrgmPackedGraph::statesActive, TrgmPackedGraph::statesCount, TrgmPackedGraph::statesQueue, TrgmPackedArc::targetState, TrgmPackArcInfo::targetState, TSTATE_FIN, and TSTATE_INIT.
Referenced by createTrgmNFAInternal().
|
static |
Definition at line 1415 of file trgm_regexp.c.
References COLOR_UNKNOWN, and fb().
Definition at line 958 of file trgm_regexp.c.
References addArcs(), addKey(), fb(), lfirst, list_free(), NIL, and TSTATE_FIN.
Referenced by transformGraph().
Definition at line 721 of file trgm_regexp.c.
References ereport, errcode(), errmsg(), ERROR, fb(), palloc(), pfree(), pg_mb2wchar_with_len(), pg_regcomp(), pg_regerror(), REG_OKAY, VARDATA_ANY(), and VARSIZE_ANY_EXHDR().
Referenced by createTrgmNFA().
Definition at line 1457 of file trgm_regexp.c.
References ColorTrgmInfo::arcs, Assert, ColorTrgmInfo::cnumber, COLOR_BLANK, ColorTrgm::colors, colorTrgmInfoCmp(), colorTrgmInfoPenaltyCmp(), ColorTrgmInfo::ctrgm, fb(), fprintf, hash_seq_init(), hash_seq_search(), i, j, lfirst, list_concat(), list_length(), list_make1, MAX_TRGM_COUNT, mergeStates(), palloc0_array, palloc_object, penalties, qsort, source, TSTATE_FIN, TSTATE_INIT, and WISH_TRGM_PENALTY.
Referenced by createTrgmNFAInternal().
Definition at line 894 of file trgm_regexp.c.
References COLOR_UNKNOWN, CurrentMemoryContext, fb(), TrgmState::flags, getState(), HASH_BLOBS, HASH_CONTEXT, hash_create(), HASH_ELEM, hash_get_num_entries(), lfirst, MAX_EXPANDED_ARCS, MAX_EXPANDED_STATES, MemSet, NIL, pg_reg_getinitialstate(), processState(), TSTATE_FIN, and TSTATE_INIT.
Referenced by createTrgmNFAInternal().
| bool trigramsMatchGraph | ( | TrgmPackedGraph * | graph, |
| bool * | check | ||
| ) |
Definition at line 628 of file trgm_regexp.c.
References TrgmPackedGraph::colorTrigramGroups, TrgmPackedGraph::colorTrigramsActive, TrgmPackedGraph::colorTrigramsCount, fb(), i, j, TrgmPackedGraph::states, TrgmPackedGraph::statesActive, TrgmPackedGraph::statesCount, and TrgmPackedGraph::statesQueue.
Referenced by gin_trgm_consistent(), gin_trgm_triconsistent(), and gtrgm_consistent().
|
static |
Definition at line 1329 of file trgm_regexp.c.
References Assert, COLOR_BLANK, and COLOR_UNKNOWN.
Definition at line 231 of file trgm_regexp.c.
Referenced by selectColorTrigrams().