PostgreSQL Source Code  git master
itemptr.c File Reference
#include "postgres.h"
#include "storage/itemptr.h"
Include dependency graph for itemptr.c:

Go to the source code of this file.

Functions

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

Function Documentation

◆ ItemPointerCompare()

int32 ItemPointerCompare ( ItemPointer  arg1,
ItemPointer  arg2 
)

Definition at line 52 of file itemptr.c.

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().

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 }
#define ItemPointerGetOffsetNumberNoCheck(pointer)
Definition: itemptr.h:108
uint32 BlockNumber
Definition: block.h:31
#define ItemPointerGetBlockNumberNoCheck(pointer)
Definition: itemptr.h:89

◆ ItemPointerDec()

void ItemPointerDec ( ItemPointer  pointer)

Definition at line 115 of file itemptr.c.

References ItemPointerGetBlockNumberNoCheck, ItemPointerGetOffsetNumberNoCheck, ItemPointerSet, and PG_UINT16_MAX.

Referenced by TidRangeEval().

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 ItemPointerGetOffsetNumberNoCheck(pointer)
Definition: itemptr.h:108
uint32 BlockNumber
Definition: block.h:31
uint16 OffsetNumber
Definition: off.h:24
#define PG_UINT16_MAX
Definition: c.h:522
#define ItemPointerGetBlockNumberNoCheck(pointer)
Definition: itemptr.h:89
#define ItemPointerSet(pointer, blockNumber, offNum)
Definition: itemptr.h:127

◆ ItemPointerEquals()

bool ItemPointerEquals ( ItemPointer  pointer1,
ItemPointer  pointer2 
)

Definition at line 29 of file itemptr.c.

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().

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 }
#define StaticAssertStmt(condition, errmessage)
Definition: c.h:918
unsigned short uint16
Definition: c.h:440
#define ItemPointerGetOffsetNumber(pointer)
Definition: itemptr.h:117
#define ItemPointerGetBlockNumber(pointer)
Definition: itemptr.h:98

◆ ItemPointerInc()

void ItemPointerInc ( ItemPointer  pointer)

Definition at line 85 of file itemptr.c.

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

Referenced by TidRangeEval().

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 }
#define ItemPointerGetOffsetNumberNoCheck(pointer)
Definition: itemptr.h:108
uint32 BlockNumber
Definition: block.h:31
uint16 OffsetNumber
Definition: off.h:24
#define PG_UINT16_MAX
Definition: c.h:522
#define InvalidBlockNumber
Definition: block.h:33
#define ItemPointerGetBlockNumberNoCheck(pointer)
Definition: itemptr.h:89
#define ItemPointerSet(pointer, blockNumber, offNum)
Definition: itemptr.h:127