aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/gist
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-11-09 21:30:38 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-11-09 21:30:38 +0000
commitc1d62bfd00f4d1ea0647e12947ca1de9fea39b33 (patch)
tree1afdccb5267627182cab94b347730657107ad6eb /src/backend/access/gist
parent723825afebb6de7212fa18882bcc78212d5c1743 (diff)
downloadpostgresql-c1d62bfd00f4d1ea0647e12947ca1de9fea39b33.tar.gz
postgresql-c1d62bfd00f4d1ea0647e12947ca1de9fea39b33.zip
Add operator strategy and comparison-value datatype fields to ScanKey.
Remove the 'strategy map' code, which was a large amount of mechanism that no longer had any use except reverse-mapping from procedure OID to strategy number. Passing the strategy number to the index AM in the first place is simpler and faster. This is a preliminary step in planned support for cross-datatype index operations. I'm committing it now since the ScanKeyEntryInitialize() API change touches quite a lot of files, and I want to commit those changes before the tree drifts under me.
Diffstat (limited to 'src/backend/access/gist')
-rw-r--r--src/backend/access/gist/Makefile4
-rw-r--r--src/backend/access/gist/gistget.c22
-rw-r--r--src/backend/access/gist/gistscan.c14
-rw-r--r--src/backend/access/gist/giststrat.c125
4 files changed, 13 insertions, 152 deletions
diff --git a/src/backend/access/gist/Makefile b/src/backend/access/gist/Makefile
index 7f982d0dfd8..f2c7ddf3a7c 100644
--- a/src/backend/access/gist/Makefile
+++ b/src/backend/access/gist/Makefile
@@ -4,7 +4,7 @@
# Makefile for access/gist
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/access/gist/Makefile,v 1.10 2000/08/31 16:09:31 petere Exp $
+# $Header: /cvsroot/pgsql/src/backend/access/gist/Makefile,v 1.11 2003/11/09 21:30:35 tgl Exp $
#
#-------------------------------------------------------------------------
@@ -12,7 +12,7 @@ subdir = src/backend/access/gist
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
-OBJS = gist.o gistget.o gistscan.o giststrat.o
+OBJS = gist.o gistget.o gistscan.o
all: SUBSYS.o
diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c
index bfa557bb9c6..24168c99269 100644
--- a/src/backend/access/gist/gistget.c
+++ b/src/backend/access/gist/gistget.c
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.36 2003/08/04 02:39:57 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.37 2003/11/09 21:30:35 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -249,26 +249,16 @@ gistindex_keytest(IndexTuple tuple,
IndexTupleSize(tuple) - sizeof(IndexTupleData),
FALSE, isNull);
- if (key[0].sk_flags & SK_COMMUTE)
- {
- test = FunctionCall3(&key[0].sk_func,
- key[0].sk_argument,
- PointerGetDatum(&de),
- ObjectIdGetDatum(key[0].sk_procedure));
- }
- else
- {
- test = FunctionCall3(&key[0].sk_func,
- PointerGetDatum(&de),
- key[0].sk_argument,
- ObjectIdGetDatum(key[0].sk_procedure));
- }
+ test = FunctionCall3(&key[0].sk_func,
+ PointerGetDatum(&de),
+ key[0].sk_argument,
+ Int32GetDatum(key[0].sk_strategy));
if (de.key != datum && !isAttByVal(giststate, key[0].sk_attno - 1))
if (DatumGetPointer(de.key) != NULL)
pfree(DatumGetPointer(de.key));
- if (DatumGetBool(test) == !!(key[0].sk_flags & SK_NEGATE))
+ if (!DatumGetBool(test))
return false;
scanKeySize--;
diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c
index 790048aef38..960d1c2f25b 100644
--- a/src/backend/access/gist/gistscan.c
+++ b/src/backend/access/gist/gistscan.c
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/gist/gistscan.c,v 1.47 2003/08/04 02:39:57 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/gist/gistscan.c,v 1.48 2003/11/09 21:30:35 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -106,17 +106,13 @@ gistrescan(PG_FUNCTION_ARGS)
s->numberOfKeys * sizeof(ScanKeyData));
/*
- * Play games here with the scan key to use the Consistent
- * function for all comparisons: 1) the sk_procedure field will
- * now be used to hold the strategy number 2) the sk_func field
- * will point to the Consistent function
+ * Modify the scan key so that the Consistent function is called
+ * for all comparisons. The original operator is passed to the
+ * Consistent function in the form of its strategy number, which
+ * is available from the sk_strategy field.
*/
for (i = 0; i < s->numberOfKeys; i++)
{
- s->keyData[i].sk_procedure =
- RelationGetGISTStrategy(s->indexRelation,
- s->keyData[i].sk_attno,
- s->keyData[i].sk_procedure);
s->keyData[i].sk_func = p->giststate->consistentFn[s->keyData[i].sk_attno - 1];
}
}
diff --git a/src/backend/access/gist/giststrat.c b/src/backend/access/gist/giststrat.c
deleted file mode 100644
index fe83b5ac799..00000000000
--- a/src/backend/access/gist/giststrat.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * giststrat.c
- * strategy map data for GiSTs.
- *
- *
- * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/gist/Attic/giststrat.c,v 1.21 2003/08/04 02:39:57 momjian Exp $
- *
- *-------------------------------------------------------------------------
- */
-#include "postgres.h"
-
-#include "access/gist.h"
-#include "access/istrat.h"
-
-
-/*
- * Note: negate, commute, and negatecommute all assume that operators are
- * ordered as follows in the strategy map:
- *
- * contains, contained-by
- *
- * The negate, commute, and negatecommute arrays are used by the planner
- * to plan indexed scans over data that appears in the qualificiation in
- * a boolean negation, or whose operands appear in the wrong order. For
- * example, if the operator "<%" means "contains", and the user says
- *
- * where not rel.box <% "(10,10,20,20)"::box
- *
- * the planner can plan an index scan by noting that GiST indices have
- * an operator in their operator class for negating <%.
- *
- * Similarly, if the user says something like
- *
- * where "(10,10,20,20)"::box <% rel.box
- *
- * the planner can see that the GiST index on rel.box has an operator in
- * its opclass for commuting <%, and plan the scan using that operator.
- * This added complexity in the access methods makes the planner a lot easier
- * to write.
- */
-
-/* if a op b, what operator tells us if (not a op b)? */
-static StrategyNumber GISTNegate[GISTNStrategies] = {
- InvalidStrategy,
- InvalidStrategy,
- InvalidStrategy
-};
-
-/* if a op_1 b, what is the operator op_2 such that b op_2 a? */
-static StrategyNumber GISTCommute[GISTNStrategies] = {
- InvalidStrategy,
- InvalidStrategy,
- InvalidStrategy
-};
-
-/* if a op_1 b, what is the operator op_2 such that (b !op_2 a)? */
-static StrategyNumber GISTNegateCommute[GISTNStrategies] = {
- InvalidStrategy,
- InvalidStrategy,
- InvalidStrategy
-};
-
-/*
- * GiSTs do not currently support TermData (see rtree/rtstrat.c for
- * discussion of
- * TermData) -- such logic must be encoded in the user's Consistent function.
- */
-
-static StrategyExpression GISTEvaluationExpressions[GISTNStrategies] = {
- NULL,
- NULL,
- NULL
-};
-
-/*
- * If you were sufficiently attentive to detail, you would go through
- * the ExpressionData pain above for every one of the strategies
- * we defined. I am not. Now we declare the StrategyEvaluationData
- * structure that gets shipped around to help the planner and the access
- * method decide what sort of scan it should do, based on (a) what the
- * user asked for, (b) what operators are defined for a particular opclass,
- * and (c) the reams of information we supplied above.
- *
- * The idea of all of this initialized data is to make life easier on the
- * user when he defines a new operator class to use this access method.
- * By filling in all the data, we let him get away with leaving holes in his
- * operator class, and still let him use the index. The added complexity
- * in the access methods just isn't worth the trouble, though.
- */
-
-static StrategyEvaluationData GISTEvaluationData = {
- GISTNStrategies, /* # of strategies */
- (StrategyTransformMap) GISTNegate, /* how to do (not qual) */
- (StrategyTransformMap) GISTCommute, /* how to swap operands */
- (StrategyTransformMap) GISTNegateCommute, /* how to do both */
- GISTEvaluationExpressions
-};
-
-
-StrategyNumber
-RelationGetGISTStrategy(Relation r,
- AttrNumber attnum,
- RegProcedure proc)
-{
- return RelationGetStrategy(r, attnum, &GISTEvaluationData, proc);
-}
-
-#ifdef NOT_USED
-bool
-RelationInvokeGISTStrategy(Relation r,
- AttrNumber attnum,
- StrategyNumber s,
- Datum left,
- Datum right)
-{
- return (RelationInvokeStrategy(r, &GISTEvaluationData, attnum, s,
- left, right));
-}
-
-#endif