Commit f8467f7d authored by Teodor Sigaev's avatar Teodor Sigaev

Prevent to use magic constants

Use macroses for definition amstrategies/amsupport fields instead of
hardcoded values.

Author: Nikolay Shaplov with addition for contrib/bloom
parent e2c79e14
...@@ -73,8 +73,8 @@ blhandler(PG_FUNCTION_ARGS) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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; ...@@ -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 ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment