Skip to content

Commit f71de76

Browse files
dvcerCommitfest Bot
authored andcommitted
brin refactoring
For adding BRIN index support in amcheck we need some tiny changes in BRIN core code: * We need to have tuple descriptor for on-disk storage of BRIN tuples. It is a public field 'bd_disktdesc' in BrinDesc, but to access it we need function 'brtuple_disk_tupdesc' which is internal. This commit makes it extern and renames it to 'brin_tuple_tupdesc'. * For meta page check we need to know pages_per_range upper limit. It's hardcoded now. This commit moves its value to macros BRIN_MAX_PAGES_PER_RANGE so that we can use it in amcheck too.
1 parent 447aae1 commit f71de76

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

src/backend/access/brin/brin_tuple.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ static inline void brin_deconstruct_tuple(BrinDesc *brdesc,
5757
/*
5858
* Return a tuple descriptor used for on-disk storage of BRIN tuples.
5959
*/
60-
static TupleDesc
61-
brtuple_disk_tupdesc(BrinDesc *brdesc)
60+
TupleDesc
61+
brin_tuple_tupdesc(BrinDesc *brdesc)
6262
{
6363
/* We cache these in the BrinDesc */
6464
if (brdesc->bd_disktdesc == NULL)
@@ -280,7 +280,7 @@ brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple,
280280

281281
len = hoff = MAXALIGN(len);
282282

283-
data_len = heap_compute_data_size(brtuple_disk_tupdesc(brdesc),
283+
data_len = heap_compute_data_size(brin_tuple_tupdesc(brdesc),
284284
values, nulls);
285285
len += data_len;
286286

@@ -299,7 +299,7 @@ brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple,
299299
* need to pass a valid null bitmap so that it will correctly skip
300300
* outputting null attributes in the data area.
301301
*/
302-
heap_fill_tuple(brtuple_disk_tupdesc(brdesc),
302+
heap_fill_tuple(brin_tuple_tupdesc(brdesc),
303303
values,
304304
nulls,
305305
(char *) rettuple + hoff,
@@ -682,7 +682,7 @@ brin_deconstruct_tuple(BrinDesc *brdesc,
682682
* may reuse attribute entries for more than one column, we cannot cache
683683
* offsets here.
684684
*/
685-
diskdsc = brtuple_disk_tupdesc(brdesc);
685+
diskdsc = brin_tuple_tupdesc(brdesc);
686686
stored = 0;
687687
off = 0;
688688
for (attnum = 0; attnum < brdesc->bd_tupdesc->natts; attnum++)

src/backend/access/common/reloptions.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "access/heaptoast.h"
2323
#include "access/htup_details.h"
2424
#include "access/nbtree.h"
25+
#include "access/brin.h"
2526
#include "access/reloptions.h"
2627
#include "access/spgist_private.h"
2728
#include "catalog/pg_type.h"
@@ -352,7 +353,7 @@ static relopt_int intRelOpts[] =
352353
"Number of pages that each page range covers in a BRIN index",
353354
RELOPT_KIND_BRIN,
354355
AccessExclusiveLock
355-
}, 128, 1, 131072
356+
}, 128, 1, BRIN_MAX_PAGES_PER_RANGE
356357
},
357358
{
358359
{

src/include/access/brin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ typedef struct BrinStatsData
3838

3939

4040
#define BRIN_DEFAULT_PAGES_PER_RANGE 128
41+
#define BRIN_MAX_PAGES_PER_RANGE 131072
4142
#define BrinGetPagesPerRange(relation) \
4243
(AssertMacro(relation->rd_rel->relkind == RELKIND_INDEX && \
4344
relation->rd_rel->relam == BRIN_AM_OID), \

src/include/access/brin_tuple.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,6 @@ extern BrinMemTuple *brin_memtuple_initialize(BrinMemTuple *dtuple,
109109
extern BrinMemTuple *brin_deform_tuple(BrinDesc *brdesc,
110110
BrinTuple *tuple, BrinMemTuple *dMemtuple);
111111

112+
extern TupleDesc brin_tuple_tupdesc(BrinDesc *brdesc);
113+
112114
#endif /* BRIN_TUPLE_H */

0 commit comments

Comments
 (0)