Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f8467f7

Browse files
committed
Prevent to use magic constants
Use macroses for definition amstrategies/amsupport fields instead of hardcoded values. Author: Nikolay Shaplov with addition for contrib/bloom
1 parent e2c79e1 commit f8467f7

File tree

8 files changed

+11
-9
lines changed

8 files changed

+11
-9
lines changed

contrib/bloom/blutils.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ blhandler(PG_FUNCTION_ARGS)
7373
{
7474
IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
7575

76-
amroutine->amstrategies = 1;
77-
amroutine->amsupport = 1;
76+
amroutine->amstrategies = BLOOM_NSTRATEGIES;
77+
amroutine->amsupport = BLOOM_NPROC;
7878
amroutine->amcanorder = false;
7979
amroutine->amcanorderbyop = false;
8080
amroutine->amcanbackward = false;

src/backend/access/gin/ginutil.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ginhandler(PG_FUNCTION_ARGS)
3535
IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
3636

3737
amroutine->amstrategies = 0;
38-
amroutine->amsupport = 6;
38+
amroutine->amsupport = GINNProcs;
3939
amroutine->amcanorder = false;
4040
amroutine->amcanorderbyop = false;
4141
amroutine->amcanbackward = false;

src/backend/access/gist/gist.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ gisthandler(PG_FUNCTION_ARGS)
5757
IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
5858

5959
amroutine->amstrategies = 0;
60-
amroutine->amsupport = 9;
60+
amroutine->amsupport = GISTNProcs;
6161
amroutine->amcanorder = false;
6262
amroutine->amcanorderbyop = true;
6363
amroutine->amcanbackward = false;

src/backend/access/hash/hash.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ hashhandler(PG_FUNCTION_ARGS)
5151
{
5252
IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
5353

54-
amroutine->amstrategies = 1;
55-
amroutine->amsupport = 1;
54+
amroutine->amstrategies = HTMaxStrategyNumber;
55+
amroutine->amsupport = HASHNProcs;
5656
amroutine->amcanorder = false;
5757
amroutine->amcanorderbyop = false;
5858
amroutine->amcanbackward = true;

src/backend/access/nbtree/nbtree.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ bthandler(PG_FUNCTION_ARGS)
8484
{
8585
IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
8686

87-
amroutine->amstrategies = 5;
88-
amroutine->amsupport = 2;
87+
amroutine->amstrategies = BTMaxStrategyNumber;
88+
amroutine->amsupport = BTNProcs;
8989
amroutine->amcanorder = true;
9090
amroutine->amcanorderbyop = false;
9191
amroutine->amcanbackward = true;

src/backend/access/spgist/spgutils.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ spghandler(PG_FUNCTION_ARGS)
3636
IndexAmRoutine *amroutine = makeNode(IndexAmRoutine);
3737

3838
amroutine->amstrategies = 0;
39-
amroutine->amsupport = 5;
39+
amroutine->amsupport = SPGISTNProc;
4040
amroutine->amcanorder = false;
4141
amroutine->amcanorderbyop = false;
4242
amroutine->amcanbackward = false;

src/include/access/hash.h

+1
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ typedef HashMetaPageData *HashMetaPage;
239239
* Since we only have one such proc in amproc, it's number 1.
240240
*/
241241
#define HASHPROC 1
242+
#define HASHNProcs 1
242243

243244

244245
/* public routines */

src/include/access/nbtree.h

+1
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ typedef struct xl_btree_newroot
454454

455455
#define BTORDER_PROC 1
456456
#define BTSORTSUPPORT_PROC 2
457+
#define BTNProcs 2
457458

458459
/*
459460
* We need to be able to tell the difference between read and write

0 commit comments

Comments
 (0)