PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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-2025, 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 */
25typedef 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
44typedef 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 */
90extern void brin_free_desc(BrinDesc *bdesc);
92 struct IndexInfo *indexInfo);
93extern void brinbuildempty(Relation index);
94extern bool brininsert(Relation idxRel, Datum *values, bool *nulls,
95 ItemPointer heaptid, Relation heapRel,
96 IndexUniqueCheck checkUnique,
97 bool indexUnchanged,
98 struct IndexInfo *indexInfo);
99extern void brininsertcleanup(Relation index, struct IndexInfo *indexInfo);
100extern IndexScanDesc brinbeginscan(Relation r, int nkeys, int norderbys);
101extern int64 bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
102extern void brinrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
103 ScanKey orderbys, int norderbys);
104extern void brinendscan(IndexScanDesc scan);
108 void *callback_state);
110 IndexBulkDeleteResult *stats);
111extern bytea *brinoptions(Datum reloptions, bool validate);
112
113/* brin_validate.c */
114extern bool brinvalidate(Oid opclassoid);
115
116#endif /* BRIN_INTERNAL_H */
static Datum values[MAXATTR]
Definition: bootstrap.c:151
bool brininsert(Relation idxRel, Datum *values, bool *nulls, ItemPointer heaptid, Relation heapRel, IndexUniqueCheck checkUnique, bool indexUnchanged, struct IndexInfo *indexInfo)
Definition: brin.c:339
void brinrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
Definition: brin.c:950
IndexBuildResult * brinbuild(Relation heap, Relation index, struct IndexInfo *indexInfo)
Definition: brin.c:1096
bool brinvalidate(Oid opclassoid)
Definition: brin_validate.c:37
IndexBulkDeleteResult * brinbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
Definition: brin.c:1294
IndexScanDesc brinbeginscan(Relation r, int nkeys, int norderbys)
Definition: brin.c:532
bytea * brinoptions(Datum reloptions, bool validate)
Definition: brin.c:1339
int64 bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
Definition: brin.c:560
void brinbuildempty(Relation index)
Definition: brin.c:1265
void brin_free_desc(BrinDesc *bdesc)
Definition: brin.c:1628
struct BrinOpcInfo BrinOpcInfo
struct BrinDesc BrinDesc
IndexBulkDeleteResult * brinvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
Definition: brin.c:1309
void brininsertcleanup(Relation index, struct IndexInfo *indexInfo)
Definition: brin.c:507
BrinDesc * brin_build_desc(Relation rel)
Definition: brin.c:1573
void brinendscan(IndexScanDesc scan)
Definition: brin.c:969
int64_t int64
Definition: c.h:482
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:417
uint16_t uint16
Definition: c.h:484
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
Definition: genam.h:89
IndexUniqueCheck
Definition: genam.h:118
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:96
Definition: c.h:641
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:46