1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-11 10:01:57 +03:00

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.
This commit is contained in:
Tom Lane
2003-11-09 21:30:38 +00:00
parent 723825afeb
commit c1d62bfd00
72 changed files with 950 additions and 2147 deletions

View File

@ -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);
}