PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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-2017, 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  /* Opaque pointer for the opclass' private use */
31  void *oi_opaque;
32 
33  /* Type cache entries of the stored columns */
34  TypeCacheEntry *oi_typcache[FLEXIBLE_ARRAY_MEMBER];
35 } BrinOpcInfo;
36 
37 /* the size of a BrinOpcInfo for the given number of columns */
38 #define SizeofBrinOpcInfo(ncols) \
39  (offsetof(BrinOpcInfo, oi_typcache) + sizeof(TypeCacheEntry *) * ncols)
40 
41 typedef struct BrinDesc
42 {
43  /* Containing memory context */
45 
46  /* the index relation itself */
48 
49  /* tuple descriptor of the index relation */
51 
52  /* cached copy for on-disk tuples; generated at first use */
54 
55  /* total number of Datum entries that are stored on-disk for all columns */
57 
58  /* per-column info; bd_tupdesc->natts entries long */
59  BrinOpcInfo *bd_info[FLEXIBLE_ARRAY_MEMBER];
60 } BrinDesc;
61 
62 /*
63  * Globally-known function support numbers for BRIN indexes. Individual
64  * opclasses can define more function support numbers, which must fall into
65  * BRIN_FIRST_OPTIONAL_PROCNUM .. BRIN_LAST_OPTIONAL_PROCNUM.
66  */
67 #define BRIN_PROCNUM_OPCINFO 1
68 #define BRIN_PROCNUM_ADDVALUE 2
69 #define BRIN_PROCNUM_CONSISTENT 3
70 #define BRIN_PROCNUM_UNION 4
71 #define BRIN_MANDATORY_NPROCS 4
72 /* procedure numbers up to 10 are reserved for BRIN future expansion */
73 #define BRIN_FIRST_OPTIONAL_PROCNUM 11
74 #define BRIN_LAST_OPTIONAL_PROCNUM 15
75 
76 #undef BRIN_DEBUG
77 
78 #ifdef BRIN_DEBUG
79 #define BRIN_elog(args) elog args
80 #else
81 #define BRIN_elog(args) ((void) 0)
82 #endif
83 
84 /* brin.c */
85 extern BrinDesc *brin_build_desc(Relation rel);
86 extern void brin_free_desc(BrinDesc *bdesc);
88  struct IndexInfo *indexInfo);
89 extern void brinbuildempty(Relation index);
90 extern bool brininsert(Relation idxRel, Datum *values, bool *nulls,
91  ItemPointer heaptid, Relation heapRel,
92  IndexUniqueCheck checkUnique,
93  struct IndexInfo *indexInfo);
94 extern IndexScanDesc brinbeginscan(Relation r, int nkeys, int norderbys);
95 extern int64 bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
96 extern void brinrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
97  ScanKey orderbys, int norderbys);
98 extern void brinendscan(IndexScanDesc scan);
100  IndexBulkDeleteResult *stats,
102  void *callback_state);
104  IndexBulkDeleteResult *stats);
105 extern bytea *brinoptions(Datum reloptions, bool validate);
106 
107 /* brin_validate.c */
108 extern bool brinvalidate(Oid opclassoid);
109 
110 #endif /* BRIN_INTERNAL_H */
BrinDesc * brin_build_desc(Relation rel)
Definition: brin.c:995
bool brinvalidate(Oid opclassoid)
Definition: brin_validate.c:38
void brinbuildempty(Relation index)
Definition: brin.c:728
unsigned int Oid
Definition: postgres_ext.h:31
Definition: type.h:90
IndexUniqueCheck
Definition: genam.h:111
unsigned short uint16
Definition: c.h:267
Relation bd_index
Definition: brin_internal.h:47
TypeCacheEntry * oi_typcache[FLEXIBLE_ARRAY_MEMBER]
Definition: brin_internal.h:34
int64 bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
Definition: brin.c:352
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
uint16 oi_nstored
Definition: brin_internal.h:28
int bd_totalstored
Definition: brin_internal.h:56
IndexBuildResult * brinbuild(Relation heap, Relation index, struct IndexInfo *indexInfo)
Definition: brin.c:644
TupleDesc bd_tupdesc
Definition: brin_internal.h:50
bytea * brinoptions(Datum reloptions, bool validate)
Definition: brin.c:803
bool brininsert(Relation idxRel, Datum *values, bool *nulls, ItemPointer heaptid, Relation heapRel, IndexUniqueCheck checkUnique, struct IndexInfo *indexInfo)
Definition: brin.c:139
IndexScanDesc brinbeginscan(Relation r, int nkeys, int norderbys)
Definition: brin.c:323
uintptr_t Datum
Definition: postgres.h:372
void * oi_opaque
Definition: brin_internal.h:31
BrinOpcInfo * bd_info[FLEXIBLE_ARRAY_MEMBER]
Definition: brin_internal.h:59
void brin_free_desc(BrinDesc *bdesc)
Definition: brin.c:1050
struct BrinOpcInfo BrinOpcInfo
IndexBulkDeleteResult * brinbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
Definition: brin.c:758
IndexBulkDeleteResult * brinvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
Definition: brin.c:773
void brinendscan(IndexScanDesc scan)
Definition: brin.c:565
MemoryContext bd_context
Definition: brin_internal.h:44
static Datum values[MAXATTR]
Definition: bootstrap.c:163
void brinrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
Definition: brin.c:545
TupleDesc bd_disktdesc
Definition: brin_internal.h:53
Definition: c.h:439
struct BrinDesc BrinDesc
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
Definition: genam.h:83