PostgreSQL Source Code  git master
itemptr.h File Reference
#include "storage/block.h"
#include "storage/off.h"
Include dependency graph for itemptr.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ItemPointerData
 

Macros

#define SpecTokenOffsetNumber   0xfffe
 
#define MovedPartitionsOffsetNumber   0xfffd
 
#define MovedPartitionsBlockNumber   InvalidBlockNumber
 
#define ItemPointerIsValid(pointer)    ((bool) (PointerIsValid(pointer) && ((pointer)->ip_posid != 0)))
 
#define ItemPointerGetBlockNumberNoCheck(pointer)
 
#define ItemPointerGetBlockNumber(pointer)
 
#define ItemPointerGetOffsetNumberNoCheck(pointer)
 
#define ItemPointerGetOffsetNumber(pointer)
 
#define ItemPointerSet(pointer, blockNumber, offNum)
 
#define ItemPointerSetBlockNumber(pointer, blockNumber)
 
#define ItemPointerSetOffsetNumber(pointer, offsetNumber)
 
#define ItemPointerCopy(fromPointer, toPointer)
 
#define ItemPointerSetInvalid(pointer)
 
#define ItemPointerIndicatesMovedPartitions(pointer)
 
#define ItemPointerSetMovedPartitions(pointer)    ItemPointerSet((pointer), MovedPartitionsBlockNumber, MovedPartitionsOffsetNumber)
 

Typedefs

typedef struct ItemPointerData ItemPointerData
 
typedef ItemPointerDataItemPointer
 

Functions

bool ItemPointerEquals (ItemPointer pointer1, ItemPointer pointer2)
 
int32 ItemPointerCompare (ItemPointer arg1, ItemPointer arg2)
 
void ItemPointerInc (ItemPointer pointer)
 
void ItemPointerDec (ItemPointer pointer)
 

Macro Definition Documentation

◆ ItemPointerCopy

#define ItemPointerCopy (   fromPointer,
  toPointer 
)
Value:
( \
AssertMacro(PointerIsValid(toPointer)), \
AssertMacro(PointerIsValid(fromPointer)), \
*(toPointer) = *(fromPointer) \
)
#define PointerIsValid(pointer)
Definition: c.h:698

Definition at line 161 of file itemptr.h.

◆ ItemPointerGetBlockNumber

#define ItemPointerGetBlockNumber (   pointer)
Value:
( \
AssertMacro(ItemPointerIsValid(pointer)), \
ItemPointerGetBlockNumberNoCheck(pointer) \
)
#define ItemPointerIsValid(pointer)
Definition: itemptr.h:82

Definition at line 98 of file itemptr.h.

◆ ItemPointerGetBlockNumberNoCheck

#define ItemPointerGetBlockNumberNoCheck (   pointer)
Value:
( \
BlockIdGetBlockNumber(&(pointer)->ip_blkid) \
)

Definition at line 89 of file itemptr.h.

◆ ItemPointerGetOffsetNumber

#define ItemPointerGetOffsetNumber (   pointer)
Value:
( \
AssertMacro(ItemPointerIsValid(pointer)), \
ItemPointerGetOffsetNumberNoCheck(pointer) \
)

Definition at line 117 of file itemptr.h.

◆ ItemPointerGetOffsetNumberNoCheck

#define ItemPointerGetOffsetNumberNoCheck (   pointer)
Value:
( \
(pointer)->ip_posid \
)

Definition at line 108 of file itemptr.h.

◆ ItemPointerIndicatesMovedPartitions

#define ItemPointerIndicatesMovedPartitions (   pointer)
Value:
( \
ItemPointerGetOffsetNumber(pointer) == MovedPartitionsOffsetNumber && \
ItemPointerGetBlockNumberNoCheck(pointer) == MovedPartitionsBlockNumber \
)
#define MovedPartitionsOffsetNumber
Definition: itemptr.h:69
#define MovedPartitionsBlockNumber
Definition: itemptr.h:70

