3 * internal declarations for BRIN indexes
5 * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
6 * Portions Copyright (c) 1994, Regents of the University of California
9 * src/include/access/brin_internal.h
11 #ifndef BRIN_INTERNAL_H
12 #define BRIN_INTERNAL_H
14 #include "access/amapi.h"
15 #include "storage/bufpage.h"
16 #include "utils/typcache.h"
20 * A BrinDesc is a struct designed to enable decoding a BRIN tuple from the
21 * on-disk format to an in-memory tuple and vice-versa.
24 /* struct returned by "OpcInfo" amproc */
25 typedef struct BrinOpcInfo
27 /* Number of columns stored in an index column of this opclass */
30 /* Regular processing of NULLs in BrinValues? */
31 bool oi_regular_nulls
;
33 /* Opaque pointer for the opclass' private use */
36 /* Type cache entries of the stored columns */
37 TypeCacheEntry
*oi_typcache
[FLEXIBLE_ARRAY_MEMBER
];
40 /* the size of a BrinOpcInfo for the given number of columns */
41 #define SizeofBrinOpcInfo(ncols) \
42 (offsetof(BrinOpcInfo, oi_typcache) + sizeof(TypeCacheEntry *) * ncols)
44 typedef struct BrinDesc
46 /* Containing memory context */
47 MemoryContext bd_context
;
49 /* the index relation itself */
52 /* tuple descriptor of the index relation */
55 /* cached copy for on-disk tuples; generated at first use */
56 TupleDesc bd_disktdesc
;
58 /* total number of Datum entries that are stored on-disk for all columns */
61 /* per-column info; bd_tupdesc->natts entries long */
62 BrinOpcInfo
*bd_info
[FLEXIBLE_ARRAY_MEMBER
];
66 * Globally-known function support numbers for BRIN indexes. Individual
67 * opclasses can define more function support numbers, which must fall into
68 * BRIN_FIRST_OPTIONAL_PROCNUM .. BRIN_LAST_OPTIONAL_PROCNUM.
70 #define BRIN_PROCNUM_OPCINFO 1
71 #define BRIN_PROCNUM_ADDVALUE 2
72 #define BRIN_PROCNUM_CONSISTENT 3
73 #define BRIN_PROCNUM_UNION 4
74 #define BRIN_MANDATORY_NPROCS 4
75 #define BRIN_PROCNUM_OPTIONS 5 /* optional */
76 /* procedure numbers up to 10 are reserved for BRIN future expansion */
77 #define BRIN_FIRST_OPTIONAL_PROCNUM 11
78 #define BRIN_LAST_OPTIONAL_PROCNUM 15
83 #define BRIN_elog(args) elog args
85 #define BRIN_elog(args) ((void) 0)
89 extern BrinDesc
*brin_build_desc(Relation rel
);
90 extern void brin_free_desc(BrinDesc
*bdesc
);
91 extern IndexBuildResult
*brinbuild(Relation heap
, Relation index
,
92 struct IndexInfo
*indexInfo
);
93 extern void brinbuildempty(Relation index
);
94 extern bool brininsert(Relation idxRel
, Datum
*values
, bool *nulls
,
95 ItemPointer heaptid
, Relation heapRel
,
96 IndexUniqueCheck checkUnique
,
98 struct IndexInfo
*indexInfo
);
99 extern IndexScanDesc
brinbeginscan(Relation r
, int nkeys
, int norderbys
);
100 extern int64
bringetbitmap(IndexScanDesc scan
, TIDBitmap
*tbm
);
101 extern void brinrescan(IndexScanDesc scan
, ScanKey scankey
, int nscankeys
,
102 ScanKey orderbys
, int norderbys
);
103 extern void brinendscan(IndexScanDesc scan
);
104 extern IndexBulkDeleteResult
*brinbulkdelete(IndexVacuumInfo
*info
,
105 IndexBulkDeleteResult
*stats
,
106 IndexBulkDeleteCallback callback
,
107 void *callback_state
);
108 extern IndexBulkDeleteResult
*brinvacuumcleanup(IndexVacuumInfo
*info
,
109 IndexBulkDeleteResult
*stats
);
110 extern bytea
*brinoptions(Datum reloptions
, bool validate
);
112 /* brin_validate.c */
113 extern bool brinvalidate(Oid opclassoid
);
115 #endif /* BRIN_INTERNAL_H */