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