PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
off.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * off.h
4  * POSTGRES disk "offset" definitions.
5  *
6  *
7  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/storage/off.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef OFF_H
15 #define OFF_H
16 
17 #include "storage/itemid.h"
18 /*
19  * OffsetNumber:
20  *
21  * this is a 1-based index into the linp (ItemIdData) array in the
22  * header of each disk page.
23  */
25 
26 #define InvalidOffsetNumber ((OffsetNumber) 0)
27 #define FirstOffsetNumber ((OffsetNumber) 1)
28 #define MaxOffsetNumber ((OffsetNumber) (BLCKSZ / sizeof(ItemIdData)))
29 
30 /* ----------------
31  * support macros
32  * ----------------
33  */
34 
35 /*
36  * OffsetNumberIsValid
37  * True iff the offset number is valid.
38  */
39 #define OffsetNumberIsValid(offsetNumber) \
40  ((bool) ((offsetNumber != InvalidOffsetNumber) && \
41  (offsetNumber <= MaxOffsetNumber)))
42 
43 /*
44  * OffsetNumberNext
45  * OffsetNumberPrev
46  * Increments/decrements the argument. These macros look pointless
47  * but they help us disambiguate the different manipulations on
48  * OffsetNumbers (e.g., sometimes we subtract one from an
49  * OffsetNumber to move back, and sometimes we do so to form a
50  * real C array index).
51  */
52 #define OffsetNumberNext(offsetNumber) \
53  ((OffsetNumber) (1 + (offsetNumber)))
54 #define OffsetNumberPrev(offsetNumber) \
55  ((OffsetNumber) (-1 + (offsetNumber)))
56 
57 #endif /* OFF_H */
unsigned short uint16
Definition: c.h:517
uint16 OffsetNumber
Definition: off.h:24