ts_cache.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*-------------------------------------------------------------------------
  2. *
  3. * ts_cache.h
  4. * Tsearch related object caches.
  5. *
  6. * Portions Copyright (c) 1996-2016, 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. #include "utils/guc.h"
  16. /*
  17. * All TS*CacheEntry structs must share this common header
  18. * (see InvalidateTSCacheCallBack)
  19. */
  20. typedef struct TSAnyCacheEntry
  21. {
  22. Oid objId;
  23. bool isvalid;
  24. } TSAnyCacheEntry;
  25. typedef struct TSParserCacheEntry
  26. {
  27. /* prsId is the hash lookup key and MUST BE FIRST */
  28. Oid prsId; /* OID of the parser */
  29. bool isvalid;
  30. Oid startOid;
  31. Oid tokenOid;
  32. Oid endOid;
  33. Oid headlineOid;
  34. Oid lextypeOid;
  35. /*
  36. * Pre-set-up fmgr call of most needed parser's methods
  37. */
  38. FmgrInfo prsstart;
  39. FmgrInfo prstoken;
  40. FmgrInfo prsend;
  41. FmgrInfo prsheadline;
  42. } TSParserCacheEntry;
  43. typedef struct TSDictionaryCacheEntry
  44. {
  45. /* dictId is the hash lookup key and MUST BE FIRST */
  46. Oid dictId;
  47. bool isvalid;
  48. /* most frequent fmgr call */
  49. Oid lexizeOid;
  50. FmgrInfo lexize;
  51. MemoryContext dictCtx; /* memory context to store private data */
  52. void *dictData;
  53. } TSDictionaryCacheEntry;
  54. typedef struct
  55. {
  56. int len;
  57. Oid *dictIds;
  58. } ListDictionary;
  59. typedef struct
  60. {
  61. /* cfgId is the hash lookup key and MUST BE FIRST */
  62. Oid cfgId;
  63. bool isvalid;
  64. Oid prsId;
  65. int lenmap;
  66. ListDictionary *map;
  67. } TSConfigCacheEntry;
  68. /*
  69. * GUC variable for current configuration
  70. */
  71. extern char *TSCurrentConfig;
  72. extern TSParserCacheEntry *lookup_ts_parser_cache(Oid prsId);
  73. extern TSDictionaryCacheEntry *lookup_ts_dictionary_cache(Oid dictId);
  74. extern TSConfigCacheEntry *lookup_ts_config_cache(Oid cfgId);
  75. extern Oid getTSCurrentConfig(bool emitError);
  76. extern bool check_TSCurrentConfig(char **newval, void **extra, GucSource source);
  77. extern void assign_TSCurrentConfig(const char *newval, void *extra);
  78. #endif /* TS_CACHE_H */