mirror of
https://github.com/postgres/postgres.git
synced 2025-10-24 01:29:19 +03:00
Refactor reloption handling for index AMs in-core
This reworks the reloption parsing and build of a couple of index AMs by creating new structures for each index AM's options. This split was already done for BRIN, GIN and GiST (which actually has a fillfactor parameter), but not for hash, B-tree and SPGiST which relied on StdRdOptions due to an overlap with the default option set. This saves a couple of bytes for rd_options in each relcache entry with indexes making use of relation options, and brings more consistency between all index AMs. While on it, add a couple of AssertMacro() calls to make sure that utility macros to grab values of reloptions are used with the expected index AM. Author: Nikolay Shaplov Reviewed-by: Amit Langote, Michael Paquier, Álvaro Herrera, Dent John Discussion: https://postgr.es/m/4127670.gFlpRb6XCm@x200m
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "access/itup.h"
|
||||
#include "access/sdir.h"
|
||||
#include "access/xlogreader.h"
|
||||
#include "catalog/pg_am_d.h"
|
||||
#include "catalog/pg_index.h"
|
||||
#include "lib/stringinfo.h"
|
||||
#include "storage/bufmgr.h"
|
||||
@@ -680,6 +681,23 @@ typedef BTScanOpaqueData *BTScanOpaque;
|
||||
#define SK_BT_DESC (INDOPTION_DESC << SK_BT_INDOPTION_SHIFT)
|
||||
#define SK_BT_NULLS_FIRST (INDOPTION_NULLS_FIRST << SK_BT_INDOPTION_SHIFT)
|
||||
|
||||
typedef struct BTOptions
|
||||
{
|
||||
int32 varlena_header_; /* varlena header (do not touch directly!) */
|
||||
int fillfactor; /* page fill factor in percent (0..100) */
|
||||
/* fraction of newly inserted tuples prior to trigger index cleanup */
|
||||
float8 vacuum_cleanup_index_scale_factor;
|
||||
} BTOptions;
|
||||
|
||||
#define BTGetFillFactor(relation) \
|
||||
(AssertMacro(relation->rd_rel->relkind == RELKIND_INDEX && \
|
||||
relation->rd_rel->relam == BTREE_AM_OID), \
|
||||
(relation)->rd_options ? \
|
||||
((BTOptions *) (relation)->rd_options)->fillfactor : \
|
||||
BTREE_DEFAULT_FILLFACTOR)
|
||||
#define BTGetTargetPageFreeSpace(relation) \
|
||||
(BLCKSZ * (100 - BTGetFillFactor(relation)) / 100)
|
||||
|
||||
/*
|
||||
* Constant definition for progress reporting. Phase numbers must match
|
||||
* btbuildphasename.
|
||||
|
||||
Reference in New Issue
Block a user