gin.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*--------------------------------------------------------------------------
  2. * gin.h
  3. * Public header file for Generalized Inverted Index access method.
  4. *
  5. * Copyright (c) 2006-2022, PostgreSQL Global Development Group
  6. *
  7. * src/include/access/gin.h
  8. *--------------------------------------------------------------------------
  9. */
  10. #ifndef GIN_H
  11. #define GIN_H
  12. #include "access/xlogreader.h"
  13. #include "lib/stringinfo.h"
  14. #include "storage/block.h"
  15. #include "utils/relcache.h"
  16. /*
  17. * amproc indexes for inverted indexes.
  18. */
  19. #define GIN_COMPARE_PROC 1
  20. #define GIN_EXTRACTVALUE_PROC 2
  21. #define GIN_EXTRACTQUERY_PROC 3
  22. #define GIN_CONSISTENT_PROC 4
  23. #define GIN_COMPARE_PARTIAL_PROC 5
  24. #define GIN_TRICONSISTENT_PROC 6
  25. #define GIN_OPTIONS_PROC 7
  26. #define GINNProcs 7
  27. /*
  28. * searchMode settings for extractQueryFn.
  29. */
  30. #define GIN_SEARCH_MODE_DEFAULT 0
  31. #define GIN_SEARCH_MODE_INCLUDE_EMPTY 1
  32. #define GIN_SEARCH_MODE_ALL 2
  33. #define GIN_SEARCH_MODE_EVERYTHING 3 /* for internal use only */
  34. /*
  35. * GinStatsData represents stats data for planner use
  36. */
  37. typedef struct GinStatsData
  38. {
  39. BlockNumber nPendingPages;
  40. BlockNumber nTotalPages;
  41. BlockNumber nEntryPages;
  42. BlockNumber nDataPages;
  43. int64 nEntries;
  44. int32 ginVersion;
  45. } GinStatsData;
  46. /*
  47. * A ternary value used by tri-consistent functions.
  48. *
  49. * This must be of the same size as a bool because some code will cast a
  50. * pointer to a bool to a pointer to a GinTernaryValue.
  51. */
  52. typedef char GinTernaryValue;
  53. #define GIN_FALSE 0 /* item is not present / does not match */
  54. #define GIN_TRUE 1 /* item is present / matches */
  55. #define GIN_MAYBE 2 /* don't know if item is present / don't know
  56. * if matches */
  57. #define DatumGetGinTernaryValue(X) ((GinTernaryValue)(X))
  58. #define GinTernaryValueGetDatum(X) ((Datum)(X))
  59. #define PG_RETURN_GIN_TERNARY_VALUE(x) return GinTernaryValueGetDatum(x)
  60. /* GUC parameters */
  61. extern PGDLLIMPORT int GinFuzzySearchLimit;
  62. extern PGDLLIMPORT int gin_pending_list_limit;
  63. /* ginutil.c */
  64. extern void ginGetStats(Relation index, GinStatsData *stats);
  65. extern void ginUpdateStats(Relation index, const GinStatsData *stats,
  66. bool is_build);
  67. #endif /* GIN_H */