aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/common/scankey.c
blob: e4940a61ca371f0d2f1f4d774521e92759ebca65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*-------------------------------------------------------------------------
 *
 * scan.c--
 *    scan direction and key code
 *
 * Copyright (c) 1994, Regents of the University of California
 *
 *
 * IDENTIFICATION
 *    $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.6 1996/11/01 09:41:40 scrappy Exp $
 *
 *-------------------------------------------------------------------------
 */

#include "postgres.h"

#include "fmgr.h"
#include "access/attnum.h"

#include "access/skey.h"

/*
 * ScanKeyEntryIsLegal --
 *	True iff the scan key entry is legal.
 */
#define ScanKeyEntryIsLegal(entry) \
    ((bool) (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 */
}

/*
 * ScanKeyEntryInitialize --
 *	Initializes an scan key entry.
 *
 * Note:
 *	Assumes the scan key entry is valid.
 *	Assumes the intialized scan key entry will be legal.
 */
void
ScanKeyEntryInitialize(ScanKey entry,
		       bits16 flags,
		       AttrNumber attributeNumber,
		       RegProcedure procedure,
		       Datum argument)
{
    Assert(PointerIsValid(entry));
    
    entry->sk_flags = flags;
    entry->sk_attno = attributeNumber;
    entry->sk_procedure = procedure;
    entry->sk_argument = argument;
    fmgr_info(procedure, &entry->sk_func, &entry->sk_nargs);
    
    Assert(ScanKeyEntryIsLegal(entry));
}