2005-04-28 23:47:18 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* htup.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* POSTGRES heap tuple definitions.
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*
|
2013-01-01 23:15:01 +01:00
|
|
|
* Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/access/htup.h
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#ifndef HTUP_H
|
1996-08-27 23:50:29 +02:00
|
|
|
#define HTUP_H
|
|
|
|
|
2006-07-13 18:49:20 +02:00
|
|
|
#include "storage/itemptr.h"
|
1996-08-27 23:50:29 +02:00
|
|
|
|
2012-08-30 22:15:44 +02:00
|
|
|
/* typedefs and forward declarations for structs defined in htup.h */
|
2004-04-01 23:28:47 +02:00
|
|
|
|
2012-08-30 22:15:44 +02:00
|
|
|
typedef struct HeapTupleHeaderData HeapTupleHeaderData;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
1998-11-27 20:33:35 +01:00
|
|
|
typedef HeapTupleHeaderData *HeapTupleHeader;
|
1996-08-27 23:50:29 +02:00
|
|
|
|
2012-08-30 22:15:44 +02:00
|
|
|
typedef struct MinimalTupleData MinimalTupleData;
|
2006-06-27 04:51:40 +02:00
|
|
|
|
|
|
|
typedef MinimalTupleData *MinimalTuple;
|
|
|
|
|
|
|
|
|
1998-11-27 20:33:35 +01:00
|
|
|
/*
|
2002-05-27 21:53:33 +02:00
|
|
|
* HeapTupleData is an in-memory data structure that points to a tuple.
|
2001-02-21 20:07:04 +01:00
|
|
|
*
|
2005-08-20 02:40:32 +02:00
|
|
|
* There are several ways in which this data structure is used:
|
|
|
|
*
|
|
|
|
* * Pointer to a tuple in a disk buffer: t_data points directly into the
|
|
|
|
* buffer (which the code had better be holding a pin on, but this is not
|
2005-11-20 20:49:08 +01:00
|
|
|
* reflected in HeapTupleData itself).
|
2005-08-20 02:40:32 +02:00
|
|
|
*
|
2005-11-20 20:49:08 +01:00
|
|
|
* * Pointer to nothing: t_data is NULL. This is used as a failure indication
|
|
|
|
* in some functions.
|
2005-08-20 02:40:32 +02:00
|
|
|
*
|
|
|
|
* * Part of a palloc'd tuple: the HeapTupleData itself and the tuple
|
|
|
|
* form a single palloc'd chunk. t_data points to the memory location
|
2005-11-20 20:49:08 +01:00
|
|
|
* immediately following the HeapTupleData struct (at offset HEAPTUPLESIZE).
|
|
|
|
* This is the output format of heap_form_tuple and related routines.
|
1998-11-27 20:33:35 +01:00
|
|
|
*
|
2005-08-20 02:40:32 +02:00
|
|
|
* * Separately allocated tuple: t_data points to a palloc'd chunk that
|
2005-11-22 19:17:34 +01:00
|
|
|
* is not adjacent to the HeapTupleData. (This case is deprecated since
|
2005-11-20 20:49:08 +01:00
|
|
|
* it's difficult to tell apart from case #1. It should be used only in
|
|
|
|
* limited contexts where the code knows that case #1 will never apply.)
|
1999-12-16 23:20:03 +01:00
|
|
|
*
|
2006-06-27 04:51:40 +02:00
|
|
|
* * Separately allocated minimal tuple: t_data points MINIMAL_TUPLE_OFFSET
|
2006-10-04 02:30:14 +02:00
|
|
|
* bytes before the start of a MinimalTuple. As with the previous case,
|
2006-06-27 04:51:40 +02:00
|
|
|
* this can't be told apart from case #1 by inspection; code setting up
|
|
|
|
* or destroying this representation has to know what it's doing.
|
|
|
|
*
|
2005-08-20 02:40:32 +02:00
|
|
|
* t_len should always be valid, except in the pointer-to-nothing case.
|
|
|
|
* t_self and t_tableOid should be valid if the HeapTupleData points to
|
|
|
|
* a disk buffer, or if it represents a copy of a tuple on disk. They
|
|
|
|
* should be explicitly set invalid in manufactured tuples.
|
1998-11-27 20:33:35 +01:00
|
|
|
*/
|
|
|
|
typedef struct HeapTupleData
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
uint32 t_len; /* length of *t_data */
|
|
|
|
ItemPointerData t_self; /* SelfItemPointer */
|
|
|
|
Oid t_tableOid; /* table the tuple came from */
|
|
|
|
HeapTupleHeader t_data; /* -> tuple header and data */
|
1998-11-27 20:33:35 +01:00
|
|
|
} HeapTupleData;
|
1999-05-25 18:15:34 +02:00
|
|
|
|
1998-11-27 20:33:35 +01:00
|
|
|
typedef HeapTupleData *HeapTuple;
|
|
|
|
|
1999-07-19 09:07:29 +02:00
|
|
|
#define HEAPTUPLESIZE MAXALIGN(sizeof(HeapTupleData))
|
1999-05-25 18:15:34 +02:00
|
|
|
|
1996-08-27 23:50:29 +02:00
|
|
|
/*
|
2004-04-01 23:28:47 +02:00
|
|
|
* Accessor macros to be used with HeapTuple pointers.
|
1996-08-27 23:50:29 +02:00
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#define HeapTupleIsValid(tuple) PointerIsValid(tuple)
|
1996-08-27 23:50:29 +02:00
|
|
|
|
2007-02-09 04:35:35 +01:00
|
|
|
/* HeapTupleHeader functions implemented in utils/time/combocid.c */
|
|
|
|
extern CommandId HeapTupleHeaderGetCmin(HeapTupleHeader tup);
|
|
|
|
extern CommandId HeapTupleHeaderGetCmax(HeapTupleHeader tup);
|
|
|
|
extern void HeapTupleHeaderAdjustCmax(HeapTupleHeader tup,
|
2007-11-15 22:14:46 +01:00
|
|
|
CommandId *cmax,
|
|
|
|
bool *iscombo);
|
2007-02-09 04:35:35 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* HTUP_H */
|