⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 htup.h

📁 PostgreSQL 8.1.4的源码 适用于Linux下的开源数据库系统
💻 H
📖 第 1 页 / 共 2 页
字号:
)#define HeapTupleHeaderGetTypMod(tup) \( \	(tup)->t_choice.t_datum.datum_typmod \)#define HeapTupleHeaderSetTypMod(tup, typmod) \( \	(tup)->t_choice.t_datum.datum_typmod = (typmod) \)#define HeapTupleHeaderGetOid(tup) \( \	((tup)->t_infomask & HEAP_HASOID) ? \		*((Oid *) ((char *)(tup) + (tup)->t_hoff - sizeof(Oid))) \	: \		InvalidOid \)#define HeapTupleHeaderSetOid(tup, oid) \do { \	Assert((tup)->t_infomask & HEAP_HASOID); \	*((Oid *) ((char *)(tup) + (tup)->t_hoff - sizeof(Oid))) = (oid); \} while (0)/* * BITMAPLEN(NATTS) - *		Computes size of null bitmap given number of data columns. */#define BITMAPLEN(NATTS)	(((int)(NATTS) + 7) / 8)/* * MaxTupleSize is the maximum allowed size of a tuple, including header and * MAXALIGN alignment padding.	Basically it's BLCKSZ minus the other stuff * that has to be on a disk page.  The "other stuff" includes access-method- * dependent "special space", which we assume will be no more than * MaxSpecialSpace bytes (currently, on heap pages it's actually zero). * * NOTE: we do not need to count an ItemId for the tuple because * sizeof(PageHeaderData) includes the first ItemId on the page. */#define MaxSpecialSpace  32#define MaxTupleSize	\	(BLCKSZ - MAXALIGN(sizeof(PageHeaderData) + MaxSpecialSpace))/* * MaxHeapTuplesPerPage is an upper bound on the number of tuples that can * fit on one heap page.  (Note that indexes could have more, because they * use a smaller tuple header.)  We arrive at the divisor because each tuple * must be maxaligned, and it must have an associated item pointer. */#define MaxHeapTuplesPerPage	\	((int) ((BLCKSZ - offsetof(PageHeaderData, pd_linp)) / \			(MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)) + sizeof(ItemIdData))))/* * MaxAttrSize is a somewhat arbitrary upper limit on the declared size of * data fields of char(n) and similar types.  It need not have anything * directly to do with the *actual* upper limit of varlena values, which * is currently 1Gb (see struct varattrib in postgres.h).  I've set it * at 10Mb which seems like a reasonable number --- tgl 8/6/00. */#define MaxAttrSize		(10 * 1024 * 1024)/* * Attribute numbers for the system-defined attributes */#define SelfItemPointerAttributeNumber			(-1)#define ObjectIdAttributeNumber					(-2)#define MinTransactionIdAttributeNumber			(-3)#define MinCommandIdAttributeNumber				(-4)#define MaxTransactionIdAttributeNumber			(-5)#define MaxCommandIdAttributeNumber				(-6)#define TableOidAttributeNumber					(-7)#define FirstLowInvalidHeapAttributeNumber		(-8)/* * 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).  t_datamcxt must be NULL. * * * Pointer to nothing: t_data and t_datamcxt are 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), *	 and t_datamcxt is the containing context.	This is used as 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, and t_datamcxt is the context *	 containing that chunk. * * 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 */	MemoryContext t_datamcxt;	/* memory context of allocation */	HeapTupleHeader t_data;		/* -> tuple header and data */} HeapTupleData;typedef HeapTupleData *HeapTuple;#define HEAPTUPLESIZE	MAXALIGN(sizeof(HeapTupleData))/* * GETSTRUCT - given a HeapTuple pointer, return address of the user data */#define GETSTRUCT(TUP) ((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff)/* * Accessor macros to be used with HeapTuple pointers. */#define HeapTupleIsValid(tuple) PointerIsValid(tuple)#define HeapTupleHasNulls(tuple) \		(((tuple)->t_data->t_infomask & HEAP_HASNULL) != 0)#define HeapTupleNoNulls(tuple) \		(!((tuple)->t_data->t_infomask & HEAP_HASNULL))#define HeapTupleHasVarWidth(tuple) \		(((tuple)->t_data->t_infomask & HEAP_HASVARWIDTH) != 0)#define HeapTupleAllFixed(tuple) \		(!((tuple)->t_data->t_infomask & HEAP_HASVARWIDTH))#define HeapTupleHasExternal(tuple) \		(((tuple)->t_data->t_infomask & HEAP_HASEXTERNAL) != 0)#define HeapTupleHasCompressed(tuple) \		(((tuple)->t_data->t_infomask & HEAP_HASCOMPRESSED) != 0)#define HeapTupleHasExtended(tuple) \		(((tuple)->t_data->t_infomask & HEAP_HASEXTENDED) != 0)#define HeapTupleGetOid(tuple) \		HeapTupleHeaderGetOid((tuple)->t_data)#define HeapTupleSetOid(tuple, oid) \		HeapTupleHeaderSetOid((tuple)->t_data, (oid))/* * WAL record definitions for heapam.c's WAL operations * * XLOG allows to store some information in high 4 bits of log * record xl_info field.  We use 3 for opcode and one for init bit. */#define XLOG_HEAP_INSERT	0x00#define XLOG_HEAP_DELETE	0x10#define XLOG_HEAP_UPDATE	0x20#define XLOG_HEAP_MOVE		0x30#define XLOG_HEAP_CLEAN		0x40#define XLOG_HEAP_NEWPAGE	0x50#define XLOG_HEAP_LOCK		0x60/* opcode 0x70 still free */#define XLOG_HEAP_OPMASK	0x70/* * When we insert 1st item on new page in INSERT/UPDATE * we can (and we do) restore entire page in redo */#define XLOG_HEAP_INIT_PAGE 0x80/* * All what we need to find changed tuple * * NB: on most machines, sizeof(xl_heaptid) will include some trailing pad * bytes for alignment.  We don't want to store the pad space in the XLOG, * so use SizeOfHeapTid for space calculations.  Similar comments apply for * the other xl_FOO structs. */typedef struct xl_heaptid{	RelFileNode node;	ItemPointerData tid;		/* changed tuple id */} xl_heaptid;#define SizeOfHeapTid		(offsetof(xl_heaptid, tid) + SizeOfIptrData)/* This is what we need to know about delete */typedef struct xl_heap_delete{	xl_heaptid	target;			/* deleted tuple id */} xl_heap_delete;#define SizeOfHeapDelete	(offsetof(xl_heap_delete, target) + SizeOfHeapTid)/* * We don't store the whole fixed part (HeapTupleHeaderData) of an inserted * or updated tuple in WAL; we can save a few bytes by reconstructing the * fields that are available elsewhere in the WAL record, or perhaps just * plain needn't be reconstructed.  These are the fields we must store. * NOTE: t_hoff could be recomputed, but we may as well store it because * it will come for free due to alignment considerations. */typedef struct xl_heap_header{	int16		t_natts;	uint16		t_infomask;	uint8		t_hoff;} xl_heap_header;#define SizeOfHeapHeader	(offsetof(xl_heap_header, t_hoff) + sizeof(uint8))/* This is what we need to know about insert */typedef struct xl_heap_insert{	xl_heaptid	target;			/* inserted tuple id */	/* xl_heap_header & TUPLE DATA FOLLOWS AT END OF STRUCT */} xl_heap_insert;#define SizeOfHeapInsert	(offsetof(xl_heap_insert, target) + SizeOfHeapTid)/* This is what we need to know about update|move */typedef struct xl_heap_update{	xl_heaptid	target;			/* deleted tuple id */	ItemPointerData newtid;		/* new inserted tuple id */	/* NEW TUPLE xl_heap_header (PLUS xmax & xmin IF MOVE OP) */	/* and TUPLE DATA FOLLOWS AT END OF STRUCT */} xl_heap_update;#define SizeOfHeapUpdate	(offsetof(xl_heap_update, newtid) + SizeOfIptrData)/* This is what we need to know about vacuum page cleanup */typedef struct xl_heap_clean{	RelFileNode node;	BlockNumber block;	/* UNUSED OFFSET NUMBERS FOLLOW AT THE END */} xl_heap_clean;#define SizeOfHeapClean (offsetof(xl_heap_clean, block) + sizeof(BlockNumber))/* This is for replacing a page's contents in toto *//* NB: this is used for indexes as well as heaps */typedef struct xl_heap_newpage{	RelFileNode node;	BlockNumber blkno;			/* location of new page */	/* entire page contents follow at end of record */} xl_heap_newpage;#define SizeOfHeapNewpage	(offsetof(xl_heap_newpage, blkno) + sizeof(BlockNumber))/* This is what we need to know about lock */typedef struct xl_heap_lock{	xl_heaptid	target;			/* locked tuple id */	TransactionId locking_xid;	/* might be a MultiXactId not xid */	bool		xid_is_mxact;	/* is it? */	bool		shared_lock;	/* shared or exclusive row lock? */} xl_heap_lock;#define SizeOfHeapLock	(offsetof(xl_heap_lock, shared_lock) + sizeof(bool))#endif   /* HTUP_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -