Move strategy numbers to include/access/stratnum.h
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 15 May 2015 20:03:16 +0000 (17:03 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 15 May 2015 20:03:16 +0000 (17:03 -0300)
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.)

35 files changed:
contrib/btree_gin/btree_gin.c
contrib/cube/cube.c
contrib/hstore/hstore_gin.c
contrib/hstore/hstore_gist.c
contrib/intarray/_int_gin.c
contrib/intarray/_int_gist.c
contrib/intarray/_intbig_gist.c
contrib/ltree/_ltree_gist.c
contrib/ltree/ltree_gist.c
contrib/pg_trgm/trgm_gin.c
contrib/pg_trgm/trgm_gist.c
contrib/seg/seg.c
src/backend/access/brin/brin_minmax.c
src/backend/access/gin/ginarrayproc.c
src/backend/access/gist/gistproc.c
src/backend/access/spgist/spgkdtreeproc.c
src/backend/access/spgist/spgquadtreeproc.c
src/backend/bootstrap/bootparse.y
src/backend/bootstrap/bootscanner.l
src/backend/optimizer/path/equivclass.c
src/backend/optimizer/path/indxpath.c
src/backend/optimizer/path/pathkeys.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/util/predtest.c
src/backend/utils/adt/jsonb_gin.c
src/backend/utils/adt/network_gist.c
src/backend/utils/adt/rangetypes_gist.c
src/backend/utils/adt/rangetypes_spgist.c
src/backend/utils/adt/tsginidx.c
src/backend/utils/adt/tsquery_gist.c
src/include/access/gist.h
src/include/access/nbtree.h
src/include/access/skey.h
src/include/access/stratnum.h [new file with mode: 0644]
src/include/utils/rangetypes.h

index 1a5bb3cdc650dbb39e4c22b079054cfd75ac7e20..6e3bf172e5021c1450a8195eee25a2eae19b63f4 100644 (file)
@@ -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"
index b9ccad994a8c000ae9345b3b488e69080b96ebf3..113c66383ac36b0d71c927b8f1d36fb73e0c6ce3 100644 (file)
@@ -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"
 
index 68f9061db14a963a83b3c8f1625b8992d2a396b5..919181d375e40371b9f03615c79153bb311c6c62 100644 (file)
@@ -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"
index 06f3c9359b92e202ce1aee52dc4b0e023cbf25b6..dde37fb6e6029d98b8f6b258faddd6b935c9eea1 100644 (file)
@@ -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"
 
index 58352cac807a2dae8ff8187c2490ab43b6fffb35..fb16b66edb0be9915fd5d4156b4c4efa17ad6fb1 100644 (file)
@@ -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"
 
index 07108eb15ebccb77327871c38dfc2eb1f2046a9f..888c277e60f183d73e07216ddb04f50578dd677d 100644 (file)
@@ -6,7 +6,7 @@
 #include <limits.h>
 
 #include "access/gist.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 
 #include "_int.h"
 
index 235db3895727c6e3b92ffa425f21aa050d7758d5..6dae7c91c126f187374f8f2e9ef7e27b4b802368 100644 (file)
@@ -4,7 +4,7 @@
 #include "postgres.h"
 
 #include "access/gist.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 
 #include "_int.h"
 
index 41be68d7ee669db44c2dd65d6eeaecc87b413d28..37cd991694237ce734a8015e74df74d9f3ad46b8 100644 (file)
@@ -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"
 
index 2d89f1aed4c6ff7bbca5c4896b9d3acbbebfc417..83da62018e304e9716693bf993d80b9e201c0778 100644 (file)
@@ -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"
 
index c59925c5750b270eb58b2777708a0aec19b0826d..d524ceaa19e57c3ecf907e7fc4403603f58279a3 100644 (file)
@@ -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);
index 69dc7f71f07069810b01e1484095c89abed97969..07d1dc308bb506b7285edfb749e871a67b6d10e1 100644 (file)
@@ -5,7 +5,8 @@
 
 #include "trgm.h"
 
-#include "access/skey.h"
+#include "access/stratnum.h"
+#include "fmgr.h"
 
 
 typedef struct
index 8e2d5343ae9d28f95942cae5dcbc7dec3418051c..1e6c37d9e1ae4f45157edf4a2deb3362cffe6631 100644 (file)
@@ -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"
 
