gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
3.4KB

  1. /*
  2. * brin_internal.h
  3. * internal declarations for BRIN indexes
  4. *
  5. * Portions Copyright (c) 1996-2019, 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. struct IndexInfo *indexInfo);
  77. extern IndexScanDesc brinbeginscan(Relation r, int nkeys, int norderbys);
  78. extern int64 bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
  79. extern void brinrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
  80. ScanKey orderbys, int norderbys);
  81. extern void brinendscan(IndexScanDesc scan);
  82. extern IndexBulkDeleteResult *brinbulkdelete(IndexVacuumInfo *info,
  83. IndexBulkDeleteResult *stats,
  84. IndexBulkDeleteCallback callback,
  85. void *callback_state);
  86. extern IndexBulkDeleteResult *brinvacuumcleanup(IndexVacuumInfo *info,
  87. IndexBulkDeleteResult *stats);
  88. extern bytea *brinoptions(Datum reloptions, bool validate);
  89. /* brin_validate.c */
  90. extern bool brinvalidate(Oid opclassoid);
  91. #endif /* BRIN_INTERNAL_H */
上海开阖软件有限公司 沪ICP备12045867号-1