Definition at line 184 of file itemptr.h.

◆ ItemPointerIsValid

#define ItemPointerIsValid (   pointer)     ((bool) (PointerIsValid(pointer) && ((pointer)->ip_posid != 0)))

Definition at line 82 of file itemptr.h.

◆ ItemPointerSet

#define ItemPointerSet (   pointer,
  blockNumber,
  offNum 
)
Value:
( \
AssertMacro(PointerIsValid(pointer)), \
BlockIdSet(&((pointer)->ip_blkid), blockNumber), \
(pointer)->ip_posid = offNum \
)

Definition at line 127 of file itemptr.h.

◆ ItemPointerSetBlockNumber

#define ItemPointerSetBlockNumber (   pointer,
  blockNumber 
)
Value:
( \
AssertMacro(PointerIsValid(pointer)), \
BlockIdSet(&((pointer)->ip_blkid), blockNumber) \
)

Definition at line 138 of file itemptr.h.

◆ ItemPointerSetInvalid

#define ItemPointerSetInvalid (   pointer)
Value:
( \
AssertMacro(PointerIsValid(pointer)), \
BlockIdSet(&((pointer)->ip_blkid), InvalidBlockNumber), \
(pointer)->ip_posid = InvalidOffsetNumber \
)
#define InvalidBlockNumber
Definition: block.h:33
#define InvalidOffsetNumber
Definition: off.h:26

Definition at line 172 of file itemptr.h.

◆ ItemPointerSetMovedPartitions

#define ItemPointerSetMovedPartitions (   pointer)     ItemPointerSet((pointer), MovedPartitionsBlockNumber, MovedPartitionsOffsetNumber)

Definition at line 195 of file itemptr.h.

◆ ItemPointerSetOffsetNumber

#define ItemPointerSetOffsetNumber (   pointer,
  offsetNumber 
)
Value:
( \
AssertMacro(PointerIsValid(pointer)), \
(pointer)->ip_posid = (offsetNumber) \
)

Definition at line 148 of file itemptr.h.

◆ MovedPartitionsBlockNumber

#define MovedPartitionsBlockNumber   InvalidBlockNumber

Definition at line 70 of file itemptr.h.

◆ MovedPartitionsOffsetNumber

#define MovedPartitionsOffsetNumber   0xfffd

Definition at line 69 of file itemptr.h.

◆ SpecTokenOffsetNumber

#define SpecTokenOffsetNumber   0xfffe

Definition at line 63 of file itemptr.h.

Typedef Documentation

◆ ItemPointer

Definition at line 49 of file itemptr.h.

◆ ItemPointerData

Function Documentation

◆ ItemPointerCompare()

int32 ItemPointerCompare ( ItemPointer  arg1,
ItemPointer  arg2 
)

Definition at line 52 of file itemptr.c.

