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
 

Typedefs

typedef struct ItemPointerData ItemPointerData
 
typedef ItemPointerDataItemPointer
 

Functions

static bool ItemPointerIsValid (const ItemPointerData *pointer)
 
static BlockNumber ItemPointerGetBlockNumberNoCheck (const ItemPointerData *pointer)
 
static BlockNumber ItemPointerGetBlockNumber (const ItemPointerData *pointer)
 
static OffsetNumber ItemPointerGetOffsetNumberNoCheck (const ItemPointerData *pointer)
 
static OffsetNumber ItemPointerGetOffsetNumber (const ItemPointerData *pointer)
 
static void ItemPointerSet (ItemPointerData *pointer, BlockNumber blockNumber, OffsetNumber offNum)
 
static void ItemPointerSetBlockNumber (ItemPointerData *pointer, BlockNumber blockNumber)
 
static void ItemPointerSetOffsetNumber (ItemPointerData *pointer, OffsetNumber offsetNumber)
 
static void ItemPointerCopy (const ItemPointerData *fromPointer, ItemPointerData *toPointer)
 
static void ItemPointerSetInvalid (ItemPointerData *pointer)
 
static bool ItemPointerIndicatesMovedPartitions (const ItemPointerData *pointer)
 
static void ItemPointerSetMovedPartitions (ItemPointerData *pointer)
 
bool ItemPointerEquals (ItemPointer pointer1, ItemPointer pointer2)
 
int32 ItemPointerCompare (ItemPointer arg1, ItemPointer arg2)
 
void ItemPointerInc (ItemPointer pointer)
 
void ItemPointerDec (ItemPointer pointer)
 

Macro Definition Documentation

◆ 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
static OffsetNumber ItemPointerGetOffsetNumberNoCheck(const ItemPointerData *pointer)
Definition: itemptr.h:114
static BlockNumber ItemPointerGetBlockNumberNoCheck(const ItemPointerData *pointer)
Definition: itemptr.h:93

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

◆ ItemPointerCopy()

◆ 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:523
static void ItemPointerSet(ItemPointerData *pointer, BlockNumber blockNumber, OffsetNumber offNum)
Definition: itemptr.h:135
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:441
#define StaticAssertStmt(condition, errmessage)
Definition: c.h:908
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
Definition: itemptr.h:124
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
Definition: itemptr.h:103

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

◆ ItemPointerGetBlockNumber()

static BlockNumber ItemPointerGetBlockNumber ( const ItemPointerData pointer)
inlinestatic

Definition at line 103 of file itemptr.h.

104 {
105  Assert(ItemPointerIsValid(pointer));
106  return ItemPointerGetBlockNumberNoCheck(pointer);
107 }
static bool ItemPointerIsValid(const ItemPointerData *pointer)
Definition: itemptr.h:83

References Assert(), ItemPointerGetBlockNumberNoCheck(), and ItemPointerIsValid().

Referenced by _bt_adjacenthtid(), _bt_binsrch_insert(), _bt_bottomupdel_finish_pending(), _bt_check_third_page(), _bt_deadblocks(), _bt_insertonpg(), _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(), index_delete_check_htid(), 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()

static OffsetNumber ItemPointerGetOffsetNumber ( const ItemPointerData pointer)
inlinestatic

Definition at line 124 of file itemptr.h.

125 {
126  Assert(ItemPointerIsValid(pointer));
127  return ItemPointerGetOffsetNumberNoCheck(pointer);
128 }

References Assert(), ItemPointerGetOffsetNumberNoCheck(), and ItemPointerIsValid().

Referenced by _bt_adjacenthtid(), _bt_binsrch_insert(), _bt_check_natts(), _bt_check_third_page(), _bt_insertonpg(), _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_check_htid(), index_delete_sort_cmp(), ItemPointerEquals(), ItemPointerIndicatesMovedPartitions(), 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()

◆ 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 }
#define InvalidBlockNumber
Definition: block.h:33

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

Referenced by TidRangeEval().

◆ ItemPointerIndicatesMovedPartitions()

static bool ItemPointerIndicatesMovedPartitions ( const ItemPointerData pointer)
inlinestatic

◆ ItemPointerIsValid()

◆ ItemPointerSet()

static void ItemPointerSet ( ItemPointerData pointer,
BlockNumber  blockNumber,
OffsetNumber  offNum 
)
inlinestatic

◆ ItemPointerSetBlockNumber()

◆ ItemPointerSetInvalid()

static void ItemPointerSetInvalid ( ItemPointerData pointer)
inlinestatic

Definition at line 184 of file itemptr.h.

185 {
186  Assert(PointerIsValid(pointer));
188  pointer->ip_posid = InvalidOffsetNumber;
189 }
#define InvalidOffsetNumber
Definition: off.h:26

References Assert(), BlockIdSet(), InvalidBlockNumber, InvalidOffsetNumber, ItemPointerData::ip_blkid, ItemPointerData::ip_posid, and PointerIsValid.

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

static void ItemPointerSetMovedPartitions ( ItemPointerData pointer)
inlinestatic

◆ ItemPointerSetOffsetNumber()

static void ItemPointerSetOffsetNumber ( ItemPointerData pointer,
OffsetNumber  offsetNumber 
)
inlinestatic