|
1 | 1 | /*-------------------------------------------------------------------------
|
2 | 2 | *
|
3 |
| - * scan.c |
4 |
| - * scan direction and key code |
| 3 | + * scankey.c |
| 4 | + * scan key support code |
5 | 5 | *
|
6 | 6 | * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
7 | 7 | * Portions Copyright (c) 1994, Regents of the University of California
|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.22 2003/08/04 02:39:56 momjian Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.23 2003/11/09 21:30:35 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
15 |
| - |
16 | 15 | #include "postgres.h"
|
17 | 16 |
|
18 | 17 | #include "access/skey.h"
|
19 | 18 |
|
20 |
| -/* |
21 |
| - * ScanKeyEntryIsLegal |
22 |
| - * True iff the scan key entry is legal. |
23 |
| - */ |
24 |
| -#define ScanKeyEntryIsLegal(entry) \ |
25 |
| -( \ |
26 |
| - AssertMacro(PointerIsValid(entry)), \ |
27 |
| - AttributeNumberIsValid((entry)->sk_attno) \ |
28 |
| -) |
29 |
| - |
30 |
| -/* |
31 |
| - * ScanKeyEntrySetIllegal |
32 |
| - * Marks a scan key entry as illegal. |
33 |
| - */ |
34 |
| -void |
35 |
| -ScanKeyEntrySetIllegal(ScanKey entry) |
36 |
| -{ |
37 |
| - |
38 |
| - Assert(PointerIsValid(entry)); |
39 |
| - |
40 |
| - entry->sk_flags = 0; /* just in case... */ |
41 |
| - entry->sk_attno = InvalidAttrNumber; |
42 |
| - entry->sk_procedure = 0; /* should be InvalidRegProcedure */ |
43 |
| - entry->sk_func.fn_oid = InvalidOid; |
44 |
| - entry->sk_argument = (Datum) 0; |
45 |
| -} |
46 | 19 |
|
47 | 20 | /*
|
48 | 21 | * ScanKeyEntryInitialize
|
49 |
| - * Initializes a scan key entry. |
| 22 | + * Initializes a scan key entry given all the field values. |
| 23 | + * The target procedure is specified by OID. |
50 | 24 | *
|
51 |
| - * Note: |
52 |
| - * Assumes the scan key entry is valid. |
53 |
| - * Assumes the intialized scan key entry will be legal. |
| 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. |
54 | 28 | */
|
55 | 29 | void
|
56 | 30 | ScanKeyEntryInitialize(ScanKey entry,
|
57 |
| - bits16 flags, |
| 31 | + int flags, |
58 | 32 | AttrNumber attributeNumber,
|
| 33 | + StrategyNumber strategy, |
59 | 34 | RegProcedure procedure,
|
60 |
| - Datum argument) |
| 35 | + Datum argument, |
| 36 | + Oid argtype) |
61 | 37 | {
|
62 |
| - Assert(PointerIsValid(entry)); |
63 |
| - |
64 | 38 | entry->sk_flags = flags;
|
65 | 39 | entry->sk_attno = attributeNumber;
|
66 |
| - entry->sk_procedure = procedure; |
| 40 | + entry->sk_strategy = strategy; |
67 | 41 | entry->sk_argument = argument;
|
| 42 | + entry->sk_argtype = argtype; |
68 | 43 | fmgr_info(procedure, &entry->sk_func);
|
69 |
| - |
70 |
| - Assert(ScanKeyEntryIsLegal(entry)); |
71 | 44 | }
|
72 | 45 |
|
73 | 46 | /*
|
74 | 47 | * ScanKeyEntryInitializeWithInfo
|
75 | 48 | * Initializes a scan key entry using an already-completed FmgrInfo
|
76 | 49 | * function lookup record.
|
77 | 50 | *
|
78 |
| - * mcxt is the memory context holding the scan key; it'll be used for |
79 |
| - * any subsidiary info attached to the scankey's FmgrInfo record. |
| 51 | + * Note: CurrentMemoryContext at call should be as long-lived as the ScanKey |
| 52 | + * itself, because that's what will be used for any subsidiary info attached |
| 53 | + * to the ScanKey's FmgrInfo record. |
80 | 54 | */
|
81 | 55 | void
|
82 | 56 | ScanKeyEntryInitializeWithInfo(ScanKey entry,
|
83 |
| - bits16 flags, |
| 57 | + int flags, |
84 | 58 | AttrNumber attributeNumber,
|
| 59 | + StrategyNumber strategy, |
85 | 60 | FmgrInfo *finfo,
|
86 |
| - MemoryContext mcxt, |
87 |
| - Datum argument) |
| 61 | + Datum argument, |
| 62 | + Oid argtype) |
88 | 63 | {
|
89 |
| - Assert(PointerIsValid(entry)); |
90 |
| - Assert(RegProcedureIsValid(finfo->fn_oid)); |
91 |
| - |
92 | 64 | entry->sk_flags = flags;
|
93 | 65 | entry->sk_attno = attributeNumber;
|
94 |
| - entry->sk_procedure = finfo->fn_oid; |
| 66 | + entry->sk_strategy = strategy; |
95 | 67 | entry->sk_argument = argument;
|
96 |
| - fmgr_info_copy(&entry->sk_func, finfo, mcxt); |
97 |
| - |
98 |
| - Assert(ScanKeyEntryIsLegal(entry)); |
| 68 | + entry->sk_argtype = argtype; |
| 69 | + fmgr_info_copy(&entry->sk_func, finfo, CurrentMemoryContext); |
99 | 70 | }
|
0 commit comments