| 1 | /*------------------------------------------------------------------------- |
| 2 | * |
| 3 | * ts_cache.h |
| 4 | * Tsearch related object caches. |
| 5 | * |
| 6 | * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group |
| 7 | * Portions Copyright (c) 1994, Regents of the University of California |
| 8 | * |
| 9 | * src/include/tsearch/ts_cache.h |
| 10 | * |
| 11 | *------------------------------------------------------------------------- |
| 12 | */ |
| 13 | #ifndef TS_CACHE_H |
| 14 | #define TS_CACHE_H |
| 15 | |
| 16 | #include "utils/guc.h" |
| 17 | |
| 18 | |
| 19 | /* |
| 20 | * All TS*CacheEntry structs must share this common header |
| 21 | * (see InvalidateTSCacheCallBack) |
| 22 | */ |
| 23 | typedef struct TSAnyCacheEntry |
| 24 | { |
| 25 | Oid objId; |
| 26 | bool isvalid; |
| 27 | } TSAnyCacheEntry; |
| 28 | |
| 29 | |
| 30 | typedef struct TSParserCacheEntry |
| 31 | { |
| 32 | /* prsId is the hash lookup key and MUST BE FIRST */ |
| 33 | Oid prsId; /* OID of the parser */ |
| 34 | bool isvalid; |
| 35 | |
| 36 | Oid startOid; |
| 37 | Oid tokenOid; |
| 38 | Oid endOid; |
| 39 | Oid headlineOid; |
| 40 | Oid lextypeOid; |
| 41 | |
| 42 | /* |
| 43 | * Pre-set-up fmgr call of most needed parser's methods |
| 44 | */ |
| 45 | FmgrInfo ; |
| 46 | FmgrInfo prstoken; |
| 47 | FmgrInfo prsend; |
| 48 | FmgrInfo prsheadline; |
| 49 | } TSParserCacheEntry; |
| 50 | |
| 51 | typedef struct TSDictionaryCacheEntry |
| 52 | { |
| 53 | /* dictId is the hash lookup key and MUST BE FIRST */ |
| 54 | Oid dictId; |
| 55 | bool isvalid; |
| 56 | |
| 57 | /* most frequent fmgr call */ |
| 58 | Oid lexizeOid; |
| 59 | FmgrInfo lexize; |
| 60 | |
| 61 | MemoryContext dictCtx; /* memory context to store private data */ |
| 62 | void *dictData; |
| 63 | } TSDictionaryCacheEntry; |
| 64 | |
| 65 | typedef struct |
| 66 | { |
| 67 | int len; |
| 68 | Oid *dictIds; |
| 69 | } ListDictionary; |
| 70 | |
| 71 | typedef struct |
| 72 | { |
| 73 | /* cfgId is the hash lookup key and MUST BE FIRST */ |
| 74 | Oid cfgId; |
| 75 | bool isvalid; |
| 76 | |
| 77 | Oid prsId; |
| 78 | |
| 79 | int lenmap; |
| 80 | ListDictionary *map; |
| 81 | } TSConfigCacheEntry; |
| 82 | |
| 83 | |
| 84 | /* |
| 85 | * GUC variable for current configuration |
| 86 | */ |
| 87 | extern char *TSCurrentConfig; |
| 88 | |
| 89 | |
| 90 | extern TSParserCacheEntry *lookup_ts_parser_cache(Oid prsId); |
| 91 | extern TSDictionaryCacheEntry *lookup_ts_dictionary_cache(Oid dictId); |
| 92 | extern TSConfigCacheEntry *lookup_ts_config_cache(Oid cfgId); |
| 93 | |
| 94 | extern Oid getTSCurrentConfig(bool emitError); |
| 95 | extern bool check_TSCurrentConfig(char **newval, void **, GucSource source); |
| 96 | extern void assign_TSCurrentConfig(const char *newval, void *); |
| 97 | |
| 98 | #endif /* TS_CACHE_H */ |
| 99 | |