~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/backend/access/common/scankey.c

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * scankey.c
 
4
 *        scan key support code
 
5
 *
 
6
 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
 
7
 * Portions Copyright (c) 1994, Regents of the University of California
 
8
 *
 
9
 *
 
10
 * IDENTIFICATION
 
11
 *        $PostgreSQL: pgsql/src/backend/access/common/scankey.c,v 1.27 2004-12-31 21:59:07 pgsql Exp $
 
12
 *
 
13
 *-------------------------------------------------------------------------
 
14
 */
 
15
#include "postgres.h"
 
16
 
 
17
#include "access/skey.h"
 
18
 
 
19
 
 
20
/*
 
21
 * ScanKeyEntryInitialize
 
22
 *              Initializes a scan key entry given all the field values.
 
23
 *              The target procedure is specified by OID.
 
24
 *
 
25
 * Note: CurrentMemoryContext at call should be as long-lived as the ScanKey
 
26
 * itself, because that's what will be used for any subsidiary info attached
 
27
 * to the ScanKey's FmgrInfo record.
 
28
 */
 
29
void
 
30
ScanKeyEntryInitialize(ScanKey entry,
 
31
                                           int flags,
 
32
                                           AttrNumber attributeNumber,
 
33
                                           StrategyNumber strategy,
 
34
                                           Oid subtype,
 
35
                                           RegProcedure procedure,
 
36
                                           Datum argument)
 
37
{
 
38
        entry->sk_flags = flags;
 
39
        entry->sk_attno = attributeNumber;
 
40
        entry->sk_strategy = strategy;
 
41
        entry->sk_subtype = subtype;
 
42
        entry->sk_argument = argument;
 
43
        fmgr_info(procedure, &entry->sk_func);
 
44
}
 
45
 
 
46
/*
 
47
 * ScanKeyInit
 
48
 *              Shorthand version of ScanKeyEntryInitialize: flags and subtype
 
49
 *              are assumed to be zero (the usual value).
 
50
 *
 
51
 * This is the recommended version for hardwired lookups in system catalogs.
 
52
 * It cannot handle NULL arguments, unary operators, or nondefault operators,
 
53
 * but we need none of those features for most hardwired lookups.
 
54
 *
 
55
 * Note: CurrentMemoryContext at call should be as long-lived as the ScanKey
 
56
 * itself, because that's what will be used for any subsidiary info attached
 
57
 * to the ScanKey's FmgrInfo record.
 
58
 */
 
59
void
 
60
ScanKeyInit(ScanKey entry,
 
61
                        AttrNumber attributeNumber,
 
62
                        StrategyNumber strategy,
 
63
                        RegProcedure procedure,
 
64
                        Datum argument)
 
65
{
 
66
        entry->sk_flags = 0;
 
67
        entry->sk_attno = attributeNumber;
 
68
        entry->sk_strategy = strategy;
 
69
        entry->sk_subtype = InvalidOid;
 
70
        entry->sk_argument = argument;
 
71
        fmgr_info(procedure, &entry->sk_func);
 
72
}
 
73
 
 
74
/*
 
75
 * ScanKeyEntryInitializeWithInfo
 
76
 *              Initializes a scan key entry using an already-completed FmgrInfo
 
77
 *              function lookup record.
 
78
 *
 
79
 * Note: CurrentMemoryContext at call should be as long-lived as the ScanKey
 
80
 * itself, because that's what will be used for any subsidiary info attached
 
81
 * to the ScanKey's FmgrInfo record.
 
82
 */
 
83
void
 
84
ScanKeyEntryInitializeWithInfo(ScanKey entry,
 
85
                                                           int flags,
 
86
                                                           AttrNumber attributeNumber,
 
87
                                                           StrategyNumber strategy,
 
88
                                                           Oid subtype,
 
89
                                                           FmgrInfo *finfo,
 
90
                                                           Datum argument)
 
91
{
 
92
        entry->sk_flags = flags;
 
93
        entry->sk_attno = attributeNumber;
 
94
        entry->sk_strategy = strategy;
 
95
        entry->sk_subtype = subtype;
 
96
        entry->sk_argument = argument;
 
97
        fmgr_info_copy(&entry->sk_func, finfo, CurrentMemoryContext);
 
98
}