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-2024, 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 */
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 */
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 void brininsertcleanup(struct IndexInfo *indexInfo);
100 extern IndexScanDesc brinbeginscan(Relation r, int nkeys, int norderbys);
101 extern int64 bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
102 extern void brinrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
103  ScanKey orderbys, int norderbys);
104 extern void brinendscan(IndexScanDesc scan);
106  IndexBulkDeleteResult *stats,
108  void *callback_state);
110  IndexBulkDeleteResult *stats);
111 extern bytea *brinoptions(Datum reloptions, bool validate);
112 
113 /* brin_validate.c */
114 extern bool brinvalidate(Oid opclassoid);
115 
116 #endif /* BRIN_INTERNAL_H */
static Datum values[MAXATTR]
Definition: bootstrap.c:152
IndexBulkDeleteResult * brinvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
Definition: brin.c:1303
bool brininsert(Relation idxRel, Datum *values, bool *nulls, ItemPointer heaptid, Relation heapRel, IndexUniqueCheck checkUnique, bool indexUnchanged, struct IndexInfo *indexInfo)
Definition: brin.c:333
void brinrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
Definition: brin.c:942
bool brinvalidate(Oid opclassoid)
Definition: brin_validate.c:37
IndexScanDesc brinbeginscan(Relation r, int nkeys, int norderbys)
Definition: brin.c:524
IndexBuildResult * brinbuild(Relation heap, Relation index, struct IndexInfo *indexInfo)
Definition: brin.c:1089
int64 bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
Definition: brin.c:552
void brinbuildempty(Relation index)
Definition: brin.c:1259
void brininsertcleanup(struct IndexInfo *indexInfo)
Definition: brin.c:501
void brin_free_desc(BrinDesc *bdesc)
Definition: brin.c:1622
BrinDesc * brin_build_desc(Relation rel)
Definition: brin.c:1567
struct BrinOpcInfo BrinOpcInfo
struct BrinDesc BrinDesc
bytea * brinoptions(Datum reloptions, bool validate)
Definition: brin.c:1333
IndexBulkDeleteResult * brinbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
Definition: brin.c:1288
void brinendscan(IndexScanDesc scan)
Definition: brin.c:962
unsigned short uint16
Definition: c.h:492
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:385
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
Definition: genam.h:87
IndexUniqueCheck
Definition: genam.h:116
uintptr_t Datum
Definition: postgres.h:64
unsigned int Oid
Definition: postgres_ext.h:31
int bd_totalstored
Definition: brin_internal.h:59
TupleDesc bd_tupdesc
Definition: brin_internal.h:53
BrinOpcInfo * bd_info[FLEXIBLE_ARRAY_MEMBER]
Definition: brin_internal.h:62
Relation bd_index
Definition: brin_internal.h:50
MemoryContext bd_context
Definition: brin_internal.h:47
TupleDesc bd_disktdesc
Definition: brin_internal.h:56
TypeCacheEntry * oi_typcache[FLEXIBLE_ARRAY_MEMBER]
Definition: brin_internal.h:37
uint16 oi_nstored
Definition: brin_internal.h:28
bool oi_regular_nulls
Definition: brin_internal.h:31
void * oi_opaque
Definition: brin_internal.h:34
Definition: type.h:95
Definition: c.h:674
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:46