brin_internal.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * brin_internal.h
  3. * internal declarations for BRIN indexes
  4. *
  5. * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
  6. * Portions Copyright (c) 1994, Regents of the University of California
  7. *
  8. * IDENTIFICATION
  9. * src/include/access/brin_internal.h
  10. */
  11. #ifndef BRIN_INTERNAL_H
  12. #define BRIN_INTERNAL_H
  13. #include "access/amapi.h"
  14. #include "storage/bufpage.h"
  15. #include "utils/typcache.h"
  16. /*
  17. * A BrinDesc is a struct designed to enable decoding a BRIN tuple from the
  18. * on-disk format to an in-memory tuple and vice-versa.
  19. */
  20. /* struct returned by "OpcInfo" amproc */
  21. typedef struct BrinOpcInfo
  22. {
  23. /* Number of columns stored in an index column of this opclass */
  24. uint16 oi_nstored;
  25. /* Opaque pointer for the opclass' private use */
  26. void *oi_opaque;
  27. /* Type cache entries of the stored columns */
  28. TypeCacheEntry *oi_typcache[FLEXIBLE_ARRAY_MEMBER];
  29. } BrinOpcInfo;
  30. /* the size of a BrinOpcInfo for the given number of columns */
  31. #define SizeofBrinOpcInfo(ncols) \
  32. (offsetof(BrinOpcInfo, oi_typcache) + sizeof(TypeCacheEntry *) * ncols)
  33. typedef struct BrinDesc
  34. {
  35. /* Containing memory context */
  36. MemoryContext bd_context;
  37. /* the index relation itself */
  38. Relation bd_index;
  39. /* tuple descriptor of the index relation */
  40. TupleDesc bd_tupdesc;
  41. /* cached copy for on-disk tuples; generated at first use */
  42. TupleDesc bd_disktdesc;
  43. /* total number of Datum entries that are stored on-disk for all columns */
  44. int bd_totalstored;
  45. /* per-column info; bd_tupdesc->natts entries long */
  46. BrinOpcInfo *bd_info[FLEXIBLE_ARRAY_MEMBER];
  47. } BrinDesc;
  48. /*
  49. * Globally-known function support numbers for BRIN indexes. Individual
  50. * opclasses can define more function support numbers, which must fall into
  51. * BRIN_FIRST_OPTIONAL_PROCNUM .. BRIN_LAST_OPTIONAL_PROCNUM.
  52. */
  53. #define BRIN_PROCNUM_OPCINFO 1
  54. #define BRIN_PROCNUM_ADDVALUE 2
  55. #define BRIN_PROCNUM_CONSISTENT 3
  56. #define BRIN_PROCNUM_UNION 4
  57. #define BRIN_MANDATORY_NPROCS 4
  58. /* procedure numbers up to 10 are reserved for BRIN future expansion */
  59. #define BRIN_FIRST_OPTIONAL_PROCNUM 11
  60. #define BRIN_LAST_OPTIONAL_PROCNUM 15
  61. #undef BRIN_DEBUG
  62. #ifdef BRIN_DEBUG
  63. #define BRIN_elog(args) elog args
  64. #else
  65. #define BRIN_elog(args) ((void) 0)
  66. #endif
  67. /* brin.c */
  68. extern BrinDesc *brin_build_desc(Relation rel);
  69. extern void brin_free_desc(BrinDesc *bdesc);
  70. extern IndexBuildResult *brinbuild(Relation heap, Relation index,
  71. struct IndexInfo *indexInfo);
  72. extern void brinbuildempty(Relation index);
  73. extern bool brininsert(Relation idxRel, Datum *values, bool *nulls,
  74. ItemPointer heaptid, Relation heapRel,
  75. IndexUniqueCheck checkUnique);
  76. extern IndexScanDesc brinbeginscan(Relation r, int nkeys, int norderbys);
  77. extern int64 bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
  78. extern void brinrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
  79. ScanKey orderbys, int norderbys);
  80. extern void brinendscan(IndexScanDesc scan);
  81. extern IndexBulkDeleteResult *brinbulkdelete(IndexVacuumInfo *info,
  82. IndexBulkDeleteResult *stats,
  83. IndexBulkDeleteCallback callback,
  84. void *callback_state);
  85. extern IndexBulkDeleteResult *brinvacuumcleanup(IndexVacuumInfo *info,
  86. IndexBulkDeleteResult *stats);
  87. extern bytea *brinoptions(Datum reloptions, bool validate);
  88. /* brin_validate.c */
  89. extern bool brinvalidate(Oid opclassoid);
  90. #endif /* BRIN_INTERNAL_H */