1 /*
2  * AM-callable functions for BRIN indexes
3  *
4  * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
5  * Portions Copyright (c) 1994, Regents of the University of California
6  *
7  * IDENTIFICATION
8  *		src/include/access/brin.h
9  */
10 #ifndef BRIN_H
11 #define BRIN_H
12 
13 #include "fmgr.h"
14 #include "nodes/execnodes.h"
15 #include "utils/relcache.h"
16 
17 
18 /*
19  * Storage type for BRIN's reloptions
20  */
21 typedef struct BrinOptions
22 {
23 	int32		vl_len_;		/* varlena header (do not touch directly!) */
24 	BlockNumber pagesPerRange;
25 	bool		autosummarize;
26 } BrinOptions;
27 
28 
29 /*
30  * BrinStatsData represents stats data for planner use
31  */
32 typedef struct BrinStatsData
33 {
34 	BlockNumber pagesPerRange;
35 	BlockNumber revmapNumPages;
36 } BrinStatsData;
37 
38 
39 #define BRIN_DEFAULT_PAGES_PER_RANGE	128
40 #define BrinGetPagesPerRange(relation) \
41 	((relation)->rd_options ? \
42 	 ((BrinOptions *) (relation)->rd_options)->pagesPerRange : \
43 	  BRIN_DEFAULT_PAGES_PER_RANGE)
44 #define BrinGetAutoSummarize(relation) \
45 	((relation)->rd_options ? \
46 	 ((BrinOptions *) (relation)->rd_options)->autosummarize : \
47 	  false)
48 
49 
50 extern void brinGetStats(Relation index, BrinStatsData *stats);
51 
52 #endif							/* BRIN_H */
53