index d64c4f0864472644bb3e5f9ed0f3667f8cf1e41b..1175649a6d65d4ebc43c51cda20ebed0dac5303e 100644 (file)
@@ -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"
index 9c26e778662fcd25d4f2165b7f197292195199fc..9220b5fccc5f37076cc644d6e3b0f8070b590f60 100644 (file)
@@ -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"
index 9667e397ce470764f36d5353f2428a0bdc173ab2..4cea3f1be18d9d51cff60dff85422e7e80c27dd5 100644 (file)
@@ -18,7 +18,7 @@
 #include "postgres.h"
 
 #include "access/gist.h"
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "utils/geo_decls.h"
 
 
index 6ea0954efb36011450914580e5088d4af1091ef1..88c0df258943492ebeb9558188641387598c8239 100644 (file)
@@ -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"
index e4b8888de8a544b3128b7328157e9cad088372fa..a5f93614df32065bd6c177b199ac44f80c300bb0 100644 (file)
@@ -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"
index 6e563b67e617b4c026faa0c367b0f00382cf10d3..d8d1b06ff0a4f7911be75320f090b20e6df759e7 100644 (file)
@@ -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"
index 72714f474bf3f7a48c9f71fadacb3541dee9cb04..e60d377ccc38db75d476cd5bd7c6ebe6385ebfb9 100644 (file)
@@ -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"
index eb65c970d7061ab1ca7118362a254c64992122a3..80021d57bdc0634a232a7519f85ef32587e28aaa 100644 (file)
@@ -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"
index fdd6baba6c674c8a8a909804af5d6cfc6209f8c6..26e6e1b6512e528a238b1570a298f1a0dae0b0fc 100644 (file)
@@ -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"
index 42183dfecbceee2dec70c8377fa3e1bd26395698..8b25222b93a82e80021c76ddc647089204d59694 100644 (file)
@@ -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"
index c6095167e807180e37ecf81b8e1f359ff7ded533..0775a676d05c1cf5832a6aaca44fdc7c7212c8fa 100644 (file)
@@ -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"
index cd34766c9a79888a3595275c89bc67f29c24332c..d9e49d127e1a0a0cc2308a8b48479d68e75f6e91 100644 (file)
@@ -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
index bc521ed831980bc360368f24404d3e6f6f575df8..2591c81f3d67151ba34953518a92108b46825c14 100644 (file)
@@ -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"
index cd2b8b19a770397ef8d2d8b2576ab4303aa498f8..2e3ee1e8ba7d0d25bfa86ba94ddaa889c58118cd 100644 (file)
 #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
 
 
 /*
index ef841219d0067acbcc850ef2a02aafb7fefd60cb..ddeb18b72f98cc4ab42165c865c8399dbe1ab082 100644 (file)
@@ -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"
index d7b208118ffb1b81b8da7ef82b26c3efa9b02222..9281529d7a1f69f070b30f9a0d87766f8d848982 100644 (file)
@@ -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"
index 828175b7a12afc438ef5ce033b9b1877e560058f..da90ca84f87f44805248bd6f13707760d9ca5220 100644 (file)
@@ -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"
index d610bbc7917892d59372007f7beb9297bab73770..232715c5740dc1b5ddc2c538a31e1aee042610c4 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "postgres.h"
 
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "access/gist.h"
 #include "tsearch/ts_utils.h"
 
index 50261b8bdd5d4686a27e722c1f0317ccaec78ad4..81e559bc2dd260ce76bb546996fc3d41153e94f4 100644 (file)
 #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.
  */
index 2ef349b74836eeba06ab873dde591740796b5b08..9e48efd829274f8c1c9de03a75a081d874ccc1d1 100644 (file)
@@ -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
index eeee1f43d440a797fb93ac2b8ebe429e692a7dc6..76c33bcfc433ae547d94fc00eb87679cdafd47e3 100644 (file)
 #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 (file)
index 0000000..458f4dc
--- /dev/null
@@ -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 */
index 00a3efedc6d3b105f156f4818ba861d47f89f203..487b2b3718868f0c3afd008d7a5e12a63cd9bd22 100644 (file)
@@ -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