diff options
author | Tom Lane | 2003-11-09 21:30:38 +0000 |
---|---|---|
committer | Tom Lane | 2003-11-09 21:30:38 +0000 |
commit | c1d62bfd00f4d1ea0647e12947ca1de9fea39b33 (patch) | |
tree | 1afdccb5267627182cab94b347730657107ad6eb /src/include/access/skey.h | |
parent | 723825afebb6de7212fa18882bcc78212d5c1743 (diff) |
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/include/access/skey.h')
-rw-r--r-- | src/include/access/skey.h | 79 |
1 files changed, 61 insertions, 18 deletions
diff --git a/src/include/access/skey.h b/src/include/access/skey.h index 2e66cfd894a..b7373dd6410 100644 --- a/src/include/access/skey.h +++ b/src/include/access/skey.h @@ -7,10 +7,8 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: skey.h,v 1.22 2003/08/04 02:40:10 momjian Exp $ + * $Id: skey.h,v 1.23 2003/11/09 21:30:37 tgl Exp $ * - * Note: - * Needs more accessor/assignment routines. *------------------------------------------------------------------------- */ #ifndef SKEY_H @@ -20,32 +18,77 @@ #include "fmgr.h" +/* + * Strategy numbers identify the semantics that particular operators have + * with respect to particular operator classes. + */ +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 + * column is the left argument of the operator, if it's a binary operator. + * (The data structure can support unary indexable operators too; in that + * case sk_argument would go unused. This is not currently implemented.) + * + * For an index scan, sk_strategy must be set correctly for the operator. + * When using a ScanKey in a heap scan, sk_strategy is not used and may be + * set to InvalidStrategy. + * + * Note: in some places, ScanKeys are used as a convenient representation + * for the invocation of an access method support procedure. In this case + * sk_strategy is not meaningful, and sk_func may refer to a function that + * returns something other than boolean. + */ typedef struct ScanKeyData { - bits16 sk_flags; /* flags */ - AttrNumber sk_attno; /* domain number */ - RegProcedure sk_procedure; /* procedure OID */ - FmgrInfo sk_func; /* fmgr call info for procedure */ + int sk_flags; /* flags, see below */ + AttrNumber sk_attno; /* table or index column number */ + StrategyNumber sk_strategy; /* operator strategy number */ + FmgrInfo sk_func; /* lookup info for function to call */ Datum sk_argument; /* data to compare */ + Oid sk_argtype; /* datatype of sk_argument */ } ScanKeyData; typedef ScanKeyData *ScanKey; -/* ScanKeyData flags */ -#define SK_ISNULL 0x1 /* sk_argument is NULL */ -#define SK_UNARY 0x2 /* unary function (currently unsupported) */ -#define SK_NEGATE 0x4 /* negate function result */ -#define SK_COMMUTE 0x8 /* commute function (not fully supported) */ +/* ScanKeyData sk_flags */ +#define SK_ISNULL 0x0001 /* sk_argument is NULL */ +#define SK_UNARY 0x0002 /* unary operator (currently unsupported) */ /* * prototypes for functions in access/common/scankey.c */ -extern void ScanKeyEntrySetIllegal(ScanKey entry); -extern void ScanKeyEntryInitialize(ScanKey entry, bits16 flags, - AttrNumber attributeNumber, RegProcedure procedure, Datum argument); -extern void ScanKeyEntryInitializeWithInfo(ScanKey entry, bits16 flags, - AttrNumber attributeNumber, FmgrInfo *finfo, - MemoryContext mcxt, Datum argument); +extern void ScanKeyEntryInitialize(ScanKey entry, + int flags, + AttrNumber attributeNumber, + StrategyNumber strategy, + RegProcedure procedure, + Datum argument, + Oid argtype); +extern void ScanKeyEntryInitializeWithInfo(ScanKey entry, + int flags, + AttrNumber attributeNumber, + StrategyNumber strategy, + FmgrInfo *finfo, + Datum argument, + Oid argtype); #endif /* SKEY_H */ |