Force a checkpoint in CREATE DATABASE before starting to copy the files,
[PostgreSQL.git] / src / backend / access / common / scankey.c
blob3ccb72b3abd37dfbc13da30bc981fc43f7bd9cc5
1 /*-------------------------------------------------------------------------
3 * scankey.c
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
10 * IDENTIFICATION
11 * $PostgreSQL$
13 *-------------------------------------------------------------------------
15 #include "postgres.h"
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.
30 void
31 ScanKeyEntryInitialize(ScanKey entry,
32 int flags,
33 AttrNumber attributeNumber,
34 StrategyNumber strategy,
35 Oid subtype,
36 RegProcedure procedure,
37 Datum argument)
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);
46 else
48 Assert(flags & SK_SEARCHNULL);
49 MemSet(&entry->sk_func, 0, sizeof(entry->sk_func));
54 * ScanKeyInit
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.
66 void
67 ScanKeyInit(ScanKey entry,
68 AttrNumber attributeNumber,
69 StrategyNumber strategy,
70 RegProcedure procedure,
71 Datum argument)
73 entry->sk_flags = 0;
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.
90 void
91 ScanKeyEntryInitializeWithInfo(ScanKey entry,
92 int flags,
93 AttrNumber attributeNumber,
94 StrategyNumber strategy,
95 Oid subtype,
96 FmgrInfo *finfo,
97 Datum argument)
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);