From 26df7066cc229887d4defdf1d105c0a22b8a88fb Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Fri, 15 May 2015 17:03:16 -0300
Subject: [PATCH] Move strategy numbers to include/access/stratnum.h
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

For upcoming BRIN opclasses, it's convenient to have strategy numbers
defined in a single place.  Since there's nothing appropriate, create
it.  The StrategyNumber typedef now lives there, as well as existing
strategy numbers for B-trees (from skey.h) and R-tree-and-friends (from
gist.h).  skey.h is forced to include stratnum.h because of the
StrategyNumber typedef, but gist.h is not; extensions that currently
rely on gist.h for rtree strategy numbers might need to add a new

A few .c files can stop including skey.h and/or gist.h, which is a nice
side benefit.

Per discussion:
https://www.postgresql.org/message-id/20150514232132.GZ2523@alvh.no-ip.org

Authored by Emre Hasegeli and Álvaro.

(It's not clear to me why bootscanner.l has any #include lines at all.)
---
 contrib/btree_gin/btree_gin.c               |  2 +-
 contrib/cube/cube.c                         |  2 +-
 contrib/hstore/hstore_gin.c                 |  2 +-
 contrib/hstore/hstore_gist.c                |  2 +-
 contrib/intarray/_int_gin.c                 |  3 +-
 contrib/intarray/_int_gist.c                |  2 +-
 contrib/intarray/_intbig_gist.c             |  2 +-
 contrib/ltree/_ltree_gist.c                 |  2 +-
 contrib/ltree/ltree_gist.c                  |  2 +-
 contrib/pg_trgm/trgm_gin.c                  |  3 +-
 contrib/pg_trgm/trgm_gist.c                 |  3 +-
 contrib/seg/seg.c                           |  3 +-
 src/backend/access/brin/brin_minmax.c       |  2 +-
 src/backend/access/gin/ginarrayproc.c       |  2 +-
 src/backend/access/gist/gistproc.c          |  2 +-
 src/backend/access/spgist/spgkdtreeproc.c   |  2 +-
 src/backend/access/spgist/spgquadtreeproc.c |  2 +-
 src/backend/bootstrap/bootparse.y           |  1 -
 src/backend/bootstrap/bootscanner.l         |  1 -
 src/backend/optimizer/path/equivclass.c     |  2 +-
 src/backend/optimizer/path/indxpath.c       |  2 +-
 src/backend/optimizer/path/pathkeys.c       |  2 +-
 src/backend/optimizer/plan/createplan.c     |  2 +-
 src/backend/optimizer/util/predtest.c       |  2 +-
 src/backend/utils/adt/jsonb_gin.c           |  2 +-
 src/backend/utils/adt/network_gist.c        | 24 +++----
 src/backend/utils/adt/rangetypes_gist.c     |  2 +-
 src/backend/utils/adt/rangetypes_spgist.c   |  2 +-
 src/backend/utils/adt/tsginidx.c            |  2 +-
 src/backend/utils/adt/tsquery_gist.c        |  2 +-
 src/include/access/gist.h                   | 20 ------
 src/include/access/nbtree.h                 |  2 +-
 src/include/access/skey.h                   | 23 +------
 src/include/access/stratnum.h               | 75 +++++++++++++++++++++
 src/include/utils/rangetypes.h              | 20 +++---
 35 files changed, 129 insertions(+), 95 deletions(-)
 create mode 100644 src/include/access/stratnum.h

diff --git a/contrib/btree_gin/btree_gin.c b/contrib/btree_gin/btree_gin.c
index 1a5bb3cdc65..6e3bf172e50 100644
--- a/contrib/btree_gin/btree_gin.c
+++ b/contrib/btree_gin/btree_gin.c
@@ -5,7 +5,7 @@
 
 #include <limits.h>
 
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "utils/builtins.h"
 #include "utils/bytea.h"
 #include "utils/cash.h"
diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c
index b9ccad994a8..113c66383ac 100644
--- a/contrib/cube/cube.c
+++ b/contrib/cube/cube.c
@@ -12,7 +12,7 @@
 #include <math.h>
 
 #include "access/gist.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "utils/array.h"
 #include "utils/builtins.h"
 
diff --git a/contrib/hstore/hstore_gin.c b/contrib/hstore/hstore_gin.c
index 68f9061db14..919181d375e 100644
--- a/contrib/hstore/hstore_gin.c
+++ b/contrib/hstore/hstore_gin.c
@@ -4,7 +4,7 @@
 #include "postgres.h"
 
 #include "access/gin.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "catalog/pg_type.h"
 
 #include "hstore.h"
diff --git a/contrib/hstore/hstore_gist.c b/contrib/hstore/hstore_gist.c
index 06f3c9359b9..dde37fb6e60 100644
--- a/contrib/hstore/hstore_gist.c
+++ b/contrib/hstore/hstore_gist.c
@@ -4,7 +4,7 @@
 #include "postgres.h"
 
 #include "access/gist.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "catalog/pg_type.h"
 #include "utils/pg_crc.h"
 
diff --git a/contrib/intarray/_int_gin.c b/contrib/intarray/_int_gin.c
index 58352cac807..fb16b66edb0 100644
--- a/contrib/intarray/_int_gin.c
+++ b/contrib/intarray/_int_gin.c
@@ -4,8 +4,7 @@
 #include "postgres.h"
 
 #include "access/gin.h"
-#include "access/gist.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 
 #include "_int.h"
 
diff --git a/contrib/intarray/_int_gist.c b/contrib/intarray/_int_gist.c
index 07108eb15eb..888c277e60f 100644
--- a/contrib/intarray/_int_gist.c
+++ b/contrib/intarray/_int_gist.c
@@ -6,7 +6,7 @@
 #include <limits.h>
 
 #include "access/gist.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 
 #include "_int.h"
 
diff --git a/contrib/intarray/_intbig_gist.c b/contrib/intarray/_intbig_gist.c
index 235db389572..6dae7c91c12 100644
--- a/contrib/intarray/_intbig_gist.c
+++ b/contrib/intarray/_intbig_gist.c
@@ -4,7 +4,7 @@
 #include "postgres.h"
 
 #include "access/gist.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 
 #include "_int.h"
 
diff --git a/contrib/ltree/_ltree_gist.c b/contrib/ltree/_ltree_gist.c
index 41be68d7ee6..37cd9916942 100644
--- a/contrib/ltree/_ltree_gist.c
+++ b/contrib/ltree/_ltree_gist.c
@@ -8,7 +8,7 @@
 #include "postgres.h"
 
 #include "access/gist.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "crc32.h"
 #include "ltree.h"
 
diff --git a/contrib/ltree/ltree_gist.c b/contrib/ltree/ltree_gist.c
index 2d89f1aed4c..83da62018e3 100644
--- a/contrib/ltree/ltree_gist.c
+++ b/contrib/ltree/ltree_gist.c
@@ -6,7 +6,7 @@
 #include "postgres.h"
 
 #include "access/gist.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "crc32.h"
 #include "ltree.h"
 
diff --git a/contrib/pg_trgm/trgm_gin.c b/contrib/pg_trgm/trgm_gin.c
index c59925c5750..d524ceaa19e 100644
--- a/contrib/pg_trgm/trgm_gin.c
+++ b/contrib/pg_trgm/trgm_gin.c
@@ -6,7 +6,8 @@
 #include "trgm.h"
 
 #include "access/gin.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
+#include "fmgr.h"
 
 
 PG_FUNCTION_INFO_V1(gin_extract_trgm);
diff --git a/contrib/pg_trgm/trgm_gist.c b/contrib/pg_trgm/trgm_gist.c
index 69dc7f71f07..07d1dc308bb 100644
--- a/contrib/pg_trgm/trgm_gist.c
+++ b/contrib/pg_trgm/trgm_gist.c
@@ -5,7 +5,8 @@
 
 #include "trgm.h"
 
-#include "access/skey.h"
+#include "access/stratnum.h"
+#include "fmgr.h"
 
 
 typedef struct
diff --git a/contrib/seg/seg.c b/contrib/seg/seg.c
index 8e2d5343ae9..1e6c37d9e1a 100644
--- a/contrib/seg/seg.c
+++ b/contrib/seg/seg.c
@@ -12,7 +12,8 @@
 #include <float.h>
 
 #include "access/gist.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
+#include "fmgr.h"
 
 #include "segdata.h"
 
diff --git a/src/backend/access/brin/brin_minmax.c b/src/backend/access/brin/brin_minmax.c
index d64c4f08644..1175649a6d6 100644
--- a/src/backend/access/brin/brin_minmax.c
+++ b/src/backend/access/brin/brin_minmax.c
@@ -13,7 +13,7 @@
 #include "access/genam.h"
 #include "access/brin_internal.h"
 #include "access/brin_tuple.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "catalog/pg_type.h"
 #include "catalog/pg_amop.h"
 #include "utils/datum.h"
diff --git a/src/backend/access/gin/ginarrayproc.c b/src/backend/access/gin/ginarrayproc.c
index 9c26e778662..9220b5fccc5 100644
--- a/src/backend/access/gin/ginarrayproc.c
+++ b/src/backend/access/gin/ginarrayproc.c
@@ -14,7 +14,7 @@
 #include "postgres.h"
 
 #include "access/gin.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "utils/array.h"
 #include "utils/builtins.h"
 #include "utils/lsyscache.h"
diff --git a/src/backend/access/gist/gistproc.c b/src/backend/access/gist/gistproc.c
index 9667e397ce4..4cea3f1be18 100644
--- a/src/backend/access/gist/gistproc.c
+++ b/src/backend/access/gist/gistproc.c
@@ -18,7 +18,7 @@
 #include "postgres.h"
 
 #include "access/gist.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "utils/geo_decls.h"
 
 
diff --git a/src/backend/access/spgist/spgkdtreeproc.c b/src/backend/access/spgist/spgkdtreeproc.c
index 6ea0954efb3..88c0df25894 100644
--- a/src/backend/access/spgist/spgkdtreeproc.c
+++ b/src/backend/access/spgist/spgkdtreeproc.c
@@ -15,8 +15,8 @@
 
 #include "postgres.h"
 
-#include "access/gist.h"		/* for RTree strategy numbers */
 #include "access/spgist.h"
+#include "access/stratnum.h"
 #include "catalog/pg_type.h"
 #include "utils/builtins.h"
 #include "utils/geo_decls.h"
diff --git a/src/backend/access/spgist/spgquadtreeproc.c b/src/backend/access/spgist/spgquadtreeproc.c
index e4b8888de8a..a5f93614df3 100644
--- a/src/backend/access/spgist/spgquadtreeproc.c
+++ b/src/backend/access/spgist/spgquadtreeproc.c
@@ -15,8 +15,8 @@
 
 #include "postgres.h"
 
-#include "access/gist.h"		/* for RTree strategy numbers */
 #include "access/spgist.h"
+#include "access/stratnum.h"
 #include "catalog/pg_type.h"
 #include "utils/builtins.h"
 #include "utils/geo_decls.h"
diff --git a/src/backend/bootstrap/bootparse.y b/src/backend/bootstrap/bootparse.y
index 6e563b67e61..d8d1b06ff0a 100644
--- a/src/backend/bootstrap/bootparse.y
+++ b/src/backend/bootstrap/bootparse.y
@@ -21,7 +21,6 @@
 #include "access/attnum.h"
 #include "access/htup.h"
 #include "access/itup.h"
-#include "access/skey.h"
 #include "access/tupdesc.h"
 #include "access/xact.h"
 #include "bootstrap/bootstrap.h"
diff --git a/src/backend/bootstrap/bootscanner.l b/src/backend/bootstrap/bootscanner.l
index 72714f474bf..e60d377ccc3 100644
--- a/src/backend/bootstrap/bootscanner.l
+++ b/src/backend/bootstrap/bootscanner.l
@@ -18,7 +18,6 @@
 #include "access/attnum.h"
 #include "access/htup.h"
 #include "access/itup.h"
-#include "access/skey.h"
 #include "access/tupdesc.h"
 #include "bootstrap/bootstrap.h"
 #include "catalog/pg_am.h"
diff --git a/src/backend/optimizer/path/equivclass.c b/src/backend/optimizer/path/equivclass.c
index eb65c970d70..80021d57bdc 100644
--- a/src/backend/optimizer/path/equivclass.c
+++ b/src/backend/optimizer/path/equivclass.c
@@ -16,7 +16,7 @@
  */
 #include "postgres.h"
 
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "catalog/pg_type.h"
 #include "nodes/makefuncs.h"
 #include "nodes/nodeFuncs.h"
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c
index fdd6baba6c6..26e6e1b6512 100644
--- a/src/backend/optimizer/path/indxpath.c
+++ b/src/backend/optimizer/path/indxpath.c
@@ -17,7 +17,7 @@
 
 #include <math.h>
 
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "access/sysattr.h"
 #include "catalog/pg_am.h"
 #include "catalog/pg_collation.h"
diff --git a/src/backend/optimizer/path/pathkeys.c b/src/backend/optimizer/path/pathkeys.c
index 42183dfecbc..8b25222b93a 100644
--- a/src/backend/optimizer/path/pathkeys.c
+++ b/src/backend/optimizer/path/pathkeys.c
@@ -17,7 +17,7 @@
  */
 #include "postgres.h"
 
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "nodes/makefuncs.h"
 #include "nodes/nodeFuncs.h"
 #include "nodes/plannodes.h"
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index c6095167e80..0775a676d05 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -19,7 +19,7 @@
 #include <limits.h>
 #include <math.h>
 
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "access/sysattr.h"
 #include "catalog/pg_class.h"
 #include "catalog/pg_operator.h"
diff --git a/src/backend/optimizer/util/predtest.c b/src/backend/optimizer/util/predtest.c
index cd34766c9a7..d9e49d127e1 100644
--- a/src/backend/optimizer/util/predtest.c
+++ b/src/backend/optimizer/util/predtest.c
@@ -1248,7 +1248,7 @@ list_member_strip(List *list, Expr *datum)
  * Define "operator implication tables" for btree operators ("strategies"),
  * and similar tables for refutation.
  *
- * The strategy numbers defined by btree indexes (see access/skey.h) are:
+ * The strategy numbers defined by btree indexes (see access/stratnum.h) are:
  *		1 <		2 <=	3 =		4 >=	5 >
  * and in addition we use 6 to represent <>.  <> is not a btree-indexable
  * operator, but we assume here that if an equality operator of a btree
diff --git a/src/backend/utils/adt/jsonb_gin.c b/src/backend/utils/adt/jsonb_gin.c
index bc521ed8319..2591c81f3d6 100644
--- a/src/backend/utils/adt/jsonb_gin.c
+++ b/src/backend/utils/adt/jsonb_gin.c
@@ -15,7 +15,7 @@
 
 #include "access/gin.h"
 #include "access/hash.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "catalog/pg_collation.h"
 #include "catalog/pg_type.h"
 #include "utils/builtins.h"
diff --git a/src/backend/utils/adt/network_gist.c b/src/backend/utils/adt/network_gist.c
index cd2b8b19a77..2e3ee1e8ba7 100644
--- a/src/backend/utils/adt/network_gist.c
+++ b/src/backend/utils/adt/network_gist.c
@@ -48,23 +48,23 @@
 #include <sys/socket.h>
 
 #include "access/gist.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "utils/inet.h"
 
 /*
  * Operator strategy numbers used in the GiST inet_ops opclass
  */
-#define INETSTRAT_OVERLAPS		3
-#define INETSTRAT_EQ			18
-#define INETSTRAT_NE			19
-#define INETSTRAT_LT			20
-#define INETSTRAT_LE			21
-#define INETSTRAT_GT			22
-#define INETSTRAT_GE			23
-#define INETSTRAT_SUB			24
-#define INETSTRAT_SUBEQ			25
-#define INETSTRAT_SUP			26
-#define INETSTRAT_SUPEQ			27
+#define INETSTRAT_OVERLAPS		RTOverlapStrategyNumber
+#define INETSTRAT_EQ			RTEqualStrategyNumber
+#define INETSTRAT_NE			RTNotEqualStrategyNumber
+#define INETSTRAT_LT			RTLessStrategyNumber
+#define INETSTRAT_LE			RTLessEqualStrategyNumber
+#define INETSTRAT_GT			RTGreaterStrategyNumber
+#define INETSTRAT_GE			RTGreaterEqualStrategyNumber
+#define INETSTRAT_SUB			RTSubStrategyNumber
+#define INETSTRAT_SUBEQ			RTSubOrEqualStrategyNumber
+#define INETSTRAT_SUP			RTSuperStrategyNumber
+#define INETSTRAT_SUPEQ			RTSuperOrEqualStrategyNumber
 
 
 /*
diff --git a/src/backend/utils/adt/rangetypes_gist.c b/src/backend/utils/adt/rangetypes_gist.c
index ef841219d00..ddeb18b72f9 100644
--- a/src/backend/utils/adt/rangetypes_gist.c
+++ b/src/backend/utils/adt/rangetypes_gist.c
@@ -15,7 +15,7 @@
 #include "postgres.h"
 
 #include "access/gist.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "utils/builtins.h"
 #include "utils/datum.h"
 #include "utils/rangetypes.h"
diff --git a/src/backend/utils/adt/rangetypes_spgist.c b/src/backend/utils/adt/rangetypes_spgist.c
index d7b208118ff..9281529d7a1 100644
--- a/src/backend/utils/adt/rangetypes_spgist.c
+++ b/src/backend/utils/adt/rangetypes_spgist.c
@@ -37,7 +37,7 @@
 #include "postgres.h"
 
 #include "access/spgist.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "catalog/pg_type.h"
 #include "utils/builtins.h"
 #include "utils/datum.h"
diff --git a/src/backend/utils/adt/tsginidx.c b/src/backend/utils/adt/tsginidx.c
index 828175b7a12..da90ca84f87 100644
--- a/src/backend/utils/adt/tsginidx.c
+++ b/src/backend/utils/adt/tsginidx.c
@@ -14,7 +14,7 @@
 #include "postgres.h"
 
 #include "access/gin.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "miscadmin.h"
 #include "tsearch/ts_type.h"
 #include "tsearch/ts_utils.h"
diff --git a/src/backend/utils/adt/tsquery_gist.c b/src/backend/utils/adt/tsquery_gist.c
index d610bbc7917..232715c5740 100644
--- a/src/backend/utils/adt/tsquery_gist.c
+++ b/src/backend/utils/adt/tsquery_gist.c
@@ -14,7 +14,7 @@
 
 #include "postgres.h"
 
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "access/gist.h"
 #include "tsearch/ts_utils.h"
 
diff --git a/src/include/access/gist.h b/src/include/access/gist.h
index 50261b8bdd5..81e559bc2dd 100644
--- a/src/include/access/gist.h
+++ b/src/include/access/gist.h
@@ -36,26 +36,6 @@
 #define GIST_FETCH_PROC					9
 #define GISTNProcs					9
 
-/*
- * strategy numbers for GiST opclasses that want to implement the old
- * RTREE behavior.
- */
-#define RTLeftStrategyNumber			1
-#define RTOverLeftStrategyNumber		2
-#define RTOverlapStrategyNumber			3
-#define RTOverRightStrategyNumber		4
-#define RTRightStrategyNumber			5
-#define RTSameStrategyNumber			6
-#define RTContainsStrategyNumber		7		/* for @> */
-#define RTContainedByStrategyNumber		8		/* for <@ */
-#define RTOverBelowStrategyNumber		9
-#define RTBelowStrategyNumber			10
-#define RTAboveStrategyNumber			11
-#define RTOverAboveStrategyNumber		12
-#define RTOldContainsStrategyNumber		13		/* for old spelling of @> */
-#define RTOldContainedByStrategyNumber	14		/* for old spelling of <@ */
-#define RTKNNSearchStrategyNumber		15
-
 /*
  * Page opaque data in a GiST index page.
  */
diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h
index 2ef349b7483..9e48efd8292 100644
--- a/src/include/access/nbtree.h
+++ b/src/include/access/nbtree.h
@@ -430,7 +430,7 @@ typedef struct xl_btree_newroot
 
 
 /*
- *	Operator strategy numbers for B-tree have been moved to access/skey.h,
+ *	Operator strategy numbers for B-tree have been moved to access/stratnum.h,
  *	because many places need to use them in ScanKeyInit() calls.
  *
  *	The strategy numbers are chosen so that we can commute them by
diff --git a/src/include/access/skey.h b/src/include/access/skey.h
index eeee1f43d44..76c33bcfc43 100644
--- a/src/include/access/skey.h
+++ b/src/include/access/skey.h
@@ -15,31 +15,10 @@
 #define SKEY_H
 
 #include "access/attnum.h"
+#include "access/stratnum.h"
 #include "fmgr.h"
 
 
-/*
- * Strategy numbers identify the semantics that particular operators have
- * with respect to particular operator classes.  In some cases a strategy
- * subtype (an OID) is used as further information.
- */
-typedef uint16 StrategyNumber;
-
-#define InvalidStrategy ((StrategyNumber) 0)
-
-/*
- * We define the strategy numbers for B-tree indexes here, to avoid having
- * to import access/nbtree.h into a lot of places that shouldn't need it.
- */
-#define BTLessStrategyNumber			1
-#define BTLessEqualStrategyNumber		2
-#define BTEqualStrategyNumber			3
-#define BTGreaterEqualStrategyNumber	4
-#define BTGreaterStrategyNumber			5
-
-#define BTMaxStrategyNumber				5
-
-
 /*
  * A ScanKey represents the application of a comparison operator between
  * a table or index column and a constant.  When it's part of an array of
diff --git a/src/include/access/stratnum.h b/src/include/access/stratnum.h
new file mode 100644
index 00000000000..458f4dc888d
--- /dev/null
+++ b/src/include/access/stratnum.h
@@ -0,0 +1,75 @@
+/*-------------------------------------------------------------------------
+ *
+ * stratnum.h
+ *	  POSTGRES strategy number definitions.
+ *
+ *
+ * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/access/stratnum.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef STRATNUM_H
+#define STRATNUM_H
+
+/*
+ * Strategy numbers identify the semantics that particular operators have
+ * with respect to particular operator classes.  In some cases a strategy
+ * subtype (an OID) is used as further information.
+ */
+typedef uint16 StrategyNumber;
+
+#define InvalidStrategy ((StrategyNumber) 0)
+
+/*
+ * Strategy numbers for B-tree indexes.
+ */
+#define BTLessStrategyNumber			1
+#define BTLessEqualStrategyNumber		2
+#define BTEqualStrategyNumber			3
+#define BTGreaterEqualStrategyNumber	4
+#define BTGreaterStrategyNumber			5
+
+#define BTMaxStrategyNumber				5
+
+
+/*
+ * Strategy numbers common to (some) GiST, SP-GiST and BRIN opclasses.
+ *
+ * The first few of these come from the R-Tree indexing method (hence the
+ * names); the others have been added over time as they have been needed.
+ */
+#define RTLeftStrategyNumber			1		/* for << */
+#define RTOverLeftStrategyNumber		2		/* for &< */
+#define RTOverlapStrategyNumber			3		/* for && */
+#define RTOverRightStrategyNumber		4		/* for &> */
+#define RTRightStrategyNumber			5		/* for >> */
+#define RTSameStrategyNumber			6		/* for ~= */
+#define RTContainsStrategyNumber		7		/* for @> */
+#define RTContainedByStrategyNumber		8		/* for <@ */
+#define RTOverBelowStrategyNumber		9		/* for &<| */
+#define RTBelowStrategyNumber			10		/* for <<| */
+#define RTAboveStrategyNumber			11		/* for |>> */
+#define RTOverAboveStrategyNumber		12		/* for |&> */
+#define RTOldContainsStrategyNumber		13		/* for old spelling of @> */
+#define RTOldContainedByStrategyNumber	14		/* for old spelling of <@ */
+#define RTKNNSearchStrategyNumber		15		/* for <-> (distance) */
+#define RTContainsElemStrategyNumber	16		/* for range types @> elem */
+#define RTAdjacentStrategyNumber		17		/* for -|- */
+#define RTEqualStrategyNumber			18		/* for = */
+#define RTNotEqualStrategyNumber		19		/* for != */
+#define RTLessStrategyNumber			20		/* for < */
+#define RTLessEqualStrategyNumber		21		/* for <= */
+#define RTGreaterStrategyNumber			22		/* for > */
+#define RTGreaterEqualStrategyNumber	23		/* for >= */
+#define RTSubStrategyNumber				24		/* for inet >> */
+#define RTSubOrEqualStrategyNumber		25		/* for inet <<= */
+#define RTSuperStrategyNumber			26		/* for inet << */
+#define RTSuperOrEqualStrategyNumber	27		/* for inet >>= */
+
+#define RTMaxStrategyNumber				27
+
+
+#endif		/* STRATNUM_H */
diff --git a/src/include/utils/rangetypes.h b/src/include/utils/rangetypes.h
index 00a3efedc6d..487b2b37188 100644
--- a/src/include/utils/rangetypes.h
+++ b/src/include/utils/rangetypes.h
@@ -77,16 +77,16 @@ typedef struct
 
 /* Operator strategy numbers used in the GiST and SP-GiST range opclasses */
 /* Numbers are chosen to match up operator names with existing usages */
-#define RANGESTRAT_BEFORE				1
-#define RANGESTRAT_OVERLEFT				2
-#define RANGESTRAT_OVERLAPS				3
-#define RANGESTRAT_OVERRIGHT			4
-#define RANGESTRAT_AFTER				5
-#define RANGESTRAT_ADJACENT				6
-#define RANGESTRAT_CONTAINS				7
-#define RANGESTRAT_CONTAINED_BY			8
-#define RANGESTRAT_CONTAINS_ELEM		16
-#define RANGESTRAT_EQ					18
+#define RANGESTRAT_BEFORE				RTLeftStrategyNumber
+#define RANGESTRAT_OVERLEFT				RTOverLeftStrategyNumber
+#define RANGESTRAT_OVERLAPS				RTOverlapStrategyNumber
+#define RANGESTRAT_OVERRIGHT			RTOverRightStrategyNumber
+#define RANGESTRAT_AFTER				RTRightStrategyNumber
+#define RANGESTRAT_ADJACENT				RTSameStrategyNumber
+#define RANGESTRAT_CONTAINS				RTContainsStrategyNumber
+#define RANGESTRAT_CONTAINED_BY			RTContainedByStrategyNumber
+#define RANGESTRAT_CONTAINS_ELEM		RTContainsElemStrategyNumber
+#define RANGESTRAT_EQ					RTEqualStrategyNumber
 
 /*
  * prototypes for functions defined in rangetypes.c
-- 
GitLab