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

◆ 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.

Referenced by _bt_adjacenthtid(), _bt_bottomupdel_finish_pending(), _bt_check_third_page(), _bt_deadblocks(), _bt_simpledel_pass(), bottomup_nblocksfavorable(), bottomup_sort_and_shrink(), brinbuildCallback(), brinGetTupleForHeapBlock(), brininsert(), brinRevmapDesummarizeRange(), brinSetHeapBlockItemptr(), bt_normalize_tuple(), bt_target_page_check(), bt_tuple_present_callback(), CheckForSerializableConflictIn(), compare_rows(), comparetup_index_btree(), comparetup_index_hash(), ConditionalLockTuple(), doPickSplit(), get_actual_variable_endpoint(), gin_desc(), gingetbitmap(), gistBufferingFindCorrectParent(), gistbufferinginserttuples(), gistdeletepage(), gistdoinsert(), gistFindCorrectParent(), gistFindPath(), gistGetMaxLevel(), gistMemorizeAllDownlinks(), gistProcessItup(), gistScanPage(), gistvacuum_delete_empty_pages(), heap2_desc(), heap_abort_speculative(), heap_delete(), heap_fetch(), heap_finish_speculative(), heap_get_latest_tid(), heap_hot_search_buffer(), heap_index_delete_tuples(), heap_inplace_update(), heap_insert(), heap_lock_tuple(), heap_lock_updated_tuple_rec(), heap_prune_chain(), heap_update(), heapam_index_build_range_scan(), heapam_index_fetch_tuple(), heapam_index_validate_scan(), heapam_tuple_lock(), heapam_tuple_tid_valid(), heapgettup(), heapgettup_pagemode(), HeapTupleHeaderAdvanceLatestRemovedXid(), index_delete_sort_cmp(), IndexOnlyNext(), ItemPointerEquals(), itemptr_comparator(), itemptr_encode(), lazy_vacuum_heap_page(), lazy_vacuum_heap_rel(), LockTuple(), pgstat_heap(), PredicateLockTID(), PrintCatCacheLeakWarning(), ResolveCminCmaxDuringDecoding(), setRedirectionTuple(), spgMatchNodeAction(), spgprocesspending(), spgTestLeafTuple(), spgWalk(), tbm_add_tuples(), test_itemptr_pair(), UnlockTuple(), vac_cmp_itemptr(), and XactLockTableWaitErrorCb().

◆ ItemPointerGetBlockNumberNoCheck

◆ ItemPointerGetOffsetNumber

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

Definition at line 117 of file itemptr.h.

Referenced by _bt_adjacenthtid(), _bt_check_natts(), _bt_check_third_page(), _bt_truncate(), brinGetTupleForHeapBlock(), brininsert(), brinRevmapDesummarizeRange(), brinSetHeapBlockItemptr(), bt_normalize_tuple(), bt_target_page_check(), bt_tuple_present_callback(), CheckForSerializableConflictIn(), compare_rows(), comparetup_index_btree(), comparetup_index_hash(), ConditionalLockTuple(), doPickSplit(), gin_desc(), ginPostingListDecodeAllSegments(), heap2_desc(), heap_abort_speculative(), heap_delete(), heap_fetch(), heap_finish_speculative(), heap_get_latest_tid(), heap_get_root_tuples(), heap_hot_search_buffer(), heap_index_delete_tuples(), heap_inplace_update(), heap_insert(), heap_lock_tuple(), heap_lock_updated_tuple_rec(), heap_multi_insert(), heap_prune_chain(), heap_update(), heapam_index_build_range_scan(), heapam_index_validate_scan(), heapam_scan_bitmap_next_block(), heapam_tuple_lock(), heapgettup(), heapgettup_pagemode(), index_delete_sort_cmp(), ItemPointerEquals(), itemptr_comparator(), itemptr_encode(), lazy_vacuum_heap_page(), LockTuple(), log_heap_update(), PredicateLockTID(), PrintCatCacheLeakWarning(), spgMatchNodeAction(), spgprocesspending(), spgTestLeafTuple(), spgWalk(), tbm_add_tuples(), test_itemptr_pair(), UnlockTuple(), vac_cmp_itemptr(), and XactLockTableWaitErrorCb().

◆ ItemPointerGetOffsetNumberNoCheck

◆ 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.

Referenced by ExecOnConflictUpdate(), heapam_tuple_lock(), RelationFindReplTupleByIndex(), and RelationFindReplTupleSeq().

◆ ItemPointerIsValid

◆ ItemPointerSet

◆ ItemPointerSetBlockNumber

#define ItemPointerSetBlockNumber (   pointer,
  blockNumber 
)
Value:
( \
AssertMacro(PointerIsValid(pointer)), \
BlockIdSet(&((pointer)->ip_blkid), blockNumber) \
)
#define PointerIsValid(pointer)
Definition: c.h:698

Definition at line 138 of file itemptr.h.

Referenced by BTreeTupleSetDownLink(), BTreeTupleSetPosting(), BTreeTupleSetTopParent(), gist_indexsortbuild_pagestate_flush(), gistformdownlink(), gistplacetopage(), heap_xlog_delete(), heap_xlog_insert(), heap_xlog_multi_insert(), and lazy_scan_prune().

◆ ItemPointerSetInvalid

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

Definition at line 172 of file itemptr.h.

Referenced by AfterTriggerSaveEvent(), brin_xlog_desummarize_page(), brinGetTupleForHeapBlock(), brinRevmapDesummarizeRange(), brinSetHeapBlockItemptr(), DecodeMultiInsert(), DecodeXLogTuple(), deconstruct_composite_datum(), end_heap_rewrite(), entryGetItem(), ER_flatten_into(), exec_move_row_from_datum(), ExecCheckIndexConstraints(), ExecEvalFieldStoreDeForm(), ExecLockRows(), ExecModifyTable(), ExecuteCallStmt(), expand_tuple(), GetAttributeByName(), GetAttributeByNum(), hash_record(), hash_record_extended(), heap_form_tuple(), heap_tuple_from_minimal_tuple(), hstore_from_record(), hstore_populate_record(), InitPlan(), initscan(), leafRepackItems(), make_expanded_record_from_datum(), make_tuple_indirect(), populate_record(), populate_recordset_record(), processPendingPage(), record_cmp(), record_eq(), record_image_cmp(), record_image_eq(), record_out(), record_send(), rewrite_heap_tuple(), scanGetCandidate(), spgFormDeadTuple(), spgFormNodeTuple(), spgRedoVacuumRedirect(), statext_expressions_load(), toast_flatten_tuple_to_datum(), tts_buffer_heap_clear(), tts_heap_clear(), tts_minimal_clear(), tts_virtual_clear(), unique_key_recheck(), and vacuumRedirectAndPlaceholder().

◆ 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) \
)
#define PointerIsValid(pointer)
Definition: c.h:698

Definition at line 148 of file itemptr.h.

Referenced by _bt_truncate(), BTreeTupleSetNAtts(), BTreeTupleSetPosting(), gistFormTuple(), heap_hot_search_buffer(), heap_xlog_delete(), heap_xlog_insert(), heap_xlog_multi_insert(), heapam_index_validate_scan(), and lazy_scan_prune().

◆ 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.

Referenced by heap_finish_speculative().

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.

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