]> granicus.if.org Git - postgresql/blob - src/include/access/htup.h
Added empty TOASTER files and corrected some minor glitches
[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.27 1999/12/21 00:06:42 wieck 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  * Change for 7.0:
83  *    Up to now t_data could be NULL, the memory location directly following
84  *    HeapTupleData or pointing into a buffer. Now, it could also point to
85  *    a separate allocation that was done in the t_datamcxt memory context.
86  */
87 typedef struct HeapTupleData
88 {
89         uint32          t_len;                  /* length of *t_data */
90         ItemPointerData t_self;         /* SelfItemPointer */
91         MemoryContext   t_datamcxt; /* */
92         HeapTupleHeader t_data;         /* */
93 } HeapTupleData;
94
95 typedef HeapTupleData *HeapTuple;
96
97 #define HEAPTUPLESIZE   MAXALIGN(sizeof(HeapTupleData))
98
99
100 /* ----------------
101  *              support macros
102  * ----------------
103  */
104 #define GETSTRUCT(TUP) (((char *)((HeapTuple)(TUP))->t_data) + \
105                                                 ((HeapTuple)(TUP))->t_data->t_hoff)
106
107
108 /*
109  * BITMAPLEN(NATTS) -
110  *              Computes minimum size of bitmap given number of domains.
111  */
112 #define BITMAPLEN(NATTS) \
113                 ((((((int)(NATTS) - 1) >> 3) + 4 - (MinHeapTupleBitmapSize >> 3)) \
114                   & ~03) + (MinHeapTupleBitmapSize >> 3))
115
116 /*
117  * HeapTupleIsValid
118  *              True iff the heap tuple is valid.
119  */
120 #define HeapTupleIsValid(tuple) PointerIsValid(tuple)
121
122 /*
123  * information stored in t_infomask:
124  */
125 #define HEAP_HASNULL                    0x0001  /* has null attribute(s) */
126 #define HEAP_HASVARLENA                 0x0002  /* has variable length
127                                                                                  * attribute(s) */
128 #define HEAP_HASEXTERNAL                0x0004  /* has external stored */
129                                                                                 /* attribute(s) */
130 #define HEAP_HASCOMPRESSED              0x0008  /* has compressed stored */
131                                                                                 /* attribute(s) */
132 #define HEAP_HASEXTENDED                0x000C  /* the two above combined */
133 #define HEAP_XMIN_COMMITTED             0x0100  /* t_xmin committed */
134 #define HEAP_XMIN_INVALID               0x0200  /* t_xmin invalid/aborted */
135 #define HEAP_XMAX_COMMITTED             0x0400  /* t_xmax committed */
136 #define HEAP_XMAX_INVALID               0x0800  /* t_xmax invalid/aborted */
137 #define HEAP_MARKED_FOR_UPDATE  0x1000  /* marked for UPDATE */
138 #define HEAP_UPDATED                    0x2000  /* this is UPDATEd version of row */
139 #define HEAP_MOVED_OFF                  0x4000  /* removed or moved to another
140                                                                                  * place by vacuum */
141 #define HEAP_MOVED_IN                   0x8000  /* moved from another place by
142                                                                                  * vacuum */
143
144 #define HEAP_XACT_MASK                  0xFF00  /* */
145
146 #define HeapTupleNoNulls(tuple) \
147                 (!(((HeapTuple) (tuple))->t_data->t_infomask & HEAP_HASNULL))
148
149 #define HeapTupleAllFixed(tuple) \
150                 (!(((HeapTuple) (tuple))->t_data->t_infomask & HEAP_HASVARLENA))
151
152 #define HeapTupleHasExternal(tuple) \
153                 ((((HeapTuple)(tuple))->t_data->t_infomask & HEAP_HASEXTERNAL) != 0)
154
155 #define HeapTupleHasCompressed(tuple) \
156                 ((((HeapTuple)(tuple))->t_data->t_infomask & HEAP_HASCOMPRESSED) != 0)
157
158 #define HeapTupleHasExtended(tuple) \
159                 ((((HeapTuple)(tuple))->t_data->t_infomask & HEAP_HASEXTENDED) != 0)
160
161 #endif   /* HTUP_H */