mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +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:
		@@ -408,8 +408,7 @@ SpGistGetBuffer(Relation index, int flags, int needSpace, bool *isNew)
 | 
			
		||||
	 * related to the ones already on it.  But fillfactor mustn't cause an
 | 
			
		||||
	 * error for requests that would otherwise be legal.
 | 
			
		||||
	 */
 | 
			
		||||
	needSpace += RelationGetTargetPageFreeSpace(index,
 | 
			
		||||
												SPGIST_DEFAULT_FILLFACTOR);
 | 
			
		||||
	needSpace += SpGistGetTargetPageFreeSpace(index);
 | 
			
		||||
	needSpace = Min(needSpace, SPGIST_PAGE_CAPACITY);
 | 
			
		||||
 | 
			
		||||
	/* Get the cache entry for this flags setting */
 | 
			
		||||
@@ -586,7 +585,15 @@ SpGistInitMetapage(Page page)
 | 
			
		||||
bytea *
 | 
			
		||||
spgoptions(Datum reloptions, bool validate)
 | 
			
		||||
{
 | 
			
		||||
	return default_reloptions(reloptions, validate, RELOPT_KIND_SPGIST);
 | 
			
		||||
	static const relopt_parse_elt tab[] = {
 | 
			
		||||
		{"fillfactor", RELOPT_TYPE_INT, offsetof(SpGistOptions, fillfactor)},
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	return (bytea *) build_reloptions(reloptions, validate,
 | 
			
		||||
									  RELOPT_KIND_SPGIST,
 | 
			
		||||
									  sizeof(SpGistOptions),
 | 
			
		||||
									  tab, lengthof(tab));
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user