mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
This reduces unnecessary exposure of other headers through htup.h, which is very widely included by many files. I have chosen to move the function prototypes to the new file as well, because that means htup.h no longer needs to include tupdesc.h. In itself this doesn't have much effect in indirect inclusion of tupdesc.h throughout the tree, because it's also required by execnodes.h; but it's something to explore in the future, and it seemed best to do the htup.h change now while I'm busy with it.
87 lines
3.0 KiB
C
87 lines
3.0 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* htup.h
|
|
* POSTGRES heap tuple definitions.
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/access/htup.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef HTUP_H
|
|
#define HTUP_H
|
|
|
|
#include "storage/itemptr.h"
|
|
|
|
/* typedefs and forward declarations for structs defined in htup.h */
|
|
|
|
typedef struct HeapTupleHeaderData HeapTupleHeaderData;
|
|
|
|
typedef HeapTupleHeaderData *HeapTupleHeader;
|
|
|
|
typedef struct MinimalTupleData MinimalTupleData;
|
|
|
|
typedef MinimalTupleData *MinimalTuple;
|
|
|
|
|
|
/*
|
|
* HeapTupleData is an in-memory data structure that points to a tuple.
|
|
*
|
|
* 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
|
|
* reflected in HeapTupleData itself).
|
|
*
|
|
* * Pointer to nothing: t_data is NULL. This is used as a failure indication
|
|
* in some functions.
|
|
*
|
|
* * 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
|
|
* immediately following the HeapTupleData struct (at offset HEAPTUPLESIZE).
|
|
* This is the output format of heap_form_tuple and related routines.
|
|
*
|
|
* * Separately allocated tuple: t_data points to a palloc'd chunk that
|
|
* is not adjacent to the HeapTupleData. (This case is deprecated since
|
|
* 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.)
|
|
*
|
|
* * Separately allocated minimal tuple: t_data points MINIMAL_TUPLE_OFFSET
|
|
* bytes before the start of a MinimalTuple. As with the previous case,
|
|
* 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.
|
|
*
|
|
* 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.
|
|
*/
|
|
typedef struct HeapTupleData
|
|
{
|
|
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 */
|
|
} HeapTupleData;
|
|
|
|
typedef HeapTupleData *HeapTuple;
|
|
|
|
#define HEAPTUPLESIZE MAXALIGN(sizeof(HeapTupleData))
|
|
|
|
/*
|
|
* Accessor macros to be used with HeapTuple pointers.
|
|
*/
|
|
#define HeapTupleIsValid(tuple) PointerIsValid(tuple)
|
|
|
|
/* HeapTupleHeader functions implemented in utils/time/combocid.c */
|
|
extern CommandId HeapTupleHeaderGetCmin(HeapTupleHeader tup);
|
|
extern CommandId HeapTupleHeaderGetCmax(HeapTupleHeader tup);
|
|
extern void HeapTupleHeaderAdjustCmax(HeapTupleHeader tup,
|
|
CommandId *cmax,
|
|
bool *iscombo);
|
|
|
|
#endif /* HTUP_H */
|