1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* scan.c
|
1997-09-07 07:04:48 +02:00
|
|
|
* scan direction and key code
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2003-08-04 04:40:20 +02:00
|
|
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2003-08-04 04:40:20 +02:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.22 2003/08/04 02:39:56 momjian Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1996-10-19 06:51:44 +02:00
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "postgres.h"
|
1996-10-19 06:51:44 +02:00
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "access/skey.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/*
|
1999-05-25 18:15:34 +02:00
|
|
|
* ScanKeyEntryIsLegal
|
1997-09-07 07:04:48 +02:00
|
|
|
* True iff the scan key entry is legal.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
#define ScanKeyEntryIsLegal(entry) \
|
1998-06-15 20:40:05 +02:00
|
|
|
( \
|
|
|
|
AssertMacro(PointerIsValid(entry)), \
|
|
|
|
AttributeNumberIsValid((entry)->sk_attno) \
|
|
|
|
)
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/*
|
1999-05-25 18:15:34 +02:00
|
|
|
* ScanKeyEntrySetIllegal
|
1997-09-07 07:04:48 +02:00
|
|
|
* Marks a scan key entry as illegal.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ScanKeyEntrySetIllegal(ScanKey entry)
|
|
|
|
{
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
Assert(PointerIsValid(entry));
|
|
|
|
|
|
|
|
entry->sk_flags = 0; /* just in case... */
|
|
|
|
entry->sk_attno = InvalidAttrNumber;
|
|
|
|
entry->sk_procedure = 0; /* should be InvalidRegProcedure */
|
2001-06-01 04:41:36 +02:00
|
|
|
entry->sk_func.fn_oid = InvalidOid;
|
|
|
|
entry->sk_argument = (Datum) 0;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-05-25 18:15:34 +02:00
|
|
|
* ScanKeyEntryInitialize
|
2001-06-01 04:41:36 +02:00
|
|
|
* Initializes a scan key entry.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
* Note:
|
1997-09-07 07:04:48 +02:00
|
|
|
* Assumes the scan key entry is valid.
|
|
|
|
* Assumes the intialized scan key entry will be legal.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ScanKeyEntryInitialize(ScanKey entry,
|
1997-09-07 07:04:48 +02:00
|
|
|
bits16 flags,
|
|
|
|
AttrNumber attributeNumber,
|
|
|
|
RegProcedure procedure,
|
|
|
|
Datum argument)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
Assert(PointerIsValid(entry));
|
|
|
|
|
|
|
|
entry->sk_flags = flags;
|
|
|
|
entry->sk_attno = attributeNumber;
|
|
|
|
entry->sk_procedure = procedure;
|
|
|
|
entry->sk_argument = argument;
|
1998-01-15 20:46:37 +01:00
|
|
|
fmgr_info(procedure, &entry->sk_func);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
Assert(ScanKeyEntryIsLegal(entry));
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
2001-10-07 01:21:45 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ScanKeyEntryInitializeWithInfo
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ScanKeyEntryInitializeWithInfo(ScanKey entry,
|
|
|
|
bits16 flags,
|
|
|
|
AttrNumber attributeNumber,
|
|
|
|
FmgrInfo *finfo,
|
|
|
|
MemoryContext mcxt,
|
|
|
|
Datum argument)
|
|
|
|
{
|
|
|
|
Assert(PointerIsValid(entry));
|
|
|
|
Assert(RegProcedureIsValid(finfo->fn_oid));
|
|
|
|
|
|
|
|
entry->sk_flags = flags;
|
|
|
|
entry->sk_attno = attributeNumber;
|
|
|
|
entry->sk_procedure = finfo->fn_oid;
|
|
|
|
entry->sk_argument = argument;
|
|
|
|
fmgr_info_copy(&entry->sk_func, finfo, mcxt);
|
|
|
|
|
|
|
|
Assert(ScanKeyEntryIsLegal(entry));
|
|
|
|
}
|