/* Try to look up an existing entry */
entry = (TSParserCacheEntry *) hash_search(TSParserCacheHash,
&prsId,
HASH_FIND, NULL); if (entry == NULL || !entry->isvalid)
{ /* *Ifwedidn'tfindone,wewanttomakeone.Butfirstlookupthe *objecttobesuretheOIDisreal.
*/
HeapTuple tp;
Form_pg_ts_parser prs;
tp = SearchSysCache1(TSPARSEROID, ObjectIdGetDatum(prsId)); if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for text search parser %u",
prsId);
prs = (Form_pg_ts_parser) GETSTRUCT(tp);
/* *Sanitychecks
*/ if (!OidIsValid(prs->prsstart))
elog(ERROR, "text search parser %u has no prsstart method", prsId); if (!OidIsValid(prs->prstoken))
elog(ERROR, "text search parser %u has no prstoken method", prsId); if (!OidIsValid(prs->prsend))
elog(ERROR, "text search parser %u has no prsend method", prsId);
if (entry == NULL)
{ bool found;
/* Now make the cache entry */
entry = (TSParserCacheEntry *)
hash_search(TSParserCacheHash, &prsId, HASH_ENTER, &found);
Assert(!found); /* it wasn't there a moment ago */
}
/* Try to look up an existing entry */
entry = (TSDictionaryCacheEntry *) hash_search(TSDictionaryCacheHash,
&dictId,
HASH_FIND, NULL); if (entry == NULL || !entry->isvalid)
{ /* *Ifwedidn'tfindone,wewanttomakeone.Butfirstlookupthe *objecttobesuretheOIDisreal.
*/
HeapTuple tpdict,
tptmpl;
Form_pg_ts_dict dict;
Form_pg_ts_template template;
MemoryContext saveCtx;
tpdict = SearchSysCache1(TSDICTOID, ObjectIdGetDatum(dictId)); if (!HeapTupleIsValid(tpdict))
elog(ERROR, "cache lookup failed for text search dictionary %u",
dictId);
dict = (Form_pg_ts_dict) GETSTRUCT(tpdict);
/* *Sanitychecks
*/ if (!OidIsValid(dict->dicttemplate))
elog(ERROR, "text search dictionary %u has no template", dictId);
/* *Retrievedictionary'stemplate
*/
tptmpl = SearchSysCache1(TSTEMPLATEOID,
ObjectIdGetDatum(dict->dicttemplate)); if (!HeapTupleIsValid(tptmpl))
elog(ERROR, "cache lookup failed for text search template %u",
dict->dicttemplate); template = (Form_pg_ts_template) GETSTRUCT(tptmpl);
/* *Sanitychecks
*/ if (!OidIsValid(template->tmpllexize))
elog(ERROR, "text search template %u has no lexize method", template->tmpllexize);
if (entry == NULL)
{ bool found;
/* Now make the cache entry */
entry = (TSDictionaryCacheEntry *)
hash_search(TSDictionaryCacheHash,
&dictId,
HASH_ENTER, &found);
Assert(!found); /* it wasn't there a moment ago */
/* Create private memory context the first time through */
saveCtx = AllocSetContextCreate(CacheMemoryContext, "TS dictionary",
ALLOCSET_SMALL_SIZES);
MemoryContextCopyAndSetIdentifier(saveCtx, NameStr(dict->dictname));
} else
{ /* Clear the existing entry's private context */
saveCtx = entry->dictCtx; /* Don't let context's ident pointer dangle while we reset it */
MemoryContextSetIdentifier(saveCtx, NULL);
MemoryContextReset(saveCtx);
MemoryContextCopyAndSetIdentifier(saveCtx, NameStr(dict->dictname));
}
/* Try to look up an existing entry */
entry = (TSConfigCacheEntry *) hash_search(TSConfigCacheHash,
&cfgId,
HASH_FIND, NULL); if (entry == NULL || !entry->isvalid)
{ /* *Ifwedidn'tfindone,wewanttomakeone.Butfirstlookupthe *objecttobesuretheOIDisreal.
*/
HeapTuple tp;
Form_pg_ts_config cfg;
Relation maprel;
Relation mapidx;
ScanKeyData mapskey;
SysScanDesc mapscan;
HeapTuple maptup;
ListDictionary maplists[MAXTOKENTYPE + 1];
Oid mapdicts[MAXDICTSPERTT]; int maxtokentype; int ndicts; int i;
tp = SearchSysCache1(TSCONFIGOID, ObjectIdGetDatum(cfgId)); if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for text search configuration %u",
cfgId);
cfg = (Form_pg_ts_config) GETSTRUCT(tp);
/* *Sanitychecks
*/ if (!OidIsValid(cfg->cfgparser))
elog(ERROR, "text search configuration %u has no parser", cfgId);
if (entry == NULL)
{ bool found;
/* Now make the cache entry */
entry = (TSConfigCacheEntry *)
hash_search(TSConfigCacheHash,
&cfgId,
HASH_ENTER, &found);
Assert(!found); /* it wasn't there a moment ago */
} else
{ /* Cleanup old contents */ if (entry->map)
{ for (i = 0; i < entry->lenmap; i++) if (entry->map[i].dictIds)
pfree(entry->map[i].dictIds);
pfree(entry->map);
}
}
while ((maptup = systable_getnext_ordered(mapscan, ForwardScanDirection)) != NULL)
{
Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup); int toktype = cfgmap->maptokentype;
if (toktype <= 0 || toktype > MAXTOKENTYPE)
elog(ERROR, "maptokentype value %d is out of range", toktype); if (toktype < maxtokentype)
elog(ERROR, "maptokentype entries are out of order"); if (toktype > maxtokentype)
{ /* starting a new token type, but first save the prior data */ if (ndicts > 0)
{
maplists[maxtokentype].len = ndicts;
maplists[maxtokentype].dictIds = (Oid *)
MemoryContextAlloc(CacheMemoryContext, sizeof(Oid) * ndicts);
memcpy(maplists[maxtokentype].dictIds, mapdicts, sizeof(Oid) * ndicts);
}
maxtokentype = toktype;
mapdicts[0] = cfgmap->mapdict;
ndicts = 1;
} else
{ /* continuing data for current token type */ if (ndicts >= MAXDICTSPERTT)
elog(ERROR, "too many pg_ts_config_map entries for one token type");
mapdicts[ndicts++] = cfgmap->mapdict;
}
}
/* GUC wants it guc_malloc'd not palloc'd */
guc_free(*newval);
*newval = guc_strdup(LOG, buf);
pfree(buf); if (!*newval) returnfalse;
}
returntrue;
}
/* GUC assign_hook for default_text_search_config */ void
assign_default_text_search_config(constchar *newval, void *extra)
{ /* Just reset the cache to force a lookup on first use */
TSCurrentConfigCache = InvalidOid;
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.23Bemerkung:
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.