diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-11-09 21:30:38 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-11-09 21:30:38 +0000 |
commit | c1d62bfd00f4d1ea0647e12947ca1de9fea39b33 (patch) | |
tree | 1afdccb5267627182cab94b347730657107ad6eb /src/backend/access/common/scankey.c | |
parent | 723825afebb6de7212fa18882bcc78212d5c1743 (diff) | |
download | postgresql-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/common/scankey.c')
-rw-r--r-- | src/backend/access/common/scankey.c | 77 |
1 files changed, 24 insertions, 53 deletions
diff --git a/src/backend/access/common/scankey.c b/src/backend/access/common/scankey.c index f79b2c71432..93741cbb849 100644 --- a/src/backend/access/common/scankey.c +++ b/src/backend/access/common/scankey.c @@ -1,73 +1,46 @@ /*------------------------------------------------------------------------- * - * scan.c - * scan direction and key code + * scankey.c + * scan key support code * * 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/common/scankey.c,v 1.22 2003/08/04 02:39:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.23 2003/11/09 21:30:35 tgl Exp $ * *------------------------------------------------------------------------- */ - #include "postgres.h" #include "access/skey.h" -/* - * ScanKeyEntryIsLegal - * True iff the scan key entry is legal. - */ -#define ScanKeyEntryIsLegal(entry) \ -( \ - AssertMacro(PointerIsValid(entry)), \ - AttributeNumberIsValid((entry)->sk_attno) \ -) - -/* - * ScanKeyEntrySetIllegal - * Marks a scan key entry as illegal. - */ -void -ScanKeyEntrySetIllegal(ScanKey entry) -{ - - Assert(PointerIsValid(entry)); - - entry->sk_flags = 0; /* just in case... */ - entry->sk_attno = InvalidAttrNumber; - entry->sk_procedure = 0; /* should be InvalidRegProcedure */ - entry->sk_func.fn_oid = InvalidOid; - entry->sk_argument = (Datum) 0; -} /* * ScanKeyEntryInitialize - * Initializes a scan key entry. + * Initializes a scan key entry given all the field values. + * The target procedure is specified by OID. * - * Note: - * Assumes the scan key entry is valid. - * Assumes the intialized scan key entry will be legal. + * Note: CurrentMemoryContext at call should be as long-lived as the ScanKey + * itself, because that's what will be used for any subsidiary info attached + * to the ScanKey's FmgrInfo record. */ void ScanKeyEntryInitialize(ScanKey entry, - bits16 flags, + int flags, AttrNumber attributeNumber, + StrategyNumber strategy, RegProcedure procedure, - Datum argument) + Datum argument, + Oid argtype) { - Assert(PointerIsValid(entry)); - entry->sk_flags = flags; entry->sk_attno = attributeNumber; - entry->sk_procedure = procedure; + entry->sk_strategy = strategy; entry->sk_argument = argument; + entry->sk_argtype = argtype; fmgr_info(procedure, &entry->sk_func); - - Assert(ScanKeyEntryIsLegal(entry)); } /* @@ -75,25 +48,23 @@ ScanKeyEntryInitialize(ScanKey entry, * Initializes a scan key entry using an already-completed FmgrInfo * function lookup record. * - * mcxt is the memory context holding the scan key; it'll be used for - * any subsidiary info attached to the scankey's FmgrInfo record. + * Note: CurrentMemoryContext at call should be as long-lived as the ScanKey + * itself, because that's what will be used for any subsidiary info attached + * to the ScanKey's FmgrInfo record. */ void ScanKeyEntryInitializeWithInfo(ScanKey entry, - bits16 flags, + int flags, AttrNumber attributeNumber, + StrategyNumber strategy, FmgrInfo *finfo, - MemoryContext mcxt, - Datum argument) + Datum argument, + Oid argtype) { - Assert(PointerIsValid(entry)); - Assert(RegProcedureIsValid(finfo->fn_oid)); - entry->sk_flags = flags; entry->sk_attno = attributeNumber; - entry->sk_procedure = finfo->fn_oid; + entry->sk_strategy = strategy; entry->sk_argument = argument; - fmgr_info_copy(&entry->sk_func, finfo, mcxt); - - Assert(ScanKeyEntryIsLegal(entry)); + entry->sk_argtype = argtype; + fmgr_info_copy(&entry->sk_func, finfo, CurrentMemoryContext); } |