]> granicus.if.org Git - postgresql/blob - src/include/access/htup.h
Clean up #include in /include directory. Add scripts for checking includes.
[postgresql] / src / include / access / htup.h
1  /*-------------------------------------------------------------------------
2  *
3  * htup.h
4  *        POSTGRES heap tuple definitions.
5  *
6  *
7  * Copyright (c) 1994, Regents of the University of California
8  *
9  * $Id: htup.h,v 1.23 1999/07/15 15:20:54 momjian Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef HTUP_H
14 #define HTUP_H
15
16 #include <storage/bufpage.h>
17
18 #define MinHeapTupleBitmapSize  32              /* 8 * 4 */
19
20 /* check these, they are likely to be more severely limited by t_hoff */
21
22 #define MaxHeapAttributeNumber  1600    /* 8 * 200 */
23
24 /*
25  * to avoid wasting space, the attributes should be layed out in such a
26  * way to reduce structure padding.
27  */
28 typedef struct HeapTupleHeaderData
29 {
30         Oid                     t_oid;                  /* OID of this tuple -- 4 bytes */
31
32         CommandId       t_cmin;                 /* insert CID stamp -- 4 bytes each */
33         CommandId       t_cmax;                 /* delete CommandId stamp */
34
35         TransactionId t_xmin;           /* insert XID stamp -- 4 bytes each */
36         TransactionId t_xmax;           /* delete XID stamp */
37
38         ItemPointerData t_ctid;         /* current TID of this or newer tuple */
39
40         int16           t_natts;                /* number of attributes */
41
42         uint16          t_infomask;             /* various infos */
43
44         uint8           t_hoff;                 /* sizeof tuple header */
45
46         bits8           t_bits[MinHeapTupleBitmapSize / 8];
47         /* bit map of domains */
48
49         /* MORE DATA FOLLOWS AT END OF STRUCT */
50 } HeapTupleHeaderData;
51
52 typedef HeapTupleHeaderData *HeapTupleHeader;
53
54 #define MinTupleSize    (MAXALIGN(sizeof (PageHeaderData)) + \
55                                                  MAXALIGN(sizeof(HeapTupleHeaderData)) + \
56                                                  MAXALIGN(sizeof(char)))
57
58 #define MaxTupleSize    (BLCKSZ - MinTupleSize)
59
60 #define MaxAttrSize             (MaxTupleSize - MAXALIGN(sizeof(HeapTupleHeaderData)))
61
62 #define SelfItemPointerAttributeNumber                  (-1)
63 #define ObjectIdAttributeNumber                                 (-2)
64 #define MinTransactionIdAttributeNumber                 (-3)
65 #define MinCommandIdAttributeNumber                             (-4)
66 #define MaxTransactionIdAttributeNumber                 (-5)
67 #define MaxCommandIdAttributeNumber                             (-6)
68 #define FirstLowInvalidHeapAttributeNumber              (-7)
69
70 /* If you make any changes above, the order off offsets in this must change */
71 extern long heap_sysoffset[];
72
73 /*
74  * This new HeapTuple for version >= 6.5 and this is why it was changed:
75  *
76  * 1. t_len moved off on-disk tuple data - ItemIdData is used to get len;
77  * 2. t_ctid above is not self tuple TID now - it may point to
78  *        updated version of tuple (required by MVCC);
79  * 3. someday someone let tuple to cross block boundaries -
80  *        he have to add something below...
81  */
82 typedef struct HeapTupleData
83 {
84         uint32          t_len;                  /* length of *t_data */
85         ItemPointerData t_self;         /* SelfItemPointer */
86         HeapTupleHeader t_data;         /* */
87 } HeapTupleData;
88
89 typedef HeapTupleData *HeapTuple;
90
91 #define HEAPTUPLESIZE   DOUBLEALIGN(sizeof(HeapTupleData))
92
93
94 /* ----------------
95  *              support macros
96  * ----------------
97  */
98 #define GETSTRUCT(TUP) (((char *)((HeapTuple)(TUP))->t_data) + \
99                                                 ((HeapTuple)(TUP))->t_data->t_hoff)
100
101
102 /*
103  * BITMAPLEN(NATTS) -
104  *              Computes minimum size of bitmap given number of domains.
105  */
106 #define BITMAPLEN(NATTS) \
107                 ((((((int)(NATTS) - 1) >> 3) + 4 - (MinHeapTupleBitmapSize >> 3)) \
108                   & ~03) + (MinHeapTupleBitmapSize >> 3))
109
110 /*
111  * HeapTupleIsValid
112  *              True iff the heap tuple is valid.
113  */
114 #define HeapTupleIsValid(tuple) PointerIsValid(tuple)
115
116 /*
117  * information stored in t_infomask:
118  */
119 #define HEAP_HASNULL                    0x0001  /* has null attribute(s) */
120 #define HEAP_HASVARLENA                 0x0002  /* has variable length
121                                                                                  * attribute(s) */
122 #define HEAP_XMIN_COMMITTED             0x0100  /* t_xmin committed */
123 #define HEAP_XMIN_INVALID               0x0200  /* t_xmin invalid/aborted */
124 #define HEAP_XMAX_COMMITTED             0x0400  /* t_xmax committed */
125 #define HEAP_XMAX_INVALID               0x0800  /* t_xmax invalid/aborted */
126 #define HEAP_MARKED_FOR_UPDATE  0x1000  /* marked for UPDATE */
127 #define HEAP_UPDATED                    0x2000  /* this is UPDATEd version of row */
128 #define HEAP_MOVED_OFF                  0x4000  /* removed or moved to another
129                                                                                  * place by vacuum */
130 #define HEAP_MOVED_IN                   0x8000  /* moved from another place by
131                                                                                  * vacuum */
132
133 #define HEAP_XACT_MASK                  0xFF00  /* */
134
135 #define HeapTupleNoNulls(tuple) \
136                 (!(((HeapTuple) (tuple))->t_data->t_infomask & HEAP_HASNULL))
137
138 #define HeapTupleAllFixed(tuple) \
139                 (!(((HeapTuple) (tuple))->t_data->t_infomask & HEAP_HASVARLENA))
140
141 #endif   /* HTUP_H */