mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Prevent to use magic constants
Use macroses for definition amstrategies/amsupport fields instead of hardcoded values. Author: Nikolay Shaplov with addition for contrib/bloom
This commit is contained in:
		@@ -73,8 +73,8 @@ blhandler(PG_FUNCTION_ARGS)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
 | 
						IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	amroutine->amstrategies = 1;
 | 
						amroutine->amstrategies = BLOOM_NSTRATEGIES;
 | 
				
			||||||
	amroutine->amsupport = 1;
 | 
						amroutine->amsupport = BLOOM_NPROC;
 | 
				
			||||||
	amroutine->amcanorder = false;
 | 
						amroutine->amcanorder = false;
 | 
				
			||||||
	amroutine->amcanorderbyop = false;
 | 
						amroutine->amcanorderbyop = false;
 | 
				
			||||||
	amroutine->amcanbackward = false;
 | 
						amroutine->amcanbackward = false;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,7 +35,7 @@ ginhandler(PG_FUNCTION_ARGS)
 | 
				
			|||||||
	IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
 | 
						IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	amroutine->amstrategies = 0;
 | 
						amroutine->amstrategies = 0;
 | 
				
			||||||
	amroutine->amsupport = 6;
 | 
						amroutine->amsupport = GINNProcs;
 | 
				
			||||||
	amroutine->amcanorder = false;
 | 
						amroutine->amcanorder = false;
 | 
				
			||||||
	amroutine->amcanorderbyop = false;
 | 
						amroutine->amcanorderbyop = false;
 | 
				
			||||||
	amroutine->amcanbackward = false;
 | 
						amroutine->amcanbackward = false;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,7 +57,7 @@ gisthandler(PG_FUNCTION_ARGS)
 | 
				
			|||||||
	IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
 | 
						IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	amroutine->amstrategies = 0;
 | 
						amroutine->amstrategies = 0;
 | 
				
			||||||
	amroutine->amsupport = 9;
 | 
						amroutine->amsupport = GISTNProcs;
 | 
				
			||||||
	amroutine->amcanorder = false;
 | 
						amroutine->amcanorder = false;
 | 
				
			||||||
	amroutine->amcanorderbyop = true;
 | 
						amroutine->amcanorderbyop = true;
 | 
				
			||||||
	amroutine->amcanbackward = false;
 | 
						amroutine->amcanbackward = false;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,8 +51,8 @@ hashhandler(PG_FUNCTION_ARGS)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
 | 
						IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	amroutine->amstrategies = 1;
 | 
						amroutine->amstrategies = HTMaxStrategyNumber;
 | 
				
			||||||
	amroutine->amsupport = 1;
 | 
						amroutine->amsupport = HASHNProcs;
 | 
				
			||||||
	amroutine->amcanorder = false;
 | 
						amroutine->amcanorder = false;
 | 
				
			||||||
	amroutine->amcanorderbyop = false;
 | 
						amroutine->amcanorderbyop = false;
 | 
				
			||||||
	amroutine->amcanbackward = true;
 | 
						amroutine->amcanbackward = true;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -84,8 +84,8 @@ bthandler(PG_FUNCTION_ARGS)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
 | 
						IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	amroutine->amstrategies = 5;
 | 
						amroutine->amstrategies = BTMaxStrategyNumber;
 | 
				
			||||||
	amroutine->amsupport = 2;
 | 
						amroutine->amsupport = BTNProcs;
 | 
				
			||||||
	amroutine->amcanorder = true;
 | 
						amroutine->amcanorder = true;
 | 
				
			||||||
	amroutine->amcanorderbyop = false;
 | 
						amroutine->amcanorderbyop = false;
 | 
				
			||||||
	amroutine->amcanbackward = true;
 | 
						amroutine->amcanbackward = true;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,7 +36,7 @@ spghandler(PG_FUNCTION_ARGS)
 | 
				
			|||||||
	IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
 | 
						IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	amroutine->amstrategies = 0;
 | 
						amroutine->amstrategies = 0;
 | 
				
			||||||
	amroutine->amsupport = 5;
 | 
						amroutine->amsupport = SPGISTNProc;
 | 
				
			||||||
	amroutine->amcanorder = false;
 | 
						amroutine->amcanorder = false;
 | 
				
			||||||
	amroutine->amcanorderbyop = false;
 | 
						amroutine->amcanorderbyop = false;
 | 
				
			||||||
	amroutine->amcanbackward = false;
 | 
						amroutine->amcanbackward = false;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -239,6 +239,7 @@ typedef HashMetaPageData *HashMetaPage;
 | 
				
			|||||||
 *	Since we only have one such proc in amproc, it's number 1.
 | 
					 *	Since we only have one such proc in amproc, it's number 1.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
#define HASHPROC		1
 | 
					#define HASHPROC		1
 | 
				
			||||||
 | 
					#define HASHNProcs		1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* public routines */
 | 
					/* public routines */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -454,6 +454,7 @@ typedef struct xl_btree_newroot
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define BTORDER_PROC		1
 | 
					#define BTORDER_PROC		1
 | 
				
			||||||
#define BTSORTSUPPORT_PROC	2
 | 
					#define BTSORTSUPPORT_PROC	2
 | 
				
			||||||
 | 
					#define BTNProcs			2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 *	We need to be able to tell the difference between read and write
 | 
					 *	We need to be able to tell the difference between read and write
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user