53 {
54  /*
55  * Use ItemPointerGet{Offset,Block}NumberNoCheck to avoid asserting
56  * ip_posid != 0, which may not be true for a user-supplied TID.
57  */
60 
61  if (b1 < b2)
62  return -1;
63  else if (b1 > b2)
64  return 1;
65  else if (ItemPointerGetOffsetNumberNoCheck(arg1) <
67  return -1;
68  else if (ItemPointerGetOffsetNumberNoCheck(arg1) >
70  return 1;
71  else
72  return 0;
73 }
uint32 BlockNumber
Definition: block.h:31
#define ItemPointerGetBlockNumberNoCheck(pointer)
Definition: itemptr.h:89
#define ItemPointerGetOffsetNumberNoCheck(pointer)
Definition: itemptr.h:108

References ItemPointerGetBlockNumberNoCheck, and ItemPointerGetOffsetNumberNoCheck.

Referenced by _bt_binsrch_posting(), _bt_check_unique(), _bt_compare(), _bt_delitems_delete_check(), _bt_load(), _bt_split(), _bt_swap_posting(), _bt_truncate(), brin_minmax_multi_distance_tid(), bt_target_page_check(), bttidcmp(), dataBeginPlaceToPageLeaf(), heap_getnextslot_tidrange(), heap_set_tidrange(), heapam_index_validate_scan(), tidcmp(), tideq(), tidge(), tidgt(), tidlarger(), tidle(), tidlt(), tidne(), TidRangeEval(), and tidsmaller().

◆ ItemPointerDec()

void ItemPointerDec ( ItemPointer  pointer)

Definition at line 115 of file itemptr.c.

116 {
119 
120  if (off == 0)
121  {
122  if (blk != 0)
123  {
124  off = PG_UINT16_MAX;
125  blk--;
126  }
127  }
128  else
129  off--;
130 
131  ItemPointerSet(pointer, blk, off);
132 }
#define PG_UINT16_MAX
Definition: c.h:522
#define ItemPointerSet(pointer, blockNumber, offNum)
Definition: itemptr.h:127
uint16 OffsetNumber
Definition: off.h:24

References ItemPointerGetBlockNumberNoCheck, ItemPointerGetOffsetNumberNoCheck, ItemPointerSet, and PG_UINT16_MAX.

Referenced by TidRangeEval().

◆ ItemPointerEquals()

bool ItemPointerEquals ( ItemPointer  pointer1,
ItemPointer  pointer2 
)

Definition at line 29 of file itemptr.c.

30 {
31  /*
32  * We really want ItemPointerData to be exactly 6 bytes. This is rather a
33  * random place to check, but there is no better place.
34  */
35  StaticAssertStmt(sizeof(ItemPointerData) == 3 * sizeof(uint16),
36  "ItemPointerData struct is improperly padded");
37 
38  if (ItemPointerGetBlockNumber(pointer1) ==
39  ItemPointerGetBlockNumber(pointer2) &&
40  ItemPointerGetOffsetNumber(pointer1) ==
42  return true;
43  else
44  return false;
45 }
unsigned short uint16
Definition: c.h:440
#define StaticAssertStmt(condition, errmessage)
Definition: c.h:918
#define ItemPointerGetBlockNumber(pointer)
Definition: itemptr.h:98
#define ItemPointerGetOffsetNumber(pointer)
Definition: itemptr.h:117

References ItemPointerGetBlockNumber, ItemPointerGetOffsetNumber, and StaticAssertStmt.

Referenced by _bt_delitems_delete_check(), _bt_killitems(), _hash_kill_items(), brinGetTupleForHeapBlock(), check_exclusion_or_unique_constraint(), collectMatchesForHeapRow(), compile_pltcl_function(), gistplacetopage(), heap_delete(), heap_get_latest_tid(), heap_lock_tuple(), heap_lock_updated_tuple(), heap_lock_updated_tuple_rec(), heap_update(), heapam_tuple_lock(), HeapTupleSatisfiesUpdate(), index_getnext_slot(), lookup_C_func(), plpgsql_compile(), PLy_procedure_valid(), processPendingPage(), rewrite_heap_tuple(), scanGetCandidate(), SearchCatCacheList(), spgAddPendingTID(), test_itemptr_pair(), test_lockmode_for_conflict(), and validate_plperl_function().

◆ ItemPointerInc()

void ItemPointerInc ( ItemPointer  pointer)

Definition at line 85 of file itemptr.c.

86 {
89 
90  if (off == PG_UINT16_MAX)
91  {
92  if (blk != InvalidBlockNumber)
93  {
94  off = 0;
95  blk++;
96  }
97  }
98  else
99  off++;
100 
101  ItemPointerSet(pointer, blk, off);
102 }

References InvalidBlockNumber, ItemPointerGetBlockNumberNoCheck, ItemPointerGetOffsetNumberNoCheck, ItemPointerSet, and PG_UINT16_MAX.

Referenced by TidRangeEval().