OSDN Git Service

Remove the mostly-stubbed-out-anyway support routines for WAL UNDO.
[pg-rex/syncrep.git] / src / include / access / valid.h
1 /*-------------------------------------------------------------------------
2  *
3  * valid.h
4  *        POSTGRES tuple qualification validity definitions.
5  *
6  *
7  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $PostgreSQL: pgsql/src/include/access/valid.h,v 1.36 2004/12/31 22:03:21 pgsql Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef VALID_H
15 #define VALID_H
16
17 /*
18  *              HeapKeyTest
19  *
20  *              Test a heap tuple to see if it satisfies a scan key.
21  */
22 #define HeapKeyTest(tuple, \
23                                         tupdesc, \
24                                         nkeys, \
25                                         keys, \
26                                         result) \
27 do \
28 { \
29         /* Use underscores to protect the variables passed in as parameters */ \
30         int                     __cur_nkeys = (nkeys); \
31         ScanKey         __cur_keys = (keys); \
32  \
33         (result) = true; /* may change */ \
34         for (; __cur_nkeys--; __cur_keys++) \
35         { \
36                 Datum   __atp; \
37                 bool    __isnull; \
38                 Datum   __test; \
39  \
40                 if (__cur_keys->sk_flags & SK_ISNULL) \
41                 { \
42                         (result) = false; \
43                         break; \
44                 } \
45  \
46                 __atp = heap_getattr((tuple), \
47                                                          __cur_keys->sk_attno, \
48                                                          (tupdesc), \
49                                                          &__isnull); \
50  \
51                 if (__isnull) \
52                 { \
53                         (result) = false; \
54                         break; \
55                 } \
56  \
57                 __test = FunctionCall2(&__cur_keys->sk_func, \
58                                                            __atp, __cur_keys->sk_argument); \
59  \
60                 if (!DatumGetBool(__test)) \
61                 { \
62                         (result) = false; \
63                         break; \
64                 } \
65         } \
66 } while (0)
67
68 /*
69  *              HeapTupleSatisfies
70  *
71  *      res is set TRUE if the HeapTuple satisfies the timequal and keytest,
72  *      otherwise it is set FALSE.      Note that the hint bits in the HeapTuple's
73  *      t_infomask may be updated as a side effect.
74  *
75  *      on 8/21/92 mao says:  i rearranged the tests here to do keytest before
76  *      SatisfiesTimeQual.      profiling indicated that even for vacuumed relations,
77  *      time qual checking was more expensive than key testing.  time qual is
78  *      least likely to fail, too.      we should really add the time qual test to
79  *      the restriction and optimize it in the normal way.      this has interactions
80  *      with joey's expensive function work.
81  */
82 #define HeapTupleSatisfies(tuple, \
83                                                    relation, \
84                                                    buffer, \
85                                                    disk_page, \
86                                                    snapshot, \
87                                                    nKeys, \
88                                                    key, \
89                                                    res) \
90 do \
91 { \
92         if ((key) != NULL) \
93                 HeapKeyTest(tuple, RelationGetDescr(relation), nKeys, key, res); \
94         else \
95                 (res) = true; \
96  \
97         if ((res) && (relation)->rd_rel->relkind != RELKIND_UNCATALOGED) \
98                 (res) = HeapTupleSatisfiesVisibility(tuple, snapshot, buffer); \
99 } while (0)
100
101 #endif   /* VALID_H */