PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
htup.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * htup.h
4  * POSTGRES heap tuple definitions.
5  *
6  *
7  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/access/htup.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef HTUP_H
15 #define HTUP_H
16 
17 #include "storage/itemptr.h"
18 
19 /* typedefs and forward declarations for structs defined in htup_details.h */
20 
22 
24 
26 
28 
29 
30 /*
31  * HeapTupleData is an in-memory data structure that points to a tuple.
32  *
33  * There are several ways in which this data structure is used:
34  *
35  * * Pointer to a tuple in a disk buffer: t_data points directly into the
36  * buffer (which the code had better be holding a pin on, but this is not
37  * reflected in HeapTupleData itself).
38  *
39  * * Pointer to nothing: t_data is NULL. This is used as a failure indication
40  * in some functions.
41  *
42  * * Part of a palloc'd tuple: the HeapTupleData itself and the tuple
43  * form a single palloc'd chunk. t_data points to the memory location
44  * immediately following the HeapTupleData struct (at offset HEAPTUPLESIZE).
45  * This is the output format of heap_form_tuple and related routines.
46  *
47  * * Separately allocated tuple: t_data points to a palloc'd chunk that
48  * is not adjacent to the HeapTupleData. (This case is deprecated since
49  * it's difficult to tell apart from case #1. It should be used only in
50  * limited contexts where the code knows that case #1 will never apply.)
51  *
52  * * Separately allocated minimal tuple: t_data points MINIMAL_TUPLE_OFFSET
53  * bytes before the start of a MinimalTuple. As with the previous case,
54  * this can't be told apart from case #1 by inspection; code setting up
55  * or destroying this representation has to know what it's doing.
56  *
57  * t_len should always be valid, except in the pointer-to-nothing case.
58  * t_self and t_tableOid should be valid if the HeapTupleData points to
59  * a disk buffer, or if it represents a copy of a tuple on disk. They
60  * should be explicitly set invalid in manufactured tuples.
61  */
62 typedef struct HeapTupleData
63 {
64  uint32 t_len; /* length of *t_data */
65  ItemPointerData t_self; /* SelfItemPointer */
66  Oid t_tableOid; /* table the tuple came from */
67  HeapTupleHeader t_data; /* -> tuple header and data */
69 
71 
72 #define HEAPTUPLESIZE MAXALIGN(sizeof(HeapTupleData))
73 
74 /*
75  * Accessor macros to be used with HeapTuple pointers.
76  */
77 #define HeapTupleIsValid(tuple) PointerIsValid(tuple)
78 
79 /* HeapTupleHeader functions implemented in utils/time/combocid.c */
83  CommandId *cmax, bool *iscombo);
84 
85 /* Prototype for HeapTupleHeader accessors in heapam.c */
87 
88 #endif /* HTUP_H */
uint32 CommandId
Definition: c.h:411
HeapTupleData * HeapTuple
Definition: htup.h:70
uint32 TransactionId
Definition: c.h:397
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
unsigned int Oid
Definition: postgres_ext.h:31
HeapTupleHeader t_data
Definition: htup.h:67
CommandId HeapTupleHeaderGetCmin(HeapTupleHeader tup)
Definition: combocid.c:105
ItemPointerData t_self
Definition: htup.h:65
uint32 t_len
Definition: htup.h:64
MinimalTupleData * MinimalTuple
Definition: htup.h:27
unsigned int uint32
Definition: c.h:268
Oid t_tableOid
Definition: htup.h:66
TransactionId HeapTupleGetUpdateXid(HeapTupleHeader tuple)
Definition: heapam.c:6930
CommandId HeapTupleHeaderGetCmax(HeapTupleHeader tup)
Definition: combocid.c:119
void HeapTupleHeaderAdjustCmax(HeapTupleHeader tup, CommandId *cmax, bool *iscombo)
Definition: combocid.c:154
struct HeapTupleData HeapTupleData