PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 PG_GETARG_ITEMPOINTER(n)   DatumGetItemPointer(PG_GETARG_DATUM(n))
 
#define PG_RETURN_ITEMPOINTER(x)   return ItemPointerGetDatum(x)
 

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)
 
static ItemPointer DatumGetItemPointer (Datum X)
 
static Datum ItemPointerGetDatum (const ItemPointerData *X)
 

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.

◆ PG_GETARG_ITEMPOINTER

#define PG_GETARG_ITEMPOINTER (   n)    DatumGetItemPointer(PG_GETARG_DATUM(n))

Definition at line 242 of file itemptr.h.

◆ PG_RETURN_ITEMPOINTER

#define PG_RETURN_ITEMPOINTER (   x)    return ItemPointerGetDatum(x)

Definition at line 243 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

◆ DatumGetItemPointer()

static ItemPointer DatumGetItemPointer ( Datum  X)
inlinestatic

Definition at line 231 of file itemptr.h.

232 {
233  return (ItemPointer) DatumGetPointer(X);
234 }
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:312

References DatumGetPointer().

◆ ItemPointerCompare()

int32 ItemPointerCompare ( ItemPointer  arg1,
ItemPointer  arg2 
)

Definition at line 51 of file itemptr.c.

52 {
53  /*
54  * Use ItemPointerGet{Offset,Block}NumberNoCheck to avoid asserting
55  * ip_posid != 0, which may not be true for a user-supplied TID.
56  */
59 
60  if (b1 < b2)
61  return -1;
62  else if (b1 > b2)
63  return 1;
64  else if (ItemPointerGetOffsetNumberNoCheck(arg1) <
66  return -1;
67  else if (ItemPointerGetOffsetNumberNoCheck(arg1) >
69  return 1;
70  else
71  return 0;
72 }
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()

static void ItemPointerCopy ( const ItemPointerData fromPointer,
ItemPointerData toPointer 
)
inlinestatic

◆ ItemPointerDec()

void ItemPointerDec ( ItemPointer  pointer)

Definition at line 114 of file itemptr.c.

115 {
118 
119  if (off == 0)
120  {
121  if (blk != 0)
122  {
123  off = PG_UINT16_MAX;
124  blk--;
125  }
126  }
127  else
128  off--;
129 
130  ItemPointerSet(pointer, blk, off);
131 }
#define PG_UINT16_MAX
Definition: c.h:592
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()

◆ 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(), brinbuildCallbackParallel(), brinGetTupleForHeapBlock(), brininsert(), brinRevmapDesummarizeRange(), brinSetHeapBlockItemptr(), bt_normalize_tuple(), bt_target_page_check(), bt_tuple_present_callback(), check_set_block_offsets(), CheckForSerializableConflictIn(), compare_rows(), comparetup_index_btree_tiebreak(), 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_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(), index_delete_check_htid(), index_delete_sort_cmp(), IndexOnlyNext(), ItemPointerEquals(), itemptr_cmp(), itemptr_comparator(), itemptr_encode(), LockTuple(), pgstat_heap(), PredicateLockTID(), purge_from_verification_array(), ResolveCminCmaxDuringDecoding(), ResOwnerPrintCatCache(), SearchSysCacheLocked1(), setRedirectionTuple(), spgMatchNodeAction(), spgprocesspending(), spgTestLeafTuple(), spgWalk(), tbm_add_tuples(), test_itemptr_pair(), TidStoreIsMember(), UnlockTuple(), verify_heapam(), and XactLockTableWaitErrorCb().

◆ ItemPointerGetBlockNumberNoCheck()

◆ ItemPointerGetDatum()

static Datum ItemPointerGetDatum ( const ItemPointerData X)
inlinestatic

Definition at line 237 of file itemptr.h.

238 {
239  return PointerGetDatum(X);
240 }
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:322

References PointerGetDatum().

Referenced by bt_page_print_tuples(), gin_leafpage_items(), gist_page_items(), and gist_page_items_bytea().

◆ 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(), check_set_block_offsets(), CheckForSerializableConflictIn(), compare_rows(), comparetup_index_btree_tiebreak(), 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_and_unlock(), 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(), index_delete_check_htid(), index_delete_sort_cmp(), ItemPointerEquals(), ItemPointerIndicatesMovedPartitions(), itemptr_cmp(), itemptr_comparator(), itemptr_encode(), LockTuple(), log_heap_update(), PredicateLockTID(), ResOwnerPrintCatCache(), SearchSysCacheLocked1(), spgMatchNodeAction(), spgprocesspending(), spgTestLeafTuple(), spgWalk(), tbm_add_tuples(), test_itemptr_pair(), TidStoreIsMember(), UnlockTuple(), verify_heapam(), and XactLockTableWaitErrorCb().

◆ ItemPointerGetOffsetNumberNoCheck()

◆ ItemPointerInc()

void ItemPointerInc ( ItemPointer  pointer)

Definition at line 84 of file itemptr.c.

85 {
88 
89  if (off == PG_UINT16_MAX)
90  {
91  if (blk != InvalidBlockNumber)
92  {
93  off = 0;
94  blk++;
95  }
96  }
97  else
98  off++;
99 
100  ItemPointerSet(pointer, blk, off);
101 }
#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()

static bool ItemPointerIsValid ( const ItemPointerData pointer)
inlinestatic

◆ ItemPointerSet()

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

◆ ItemPointerSetBlockNumber()

static void ItemPointerSetBlockNumber ( ItemPointerData pointer,
BlockNumber  blockNumber 
)
inlinestatic

◆ 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(), ExecInsert(), ExecLockRows(), ExecMergeMatched(), 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(), SearchSysCacheLocked1(), 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