best place for "rtree" strategy numbers
In Emre Hasegeli's patch for range/inet/geometry opclasses for BRIN, he
chose to move strategy numbers from gist.h to a more central place. He
chose skey.h because that's where btree strategy numbers are defined,
but I'm not sure I agree with that choice.
It's been clear for a while now that these numbers are not gist-only
anyway; spgist and GIN also make use of them, and now brin inclusion
opclass infrastructure also wants to use the same numbers. This is the
reason for a central place, anyway. However, we find datatype specific
definitions in places such as rangetypes.h:
/* 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
[ .. etc .. ]
and network_gist.c:
/*
* Operator strategy numbers used in the GiST inet_ops opclass
*/
#define INETSTRAT_OVERLAPS 3
#define INETSTRAT_EQ 18
#define INETSTRAT_NE 19
[ .. etc .. ]
Obviously, the expectation is that the numbers are not needed outside
the opclass implementation itself. I think that's a lost cause, mainly
because we want to have consistent operator names across datatypes.
Therefore I would like to move those numbers elsewhere. Maybe we could
have a new file which would be used only for strategy numbers, such as
src/include/access/stratnum.h, and we would have something like this,
and redefine the ones elsewhere to reference those. For instance,
rangetypes.h could look like this:
/* 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 RTLeftStrategyNumber
#define RANGESTRAT_OVERLEFT RTOverLeftStrategyNumber
#define RANGESTRAT_OVERLAPS RTOverlapStrategyNumber
and so on. (I am a bit hesitant about using the "RT" prefix in those
symbols, since the set has grown quite a bit from R-Tree alone. But I
don't have any ideas on what else to use either.)
I can, of course, just leave these files well enough alone and just rely
on the numbers not changing (which surely they won't anyway) and
remaining consistent with numbers used in new opclasses (which surely
they will lest they be born inconsistent with existing ones).
Opinions?
--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
In Emre Hasegeli's patch for range/inet/geometry opclasses for BRIN, he
chose to move strategy numbers from gist.h to a more central place. He
chose skey.h because that's where btree strategy numbers are defined,
but I'm not sure I agree with that choice.
Yeah, putting those in skey.h was probably not such a great idea.
(IIRC, they didn't use to be there ... it's probably my fault that
they're there now.)
Therefore I would like to move those numbers elsewhere. Maybe we could
have a new file which would be used only for strategy numbers, such as
src/include/access/stratnum.h, and we would have something like this,
and redefine the ones elsewhere to reference those.
+1
I can, of course, just leave these files well enough alone and just rely
on the numbers not changing (which surely they won't anyway) and
remaining consistent with numbers used in new opclasses (which surely
they will lest they be born inconsistent with existing ones).
Yeah, we do have checks in opr_sanity which will complain if inconsistent
strategy numbers are used for similarly-named operators. That's a pretty
weak test though, and operator names aren't exactly the right thing to
check anyway. I'd be good with pushing all of that stuff to a new central
header.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Tom Lane wrote:
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
I can, of course, just leave these files well enough alone and just rely
on the numbers not changing (which surely they won't anyway) and
remaining consistent with numbers used in new opclasses (which surely
they will lest they be born inconsistent with existing ones).Yeah, we do have checks in opr_sanity which will complain if inconsistent
strategy numbers are used for similarly-named operators. That's a pretty
weak test though, and operator names aren't exactly the right thing to
check anyway. I'd be good with pushing all of that stuff to a new central
header.
So here's a patch for this.
--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:
stratnum.patchtext/x-diff; charset=us-asciiDownload
commit 912acf2a0e622fec0837ff6773fc95621e216fa5
Author: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Fri May 15 01:26:12 2015 -0300
Move strategy number definitions to their own file
diff --git a/contrib/btree_gin/btree_gin.c b/contrib/btree_gin/btree_gin.c
index 1a5bb3c..6e3bf17 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 b9ccad9..113c663 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 68f9061..919181d 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 06f3c93..dde37fb 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 58352ca..fb16b66 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/_intbig_gist.c b/contrib/intarray/_intbig_gist.c
index 235db38..6dae7c91 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 41be68d..37cd991 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 2d89f1a..83da620 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 c59925c..d524cea 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 69dc7f7..07d1dc3 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 8e2d534..1e6c37d 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/gin/ginarrayproc.c b/src/backend/access/gin/ginarrayproc.c
index 9c26e77..9220b5f 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 9d21e3f..c5aaeab 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/bootstrap/bootparse.y b/src/backend/bootstrap/bootparse.y
index 6e563b6..d8d1b06 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 72714f4..e60d377 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 eb65c97..80021d5 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 fdd6bab..26e6e1b 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 42183df..8b25222 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 c809237..454d9a0 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 "foreign/fdwapi.h"
diff --git a/src/backend/utils/adt/jsonb_gin.c b/src/backend/utils/adt/jsonb_gin.c
index bc521ed..2591c81 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 cd2b8b1..958e1e2 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 RTContainsNotEqualStrategyNumber
+#define INETSTRAT_SUBEQ RTSubOrEqualStrategyNumber
+#define INETSTRAT_SUP RTContainedByNotEqualStrategyNumber
+#define INETSTRAT_SUPEQ RTSuperOrEqualStrategyNumber
/*
diff --git a/src/backend/utils/adt/rangetypes_gist.c b/src/backend/utils/adt/rangetypes_gist.c
index ef84121..ddeb18b 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 d7b2081..9281529 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 828175b..da90ca8 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 d610bbc..232715c 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/skey.h b/src/include/access/skey.h
index eeee1f4..76c33bc 100644
--- a/src/include/access/skey.h
+++ b/src/include/access/skey.h
@@ -15,32 +15,11 @@
#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
* ScanKeys, the comparison conditions are implicitly ANDed. The index
diff --git a/src/include/access/stratnum.h b/src/include/access/stratnum.h
new file mode 100644
index 0000000..ac0d2e7
--- /dev/null
+++ b/src/include/access/stratnum.h
@@ -0,0 +1,74 @@
+/*-------------------------------------------------------------------------
+ *
+ * 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, GIN 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 RTContainsNotEqualStrategyNumber 24 /* for inet >> */
+#define RTSubOrEqualStrategyNumber 25 /* for inet <<= */
+#define RTContainedByNotEqualStrategyNumber 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 00a3efe..487b2b3 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
Alvaro Herrera <alvaro.herrera@2ndquadrant.com> writes:
So here's a patch for this.
Looks reasonable to me (though I only eyeballed it, not tested).
Do we want to push this into 9.5, or wait for 9.6?
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Tom Lane wrote:
Alvaro Herrera <alvaro.herrera@2ndquadrant.com> writes:
So here's a patch for this.
Looks reasonable to me (though I only eyeballed it, not tested).
Do we want to push this into 9.5, or wait for 9.6?
My intention is to push this now, before pushing brin inclusion.
--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Adjacent strategy number of range types don't match the central
definitions. Attached patch changes it.
Also, maybe it is better to include stratnum.h on rangetypes.h and
inet.h rather than the .c files as the definitions are used in the
headers. I wouldn't re-define them, anyway. Two definitions just to
say 3 is too much for my taste.
Attachments:
change-range-adjacent-strategy-number.patchapplication/octet-stream; name=change-range-adjacent-strategy-number.patchDownload
diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h
index 657ec07..c3171ae 100644
--- a/src/include/catalog/pg_amop.h
+++ b/src/include/catalog/pg_amop.h
@@ -745,24 +745,24 @@ DATA(insert ( 3901 3831 3831 5 s 3887 403 0 ));
DATA(insert ( 3903 3831 3831 1 s 3882 405 0 ));
/*
* GiST range_ops
*/
DATA(insert ( 3919 3831 3831 1 s 3893 783 0 ));
DATA(insert ( 3919 3831 3831 2 s 3895 783 0 ));
DATA(insert ( 3919 3831 3831 3 s 3888 783 0 ));
DATA(insert ( 3919 3831 3831 4 s 3896 783 0 ));
DATA(insert ( 3919 3831 3831 5 s 3894 783 0 ));
-DATA(insert ( 3919 3831 3831 6 s 3897 783 0 ));
DATA(insert ( 3919 3831 3831 7 s 3890 783 0 ));
DATA(insert ( 3919 3831 3831 8 s 3892 783 0 ));
DATA(insert ( 3919 3831 2283 16 s 3889 783 0 ));
+DATA(insert ( 3919 3831 3831 17 s 3897 783 0 ));
DATA(insert ( 3919 3831 3831 18 s 3882 783 0 ));
/*
* SP-GiST quad_point_ops
*/
DATA(insert ( 4015 600 600 11 s 506 4000 0 ));
DATA(insert ( 4015 600 600 1 s 507 4000 0 ));
DATA(insert ( 4015 600 600 5 s 508 4000 0 ));
DATA(insert ( 4015 600 600 10 s 509 4000 0 ));
DATA(insert ( 4015 600 600 6 s 510 4000 0 ));
@@ -819,24 +819,24 @@ DATA(insert ( 4036 3802 1009 11 s 3249 2742 0 ));
DATA(insert ( 4037 3802 3802 7 s 3246 2742 0 ));
/*
* SP-GiST range_ops
*/
DATA(insert ( 3474 3831 3831 1 s 3893 4000 0 ));
DATA(insert ( 3474 3831 3831 2 s 3895 4000 0 ));
DATA(insert ( 3474 3831 3831 3 s 3888 4000 0 ));
DATA(insert ( 3474 3831 3831 4 s 3896 4000 0 ));
DATA(insert ( 3474 3831 3831 5 s 3894 4000 0 ));
-DATA(insert ( 3474 3831 3831 6 s 3897 4000 0 ));
DATA(insert ( 3474 3831 3831 7 s 3890 4000 0 ));
DATA(insert ( 3474 3831 3831 8 s 3892 4000 0 ));
DATA(insert ( 3474 3831 2283 16 s 3889 4000 0 ));
+DATA(insert ( 3474 3831 3831 17 s 3897 4000 0 ));
DATA(insert ( 3474 3831 3831 18 s 3882 4000 0 ));
/*
* GiST inet_ops
*/
DATA(insert ( 3550 869 869 3 s 3552 783 0 ));
DATA(insert ( 3550 869 869 18 s 1201 783 0 ));
DATA(insert ( 3550 869 869 19 s 1202 783 0 ));
DATA(insert ( 3550 869 869 20 s 1203 783 0 ));
DATA(insert ( 3550 869 869 21 s 1204 783 0 ));
diff --git a/src/include/utils/rangetypes.h b/src/include/utils/rangetypes.h
index 487b2b3..362e0c4 100644
--- a/src/include/utils/rangetypes.h
+++ b/src/include/utils/rangetypes.h
@@ -75,24 +75,24 @@ typedef struct
#define PG_GETARG_RANGE_COPY(n) DatumGetRangeTypeCopy(PG_GETARG_DATUM(n))
#define PG_RETURN_RANGE(x) return RangeTypeGetDatum(x)
/* 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 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_ADJACENT RTAdjacentStrategyNumber
#define RANGESTRAT_EQ RTEqualStrategyNumber
/*
* prototypes for functions defined in rangetypes.c
*/
/* I/O */
extern Datum range_in(PG_FUNCTION_ARGS);
extern Datum range_out(PG_FUNCTION_ARGS);
extern Datum range_recv(PG_FUNCTION_ARGS);
diff --git a/src/test/regress/expected/opr_sanity.out b/src/test/regress/expected/opr_sanity.out
index b889123..05f8312 100644
--- a/src/test/regress/expected/opr_sanity.out
+++ b/src/test/regress/expected/opr_sanity.out
@@ -1616,34 +1616,34 @@ ORDER BY 1, 2, 3;
403 | 5 | *>
403 | 5 | >
403 | 5 | ~>~
405 | 1 | =
783 | 1 | <<
783 | 1 | @@
783 | 2 | &<
783 | 3 | &&
783 | 4 | &>
783 | 5 | >>
- 783 | 6 | -|-
783 | 6 | ~=
783 | 7 | @>
783 | 8 | <@
783 | 9 | &<|
783 | 10 | <<|
783 | 10 | <^
783 | 11 | >^
783 | 11 | |>>
783 | 12 | |&>
783 | 13 | ~
783 | 14 | @
783 | 15 | <->
783 | 16 | @>
+ 783 | 17 | -|-
783 | 18 | =
783 | 19 | <>
783 | 20 | <
783 | 21 | <=
783 | 22 | >
783 | 23 | >=
783 | 24 | <<
783 | 25 | <<=
783 | 26 | >>
783 | 27 | >>=
@@ -1691,31 +1691,31 @@ ORDER BY 1, 2, 3;
4000 | 1 | <<
4000 | 1 | ~<~
4000 | 2 | &<
4000 | 2 | ~<=~
4000 | 3 | &&
4000 | 3 | =
4000 | 4 | &>
4000 | 4 | ~>=~
4000 | 5 | >>
4000 | 5 | ~>~
- 4000 | 6 | -|-
4000 | 6 | ~=
4000 | 7 | @>
4000 | 8 | <@
4000 | 10 | <^
4000 | 11 | <
4000 | 11 | >^
4000 | 12 | <=
4000 | 14 | >=
4000 | 15 | >
4000 | 16 | @>
+ 4000 | 17 | -|-
4000 | 18 | =
(108 rows)
-- Check that all opclass search operators have selectivity estimators.
-- This is not absolutely required, but it seems a reasonable thing
-- to insist on for all standard datatypes.
SELECT p1.amopfamily, p1.amopopr, p2.oid, p2.oprname
FROM pg_amop AS p1, pg_operator AS p2
WHERE p1.amopopr = p2.oid AND p1.amoppurpose = 's' AND
(p2.oprrest = 0 OR p2.oprjoin = 0);