Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
htup.h90 linesDownload Raw Back to access
1/*-------------------------------------------------------------------------2 *3 * htup.h4 *	  POSTGRES heap tuple definitions.5 *6 *7 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group8 * Portions Copyright (c) 1994, Regents of the University of California9 *10 * src/include/access/htup.h11 *12 *-------------------------------------------------------------------------13 */14#ifndef HTUP_H15#define HTUP_H16 17#include "storage/itemptr.h"18 19/* typedefs and forward declarations for structs defined in htup_details.h */20 21typedef struct HeapTupleHeaderData HeapTupleHeaderData;22 23typedef HeapTupleHeaderData *HeapTupleHeader;24 25typedef struct MinimalTupleData MinimalTupleData;26 27typedef MinimalTupleData *MinimalTuple;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 the36 *	 buffer (which the code had better be holding a pin on, but this is not37 *	 reflected in HeapTupleData itself).38 *39 * * Pointer to nothing: t_data is NULL.  This is used as a failure indication40 *	 in some functions.41 *42 * * Part of a palloc'd tuple: the HeapTupleData itself and the tuple43 *	 form a single palloc'd chunk.  t_data points to the memory location44 *	 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 that48 *	 is not adjacent to the HeapTupleData.  (This case is deprecated since49 *	 it's difficult to tell apart from case #1.  It should be used only in50 *	 limited contexts where the code knows that case #1 will never apply.)51 *52 * * Separately allocated minimal tuple: t_data points MINIMAL_TUPLE_OFFSET53 *	 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 up55 *	 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 to59 * a disk buffer, or if it represents a copy of a tuple on disk.  They60 * should be explicitly set invalid in manufactured tuples.61 */62typedef struct HeapTupleData63{64	uint32		t_len;			/* length of *t_data */65	ItemPointerData t_self;		/* SelfItemPointer */66	Oid			t_tableOid;		/* table the tuple came from */67#define FIELDNO_HEAPTUPLEDATA_DATA 368	HeapTupleHeader t_data;		/* -> tuple header and data */69} HeapTupleData;70 71typedef HeapTupleData *HeapTuple;72 73#define HEAPTUPLESIZE	MAXALIGN(sizeof(HeapTupleData))74 75/*76 * Accessor macros to be used with HeapTuple pointers.77 */78#define HeapTupleIsValid(tuple) PointerIsValid(tuple)79 80/* HeapTupleHeader functions implemented in utils/time/combocid.c */81extern CommandId HeapTupleHeaderGetCmin(HeapTupleHeader tup);82extern CommandId HeapTupleHeaderGetCmax(HeapTupleHeader tup);83extern void HeapTupleHeaderAdjustCmax(HeapTupleHeader tup,84									  CommandId *cmax, bool *iscombo);85 86/* Prototype for HeapTupleHeader accessors in heapam.c */87extern TransactionId HeapTupleGetUpdateXid(HeapTupleHeader tuple);88 89#endif							/* HTUP_H */90 
codekingpro/portable-devtools · Team Ai