gin.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*--------------------------------------------------------------------------
  2. * gin.h
  3. * Public header file for Generalized Inverted Index access method.
  4. *
  5. * Copyright (c) 2006-2016, 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 GINNProcs 6
  26. /*
  27. * searchMode settings for extractQueryFn.
  28. */
  29. #define GIN_SEARCH_MODE_DEFAULT 0
  30. #define GIN_SEARCH_MODE_INCLUDE_EMPTY 1
  31. #define GIN_SEARCH_MODE_ALL 2
  32. #define GIN_SEARCH_MODE_EVERYTHING 3 /* for internal use only */
  33. /*
  34. * GinStatsData represents stats data for planner use
  35. */
  36. typedef struct GinStatsData
  37. {
  38. BlockNumber nPendingPages;
  39. BlockNumber nTotalPages;
  40. BlockNumber nEntryPages;
  41. BlockNumber nDataPages;
  42. int64 nEntries;
  43. int32 ginVersion;
  44. } GinStatsData;
  45. /*
  46. * A ternary value used by tri-consistent functions.
  47. *
  48. * For convenience, this is compatible with booleans. A boolean can be
  49. * safely cast to a GinTernaryValue.
  50. */
  51. typedef char GinTernaryValue;
  52. #define GIN_FALSE 0 /* item is not present / does not match */
  53. #define GIN_TRUE 1 /* item is present / matches */
  54. #define GIN_MAYBE 2 /* don't know if item is present / don't know
  55. * if matches */
  56. #define DatumGetGinTernaryValue(X) ((GinTernaryValue)(X))
  57. #define GinTernaryValueGetDatum(X) ((Datum)(X))
  58. #define PG_RETURN_GIN_TERNARY_VALUE(x) return GinTernaryValueGetDatum(x)
  59. /* GUC parameters */
  60. extern PGDLLIMPORT int GinFuzzySearchLimit;
  61. extern int gin_pending_list_limit;
  62. /* ginutil.c */
  63. extern void ginGetStats(Relation index, GinStatsData *stats);
  64. extern void ginUpdateStats(Relation index, const GinStatsData *stats);
  65. /* ginxlog.c */
  66. extern void gin_redo(XLogReaderState *record);
  67. extern void gin_desc(StringInfo buf, XLogReaderState *record);
  68. extern const char *gin_identify(uint8 info);
  69. extern void gin_xlog_startup(void);
  70. extern void gin_xlog_cleanup(void);
  71. #endif /* GIN_H */