]> granicus.if.org Git - postgresql/blob - src/include/storage/itemid.h
Update CVS HEAD for 2007 copyright. Back branches are typically not
[postgresql] / src / include / storage / itemid.h
1 /*-------------------------------------------------------------------------
2  *
3  * itemid.h
4  *        Standard POSTGRES buffer page item identifier definitions.
5  *
6  *
7  * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $PostgreSQL: pgsql/src/include/storage/itemid.h,v 1.27 2007/01/05 22:19:58 momjian Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef ITEMID_H
15 #define ITEMID_H
16
17 /*
18  * An item pointer (also called line pointer) on a buffer page
19  */
20 typedef struct ItemIdData
21 {                                                               /* line pointers */
22         unsigned        lp_off:15,              /* offset to start of tuple */
23                                 lp_flags:2,             /* flags for tuple */
24                                 lp_len:15;              /* length of tuple */
25 } ItemIdData;
26
27 typedef ItemIdData *ItemId;
28
29 /*
30  * lp_flags contains these flags:
31  */
32 #define LP_USED                 0x01    /* this line pointer is being used */
33
34 #define LP_DELETE               0x02    /* item is to be deleted */
35
36 #define ItemIdDeleted(itemId) \
37         (((itemId)->lp_flags & LP_DELETE) != 0)
38
39 /*
40  * This bit may be passed to PageAddItem together with
41  * LP_USED & LP_DELETE bits to specify overwrite mode
42  */
43 #define OverwritePageMode       0x10
44
45 /*
46  * Item offsets, lengths, and flags are represented by these types when
47  * they're not actually stored in an ItemIdData.
48  */
49 typedef uint16 ItemOffset;
50 typedef uint16 ItemLength;
51
52 typedef bits16 ItemIdFlags;
53
54
55 /* ----------------
56  *              support macros
57  * ----------------
58  */
59
60 /*
61  *              ItemIdGetLength
62  */
63 #define ItemIdGetLength(itemId) \
64    ((itemId)->lp_len)
65
66 /*
67  *              ItemIdGetOffset
68  */
69 #define ItemIdGetOffset(itemId) \
70    ((itemId)->lp_off)
71
72 /*
73  *              ItemIdGetFlags
74  */
75 #define ItemIdGetFlags(itemId) \
76    ((itemId)->lp_flags)
77
78 /*
79  * ItemIdIsValid
80  *              True iff disk item identifier is valid.
81  */
82 #define ItemIdIsValid(itemId)   PointerIsValid(itemId)
83
84 /*
85  * ItemIdIsUsed
86  *              True iff disk item identifier is in use.
87  *
88  * Note:
89  *              Assumes disk item identifier is valid.
90  */
91 #define ItemIdIsUsed(itemId) \
92 ( \
93         AssertMacro(ItemIdIsValid(itemId)), \
94         (bool) (((itemId)->lp_flags & LP_USED) != 0) \
95 )
96
97 #endif   /* ITEMID_H */