PostgreSQL Source Code  git master
brin_internal.h
Go to the documentation of this file.
1 /*
2  * brin_internal.h
3  * internal declarations for BRIN indexes
4  *
5  * Portions Copyright (c) 1996-2021, 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 
14 #include "access/amapi.h"
15 #include "storage/bufpage.h"
16 #include "utils/typcache.h"
17 
18 
19 /*
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.
22  */
23 
24 /* struct returned by "OpcInfo" amproc */
25 typedef struct BrinOpcInfo
26 {
27  /* Number of columns stored in an index column of this opclass */
29 
30  /* Regular processing of NULLs in BrinValues? */
32 
33  /* Opaque pointer for the opclass' private use */
34  void *oi_opaque;
35 
36  /* Type cache entries of the stored columns */
38 } BrinOpcInfo;
39 
40 /* the size of a BrinOpcInfo for the given number of columns */
41 #define SizeofBrinOpcInfo(ncols) \
42  (offsetof(BrinOpcInfo, oi_typcache) + sizeof(TypeCacheEntry *) * ncols)
43 
44 typedef struct BrinDesc
45 {
46  /* Containing memory context */
48 
49  /* the index relation itself */
51 
52  /* tuple descriptor of the index relation */
54 
55  /* cached copy for on-disk tuples; generated at first use */
57 
58  /* total number of Datum entries that are stored on-disk for all columns */
60 
61  /* per-column info; bd_tupdesc->natts entries long */
63 } BrinDesc;
64 
65 /*
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.
69  */
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
79 
80 #undef BRIN_DEBUG
81 
82 #ifdef BRIN_DEBUG
83 #define BRIN_elog(args) elog args
84 #else
85 #define BRIN_elog(args) ((void) 0)
86 #endif
87 
88 /* brin.c */
89 extern BrinDesc *brin_build_desc(Relation rel);
90 extern void brin_free_desc(BrinDesc *bdesc);
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,
97  bool indexUnchanged,
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);
105  IndexBulkDeleteResult *stats,
107  void *callback_state);
109  IndexBulkDeleteResult *stats);
110 extern bytea *brinoptions(Datum reloptions, bool validate);
111 
112 /* brin_validate.c */
113 extern bool brinvalidate(Oid opclassoid);
114 
115 #endif /* BRIN_INTERNAL_H */
BrinDesc * brin_build_desc(Relation rel)
Definition: brin.c:1160
bool brinvalidate(Oid opclassoid)
Definition: brin_validate.c:37
void brinbuildempty(Relation index)
Definition: brin.c:894
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:350
unsigned int Oid
Definition: postgres_ext.h:31
Definition: type.h:89
IndexUniqueCheck
Definition: genam.h:114
unsigned short uint16
Definition: c.h:440
Relation bd_index
Definition: brin_internal.h:50
TypeCacheEntry * oi_typcache[FLEXIBLE_ARRAY_MEMBER]
Definition: brin_internal.h:37
int64 bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
Definition: brin.c:354
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
bool brininsert(Relation idxRel, Datum *values, bool *nulls, ItemPointer heaptid, Relation heapRel, IndexUniqueCheck checkUnique, bool indexUnchanged, struct IndexInfo *indexInfo)
Definition: brin.c:154
uint16 oi_nstored
Definition: brin_internal.h:28
int bd_totalstored
Definition: brin_internal.h:59
IndexBuildResult * brinbuild(Relation heap, Relation index, struct IndexInfo *indexInfo)
Definition: brin.c:810
TupleDesc bd_tupdesc
Definition: brin_internal.h:53
bool oi_regular_nulls
Definition: brin_internal.h:31
bytea * brinoptions(Datum reloptions, bool validate)
Definition: brin.c:969
IndexScanDesc brinbeginscan(Relation r, int nkeys, int norderbys)
Definition: brin.c:325
uintptr_t Datum
Definition: postgres.h:411
void * oi_opaque
Definition: brin_internal.h:34
void brin_free_desc(BrinDesc *bdesc)
Definition: brin.c:1215
struct BrinOpcInfo BrinOpcInfo
IndexBulkDeleteResult * brinbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
Definition: brin.c:924
IndexBulkDeleteResult * brinvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
Definition: brin.c:939
void brinendscan(IndexScanDesc scan)
Definition: brin.c:748
MemoryContext bd_context
Definition: brin_internal.h:47
static Datum values[MAXATTR]
Definition: bootstrap.c:166
void brinrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
Definition: brin.c:728
TupleDesc bd_disktdesc
Definition: brin_internal.h:56
Definition: c.h:621
struct BrinDesc BrinDesc
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
Definition: genam.h:86