1 /*-------------------------------------------------------------------------
4 * scan key support code
6 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
13 *-------------------------------------------------------------------------
17 #include "access/skey.h"
21 * ScanKeyEntryInitialize
22 * Initializes a scan key entry given all the field values.
23 * The target procedure is specified by OID (but can be invalid
24 * if SK_SEARCHNULL is set).
26 * Note: CurrentMemoryContext at call should be as long-lived as the ScanKey
27 * itself, because that's what will be used for any subsidiary info attached
28 * to the ScanKey's FmgrInfo record.
31 ScanKeyEntryInitialize(ScanKey entry
,
33 AttrNumber attributeNumber
,
34 StrategyNumber strategy
,
36 RegProcedure procedure
,
39 entry
->sk_flags
= flags
;
40 entry
->sk_attno
= attributeNumber
;
41 entry
->sk_strategy
= strategy
;
42 entry
->sk_subtype
= subtype
;
43 entry
->sk_argument
= argument
;
44 if (RegProcedureIsValid(procedure
))
45 fmgr_info(procedure
, &entry
->sk_func
);
48 Assert(flags
& SK_SEARCHNULL
);
49 MemSet(&entry
->sk_func
, 0, sizeof(entry
->sk_func
));
55 * Shorthand version of ScanKeyEntryInitialize: flags and subtype
56 * are assumed to be zero (the usual value).
58 * This is the recommended version for hardwired lookups in system catalogs.
59 * It cannot handle NULL arguments, unary operators, or nondefault operators,
60 * but we need none of those features for most hardwired lookups.
62 * Note: CurrentMemoryContext at call should be as long-lived as the ScanKey
63 * itself, because that's what will be used for any subsidiary info attached
64 * to the ScanKey's FmgrInfo record.
67 ScanKeyInit(ScanKey entry
,
68 AttrNumber attributeNumber
,
69 StrategyNumber strategy
,
70 RegProcedure procedure
,
74 entry
->sk_attno
= attributeNumber
;
75 entry
->sk_strategy
= strategy
;
76 entry
->sk_subtype
= InvalidOid
;
77 entry
->sk_argument
= argument
;
78 fmgr_info(procedure
, &entry
->sk_func
);
82 * ScanKeyEntryInitializeWithInfo
83 * Initializes a scan key entry using an already-completed FmgrInfo
84 * function lookup record.
86 * Note: CurrentMemoryContext at call should be as long-lived as the ScanKey
87 * itself, because that's what will be used for any subsidiary info attached
88 * to the ScanKey's FmgrInfo record.
91 ScanKeyEntryInitializeWithInfo(ScanKey entry
,
93 AttrNumber attributeNumber
,
94 StrategyNumber strategy
,
99 entry
->sk_flags
= flags
;
100 entry
->sk_attno
= attributeNumber
;
101 entry
->sk_strategy
= strategy
;
102 entry
->sk_subtype
= subtype
;
103 entry
->sk_argument
= argument
;
104 fmgr_info_copy(&entry
->sk_func
, finfo
, CurrentMemoryContext
);