45 #include "utils/fmgroids.h" 59 #define MAXTOKENTYPE 256 60 #define MAXDICTSPERTT 100 104 if (hash == TSConfigCacheHash)
116 if (TSParserCacheHash == NULL)
121 MemSet(&ctl, 0,
sizeof(ctl));
124 TSParserCacheHash =
hash_create(
"Tsearch parser cache", 4,
136 if (lastUsedParser && lastUsedParser->
prsId == prsId &&
144 if (entry == NULL || !entry->
isvalid)
155 elog(
ERROR,
"cache lookup failed for text search parser %u",
163 elog(
ERROR,
"text search parser %u has no prsstart method", prsId);
165 elog(
ERROR,
"text search parser %u has no prstoken method", prsId);
167 elog(
ERROR,
"text search parser %u has no prsend method", prsId);
182 entry->
prsId = prsId;
185 entry->
endOid = prs->prsend;
201 lastUsedParser = entry;
214 if (TSDictionaryCacheHash == NULL)
219 MemSet(&ctl, 0,
sizeof(ctl));
222 TSDictionaryCacheHash =
hash_create(
"Tsearch dictionary cache", 8,
236 if (lastUsedDictionary && lastUsedDictionary->
dictId == dictId &&
244 if (entry == NULL || !entry->
isvalid)
258 elog(
ERROR,
"cache lookup failed for text search dictionary %u",
266 elog(
ERROR,
"text search dictionary %u has no template", dictId);
274 elog(
ERROR,
"cache lookup failed for text search template %u",
282 elog(
ERROR,
"text search template %u has no lexize method",
283 template->tmpllexize);
332 Anum_pg_ts_dict_dictinitoption,
354 lastUsedDictionary = entry;
369 MemSet(&ctl, 0,
sizeof(ctl));
372 TSConfigCacheHash =
hash_create(
"Tsearch configuration cache", 16,
393 if (TSConfigCacheHash == NULL)
400 if (lastUsedConfig && lastUsedConfig->
cfgId == cfgId &&
408 if (entry == NULL || !entry->
isvalid)
429 elog(
ERROR,
"cache lookup failed for text search configuration %u",
437 elog(
ERROR,
"text search configuration %u has no parser", cfgId);
455 for (i = 0; i < entry->
lenmap; i++)
463 entry->
cfgId = cfgId;
464 entry->
prsId = cfg->cfgparser;
475 MemSet(maplists, 0,
sizeof(maplists));
480 Anum_pg_ts_config_map_mapcfg,
492 int toktype = cfgmap->maptokentype;
495 elog(
ERROR,
"maptokentype value %d is out of range", toktype);
496 if (toktype < maxtokentype)
497 elog(
ERROR,
"maptokentype entries are out of order");
498 if (toktype > maxtokentype)
503 maplists[maxtokentype].
len = ndicts;
506 sizeof(
Oid) * ndicts);
507 memcpy(maplists[maxtokentype].dictIds, mapdicts,
508 sizeof(
Oid) * ndicts);
510 maxtokentype = toktype;
511 mapdicts[0] = cfgmap->mapdict;
518 elog(
ERROR,
"too many pg_ts_config_map entries for one token type");
519 mapdicts[ndicts++] = cfgmap->mapdict;
530 maplists[maxtokentype].
len = ndicts;
533 sizeof(
Oid) * ndicts);
534 memcpy(maplists[maxtokentype].dictIds, mapdicts,
535 sizeof(
Oid) * ndicts);
537 entry->
lenmap = maxtokentype + 1;
541 memcpy(entry->
map, maplists,
548 lastUsedConfig = entry;
570 elog(
ERROR,
"text search configuration isn't set");
575 if (TSConfigCacheHash == NULL)
616 (
errcode(ERRCODE_UNDEFINED_OBJECT),
617 errmsg(
"text search configuration \"%s\" does not exist", *newval)));
630 elog(
ERROR,
"cache lookup failed for text search configuration %u",
641 *newval = strdup(buf);
#define AllocSetContextCreate
void table_close(Relation relation, LOCKMODE lockmode)
FormData_pg_ts_config * Form_pg_ts_config
Oid getTSCurrentConfig(bool emitError)
FormData_pg_ts_config_map * Form_pg_ts_config_map
#define PointerGetDatum(X)
static TSDictionaryCacheEntry * lastUsedDictionary
List * deserialize_deflist(Datum txt)
#define ALLOCSET_SMALL_SIZES
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
int errcode(int sqlerrcode)
Oid get_ts_config_oid(List *names, bool missing_ok)
#define MemSet(start, val, len)
void MemoryContextReset(MemoryContext context)
TSParserCacheEntry * lookup_ts_parser_cache(Oid prsId)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HeapTuple systable_getnext_ordered(SysScanDesc sysscan, ScanDirection direction)
#define OidIsValid(objectId)
TSDictionaryCacheEntry * lookup_ts_dictionary_cache(Oid dictId)
static Oid TSCurrentConfigCache
void pfree(void *pointer)
#define ObjectIdGetDatum(X)
TSConfigCacheEntry * lookup_ts_config_cache(Oid cfgId)
#define OidFunctionCall1(functionId, arg1)
FormData_pg_ts_dict * Form_pg_ts_dict
static HTAB * TSParserCacheHash
char * get_namespace_name(Oid nspid)
#define MemoryContextCopyAndSetIdentifier(cxt, id)
void assign_TSCurrentConfig(const char *newval, void *extra)
void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
static void InvalidateTSCacheCallBack(Datum arg, int cacheid, uint32 hashvalue)
#define ereport(elevel, rest)
char * quote_qualified_identifier(const char *qualifier, const char *ident)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
void CacheRegisterSyscacheCallback(int cacheid, SyscacheCallbackFunction func, Datum arg)
HTAB * hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
void ReleaseSysCache(HeapTuple tuple)
FormData_pg_ts_parser * Form_pg_ts_parser
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
void systable_endscan_ordered(SysScanDesc sysscan)
static void init_ts_config_cache(void)
static TSParserCacheEntry * lastUsedParser
static HTAB * TSConfigCacheHash
#define HeapTupleIsValid(tuple)
#define Assert(condition)
void CreateCacheMemoryContext(void)
bool IsTransactionState(void)
void MemoryContextSetIdentifier(MemoryContext context, const char *id)
void * hash_seq_search(HASH_SEQ_STATUS *status)
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
static TSConfigCacheEntry * lastUsedConfig
void index_close(Relation relation, LOCKMODE lockmode)
#define DatumGetPointer(X)
List * stringToQualifiedNameList(const char *string)
int errmsg(const char *fmt,...)
SysScanDesc systable_beginscan_ordered(Relation heapRelation, Relation indexRelation, Snapshot snapshot, int nkeys, ScanKey key)
void * MemoryContextAlloc(MemoryContext context, Size size)
FormData_pg_ts_template * Form_pg_ts_template
struct TSParserCacheEntry TSParserCacheEntry
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
static HTAB * TSDictionaryCacheHash
#define TSConfigMapIndexId
static void static void status(const char *fmt,...) pg_attribute_printf(1
Relation table_open(Oid relationId, LOCKMODE lockmode)
struct TSDictionaryCacheEntry TSDictionaryCacheEntry
static unsigned hash(unsigned *uv, int n)
bool check_TSCurrentConfig(char **newval, void **extra, GucSource source)
Relation index_open(Oid relationId, LOCKMODE lockmode)
#define BTEqualStrategyNumber
MemoryContext CacheMemoryContext