PostgreSQL Source Code git master
Loading...
Searching...
No Matches
hio.h File Reference
#include "access/htup.h"
#include "storage/buf.h"
#include "utils/relcache.h"
Include dependency graph for hio.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  BulkInsertStateData
 

Typedefs

typedef struct BulkInsertStateData BulkInsertStateData
 

Functions

void RelationPutHeapTuple (Relation relation, Buffer buffer, HeapTuple tuple, bool token)
 
Buffer RelationGetBufferForTuple (Relation relation, Size len, Buffer otherBuffer, int options, BulkInsertStateData *bistate, Buffer *vmbuffer, Buffer *vmbuffer_other, int num_pages)
 

Typedef Documentation

◆ BulkInsertStateData

Function Documentation

◆ RelationGetBufferForTuple()

Buffer RelationGetBufferForTuple ( Relation  relation,
Size  len,
Buffer  otherBuffer,
int  options,
BulkInsertStateData bistate,
Buffer vmbuffer,
Buffer vmbuffer_other,
int  num_pages 
)
extern

◆ RelationPutHeapTuple()

void RelationPutHeapTuple ( Relation  relation,
Buffer  buffer,
HeapTuple  tuple,
bool  token 
)
extern

Definition at line 35 of file hio.c.

39{
41 OffsetNumber offnum;
42
43 /*
44 * A tuple that's being inserted speculatively should already have its
45 * token set.
46 */
48
49 /*
50 * Do not allow tuples with invalid combinations of hint bits to be placed
51 * on a page. This combination is detected as corruption by the
52 * contrib/amcheck logic, so if you disable this assertion, make
53 * corresponding changes there.
54 */
57
58 /* Add the tuple to the page */
59 pageHeader = BufferGetPage(buffer);
60
61 offnum = PageAddItem(pageHeader, tuple->t_data, tuple->t_len, InvalidOffsetNumber, false, true);
62 if (offnum == InvalidOffsetNumber)
63 elog(PANIC, "failed to add tuple to page");
64
65 /* Update tuple->t_self to the actual position where it was stored */
66 ItemPointerSet(&(tuple->t_self), BufferGetBlockNumber(buffer), offnum);
67
68 /*
69 * Insert the correct position into CTID of the stored tuple, too (unless
70 * this is a speculative insertion, in which case the token is held in
71 * CTID field instead)
72 */
73 if (!token)
74 {
77
78 item->t_ctid = tuple->t_self;
79 }
80}
BlockNumber BufferGetBlockNumber(Buffer buffer)
Definition bufmgr.c:4356
static Page BufferGetPage(Buffer buffer)
Definition bufmgr.h:466
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
Definition bufpage.h:243
static void * PageGetItem(PageData *page, const ItemIdData *itemId)
Definition bufpage.h:353
PageData * Page
Definition bufpage.h:81
#define PageAddItem(page, item, size, offsetNumber, overwrite, is_heap)
Definition bufpage.h:471
#define Assert(condition)
Definition c.h:873
#define PANIC
Definition elog.h:42
#define elog(elevel,...)
Definition elog.h:226
HeapTupleHeaderData * HeapTupleHeader
Definition htup.h:23
#define HEAP_XMAX_IS_MULTI
#define HEAP_XMAX_COMMITTED
static bool HeapTupleHeaderIsSpeculative(const HeapTupleHeaderData *tup)
static void ItemPointerSet(ItemPointerData *pointer, BlockNumber blockNumber, OffsetNumber offNum)
Definition itemptr.h:135
#define InvalidOffsetNumber
Definition off.h:26
uint16 OffsetNumber
Definition off.h:24
static int fb(int x)
ItemPointerData t_self
Definition htup.h:65
uint32 t_len
Definition htup.h:64
HeapTupleHeader t_data
Definition htup.h:68
ItemPointerData t_ctid

References Assert, BufferGetBlockNumber(), BufferGetPage(), elog, fb(), HEAP_XMAX_COMMITTED, HEAP_XMAX_IS_MULTI, HeapTupleHeaderIsSpeculative(), InvalidOffsetNumber, ItemPointerSet(), PageAddItem, PageGetItem(), PageGetItemId(), PANIC, HeapTupleHeaderData::t_ctid, HeapTupleData::t_data, HeapTupleHeaderData::t_infomask, HeapTupleData::t_len, and HeapTupleData::t_self.

Referenced by heap_insert(), heap_multi_insert(), and heap_update().