aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gistget.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-11-12 21:15:59 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-11-12 21:15:59 +0000
commitfa5c8a055a02e44f446e4593e397c33a572c4d67 (patch)
tree9c0a7ded5a88c082c28dbe2b431660813abd72b8 /src/backend/access/gist/gistget.c
parent49f98fa833407b4e4252e42522e640ec8a0d08b2 (diff)
downloadpostgresql-fa5c8a055a02e44f446e4593e397c33a572c4d67.tar.gz
postgresql-fa5c8a055a02e44f446e4593e397c33a572c4d67.zip
Cross-data-type comparisons are now indexable by btrees, pursuant to my
pghackers proposal of 8-Nov. All the existing cross-type comparison operators (int2/int4/int8 and float4/float8) have appropriate support. The original proposal of storing the right-hand-side datatype as part of the primary key for pg_amop and pg_amproc got modified a bit in the event; it is easier to store zero as the 'default' case and only store a nonzero when the operator is actually cross-type. Along the way, remove the long-since-defunct bigbox_ops operator class.
Diffstat (limited to 'src/backend/access/gist/gistget.c')
-rw-r--r--src/backend/access/gist/gistget.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c
index 24168c99269..5db69a6b40a 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.37 2003/11/09 21:30:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.38 2003/11/12 21:15:46 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -221,40 +221,50 @@ gistindex_keytest(IndexTuple tuple,
Page p,
OffsetNumber offset)
{
- bool isNull;
- Datum datum;
- Datum test;
- GISTENTRY de;
-
IncrIndexProcessed();
while (scanKeySize > 0)
{
+ Datum datum;
+ bool isNull;
+ Datum test;
+ GISTENTRY de;
+
datum = index_getattr(tuple,
- key[0].sk_attno,
+ key->sk_attno,
giststate->tupdesc,
&isNull);
+ /* is the index entry NULL? */
if (isNull)
{
/* XXX eventually should check if SK_ISNULL */
return false;
}
-
-/* this code from backend/access/common/indexvalid.c. But why and what???
- if (key[0].sk_flags & SK_ISNULL)
+ /* is the compared-to datum NULL? */
+ if (key->sk_flags & SK_ISNULL)
return false;
-*/
- gistdentryinit(giststate, key[0].sk_attno - 1, &de,
+
+ gistdentryinit(giststate, key->sk_attno - 1, &de,
datum, r, p, offset,
IndexTupleSize(tuple) - sizeof(IndexTupleData),
FALSE, isNull);
- test = FunctionCall3(&key[0].sk_func,
+ /*
+ * Call the Consistent function to evaluate the test. The arguments
+ * are the index datum (as a GISTENTRY*), the comparison datum, and
+ * the comparison operator's strategy number and subtype from pg_amop.
+ *
+ * (Presently there's no need to pass the subtype since it'll always
+ * be zero, but might as well pass it for possible future use.)
+ */
+ test = FunctionCall4(&key->sk_func,
PointerGetDatum(&de),
- key[0].sk_argument,
- Int32GetDatum(key[0].sk_strategy));
+ key->sk_argument,
+ Int32GetDatum(key->sk_strategy),
+ ObjectIdGetDatum(key->sk_subtype));
- if (de.key != datum && !isAttByVal(giststate, key[0].sk_attno - 1))
+ /* if index datum had to be decompressed, free it */
+ if (de.key != datum && !isAttByVal(giststate, key->sk_attno - 1))
if (DatumGetPointer(de.key) != NULL)
pfree(DatumGetPointer(de.key));
@@ -264,6 +274,7 @@ gistindex_keytest(IndexTuple tuple,
scanKeySize--;
key++;
}
+
return true;
}